Make tricks and locations lists re-evaluate after preset application. (#6263)

This commit is contained in:
Malkierian
2026-02-14 15:58:26 -07:00
committed by GitHub
parent 7eb5acf224
commit b83ca39c98
3 changed files with 34 additions and 22 deletions

View File

@@ -122,6 +122,8 @@ void applyPreset(std::string presetName, std::vector<PresetSection> includeSecti
}
if (i == PRESET_SECTION_RANDOMIZER) {
Rando::Settings::GetInstance()->UpdateAllOptions();
SohGui::UpdateMenuTricks();
SohGui::UpdateMenuLocations();
}
}
}

View File

@@ -26,6 +26,8 @@ static std::map<int32_t, const char*> languages = {
{ LANGUAGE_FRA, "French" },
{ LANGUAGE_JPN, "Japanese" },
};
void UpdateMenuTricks();
void UpdateMenuLocations();
class SohMenu : public Ship::Menu {
public:

View File

@@ -38,15 +38,8 @@ void DrawLocationsMenu(WidgetInfo& info) {
ImGui::BeginDisabled(CVarGetInteger(CVAR_SETTING("DisableChanges"), 0) || disableEditingRandoSettings);
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, cellPadding);
if (locationsDirty || currMQDungeonSetting != prevMQDungeonSetting) {
RandomizerCheckObjects::UpdateImGuiVisibility();
// todo: this efficently when we build out cvar array support
std::stringstream excludedLocationStringStream(CVarGetString(CVAR_RANDOMIZER_SETTING("ExcludedLocations"), ""));
std::string excludedLocationString;
excludedLocations.clear();
while (getline(excludedLocationStringStream, excludedLocationString, ',')) {
excludedLocations.insert((RandomizerCheck)std::stoi(excludedLocationString));
}
locationsDirty = false;
UpdateMenuLocations();
}
prevMQDungeonSetting = currMQDungeonSetting;
@@ -166,6 +159,34 @@ void DrawLocationsMenu(WidgetInfo& info) {
ImGui::EndDisabled();
}
void UpdateMenuLocations() {
RandomizerCheckObjects::UpdateImGuiVisibility();
// todo: this efficently when we build out cvar array support
std::stringstream excludedLocationStringStream(CVarGetString(CVAR_RANDOMIZER_SETTING("ExcludedLocations"), ""));
std::string excludedLocationString;
excludedLocations.clear();
while (getline(excludedLocationStringStream, excludedLocationString, ',')) {
excludedLocations.insert((RandomizerCheck)std::stoi(excludedLocationString));
}
}
void UpdateMenuTricks() {
// RandomizerTricks::UpdateImGuiVisibility();
// todo: this efficently when we build out cvar array support
std::stringstream enabledTrickStringStream(CVarGetString(CVAR_RANDOMIZER_SETTING("EnabledTricks"), ""));
std::string enabledTrickString;
enabledTricks.clear();
while (getline(enabledTrickStringStream, enabledTrickString, ',')) {
enabledTricks.insert((RandomizerTrick)std::stoi(enabledTrickString));
}
std::stringstream enabledGlitchStringStream(CVarGetString(CVAR_RANDOMIZER_SETTING("EnabledGlitches"), ""));
std::string enabledGlitchString;
enabledGlitches.clear();
while (getline(enabledGlitchStringStream, enabledGlitchString, ',')) {
enabledGlitches.insert((RandomizerTrick)std::stoi(enabledGlitchString));
}
}
void DrawTricksMenu(WidgetInfo& info) {
auto ctx = OTRGlobals::Instance->gRandoContext;
auto randoSettings = Rando::Settings::GetInstance();
@@ -174,20 +195,7 @@ void DrawTricksMenu(WidgetInfo& info) {
bool disableEditingRandoSettings = generating || CVarGetInteger(CVAR_GENERAL("OnFileSelectNameEntry"), 0);
if (tricksDirty) {
tricksDirty = false;
// RandomizerTricks::UpdateImGuiVisibility();
// todo: this efficently when we build out cvar array support
std::stringstream enabledTrickStringStream(CVarGetString(CVAR_RANDOMIZER_SETTING("EnabledTricks"), ""));
std::string enabledTrickString;
enabledTricks.clear();
while (getline(enabledTrickStringStream, enabledTrickString, ',')) {
enabledTricks.insert((RandomizerTrick)std::stoi(enabledTrickString));
}
std::stringstream enabledGlitchStringStream(CVarGetString(CVAR_RANDOMIZER_SETTING("EnabledGlitches"), ""));
std::string enabledGlitchString;
enabledGlitches.clear();
while (getline(enabledGlitchStringStream, enabledGlitchString, ',')) {
enabledGlitches.insert((RandomizerTrick)std::stoi(enabledGlitchString));
}
UpdateMenuTricks();
}
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, cellPadding);