Merge pull request #2439 from Irastris/menus

Menu fixes
This commit is contained in:
TakaRikka
2026-09-14 15:47:31 -07:00
committed by GitHub
8 changed files with 197 additions and 139 deletions
-1
View File
@@ -207,7 +207,6 @@ public:
bool isClose();
#if TARGET_PC
void presentAnims();
void presentLayoutAnims();
void presentMapView();
#endif
void _draw();
+5 -2
View File
@@ -120,8 +120,11 @@ public:
void _draw();
#if TARGET_PC
void presentAnims();
void presentZoomView();
f32 getRenderZoomLevel() const;
void presentZoomView(u8 process, f32 zoomLevel, f32 zoomBlend);
void captureRenderState();
void captureZoomEnd(u8 process);
void resetRenderState();
void resetZoomEnd();
#endif
u8 getNextStatus(u8*);
bool isSync();
+1
View File
@@ -29,6 +29,7 @@ public:
void _draw();
#if TARGET_PC
void advanceSelectItem();
void captureRenderState();
#endif
void setKanteraPos(f32, f32);
bool isOpen();
+18 -59
View File
@@ -868,6 +868,11 @@ dMenu_DmapBg_c::~dMenu_DmapBg_c() {
}
void dMenu_DmapBg_c::setAllAlphaRate(f32 i_rate, bool param_2) {
#if TARGET_PC
if (!param_2 && i_rate == 1.0f && field_0xd9c == 1.0f) {
return;
}
#endif
field_0xd9c = i_rate;
if (param_2) {
@@ -2035,7 +2040,7 @@ void dMenu_Dmap_c::_move() {
IF_NOT_DUSK(mpDrawBg->addGoldFrameAlphaRate());
mDoExt_setCurrentHeap(prev_heap);
IF_DUSK(dusk::interp::capture_menu_values(this, field_0x104, field_0x108, field_0x10c));
IF_DUSK(dusk::interp::capture_menu_pose(this, {field_0x104, field_0x108, field_0x10c}));
}
void dMenu_Dmap_c::setMapTexture() {
@@ -2197,7 +2202,7 @@ bool dMenu_Dmap_c::isOpen() {
mpDrawBg->setAllAlphaRate(field_0x10c, var_r27);
mpDrawBg->setGoldFrameAlphaRate(0.0f);
IF_DUSK(dusk::interp::capture_menu_values(this, field_0x104, field_0x108, field_0x10c));
IF_DUSK(dusk::interp::capture_menu_pose(this, {field_0x104, field_0x108, field_0x10c}));
return var_r28;
}
@@ -2237,7 +2242,7 @@ bool dMenu_Dmap_c::isClose() {
field_0x10c = temp_f31;
mpDrawBg->setAllAlphaRate(field_0x10c, var_r29);
mpDrawBg->decGoldFrameAlphaRate();
IF_DUSK(dusk::interp::capture_menu_values(this, field_0x104, field_0x108, field_0x10c));
IF_DUSK(dusk::interp::capture_menu_pose(this, {field_0x104, field_0x108, field_0x10c}));
return var_r30;
}
@@ -2270,53 +2275,6 @@ void dMenu_Dmap_c::presentAnims() {
mpDrawBg->iconScaleAnm();
}
}
presentLayoutAnims();
}
void dMenu_Dmap_c::presentLayoutAnims() {
mpDrawBg->setAllTrans(field_0x104, field_0x108);
if (mpDrawBg->mpBackTexture != NULL) {
f32 var_f31 = 100.0f * mpDrawBg->field_0xd88;
f32 sp24 = mpDrawBg->field_0xd80 / var_f31;
f32 sp20 = mpDrawBg->field_0xd84 / var_f31;
const ResTIMG* back_timg = mpDrawBg->mpBackTexture->getTexture(0)->getTexInfo();
field_0x13c = mMapCtrl->getPixelStageSizeX();
field_0x140 = mMapCtrl->getPixelStageSizeZ();
field_0x134 = mMapCtrl->getPixelCenterX();
field_0x138 = mMapCtrl->getPixelCenterZ();
f32 temp_f30;
f32 var_f29;
f32 var_f27;
if (field_0x13c > field_0x140) {
temp_f30 = back_timg->width * var_f31;
var_f29 = mMapCtrl->getStageMapSizeX();
var_f27 = field_0x13c * (temp_f30 / var_f29);
} else {
temp_f30 = back_timg->height * var_f31;
var_f29 = mMapCtrl->getStageMapSizeZ();
var_f27 = field_0x140 * (temp_f30 / var_f29);
}
f32 sp1C[2];
sp1C[0] = var_f27;
sp1C[1] = var_f27;
f32 sp14[2];
sp14[0] = -(field_0x134 + (100.0f * (sp24 * mMapCtrl->getPixelPerCm())));
sp14[1] = -(field_0x138 + 100.0f * (sp20 * mMapCtrl->getPixelPerCm()));
CPaneMgr sp70;
//!@bug It's unclear what this is supposed to be, but a stack pointer being converted to a bool is probably not intended.
u8 sp40[0x30];
Vec sp34 = sp70.getGlobalVtxCenter(mpDrawBg->getMapPane(), (bool)sp40, 0);
mpDrawBg->mpBackTexture->move(sp14[0] + (sp34.x - (sp1C[0] / 2)),
sp14[1] + (sp34.y - (sp1C[1] / 2)));
mpDrawBg->mpBackTexture->resize(sp1C[0], sp1C[1]);
}
}
void dMenu_Dmap_c::presentMapView() {
@@ -2380,17 +2338,16 @@ void dMenu_Dmap_c::presentMapView() {
#endif
void dMenu_Dmap_c::_draw() {
IF_DUSK(dusk::interp::ScopedMenuValues pose(this, field_0x104, field_0x108, field_0x10c));
IF_DUSK(const auto pose = dusk::interp::read_menu_pose(this, {field_0x104, field_0x108, field_0x10c}));
if (mMapCtrl != NULL) {
IF_NOT_DUSK(mMapCtrl->draw());
if (mpDrawBg != NULL) {
IF_DUSK_BLOCK(dusk::game_clock::is_presentation_frame())
#if TARGET_PC
if (dusk::game_clock::is_presentation_frame()) {
presentAnims();
mpDrawBg->setAllAlphaRate(field_0x10c, false);
}
#else
mpDrawBg->setAllTrans(field_0x104, field_0x108);
mpDrawBg->setAllAlphaRate(pose.alpha, false);
presentAnims();
#endif
mpDrawBg->setAllTrans(DUSK_IF_ELSE(pose.x, field_0x104), DUSK_IF_ELSE(pose.y, field_0x108));
if (mpDrawBg->mpBackTexture != NULL) {
f32 var_f31 = 100.0f * mpDrawBg->field_0xd88;
@@ -2426,8 +2383,10 @@ void dMenu_Dmap_c::_draw() {
sp14[1] = -(field_0x138 + 100.0f * (sp20 * mMapCtrl->getPixelPerCm()));
Vec spC;
#if !TARGET_PC
spC.x = mpDrawBg->mMapScreen[0]->search(MULTI_CHAR('center_n'))->getGlbBounds().i.x + (mpDrawBg->mMapScreen[0]->search(MULTI_CHAR('center_n'))->getWidth() / 2);
spC.y = mpDrawBg->mMapScreen[0]->search(MULTI_CHAR('center_n'))->getGlbBounds().i.y + (mpDrawBg->mMapScreen[0]->search(MULTI_CHAR('center_n'))->getHeight() / 2);
#endif
CPaneMgr sp70;
//!@bug It's unclear what this is supposed to be, but a stack pointer being converted to a bool is probably not intended.
@@ -2439,9 +2398,9 @@ void dMenu_Dmap_c::_draw() {
mpDrawBg->mpBackTexture->move(sp14[0] + (spC.x - (sp1C[0] / 2)), sp14[1] + (spC.y - (sp1C[1] / 2)));
mpDrawBg->mpBackTexture->resize(sp1C[0], sp1C[1]);
}
IF_DUSK_BLOCK_END
dComIfGd_set2DOpa(mpDrawBg);
#endif
IF_NOT_DUSK(dComIfGd_set2DOpa(mpDrawBg));
}
#if TARGET_PC
+112 -26
View File
@@ -498,7 +498,29 @@ void dMenu_Fmap_c::_delete() {
/* empty function */
}
#if TARGET_PC
namespace {
struct FmapZoomView {
u8 process = 0xff;
f32 level = 0.0f;
f32 blend = 0.0f;
};
void lerp(FmapZoomView& out, const FmapZoomView& lhs, const FmapZoomView& rhs, f32 step) {
out = {rhs.process, dusk::interp::lerp(lhs.level, rhs.level, step),
dusk::interp::lerp(lhs.blend, rhs.blend, step)};
}
struct FmapZoomSamples {
dusk::interp::Samples<FmapZoomView> views;
FmapZoomView end;
bool needsRestore = false;
};
}
#endif
void dMenu_Fmap_c::_move() {
IF_DUSK(resetZoomEnd());
u8 process = mProcess;
field_0x310 = 0;
mpDraw2DBack->clearIconInfo();
@@ -512,8 +534,9 @@ void dMenu_Fmap_c::_move() {
IF_NOT_DUSK(mpDraw2DTop->btkAnimeLoop(g_fmHIO.mTopAnimeStep));
if (mProcess != process) {
IF_DUSK(captureZoomEnd(process));
(this->*init_process[mProcess])();
IF_DUSK(dusk::interp::erase_owned_samples(this));
IF_DUSK(resetRenderState());
}
#if !TARGET_PC
@@ -549,21 +572,83 @@ void dMenu_Fmap_c::_move() {
mpDraw2DTop->mSelectRegionNo = 0xFF;
}
dusk::interp::capture_menu_values(this, mTransX, mTransY, mAlphaRatio, field_0x1ec, mZoomLevel);
captureRenderState();
#endif
}
#if TARGET_PC
void dMenu_Fmap_c::captureRenderState() {
dusk::interp::capture_menu_pose(this, {mTransX, mTransY, mAlphaRatio});
auto& zoom = dusk::interp::get<FmapZoomSamples>(this);
if (zoom.end.process == 0xff) {
const FmapZoomView view{mProcess, (f32)mZoomLevel, field_0x1ec};
zoom.views.capture(&view, 1);
}
}
void dMenu_Fmap_c::captureZoomEnd(u8 process) {
switch (process) {
case PROC_ZOOM_ALL_TO_REGION:
case PROC_ZOOM_REGION_TO_ALL:
case PROC_ZOOM_REGION_TO_SPOT:
case PROC_ZOOM_SPOT_TO_REGION:
case PROC_PORTAL_DEMO1:
case PROC_PORTAL_DEMO3:
case PROC_YAMIBOSS_DEMO4:
case PROC_TABLE_DEMO1:
case PROC_TABLE_DEMO2:
case PROC_HOWL_DEMO1:
break;
default:
return;
}
auto& zoom = dusk::interp::get<FmapZoomSamples>(this);
zoom.end = {process, (f32)mZoomLevel, field_0x1ec};
zoom.views.capture(&zoom.end, 1);
}
void dMenu_Fmap_c::resetRenderState() {
if (dusk::interp::get<FmapZoomSamples>(this).end.process != 0xff) {
dusk::interp::get<dusk::interp::MenuTransition>(this).poses.reset();
} else {
dusk::interp::erase_owned_samples(this);
}
}
void dMenu_Fmap_c::resetZoomEnd() {
auto& zoom = dusk::interp::get<FmapZoomSamples>(this);
if (zoom.needsRestore) {
presentZoomView(zoom.end.process, zoom.end.level, zoom.end.blend);
}
if (zoom.end.process != 0xff) {
zoom.views.reset();
const FmapZoomView view{mProcess, (f32)mZoomLevel, field_0x1ec};
zoom.views.capture(&view, 1);
}
zoom.end.process = 0xff;
zoom.needsRestore = false;
}
#endif
void dMenu_Fmap_c::_draw() {
IF_DUSK(dusk::interp::ScopedMenuValues pose(this, mTransX, mTransY, mAlphaRatio, field_0x1ec));
IF_DUSK(const auto pose = dusk::interp::read_menu_pose(this, {mTransX, mTransY, mAlphaRatio}));
#if TARGET_PC
auto& zoom = dusk::interp::get<FmapZoomSamples>(this);
const auto [renderProcess, zoomLevel, zoomBlend] =
zoom.views.read(0, {mProcess, (f32)mZoomLevel, field_0x1ec});
const bool finishingZoom = renderProcess != mProcess;
#endif
if (mpDraw2DBack != NULL && mpDraw2DTop != NULL) {
#if TARGET_PC
if (dusk::game_clock::is_presentation_frame()) {
mpDraw2DTop->setAllAlphaRate(pose.alpha, false);
presentAnims();
presentZoomView();
mpDraw2DBack->setAllTrans(mTransX, mTransY);
mpDraw2DTop->setAllTrans(mTransX, mTransY);
mpDraw2DBack->setAllAlphaRate(mAlphaRatio, false);
mpDraw2DTop->setAllAlphaRate(mAlphaRatio, false);
presentZoomView(renderProcess, zoomLevel, zoomBlend);
zoom.needsRestore |= finishingZoom;
mpDraw2DBack->setAllTrans(pose.x, pose.y);
mpDraw2DTop->setAllTrans(pose.x, pose.y);
mpDraw2DBack->setAllAlphaRate(pose.alpha, false);
mpDraw2DTop->setMoyaAlpha(g_fmHIO.mMoyaAlpha);
if (field_0x305) {
mpMenuFmapMap->presentRendering(mpWorldData, mStartStageNo,
@@ -584,18 +669,23 @@ void dMenu_Fmap_c::_draw() {
mpDraw2DBack->getMapZoomRate());
mpDraw2DBack->setStageInfo(mSpotNum, mpMenuFmapMap);
IF_DUSK_BLOCK_END
drawIcon(field_0x1ec, false);
if (mProcess == PROC_ZOOM_REGION_TO_SPOT || mProcess == PROC_ZOOM_SPOT_TO_REGION
|| mProcess == PROC_YAMIBOSS_DEMO4 || mProcess == PROC_LIGHT_DEMO1
|| mProcess == PROC_TABLE_DEMO2 || mProcess == PROC_HOWL_DEMO1)
drawIcon(DUSK_IF_ELSE(zoomBlend, field_0x1ec), false);
if (DUSK_IF_ELSE(renderProcess, mProcess) == PROC_ZOOM_REGION_TO_SPOT ||
DUSK_IF_ELSE(renderProcess, mProcess) == PROC_ZOOM_SPOT_TO_REGION ||
DUSK_IF_ELSE(renderProcess, mProcess) == PROC_YAMIBOSS_DEMO4 ||
DUSK_IF_ELSE(renderProcess, mProcess) == PROC_LIGHT_DEMO1 ||
DUSK_IF_ELSE(renderProcess, mProcess) == PROC_TABLE_DEMO2 ||
DUSK_IF_ELSE(renderProcess, mProcess) == PROC_HOWL_DEMO1)
{
f32 scale = 1.0f - field_0x1ec;
f32 scale = 1.0f - DUSK_IF_ELSE(zoomBlend, field_0x1ec);
mpDraw2DBack->iconScale(0, scale, scale, 1.0f - scale);
}
} else {
drawPortalIcon();
if (mProcess == PROC_ZOOM_ALL_TO_REGION || mProcess == PROC_ZOOM_REGION_TO_ALL) {
f32 scale = 1.0f - DUSK_IF_ELSE(getRenderZoomLevel(), (f32)mZoomLevel) / 10.0f;
if (DUSK_IF_ELSE(renderProcess, mProcess) == PROC_ZOOM_ALL_TO_REGION ||
DUSK_IF_ELSE(renderProcess, mProcess) == PROC_ZOOM_REGION_TO_ALL)
{
f32 scale = 1.0f - DUSK_IF_ELSE(zoomLevel, (f32)mZoomLevel) / 10.0f;
mpDraw2DBack->iconScale(0, scale, scale, 1.0f - scale);
}
}
@@ -633,9 +723,8 @@ void dMenu_Fmap_c::presentAnims() {
}
}
void dMenu_Fmap_c::presentZoomView() {
const f32 zoomLevel = getRenderZoomLevel();
switch (mProcess) {
void dMenu_Fmap_c::presentZoomView(u8 process, f32 zoomLevel, f32 zoomBlend) {
switch (process) {
case PROC_ZOOM_ALL_TO_REGION:
case PROC_ZOOM_REGION_TO_ALL:
case PROC_PORTAL_DEMO1:
@@ -650,20 +739,16 @@ void dMenu_Fmap_c::presentZoomView() {
case PROC_ZOOM_REGION_TO_SPOT:
case PROC_ZOOM_SPOT_TO_REGION:
case PROC_YAMIBOSS_DEMO4:
mpDraw2DBack->zoomMapCalc2(field_0x1ec);
mpDraw2DBack->zoomMapCalc2(zoomBlend);
break;
case PROC_TABLE_DEMO2:
case PROC_HOWL_DEMO1:
if (zoomLevel > 0) {
mpDraw2DBack->zoomMapCalc2(field_0x1ec);
mpDraw2DBack->zoomMapCalc2(zoomBlend);
}
break;
}
}
f32 dMenu_Fmap_c::getRenderZoomLevel() const {
return dusk::interp::get<dusk::interp::MenuValues>(this).values.read(4, (f32)mZoomLevel);
}
#endif
u8 dMenu_Fmap_c::getNextStatus(u8* param_0) {
@@ -1851,12 +1936,13 @@ bool dMenu_Fmap_c::isOpen() {
#if TARGET_PC
mpDraw2DTop->setMoyaAlpha(g_fmHIO.mMoyaAlpha);
dusk::interp::capture_menu_values(this, mTransX, mTransY, mAlphaRatio, field_0x1ec, mZoomLevel);
captureRenderState();
#endif
return ret;
}
bool dMenu_Fmap_c::isClose() {
IF_DUSK(resetZoomEnd());
bool ret = true;
bool bVar2 = false;
@@ -1896,7 +1982,7 @@ bool dMenu_Fmap_c::isClose() {
#if TARGET_PC
mpDraw2DTop->setMoyaAlpha(g_fmHIO.mMoyaAlpha);
dusk::interp::capture_menu_values(this, mTransX, mTransY, mAlphaRatio, field_0x1ec, mZoomLevel);
captureRenderState();
#endif
return ret;
}
+11
View File
@@ -2110,6 +2110,11 @@ void dMenu_Fmap2DBack_c::stageMapMove(STControl* i_stick, u8 param_1, bool param
}
void dMenu_Fmap2DBack_c::setAllAlphaRate(f32 i_rate, bool i_init) {
#if TARGET_PC
if (!i_init && i_rate == 1.0f && mAlphaRate == 1.0f) {
return;
}
#endif
mAlphaRate = i_rate;
if (i_init) {
mpBaseRoot->setBackupAlpha();
@@ -2304,6 +2309,7 @@ dMenu_Fmap2DTop_c::dMenu_Fmap2DTop_c(JKRExpHeap* i_heap, STControl* i_stick) {
mpHeap = i_heap;
mTransX = 0.0f;
mTransY = 0.0f;
IF_DUSK(mAlphaRate = 0.0f;)
mpPortalBin = NULL;
mpScrnExplain = NULL;
@@ -2793,6 +2799,11 @@ void dMenu_Fmap2DTop_c::_execute() {
}
void dMenu_Fmap2DTop_c::setAllAlphaRate(f32 i_rate, bool i_init) {
#if TARGET_PC
if (!i_init && i_rate == 1.0f && mAlphaRate == 1.0f) {
return;
}
#endif
mAlphaRate = i_rate;
if (i_init) {
mpTitleRoot->setBackupAlpha();
+33 -12
View File
@@ -688,13 +688,28 @@ void dMenu_Ring_c::_move() {
mRingCursorScale = g_ringHIO.mCursorScale;
mpDrawCursor->setScale(g_ringHIO.mCursorScale);
}
IF_DUSK(dusk::interp::capture_menu_values(this, mCenterPosX, mCenterPosY, mAlphaRate,
field_0x674[0], field_0x674[1], field_0x674[2], field_0x674[3]));
IF_DUSK(captureRenderState());
}
#if TARGET_PC
namespace {
struct RingSelectionSamples {
dusk::interp::Samples<f32> frames;
};
}
void dMenu_Ring_c::captureRenderState() {
dusk::interp::capture_menu_pose(this, {mCenterPosX, mCenterPosY, mAlphaRate});
dusk::interp::get<RingSelectionSamples>(this).frames.capture(4, [&](int i) {
return (f32)field_0x674[i];
});
}
#endif
void dMenu_Ring_c::_draw() {
#if TARGET_PC
dusk::interp::ScopedMenuValues pose(this, mCenterPosX, mCenterPosY, mAlphaRate);
const auto [mCenterPosX, mCenterPosY, mAlphaRate] =
dusk::interp::read_menu_pose(this, {this->mCenterPosX, this->mCenterPosY, this->mAlphaRate});
if (mDrawFlag == 0) {
dusk::vdt::advance_looping_frame(field_0x684, 1.0f, g_ringHIO.mItemAlphaFlashDuration);
}
@@ -799,8 +814,7 @@ bool dMenu_Ring_c::isOpen() {
mpDrawCursor->setParam(1.0f, 1.0f, 0.1f, 0.6f, 0.5f);
}
IF_DUSK(dusk::interp::capture_menu_values(this, mCenterPosX, mCenterPosY, mAlphaRate,
field_0x674[0], field_0x674[1], field_0x674[2], field_0x674[3]));
IF_DUSK(captureRenderState());
return opened;
}
@@ -864,8 +878,7 @@ bool dMenu_Ring_c::isClose() {
mpDrawCursor->setParam(1.0f, 1.0f, 0.1f, 0.6f, 0.5f);
}
IF_DUSK(dusk::interp::capture_menu_values(this, mCenterPosX, mCenterPosY, mAlphaRate,
field_0x674[0], field_0x674[1], field_0x674[2], field_0x674[3]));
IF_DUSK(captureRenderState());
return closed;
}
@@ -1389,7 +1402,10 @@ void dMenu_Ring_c::setMixItem() {
}
void dMenu_Ring_c::drawItem() {
#if !TARGET_PC
#if TARGET_PC
const auto [mCenterPosX, mCenterPosY, mAlphaRate] =
dusk::interp::read_menu_pose(this, {this->mCenterPosX, this->mCenterPosY, this->mAlphaRate});
#else
field_0x684++;
if (field_0x684 >= g_ringHIO.mItemAlphaFlashDuration) {
field_0x684 = 0;
@@ -1448,6 +1464,10 @@ void dMenu_Ring_c::drawItem() {
}
void dMenu_Ring_c::drawItem2() {
#if TARGET_PC
const auto [mCenterPosX, mCenterPosY, mAlphaRate] =
dusk::interp::read_menu_pose(this, {this->mCenterPosX, this->mCenterPosY, this->mAlphaRate});
#endif
s32 idx = mCurrentSlot;
if (mStatus == STATUS_WAIT || mStatus == STATUS_EXPLAIN || mStatus == STATUS_EXPLAIN_FORCE) {
J2DDrawFrame(mItemSlotPosX[idx] - 24.0f + mCenterPosX, mItemSlotPosY[idx] - 24.0f + mCenterPosY,
@@ -1745,12 +1765,12 @@ void dMenu_Ring_c::advanceSelectItem() {
++field_0x674[i];
}
}
dusk::interp::capture_menu_values(this, mCenterPosX, mCenterPosY, mAlphaRate, field_0x674[0],
field_0x674[1], field_0x674[2], field_0x674[3]);
captureRenderState();
}
#endif
void dMenu_Ring_c::drawSelectItem() {
IF_DUSK(const auto mAlphaRate = dusk::interp::read_menu_pose(this, {mCenterPosX, mCenterPosY, this->mAlphaRate}).alpha);
for (int i = 0; i < 4; i++) {
if (field_0x674[i] != 0) {
if (DUSK_IF_ELSE(true, field_0x674[i] < 10)) {
@@ -1790,8 +1810,8 @@ void dMenu_Ring_c::drawSelectItem() {
#endif
#if TARGET_PC
const auto& samples = dusk::interp::get<dusk::interp::MenuValues>(this).values;
const f32 frame = field_0x674[i] == 1 ? 1.0f : samples.read(3 + i, (f32)field_0x674[i]);
const auto& samples = dusk::interp::get<RingSelectionSamples>(this).frames;
const f32 frame = field_0x674[i] == 1 ? 1.0f : samples.read(i, (f32)field_0x674[i]);
f32 fVar14 = std::clamp(frame, 1.0f, 9.0f) / 10.0f;
#else
f32 fVar14 = field_0x674[i] / 10.0f;
@@ -2050,6 +2070,7 @@ void dMenu_Ring_c::setCombineBomb(int param_0) {
}
void dMenu_Ring_c::drawNumber(int i_itemNum, int i_itemMaxNum, f32 i_posX, f32 i_posY) {
IF_DUSK(const auto mAlphaRate = dusk::interp::read_menu_pose(this, {mCenterPosX, mCenterPosY, this->mAlphaRate}).alpha);
if (i_itemNum > 100) {
i_itemNum = 100;
}
+17 -39
View File
@@ -2,52 +2,30 @@
#include "samples.h"
#include <array>
namespace dusk::interp {
struct MenuValues {
Samples<f32> values;
struct MenuPose {
f32 x;
f32 y;
f32 alpha;
};
template <typename... Values>
void capture_menu_values(const void* owner, Values... values) {
if (!should_capture()) {
return;
}
const f32 pose[] = {static_cast<f32>(values)...};
get<MenuValues>(owner).values.capture(pose, sizeof...(Values));
inline void lerp(MenuPose& out, const MenuPose& lhs, const MenuPose& rhs, float step) {
out = {lerp(lhs.x, rhs.x, step), lerp(lhs.y, rhs.y, step), lerp(lhs.alpha, rhs.alpha, step)};
}
template <size_t Count>
class ScopedMenuValues {
public:
template <typename... Values>
ScopedMenuValues(const void* owner, Values&... values) : mValues{&values...}, mSaved{values...} {
if (is_enabled() && is_presentation_active()) {
const auto& samples = get<MenuValues>(owner).values;
for (size_t i = 0; i < Count; ++i) {
*mValues[i] = samples.read(i, mSaved[i]);
}
}
}
~ScopedMenuValues() {
for (size_t i = 0; i < Count; ++i) {
*mValues[i] = mSaved[i];
}
}
ScopedMenuValues(const ScopedMenuValues&) = delete;
ScopedMenuValues& operator=(const ScopedMenuValues&) = delete;
private:
std::array<f32*, Count> mValues;
std::array<f32, Count> mSaved;
struct MenuTransition {
Samples<MenuPose> poses;
};
template <typename... Values>
ScopedMenuValues(const void*, Values&...) -> ScopedMenuValues<sizeof...(Values)>;
inline void capture_menu_pose(const void* owner, MenuPose pose) {
if (should_capture()) {
get<MenuTransition>(owner).poses.capture(&pose, 1);
}
}
inline MenuPose read_menu_pose(const void* owner, MenuPose current) {
return get<MenuTransition>(owner).poses.read(0, current);
}
} // namespace dusk::interp