diff options
author | 2017-04-15 16:32:12 -0400 | |
---|---|---|
committer | 2017-04-15 22:32:12 +0200 | |
commit | 02ea4fd43cb42ffdbba6f87a93c03b697c426269 (patch) | |
tree | f04a48f239f0686fe711fbda5dc7e69a97d2b281 /src/lib | |
parent | c4b2aa746602b5896400bef928cf76c5d5c72e83 (diff) |
Fixes issues specifying image/slot options fron INI files (reported by Robbbert) (#2231)
This fix really doesn't go far enough. I added hooks so that options specified at the command line can also be responded to when parsed from INI files, but in the long run much of the logic that is currently in mame_options should go into emu_options so that when an option is specified, all of the wacko logic around slot/image specification "just works" because it is encapsulated within emu_options.
We have a release 11 days away; I want to be in stabilization mode.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/util/options.cpp | 9 | ||||
-rw-r--r-- | src/lib/util/options.h | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/lib/util/options.cpp b/src/lib/util/options.cpp index af83291f83b..16b62f9c91f 100644 --- a/src/lib/util/options.cpp +++ b/src/lib/util/options.cpp @@ -559,12 +559,15 @@ std::string core_options::output_ini(const core_options *diff) const int num_valid_headers = 0; int unadorned_index = 0; const char *last_header = nullptr; + std::string overridden_value; // loop over all items for (entry &curentry : m_entrylist) { const char *name = curentry.name(); - const char *value = curentry.value(); + const char *value = name && override_get_value(name, overridden_value) + ? overridden_value.c_str() + : curentry.value(); bool is_unadorned = false; // check if it's unadorned @@ -848,6 +851,10 @@ bool core_options::validate_and_set_data(core_options::entry &curentry, std::str data.erase(data.length() - 1, 1); } + // let derived classes override how we set this data + if (override_set_value(curentry.name(), data)) + return true; + // validate the type of data and optionally the range float fval; int ival; diff --git a/src/lib/util/options.h b/src/lib/util/options.h index 47780652586..b2bc46343ac 100644 --- a/src/lib/util/options.h +++ b/src/lib/util/options.h @@ -182,6 +182,8 @@ public: protected: virtual void value_changed(const std::string &name, const std::string &value) {} + virtual bool override_get_value(const char *name, std::string &value) const { return false; } + virtual bool override_set_value(const char *name, const std::string &value) { return false; } private: // internal helpers |