From 8021f29c3ed864de32c0270e628e02c8c8bcb83b Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Sat, 10 Dec 2022 14:36:17 -0600 Subject: [PATCH] Add toggle for all locations reachable (#2125) --- soh/soh/Enhancements/randomizer/3drando/settings.cpp | 1 + soh/soh/Enhancements/randomizer/randomizer.cpp | 12 ++++++++++++ soh/soh/Enhancements/randomizer/randomizerTypes.h | 1 + soh/soh/UIWidgets.cpp | 8 ++++---- soh/soh/UIWidgets.hpp | 4 ++-- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/3drando/settings.cpp b/soh/soh/Enhancements/randomizer/3drando/settings.cpp index d0615e124..4dfa26afb 100644 --- a/soh/soh/Enhancements/randomizer/3drando/settings.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/settings.cpp @@ -2608,6 +2608,7 @@ namespace Settings { Logic.SetSelectedIndex(2); break; } + LocationsReachable.SetSelectedIndex(cvarSettings[RSK_ALL_LOCATIONS_REACHABLE]); AddExcludedOptions(); for (auto locationKey : everyPossibleLocation) { diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 9bacc8d96..0668c6157 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -2552,6 +2552,7 @@ void GenerateRandomizerImgui() { std::unordered_map cvarSettings; cvarSettings[RSK_LOGIC_RULES] = CVar_GetS32("gRandomizeLogicRules", RO_LOGIC_GLITCHLESS); + cvarSettings[RSK_ALL_LOCATIONS_REACHABLE] = CVar_GetS32("gRandomizeAllLocationsReachable", RO_GENERIC_ON); cvarSettings[RSK_FOREST] = CVar_GetS32("gRandomizeForest", RO_FOREST_CLOSED); cvarSettings[RSK_KAK_GATE] = CVar_GetS32("gRandomizeKakarikoGate", RO_KAK_GATE_CLOSED); cvarSettings[RSK_DOOR_OF_TIME] = CVar_GetS32("gRandomizeDoorOfTime", RO_DOOROFTIME_CLOSED); @@ -3975,6 +3976,17 @@ void DrawRandoEditor(bool& open) { "No logic - Item placement is completely random. MAY BE IMPOSSIBLE TO BEAT." ); UIWidgets::EnhancementCombobox("gRandomizeLogicRules", randoLogicRules, RO_LOGIC_MAX, RO_LOGIC_GLITCHLESS); + if (CVar_GetS32("gRandomizeLogicRules", RO_LOGIC_GLITCHLESS) == RO_LOGIC_GLITCHLESS) { + ImGui::SameLine(); + UIWidgets::EnhancementCheckbox(Settings::LocationsReachable.GetName().c_str(), "gRandomizeAllLocationsReachable", false, "", UIWidgets::CheckboxGraphics::Cross, RO_GENERIC_ON); + UIWidgets::InsertHelpHoverText( + "When this options is enabled, the randomizer will " + "guarantee that every item is obtainable and every " + "location is reachable. When disabled, only " + "required items and locations to beat the game " + "will be guaranteed reachable." + ); + } UIWidgets::PaddedSeparator(); diff --git a/soh/soh/Enhancements/randomizer/randomizerTypes.h b/soh/soh/Enhancements/randomizer/randomizerTypes.h index da38374ab..593e2fa34 100644 --- a/soh/soh/Enhancements/randomizer/randomizerTypes.h +++ b/soh/soh/Enhancements/randomizer/randomizerTypes.h @@ -1067,6 +1067,7 @@ typedef enum { RSK_MIX_GROTTO_ENTRANCES, RSK_DECOUPLED_ENTRANCES, RSK_STARTING_SKULLTULA_TOKEN, + RSK_ALL_LOCATIONS_REACHABLE, RSK_MAX } RandomizerSettingKey; diff --git a/soh/soh/UIWidgets.cpp b/soh/soh/UIWidgets.cpp index 4e9fd38a6..2282c73ad 100644 --- a/soh/soh/UIWidgets.cpp +++ b/soh/soh/UIWidgets.cpp @@ -196,13 +196,13 @@ namespace UIWidgets { return pressed; } - bool EnhancementCheckbox(const char* text, const char* cvarName, bool disabled, const char* disabledTooltipText, CheckboxGraphics disabledGraphic) { + bool EnhancementCheckbox(const char* text, const char* cvarName, bool disabled, const char* disabledTooltipText, CheckboxGraphics disabledGraphic, bool defaultValue) { bool changed = false; if (disabled) { ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f); } - bool val = (bool)CVar_GetS32(cvarName, 0); + bool val = (bool)CVar_GetS32(cvarName, defaultValue); if (CustomCheckbox(text, &val, disabled, disabledGraphic)) { CVar_SetS32(cvarName, val); SohImGui::RequestCvarSaveOnNextTick(); @@ -219,11 +219,11 @@ namespace UIWidgets { return changed; } - bool PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop, bool padBottom, bool disabled, const char* disabledTooltipText, CheckboxGraphics disabledGraphic) { + bool PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop, bool padBottom, bool disabled, const char* disabledTooltipText, CheckboxGraphics disabledGraphic, bool defaultValue) { bool changed = false; if (padTop) Spacer(0); - if (EnhancementCheckbox(text, cvarName, disabled, disabledTooltipText, disabledGraphic)) { + if (EnhancementCheckbox(text, cvarName, disabled, disabledTooltipText, disabledGraphic, defaultValue)) { changed = true; } diff --git a/soh/soh/UIWidgets.hpp b/soh/soh/UIWidgets.hpp index 48fb7d6a5..31ba7fd83 100644 --- a/soh/soh/UIWidgets.hpp +++ b/soh/soh/UIWidgets.hpp @@ -36,8 +36,8 @@ namespace UIWidgets { void Spacer(float height); void PaddedSeparator(bool padTop = true, bool padBottom = true, float extraVerticalTopPadding = 0.0f, float extraVerticalBottomPadding = 0.0f); - bool EnhancementCheckbox(const char* text, const char* cvarName, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross); - bool PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross); + bool EnhancementCheckbox(const char* text, const char* cvarName, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross, bool defaultValue = false); + bool PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross, bool defaultValue = false); void EnhancementCombo(const std::string& name, const char* cvarName, const std::vector& items, int defaultValue = 0); bool EnhancementCombobox(const char* name, const char* ComboArray[], size_t arraySize, uint8_t FirstTimeValue); void PaddedText(const char* text, bool padTop = true, bool padBottom = true);