diff options
author | Vas Crabb <vas@vastheman.com> | 2017-05-07 14:40:12 +1000 |
---|---|---|
committer | Vas Crabb <vas@vastheman.com> | 2017-05-07 14:40:12 +1000 |
commit | a400c011a96197281e205d265c267ecd915fb597 (patch) | |
tree | 68bb8b132d9c8dea4e587c22db6b32c6ece08b73 /src/frontend/mame/ui | |
parent | 1970bcfab8103d41ce65bffa7933d19eda1f1b19 (diff) |
Revert "Overhaul to how MAME handles options (#2260)"
This reverts commit 536990e77b49ccc50ef275bfbf1018cc29c16154.
Conflicts:
src/frontend/mame/mame.cpp
Sorry, but this change was half-baked. It breaks a lot of existing
functionality and clearly hasn't been tested in more than a tiny subset
of use cases. Please play this work back onto your own branch, and test
it before submitting another PR.
Diffstat (limited to 'src/frontend/mame/ui')
-rw-r--r-- | src/frontend/mame/ui/custui.cpp | 38 | ||||
-rw-r--r-- | src/frontend/mame/ui/dirmenu.cpp | 15 | ||||
-rw-r--r-- | src/frontend/mame/ui/info.cpp | 3 | ||||
-rw-r--r-- | src/frontend/mame/ui/miscmenu.cpp | 28 | ||||
-rw-r--r-- | src/frontend/mame/ui/selgame.cpp | 14 | ||||
-rw-r--r-- | src/frontend/mame/ui/selsoft.cpp | 26 | ||||
-rw-r--r-- | src/frontend/mame/ui/slotopt.cpp | 9 | ||||
-rw-r--r-- | src/frontend/mame/ui/sndmenu.cpp | 10 | ||||
-rw-r--r-- | src/frontend/mame/ui/submenu.cpp | 26 | ||||
-rw-r--r-- | src/frontend/mame/ui/submenu.h | 2 | ||||
-rw-r--r-- | src/frontend/mame/ui/ui.cpp | 35 |
11 files changed, 118 insertions, 88 deletions
diff --git a/src/frontend/mame/ui/custui.cpp b/src/frontend/mame/ui/custui.cpp index 438840f0fc0..17a5c22539b 100644 --- a/src/frontend/mame/ui/custui.cpp +++ b/src/frontend/mame/ui/custui.cpp @@ -64,10 +64,12 @@ menu_custom_ui::menu_custom_ui(mame_ui_manager &mui, render_container &container menu_custom_ui::~menu_custom_ui() { - ui().options().set_value(OPTION_HIDE_PANELS, ui_globals::panels_status, OPTION_PRIORITY_CMDLINE); + std::string error_string; + ui().options().set_value(OPTION_HIDE_PANELS, ui_globals::panels_status, OPTION_PRIORITY_CMDLINE, error_string); if (!m_lang.empty()) { - machine().options().set_value(OPTION_LANGUAGE, m_lang[m_currlang].c_str(), OPTION_PRIORITY_CMDLINE); + machine().options().set_value(OPTION_LANGUAGE, m_lang[m_currlang].c_str(), OPTION_PRIORITY_CMDLINE, error_string); + machine().options().mark_changed(OPTION_LANGUAGE); load_translation(machine().options()); } ui_globals::reset = true; @@ -213,10 +215,22 @@ menu_font_ui::menu_font_ui(mame_ui_manager &mui, render_container &container) : m_info_size = moptions.infos_size(); m_font_size = moptions.font_rows(); - m_info_max = atof(moptions.get_entry(OPTION_INFOS_SIZE)->maximum()); - m_info_min = atof(moptions.get_entry(OPTION_INFOS_SIZE)->minimum()); - m_font_max = atof(moptions.get_entry(OPTION_FONT_ROWS)->maximum()); - m_font_max = atof(moptions.get_entry(OPTION_FONT_ROWS)->minimum()); + + for (ui_options::entry &f_entry : moptions) + { + const char *entry_name = f_entry.name(); + if (entry_name && strlen(entry_name) && !strcmp(OPTION_INFOS_SIZE, f_entry.name())) + { + m_info_max = atof(f_entry.maximum()); + m_info_min = atof(f_entry.minimum()); + } + else if (entry_name && strlen(entry_name) && !strcmp(OPTION_FONT_ROWS, f_entry.name())) + { + m_font_max = atof(f_entry.maximum()); + m_font_min = atof(f_entry.minimum()); + } + } + } //------------------------------------------------- @@ -250,9 +264,11 @@ menu_font_ui::~menu_font_ui() name.insert(0, "[B]"); } #endif - machine().options().set_value(OPTION_UI_FONT, name, OPTION_PRIORITY_CMDLINE); - moptions.set_value(OPTION_INFOS_SIZE, m_info_size, OPTION_PRIORITY_CMDLINE); - moptions.set_value(OPTION_FONT_ROWS, m_font_size, OPTION_PRIORITY_CMDLINE); + machine().options().set_value(OPTION_UI_FONT, name.c_str(), OPTION_PRIORITY_CMDLINE, error_string); + machine().options().mark_changed(OPTION_UI_FONT); + + moptions.set_value(OPTION_INFOS_SIZE, m_info_size, OPTION_PRIORITY_CMDLINE, error_string); + moptions.set_value(OPTION_FONT_ROWS, m_font_size, OPTION_PRIORITY_CMDLINE, error_string); } //------------------------------------------------- @@ -447,11 +463,11 @@ menu_colors_ui::menu_colors_ui(mame_ui_manager &mui, render_container &container menu_colors_ui::~menu_colors_ui() { - std::string dec_color; + std::string error_string, dec_color; for (int index = 1; index < MUI_RESTORE; index++) { dec_color = string_format("%x", (uint32_t)m_color_table[index].color); - ui().options().set_value(m_color_table[index].option, dec_color.c_str(), OPTION_PRIORITY_CMDLINE); + ui().options().set_value(m_color_table[index].option, dec_color.c_str(), OPTION_PRIORITY_CMDLINE, error_string); } } diff --git a/src/frontend/mame/ui/dirmenu.cpp b/src/frontend/mame/ui/dirmenu.cpp index 2d0200ef099..1ef39925bfd 100644 --- a/src/frontend/mame/ui/dirmenu.cpp +++ b/src/frontend/mame/ui/dirmenu.cpp @@ -352,10 +352,11 @@ void menu_add_change_folder::handle() if (m_change) { if (ui().options().exists(s_folders[m_ref].option)) - ui().options().set_value(s_folders[m_ref].option, m_current_path.c_str(), OPTION_PRIORITY_CMDLINE); + ui().options().set_value(s_folders[m_ref].option, m_current_path.c_str(), OPTION_PRIORITY_CMDLINE, error_string); else if (strcmp(machine().options().value(s_folders[m_ref].option), m_current_path.c_str()) != 0) { - machine().options().set_value(s_folders[m_ref].option, m_current_path.c_str(), OPTION_PRIORITY_CMDLINE); + machine().options().set_value(s_folders[m_ref].option, m_current_path.c_str(), OPTION_PRIORITY_CMDLINE, error_string); + machine().options().mark_changed(s_folders[m_ref].option); } } else @@ -370,10 +371,11 @@ void menu_add_change_folder::handle() } if (ui().options().exists(s_folders[m_ref].option)) - ui().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE); + ui().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string); else if (strcmp(machine().options().value(s_folders[m_ref].option), tmppath.c_str()) != 0) { - machine().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE); + machine().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string); + machine().options().mark_changed(s_folders[m_ref].option); } } @@ -590,10 +592,11 @@ void menu_remove_folder::handle() } if (ui().options().exists(s_folders[m_ref].option)) - ui().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE); + ui().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string); else if (strcmp(machine().options().value(s_folders[m_ref].option),tmppath.c_str())!=0) { - machine().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE); + machine().options().set_value(s_folders[m_ref].option, tmppath.c_str(), OPTION_PRIORITY_CMDLINE, error_string); + machine().options().mark_changed(s_folders[m_ref].option); } reset_parent(reset_options::REMEMBER_REF); diff --git a/src/frontend/mame/ui/info.cpp b/src/frontend/mame/ui/info.cpp index ab0e6d85cd3..8101faad3c6 100644 --- a/src/frontend/mame/ui/info.cpp +++ b/src/frontend/mame/ui/info.cpp @@ -326,7 +326,8 @@ std::string machine_info::mandatory_images() { if (image.must_be_loaded()) { - if (m_machine.options().image_option(image.instance_name()).value().empty()) + auto iter = m_machine.options().image_options().find(image.instance_name()); + if (iter == m_machine.options().image_options().end() || iter->second.empty()) { if (is_first) is_first = false; diff --git a/src/frontend/mame/ui/miscmenu.cpp b/src/frontend/mame/ui/miscmenu.cpp index 66201951a91..3ec2bf78cd3 100644 --- a/src/frontend/mame/ui/miscmenu.cpp +++ b/src/frontend/mame/ui/miscmenu.cpp @@ -127,10 +127,12 @@ void menu_bios_selection::handle() if (val>cnt) val=1; dev->set_system_bios(val); if (strcmp(dev->tag(),":")==0) { - machine().options().set_value("bios", val-1, OPTION_PRIORITY_CMDLINE); + std::string error; + machine().options().set_value("bios", val-1, OPTION_PRIORITY_CMDLINE, error); + assert(error.empty()); } else { const char *slot_option_name = dev->owner()->tag() + 1; - machine().options().slot_option(slot_option_name).set_bios(string_format("%d", val - 1)); + machine().options().slot_options()[slot_option_name].set_bios(string_format("%d", val - 1)); } reset(reset_options::REMEMBER_REF); } @@ -673,14 +675,15 @@ void menu_export::populate(float &customtop, float &custombottom) menu_machine_configure::menu_machine_configure(mame_ui_manager &mui, render_container &container, const game_driver *prev, float _x0, float _y0) : menu(mui, container) , m_drv(prev) + , m_opts(mui.machine().options()) , x0(_x0) , y0(_y0) , m_curbios(0) , m_fav_reset(false) { // parse the INI file - std::ostringstream error; - mame_options::parse_standard_inis(m_opts, error, m_drv); + std::string error; + mame_options::parse_standard_inis(m_opts,error, m_drv); setup_bios(); } @@ -751,7 +754,9 @@ void menu_machine_configure::handle() else if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) { (menu_event->iptkey == IPT_UI_LEFT) ? --m_curbios : ++m_curbios; - m_opts.set_value(OPTION_BIOS, m_bios[m_curbios].second, OPTION_PRIORITY_CMDLINE); + std::string error; + m_opts.set_value(OPTION_BIOS, m_bios[m_curbios].second, OPTION_PRIORITY_CMDLINE, error); + m_opts.mark_changed(OPTION_BIOS); reset(reset_options::REMEMBER_POSITION); } } @@ -913,7 +918,8 @@ void menu_plugins_configure::handle() if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT || menu_event->iptkey == IPT_UI_SELECT) { int oldval = plugins.int_value((const char*)menu_event->itemref); - plugins.set_value((const char*)menu_event->itemref, oldval == 1 ? 0 : 1, OPTION_PRIORITY_CMDLINE); + std::string error_string; + plugins.set_value((const char*)menu_event->itemref, oldval == 1 ? 0 : 1, OPTION_PRIORITY_CMDLINE, error_string); changed = true; } } @@ -929,13 +935,13 @@ void menu_plugins_configure::populate(float &customtop, float &custombottom) { plugin_options& plugins = mame_machine_manager::instance()->plugins(); - for (auto &curentry : plugins.entries()) + for (auto &curentry : plugins) { - if (curentry->type() != OPTION_HEADER) + if (!curentry.is_header()) { - auto enabled = !strcmp(curentry->value(), "1"); - item_append(curentry->description(), enabled ? _("On") : _("Off"), - enabled ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW, (void *)(uintptr_t)curentry->name().c_str()); + auto enabled = std::string(curentry.value()) == "1"; + item_append(curentry.description(), enabled ? _("On") : _("Off"), + enabled ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW, (void *)(uintptr_t)curentry.name()); } } item_append(menu_item_type::SEPARATOR); diff --git a/src/frontend/mame/ui/selgame.cpp b/src/frontend/mame/ui/selgame.cpp index 04d1c2b2350..e2628f63a9b 100644 --- a/src/frontend/mame/ui/selgame.cpp +++ b/src/frontend/mame/ui/selgame.cpp @@ -116,7 +116,8 @@ menu_select_game::menu_select_game(mame_ui_manager &mui, render_container &conta if (!moptions.remember_last()) reselect_last::reset(); - mui.machine().options().set_value(OPTION_SNAPNAME, "%g/%i", OPTION_PRIORITY_CMDLINE); + mui.machine().options().set_value(OPTION_SNAPNAME, "%g/%i", OPTION_PRIORITY_CMDLINE, error_string); + mui.machine().options().set_value(OPTION_SOFTWARENAME, "", OPTION_PRIORITY_CMDLINE, error_string); ui_globals::curimage_view = FIRST_VIEW; ui_globals::curdats_view = 0; @@ -154,9 +155,9 @@ menu_select_game::~menu_select_game() filter.append(",").append(c_year::ui[c_year::actual]); ui_options &mopt = ui().options(); - mopt.set_value(OPTION_LAST_USED_FILTER, filter.c_str(), OPTION_PRIORITY_CMDLINE); - mopt.set_value(OPTION_LAST_USED_MACHINE, last_driver.c_str(), OPTION_PRIORITY_CMDLINE); - mopt.set_value(OPTION_HIDE_PANELS, ui_globals::panels_status, OPTION_PRIORITY_CMDLINE); + mopt.set_value(OPTION_LAST_USED_FILTER, filter.c_str(), OPTION_PRIORITY_CMDLINE, error_string); + mopt.set_value(OPTION_LAST_USED_MACHINE, last_driver.c_str(), OPTION_PRIORITY_CMDLINE, error_string); + mopt.set_value(OPTION_HIDE_PANELS, ui_globals::panels_status, OPTION_PRIORITY_CMDLINE, error_string); ui().save_ui_options(); } @@ -929,10 +930,11 @@ void menu_select_game::inkey_select_favorite(const event *menu_event) return; } + std::string error_string; std::string string_list = std::string(ui_swinfo->listname).append(":").append(ui_swinfo->shortname).append(":").append(ui_swinfo->part).append(":").append(ui_swinfo->instance); - mopt.set_value(OPTION_SOFTWARENAME, string_list.c_str(), OPTION_PRIORITY_CMDLINE); + mopt.set_value(OPTION_SOFTWARENAME, string_list.c_str(), OPTION_PRIORITY_CMDLINE, error_string); std::string snap_list = std::string(ui_swinfo->listname).append(PATH_SEPARATOR).append(ui_swinfo->shortname); - mopt.set_value(OPTION_SNAPNAME, snap_list.c_str(), OPTION_PRIORITY_CMDLINE); + mopt.set_value(OPTION_SNAPNAME, snap_list.c_str(), OPTION_PRIORITY_CMDLINE, error_string); reselect_last::driver = drv.driver().name; reselect_last::software = ui_swinfo->shortname; reselect_last::swlist = ui_swinfo->listname; diff --git a/src/frontend/mame/ui/selsoft.cpp b/src/frontend/mame/ui/selsoft.cpp index 23107e4d992..b5eeb36b204 100644 --- a/src/frontend/mame/ui/selsoft.cpp +++ b/src/frontend/mame/ui/selsoft.cpp @@ -144,6 +144,9 @@ menu_select_software::menu_select_software(mame_ui_manager &mui, render_containe ui_globals::switch_image = true; ui_globals::cur_sw_dats_view = 0; ui_globals::cur_sw_dats_total = 1; + + std::string error_string; + mui.machine().options().set_value(OPTION_SOFTWARENAME, "", OPTION_PRIORITY_CMDLINE, error_string); } //------------------------------------------------- @@ -715,10 +718,11 @@ void menu_select_software::inkey_select(const event *menu_event) return; } - machine().options().set_system_name(m_driver->name); - machine().options().set_value(OPTION_SOFTWARENAME, ui_swinfo->shortname, OPTION_PRIORITY_CMDLINE); + std::string error_string; + std::string string_list = std::string(ui_swinfo->listname).append(":").append(ui_swinfo->shortname).append(":").append(ui_swinfo->part).append(":").append(ui_swinfo->instance); + machine().options().set_value(OPTION_SOFTWARENAME, string_list.c_str(), OPTION_PRIORITY_CMDLINE, error_string); std::string snap_list = std::string(ui_swinfo->listname).append(PATH_SEPARATOR).append(ui_swinfo->shortname); - machine().options().set_value(OPTION_SNAPNAME, snap_list.c_str(), OPTION_PRIORITY_CMDLINE); + machine().options().set_value(OPTION_SNAPNAME, snap_list.c_str(), OPTION_PRIORITY_CMDLINE, error_string); reselect_last::driver = drivlist.driver().name; reselect_last::software = ui_swinfo->shortname; reselect_last::swlist = ui_swinfo->listname; @@ -1284,8 +1288,9 @@ void software_parts::handle() { if ((void*)&elem == menu_event->itemref) { + std::string error_string; std::string string_list = std::string(m_uiinfo->listname).append(":").append(m_uiinfo->shortname).append(":").append(elem.first).append(":").append(m_uiinfo->instance); - machine().options().set_value(OPTION_SOFTWARENAME, string_list.c_str(), OPTION_PRIORITY_CMDLINE); + machine().options().set_value(OPTION_SOFTWARENAME, string_list.c_str(), OPTION_PRIORITY_CMDLINE, error_string); reselect_last::driver = m_uiinfo->driver->name; reselect_last::software = m_uiinfo->shortname; @@ -1293,7 +1298,7 @@ void software_parts::handle() reselect_last::set(true); std::string snap_list = std::string(m_uiinfo->listname).append("/").append(m_uiinfo->shortname); - machine().options().set_value(OPTION_SNAPNAME, snap_list.c_str(), OPTION_PRIORITY_CMDLINE); + machine().options().set_value(OPTION_SNAPNAME, snap_list.c_str(), OPTION_PRIORITY_CMDLINE, error_string); mame_machine_manager::instance()->schedule_new_driver(*m_uiinfo->driver); machine().schedule_hard_reset(); @@ -1395,7 +1400,8 @@ void bios_selection::handle() reselect_last::set(true); } - moptions.set_value(OPTION_BIOS, elem.second, OPTION_PRIORITY_CMDLINE); + std::string error; + moptions.set_value(OPTION_BIOS, elem.second, OPTION_PRIORITY_CMDLINE, error); mame_machine_manager::instance()->schedule_new_driver(*s_driver); machine().schedule_hard_reset(); stack_reset(); @@ -1403,7 +1409,8 @@ void bios_selection::handle() else { ui_software_info *ui_swinfo = (ui_software_info *)m_driver; - machine().options().set_value(OPTION_BIOS, elem.second, OPTION_PRIORITY_CMDLINE); + std::string error; + machine().options().set_value(OPTION_BIOS, elem.second, OPTION_PRIORITY_CMDLINE, error); driver_enumerator drivlist(machine().options(), *ui_swinfo->driver); drivlist.next(); software_list_device *swlist = software_list_device::find_by_name(*drivlist.config(), ui_swinfo->listname.c_str()); @@ -1424,10 +1431,11 @@ void bios_selection::handle() menu::stack_push<software_parts>(ui(), container(), parts, ui_swinfo); return; } + std::string error_string; std::string string_list = std::string(ui_swinfo->listname).append(":").append(ui_swinfo->shortname).append(":").append(ui_swinfo->part).append(":").append(ui_swinfo->instance); - moptions.set_value(OPTION_SOFTWARENAME, string_list.c_str(), OPTION_PRIORITY_CMDLINE); + moptions.set_value(OPTION_SOFTWARENAME, string_list.c_str(), OPTION_PRIORITY_CMDLINE, error_string); std::string snap_list = std::string(ui_swinfo->listname).append(PATH_SEPARATOR).append(ui_swinfo->shortname); - moptions.set_value(OPTION_SNAPNAME, snap_list.c_str(), OPTION_PRIORITY_CMDLINE); + moptions.set_value(OPTION_SNAPNAME, snap_list.c_str(), OPTION_PRIORITY_CMDLINE, error_string); reselect_last::driver = drivlist.driver().name; reselect_last::software = ui_swinfo->shortname; reselect_last::swlist = ui_swinfo->listname; diff --git a/src/frontend/mame/ui/slotopt.cpp b/src/frontend/mame/ui/slotopt.cpp index 8434a667899..42ec9e1a896 100644 --- a/src/frontend/mame/ui/slotopt.cpp +++ b/src/frontend/mame/ui/slotopt.cpp @@ -27,9 +27,9 @@ device_slot_option *menu_slot_devices::slot_get_current_option(device_slot_inter std::string current; const char *slot_option_name = slot.device().tag() + 1; - if (!slot.fixed()) + if (!slot.fixed() && machine().options().slot_options().count(slot_option_name) > 0) { - current = machine().options().slot_option(slot_option_name).value(); + current = machine().options().slot_options()[slot_option_name].value(); } else { @@ -140,7 +140,9 @@ const char *menu_slot_devices::slot_get_option(device_slot_interface &slot, int void menu_slot_devices::set_slot_device(device_slot_interface &slot, const char *val) { - machine().options().set_value(slot.device().tag()+1, val, OPTION_PRIORITY_CMDLINE); + std::string error; + machine().options().set_value(slot.device().tag()+1, val, OPTION_PRIORITY_CMDLINE, error); + assert(error.empty()); } /*------------------------------------------------- @@ -198,6 +200,7 @@ void menu_slot_devices::handle() { if ((uintptr_t)menu_event->itemref == 1 && menu_event->iptkey == IPT_UI_SELECT) { + mame_options::add_slot_options(machine().options()); machine().schedule_hard_reset(); } else if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) diff --git a/src/frontend/mame/ui/sndmenu.cpp b/src/frontend/mame/ui/sndmenu.cpp index f2304b529ea..0a0d1c019ed 100644 --- a/src/frontend/mame/ui/sndmenu.cpp +++ b/src/frontend/mame/ui/sndmenu.cpp @@ -45,19 +45,23 @@ menu_sound_options::menu_sound_options(mame_ui_manager &mui, render_container &c menu_sound_options::~menu_sound_options() { + std::string error_string; emu_options &moptions = machine().options(); if (strcmp(moptions.value(OSDOPTION_SOUND),m_sound ? OSDOPTVAL_AUTO : OSDOPTVAL_NONE)!=0) { - moptions.set_value(OSDOPTION_SOUND, m_sound ? OSDOPTVAL_AUTO : OSDOPTVAL_NONE, OPTION_PRIORITY_CMDLINE); + moptions.set_value(OSDOPTION_SOUND, m_sound ? OSDOPTVAL_AUTO : OSDOPTVAL_NONE, OPTION_PRIORITY_CMDLINE, error_string); + machine().options().mark_changed(OSDOPTION_SOUND); } if (moptions.int_value(OPTION_SAMPLERATE)!=m_sound_rate[m_cur_rates]) { - moptions.set_value(OPTION_SAMPLERATE, m_sound_rate[m_cur_rates], OPTION_PRIORITY_CMDLINE); + moptions.set_value(OPTION_SAMPLERATE, m_sound_rate[m_cur_rates], OPTION_PRIORITY_CMDLINE, error_string); + machine().options().mark_changed(OPTION_SAMPLERATE); } if (moptions.bool_value(OPTION_SAMPLES)!=m_samples) { - moptions.set_value(OPTION_SAMPLES, m_samples, OPTION_PRIORITY_CMDLINE); + moptions.set_value(OPTION_SAMPLES, m_samples, OPTION_PRIORITY_CMDLINE, error_string); + machine().options().mark_changed(OPTION_SAMPLES); } } diff --git a/src/frontend/mame/ui/submenu.cpp b/src/frontend/mame/ui/submenu.cpp index ab18a5a5a95..5a8cb83cd8b 100644 --- a/src/frontend/mame/ui/submenu.cpp +++ b/src/frontend/mame/ui/submenu.cpp @@ -240,7 +240,8 @@ 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); + 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(); break; case OPTION_INTEGER: if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) @@ -248,7 +249,8 @@ 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); + sm_option.options->set_value(sm_option.name, i_cur, OPTION_PRIORITY_CMDLINE, error_string); + sm_option.entry->mark_changed(); } break; case OPTION_FLOAT: @@ -258,19 +260,17 @@ void submenu::handle() f_cur = atof(sm_option.entry->value()); if (sm_option.entry->has_range()) { - const char *minimum = sm_option.entry->minimum(); - const char *maximum = sm_option.entry->maximum(); - f_step = atof(minimum); + f_step = atof(sm_option.entry->minimum()); if (f_step <= 0.0f) { - int pmin = getprecisionchr(minimum); - int pmax = getprecisionchr(maximum); + int pmin = getprecisionchr(sm_option.entry->minimum()); + int pmax = getprecisionchr(sm_option.entry->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().c_str()); + int precision = getprecisionchr(sm_option.entry->default_value()); tmptxt = '1' + std::string(precision, '0'); f_step = 1 / atof(tmptxt.c_str()); } @@ -279,7 +279,8 @@ 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); + sm_option.options->set_value(sm_option.name, tmptxt.c_str(), OPTION_PRIORITY_CMDLINE, error_string); + sm_option.entry->mark_changed(); } break; case OPTION_STRING: @@ -292,11 +293,10 @@ 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); + sm_option.options->set_value(sm_option.name, v_cur.c_str(), OPTION_PRIORITY_CMDLINE, error_string); + sm_option.entry->mark_changed(); } break; - default: - break; } break; default: @@ -391,7 +391,7 @@ void submenu::populate(float &customtop, float &custombottom) break; case OPTION_STRING: { - std::string v_cur(sm_option->entry->value()); + std::string const 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), diff --git a/src/frontend/mame/ui/submenu.h b/src/frontend/mame/ui/submenu.h index f17b6fe53ff..acaf28d90e4 100644 --- a/src/frontend/mame/ui/submenu.h +++ b/src/frontend/mame/ui/submenu.h @@ -48,7 +48,7 @@ public: option_type type; const char *description; const char *name; - core_options::entry::shared_ptr entry; + core_options::entry *entry; core_options *options; std::vector<std::string> value; }; diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp index fc080835893..cf4ea2c9cc5 100644 --- a/src/frontend/mame/ui/ui.cpp +++ b/src/frontend/mame/ui/ui.cpp @@ -2228,18 +2228,14 @@ void mame_ui_manager::popup_time_string(int seconds, std::string message) void mame_ui_manager::load_ui_options() { // parse the file + std::string error; // attempt to open the output file emu_file file(machine().options().ini_path(), OPEN_FLAG_READ); if (file.open("ui.ini") == osd_file::error::NONE) { - try - { - options().parse_ini_file((util::core_file&)file, OPTION_PRIORITY_MAME_INI, true); - } - catch (options_exception &) - { + bool result = options().parse_ini_file((util::core_file&)file, OPTION_PRIORITY_MAME_INI, OPTION_PRIORITY_DRIVER_INI, error); + if (!result) osd_printf_error("**Error loading ui.ini**"); - } } } @@ -2270,37 +2266,28 @@ void mame_ui_manager::save_main_option() { // parse the file std::string error; - emu_options options(true); // This way we make sure that all OSD parts are in - - options.copy_from(machine().options()); + emu_options options(machine().options()); // This way we make sure that all OSD parts are in + std::string error_string; // attempt to open the main ini file { emu_file file(machine().options().ini_path(), OPEN_FLAG_READ); if (file.open(emulator_info::get_configname(), ".ini") == osd_file::error::NONE) { - try - { - options.parse_ini_file((util::core_file&)file, OPTION_PRIORITY_MAME_INI, true); - } - catch(options_error_exception &ex) + bool result = options.parse_ini_file((util::core_file&)file, OPTION_PRIORITY_MAME_INI, OPTION_PRIORITY_DRIVER_INI, error); + if (!result) { - osd_printf_error("**Error loading %s.ini**: %s\n", emulator_info::get_configname(), ex.message().c_str()); + osd_printf_error("**Error loading %s.ini**", emulator_info::get_configname()); return; } - catch (options_exception &) - { - // ignore other exceptions - } } } - for (const auto &f_entry : machine().options().entries()) + for (emu_options::entry &f_entry : machine().options()) { - const char *value = f_entry->value(); - if (value && strcmp(value, options.value(f_entry->name().c_str()))) + if (f_entry.is_changed()) { - options.set_value(f_entry->name(), *f_entry->value(), OPTION_PRIORITY_CMDLINE); + options.set_value(f_entry.name(), f_entry.value(), OPTION_PRIORITY_CMDLINE, error_string); } } |