adjust closed forest and starting age settings for edge cases (#2421)

This commit is contained in:
Adam Bird 2023-01-30 22:51:41 -05:00 committed by GitHub
parent 44f963e310
commit 4e08eca1b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 23 deletions

View File

@ -2965,6 +2965,13 @@ namespace Settings {
trials[i]->SetAsRequired(); trials[i]->SetAsRequired();
} }
// If any ER option is on that would allow you to escape forest, then we should set closed forest to closed deku
if (OpenForest.Is(OPENFOREST_CLOSED) &&
(ShuffleInteriorEntrances.Is(SHUFFLEINTERIORS_ALL) || ShuffleOverworldEntrances || ShuffleOverworldSpawns ||
DecoupleEntrances || MixedEntrancePools)) {
OpenForest.SetSelectedIndex(OPENFOREST_CLOSED_DEKU);
}
if (StartingAge.Is(AGE_RANDOM)) { if (StartingAge.Is(AGE_RANDOM)) {
int choice = Random(0, 2); //50% chance of each int choice = Random(0, 2); //50% chance of each
if (choice == 0) { if (choice == 0) {

View File

@ -3168,11 +3168,9 @@ void DrawRandoEditor(bool& open) {
//Starting Age //Starting Age
//Disabled when Forest is set to Closed or under very specific conditions //Disabled when Forest is set to Closed or under very specific conditions
//RANDOTODO: Replace magic number checks with enums bool disableRandoStartingAge = CVarGetInteger("gRandomizeForest", RO_FOREST_CLOSED) == RO_FOREST_CLOSED ||
bool disableRandoStartingAge = (CVarGetInteger("gRandomizeLogicRules", RO_LOGIC_GLITCHLESS) == RO_LOGIC_GLITCHLESS) && ((CVarGetInteger("gRandomizeDoorOfTime", RO_DOOROFTIME_CLOSED) == RO_DOOROFTIME_CLOSED) &&
((CVarGetInteger("gRandomizeForest", RO_FOREST_CLOSED) == RO_FOREST_CLOSED) || (CVarGetInteger("gRandomizeShuffleOcarinas", RO_GENERIC_OFF) == RO_GENERIC_OFF)); // closed door of time with ocarina shuffle off
((CVarGetInteger("gRandomizeDoorOfTime", RO_DOOROFTIME_CLOSED) == RO_DOOROFTIME_CLOSED) &&
(CVarGetInteger("gRandomizeShuffleOcarinas", 0) == 0))); // ocarinas not shuffled
static const char* disableRandoStartingAgeText = "This option is disabled due to other options making the game unbeatable."; static const char* disableRandoStartingAgeText = "This option is disabled due to other options making the game unbeatable.";
ImGui::Text(Settings::StartingAge.GetName().c_str()); ImGui::Text(Settings::StartingAge.GetName().c_str());
@ -3181,19 +3179,7 @@ void DrawRandoEditor(bool& open) {
"Starting as adult means you start with the Master Sword in your inventory.\n" "Starting as adult means you start with the Master Sword in your inventory.\n"
"The child option is forcefully set if it would conflict with other options." "The child option is forcefully set if it would conflict with other options."
); );
if (disableRandoStartingAge) { UIWidgets::EnhancementCombobox("gRandomizeStartingAge", randoStartingAge, RO_AGE_MAX, RO_AGE_CHILD, disableRandoStartingAge, disableRandoStartingAgeText, RO_AGE_CHILD);
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f);
}
UIWidgets::EnhancementCombobox("gRandomizeStartingAge", randoStartingAge, RO_AGE_MAX, RO_AGE_CHILD);
if (disableRandoStartingAge) {
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) {
ImGui::SetTooltip("%s", disableRandoStartingAgeText);
}
CVarSetInteger("gRandomizeStartingAge", RO_AGE_CHILD);
ImGui::PopStyleVar(1);
ImGui::PopItemFlag();
}
UIWidgets::PaddedSeparator(); UIWidgets::PaddedSeparator();

View File

@ -245,11 +245,17 @@ namespace UIWidgets {
} }
} }
bool EnhancementCombobox(const char* name, const char* ComboArray[], size_t arraySize, uint8_t FirstTimeValue) { bool EnhancementCombobox(const char* name, const char* ComboArray[], size_t arraySize, uint8_t FirstTimeValue, bool disabled, const char* disabledTooltipText, uint8_t disabledValue) {
bool changed = false; bool changed = false;
if (FirstTimeValue <= 0) { if (FirstTimeValue <= 0) {
FirstTimeValue = 0; FirstTimeValue = 0;
} }
if (disabled) {
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f);
}
uint8_t selected = CVarGetInteger(name, FirstTimeValue); uint8_t selected = CVarGetInteger(name, FirstTimeValue);
uint8_t DefaultValue = selected; uint8_t DefaultValue = selected;
std::string comboName = std::string("##") + std::string(name); std::string comboName = std::string("##") + std::string(name);
@ -266,6 +272,21 @@ namespace UIWidgets {
} }
ImGui::EndCombo(); ImGui::EndCombo();
} }
if (disabled) {
ImGui::PopStyleVar(1);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(disabledTooltipText, "") != 0) {
ImGui::SetTooltip("%s", disabledTooltipText);
}
ImGui::PopItemFlag();
if (disabledValue >= 0 && selected != disabledValue) {
CVarSetInteger(name, disabledValue);
changed = true;
SohImGui::RequestCvarSaveOnNextTick();
}
}
return changed; return changed;
} }

View File

@ -48,7 +48,7 @@ namespace UIWidgets {
bool EnhancementCheckbox(const char* text, const char* cvarName, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross, bool defaultValue = false); 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); 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<std::string>& items, int defaultValue = 0); void EnhancementCombo(const std::string& name, const char* cvarName, const std::vector<std::string>& items, int defaultValue = 0);
bool EnhancementCombobox(const char* name, const char* ComboArray[], size_t arraySize, uint8_t FirstTimeValue); bool EnhancementCombobox(const char* name, const char* ComboArray[], size_t arraySize, uint8_t FirstTimeValue, bool disabled = false, const char* disabledTooltipText = "", uint8_t disabledValue = -1);
void PaddedText(const char* text, bool padTop = true, bool padBottom = true); void PaddedText(const char* text, bool padTop = true, bool padBottom = true);
bool EnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = false, bool disabled = false, const char* disabledTooltipText = ""); bool EnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = false, bool disabled = false, const char* disabledTooltipText = "");
void PaddedEnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = false, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = ""); void PaddedEnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = false, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = "");