From 56d47d475fa2035c0ac89dc961a33ff4359c873a Mon Sep 17 00:00:00 2001 From: gymnast86 Date: Wed, 17 Jun 2026 03:00:40 -0700 Subject: [PATCH] add button to reset settings to default --- src/dusk/randomizer/generator/seedgen/config.cpp | 11 +++++++++++ src/dusk/randomizer/generator/seedgen/config.hpp | 1 + src/dusk/randomizer/generator/seedgen/settings.hpp | 1 + src/dusk/ui/rando_config.cpp | 11 +++++++++++ 4 files changed, 24 insertions(+) diff --git a/src/dusk/randomizer/generator/seedgen/config.cpp b/src/dusk/randomizer/generator/seedgen/config.cpp index f467bbebee..0a3c533a07 100644 --- a/src/dusk/randomizer/generator/seedgen/config.cpp +++ b/src/dusk/randomizer/generator/seedgen/config.cpp @@ -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*/, diff --git a/src/dusk/randomizer/generator/seedgen/config.hpp b/src/dusk/randomizer/generator/seedgen/config.hpp index 61a892c2b5..175c9374f6 100644 --- a/src/dusk/randomizer/generator/seedgen/config.hpp +++ b/src/dusk/randomizer/generator/seedgen/config.hpp @@ -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); diff --git a/src/dusk/randomizer/generator/seedgen/settings.hpp b/src/dusk/randomizer/generator/seedgen/settings.hpp index 09ccf696d8..114b4b09cf 100644 --- a/src/dusk/randomizer/generator/seedgen/settings.hpp +++ b/src/dusk/randomizer/generator/seedgen/settings.hpp @@ -202,6 +202,7 @@ namespace randomizer::seedgen::settings const std::list>& GetMixedEntrancePools() const { return this->_mixedEntrancePools; } std::map& GetModifiableStartingInventory() { return this->_startingInventory; } std::set& GetModifiableExcludedLocations() { return this->_excludedLocations; } + std::list>& GetModifiableMixedEntrancePools() { return this->_mixedEntrancePools; } private: std::map _map = {}; diff --git a/src/dusk/ui/rando_config.cpp b/src/dusk/ui/rando_config.cpp index dd872bcc3a..7b4928cac9 100644 --- a/src/dusk/ui/rando_config.cpp +++ b/src/dusk/ui/rando_config.cpp @@ -829,6 +829,17 @@ RandomizerWindow::RandomizerWindow(dFile_select_c* fileSelect /*= nullptr*/) : m auto& leftPane = add_child(content, Pane::Type::Controlled); auto& rightPane = add_child(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");