From 7d48b65a6bb8d8c2c225b906128b39da41a918bf Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Tue, 25 Feb 2020 05:08:45 +1100 Subject: [PATCH] pause: fix restart scoring, improve navigation implementation --- .../source/plugins/TLAC/Components/Pause.cpp | 25 ++++++++------ .../source/plugins/TLAC/Components/Pause.h | 34 ++++++++++++++++--- 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/source-code/source/plugins/TLAC/Components/Pause.cpp b/source-code/source/plugins/TLAC/Components/Pause.cpp index 39b64e4..c5b85b9 100644 --- a/source-code/source/plugins/TLAC/Components/Pause.cpp +++ b/source-code/source/plugins/TLAC/Components/Pause.cpp @@ -28,7 +28,7 @@ namespace TLAC::Components int Pause::crossAet = 0; int Pause::circleAet = 0; int Pause::curMenuPos = 0; - int Pause::mainMenuPos = 0; + std::vector> Pause::menuHistory; Pause::menusets Pause::curMenuSet = MENUSET_MAIN; std::chrono::time_point Pause::menuItemMoveTime; std::vector Pause::origAetMovOp; @@ -60,7 +60,7 @@ namespace TLAC::Components "SE VOLUME", { { "+", sevolplus, true }, - { "XX", mainmenu, false }, + { "XX", menuback, false }, { "-", sevolminus, true }, } }, @@ -148,6 +148,7 @@ namespace TLAC::Components filteredButtons = allButtons; setMenuPos(MENUSET_MAIN, 0); + menuHistory.resize(0); showUI = true; isPaused = true; } @@ -210,7 +211,7 @@ namespace TLAC::Components } else { - setMenuPos(MENUSET_MAIN, mainMenuPos); + menuback(); } } @@ -553,7 +554,7 @@ namespace TLAC::Components aetLoc.x = dtParams.textCurrentLoc.x + halfSpriteSize; crossAet = Drawing::createAetLayer(3, dtParams.layer, Drawing::CREATEAET_20000, "button_batsu", aetLoc, 0, nullptr, nullptr, 0, 0, aetScale, nullptr); dtParams.textCurrentLoc.x += spriteSize; - if (curMenuSet == MENUSET_MAIN) + if (menuHistory.size() == 0) Drawing::drawTextW(&dtParams, (Drawing::drawTextFlags)(Drawing::DRAWTEXT_ENABLE_XADVANCE), L":Close "); else Drawing::drawTextW(&dtParams, (Drawing::drawTextFlags)(Drawing::DRAWTEXT_ENABLE_XADVANCE), L":Back "); @@ -608,12 +609,19 @@ namespace TLAC::Components playerData->act_slide_vol = playerData->act_vol; } - void Pause::setMenuPos(menusets set, int pos) + void Pause::setMenuPos(menusets set, int pos, bool updateHistory) { + menusets newMenuSet; + if (set >= 0 && set < menu.size()) - curMenuSet = set; + newMenuSet = set; else - curMenuSet = MENUSET_MAIN; + newMenuSet = MENUSET_MAIN; + + if (updateHistory && newMenuSet != curMenuSet) + menuHistory.push_back(std::pair(curMenuSet, curMenuPos)); + + curMenuSet = newMenuSet; if (pos < 0) pos = menu[curMenuSet].items.size() - 1; @@ -622,9 +630,6 @@ namespace TLAC::Components curMenuPos = pos; - if (curMenuSet == MENUSET_MAIN) - mainMenuPos = curMenuPos; - menuItemMoveTime = std::chrono::high_resolution_clock::now(); // restart animations } diff --git a/source-code/source/plugins/TLAC/Components/Pause.h b/source-code/source/plugins/TLAC/Components/Pause.h index 15a7018..306f0c1 100644 --- a/source-code/source/plugins/TLAC/Components/Pause.h +++ b/source-code/source/plugins/TLAC/Components/Pause.h @@ -114,14 +114,30 @@ namespace TLAC::Components }; static int curMenuPos; - static int mainMenuPos; // syncs to curMenuPos when curMenuSet == MENUSET_MAIN (used for restoring on back) + static std::vector> menuHistory; // used for implementing back button in menus static menusets curMenuSet; static std::chrono::time_point menuItemMoveTime; // used for animation - static void mainmenu() { setMenuPos(MENUSET_MAIN, mainMenuPos); }; + // static void mainmenu() { setMenuPos(MENUSET_MAIN, 0); menuHistory.resize(0); }; + static void menuback() + { + if (menuHistory.size() == 0) + { + // mainmenu(); + unpause(); + } + else + { + std::pair menuPos = menuHistory.back(); + menuHistory.pop_back(); + + setMenuPos(menuPos.first, menuPos.second, false); + } + } static void unpause() { pause = false; }; - static void restart() { + static void restart() + { /* 140d0b510+2 = 0, 140d0b510+14 = 8 for restart @@ -146,6 +162,11 @@ namespace TLAC::Components percentage doesn't fully reset by the looks of it???? rip + (actually was hold and slide scores -- fixed by manually clearing them now) + + TODO: + check holds count towards percentage after restart if 5% limit was reached + reset not clear flag in protected mode */ // inject flow overrides to switch cases in FUN_1400fddc0 @@ -162,6 +183,11 @@ namespace TLAC::Components doLoading(0x140cdd8d0); } + // for some reason the above doesn't reset all scoring stuff + *(int*)0x140D0A9BC = 0; // total holds + *(int*)0x140D0A9B8 = 0; // hold + multi + *(int*)0x140D0A9C0 = 0; // slide + // revert patches and unpause InjectCode((void*)0x1401038cd, { 0x12 }); InjectCode((void*)0x140103b94, { 0x16 }); unpause(); @@ -175,7 +201,7 @@ namespace TLAC::Components // contents are in Pause.cpp because they can't be inline here for a static (const) array/vec static std::vector menu; - static void setMenuPos(menusets set, int pos); + static void setMenuPos(menusets set, int pos, bool updateHistory = true); static float getMenuAnimPos();