diff --git a/mm/2s2h/BenGui/BenMenuBar.cpp b/mm/2s2h/BenGui/BenMenuBar.cpp index f1f09cb4b..266bf22ed 100644 --- a/mm/2s2h/BenGui/BenMenuBar.cpp +++ b/mm/2s2h/BenGui/BenMenuBar.cpp @@ -332,7 +332,6 @@ extern std::shared_ptr mHudEditorWindow; void DrawEnhancementsMenu() { if (UIWidgets::BeginMenu("Enhancements")) { - if (UIWidgets::BeginMenu("Camera")) { ImGui::SeparatorText("Fixes"); UIWidgets::CVarCheckbox( @@ -475,7 +474,11 @@ void DrawEnhancementsMenu() { ImGui::EndMenu(); } - if (UIWidgets::BeginMenu("Dialogues")) { + if (UIWidgets::BeginMenu("Dialogue")) { + UIWidgets::CVarCheckbox( + "Fast Bank Selection", "gEnhancements.Dialogue.FastBankSelection", + { .tooltip = "Pressing the Z or R buttons while the Deposit/Withdrawl Rupees dialogue is open will set " + "the Rupees to Links current Rupees or 0 respectively." }); UIWidgets::CVarCheckbox( "Fast Text", "gEnhancements.Dialogue.FastText", { .tooltip = "Speeds up text rendering, and enables holding of B progress to next message" }); diff --git a/mm/2s2h/Enhancements/Dialogue/Dialogue.h b/mm/2s2h/Enhancements/Dialogue/Dialogue.h new file mode 100644 index 000000000..980e7d523 --- /dev/null +++ b/mm/2s2h/Enhancements/Dialogue/Dialogue.h @@ -0,0 +1,6 @@ +#ifndef DIALOGUES_H +#define DIALOGUES_H + +void RegisterFastBankSelection(); + +#endif // DIALOGUES_H \ No newline at end of file diff --git a/mm/2s2h/Enhancements/Dialogue/FastBankSelection.cpp b/mm/2s2h/Enhancements/Dialogue/FastBankSelection.cpp new file mode 100644 index 000000000..1035fb398 --- /dev/null +++ b/mm/2s2h/Enhancements/Dialogue/FastBankSelection.cpp @@ -0,0 +1,86 @@ +#include +#include "Enhancements/GameInteractor/GameInteractor.h" +#include "z64.h" +#include "global.h" + +#include "overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.h" + +static const char zeroRupees[3] = { '0', '0', '0' }; + +void FastBankSelection_UpdateMessage(const char rupeeValue[3]) { + for (int i = 0; i <= 2; i++) { + gPlayState->msgCtx.decodedBuffer.schar[gPlayState->msgCtx.unk120C0 + i] = rupeeValue[i]; + Font_LoadCharNES(gPlayState, gPlayState->msgCtx.decodedBuffer.schar[gPlayState->msgCtx.unk120C0 + i], + gPlayState->msgCtx.unk120C4 + (i << 7)); + } + Audio_PlaySfx(NA_SE_SY_RUPY_COUNT); +} + +void RegisterFastBankSelection() { + GameInteractor::Instance->RegisterGameHookForID( + ACTOR_EN_GINKO_MAN, [](Actor* outerActor) { + static HOOK_ID enGinkoUpdateHook = 0; + static HOOK_ID enGinkoKillHook = 0; + GameInteractor::Instance->UnregisterGameHookForPtr(enGinkoUpdateHook); + GameInteractor::Instance->UnregisterGameHook(enGinkoKillHook); + enGinkoUpdateHook = 0; + enGinkoKillHook = 0; + + enGinkoUpdateHook = GameInteractor::Instance->RegisterGameHookForPtr( + (uintptr_t)outerActor, [](Actor* actor) { + EnGinkoMan* enGinko = (EnGinkoMan*)actor; + if (CVarGetInteger("gEnhancements.Dialogue.FastBankSelection", 0)) { + if (gPlayState->msgCtx.currentTextId == 0x450) { + if (CHECK_BTN_ALL(gPlayState->state.input[0].cur.button, BTN_Z) && + gPlayState->msgCtx.bankRupeesSelected != gSaveContext.save.saveInfo.playerData.rupees) { + char firstChar = (gSaveContext.save.saveInfo.playerData.rupees / 100) + '0'; + char secondChar = ((gSaveContext.save.saveInfo.playerData.rupees / 10) % 10) + '0'; + char thirdChar = (gSaveContext.save.saveInfo.playerData.rupees % 10) + '0'; + const char rupeeChar[3] = { firstChar, secondChar, thirdChar }; + + FastBankSelection_UpdateMessage(rupeeChar); + } + } else if (gPlayState->msgCtx.currentTextId == 0x46E) { + uint32_t walletSize = CUR_UPG_VALUE(UPG_WALLET); + uint32_t currentRupees = gSaveContext.save.saveInfo.playerData.rupees; + uint32_t maxWallet; + if (CHECK_BTN_ALL(gPlayState->state.input[0].cur.button, BTN_Z)) { + switch (ITEM_WALLET_DEFAULT + walletSize) { + case ITEM_WALLET_ADULT: + maxWallet = (200 - currentRupees); + break; + case ITEM_WALLET_GIANT: + maxWallet = (500 - currentRupees); + break; + default: + maxWallet = (99 - currentRupees); + break; + } + if (maxWallet != 0 && gPlayState->msgCtx.bankRupeesSelected != maxWallet) { + char firstChar = (maxWallet / 100) + '0'; + char secondChar = ((maxWallet / 10) % 10) + '0'; + char thirdChar = (maxWallet % 10) + '0'; + const char rupeeChar[3] = { firstChar, secondChar, thirdChar }; + + FastBankSelection_UpdateMessage(rupeeChar); + } + } + } + if (gPlayState->msgCtx.currentTextId == 0x450 || gPlayState->msgCtx.currentTextId == 0x46E) { + if (CHECK_BTN_ALL(gPlayState->state.input[0].cur.button, BTN_R) && + gPlayState->msgCtx.bankRupeesSelected != 0) { + + FastBankSelection_UpdateMessage(zeroRupees); + } + } + } + }); + enGinkoKillHook = + GameInteractor::Instance->RegisterGameHook([](s8 sceneId, s8 spawnNum) { + GameInteractor::Instance->UnregisterGameHook(enGinkoUpdateHook); + GameInteractor::Instance->UnregisterGameHook(enGinkoKillHook); + enGinkoUpdateHook = 0; + enGinkoKillHook = 0; + }); + }); +} \ No newline at end of file diff --git a/mm/2s2h/Enhancements/Enhancements.cpp b/mm/2s2h/Enhancements/Enhancements.cpp index fe213e977..87a119155 100644 --- a/mm/2s2h/Enhancements/Enhancements.cpp +++ b/mm/2s2h/Enhancements/Enhancements.cpp @@ -20,6 +20,9 @@ void InitEnhancements() { RegisterSavingEnhancements(); RegisterAutosave(); + // Dialogue + RegisterFastBankSelection(); + // Equipment RegisterSkipMagicArrowEquip(); diff --git a/mm/2s2h/Enhancements/Enhancements.h b/mm/2s2h/Enhancements/Enhancements.h index 3461bda91..9b78c6aca 100644 --- a/mm/2s2h/Enhancements/Enhancements.h +++ b/mm/2s2h/Enhancements/Enhancements.h @@ -6,6 +6,7 @@ #include "Camera/FreeLook.h" #include "Cheats/MoonJump.h" #include "Cheats/Infinite.h" +#include "Dialogue/Dialogue.h" #include "Graphics/TextBasedClock.h" #include "Cheats/UnbreakableRazorSword.h" #include "Cheats/UnrestrictedItems.h"