summaryrefslogtreecommitdiffstats
path: root/src/frontend/mame/ui/submenu.cpp
diff options
context:
space:
mode:
author npwoods <npwoods@alumni.carnegiemellon.edu>2017-05-05 02:17:49 -0400
committer Vas Crabb <cuavas@users.noreply.github.com>2017-05-05 16:17:49 +1000
commit536990e77b49ccc50ef275bfbf1018cc29c16154 (patch)
tree86e160cca07995479cd87506732c178b3728e58a /src/frontend/mame/ui/submenu.cpp
parentcce3369cdeec54494c6d4dc4a781cbba64d027bd (diff)
Overhaul to how MAME handles options (#2260)
This is an overhaul to how MAME handles options to provide a better foundation for what MAME is already doing in practice. Previously, core_options was designed to provide an input/output facility for reading options from the command line and INI files. However, the current needs (image/slot/get_default_card_software calculus and MewUI) go way beyond that. Broadly, this PR makes the following changes: * core_options now has an extensibility mechanism, so one can register options that behave dramatically differently * With that foundation, emu_options now encapsulates all of the funky image/slot/get_default_card_software calculus that were previously handled by static methods in mameopts.cpp. Changes to emu_options should not automatically cascade in such a way so that it stays in a consistent state * emu_options no longer provides direct access to the slot_options/image_options maps; there are simpler API functions that control these capabilities * Many core_options functions that expose internal data structures (e.g. - priority) that were only really needed because of previous (now obsolete) techniques have been removed. * core_options is now exception based (rather than dumping text to an std::string). The burden is on the caller to catch these, and discern between warnings and errors as needed. Obviously this is a risky change; that's why this is being submitted at the start of the dev cycle.
Diffstat (limited to 'src/frontend/mame/ui/submenu.cpp')
-rw-r--r--src/frontend/mame/ui/submenu.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/frontend/mame/ui/submenu.cpp b/src/frontend/mame/ui/submenu.cpp
index 5a8cb83cd8b..ab18a5a5a95 100644
--- a/src/frontend/mame/ui/submenu.cpp
+++ b/src/frontend/mame/ui/submenu.cpp
@@ -240,8 +240,7 @@ void submenu::handle()
{
case OPTION_BOOLEAN:
changed = true;
- sm_option.options->set_value(sm_option.name, !strcmp(sm_option.entry->value(),"1") ? "0" : "1", OPTION_PRIORITY_CMDLINE, error_string);
- sm_option.entry->mark_changed();
+ sm_option.options->set_value(sm_option.name, !strcmp(sm_option.entry->value(),"1") ? "0" : "1", OPTION_PRIORITY_CMDLINE);
break;
case OPTION_INTEGER:
if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
@@ -249,8 +248,7 @@ void submenu::handle()
changed = true;
int i_cur = atoi(sm_option.entry->value());
(menu_event->iptkey == IPT_UI_LEFT) ? i_cur-- : i_cur++;
- sm_option.options->set_value(sm_option.name, i_cur, OPTION_PRIORITY_CMDLINE, error_string);
- sm_option.entry->mark_changed();
+ sm_option.options->set_value(sm_option.name, i_cur, OPTION_PRIORITY_CMDLINE);
}
break;
case OPTION_FLOAT:
@@ -260,17 +258,19 @@ void submenu::handle()
f_cur = atof(sm_option.entry->value());
if (sm_option.entry->has_range())
{
- f_step = atof(sm_option.entry->minimum());
+ const char *minimum = sm_option.entry->minimum();
+ const char *maximum = sm_option.entry->maximum();
+ f_step = atof(minimum);
if (f_step <= 0.0f) {
- int pmin = getprecisionchr(sm_option.entry->minimum());
- int pmax = getprecisionchr(sm_option.entry->maximum());
+ int pmin = getprecisionchr(minimum);
+ int pmax = getprecisionchr(maximum);
tmptxt = '1' + std::string((pmin > pmax) ? pmin : pmax, '0');
f_step = 1 / atof(tmptxt.c_str());
}
}
else
{
- int precision = getprecisionchr(sm_option.entry->default_value());
+ int precision = getprecisionchr(sm_option.entry->default_value().c_str());
tmptxt = '1' + std::string(precision, '0');
f_step = 1 / atof(tmptxt.c_str());
}
@@ -279,8 +279,7 @@ void submenu::handle()
else
f_cur += f_step;
tmptxt = string_format("%g", f_cur);
- sm_option.options->set_value(sm_option.name, tmptxt.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
- sm_option.entry->mark_changed();
+ sm_option.options->set_value(sm_option.name, tmptxt.c_str(), OPTION_PRIORITY_CMDLINE);
}
break;
case OPTION_STRING:
@@ -293,10 +292,11 @@ void submenu::handle()
v_cur = sm_option.value[--cur_value];
else
v_cur = sm_option.value[++cur_value];
- sm_option.options->set_value(sm_option.name, v_cur.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
- sm_option.entry->mark_changed();
+ sm_option.options->set_value(sm_option.name, v_cur.c_str(), OPTION_PRIORITY_CMDLINE);
}
break;
+ default:
+ break;
}
break;
default:
@@ -391,7 +391,7 @@ void submenu::populate(float &customtop, float &custombottom)
break;
case OPTION_STRING:
{
- std::string const v_cur(sm_option->entry->value());
+ std::string v_cur(sm_option->entry->value());
int const cur_value = std::distance(sm_option->value.begin(), std::find(sm_option->value.begin(), sm_option->value.end(), v_cur));
arrow_flags = get_arrow_flags(0, int(unsigned(sm_option->value.size() - 1)), cur_value);
item_append(_(sm_option->description),