diff options
author | 2018-10-05 01:13:05 +0200 | |
---|---|---|
committer | 2018-10-05 01:20:04 +0200 | |
commit | f522870d8acf3e12ab0845272844561d9195fe4d (patch) | |
tree | 46ebc8a6926af06ce89bd9308537a8eeb2fdf610 | |
parent | 99574efebe6c62ac7b4fda4080174dd91ac821ff (diff) |
-options: Restored erroneously-removed game-specific INI option reversion between runs. Fixes MT#06171. [Ryan Holtz]
-rw-r--r-- | src/frontend/mame/mame.cpp | 3 | ||||
-rw-r--r-- | src/lib/util/options.cpp | 26 | ||||
-rw-r--r-- | src/lib/util/options.h | 3 |
3 files changed, 32 insertions, 0 deletions
diff --git a/src/frontend/mame/mame.cpp b/src/frontend/mame/mame.cpp index 63c765abc24..528a1717a4a 100644 --- a/src/frontend/mame/mame.cpp +++ b/src/frontend/mame/mame.cpp @@ -211,6 +211,9 @@ int mame_machine_manager::execute() // parse any INI files as the first thing if (m_options.read_config()) { + // but first, revert out any potential game-specific INI settings from previous runs via the internal UI + m_options.revert(OPTION_PRIORITY_INI); + std::ostringstream errors; mame_options::parse_standard_inis(m_options, errors); } diff --git a/src/lib/util/options.cpp b/src/lib/util/options.cpp index d323ef11ffe..a7e901bbf70 100644 --- a/src/lib/util/options.cpp +++ b/src/lib/util/options.cpp @@ -1025,3 +1025,29 @@ bool core_options::header_exists(const char *description) const return iter != m_entries.end(); } + +//------------------------------------------------- +// revert - revert options at or below a certain +// priority back to their defaults +//------------------------------------------------- + +void core_options::revert(int priority_hi, int priority_lo) +{ + for (entry::shared_ptr &curentry : m_entries) + curentry->revert(priority_hi, priority_lo); +} + +//------------------------------------------------- +// revert - revert back to our default if we are +// within the given priority range +//------------------------------------------------- + +void core_options::simple_entry::revert(int priority_hi, int priority_lo) +{ + // if our priority is within the range, revert to the default + if (priority() <= priority_hi && priority() >= priority_lo) + { + set_value(std::string(default_value()), priority(), true); + set_priority(OPTION_PRIORITY_DEFAULT); + } +} diff --git a/src/lib/util/options.h b/src/lib/util/options.h index d0cb6e5c29f..74fec7b0a90 100644 --- a/src/lib/util/options.h +++ b/src/lib/util/options.h @@ -130,6 +130,7 @@ public: virtual void set_default_value(std::string &&newvalue); void set_description(const char *description) { m_description = description; } void set_value_changed_handler(std::function<void(const char *)> &&handler) { m_value_changed_handler = std::move(handler); } + virtual void revert(int priority_hi, int priority_lo) { } protected: virtual void internal_set_value(std::string &&newvalue) = 0; @@ -171,6 +172,7 @@ public: void set_description(const char *name, const char *description); void remove_entry(entry &delentry); void set_value_changed_handler(const std::string &name, std::function<void(const char *)> &&handler); + void revert(int priority_hi = OPTION_PRIORITY_MAXIMUM, int priority_lo = OPTION_PRIORITY_DEFAULT); // parsing/input void parse_command_line(const std::vector<std::string> &args, int priority, bool ignore_unknown_options = false); @@ -217,6 +219,7 @@ private: virtual const char *minimum() const override; virtual const char *maximum() const override; virtual const std::string &default_value() const override; + virtual void revert(int priority_hi, int priority_lo) override; virtual void set_default_value(std::string &&newvalue) override; |