From 294684213aedbd8f09c6cbaa452dd0137d1e9e4c Mon Sep 17 00:00:00 2001 From: vaguerant Date: Sun, 24 Jul 2022 23:14:36 +1000 Subject: [PATCH] Timer Savers: Mask Select in Inventory (#670) * Timer Savers: Mask Select in Inventory * Merge derp * Implement suggestions per @briaguya-ai * Fix cut & paste derp --- libultraship/libultraship/ImGuiImpl.cpp | 2 + .../misc/ovl_kaleido_scope/z_kaleido_item.c | 40 ++++++++++++++++++- .../misc/ovl_kaleido_scope/z_kaleido_scope.h | 1 + .../ovl_kaleido_scope/z_kaleido_scope_PAL.c | 2 + 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index f4cd00053..4fed3d115 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -977,6 +977,8 @@ namespace SohImGui { Tooltip("Skip the part where the Ocarina playback is called when you play\na song"); EnhancementCheckbox("Instant Putaway", "gInstantPutaway"); Tooltip("Allow Link to put items away without having to wait around"); + EnhancementCheckbox("Mask Select in Inventory", "gMaskSelect"); + Tooltip("After completing the mask trading sub-quest,\npress A and any direction on the mask slot to change masks"); ImGui::EndMenu(); } diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c index 6a0e32bea..8bb4cc431 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c @@ -9,6 +9,7 @@ u8 gAmmoItems[] = { static s16 sEquipState = 0; static s16 sEquipAnimTimer = 0; static s16 sEquipMoveTimer = 10; +bool gSelectingMask; static s16 sAmmoVtxOffset[] = { 0, 2, 4, 6, 99, 99, 8, 99, 99, 10, 99, 99, 99, 99, 99, 99, 12, @@ -108,7 +109,7 @@ void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) { pauseCtx->nameColorSet = 0; if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_ITEM)) { - moveCursorResult = 0; + moveCursorResult = 0 || gSelectingMask; oldCursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; cursorItem = pauseCtx->cursorItem[PAUSE_ITEM]; @@ -282,7 +283,7 @@ void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) { if (pauseCtx->cursorSpecialPos == 0) { if (cursorItem != PAUSE_ITEM_NONE) { if ((ABS(pauseCtx->stickRelY) > 30) || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DDOWN | BTN_DUP))) { - moveCursorResult = 0; + moveCursorResult = 0 || gSelectingMask; cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; cursorY = pauseCtx->cursorY[PAUSE_ITEM]; @@ -350,6 +351,40 @@ void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) { KaleidoScope_SetCursorVtx(pauseCtx, index, pauseCtx->itemVtx); if ((pauseCtx->debugState == 0) && (pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0)) { + if (CVar_GetS32("gMaskSelect", 0) && (gSaveContext.eventChkInf[8] & 0x8000) && + cursorSlot == SLOT_TRADE_CHILD && CHECK_BTN_ALL(input->press.button, BTN_A)) { + Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + gSelectingMask = !gSelectingMask; + } + if (gSelectingMask) { + pauseCtx->cursorColorSet = 8; + if (((pauseCtx->stickRelX > 30 || pauseCtx->stickRelY > 30) || + dpad && CHECK_BTN_ANY(input->press.button, BTN_DRIGHT | BTN_DUP)) && + INV_CONTENT(ITEM_TRADE_CHILD) < ITEM_MASK_TRUTH) { + Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + ++INV_CONTENT(ITEM_TRADE_CHILD); + } else if (((pauseCtx->stickRelX < -30 || pauseCtx->stickRelY < -30) || + dpad && CHECK_BTN_ANY(input->press.button, BTN_DLEFT | BTN_DDOWN)) && + INV_CONTENT(ITEM_TRADE_CHILD) > ITEM_MASK_KEATON) { + Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + --INV_CONTENT(ITEM_TRADE_CHILD); + } else if ((pauseCtx->stickRelX < -30 || pauseCtx->stickRelX > 30 || pauseCtx->stickRelY < -30 || pauseCtx->stickRelY > 30) || + dpad && CHECK_BTN_ANY(input->press.button, BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT)) { + INV_CONTENT(ITEM_TRADE_CHILD) ^= ITEM_MASK_KEATON ^ ITEM_MASK_TRUTH; + Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + for (uint16_t cSlotIndex = 0; cSlotIndex < ARRAY_COUNT(gSaveContext.equips.cButtonSlots); cSlotIndex++) { + if (gSaveContext.equips.cButtonSlots[cSlotIndex] == SLOT_TRADE_CHILD) { + if (!LINK_IS_ADULT || CVar_GetS32("gNoRestrictAge", 0)) { + gSaveContext.equips.buttonItems[cSlotIndex+1] = INV_CONTENT(ITEM_TRADE_CHILD); + } else if (INV_CONTENT(ITEM_TRADE_CHILD) != gSaveContext.equips.buttonItems[cSlotIndex+1]) { + gSaveContext.equips.cButtonSlots[cSlotIndex] = SLOT_NONE; + gSaveContext.equips.buttonItems[cSlotIndex+1] = ITEM_NONE; + } + } + } + gSelectingMask = cursorSlot == SLOT_TRADE_CHILD; + } u16 buttonsToCheck = BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT; if (CVar_GetS32("gDpadEquips", 0) && (!CVar_GetS32("gDpadPauseName", 0) || CHECK_BTN_ALL(input->cur.button, BTN_CUP))) { buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; @@ -474,6 +509,7 @@ void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) { void KaleidoScope_SetupItemEquip(GlobalContext* globalCtx, u16 item, u16 slot, s16 animX, s16 animY) { Input* input = &globalCtx->state.input[0]; PauseContext* pauseCtx = &globalCtx->pauseCtx; + gSelectingMask = false; if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { pauseCtx->equipTargetCBtn = 0; diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h index fa1d88fec..b272297f1 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.h @@ -10,6 +10,7 @@ extern s16 D_8082AB2C[]; extern u8 gSlotAgeReqs[]; extern u8 gEquipAgeReqs[][4]; extern u8 gAreaGsFlags[]; +extern bool gSelectingMask; void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfxCtx); s32 KaleidoScope_UpdateQuestStatusPoint(PauseContext* pauseCtx, s32 point); diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index f6116c765..9071e7a0f 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -867,6 +867,7 @@ void KaleidoScope_SetDefaultCursor(GlobalContext* globalCtx) { PauseContext* pauseCtx = &globalCtx->pauseCtx; s16 s; s16 i; + gSelectingMask = false; switch (pauseCtx->pageIndex) { case PAUSE_ITEM: @@ -900,6 +901,7 @@ void KaleidoScope_SetDefaultCursor(GlobalContext* globalCtx) { void KaleidoScope_SwitchPage(PauseContext* pauseCtx, u8 pt) { pauseCtx->unk_1E4 = 1; pauseCtx->unk_1EA = 0; + gSelectingMask = false; if (!pt) { pauseCtx->mode = pauseCtx->pageIndex * 2 + 1;