From 612700c2ab73fbc4485ccb149eb407c07122d63a Mon Sep 17 00:00:00 2001 From: aMannus Date: Tue, 31 Jan 2023 12:53:22 +0100 Subject: [PATCH] Change gPauseAnyCursor into combobox (#2423) * Change gPauseAnyCursor into combobox * Add enums * Change naming --- soh/include/z64.h | 7 +++++++ soh/soh/Enhancements/controls/GameControlEditor.cpp | 9 +++++++-- soh/soh/Enhancements/presets.h | 2 -- .../misc/ovl_kaleido_scope/z_kaleido_equipment.c | 10 ++++++---- .../overlays/misc/ovl_kaleido_scope/z_kaleido_item.c | 10 ++++++---- .../misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c | 9 +++++++-- 6 files changed, 33 insertions(+), 14 deletions(-) diff --git a/soh/include/z64.h b/soh/include/z64.h index cd795c62b..f0335ca40 100644 --- a/soh/include/z64.h +++ b/soh/include/z64.h @@ -2222,6 +2222,13 @@ typedef struct { const char** palettes; } SkyboxTableEntry; +typedef enum { + /* 0x00 */ PAUSE_ANY_CURSOR_RANDO_ONLY, + /* 0x01 */ PAUSE_ANY_CURSOR_ALWAYS_ON, + /* 0x02 */ PAUSE_ANY_CURSOR_ALWAYS_OFF, + /* 0x03 */ PAUSE_ANY_CURSOR_MAX +} PauseCursorAnySlotOptions; + #define ROM_FILE(name) \ { 0, 0, #name } diff --git a/soh/soh/Enhancements/controls/GameControlEditor.cpp b/soh/soh/Enhancements/controls/GameControlEditor.cpp index 6a2ce82de..1f55dbe9a 100644 --- a/soh/soh/Enhancements/controls/GameControlEditor.cpp +++ b/soh/soh/Enhancements/controls/GameControlEditor.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -296,6 +297,12 @@ namespace GameControlEditor { ImVec2 cursor = ImGui::GetCursorPos(); ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5)); SohImGui::BeginGroupPanel("Misc Controls", ImGui::GetContentRegionAvail()); + UIWidgets::PaddedText("Allow the cursor to be on any slot"); + static const char* cursorOnAnySlot[3] = { "Only in Rando", "Always", "Never" }; + UIWidgets::EnhancementCombobox("gPauseAnyCursor", cursorOnAnySlot, PAUSE_ANY_CURSOR_MAX, PAUSE_ANY_CURSOR_RANDO_ONLY); + DrawHelpIcon("Allows the cursor on the pause menu to be over any slot. Sometimes required in rando to select " + "certain items."); + UIWidgets::Spacer(0); UIWidgets::PaddedEnhancementCheckbox("Enable walk speed modifiers", "gEnableWalkModify", true, false); DrawHelpIcon("Hold the assigned button to change the maximum walking speed\nTo change the assigned button, go into the Ports tabs above"); if (CVarGetInteger("gEnableWalkModify", 0)) { @@ -307,8 +314,6 @@ namespace GameControlEditor { SohImGui::EndGroupPanel(); } UIWidgets::Spacer(0); - UIWidgets::PaddedEnhancementCheckbox("Allow the cursor to be on any slot", "gPauseAnyCursor"); - DrawHelpIcon("Allows the cursor on the pause menu to be over any slot\nSimilar to Rando and Spaceworld 97"); UIWidgets::PaddedEnhancementCheckbox("Answer Navi Prompt with L Button", "gNaviOnL"); DrawHelpIcon("Speak to Navi with L but enter first-person camera with C-Up"); SohImGui::EndGroupPanel(); diff --git a/soh/soh/Enhancements/presets.h b/soh/soh/Enhancements/presets.h index 91bdac3a6..5a8d7188c 100644 --- a/soh/soh/Enhancements/presets.h +++ b/soh/soh/Enhancements/presets.h @@ -599,8 +599,6 @@ const std::vector randomizerPresetEntries = { // Autosave PRESET_ENTRY_S32("gAutosave", 1), - // Allow the cursor to be on any slot - PRESET_ENTRY_S32("gPauseAnyCursor", 1), // Customize Fishing Behaviour PRESET_ENTRY_S32("gCustomizeFishing", 1), diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c index 208ad5a67..be1320d78 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c @@ -177,6 +177,8 @@ void KaleidoScope_DrawEquipment(PlayState* play) { s16 cursorY; s16 oldCursorPoint; bool dpad = (CVarGetInteger("gDpadPause", 0) && !CHECK_BTN_ALL(input->cur.button, BTN_CUP)); + bool pauseAnyCursor = (CVarGetInteger("gPauseAnyCursor", 0) == PAUSE_ANY_CURSOR_RANDO_ONLY && gSaveContext.n64ddFlag) || + (CVarGetInteger("gPauseAnyCursor", 0) == PAUSE_ANY_CURSOR_ALWAYS_ON); OPEN_DISPS(play->state.gfxCtx); @@ -226,7 +228,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) { cursorMoveResult = 1; } } - } else if ((gBitFlags[pauseCtx->cursorPoint[PAUSE_EQUIP] - 1] & gSaveContext.inventory.equipment) || CVarGetInteger("gPauseAnyCursor", 0)) { + } else if ((gBitFlags[pauseCtx->cursorPoint[PAUSE_EQUIP] - 1] & gSaveContext.inventory.equipment) || pauseAnyCursor) { cursorMoveResult = 2; } } else { @@ -260,7 +262,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) { if (CUR_UPG_VALUE(pauseCtx->cursorY[PAUSE_EQUIP]) != 0) { cursorMoveResult = 1; } - } else if ((gBitFlags[pauseCtx->cursorPoint[PAUSE_EQUIP] - 1] & gSaveContext.inventory.equipment) || CVarGetInteger("gPauseAnyCursor", 0)) { + } else if ((gBitFlags[pauseCtx->cursorPoint[PAUSE_EQUIP] - 1] & gSaveContext.inventory.equipment) || pauseAnyCursor) { cursorMoveResult = 2; } } else { @@ -311,7 +313,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) { cursorMoveResult = 1; } } else if ((gBitFlags[pauseCtx->cursorPoint[PAUSE_EQUIP] - 1] & - gSaveContext.inventory.equipment) || CVarGetInteger("gPauseAnyCursor", 0)) { + gSaveContext.inventory.equipment) || pauseAnyCursor) { cursorMoveResult = 2; } } else { @@ -329,7 +331,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) { cursorMoveResult = 1; } } else if ((gBitFlags[pauseCtx->cursorPoint[PAUSE_EQUIP] - 1] & - gSaveContext.inventory.equipment) || CVarGetInteger("gPauseAnyCursor", 0)) { + gSaveContext.inventory.equipment) || pauseAnyCursor) { cursorMoveResult = 2; } } else { 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 b9b17a067..89bc1c6ac 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 @@ -101,6 +101,8 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { s16 oldCursorPoint; s16 moveCursorResult; bool dpad = (CVarGetInteger("gDpadPause", 0) && !CHECK_BTN_ALL(input->cur.button, BTN_CUP)); + bool pauseAnyCursor = (CVarGetInteger("gPauseAnyCursor", 0) == PAUSE_ANY_CURSOR_RANDO_ONLY && gSaveContext.n64ddFlag) || + (CVarGetInteger("gPauseAnyCursor", 0) == PAUSE_ANY_CURSOR_ALWAYS_ON); OPEN_DISPS(play->state.gfxCtx); @@ -142,7 +144,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { pauseCtx->cursorX[PAUSE_ITEM] -= 1; pauseCtx->cursorPoint[PAUSE_ITEM] -= 1; if ((gSaveContext.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] != ITEM_NONE) || - CVarGetInteger("gPauseAnyCursor", 0)) { + pauseAnyCursor) { moveCursorResult = 1; } } else { @@ -174,7 +176,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { pauseCtx->cursorX[PAUSE_ITEM] += 1; pauseCtx->cursorPoint[PAUSE_ITEM] += 1; if ((gSaveContext.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] != ITEM_NONE) || - CVarGetInteger("gPauseAnyCursor", 0)) { + pauseAnyCursor) { moveCursorResult = 1; } } else { @@ -296,7 +298,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { pauseCtx->cursorY[PAUSE_ITEM] -= 1; pauseCtx->cursorPoint[PAUSE_ITEM] -= 6; if ((gSaveContext.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] != ITEM_NONE) || - CVarGetInteger("gPauseAnyCursor", 0)) { + pauseAnyCursor) { moveCursorResult = 1; } } else { @@ -310,7 +312,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { pauseCtx->cursorY[PAUSE_ITEM] += 1; pauseCtx->cursorPoint[PAUSE_ITEM] += 6; if ((gSaveContext.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] != ITEM_NONE) || - CVarGetInteger("gPauseAnyCursor", 0)) { + pauseAnyCursor) { moveCursorResult = 1; } } else { 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 54d23405d..fce208c10 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 @@ -1912,7 +1912,10 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { } } } else { - if (!pauseCtx->pageIndex && (!CVarGetInteger("gPauseAnyCursor", 0) || (gSaveContext.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] != ITEM_NONE))) { // pageIndex == PAUSE_ITEM + bool pauseAnyCursor = + (CVarGetInteger("gPauseAnyCursor", 0) == PAUSE_ANY_CURSOR_RANDO_ONLY && gSaveContext.n64ddFlag) || + (CVarGetInteger("gPauseAnyCursor", 0) == PAUSE_ANY_CURSOR_ALWAYS_ON); + if (!pauseCtx->pageIndex && (!pauseAnyCursor || (gSaveContext.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] != ITEM_NONE))) { // pageIndex == PAUSE_ITEM pauseCtx->infoPanelVtx[16].v.ob[0] = pauseCtx->infoPanelVtx[18].v.ob[0] = WREG(49 + gSaveContext.language); @@ -2048,6 +2051,8 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { void KaleidoScope_UpdateNamePanel(PlayState* play) { PauseContext* pauseCtx = &play->pauseCtx; u16 sp2A; + bool pauseAnyCursor = (CVarGetInteger("gPauseAnyCursor", 0) == PAUSE_ANY_CURSOR_RANDO_ONLY && gSaveContext.n64ddFlag) || + (CVarGetInteger("gPauseAnyCursor", 0) == PAUSE_ANY_CURSOR_ALWAYS_ON); if ((pauseCtx->namedItem != pauseCtx->cursorItem[pauseCtx->pageIndex]) || ((pauseCtx->pageIndex == PAUSE_MAP) && (pauseCtx->cursorSpecialPos != 0))) { @@ -2057,7 +2062,7 @@ void KaleidoScope_UpdateNamePanel(PlayState* play) { osCreateMesgQueue(&pauseCtx->loadQueue, &pauseCtx->loadMsg, 1); - if (CVarGetInteger("gPauseAnyCursor", 0) && + if (pauseAnyCursor && ((pauseCtx->pageIndex == PAUSE_EQUIP && pauseCtx->cursorX[PAUSE_EQUIP] != 0 && !CHECK_OWNED_EQUIP(pauseCtx->cursorY[PAUSE_EQUIP], pauseCtx->cursorX[PAUSE_EQUIP] - 1)) || (pauseCtx->pageIndex == PAUSE_ITEM && gSaveContext.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] == ITEM_NONE))) { pauseCtx->namedItem = PAUSE_ITEM_NONE;