Skip to content

Commit

Permalink
Merge pull request #2 from leggettc18/gf-keyring
Browse files Browse the repository at this point in the history
Adds validation to GF Key Ring and Key Ring Count settings
  • Loading branch information
Archez authored May 25, 2023
2 parents 5244cda + f6b9c22 commit 015c30d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
4 changes: 3 additions & 1 deletion soh/soh/Enhancements/randomizer/3drando/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ namespace Settings {
&RingCastle,
};
std::vector<Option *> keyRingOptions = {
&RingFortress,
&RingForest,
&RingFire,
&RingWater,
Expand Down Expand Up @@ -2933,6 +2932,9 @@ namespace Settings {
// Random Key Rings
if (KeyRings.Is(KEYRINGS_RANDOM) || KeyRings.Is(KEYRINGS_RANDOM_COUNT)) {
auto keyRings = keyRingOptions;
if (GerudoFortress.Is(GERUDOFORTRESS_NORMAL) && GerudoKeys.IsNot(GERUDOKEYS_VANILLA)) {
keyRings.push_back(&RingFortress);
}
int keyRingCount = KeyRings.Is(KEYRINGS_RANDOM_COUNT) ? KeyRingsRandomCount.Value<uint8_t>() : Random(0, keyRings.size());
Shuffle(keyRings);
for (size_t i = 0; i < keyRingCount; i++) {
Expand Down
44 changes: 35 additions & 9 deletions soh/soh/Enhancements/randomizer/randomizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2967,8 +2967,17 @@ void GenerateRandomizerImgui(std::string seed = "") {
cvarSettings[RSK_KEYSANITY] = CVarGetInteger("gRandomizeKeysanity", RO_DUNGEON_ITEM_LOC_OWN_DUNGEON);
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);
int maxKeyringCount = (CVarGetInteger("gRandomizeGerudoFortress", RO_GF_NORMAL) == RO_GF_NORMAL &&
CVarGetInteger("gRandomizeGerudoKeys", RO_GERUDO_KEYS_VANILLA) != RO_GERUDO_KEYS_VANILLA)
? 9
: 8;
cvarSettings[RSK_KEYRINGS_RANDOM_COUNT] = std::min(CVarGetInteger("gRandomizeShuffleKeyRingsRandomCount", maxKeyringCount), maxKeyringCount);
// Don't allow this to be on if Gerudo Fortress Carpenters is anything other than Normal
cvarSettings[RSK_KEYRINGS_GERUDO_FORTRESS] =
(CVarGetInteger("gRandomizeGerudoFortress", RO_GF_NORMAL) == RO_GF_NORMAL &&
CVarGetInteger("gRandomizeGerudoKeys", RO_GERUDO_KEYS_VANILLA) != RO_GERUDO_KEYS_VANILLA)
? CVarGetInteger("gRandomizeShuffleKeyRingsGerudoFortress", RO_GENERIC_OFF)
: RO_GENERIC_OFF;
cvarSettings[RSK_KEYRINGS_FOREST_TEMPLE] = CVarGetInteger("gRandomizeShuffleKeyRingsForestTemple", 0);
cvarSettings[RSK_KEYRINGS_FIRE_TEMPLE] = CVarGetInteger("gRandomizeShuffleKeyRingsFireTemple", 0);
cvarSettings[RSK_KEYRINGS_WATER_TEMPLE] = CVarGetInteger("gRandomizeShuffleKeyRingsWaterTemple", 0);
Expand Down Expand Up @@ -3160,6 +3169,9 @@ void DrawRandoEditor(bool& open) {
static const char* randoItemPool[4] = { "Plentiful", "Balanced", "Scarce", "Minimal" };
static const char* randoIceTraps[5] = { "Off", "Normal", "Extra", "Mayhem", "Onslaught" };

static int maxKeyringCount;
static bool disableGFKeyring = false;

ImGui::SetNextWindowSize(ImVec2(920, 600), ImGuiCond_FirstUseEver);
if (!ImGui::Begin("Randomizer Editor", &open, ImGuiWindowFlags_NoFocusOnAppearing)) {
ImGui::End();
Expand Down Expand Up @@ -3327,7 +3339,9 @@ void DrawRandoEditor(bool& open) {
"\n"
"Fast - Only the bottom left carpenter requires rescuing.\n"
"\n"
"Open - The bridge is repaired from the start."
"Open - The bridge is repaired from the start.\n"
"\n"
"Only \"Normal\" is compatible with Gerudo Fortress Key Rings."
);
UIWidgets::EnhancementCombobox("gRandomizeGerudoFortress", randoGerudoFortress, RO_GF_NORMAL);

Expand Down Expand Up @@ -3924,26 +3938,38 @@ void DrawRandoEditor(bool& open) {
"\n"
"Off - No dungeons will have their keys replaced with keyrings.\n"
"\n"
"Random - A random amount of dungeons(0-9) will have their keys replaced with keyrings.\n"
"Random - A random amount of dungeons(0-8 or 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.\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)."
"If Gerudo Fortress Carpenters is set to Normal, and Gerudo Fortress Keys is set to anything "
"other than Vanilla, then the maximum amount of Key Rings that can be selected by Random or "
"Count will be 9. Otherwise, the maximum amount of Key Rings will be 8."
);
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, 9, "", 9, true, true, false);
maxKeyringCount =
(CVarGetInteger("gRandomizeGerudoFortress", RO_GF_NORMAL) == RO_GF_NORMAL &&
CVarGetInteger("gRandomizeGerudoKeys", RO_GERUDO_KEYS_VANILLA) != RO_GERUDO_KEYS_VANILLA)
? 9
: 8;
UIWidgets::PaddedEnhancementSliderInt("Key Ring Count: %d",
"##RandomizeShuffleKeyRingsRandomCount",
"gRandomizeShuffleKeyRingsRandomCount", 1,
maxKeyringCount, "", maxKeyringCount, true, true, false);
break;
case RO_KEYRINGS_SELECTION:
UIWidgets::EnhancementCheckbox("Gerudo Fortress##RandomizeShuffleKeyRings", "gRandomizeShuffleKeyRingsGerudoFortress");
disableGFKeyring =
CVarGetInteger("gRandomizeGerudoFortress", RO_GF_NORMAL) != RO_GF_NORMAL || CVarGetInteger("gRandomizeGerudoKeys", RO_GERUDO_KEYS_VANILLA) == RO_GERUDO_KEYS_VANILLA;
UIWidgets::EnhancementCheckbox(
"Gerudo Fortress##RandomizeShuffleKeyRings", "gRandomizeShuffleKeyRingsGerudoFortress",
disableGFKeyring, "Disabled because the currently selected Gerudo Fortress Carpenters\n setting and/or Gerudo Fortress Keys setting is incompatible with \nhaving a Gerudo Fortress keyring.");
UIWidgets::EnhancementCheckbox("Forest Temple##RandomizeShuffleKeyRings", "gRandomizeShuffleKeyRingsForestTemple");
UIWidgets::EnhancementCheckbox("Fire Temple##RandomizeShuffleKeyRings", "gRandomizeShuffleKeyRingsFireTemple");
UIWidgets::EnhancementCheckbox("Water Temple##RandomizeShuffleKeyRings", "gRandomizeShuffleKeyRingsWaterTemple");
Expand Down

0 comments on commit 015c30d

Please sign in to comment.