From bd7b3d48e6cc5acb4c7c8bbca89a833885250251 Mon Sep 17 00:00:00 2001 From: aMannus Date: Sat, 7 Dec 2024 23:54:34 +0100 Subject: [PATCH 1/7] Initial mockup --- soh/include/z64.h | 3 + .../gamestates/ovl_file_choose/file_choose.h | 4 + .../ovl_file_choose/z_file_choose.c | 193 +++++++++++++++++- 3 files changed, 189 insertions(+), 11 deletions(-) diff --git a/soh/include/z64.h b/soh/include/z64.h index cd66089a8f6..d1678147adb 100644 --- a/soh/include/z64.h +++ b/soh/include/z64.h @@ -1595,6 +1595,9 @@ typedef struct { uint8_t bossRushOffset; int16_t bossRushUIAlpha; uint16_t bossRushArrowOffset; + uint8_t randomizerIndex; + int16_t randomizerUIAlpha; + uint16_t randomizerArrowOffset; } FileChooseContext; // size = 0x1CAE0 // Macros for `EntranceInfo.field` diff --git a/soh/src/overlays/gamestates/ovl_file_choose/file_choose.h b/soh/src/overlays/gamestates/ovl_file_choose/file_choose.h index 59d2515840c..f40e1dde6df 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/file_choose.h +++ b/soh/src/overlays/gamestates/ovl_file_choose/file_choose.h @@ -65,6 +65,10 @@ typedef enum { CM_BOSS_RUSH_MENU, CM_START_BOSS_RUSH_MENU, CM_BOSS_RUSH_TO_QUEST, + CM_ROTATE_TO_RANDOMIZER_MENU, + CM_RANDOMIZER_MENU, + CM_START_RANDOMIZER_MENU, + CM_RANDOMIZER_TO_QUEST, CM_GENERATE_SEED, } ConfigMode; diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index b093a746ce0..ede7537019f 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -1249,6 +1249,19 @@ void FileChoose_StartBossRushMenu(GameState* thisx) { } } +void FileChoose_StartRandomizerMenu(GameState* thisx) { + FileChooseContext* this = (FileChooseContext*)thisx; + + this->logoAlpha -= 25; + this->randomizerUIAlpha = 0; + this->randomizerArrowOffset = 0; + + if (this->logoAlpha >= 0) { + this->logoAlpha = 0; + this->configMode = CM_RANDOMIZER_MENU; + } +} + void FileChoose_UpdateQuestMenu(GameState* thisx) { static u8 emptyName[] = { 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E }; static u8 linkName[] = { 0x15, 0x2C, 0x31, 0x2E, 0x3E, 0x3E, 0x3E, 0x3E }; @@ -1306,7 +1319,7 @@ void FileChoose_UpdateQuestMenu(GameState* thisx) { } else if (this->questType[this->buttonIndex] == QUEST_RANDOMIZER) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); this->prevConfigMode = this->configMode; - this->configMode = CM_GENERATE_SEED; + this->configMode = CM_ROTATE_TO_RANDOMIZER_MENU; } else { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); osSyncPrintf("Selected Dungeon Quest: %d\n", IS_MASTER_QUEST); @@ -1471,6 +1484,73 @@ void FileChoose_UpdateBossRushMenu(GameState* thisx) { } } +void FileChoose_UpdateRandomizerMenu(GameState* thisx) { + FileChoose_UpdateStickDirectionPromptAnim(thisx); + FileChooseContext* this = (FileChooseContext*)thisx; + Input* input = &this->state.input[0]; + bool dpad = CVarGetInteger(CVAR_SETTING("DpadInText"), 0); + + // Fade in elements after opening Boss Rush options menu + this->randomizerUIAlpha += 25; + if (this->randomizerUIAlpha > 255) { + this->randomizerUIAlpha = 255; + } + + // Move menu selection up or down. + if (ABS(this->stickRelY) > 30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DDOWN | BTN_DUP))) { + // Move down + if (this->stickRelY < -30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DDOWN))) { + // When selecting past the last option, cycle back to the first option. + if ((this->randomizerIndex + 1) > 3) { + this->randomizerIndex = 0; + } else { + this->randomizerIndex++; + } + } else if (this->stickRelY > 30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DUP))) { + // When selecting past the first option, cycle back to the last option and offset the list to view it properly. + if ((this->randomizerIndex - 1) < 0) { + this->randomizerIndex = 3; + } else { + this->randomizerIndex--; + } + } + + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + } + + // Cycle through spoiler log + if (ABS(this->stickRelX) > 30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DLEFT | BTN_DRIGHT))) { + if (this->stickRelX > 30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DRIGHT))) { + // If exceeding the amount of choices for the selected option, cycle back to the first. + if ((gSaveContext.bossRushOptions[this->bossRushIndex] + 1) == BossRush_GetSettingOptionsAmount(this->bossRushIndex)) { + gSaveContext.bossRushOptions[this->bossRushIndex] = 0; + } else { + gSaveContext.bossRushOptions[this->bossRushIndex]++; + } + } else if (this->stickRelX < -30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DLEFT))) { + // If cycling back when already at the first choice for the selected option, cycle back to the last choice. + if ((gSaveContext.bossRushOptions[this->bossRushIndex] - 1) < 0) { + gSaveContext.bossRushOptions[this->bossRushIndex] = BossRush_GetSettingOptionsAmount(this->bossRushIndex) - 1; + } else { + gSaveContext.bossRushOptions[this->bossRushIndex]--; + } + } + + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + } + + if (CHECK_BTN_ALL(input->press.button, BTN_B)) { + this->configMode = CM_RANDOMIZER_TO_QUEST; + return; + } + + // Handle executing options + if (CHECK_BTN_ALL(input->press.button, BTN_START) || CHECK_BTN_ALL(input->press.button, BTN_A)) { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + + } +} + /** * Update function for `CM_UNUSED_31` */ @@ -1552,7 +1632,8 @@ void FileChoose_RotateToMain(GameState* thisx) { void FileChoose_RotateToQuest(GameState* thisx) { FileChooseContext* this = (FileChooseContext*)thisx; - if (this->configMode == CM_NAME_ENTRY_TO_QUEST_MENU || this->configMode == CM_BOSS_RUSH_TO_QUEST) { + if (this->configMode == CM_NAME_ENTRY_TO_QUEST_MENU || this->configMode == CM_BOSS_RUSH_TO_QUEST || + this->configMode == CM_RANDOMIZER_TO_QUEST) { this->windowRot -= VREG(16); if (this->windowRot <= 314.0f) { @@ -1580,6 +1661,17 @@ void FileChoose_RotateToBossRush(GameState* thisx) { } } +void FileChoose_RotateToRandomizer(GameState* thisx) { + FileChooseContext* this = (FileChooseContext*)thisx; + + this->windowRot += VREG(16); + + if (this->windowRot >= 628.0f) { + this->windowRot = 628.0f; + this->configMode = CM_START_RANDOMIZER_MENU; + } +} + static void (*gConfigModeUpdateFuncs[])(GameState*) = { FileChoose_StartFadeIn, FileChoose_FinishFadeIn, FileChoose_UpdateMainMenu, FileChoose_SetupCopySource, @@ -1606,7 +1698,8 @@ static void (*gConfigModeUpdateFuncs[])(GameState*) = { FileChoose_RotateToMain, FileChoose_RotateToQuest, FileChoose_RotateToBossRush, FileChoose_UpdateBossRushMenu, FileChoose_StartBossRushMenu, FileChoose_RotateToQuest, - FileChoose_GenerateRandoSeed, + FileChoose_RotateToRandomizer, FileChoose_UpdateRandomizerMenu, + FileChoose_StartRandomizerMenu,FileChoose_RotateToQuest, }; /** @@ -2206,7 +2299,7 @@ void FileChoose_DrawWindowContents(GameState* thisx) { case CM_QUEST_TO_MAIN: case CM_NAME_ENTRY_TO_QUEST_MENU: case CM_ROTATE_TO_BOSS_RUSH_MENU: - case CM_GENERATE_SEED: + case CM_ROTATE_TO_RANDOMIZER_MENU: tex = FileChoose_GetQuestChooseTitleTexName(gSaveContext.language); break; case CM_BOSS_RUSH_MENU: @@ -2214,6 +2307,11 @@ void FileChoose_DrawWindowContents(GameState* thisx) { case CM_BOSS_RUSH_TO_QUEST: tex = FileChoose_GetBossRushOptionsTitleTexName(gSaveContext.language); break; + case CM_RANDOMIZER_MENU: + case CM_START_RANDOMIZER_MENU: + case CM_RANDOMIZER_TO_QUEST: + tex = FileChoose_GetBossRushOptionsTitleTexName(gSaveContext.language); + break; default: tex = sTitleLabels[gSaveContext.language][this->titleLabel]; break; @@ -2282,11 +2380,7 @@ void FileChoose_DrawWindowContents(GameState* thisx) { break; case QUEST_RANDOMIZER: - if (this->configMode == CM_GENERATE_SEED) { - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->logoAlpha / 2); - } else { - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->logoAlpha); - } + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->logoAlpha); FileChoose_DrawTextureI8(this->state.gfxCtx, gTitleTheLegendOfTextTex, 72, 8, 156, 108, 72, 8, 1024, 1024); FileChoose_DrawTextureI8(this->state.gfxCtx, gTitleOcarinaOfTimeTMTextTex, 96, 8, 154, 163, 96, 8, 1024, 1024); FileChoose_DrawImageRGBA32(this->state.gfxCtx, 160, 135, ResourceMgr_GameHasOriginal() ? gTitleZeldaShieldLogoTex : gTitleZeldaShieldLogoMQTex, 160, 160); @@ -2360,9 +2454,55 @@ void FileChoose_DrawWindowContents(GameState* thisx) { (92 + textYOffset), 0.42f, 0, 0, 1.0f, 1.0f); } } + } else if (this->configMode == CM_RANDOMIZER_MENU) { + + uint8_t textAlpha = this->randomizerUIAlpha; + uint8_t textColorB = 0; + + textColorB = this->randomizerIndex == 0 ? 80 : 255; + Interface_DrawTextLine(this->state.gfxCtx, "Create New Randomizer", 70, (80 + 0), 255, 255, textColorB, textAlpha, 0.8f, true); + + textColorB = this->randomizerIndex == 1 ? 80 : 255; + Interface_DrawTextLine(this->state.gfxCtx, "Generate New Seed", 70, (80 + 16), 255, 255, textColorB, textAlpha, 0.8f, true); + + textColorB = this->randomizerIndex == 2 ? 80 : 255; + Interface_DrawTextLine(this->state.gfxCtx, "Open Randomizer Settings", 70, (80 + 32), 255, 255, textColorB, textAlpha, 0.8f, true); + + textColorB = this->randomizerIndex == 3 ? 80 : 255; + Interface_DrawTextLine(this->state.gfxCtx, "Select Seed:", 70, (80 + 48), 255, 255, textColorB, textAlpha, 0.8f, true); + + uint16_t finalKerning = Interface_DrawTextLine(this->state.gfxCtx, "10-10-10-10-10.json", 140, (80 + 48), 255, 255, 255, textAlpha, 0.8f, true); + + if (this->randomizerIndex != 3) { + uint16_t textOffset = 16 * this->randomizerIndex; + Gfx_SetupDL_39Opa(this->state.gfxCtx); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPLoadTextureBlock(POLY_OPA_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + FileChoose_DrawTextRec(this->state.gfxCtx, this->stickRightPrompt.arrowColorR, + this->stickRightPrompt.arrowColorG, this->stickRightPrompt.arrowColorB, textAlpha, + 62, (85 + textOffset), 0.42f, 0, 0, 1.0f, 1.0f); + } else { + Gfx_SetupDL_39Opa(this->state.gfxCtx); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPLoadTextureBlock(POLY_OPA_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + FileChoose_DrawTextRec(this->state.gfxCtx, this->stickLeftPrompt.arrowColorR, + this->stickLeftPrompt.arrowColorG, this->stickLeftPrompt.arrowColorB, + textAlpha, 135, (85 + 48), 0.42f, 0, 0, -1.0f, + 1.0f); + FileChoose_DrawTextRec(this->state.gfxCtx, this->stickRightPrompt.arrowColorR, + this->stickRightPrompt.arrowColorG, this->stickRightPrompt.arrowColorB, + textAlpha, (146 + finalKerning), + (85 + 48), 0.42f, 0, 0, 1.0f, 1.0f); + } } else if (this->configMode != CM_ROTATE_TO_NAME_ENTRY && this->configMode != CM_START_BOSS_RUSH_MENU && - this->configMode != CM_ROTATE_TO_BOSS_RUSH_MENU && this->configMode != CM_BOSS_RUSH_TO_QUEST) { + this->configMode != CM_ROTATE_TO_BOSS_RUSH_MENU && this->configMode != CM_BOSS_RUSH_TO_QUEST && + this->configMode != CM_START_RANDOMIZER_MENU && this->configMode != CM_ROTATE_TO_RANDOMIZER_MENU && + this->configMode != CM_RANDOMIZER_TO_QUEST) { gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->titleAlpha[1]); gDPLoadTextureBlock(POLY_OPA_DISP++, sTitleLabels[gSaveContext.language][this->nextTitleLabel], G_IM_FMT_IA, @@ -2707,7 +2847,7 @@ void FileChoose_ConfigModeDraw(GameState* thisx) { if ((this->configMode == CM_QUEST_MENU) || (this->configMode == CM_ROTATE_TO_QUEST_MENU) || (this->configMode == CM_ROTATE_TO_NAME_ENTRY) || this->configMode == CM_QUEST_TO_MAIN || this->configMode == CM_NAME_ENTRY_TO_QUEST_MENU || this->configMode == CM_ROTATE_TO_BOSS_RUSH_MENU || - this->configMode == CM_GENERATE_SEED) { + this->configMode == CM_ROTATE_TO_RANDOMIZER_MENU) { // window gDPPipeSync(POLY_OPA_DISP++); gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); @@ -2766,6 +2906,36 @@ void FileChoose_ConfigModeDraw(GameState* thisx) { FileChoose_DrawWindowContents(&this->state); } + // Draw Randomizer Options Menu + if (this->configMode == CM_RANDOMIZER_MENU || this->configMode == CM_ROTATE_TO_RANDOMIZER_MENU || + this->configMode == CM_START_RANDOMIZER_MENU || this->configMode == CM_RANDOMIZER_TO_QUEST) { + // window + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2], + this->windowAlpha); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + + Matrix_Translate(0.0f, 0.0f, -93.6f, MTXMODE_NEW); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateX((this->windowRot - 628.0f) / 100.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(this->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPVertex(POLY_OPA_DISP++, &this->windowVtx[0], 32, 0); + gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow1DL); + + gSPVertex(POLY_OPA_DISP++, &this->windowVtx[32], 32, 0); + gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow2DL); + + gSPVertex(POLY_OPA_DISP++, &this->windowVtx[64], 16, 0); + gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow3DL); + + gDPPipeSync(POLY_OPA_DISP++); + + FileChoose_DrawWindowContents(&this->state); + } + gDPPipeSync(POLY_OPA_DISP++); FileChoose_SetView(this, 0.0f, 0.0f, 64.0f); @@ -3629,6 +3799,7 @@ void FileChoose_InitContext(GameState* thisx) { this->bossRushIndex = 0; this->bossRushOffset = 0; + this->randomizerIndex = 0; ShrinkWindow_SetVal(0); From 589719b0441f318b7f27f3b0d70b33993c7332b7 Mon Sep 17 00:00:00 2001 From: aMannus Date: Thu, 2 Jan 2025 09:20:12 +0100 Subject: [PATCH 2/7] Rip out part of plando mode, implement rando settings menu --- .../randomizer/3drando/rando_main.cpp | 1 - soh/soh/Enhancements/randomizer/context.cpp | 24 +- soh/soh/Enhancements/randomizer/context.h | 4 +- soh/soh/OTRGlobals.cpp | 18 +- soh/soh/OTRGlobals.h | 3 - soh/soh/SohMenuBar.cpp | 20 +- soh/src/code/z_sram.c | 2 +- .../gamestates/ovl_file_choose/file_choose.h | 10 +- .../ovl_file_choose/z_file_choose.c | 269 ++++++++---------- .../ovl_file_choose/z_file_nameset_PAL.c | 6 +- 10 files changed, 140 insertions(+), 217 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp b/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp index 7a396aa6b53..a2ed9807220 100644 --- a/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp @@ -16,5 +16,4 @@ void RandoMain::GenerateRando(std::set excludedLocations, std:: Rando::Context::GetInstance()->SetSeedGenerated(GenerateRandomizer(excludedLocations, enabledTricks, seedString)); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); - Rando::Context::GetInstance()->SetPlandoLoaded(false); } diff --git a/soh/soh/Enhancements/randomizer/context.cpp b/soh/soh/Enhancements/randomizer/context.cpp index 39067f6a6bb..0b0af0af826 100644 --- a/soh/soh/Enhancements/randomizer/context.cpp +++ b/soh/soh/Enhancements/randomizer/context.cpp @@ -229,14 +229,6 @@ void Context::SetSpoilerLoaded(const bool spoilerLoaded) { mSpoilerLoaded = spoilerLoaded; } -bool Context::IsPlandoLoaded() const { - return mPlandoLoaded; -} - -void Context::SetPlandoLoaded(const bool plandoLoaded) { - mPlandoLoaded = plandoLoaded; -} - GetItemEntry Context::GetFinalGIEntry(const RandomizerCheck rc, const bool checkObtainability, const GetItemID ogItemId) { const auto itemLoc = GetItemLocation(rc); if (itemLoc->GetPlacedRandomizerGet() == RG_NONE) { @@ -279,7 +271,7 @@ std::string sanitize(std::string stringValue) { return stringValue; } -void Context::ParseSpoiler(const char* spoilerFileName, const bool plandoMode) { +void Context::ParseSpoiler(const char* spoilerFileName) { std::ifstream spoilerFileStream(sanitize(spoilerFileName)); if (!spoilerFileStream) { return; @@ -292,14 +284,12 @@ void Context::ParseSpoiler(const char* spoilerFileName, const bool plandoMode) { spoilerFileStream >> spoilerFileJson; ParseHashIconIndexesJson(spoilerFileJson); mSettings->ParseJson(spoilerFileJson); - if (plandoMode) { - ParseItemLocationsJson(spoilerFileJson); - ParseHintJson(spoilerFileJson); - mEntranceShuffler->ParseJson(spoilerFileJson); - mDungeons->ParseJson(spoilerFileJson); - mTrials->ParseJson(spoilerFileJson); - mPlandoLoaded = true; - } + ParseItemLocationsJson(spoilerFileJson); + ParseHintJson(spoilerFileJson); + mEntranceShuffler->ParseJson(spoilerFileJson); + mDungeons->ParseJson(spoilerFileJson); + mTrials->ParseJson(spoilerFileJson); + mPlandoLoaded = true; mSpoilerLoaded = true; mSeedGenerated = false; } catch (...) { diff --git a/soh/soh/Enhancements/randomizer/context.h b/soh/soh/Enhancements/randomizer/context.h index 842b73c2515..b276f79b5e8 100644 --- a/soh/soh/Enhancements/randomizer/context.h +++ b/soh/soh/Enhancements/randomizer/context.h @@ -62,8 +62,6 @@ class Context { void SetSeedGenerated(bool seedGenerated = true); bool IsSpoilerLoaded() const; void SetSpoilerLoaded(bool spoilerLoaded = true); - bool IsPlandoLoaded() const; - void SetPlandoLoaded(bool plandoLoaded = true); std::shared_ptr GetSettings(); std::shared_ptr GetEntranceShuffler(); std::shared_ptr GetDungeons(); @@ -78,7 +76,7 @@ class Context { Option& GetOption(RandomizerSettingKey key) const; TrickOption& GetTrickOption(RandomizerTrick key) const; GetItemEntry GetFinalGIEntry(RandomizerCheck rc, bool checkObtainability = true, GetItemID ogItemId = GI_NONE); - void ParseSpoiler(const char* spoilerFileName, bool plandoMode); + void ParseSpoiler(const char* spoilerFileName); void ParseHashIconIndexesJson(nlohmann::json spoilerFileJson); void ParseItemLocationsJson(nlohmann::json spoilerFileJson); void WriteHintJson(nlohmann::ordered_json& spoilerFileJson); diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 9189da7e581..d25e518c726 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1902,7 +1902,7 @@ extern "C" int GetEquipNowMessage(char* buffer, char* src, const int maxBufferSi } extern "C" void Randomizer_ParseSpoiler(const char* fileLoc) { - OTRGlobals::Instance->gRandoContext->ParseSpoiler(fileLoc, CVarGetInteger(CVAR_GENERAL("PlandoMode"), 0)); + OTRGlobals::Instance->gRandoContext->ParseSpoiler(fileLoc); } extern "C" void Randomizer_LoadHintMessages() { @@ -1993,14 +1993,6 @@ extern "C" GetItemEntry GetItemMystery() { return { ITEM_NONE_FE, 0, 0, 0, 0, 0, 0, ITEM_NONE_FE, 0, false, ITEM_FROM_NPC, ITEM_CATEGORY_JUNK, NULL, MOD_RANDOMIZER, (CustomDrawFunc)Randomizer_DrawMysteryItem }; } -extern "C" void Randomizer_GenerateSeed() { - std::string seed = ""; - if (OTRGlobals::Instance->gRandoContext->IsSpoilerLoaded()) { - seed = OTRGlobals::Instance->gRandoContext->GetSettings()->GetSeedString(); - } - GenerateRandomizer(seed); -} - extern "C" uint8_t Randomizer_IsSeedGenerated() { return OTRGlobals::Instance->gRandoContext->IsSeedGenerated() ? 1 : 0; } @@ -2017,14 +2009,6 @@ extern "C" void Randomizer_SetSpoilerLoaded(bool spoilerLoaded) { OTRGlobals::Instance->gRandoContext->SetSpoilerLoaded(spoilerLoaded); } -extern "C" uint8_t Randomizer_IsPlandoLoaded() { - return OTRGlobals::Instance->gRandoContext->IsPlandoLoaded() ? 1 : 0; -} - -extern "C" void Randomizer_SetPlandoLoaded(bool plandoLoaded) { - OTRGlobals::Instance->gRandoContext->SetPlandoLoaded(plandoLoaded); -} - CustomMessage Randomizer_GetCustomGetItemMessage(Player* player) { s16 giid; if (player->getItemEntry.objectId != OBJECT_INVALID) { diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 854ef5b8fc2..283d76f3317 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -135,13 +135,10 @@ RandomizerInf Randomizer_GetRandomizerInfFromCheck(RandomizerCheck randomizerChe bool Randomizer_IsCheckShuffled(RandomizerCheck check); GetItemEntry GetItemMystery(); ItemObtainability Randomizer_GetItemObtainabilityFromRandomizerCheck(RandomizerCheck randomizerCheck); -void Randomizer_GenerateSeed(); uint8_t Randomizer_IsSeedGenerated(); void Randomizer_SetSeedGenerated(bool seedGenerated); uint8_t Randomizer_IsSpoilerLoaded(); void Randomizer_SetSpoilerLoaded(bool spoilerLoaded); -uint8_t Randomizer_IsPlandoLoaded(); -void Randomizer_SetPlandoLoaded(bool plandoLoaded); int CustomMessage_RetrieveIfExists(PlayState* play); void Overlay_DisplayText(float duration, const char* text); void Overlay_DisplayText_Seconds(int seconds, const char* text); diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index c4989542180..c4067ce1c01 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -2119,14 +2119,6 @@ extern "C" u8 Randomizer_GetSettingValue(RandomizerSettingKey randoSettingKey); void DrawRandomizerMenu() { if (ImGui::BeginMenu("Randomizer")) { - UIWidgets::EnhancementCheckbox("Plando Mode", CVAR_GENERAL("PlandoMode")); - UIWidgets::Tooltip( - "When dropping a spoiler file on the game window, parse the full spoiler file instead of just the " - "necessary " - "parts to regenerate a seed.\n\nKeep in mind if you do this, all custom text will only be available in the " - "language present in the spoilerfile. You can use this to edit a previously generated spoilerfile that has " - "been edited with custom hint text and item locations. May be useful for debugging."); - UIWidgets::PaddedSeparator(); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(12.0f, 6.0f)); ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0)); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); @@ -2144,17 +2136,17 @@ void DrawRandomizerMenu() { static float separationToOptionsButton = 5.0f; #endif - if (mPlandomizerWindow) { - if (ImGui::Button(GetWindowButtonText("Plandomizer Editor", CVarGetInteger(CVAR_WINDOW("PlandomizerWindow"), 0)).c_str(), buttonSize)) { - mPlandomizerWindow->ToggleVisibility(); + if (mRandomizerSettingsWindow) { + if (ImGui::Button(GetWindowButtonText("Randomizer Settings", CVarGetInteger(CVAR_WINDOW("RandomizerSettings"), 0)).c_str(), buttonSize)) { + mRandomizerSettingsWindow->ToggleVisibility(); } } UIWidgets::Spacer(0); - if (mRandomizerSettingsWindow) { - if (ImGui::Button(GetWindowButtonText("Randomizer Settings", CVarGetInteger(CVAR_WINDOW("RandomizerSettings"), 0)).c_str(), buttonSize)) { - mRandomizerSettingsWindow->ToggleVisibility(); + if (mPlandomizerWindow) { + if (ImGui::Button(GetWindowButtonText("Plandomizer Editor", CVarGetInteger(CVAR_WINDOW("PlandomizerWindow"), 0)).c_str(), buttonSize)) { + mPlandomizerWindow->ToggleVisibility(); } } diff --git a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c index e7e43a823bf..d5b4f888f62 100644 --- a/soh/src/code/z_sram.c +++ b/soh/src/code/z_sram.c @@ -251,7 +251,7 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx) { u8 currentQuest = fileChooseCtx->questType[fileChooseCtx->buttonIndex]; - if (currentQuest == QUEST_RANDOMIZER && (Randomizer_IsSeedGenerated() || Randomizer_IsPlandoLoaded())) { + if (currentQuest == QUEST_RANDOMIZER && Randomizer_IsSeedGenerated()) { gSaveContext.questId = QUEST_RANDOMIZER; Randomizer_InitSaveFile(); diff --git a/soh/src/overlays/gamestates/ovl_file_choose/file_choose.h b/soh/src/overlays/gamestates/ovl_file_choose/file_choose.h index f40e1dde6df..3e3106ef494 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/file_choose.h +++ b/soh/src/overlays/gamestates/ovl_file_choose/file_choose.h @@ -65,11 +65,11 @@ typedef enum { CM_BOSS_RUSH_MENU, CM_START_BOSS_RUSH_MENU, CM_BOSS_RUSH_TO_QUEST, - CM_ROTATE_TO_RANDOMIZER_MENU, - CM_RANDOMIZER_MENU, - CM_START_RANDOMIZER_MENU, - CM_RANDOMIZER_TO_QUEST, - CM_GENERATE_SEED, + CM_ROTATE_TO_RANDOMIZER_SETTINGS_MENU, + CM_RANDOMIZER_SETTINGS_MENU, + CM_START_RANDOMIZER_SETTINGS_MENU, + CM_RANDOMIZER_SETTINGS_MENU_TO_QUEST, + CM_NAME_ENTRY_TO_RANDOMIZER_SETTINGS_MENU, } ConfigMode; typedef enum { diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index fef3ee6dced..1896eba3434 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -984,17 +984,13 @@ void DrawSeedHashSprites(FileChooseContext* this) { // 1. On Name Entry if a rando seed has been generated // 2. On Quest Menu if a spoiler has been dropped and the Randomizer quest option is currently hovered. if ((Randomizer_IsSeedGenerated() || Randomizer_IsSpoilerLoaded()) && - ((this->configMode == CM_NAME_ENTRY && gSaveContext.questId == QUEST_RANDOMIZER) || - (this->configMode == CM_GENERATE_SEED && Randomizer_IsSpoilerLoaded()) || - (this->configMode == CM_QUEST_MENU && this->questType[this->buttonIndex] == QUEST_RANDOMIZER))) { - // Fade top seed icons based on main menu fade and if save supports rando - u8 alpha = - MAX(this->optionButtonAlpha, Save_GetSaveMetaInfo(this->selectedFileIndex)->randoSave == 1 ? 0xFF : 0); - if (alpha >= 200) { - alpha = 0xFF; - } + (((this->configMode == CM_NAME_ENTRY || this->configMode == CM_ROTATE_TO_NAME_ENTRY || + this->configMode == CM_NAME_ENTRY_TO_RANDOMIZER_SETTINGS_MENU || this->configMode == CM_START_NAME_ENTRY || + this->configMode == CM_START_RANDOMIZER_SETTINGS_MENU) && + gSaveContext.questId == QUEST_RANDOMIZER) || + (this->configMode == CM_RANDOMIZER_SETTINGS_MENU && Randomizer_IsSpoilerLoaded()))) { - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0xFF, 0xFF, 0xFF, alpha); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF); u16 xStart = 64; for (unsigned int i = 0; i < 5; i++) { SpriteLoad(this, GetSeedTexture(GetSeedIconIndex(i))); @@ -1243,7 +1239,7 @@ void FileChoose_StartBossRushMenu(GameState* thisx) { this->bossRushUIAlpha = 0; this->bossRushArrowOffset = 0; - if (this->logoAlpha >= 0) { + if (this->logoAlpha <= 0) { this->logoAlpha = 0; this->configMode = CM_BOSS_RUSH_MENU; } @@ -1256,9 +1252,9 @@ void FileChoose_StartRandomizerMenu(GameState* thisx) { this->randomizerUIAlpha = 0; this->randomizerArrowOffset = 0; - if (this->logoAlpha >= 0) { + if (this->logoAlpha <= 0) { this->logoAlpha = 0; - this->configMode = CM_RANDOMIZER_MENU; + this->configMode = CM_RANDOMIZER_SETTINGS_MENU; } } @@ -1300,14 +1296,6 @@ void FileChoose_UpdateQuestMenu(GameState* thisx) { GameInteractor_ExecuteOnUpdateFileQuestSelection(this->questType[this->buttonIndex]); } - if (CHECK_BTN_ALL(input->press.button, BTN_L)) { - if (this->questType[this->buttonIndex] == QUEST_RANDOMIZER) { - Randomizer_SetSpoilerLoaded(false); - this->prevConfigMode = this->configMode; - this->configMode = CM_GENERATE_SEED; - } - } - if (CHECK_BTN_ALL(input->press.button, BTN_A)) { gSaveContext.questId = this->questType[this->buttonIndex]; @@ -1319,14 +1307,14 @@ void FileChoose_UpdateQuestMenu(GameState* thisx) { } else if (this->questType[this->buttonIndex] == QUEST_RANDOMIZER) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); this->prevConfigMode = this->configMode; - this->configMode = CM_ROTATE_TO_RANDOMIZER_MENU; + this->configMode = CM_ROTATE_TO_RANDOMIZER_SETTINGS_MENU; } else { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); osSyncPrintf("Selected Dungeon Quest: %d\n", IS_MASTER_QUEST); this->prevConfigMode = this->configMode; this->configMode = CM_ROTATE_TO_NAME_ENTRY; this->logoAlpha = 0; - CVarSetInteger(CVAR_GENERAL("OnFileSelectNameEntry"), 1); + CVarSetInteger(CVAR_GENERAL("OnFileSelectNameEntry"), 0); this->kbdButton = FS_KBD_BTN_NONE; this->charPage = FS_CHAR_PAGE_ENG; this->kbdX = 0; @@ -1348,45 +1336,6 @@ void FileChoose_UpdateQuestMenu(GameState* thisx) { } } -void FileChoose_GenerateRandoSeed(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - FileChoose_UpdateRandomizer(); - if (Randomizer_IsSeedGenerated() || Randomizer_IsPlandoLoaded()) { - Audio_PlayFanfare(NA_BGM_HORSE_GOAL); - func_800F5E18(SEQ_PLAYER_BGM_MAIN, NA_BGM_FILE_SELECT, 0, 7, 1); - generating = 0; - retries = 0; - Randomizer_SetSpoilerLoaded(true); - static u8 emptyName[] = { 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E }; - static u8 linkName[] = { 0x15, 0x2C, 0x31, 0x2E, 0x3E, 0x3E, 0x3E, 0x3E }; - this->prevConfigMode = this->configMode; - this->configMode = CM_ROTATE_TO_NAME_ENTRY; - this->logoAlpha = 0; - CVarSetInteger(CVAR_GENERAL("OnFileSelectNameEntry"), 1); - this->kbdButton = FS_KBD_BTN_NONE; - this->charPage = FS_CHAR_PAGE_ENG; - this->kbdX = 0; - this->kbdY = 0; - this->charIndex = 0; - this->charBgAlpha = 0; - this->newFileNameCharCount = CVarGetInteger(CVAR_ENHANCEMENT("LinkDefaultName"), 0) ? 4 : 0; - this->nameEntryBoxPosX = 120; - this->nameEntryBoxAlpha = 0; - memcpy(Save_GetSaveMetaInfo(this->buttonIndex)->playerName, - CVarGetInteger(CVAR_ENHANCEMENT("LinkDefaultName"), 0) ? &linkName : &emptyName, 8); - return; - } - if (!generating) { - if (retries >= 5 || (retries >= 1 && Randomizer_IsSpoilerLoaded())){ - this->configMode = CM_QUEST_MENU; - retries = 0; - } else { - Randomizer_GenerateSeed(); - retries++; - } - } -} - static s8 sLastBossRushOptionIndex = -1; static s8 sLastBossRushOptionValue = -1; @@ -1490,7 +1439,7 @@ void FileChoose_UpdateRandomizerMenu(GameState* thisx) { Input* input = &this->state.input[0]; bool dpad = CVarGetInteger(CVAR_SETTING("DpadInText"), 0); - // Fade in elements after opening Boss Rush options menu + // Fade in elements after opening Randomizer options menu this->randomizerUIAlpha += 25; if (this->randomizerUIAlpha > 255) { this->randomizerUIAlpha = 255; @@ -1540,10 +1489,34 @@ void FileChoose_UpdateRandomizerMenu(GameState* thisx) { } if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - this->configMode = CM_RANDOMIZER_TO_QUEST; + this->configMode = CM_RANDOMIZER_SETTINGS_MENU_TO_QUEST; return; } + if (CHECK_BTN_ALL(input->press.button, BTN_A)) { + if (this->randomizerIndex == 0) { + func_800F5E18(SEQ_PLAYER_BGM_MAIN, NA_BGM_FILE_SELECT, 0, 7, 1); + static u8 emptyName[] = { 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E }; + static u8 linkName[] = { 0x15, 0x2C, 0x31, 0x2E, 0x3E, 0x3E, 0x3E, 0x3E }; + this->prevConfigMode = this->configMode; + this->configMode = CM_ROTATE_TO_NAME_ENTRY; + this->logoAlpha = 0; + CVarSetInteger(CVAR_GENERAL("OnFileSelectNameEntry"), 1); + this->kbdButton = FS_KBD_BTN_NONE; + this->charPage = FS_CHAR_PAGE_ENG; + this->kbdX = 0; + this->kbdY = 0; + this->charIndex = 0; + this->charBgAlpha = 0; + this->newFileNameCharCount = CVarGetInteger(CVAR_ENHANCEMENT("LinkDefaultName"), 0) ? 4 : 0; + this->nameEntryBoxPosX = 120; + this->nameEntryBoxAlpha = 0; + memcpy(Save_GetSaveMetaInfo(this->buttonIndex)->playerName, + CVarGetInteger(CVAR_ENHANCEMENT("LinkDefaultName"), 0) ? &linkName : &emptyName, 8); + return; + } + } + // Handle executing options if (CHECK_BTN_ALL(input->press.button, BTN_START) || CHECK_BTN_ALL(input->press.button, BTN_A)) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); @@ -1583,9 +1556,16 @@ void FileChoose_RotateToNameEntry(GameState* thisx) { this->windowRot += VREG(16); - if (this->windowRot >= 628.0f) { - this->windowRot = 628.0f; - this->configMode = CM_START_NAME_ENTRY; + if (this->prevConfigMode == CM_RANDOMIZER_SETTINGS_MENU) { + if (this->windowRot >= 942.0f) { + this->windowRot = 628.0f; + this->configMode = CM_START_NAME_ENTRY; + } + } else { + if (this->windowRot >= 628.0f) { + this->windowRot = 628.0f; + this->configMode = CM_START_NAME_ENTRY; + } } } @@ -1633,7 +1613,7 @@ void FileChoose_RotateToQuest(GameState* thisx) { FileChooseContext* this = (FileChooseContext*)thisx; if (this->configMode == CM_NAME_ENTRY_TO_QUEST_MENU || this->configMode == CM_BOSS_RUSH_TO_QUEST || - this->configMode == CM_RANDOMIZER_TO_QUEST) { + this->configMode == CM_RANDOMIZER_SETTINGS_MENU_TO_QUEST) { this->windowRot -= VREG(16); if (this->windowRot <= 314.0f) { @@ -1664,11 +1644,20 @@ void FileChoose_RotateToBossRush(GameState* thisx) { void FileChoose_RotateToRandomizer(GameState* thisx) { FileChooseContext* this = (FileChooseContext*)thisx; - this->windowRot += VREG(16); + if (this->configMode == CM_NAME_ENTRY_TO_RANDOMIZER_SETTINGS_MENU) { + this->windowRot -= VREG(16); - if (this->windowRot >= 628.0f) { - this->windowRot = 628.0f; - this->configMode = CM_START_RANDOMIZER_MENU; + if (this->windowRot <= 314.0f) { + this->windowRot = 628.0f; + this->configMode = CM_START_RANDOMIZER_SETTINGS_MENU; + } + } else { + this->windowRot += VREG(16); + + if (this->windowRot >= 628.0f) { + this->windowRot = 628.0f; + this->configMode = CM_START_RANDOMIZER_SETTINGS_MENU; + } } } @@ -1700,6 +1689,7 @@ static void (*gConfigModeUpdateFuncs[])(GameState*) = { FileChoose_StartBossRushMenu, FileChoose_RotateToQuest, FileChoose_RotateToRandomizer, FileChoose_UpdateRandomizerMenu, FileChoose_StartRandomizerMenu,FileChoose_RotateToQuest, + FileChoose_RotateToRandomizer }; /** @@ -2266,7 +2256,7 @@ const char* FileChoose_GetQuestChooseTitleTexName(Language lang) { } } -const char* FileChoose_GetBossRushOptionsTitleTexName(Language lang) { +const char* FileChoose_GetShipOptionsTitleTexName(Language lang) { switch (lang) { case LANGUAGE_ENG: default: @@ -2299,18 +2289,17 @@ void FileChoose_DrawWindowContents(GameState* thisx) { case CM_QUEST_TO_MAIN: case CM_NAME_ENTRY_TO_QUEST_MENU: case CM_ROTATE_TO_BOSS_RUSH_MENU: - case CM_ROTATE_TO_RANDOMIZER_MENU: + case CM_ROTATE_TO_RANDOMIZER_SETTINGS_MENU: tex = FileChoose_GetQuestChooseTitleTexName(gSaveContext.language); break; case CM_BOSS_RUSH_MENU: case CM_START_BOSS_RUSH_MENU: case CM_BOSS_RUSH_TO_QUEST: - tex = FileChoose_GetBossRushOptionsTitleTexName(gSaveContext.language); - break; - case CM_RANDOMIZER_MENU: - case CM_START_RANDOMIZER_MENU: - case CM_RANDOMIZER_TO_QUEST: - tex = FileChoose_GetBossRushOptionsTitleTexName(gSaveContext.language); + case CM_RANDOMIZER_SETTINGS_MENU: + case CM_START_RANDOMIZER_SETTINGS_MENU: + case CM_RANDOMIZER_SETTINGS_MENU_TO_QUEST: + case CM_NAME_ENTRY_TO_RANDOMIZER_SETTINGS_MENU: + tex = FileChoose_GetShipOptionsTitleTexName(gSaveContext.language); break; default: tex = sTitleLabels[gSaveContext.language][this->titleLabel]; @@ -2334,34 +2323,32 @@ void FileChoose_DrawWindowContents(GameState* thisx) { // draw next title label if ((this->configMode == CM_QUEST_MENU) || (this->configMode == CM_START_QUEST_MENU) || - this->configMode == CM_NAME_ENTRY_TO_QUEST_MENU || this->configMode == CM_GENERATE_SEED) { + this->configMode == CM_NAME_ENTRY_TO_QUEST_MENU || this->configMode == CM_NAME_ENTRY_TO_RANDOMIZER_SETTINGS_MENU) { // draw control stick prompts. - if (this->configMode != CM_GENERATE_SEED) { - Gfx_SetupDL_39Opa(this->state.gfxCtx); - gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPLoadTextureBlock(POLY_OPA_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, - G_TX_NOLOD); - FileChoose_DrawTextRec(this->state.gfxCtx, this->stickLeftPrompt.arrowColorR, - this->stickLeftPrompt.arrowColorG, this->stickLeftPrompt.arrowColorB, - this->stickLeftPrompt.arrowColorA, this->stickLeftPrompt.arrowTexX, - this->stickLeftPrompt.arrowTexY, this->stickLeftPrompt.z, 0, 0, -1.0f, 1.0f); - FileChoose_DrawTextRec(this->state.gfxCtx, this->stickRightPrompt.arrowColorR, - this->stickRightPrompt.arrowColorG, this->stickRightPrompt.arrowColorB, - this->stickRightPrompt.arrowColorA, this->stickRightPrompt.arrowTexX, - this->stickRightPrompt.arrowTexY, this->stickRightPrompt.z, 0, 0, 1.0f, 1.0f); - gDPLoadTextureBlock(POLY_OPA_DISP++, gControlStickTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, - G_TX_NOLOD); - FileChoose_DrawTextRec(this->state.gfxCtx, this->stickLeftPrompt.stickColorR, - this->stickLeftPrompt.stickColorG, this->stickLeftPrompt.stickColorB, - this->stickLeftPrompt.stickColorA, this->stickLeftPrompt.stickTexX, - this->stickLeftPrompt.stickTexY, this->stickLeftPrompt.z, 0, 0, -1.0f, 1.0f); - FileChoose_DrawTextRec(this->state.gfxCtx, this->stickRightPrompt.stickColorR, - this->stickRightPrompt.stickColorG, this->stickRightPrompt.stickColorB, - this->stickRightPrompt.stickColorA, this->stickRightPrompt.stickTexX, - this->stickRightPrompt.stickTexY, this->stickRightPrompt.z, 0, 0, 1.0f, 1.0f); - } + Gfx_SetupDL_39Opa(this->state.gfxCtx); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPLoadTextureBlock(POLY_OPA_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + FileChoose_DrawTextRec(this->state.gfxCtx, this->stickLeftPrompt.arrowColorR, + this->stickLeftPrompt.arrowColorG, this->stickLeftPrompt.arrowColorB, + this->stickLeftPrompt.arrowColorA, this->stickLeftPrompt.arrowTexX, + this->stickLeftPrompt.arrowTexY, this->stickLeftPrompt.z, 0, 0, -1.0f, 1.0f); + FileChoose_DrawTextRec(this->state.gfxCtx, this->stickRightPrompt.arrowColorR, + this->stickRightPrompt.arrowColorG, this->stickRightPrompt.arrowColorB, + this->stickRightPrompt.arrowColorA, this->stickRightPrompt.arrowTexX, + this->stickRightPrompt.arrowTexY, this->stickRightPrompt.z, 0, 0, 1.0f, 1.0f); + gDPLoadTextureBlock(POLY_OPA_DISP++, gControlStickTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + FileChoose_DrawTextRec(this->state.gfxCtx, this->stickLeftPrompt.stickColorR, + this->stickLeftPrompt.stickColorG, this->stickLeftPrompt.stickColorB, + this->stickLeftPrompt.stickColorA, this->stickLeftPrompt.stickTexX, + this->stickLeftPrompt.stickTexY, this->stickLeftPrompt.z, 0, 0, -1.0f, 1.0f); + FileChoose_DrawTextRec(this->state.gfxCtx, this->stickRightPrompt.stickColorR, + this->stickRightPrompt.stickColorG, this->stickRightPrompt.stickColorB, + this->stickRightPrompt.stickColorA, this->stickRightPrompt.stickTexX, + this->stickRightPrompt.stickTexY, this->stickRightPrompt.z, 0, 0, 1.0f, 1.0f); switch (this->questType[this->buttonIndex]) { case QUEST_NORMAL: default: @@ -2454,7 +2441,7 @@ void FileChoose_DrawWindowContents(GameState* thisx) { (92 + textYOffset), 0.42f, 0, 0, 1.0f, 1.0f); } } - } else if (this->configMode == CM_RANDOMIZER_MENU) { + } else if (this->configMode == CM_RANDOMIZER_SETTINGS_MENU) { uint8_t textAlpha = this->randomizerUIAlpha; uint8_t textColorB = 0; @@ -2501,8 +2488,8 @@ void FileChoose_DrawWindowContents(GameState* thisx) { } else if (this->configMode != CM_ROTATE_TO_NAME_ENTRY && this->configMode != CM_START_BOSS_RUSH_MENU && this->configMode != CM_ROTATE_TO_BOSS_RUSH_MENU && this->configMode != CM_BOSS_RUSH_TO_QUEST && - this->configMode != CM_START_RANDOMIZER_MENU && this->configMode != CM_ROTATE_TO_RANDOMIZER_MENU && - this->configMode != CM_RANDOMIZER_TO_QUEST) { + this->configMode != CM_START_RANDOMIZER_SETTINGS_MENU && this->configMode != CM_ROTATE_TO_RANDOMIZER_SETTINGS_MENU && + this->configMode != CM_RANDOMIZER_SETTINGS_MENU_TO_QUEST && this->configMode != CM_NAME_ENTRY_TO_RANDOMIZER_SETTINGS_MENU) { gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->titleAlpha[1]); gDPLoadTextureBlock(POLY_OPA_DISP++, sTitleLabels[gSaveContext.language][this->nextTitleLabel], G_IM_FMT_IA, @@ -2748,8 +2735,9 @@ void FileChoose_ConfigModeDraw(GameState* thisx) { FrameInterpolation_RecordOpenChild(this, this->configMode); - if ((this->configMode != CM_NAME_ENTRY) && (this->configMode != CM_START_NAME_ENTRY) && - (this->configMode != CM_QUEST_MENU) && this->configMode != CM_NAME_ENTRY_TO_QUEST_MENU) { + if (this->configMode != CM_NAME_ENTRY && this->configMode != CM_START_NAME_ENTRY && + this->configMode != CM_QUEST_MENU && this->configMode != CM_NAME_ENTRY_TO_QUEST_MENU && + this->configMode != CM_RANDOMIZER_SETTINGS_MENU && this->configMode != CM_NAME_ENTRY_TO_RANDOMIZER_SETTINGS_MENU) { gDPPipeSync(POLY_OPA_DISP++); gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2], @@ -2760,9 +2748,8 @@ void FileChoose_ConfigModeDraw(GameState* thisx) { Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); if (this->windowRot != 0) { - if (this->configMode == CM_ROTATE_TO_QUEST_MENU || - (this->configMode >= CM_MAIN_TO_OPTIONS && this->configMode <= CM_OPTIONS_TO_MAIN) || - this->configMode == CM_QUEST_TO_MAIN) { + if ((this->configMode >= CM_MAIN_TO_OPTIONS && this->configMode <= CM_OPTIONS_TO_MAIN) || + this->configMode == CM_ROTATE_TO_QUEST_MENU || this->configMode == CM_QUEST_TO_MAIN) { Matrix_RotateX(this->windowRot / 100.0f, MTXMODE_APPLY); } else { Matrix_RotateX((this->windowRot - 942.0f) / 100.0f, MTXMODE_APPLY); @@ -2796,7 +2783,13 @@ void FileChoose_ConfigModeDraw(GameState* thisx) { Matrix_Translate(0.0f, 0.0f, -93.6f, MTXMODE_NEW); Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); - Matrix_RotateX((this->windowRot - 628.0f) / 100.0f, MTXMODE_APPLY); + // Invert name select when switching from randomizer settings menu to name entry, otherwise + // it'll show on the backside while rotating to the menu. + if (this->configMode == CM_ROTATE_TO_NAME_ENTRY && this->prevConfigMode == CM_RANDOMIZER_SETTINGS_MENU) { + Matrix_RotateX((this->windowRot - 314.0f) / 100.0f, MTXMODE_APPLY); + } else { + Matrix_RotateX((this->windowRot - 628.0f) / 100.0f, MTXMODE_APPLY); + } gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(this->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -2844,10 +2837,10 @@ void FileChoose_ConfigModeDraw(GameState* thisx) { } // draw quest menu - if ((this->configMode == CM_QUEST_MENU) || (this->configMode == CM_ROTATE_TO_QUEST_MENU) || - (this->configMode == CM_ROTATE_TO_NAME_ENTRY) || this->configMode == CM_QUEST_TO_MAIN || + if (this->configMode == CM_QUEST_MENU || (this->configMode == CM_ROTATE_TO_QUEST_MENU) || + this->configMode == CM_ROTATE_TO_NAME_ENTRY || this->configMode == CM_QUEST_TO_MAIN || this->configMode == CM_NAME_ENTRY_TO_QUEST_MENU || this->configMode == CM_ROTATE_TO_BOSS_RUSH_MENU || - this->configMode == CM_ROTATE_TO_RANDOMIZER_MENU) { + this->configMode == CM_ROTATE_TO_RANDOMIZER_SETTINGS_MENU || this->configMode == CM_NAME_ENTRY_TO_RANDOMIZER_SETTINGS_MENU) { // window gDPPipeSync(POLY_OPA_DISP++); gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); @@ -2876,39 +2869,11 @@ void FileChoose_ConfigModeDraw(GameState* thisx) { FileChoose_DrawWindowContents(&this->state); } - // Draw Boss Rush Options Menu + // Draw Boss Rush / Randomizer Options Menu if (this->configMode == CM_BOSS_RUSH_MENU || this->configMode == CM_ROTATE_TO_BOSS_RUSH_MENU || - this->configMode == CM_START_BOSS_RUSH_MENU || this->configMode == CM_BOSS_RUSH_TO_QUEST) { - // window - gDPPipeSync(POLY_OPA_DISP++); - gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2], - this->windowAlpha); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); - - Matrix_Translate(0.0f, 0.0f, -93.6f, MTXMODE_NEW); - Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); - Matrix_RotateX((this->windowRot - 628.0f) / 100.0f, MTXMODE_APPLY); - - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(this->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - gSPVertex(POLY_OPA_DISP++, &this->windowVtx[0], 32, 0); - gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow1DL); - - gSPVertex(POLY_OPA_DISP++, &this->windowVtx[32], 32, 0); - gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow2DL); - - gSPVertex(POLY_OPA_DISP++, &this->windowVtx[64], 16, 0); - gSPDisplayList(POLY_OPA_DISP++, gFileSelWindow3DL); - - gDPPipeSync(POLY_OPA_DISP++); - - FileChoose_DrawWindowContents(&this->state); - } - - // Draw Randomizer Options Menu - if (this->configMode == CM_RANDOMIZER_MENU || this->configMode == CM_ROTATE_TO_RANDOMIZER_MENU || - this->configMode == CM_START_RANDOMIZER_MENU || this->configMode == CM_RANDOMIZER_TO_QUEST) { + this->configMode == CM_START_BOSS_RUSH_MENU || this->configMode == CM_BOSS_RUSH_TO_QUEST || + this->configMode == CM_RANDOMIZER_SETTINGS_MENU || this->configMode == CM_ROTATE_TO_RANDOMIZER_SETTINGS_MENU || + this->configMode == CM_START_RANDOMIZER_SETTINGS_MENU || this->configMode == CM_RANDOMIZER_SETTINGS_MENU_TO_QUEST) { // window gDPPipeSync(POLY_OPA_DISP++); gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); @@ -3290,8 +3255,6 @@ void FileChoose_SelectModeDraw(GameState* thisx) { gDPPipeSync(POLY_OPA_DISP++); FileChoose_SetView(this, 0.0f, 0.0f, 64.0f); - DrawSeedHashSprites(this); - CLOSE_DISPS(this->state.gfxCtx); } diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c index fba1f4a7043..8f10e98379c 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c @@ -376,9 +376,10 @@ void FileChoose_DrawNameEntry(GameState* thisx) { if (this->newFileNameCharCount < 0) { this->newFileNameCharCount = 0; - if (this->prevConfigMode == CM_QUEST_MENU || this->prevConfigMode == CM_GENERATE_SEED) { + if (this->prevConfigMode == CM_QUEST_MENU) { this->configMode = CM_NAME_ENTRY_TO_QUEST_MENU; - Randomizer_SetSeedGenerated(false); + } else if (this->prevConfigMode == CM_RANDOMIZER_SETTINGS_MENU) { + this->configMode = CM_NAME_ENTRY_TO_RANDOMIZER_SETTINGS_MENU; } else { this->configMode = CM_NAME_ENTRY_TO_MAIN; } @@ -460,7 +461,6 @@ void FileChoose_DrawNameEntry(GameState* thisx) { this->prevConfigMode = CM_MAIN_MENU; this->configMode = CM_NAME_ENTRY_TO_MAIN; CVarSetInteger(CVAR_GENERAL("OnFileSelectNameEntry"), 0); - Randomizer_SetSeedGenerated(false); this->nameBoxAlpha[this->buttonIndex] = this->nameAlpha[this->buttonIndex] = 200; this->connectorAlpha[this->buttonIndex] = 255; func_800AA000(300.0f, 0xB4, 0x14, 0x64); From a7474263a7ece7266fac37ebc591770ad4f8b749 Mon Sep 17 00:00:00 2001 From: aMannus Date: Thu, 2 Jan 2025 17:14:48 +0100 Subject: [PATCH 3/7] MVP new randomizer flow --- soh/soh/Enhancements/randomizer/context.cpp | 2 - soh/soh/Enhancements/randomizer/context.h | 1 - .../Enhancements/randomizer/randomizer.cpp | 1 - soh/soh/OTRGlobals.cpp | 8 + soh/soh/OTRGlobals.h | 2 + soh/soh/SohGui.cpp | 4 + soh/soh/SohGui.hpp | 1 + soh/soh/SohMenuBar.cpp | 2 +- .../ovl_file_choose/z_file_choose.c | 259 +++++++----------- 9 files changed, 118 insertions(+), 162 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/context.cpp b/soh/soh/Enhancements/randomizer/context.cpp index 0b0af0af826..7ab837ea69d 100644 --- a/soh/soh/Enhancements/randomizer/context.cpp +++ b/soh/soh/Enhancements/randomizer/context.cpp @@ -278,7 +278,6 @@ void Context::ParseSpoiler(const char* spoilerFileName) { } mSeedGenerated = false; mSpoilerLoaded = false; - mPlandoLoaded = false; try { nlohmann::json spoilerFileJson; spoilerFileStream >> spoilerFileJson; @@ -289,7 +288,6 @@ void Context::ParseSpoiler(const char* spoilerFileName) { mEntranceShuffler->ParseJson(spoilerFileJson); mDungeons->ParseJson(spoilerFileJson); mTrials->ParseJson(spoilerFileJson); - mPlandoLoaded = true; mSpoilerLoaded = true; mSeedGenerated = false; } catch (...) { diff --git a/soh/soh/Enhancements/randomizer/context.h b/soh/soh/Enhancements/randomizer/context.h index b276f79b5e8..6542c792f0a 100644 --- a/soh/soh/Enhancements/randomizer/context.h +++ b/soh/soh/Enhancements/randomizer/context.h @@ -104,6 +104,5 @@ class Context { std::shared_ptr mKaleido; bool mSeedGenerated = false; bool mSpoilerLoaded = false; - bool mPlandoLoaded = false; }; } // namespace Rando \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 0e5a39164b9..ba255f00c75 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -1968,7 +1968,6 @@ void RandomizerSettingsWindow::DrawElement() { ctx->SetSpoilerLoaded(false); GenerateRandomizer(CVarGetInteger(CVAR_RANDOMIZER_SETTING("ManualSeedEntry"), 0) ? seedString : ""); } - UIWidgets::Tooltip("You can also press L on the Quest Select screen to generate a new seed"); ImGui::EndDisabled(); UIWidgets::Spacer(0); diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index d25e518c726..93819d4460e 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -2009,6 +2009,14 @@ extern "C" void Randomizer_SetSpoilerLoaded(bool spoilerLoaded) { OTRGlobals::Instance->gRandoContext->SetSpoilerLoaded(spoilerLoaded); } +extern "C" uint8_t Randomizer_GenerateRandomizer() { + return GenerateRandomizer() ? 1 : 0; +} + +extern "C" void Randomizer_ShowRandomizerMenu() { + SohGui::ShowRandomizerSettingsMenu(); +} + CustomMessage Randomizer_GetCustomGetItemMessage(Player* player) { s16 giid; if (player->getItemEntry.objectId != OBJECT_INVALID) { diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 283d76f3317..9eb063227a5 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -139,6 +139,8 @@ uint8_t Randomizer_IsSeedGenerated(); void Randomizer_SetSeedGenerated(bool seedGenerated); uint8_t Randomizer_IsSpoilerLoaded(); void Randomizer_SetSpoilerLoaded(bool spoilerLoaded); +uint8_t Randomizer_GenerateRandomizer(); +//void Randomizer_ShowRandomizerMenu(); int CustomMessage_RetrieveIfExists(PlayState* play); void Overlay_DisplayText(float duration, const char* text); void Overlay_DisplayText_Seconds(int seconds, const char* text); diff --git a/soh/soh/SohGui.cpp b/soh/soh/SohGui.cpp index 2dbf62a99a6..42ba25de2b4 100644 --- a/soh/soh/SohGui.cpp +++ b/soh/soh/SohGui.cpp @@ -266,4 +266,8 @@ namespace SohGui { void RegisterPopup(std::string title, std::string message, std::string button1, std::string button2, std::function button1callback, std::function button2callback) { mModalWindow->RegisterPopup(title, message, button1, button2, button1callback, button2callback); } + + void ShowRandomizerSettingsMenu() { + mRandomizerSettingsWindow->Show(); + } } diff --git a/soh/soh/SohGui.hpp b/soh/soh/SohGui.hpp index 5502b675750..3f9d616db9f 100644 --- a/soh/soh/SohGui.hpp +++ b/soh/soh/SohGui.hpp @@ -43,6 +43,7 @@ namespace SohGui { void Draw(); void Destroy(); void RegisterPopup(std::string title, std::string message, std::string button1 = "OK", std::string button2 = "", std::function button1callback = nullptr, std::function button2callback = nullptr); + void ShowRandomizerSettingsMenu(); } #endif /* SohGui_hpp */ diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index c4067ce1c01..37b90d83775 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -2108,13 +2108,13 @@ void DrawRemoteControlMenu() { #endif extern std::shared_ptr mRandomizerSettingsWindow; +extern std::shared_ptr mPlandomizerWindow; extern std::shared_ptr mItemTrackerWindow; extern std::shared_ptr mItemTrackerSettingsWindow; extern std::shared_ptr mEntranceTrackerWindow; extern std::shared_ptr mEntranceTrackerSettingsWindow; extern std::shared_ptr mCheckTrackerWindow; extern std::shared_ptr mCheckTrackerSettingsWindow; -extern std::shared_ptr mPlandomizerWindow; extern "C" u8 Randomizer_GetSettingValue(RandomizerSettingKey randoSettingKey); void DrawRandomizerMenu() { diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 1896eba3434..386e72e1614 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -986,9 +986,9 @@ void DrawSeedHashSprites(FileChooseContext* this) { if ((Randomizer_IsSeedGenerated() || Randomizer_IsSpoilerLoaded()) && (((this->configMode == CM_NAME_ENTRY || this->configMode == CM_ROTATE_TO_NAME_ENTRY || this->configMode == CM_NAME_ENTRY_TO_RANDOMIZER_SETTINGS_MENU || this->configMode == CM_START_NAME_ENTRY || - this->configMode == CM_START_RANDOMIZER_SETTINGS_MENU) && - gSaveContext.questId == QUEST_RANDOMIZER) || - (this->configMode == CM_RANDOMIZER_SETTINGS_MENU && Randomizer_IsSpoilerLoaded()))) { + this->configMode == CM_START_RANDOMIZER_SETTINGS_MENU) || + this->configMode == CM_RANDOMIZER_SETTINGS_MENU) && + gSaveContext.questId == QUEST_RANDOMIZER)) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF); u16 xStart = 64; @@ -1439,6 +1439,12 @@ void FileChoose_UpdateRandomizerMenu(GameState* thisx) { Input* input = &this->state.input[0]; bool dpad = CVarGetInteger(CVAR_SETTING("DpadInText"), 0); + FileChoose_UpdateRandomizer(); + + if (generating) { + return; + } + // Fade in elements after opening Randomizer options menu this->randomizerUIAlpha += 25; if (this->randomizerUIAlpha > 255) { @@ -1450,7 +1456,7 @@ void FileChoose_UpdateRandomizerMenu(GameState* thisx) { // Move down if (this->stickRelY < -30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DDOWN))) { // When selecting past the last option, cycle back to the first option. - if ((this->randomizerIndex + 1) > 3) { + if ((this->randomizerIndex + 1) > 2) { this->randomizerIndex = 0; } else { this->randomizerIndex++; @@ -1458,7 +1464,7 @@ void FileChoose_UpdateRandomizerMenu(GameState* thisx) { } else if (this->stickRelY > 30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DUP))) { // When selecting past the first option, cycle back to the last option and offset the list to view it properly. if ((this->randomizerIndex - 1) < 0) { - this->randomizerIndex = 3; + this->randomizerIndex = 2; } else { this->randomizerIndex--; } @@ -1467,27 +1473,6 @@ void FileChoose_UpdateRandomizerMenu(GameState* thisx) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } - // Cycle through spoiler log - if (ABS(this->stickRelX) > 30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DLEFT | BTN_DRIGHT))) { - if (this->stickRelX > 30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DRIGHT))) { - // If exceeding the amount of choices for the selected option, cycle back to the first. - if ((gSaveContext.bossRushOptions[this->bossRushIndex] + 1) == BossRush_GetSettingOptionsAmount(this->bossRushIndex)) { - gSaveContext.bossRushOptions[this->bossRushIndex] = 0; - } else { - gSaveContext.bossRushOptions[this->bossRushIndex]++; - } - } else if (this->stickRelX < -30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DLEFT))) { - // If cycling back when already at the first choice for the selected option, cycle back to the last choice. - if ((gSaveContext.bossRushOptions[this->bossRushIndex] - 1) < 0) { - gSaveContext.bossRushOptions[this->bossRushIndex] = BossRush_GetSettingOptionsAmount(this->bossRushIndex) - 1; - } else { - gSaveContext.bossRushOptions[this->bossRushIndex]--; - } - } - - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - } - if (CHECK_BTN_ALL(input->press.button, BTN_B)) { this->configMode = CM_RANDOMIZER_SETTINGS_MENU_TO_QUEST; return; @@ -1495,33 +1480,35 @@ void FileChoose_UpdateRandomizerMenu(GameState* thisx) { if (CHECK_BTN_ALL(input->press.button, BTN_A)) { if (this->randomizerIndex == 0) { - func_800F5E18(SEQ_PLAYER_BGM_MAIN, NA_BGM_FILE_SELECT, 0, 7, 1); - static u8 emptyName[] = { 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E }; - static u8 linkName[] = { 0x15, 0x2C, 0x31, 0x2E, 0x3E, 0x3E, 0x3E, 0x3E }; - this->prevConfigMode = this->configMode; - this->configMode = CM_ROTATE_TO_NAME_ENTRY; - this->logoAlpha = 0; - CVarSetInteger(CVAR_GENERAL("OnFileSelectNameEntry"), 1); - this->kbdButton = FS_KBD_BTN_NONE; - this->charPage = FS_CHAR_PAGE_ENG; - this->kbdX = 0; - this->kbdY = 0; - this->charIndex = 0; - this->charBgAlpha = 0; - this->newFileNameCharCount = CVarGetInteger(CVAR_ENHANCEMENT("LinkDefaultName"), 0) ? 4 : 0; - this->nameEntryBoxPosX = 120; - this->nameEntryBoxAlpha = 0; - memcpy(Save_GetSaveMetaInfo(this->buttonIndex)->playerName, - CVarGetInteger(CVAR_ENHANCEMENT("LinkDefaultName"), 0) ? &linkName : &emptyName, 8); - return; + if (Randomizer_IsSeedGenerated() || Randomizer_IsSpoilerLoaded()) { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + static u8 emptyName[] = { 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E }; + static u8 linkName[] = { 0x15, 0x2C, 0x31, 0x2E, 0x3E, 0x3E, 0x3E, 0x3E }; + this->prevConfigMode = this->configMode; + this->configMode = CM_ROTATE_TO_NAME_ENTRY; + this->logoAlpha = 0; + CVarSetInteger(CVAR_GENERAL("OnFileSelectNameEntry"), 1); + this->kbdButton = FS_KBD_BTN_NONE; + this->charPage = FS_CHAR_PAGE_ENG; + this->kbdX = 0; + this->kbdY = 0; + this->charIndex = 0; + this->charBgAlpha = 0; + this->newFileNameCharCount = CVarGetInteger(CVAR_ENHANCEMENT("LinkDefaultName"), 0) ? 4 : 0; + this->nameEntryBoxPosX = 120; + this->nameEntryBoxAlpha = 0; + memcpy(Save_GetSaveMetaInfo(this->buttonIndex)->playerName, + CVarGetInteger(CVAR_ENHANCEMENT("LinkDefaultName"), 0) ? &linkName : &emptyName, 8); + } else { + Sfx_PlaySfxCentered(NA_SE_SY_OCARINA_ERROR); + } + } else if (this->randomizerIndex == 1) { + Randomizer_GenerateRandomizer(); + } else if (this->randomizerIndex == 2) { + Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + Randomizer_ShowRandomizerMenu(); } } - - // Handle executing options - if (CHECK_BTN_ALL(input->press.button, BTN_START) || CHECK_BTN_ALL(input->press.button, BTN_A)) { - Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - - } } /** @@ -2268,6 +2255,30 @@ const char* FileChoose_GetShipOptionsTitleTexName(Language lang) { } } +static const char* noRandoGeneratedText[] = { + // English + "No randomizer seed loaded.\nPlease generate one first" +#if defined(__WIIU__) || defined(__SWITCH__) + ".", +#else + ",\nor drop a spoiler log on the game window.", +#endif + // German + "No randomizer seed loaded.\nPlease generate one first" +#if defined(__WIIU__) || defined(__SWITCH__) + ".", +#else + ",\nor drop a spoiler log on the game window.", +#endif + // French + "Aucune Seed de Randomizer actuellement disponible.\nGénérez-en une dans les \"Randomizer Settings\"" +#if (defined(__WIIU__) || defined(__SWITCH__)) + "." +#else + "\nou glissez un spoilerlog sur la fenêtre du jeu." +#endif +}; + /** * Draw most window contents including buttons, labels, and icons. * Does not include anything from the keyboard and settings windows. @@ -2444,47 +2455,54 @@ void FileChoose_DrawWindowContents(GameState* thisx) { } else if (this->configMode == CM_RANDOMIZER_SETTINGS_MENU) { uint8_t textAlpha = this->randomizerUIAlpha; + uint8_t textColorR = 255; + uint8_t textColorG = 255; uint8_t textColorB = 0; textColorB = this->randomizerIndex == 0 ? 80 : 255; - Interface_DrawTextLine(this->state.gfxCtx, "Create New Randomizer", 70, (80 + 0), 255, 255, textColorB, textAlpha, 0.8f, true); - - textColorB = this->randomizerIndex == 1 ? 80 : 255; - Interface_DrawTextLine(this->state.gfxCtx, "Generate New Seed", 70, (80 + 16), 255, 255, textColorB, textAlpha, 0.8f, true); + if (!Randomizer_IsSeedGenerated() && !Randomizer_IsSpoilerLoaded() || generating) { + textColorR = textColorG = textColorB = 100; + } + Interface_DrawTextLine(this->state.gfxCtx, "Start Randomizer", 70, (80 + 0), textColorR, textColorG, textColorB, + textAlpha, 0.8f, true); - textColorB = this->randomizerIndex == 2 ? 80 : 255; - Interface_DrawTextLine(this->state.gfxCtx, "Open Randomizer Settings", 70, (80 + 32), 255, 255, textColorB, textAlpha, 0.8f, true); + if (generating) { + textColorR = textColorG = textColorB = 100; + } else { + textColorR = textColorG = 255; + textColorB = this->randomizerIndex == 1 ? 80 : 255; + } + Interface_DrawTextLine(this->state.gfxCtx, "Generate New Randomizer Seed", 70, (80 + 16), textColorR, + textColorG, textColorB, textAlpha, 0.8f, true); - textColorB = this->randomizerIndex == 3 ? 80 : 255; - Interface_DrawTextLine(this->state.gfxCtx, "Select Seed:", 70, (80 + 48), 255, 255, textColorB, textAlpha, 0.8f, true); + if (generating) { + textColorR = textColorG = textColorB = 100; + } else { + textColorR = textColorG = 255; + textColorB = this->randomizerIndex == 2 ? 80 : 255; + } + Interface_DrawTextLine(this->state.gfxCtx, "Open Randomizer Settings", 70, (80 + 32), textColorR, textColorG, + textColorB, textAlpha, 0.8f, true); - uint16_t finalKerning = Interface_DrawTextLine(this->state.gfxCtx, "10-10-10-10-10.json", 140, (80 + 48), 255, 255, 255, textAlpha, 0.8f, true); + if (generating) { + Interface_DrawTextLine(this->state.gfxCtx, "Generating...", 70, (80 + 64), 255, 255, 255, textAlpha, 0.8f, true); + } - if (this->randomizerIndex != 3) { - uint16_t textOffset = 16 * this->randomizerIndex; - Gfx_SetupDL_39Opa(this->state.gfxCtx); - gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPLoadTextureBlock(POLY_OPA_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, - G_TX_NOLOD); - FileChoose_DrawTextRec(this->state.gfxCtx, this->stickRightPrompt.arrowColorR, - this->stickRightPrompt.arrowColorG, this->stickRightPrompt.arrowColorB, textAlpha, - 62, (85 + textOffset), 0.42f, 0, 0, 1.0f, 1.0f); - } else { - Gfx_SetupDL_39Opa(this->state.gfxCtx); - gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPLoadTextureBlock(POLY_OPA_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, - G_TX_NOLOD); - FileChoose_DrawTextRec(this->state.gfxCtx, this->stickLeftPrompt.arrowColorR, - this->stickLeftPrompt.arrowColorG, this->stickLeftPrompt.arrowColorB, - textAlpha, 135, (85 + 48), 0.42f, 0, 0, -1.0f, - 1.0f); - FileChoose_DrawTextRec(this->state.gfxCtx, this->stickRightPrompt.arrowColorR, - this->stickRightPrompt.arrowColorG, this->stickRightPrompt.arrowColorB, - textAlpha, (146 + finalKerning), - (85 + 48), 0.42f, 0, 0, 1.0f, 1.0f); + if (!Randomizer_IsSeedGenerated() && !Randomizer_IsSpoilerLoaded() && this->randomizerIndex == 0) { + Interface_DrawTextLine(this->state.gfxCtx, noRandoGeneratedText[gSaveContext.language], 70, (80 + 64), 240, + 80, 80, textAlpha, 0.8f, true); } + + + uint16_t textOffset = 16 * this->randomizerIndex; + Gfx_SetupDL_39Opa(this->state.gfxCtx); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPLoadTextureBlock(POLY_OPA_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + FileChoose_DrawTextRec(this->state.gfxCtx, this->stickRightPrompt.arrowColorR, + this->stickRightPrompt.arrowColorG, this->stickRightPrompt.arrowColorB, textAlpha, + 62, (85 + textOffset), 0.42f, 0, 0, 1.0f, 1.0f); } else if (this->configMode != CM_ROTATE_TO_NAME_ENTRY && this->configMode != CM_START_BOSS_RUSH_MENU && this->configMode != CM_ROTATE_TO_BOSS_RUSH_MENU && this->configMode != CM_BOSS_RUSH_TO_QUEST && @@ -3324,77 +3342,6 @@ void FileChoose_DrawRandoSaveVersionWarning(GameState* thisx) { CLOSE_DISPS(this->state.gfxCtx); } -static const char* noRandoGeneratedText[] = { - // English - "No Randomizer seed currently available.\nGenerate one in the Randomizer Settings" -#if defined(__WIIU__) || defined(__SWITCH__) - ".", -#else - ",\nor drop a spoiler log on the game window.", -#endif - // German - "No Randomizer seed currently available.\nGenerate one in the Randomizer Settings" -#if defined(__WIIU__) || defined(__SWITCH__) - ".", -#else - ",\nor drop a spoiler log on the game window.", -#endif - // French - "Aucune Seed de Randomizer actuellement disponible.\nGénérez-en une dans les \"Randomizer Settings\"" -#if (defined(__WIIU__) || defined(__SWITCH__)) - "." -#else - "\nou glissez un spoilerlog sur la fenêtre du jeu." -#endif -}; - -void FileChoose_DrawNoRandoGeneratedWarning(GameState* thisx) { - FileChooseContext* this = (FileChooseContext*)thisx; - - OPEN_DISPS(this->state.gfxCtx); - - // Draw rando seed warning when build version doesn't match for Major or Minor number - if (this->configMode == CM_QUEST_MENU && this->questType[this->buttonIndex] == QUEST_RANDOMIZER && !(Randomizer_IsSeedGenerated() || Randomizer_IsSpoilerLoaded())) { - uint8_t textAlpha = 225; - uint8_t textboxAlpha = 170; - float textboxScale = 0.7f; - - // float math to get a S5.10 number that will squish the texture - float texCoordinateHeightF = 512 / textboxScale; - uint16_t texCoordinateHeightScale = texCoordinateHeightF + 0.5f; - float texCoordinateWidthF = 512 / textboxScale; - uint16_t texCoordinateWidthScale = texCoordinateWidthF + 0.5f; - uint16_t textboxWidth = 256 * textboxScale; - uint16_t textboxHeight = 64 * textboxScale; - uint8_t leftOffset = 72; - uint8_t bottomOffset = 84; - uint8_t textVerticalOffset; -#if defined(__WIIU__) || defined(__SWITCH__) - textVerticalOffset = 127; // 2 lines -#else - textVerticalOffset = 122; // 3 lines -#endif - - Gfx_SetupDL_39Opa(this->state.gfxCtx); - gDPSetAlphaDither(POLY_OPA_DISP++, G_AD_DISABLE); - gSPClearGeometryMode(POLY_OPA_DISP++, G_SHADE); - gDPSetCombineLERP(POLY_OPA_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, - 0, PRIMITIVE, 0); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, textboxAlpha); - gDPLoadTextureBlock_4b(POLY_OPA_DISP++, gDefaultMessageBackgroundTex, G_IM_FMT_I, 128, 64, 0, G_TX_MIRROR, - G_TX_MIRROR, 7, 0, G_TX_NOLOD, G_TX_NOLOD); - - gSPTextureRectangle(POLY_OPA_DISP++, leftOffset << 2, (SCREEN_HEIGHT - bottomOffset - textboxHeight) << 2, - (textboxWidth + leftOffset) << 2, (SCREEN_HEIGHT - bottomOffset) << 2, G_TX_RENDERTILE, 0, 0, - texCoordinateWidthScale << 1, texCoordinateHeightScale << 1); - - Interface_DrawTextLine(this->state.gfxCtx, noRandoGeneratedText[gSaveContext.language], 80, textVerticalOffset, - 255, 255, 255, textAlpha, 0.6f, 1); - } - - CLOSE_DISPS(this->state.gfxCtx); -} - void FileChoose_Main(GameState* thisx) { static void* controlsTextures[] = { gFileSelControlsENGTex, @@ -3589,8 +3536,6 @@ void FileChoose_Main(GameState* thisx) { // Draw rando save version warning over the controls text, but before the screen fill fade out FileChoose_DrawRandoSaveVersionWarning(&this->state); - FileChoose_DrawNoRandoGeneratedWarning(&this->state); - gDPPipeSync(POLY_OPA_DISP++); gSPDisplayList(POLY_OPA_DISP++, sScreenFillSetupDL); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, sScreenFillAlpha); From 5cefea1900ec0f480b271ebee7dc63c83a971065 Mon Sep 17 00:00:00 2001 From: aMannus Date: Sat, 4 Jan 2025 13:51:17 +0100 Subject: [PATCH 4/7] Translation support and code cleanup --- .../Enhancements/FileSelectEnhancements.cpp | 69 ++++++++++++++++ soh/soh/Enhancements/FileSelectEnhancements.h | 23 ++++++ .../ovl_file_choose/z_file_choose.c | 81 +++++++------------ 3 files changed, 119 insertions(+), 54 deletions(-) create mode 100644 soh/soh/Enhancements/FileSelectEnhancements.cpp create mode 100644 soh/soh/Enhancements/FileSelectEnhancements.h diff --git a/soh/soh/Enhancements/FileSelectEnhancements.cpp b/soh/soh/Enhancements/FileSelectEnhancements.cpp new file mode 100644 index 00000000000..b7740d7ae3c --- /dev/null +++ b/soh/soh/Enhancements/FileSelectEnhancements.cpp @@ -0,0 +1,69 @@ +#include "FileSelectEnhancements.h" + +#include "soh/OTRGlobals.h" + +#include +#include +#include + +std::array RandomizerSettingsMenuText[RSM_MAX] = { + { + // English + "Start Randomizer", + // German + "Start Randomizer", + // French + "Start Randomizer", + }, + { + // English + "Generate New Randomizer Seed", + // German + "Generate New Randomizer Seed", + // French + "Generate New Randomizer Seed", + }, + { + // English + "Open Randomizer Settings", + // German + "Open Randomizer Settings", + // French + "Open Randomizer Settings", + }, + { + // English + "Generating...", + // German + "Generating...", + // French + "Generating...", + }, + { + // English + "No randomizer seed loaded.\nPlease generate one first" + #if defined(__WIIU__) || defined(__SWITCH__) + ".", + #else + ",\nor drop a spoiler log on the game window.", + #endif + // German + "No randomizer seed loaded.\nPlease generate one first" + #if defined(__WIIU__) || defined(__SWITCH__) + ".", + #else + ",\nor drop a spoiler log on the game window.", + #endif + // French + "Aucune Seed de Randomizer actuellement disponible.\nGénérez-en une dans les \"Randomizer Settings\"" + #if (defined(__WIIU__) || defined(__SWITCH__)) + "." + #else + "\nou glissez un spoilerlog sur la fenêtre du jeu." + #endif + }, +}; + +const char* SoHFileSelect_GetSettingText(uint8_t optionIndex, uint8_t language) { + return RandomizerSettingsMenuText[optionIndex][language].c_str(); +} diff --git a/soh/soh/Enhancements/FileSelectEnhancements.h b/soh/soh/Enhancements/FileSelectEnhancements.h new file mode 100644 index 00000000000..9eb30d29c78 --- /dev/null +++ b/soh/soh/Enhancements/FileSelectEnhancements.h @@ -0,0 +1,23 @@ +#ifndef FILE_SELECT_ENHANCEMENTS_H +#define FILE_SELECT_ENHANCEMENTS_H + +#include "z64.h" + +#ifdef __cplusplus +extern "C" { +#endif +const char* SoHFileSelect_GetSettingText(u8 optionIndex, u8 language); +#ifdef __cplusplus +}; +#endif + +typedef enum { + RSM_START_RANDOMIZER, + RSM_GENERATE_RANDOMIZER, + RSM_OPEN_RANDOMIZER_SETTINGS, + RSM_GENERATING, + RSM_NO_RANDOMIZER_GENERATED, + RSM_MAX, +} RandomizerSettingsMenuEnums; + +#endif diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 386e72e1614..eff344e115f 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -17,6 +17,7 @@ #include "soh_assets.h" #include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/boss-rush/BossRush.h" +#include "soh/Enhancements/FileSelectEnhancements.h" #include "soh/Enhancements/custom-message/CustomMessageTypes.h" #include "soh/Enhancements/enhancementTypes.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" @@ -2255,30 +2256,6 @@ const char* FileChoose_GetShipOptionsTitleTexName(Language lang) { } } -static const char* noRandoGeneratedText[] = { - // English - "No randomizer seed loaded.\nPlease generate one first" -#if defined(__WIIU__) || defined(__SWITCH__) - ".", -#else - ",\nor drop a spoiler log on the game window.", -#endif - // German - "No randomizer seed loaded.\nPlease generate one first" -#if defined(__WIIU__) || defined(__SWITCH__) - ".", -#else - ",\nor drop a spoiler log on the game window.", -#endif - // French - "Aucune Seed de Randomizer actuellement disponible.\nGénérez-en une dans les \"Randomizer Settings\"" -#if (defined(__WIIU__) || defined(__SWITCH__)) - "." -#else - "\nou glissez un spoilerlog sur la fenêtre du jeu." -#endif -}; - /** * Draw most window contents including buttons, labels, and icons. * Does not include anything from the keyboard and settings windows. @@ -2293,7 +2270,7 @@ void FileChoose_DrawWindowContents(GameState* thisx) { s16 pad; char* tex; - switch (this->configMode) { + switch (this->configMode) { case CM_QUEST_MENU: case CM_ROTATE_TO_NAME_ENTRY: case CM_START_QUEST_MENU: @@ -2455,44 +2432,40 @@ void FileChoose_DrawWindowContents(GameState* thisx) { } else if (this->configMode == CM_RANDOMIZER_SETTINGS_MENU) { uint8_t textAlpha = this->randomizerUIAlpha; - uint8_t textColorR = 255; - uint8_t textColorG = 255; - uint8_t textColorB = 0; - textColorB = this->randomizerIndex == 0 ? 80 : 255; - if (!Randomizer_IsSeedGenerated() && !Randomizer_IsSpoilerLoaded() || generating) { - textColorR = textColorG = textColorB = 100; - } - Interface_DrawTextLine(this->state.gfxCtx, "Start Randomizer", 70, (80 + 0), textColorR, textColorG, textColorB, - textAlpha, 0.8f, true); + for (uint8_t index = 0; index <= RSM_OPEN_RANDOMIZER_SETTINGS; index++) { + uint8_t textColorR = 255; + uint8_t textColorG = 255; + uint8_t textColorB = 255; - if (generating) { - textColorR = textColorG = textColorB = 100; - } else { - textColorR = textColorG = 255; - textColorB = this->randomizerIndex == 1 ? 80 : 255; - } - Interface_DrawTextLine(this->state.gfxCtx, "Generate New Randomizer Seed", 70, (80 + 16), textColorR, - textColorG, textColorB, textAlpha, 0.8f, true); + // If current index is the selected one, make the text yellow. + if (this->randomizerIndex == index) { + textColorB = 80; + } - if (generating) { - textColorR = textColorG = textColorB = 100; - } else { - textColorR = textColorG = 255; - textColorB = this->randomizerIndex == 2 ? 80 : 255; + // If no randomizer is loaded and text is "start randomizer" or when a seed is generating, make all options gray. + if ((index == RSM_START_RANDOMIZER && !Randomizer_IsSeedGenerated() && !Randomizer_IsSpoilerLoaded()) || generating) { + textColorR = textColorG = textColorB = 100; + } + + Interface_DrawTextLine(this->state.gfxCtx, SoHFileSelect_GetSettingText(index, gSaveContext.language), 70, + (80 + (index * 16)), textColorR, textColorG, textColorB, textAlpha, 0.8f, true); } - Interface_DrawTextLine(this->state.gfxCtx, "Open Randomizer Settings", 70, (80 + 32), textColorR, textColorG, - textColorB, textAlpha, 0.8f, true); + // Show text to indicate randomizer is being generated. if (generating) { - Interface_DrawTextLine(this->state.gfxCtx, "Generating...", 70, (80 + 64), 255, 255, 255, textAlpha, 0.8f, true); + Interface_DrawTextLine(this->state.gfxCtx, + SoHFileSelect_GetSettingText(RSM_GENERATING, gSaveContext.language), 70, + (80 + 64), 255, 255, 255, textAlpha, 0.8f, true); } - if (!Randomizer_IsSeedGenerated() && !Randomizer_IsSpoilerLoaded() && this->randomizerIndex == 0) { - Interface_DrawTextLine(this->state.gfxCtx, noRandoGeneratedText[gSaveContext.language], 70, (80 + 64), 240, - 80, 80, textAlpha, 0.8f, true); + // If no randomizer is generated and "start randomizer" is selected, show text to explain why user can't start the randomizer. + if (!Randomizer_IsSeedGenerated() && !Randomizer_IsSpoilerLoaded() && this->randomizerIndex == RSM_START_RANDOMIZER) { + Interface_DrawTextLine(this->state.gfxCtx, + SoHFileSelect_GetSettingText(RSM_NO_RANDOMIZER_GENERATED, gSaveContext.language), 70, + (80 + 64), + 240, 80, 80, textAlpha, 0.8f, true); } - uint16_t textOffset = 16 * this->randomizerIndex; Gfx_SetupDL_39Opa(this->state.gfxCtx); From aad6b3d93c2e3a6d99699e8a142a5ec5bab05e8a Mon Sep 17 00:00:00 2001 From: aMannus Date: Sat, 4 Jan 2025 14:05:51 +0100 Subject: [PATCH 5/7] Fixes and more cleanup --- .../Enhancements/FileSelectEnhancements.cpp | 2 +- soh/soh/Enhancements/FileSelectEnhancements.h | 2 +- soh/src/code/z_sram.c | 2 +- .../ovl_file_choose/z_file_choose.c | 24 +++++++++---------- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/soh/soh/Enhancements/FileSelectEnhancements.cpp b/soh/soh/Enhancements/FileSelectEnhancements.cpp index b7740d7ae3c..43b2f19667d 100644 --- a/soh/soh/Enhancements/FileSelectEnhancements.cpp +++ b/soh/soh/Enhancements/FileSelectEnhancements.cpp @@ -64,6 +64,6 @@ std::array RandomizerSettingsMenuText[RSM_MAX] = { }, }; -const char* SoHFileSelect_GetSettingText(uint8_t optionIndex, uint8_t language) { +const char* SohFileSelect_GetSettingText(uint8_t optionIndex, uint8_t language) { return RandomizerSettingsMenuText[optionIndex][language].c_str(); } diff --git a/soh/soh/Enhancements/FileSelectEnhancements.h b/soh/soh/Enhancements/FileSelectEnhancements.h index 9eb30d29c78..070d270dc7b 100644 --- a/soh/soh/Enhancements/FileSelectEnhancements.h +++ b/soh/soh/Enhancements/FileSelectEnhancements.h @@ -6,7 +6,7 @@ #ifdef __cplusplus extern "C" { #endif -const char* SoHFileSelect_GetSettingText(u8 optionIndex, u8 language); +const char* SohFileSelect_GetSettingText(u8 optionIndex, u8 language); #ifdef __cplusplus }; #endif diff --git a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c index d5b4f888f62..adea0cbbf04 100644 --- a/soh/src/code/z_sram.c +++ b/soh/src/code/z_sram.c @@ -251,7 +251,7 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx) { u8 currentQuest = fileChooseCtx->questType[fileChooseCtx->buttonIndex]; - if (currentQuest == QUEST_RANDOMIZER && Randomizer_IsSeedGenerated()) { + if (currentQuest == QUEST_RANDOMIZER && (Randomizer_IsSeedGenerated() || Randomizer_IsSpoilerLoaded())) { gSaveContext.questId = QUEST_RANDOMIZER; Randomizer_InitSaveFile(); diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index eff344e115f..311882139bb 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -1315,7 +1315,6 @@ void FileChoose_UpdateQuestMenu(GameState* thisx) { this->prevConfigMode = this->configMode; this->configMode = CM_ROTATE_TO_NAME_ENTRY; this->logoAlpha = 0; - CVarSetInteger(CVAR_GENERAL("OnFileSelectNameEntry"), 0); this->kbdButton = FS_KBD_BTN_NONE; this->charPage = FS_CHAR_PAGE_ENG; this->kbdX = 0; @@ -1457,15 +1456,15 @@ void FileChoose_UpdateRandomizerMenu(GameState* thisx) { // Move down if (this->stickRelY < -30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DDOWN))) { // When selecting past the last option, cycle back to the first option. - if ((this->randomizerIndex + 1) > 2) { - this->randomizerIndex = 0; + if ((this->randomizerIndex + 1) > RSM_OPEN_RANDOMIZER_SETTINGS) { + this->randomizerIndex = RSM_START_RANDOMIZER; } else { this->randomizerIndex++; } } else if (this->stickRelY > 30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DUP))) { // When selecting past the first option, cycle back to the last option and offset the list to view it properly. - if ((this->randomizerIndex - 1) < 0) { - this->randomizerIndex = 2; + if ((this->randomizerIndex - 1) < RSM_START_RANDOMIZER) { + this->randomizerIndex = RSM_OPEN_RANDOMIZER_SETTINGS; } else { this->randomizerIndex--; } @@ -1480,7 +1479,7 @@ void FileChoose_UpdateRandomizerMenu(GameState* thisx) { } if (CHECK_BTN_ALL(input->press.button, BTN_A)) { - if (this->randomizerIndex == 0) { + if (this->randomizerIndex == RSM_START_RANDOMIZER) { if (Randomizer_IsSeedGenerated() || Randomizer_IsSpoilerLoaded()) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); static u8 emptyName[] = { 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E }; @@ -1503,9 +1502,9 @@ void FileChoose_UpdateRandomizerMenu(GameState* thisx) { } else { Sfx_PlaySfxCentered(NA_SE_SY_OCARINA_ERROR); } - } else if (this->randomizerIndex == 1) { + } else if (this->randomizerIndex == RSM_GENERATE_RANDOMIZER) { Randomizer_GenerateRandomizer(); - } else if (this->randomizerIndex == 2) { + } else if (this->randomizerIndex == RSM_OPEN_RANDOMIZER_SETTINGS) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); Randomizer_ShowRandomizerMenu(); } @@ -2244,7 +2243,7 @@ const char* FileChoose_GetQuestChooseTitleTexName(Language lang) { } } -const char* FileChoose_GetShipOptionsTitleTexName(Language lang) { +const char* FileChoose_GetSohOptionsTitleTexName(Language lang) { switch (lang) { case LANGUAGE_ENG: default: @@ -2430,7 +2429,6 @@ void FileChoose_DrawWindowContents(GameState* thisx) { } } } else if (this->configMode == CM_RANDOMIZER_SETTINGS_MENU) { - uint8_t textAlpha = this->randomizerUIAlpha; for (uint8_t index = 0; index <= RSM_OPEN_RANDOMIZER_SETTINGS; index++) { @@ -2448,21 +2446,21 @@ void FileChoose_DrawWindowContents(GameState* thisx) { textColorR = textColorG = textColorB = 100; } - Interface_DrawTextLine(this->state.gfxCtx, SoHFileSelect_GetSettingText(index, gSaveContext.language), 70, + Interface_DrawTextLine(this->state.gfxCtx, SohFileSelect_GetSettingText(index, gSaveContext.language), 70, (80 + (index * 16)), textColorR, textColorG, textColorB, textAlpha, 0.8f, true); } // Show text to indicate randomizer is being generated. if (generating) { Interface_DrawTextLine(this->state.gfxCtx, - SoHFileSelect_GetSettingText(RSM_GENERATING, gSaveContext.language), 70, + SohFileSelect_GetSettingText(RSM_GENERATING, gSaveContext.language), 70, (80 + 64), 255, 255, 255, textAlpha, 0.8f, true); } // If no randomizer is generated and "start randomizer" is selected, show text to explain why user can't start the randomizer. if (!Randomizer_IsSeedGenerated() && !Randomizer_IsSpoilerLoaded() && this->randomizerIndex == RSM_START_RANDOMIZER) { Interface_DrawTextLine(this->state.gfxCtx, - SoHFileSelect_GetSettingText(RSM_NO_RANDOMIZER_GENERATED, gSaveContext.language), 70, + SohFileSelect_GetSettingText(RSM_NO_RANDOMIZER_GENERATED, gSaveContext.language), 70, (80 + 64), 240, 80, 80, textAlpha, 0.8f, true); } From 2ec8b7b02b1a420268e3bd207c66565a77d9f3f6 Mon Sep 17 00:00:00 2001 From: aMannus Date: Sat, 4 Jan 2025 14:37:15 +0100 Subject: [PATCH 6/7] Fix whoopsie --- soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 311882139bb..9b964054e95 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -2286,7 +2286,7 @@ void FileChoose_DrawWindowContents(GameState* thisx) { case CM_START_RANDOMIZER_SETTINGS_MENU: case CM_RANDOMIZER_SETTINGS_MENU_TO_QUEST: case CM_NAME_ENTRY_TO_RANDOMIZER_SETTINGS_MENU: - tex = FileChoose_GetShipOptionsTitleTexName(gSaveContext.language); + tex = FileChoose_GetSohOptionsTitleTexName(gSaveContext.language); break; default: tex = sTitleLabels[gSaveContext.language][this->titleLabel]; From e781484dcf3f0feaea5f9db5fc180054ed2d6b30 Mon Sep 17 00:00:00 2001 From: aMannus Date: Sat, 4 Jan 2025 14:43:40 +0100 Subject: [PATCH 7/7] Fix whoopsie 2 --- soh/soh/OTRGlobals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 9eb063227a5..6945d833951 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -140,7 +140,7 @@ void Randomizer_SetSeedGenerated(bool seedGenerated); uint8_t Randomizer_IsSpoilerLoaded(); void Randomizer_SetSpoilerLoaded(bool spoilerLoaded); uint8_t Randomizer_GenerateRandomizer(); -//void Randomizer_ShowRandomizerMenu(); +void Randomizer_ShowRandomizerMenu(); int CustomMessage_RetrieveIfExists(PlayState* play); void Overlay_DisplayText(float duration, const char* text); void Overlay_DisplayText_Seconds(int seconds, const char* text);