diff options
Diffstat (limited to 'src/frontend/mame/ui/ui.cpp')
-rw-r--r-- | src/frontend/mame/ui/ui.cpp | 88 |
1 files changed, 84 insertions, 4 deletions
diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp index 37df0da6b1f..ff581c5fd3b 100644 --- a/src/frontend/mame/ui/ui.cpp +++ b/src/frontend/mame/ui/ui.cpp @@ -37,7 +37,6 @@ #include "rendfont.h" #include "romload.h" #include "uiinput.h" - #include "../osd/modules/lib/osdobj_common.h" #include <chrono> @@ -215,6 +214,8 @@ void mame_ui_manager::init() // request notification callbacks machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(&mame_ui_manager::exit, this)); + // register callbacks + machine().configuration().config_register("sliders", config_load_delegate(&mame_ui_manager::config_load_s, this), config_save_delegate(&mame_ui_manager::config_save_s, this)); machine().configuration().config_register( "ui_warnings", config_load_delegate(&mame_ui_manager::config_load, this), @@ -630,7 +631,8 @@ void mame_ui_manager::update_and_render(render_container &container) m_popup_text_end = 0; // display the internal mouse cursor - if (m_mouse_show || (is_menu_active() && machine().options().ui_mouse())) + if (machine().options().ui_mouse() && (m_mouse_show || is_menu_active())) //MESSUI - (NEWUI) system pointer always on; MAME pointer always off +// if (m_mouse_show || (is_menu_active() && machine().options().ui_mouse())) { int32_t mouse_target_x, mouse_target_y; bool mouse_button; @@ -1526,7 +1528,7 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine // add CPU overclocking (cheat only) slider_index = 0; - if (machine.options().cheat()) +// if (machine.options().cheat()) // HBMAME { for (device_execute_interface &exec : execute_interface_enumerator(machine.root_device())) { @@ -1559,7 +1561,7 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine std::string screen_desc = machine_info().get_screen_desc(screen); // add refresh rate tweaker - if (machine.options().cheat()) +// if (machine.options().cheat()) // HBMAME { std::string str = string_format(_("%1$s Refresh Rate"), screen_desc); m_sliders.push_back(slider_alloc(SLIDER_ID_REFRESH + slider_index, str.c_str(), -10000, 0, 10000, 1000, param)); @@ -1644,6 +1646,7 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine } } #endif + config_apply(); std::vector<ui::menu_item> items; for (auto &slider : m_sliders) @@ -2336,6 +2339,83 @@ void mame_ui_manager::menu_reset() ui::menu::stack_reset(machine()); } + +//------------------------------------------------- +// config_load - read data from the +// configuration file +//------------------------------------------------- + +void mame_ui_manager::config_load_s(config_type cfg_type, util::xml::data_node const *parentnode) +{ + // we only care about game files + if (cfg_type != config_type::GAME) + return; + + // might not have any data + if (parentnode == nullptr) + return; + + // iterate over slider nodes + for (util::xml::data_node const *slider_node = parentnode->get_child("slider"); slider_node; slider_node = slider_node->get_next_sibling("slider")) + { + const char *desc = slider_node->get_attribute_string("desc", ""); + int32_t saved_val = slider_node->get_attribute_int("value", 0); + + // create a dummy slider to store the saved value + m_sliders_saved.push_back(slider_alloc(0, desc, 0, saved_val, 0, 0, 0)); + } +} + + +//------------------------------------------------- +// config_appy - apply data from the conf. file +// This currently needs to be done on a separate +// step because sliders are not created yet when +// configuration file is loaded +//------------------------------------------------- + +void mame_ui_manager::config_apply(void) +{ + // iterate over sliders and restore saved values + for (auto &slider : m_sliders) + { + for (auto &slider_saved : m_sliders_saved) + { + if (!strcmp(slider->description.c_str(), slider_saved->description.c_str())) + { + std::string tempstring; + slider->update(machine(), slider->arg, slider->id, &tempstring, slider_saved->defval); + break; + } + } + } +} + + +//------------------------------------------------- +// config_save - save data to the configuration +// file +//------------------------------------------------- + +void mame_ui_manager::config_save_s(config_type cfg_type, util::xml::data_node *parentnode) +{ + // we only care about game files + if (cfg_type != config_type::GAME) + return; + + std::string tempstring; + util::xml::data_node *slider_node; + + // save UI sliders + for (auto &slider : m_sliders) + { + int32_t curval = slider->update(machine(), slider->arg, slider->id, &tempstring, SLIDER_NOCHANGE); + slider_node = parentnode->add_child("slider", nullptr); + slider_node->set_attribute("desc", slider->description.c_str()); + slider_node->set_attribute_int("value", curval); + } +} + void ui_colors::refresh(const ui_options &options) { m_border_color = options.border_color(); |