From 5244cda90e753e40ab349be0e1d7695bbe26ee2c Mon Sep 17 00:00:00 2001 From: Adam Bird Date: Tue, 16 May 2023 17:40:50 -0400 Subject: [PATCH] expose thieves hideout selection for keyrings in randomizer settings --- soh/soh/Enhancements/presets.h | 1 + .../randomizer/3drando/settings.cpp | 26 +++++++++---------- soh/soh/Enhancements/randomizer/draw.cpp | 4 +-- .../Enhancements/randomizer/randomizer.cpp | 15 ++++++++--- .../Enhancements/randomizer/randomizerTypes.h | 1 + 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/soh/soh/Enhancements/presets.h b/soh/soh/Enhancements/presets.h index ca8ded27d..d8fea14ea 100644 --- a/soh/soh/Enhancements/presets.h +++ b/soh/soh/Enhancements/presets.h @@ -276,6 +276,7 @@ const std::vector randomizerCvars = { "gRandomizeShuffleKeyRingsFireTemple", "gRandomizeShuffleKeyRingsForestTemple", "gRandomizeShuffleKeyRingsGanonsCastle", + "gRandomizeShuffleKeyRingsGerudoFortress", "gRandomizeShuffleKeyRingsGTG", "gRandomizeShuffleKeyRingsRandomCount", "gRandomizeShuffleKeyRingsShadowTemple", diff --git a/soh/soh/Enhancements/randomizer/3drando/settings.cpp b/soh/soh/Enhancements/randomizer/3drando/settings.cpp index 3cba56b08..47064e766 100644 --- a/soh/soh/Enhancements/randomizer/3drando/settings.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/settings.cpp @@ -236,7 +236,7 @@ namespace Settings { Option LACSDungeonCount = Option::U8 ("Dungeon Count", {NumOpts(0, 8)}, {lacsDungeonCountDesc}, OptionCategory::Setting, 1, true); Option LACSTokenCount = Option::U8 ("Token Count", {NumOpts(0, 100)}, {lacsTokenCountDesc}, OptionCategory::Setting, 1, true); Option KeyRings = Option::U8 ("Key Rings", {"Off", "Random", "Count", "Selection"}, {keyRingDesc}); - Option KeyRingsRandomCount = Option::U8 ("Keyring Dungeon Count", {NumOpts(0, 8)}, {keyRingDesc}, OptionCategory::Setting, 1); + Option KeyRingsRandomCount = Option::U8 ("Keyring Dungeon Count", {NumOpts(0, 9)}, {keyRingDesc}, OptionCategory::Setting, 1); Option RingFortress = Option::Bool("Gerudo Fortress", {"Off", "On"}, {keyRingDesc}, OptionCategory::Setting); Option RingForest = Option::Bool("Forest Temple", {"Off", "On"}, {keyRingDesc}, OptionCategory::Setting); Option RingFire = Option::Bool("Fire Temple", {"Off", "On"}, {keyRingDesc}, OptionCategory::Setting); @@ -2155,7 +2155,8 @@ namespace Settings { LACSTokenCount.Hide(); } - if (KeyRings.IsNot(KEYRINGS_OFF)) { + // Only show dungeons when keyring selection is enabled + if (KeyRings.Is(KEYRINGS_SELECTION)) { for (Option *option : keyRingOptions) { option->Unhide(); } @@ -2829,6 +2830,7 @@ namespace Settings { KeyRings.SetSelectedIndex(cvarSettings[RSK_KEYRINGS]); KeyRingsRandomCount.SetSelectedIndex(cvarSettings[RSK_KEYRINGS_RANDOM_COUNT]); + RingFortress.SetSelectedIndex(cvarSettings[RSK_KEYRINGS_GERUDO_FORTRESS]); RingForest.SetSelectedIndex(cvarSettings[RSK_KEYRINGS_FOREST_TEMPLE]); RingFire.SetSelectedIndex(cvarSettings[RSK_KEYRINGS_FIRE_TEMPLE]); RingWater.SetSelectedIndex(cvarSettings[RSK_KEYRINGS_WATER_TEMPLE]); @@ -2923,22 +2925,20 @@ namespace Settings { } } - std::vector randKeyRingDungeons = {}; //Set key ring for each dungeon for (size_t i = 0; i < dungeons.size(); i++) { dungeons[i]->ClearKeyRing(); - if (dungeons[i]->GetSmallKeyCount() > 0) { - randKeyRingDungeons.push_back(i); - } } - if (KeyRings.Is(KEYRINGS_RANDOM) || KeyRings.Is(KEYRINGS_RANDOM_COUNT)) { - int keyRingCount = KeyRings.Is(KEYRINGS_RANDOM_COUNT) ? KeyRingsRandomCount.Value() : Random(0, randKeyRingDungeons.size()); - Shuffle(randKeyRingDungeons); - - for (uint8_t i = 0; i < keyRingCount; i++) { - dungeons[randKeyRingDungeons[i]]->SetKeyRing(); + if (KeyRings) { + // Random Key Rings + if (KeyRings.Is(KEYRINGS_RANDOM) || KeyRings.Is(KEYRINGS_RANDOM_COUNT)) { + auto keyRings = keyRingOptions; + int keyRingCount = KeyRings.Is(KEYRINGS_RANDOM_COUNT) ? KeyRingsRandomCount.Value() : Random(0, keyRings.size()); + Shuffle(keyRings); + for (size_t i = 0; i < keyRingCount; i++) { + keyRings[i]->SetSelectedIndex(ON); + } } - } else if (KeyRings.Is(KEYRINGS_SELECTION)) { if (RingWell) { BottomOfTheWell.SetKeyRing(); } diff --git a/soh/soh/Enhancements/randomizer/draw.cpp b/soh/soh/Enhancements/randomizer/draw.cpp index 69a25368c..73a052508 100644 --- a/soh/soh/Enhancements/randomizer/draw.cpp +++ b/soh/soh/Enhancements/randomizer/draw.cpp @@ -22,7 +22,7 @@ extern "C" void Randomizer_DrawSmallKey(PlayState* play, GetItemEntry* getItemEn { 126, 16, 177 }, // Shadow Temple { 227, 110, 255 }, // Bottom of the Well { 221, 212, 60 }, // Gerudo Training Grounds - { 255, 255, 255 }, // Theive's Hideout (unused) + { 255, 255, 255 }, // Thieves' Hideout { 80, 80, 80 } // Ganon's Castle }; @@ -110,7 +110,7 @@ extern "C" void Randomizer_DrawKeyRing(PlayState* play, GetItemEntry* getItemEnt { 126, 16, 177 }, // Shadow Temple { 227, 110, 255 }, // Bottom of the Well { 221, 212, 60 }, // Gerudo Training Grounds - { 255, 255, 255 }, // Theive's Hideout (unused) + { 255, 255, 255 }, // Thieves' Hideout { 80, 80, 80 } // Ganon's Castle }; diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 6fd58e908..463c51a13 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -270,6 +270,7 @@ std::unordered_map SpoilerfileSettingNameToEn { "Shuffle Dungeon Items:Token Count", RSK_LACS_TOKEN_COUNT }, { "Shuffle Dungeon Items:Key Rings", RSK_KEYRINGS }, { "Shuffle Dungeon Items:Keyring Dungeon Count", RSK_KEYRINGS_RANDOM_COUNT }, + { "Shuffle Dungeon Items:Gerudo Fortress", RSK_KEYRINGS_GERUDO_FORTRESS }, { "Shuffle Dungeon Items:Forest Temple", RSK_KEYRINGS_FOREST_TEMPLE }, { "Shuffle Dungeon Items:Fire Temple", RSK_KEYRINGS_FIRE_TEMPLE }, { "Shuffle Dungeon Items:Water Temple", RSK_KEYRINGS_WATER_TEMPLE }, @@ -845,6 +846,7 @@ void Randomizer::ParseRandomizerSettingsFile(const char* spoilerFileName) { case RSK_KAK_50_SKULLS_HINT: case RSK_WARP_SONG_HINTS: case RSK_SCRUB_TEXT_HINT: + case RSK_KEYRINGS_GERUDO_FORTRESS: case RSK_KEYRINGS_FOREST_TEMPLE: case RSK_KEYRINGS_FIRE_TEMPLE: case RSK_KEYRINGS_WATER_TEMPLE: @@ -2966,6 +2968,7 @@ void GenerateRandomizerImgui(std::string seed = "") { cvarSettings[RSK_GERUDO_KEYS] = CVarGetInteger("gRandomizeGerudoKeys", RO_GERUDO_KEYS_VANILLA); cvarSettings[RSK_KEYRINGS] = CVarGetInteger("gRandomizeShuffleKeyRings", RO_KEYRINGS_OFF); cvarSettings[RSK_KEYRINGS_RANDOM_COUNT] = CVarGetInteger("gRandomizeShuffleKeyRingsRandomCount", 8); + cvarSettings[RSK_KEYRINGS_GERUDO_FORTRESS] = CVarGetInteger("gRandomizeShuffleKeyRingsGerudoFortress", 0); cvarSettings[RSK_KEYRINGS_FOREST_TEMPLE] = CVarGetInteger("gRandomizeShuffleKeyRingsForestTemple", 0); cvarSettings[RSK_KEYRINGS_FIRE_TEMPLE] = CVarGetInteger("gRandomizeShuffleKeyRingsFireTemple", 0); cvarSettings[RSK_KEYRINGS_WATER_TEMPLE] = CVarGetInteger("gRandomizeShuffleKeyRingsWaterTemple", 0); @@ -3921,20 +3924,26 @@ void DrawRandoEditor(bool& open) { "\n" "Off - No dungeons will have their keys replaced with keyrings.\n" "\n" - "Random - A random amount of dungeons(0-8) will have their keys replaced with keyrings.\n" + "Random - A random amount of dungeons(0-9) will have their keys replaced with keyrings.\n" "\n" "Count - A specified amount of randomly selected dungeons will have their keys replaced with keyrings.\n" "\n" - "Selection - Hand select which dungeons will have their keys replaced with keyrings." + "Selection - Hand select which dungeons will have their keys replaced with keyrings.\n" + "\n" + "Selecting key ring for dungeons will have no effect if Small Keys are set to Start With or Vanilla.\n" + "\n" + "Selecting key ring for Thieves' Hideout will have no effect if Thieves' Hideout keys are in vanilla " + "locations or Gerudo's Fortress is set to Fast (Rescue One Carpenter)." ); UIWidgets::EnhancementCombobox("gRandomizeShuffleKeyRings", randoShuffleKeyRings, RO_KEYRINGS_OFF); ImGui::PopItemWidth(); switch (CVarGetInteger("gRandomizeShuffleKeyRings", RO_KEYRINGS_OFF)) { case RO_KEYRINGS_COUNT: UIWidgets::PaddedEnhancementSliderInt("Key Ring Count: %d", "##RandomizeShuffleKeyRingsRandomCount", - "gRandomizeShuffleKeyRingsRandomCount", 1, 8, "", 8, true, true, false); + "gRandomizeShuffleKeyRingsRandomCount", 1, 9, "", 9, true, true, false); break; case RO_KEYRINGS_SELECTION: + UIWidgets::EnhancementCheckbox("Gerudo Fortress##RandomizeShuffleKeyRings", "gRandomizeShuffleKeyRingsGerudoFortress"); UIWidgets::EnhancementCheckbox("Forest Temple##RandomizeShuffleKeyRings", "gRandomizeShuffleKeyRingsForestTemple"); UIWidgets::EnhancementCheckbox("Fire Temple##RandomizeShuffleKeyRings", "gRandomizeShuffleKeyRingsFireTemple"); UIWidgets::EnhancementCheckbox("Water Temple##RandomizeShuffleKeyRings", "gRandomizeShuffleKeyRingsWaterTemple"); diff --git a/soh/soh/Enhancements/randomizer/randomizerTypes.h b/soh/soh/Enhancements/randomizer/randomizerTypes.h index 13a1af3bd..299788f14 100644 --- a/soh/soh/Enhancements/randomizer/randomizerTypes.h +++ b/soh/soh/Enhancements/randomizer/randomizerTypes.h @@ -1072,6 +1072,7 @@ typedef enum { RSK_LACS_TOKEN_COUNT, RSK_KEYRINGS, RSK_KEYRINGS_RANDOM_COUNT, + RSK_KEYRINGS_GERUDO_FORTRESS, RSK_KEYRINGS_FOREST_TEMPLE, RSK_KEYRINGS_FIRE_TEMPLE, RSK_KEYRINGS_WATER_TEMPLE,