add button to reset settings to default

This commit is contained in:
gymnast86
2026-06-17 03:00:40 -07:00
parent 8a92efbe0d
commit 56d47d475f
4 changed files with 24 additions and 0 deletions
@@ -16,6 +16,17 @@ namespace randomizer::seedgen::config
LoadFromFile(settingsPath, preferencesPath);
}
void Config::ResetSettingsToDefault() {
for (auto& settings : this->_settingsList) {
for (auto& [settingName, setting] : settings.GetMap()) {
setting.SetCurrentOption(setting.GetInfo()->GetDefaultOption());
}
settings.GetModifiableExcludedLocations().clear();
settings.GetModifiableStartingInventory().clear();
settings.GetModifiableMixedEntrancePools().clear();
}
}
void Config::LoadFromFile(const fspath& settingsPath,
const fspath& preferencesPath,
const bool& createIfNotFound /*= true*/,
@@ -55,6 +55,7 @@ namespace randomizer::seedgen::config
auto& GetSettings() { return this->_settingsList.front();}
bool IsUsingPlandomizer() const { return this->_isUsingPlandomizer; }
bool IsGeneratingSpoilerLog() const { return this->_isGeneratingSpoilerLog; }
void ResetSettingsToDefault();
// void resetDefaultSettings();
// void resetDefaultPreferences(const bool& paths = false);
@@ -202,6 +202,7 @@ namespace randomizer::seedgen::settings
const std::list<std::list<std::string>>& GetMixedEntrancePools() const { return this->_mixedEntrancePools; }
std::map<std::string, int>& GetModifiableStartingInventory() { return this->_startingInventory; }
std::set<std::string>& GetModifiableExcludedLocations() { return this->_excludedLocations; }
std::list<std::list<std::string>>& GetModifiableMixedEntrancePools() { return this->_mixedEntrancePools; }
private:
std::map<std::string, Setting> _map = {};
+11
View File
@@ -829,6 +829,17 @@ RandomizerWindow::RandomizerWindow(dFile_select_c* fileSelect /*= nullptr*/) : m
auto& leftPane = add_child<Pane>(content, Pane::Type::Controlled);
auto& rightPane = add_child<Pane>(content, Pane::Type::Uncontrolled);
leftPane.register_control(leftPane.add_button("Reset Settings to Default")
.on_pressed([] {
GetRandomizerConfig().ResetSettingsToDefault();
SaveRandomizerConfig();
}),
rightPane, [](Pane& pane) {
pane.clear();
pane.add_rml(
"Reset all settings to their default values. This will also clear starting items and excluded locations.");
});
leftPane.add_section("Logic Settings");
rando_config_group(leftPane, rightPane, "Logic Rules");