summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend/mame/ui/optsmenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/mame/ui/optsmenu.cpp')
-rw-r--r--src/frontend/mame/ui/optsmenu.cpp365
1 files changed, 212 insertions, 153 deletions
diff --git a/src/frontend/mame/ui/optsmenu.cpp b/src/frontend/mame/ui/optsmenu.cpp
index fd29c3329bc..4452fae9bce 100644
--- a/src/frontend/mame/ui/optsmenu.cpp
+++ b/src/frontend/mame/ui/optsmenu.cpp
@@ -30,182 +30,44 @@ namespace ui {
// ctor
//-------------------------------------------------
-menu_game_options::menu_game_options(mame_ui_manager &mui, render_container &container) : menu(mui, container)
+menu_simple_game_options::menu_simple_game_options(
+ mame_ui_manager &mui,
+ render_container &container,
+ std::function<void ()> &&handler)
+ : menu(mui, container)
+ , m_handler(std::move(handler))
{
- m_main = main_filters::actual;
}
//-------------------------------------------------
// dtor
//-------------------------------------------------
-menu_game_options::~menu_game_options()
+menu_simple_game_options::~menu_simple_game_options()
{
- main_filters::actual = m_main;
- reset_topmost(reset_options::SELECT_FIRST);
ui().save_ui_options();
- ui_globals::switch_image = true;
+ if (m_handler)
+ m_handler();
}
//-------------------------------------------------
// handle
//-------------------------------------------------
-void menu_game_options::handle()
+void menu_simple_game_options::handle()
{
- bool changed = false;
-
// process the menu
- const event *menu_event;
- if (machine().options().ui() == emu_options::UI_SIMPLE)
- {
- menu_event = process(PROCESS_LR_REPEAT);
- }
- else
- {
- process_parent();
- menu_event = process(PROCESS_LR_REPEAT | PROCESS_NOIMAGE);
- }
-
- if (menu_event != nullptr && menu_event->itemref != nullptr)
- switch ((uintptr_t)menu_event->itemref)
- {
- case FILTER_MENU:
- if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
- {
- (menu_event->iptkey == IPT_UI_RIGHT) ? ++m_main : --m_main;
- changed = true;
- }
- else if (menu_event->iptkey == IPT_UI_SELECT)
- {
- std::vector<std::string> s_sel(machine_filter::COUNT);
- for (unsigned index = 0; index < s_sel.size(); ++index)
- s_sel[index] = machine_filter::display_name(machine_filter::type(index));
-
- menu::stack_push<menu_selector>(
- ui(), container(), std::move(s_sel), m_main,
- [this] (int selection)
- {
- m_main = machine_filter::type(selection);
- reset(reset_options::REMEMBER_REF);
- });
- }
- break;
- case FILTER_ADJUST:
- if (menu_event->iptkey == IPT_UI_LEFT)
- {
- changed = main_filters::filters.find(m_main)->second->adjust_left();
- }
- else if (menu_event->iptkey == IPT_UI_RIGHT)
- {
- changed = main_filters::filters.find(m_main)->second->adjust_right();
- }
- else if (menu_event->iptkey == IPT_UI_SELECT)
- {
- main_filters::filters.find(m_main)->second->show_ui(
- ui(),
- container(),
- [this] (machine_filter &filter)
- {
- if (machine_filter::CUSTOM == filter.get_type())
- {
- emu_file file(ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
- if (file.open("custom_", emulator_info::get_configname(), "_filter.ini") == osd_file::error::NONE)
- {
- filter.save_ini(file, 0);
- file.close();
- }
- }
- reset(reset_options::REMEMBER_REF);
- });
- }
- break;
- case CONF_DIR:
- if (menu_event->iptkey == IPT_UI_SELECT)
- menu::stack_push<menu_directory>(ui(), container());
- break;
- case MISC_MENU:
- if (menu_event->iptkey == IPT_UI_SELECT)
- {
- menu::stack_push<submenu>(ui(), container(), submenu::misc_options);
- ui_globals::reset = true;
- }
- break;
- case SOUND_MENU:
- if (menu_event->iptkey == IPT_UI_SELECT)
- {
- menu::stack_push<menu_sound_options>(ui(), container());
- ui_globals::reset = true;
- }
- break;
- case DISPLAY_MENU:
- if (menu_event->iptkey == IPT_UI_SELECT)
- {
- menu::stack_push<submenu>(ui(), container(), submenu::video_options);
- ui_globals::reset = true;
- }
- break;
- case CUSTOM_MENU:
- if (menu_event->iptkey == IPT_UI_SELECT)
- menu::stack_push<menu_custom_ui>(ui(), container());
- break;
- case CONTROLLER_MENU:
- if (menu_event->iptkey == IPT_UI_SELECT)
- menu::stack_push<submenu>(ui(), container(), submenu::control_options);
- break;
- case CGI_MENU:
- if (menu_event->iptkey == IPT_UI_SELECT)
- menu::stack_push<menu_input_groups>(ui(), container());
- break;
- case ADVANCED_MENU:
- if (menu_event->iptkey == IPT_UI_SELECT)
- {
- menu::stack_push<submenu>(ui(), container(), submenu::advanced_options);
- ui_globals::reset = true;
- }
- break;
- case SAVE_CONFIG:
- if (menu_event->iptkey == IPT_UI_SELECT)
- ui().save_main_option();
- break;
- }
-
- if (changed)
- reset(reset_options::REMEMBER_REF);
+ event const *const menu_event(process(PROCESS_LR_REPEAT));
+ if (menu_event && menu_event->itemref)
+ handle_item_event(*menu_event);
}
//-------------------------------------------------
// populate
//-------------------------------------------------
-void menu_game_options::populate(float &customtop, float &custombottom)
+void menu_simple_game_options::populate(float &customtop, float &custombottom)
{
- if (machine().options().ui() != emu_options::UI_SIMPLE)
- {
- // set filter arrow
- std::string fbuff;
-
- // add filter item
- uint32_t arrow_flags = get_arrow_flags<uint16_t>(machine_filter::FIRST, machine_filter::LAST, m_main);
- auto active_filter(main_filters::filters.find(m_main));
- if (main_filters::filters.end() == active_filter)
- active_filter = main_filters::filters.emplace(m_main, machine_filter::create(m_main)).first;
- item_append(_("Filter"), active_filter->second->display_name(), arrow_flags, (void *)(uintptr_t)FILTER_MENU);
-
- // add subitem if the filter wants it
- if (active_filter->second->wants_adjuster())
- {
- std::string name("^!");
- convert_command_glyph(name);
- item_append(name, active_filter->second->adjust_text(), active_filter->second->arrow_flags(), (void *)(FILTER_ADJUST));
- }
-
- item_append(menu_item_type::SEPARATOR);
-
- // add options items
- item_append(_("Customize UI"), "", 0, (void *)(uintptr_t)CUSTOM_MENU);
- item_append(_("Configure Directories"), "", 0, (void *)(uintptr_t)CONF_DIR);
- }
item_append(_(submenu::video_options[0].description), "", 0, (void *)(uintptr_t)DISPLAY_MENU);
item_append(_("Sound Options"), "", 0, (void *)(uintptr_t)SOUND_MENU);
item_append(_(submenu::misc_options[0].description), "", 0, (void *)(uintptr_t)MISC_MENU);
@@ -220,10 +82,61 @@ void menu_game_options::populate(float &customtop, float &custombottom)
}
//-------------------------------------------------
+// handle item
+//-------------------------------------------------
+
+void menu_simple_game_options::handle_item_event(event const &menu_event)
+{
+ switch ((uintptr_t)menu_event.itemref)
+ {
+ case MISC_MENU:
+ if (menu_event.iptkey == IPT_UI_SELECT)
+ {
+ menu::stack_push<submenu>(ui(), container(), submenu::misc_options);
+ ui_globals::reset = true;
+ }
+ break;
+ case SOUND_MENU:
+ if (menu_event.iptkey == IPT_UI_SELECT)
+ {
+ menu::stack_push<menu_sound_options>(ui(), container());
+ ui_globals::reset = true;
+ }
+ break;
+ case DISPLAY_MENU:
+ if (menu_event.iptkey == IPT_UI_SELECT)
+ {
+ menu::stack_push<submenu>(ui(), container(), submenu::video_options);
+ ui_globals::reset = true;
+ }
+ break;
+ case CONTROLLER_MENU:
+ if (menu_event.iptkey == IPT_UI_SELECT)
+ menu::stack_push<submenu>(ui(), container(), submenu::control_options);
+ break;
+ case CGI_MENU:
+ if (menu_event.iptkey == IPT_UI_SELECT)
+ menu::stack_push<menu_input_groups>(ui(), container());
+ break;
+ case ADVANCED_MENU:
+ if (menu_event.iptkey == IPT_UI_SELECT)
+ {
+ menu::stack_push<submenu>(ui(), container(), submenu::advanced_options);
+ ui_globals::reset = true;
+ }
+ break;
+ case SAVE_CONFIG:
+ if (menu_event.iptkey == IPT_UI_SELECT)
+ ui().save_main_option();
+ break;
+ }
+}
+
+//-------------------------------------------------
// perform our special rendering
//-------------------------------------------------
-void menu_game_options::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
+void menu_simple_game_options::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
char const *const toptext[] = { _("Settings") };
draw_text_box(
@@ -234,4 +147,150 @@ void menu_game_options::custom_render(void *selectedref, float top, float bottom
}
+//-------------------------------------------------
+// ctor
+//-------------------------------------------------
+
+menu_game_options::menu_game_options(
+ mame_ui_manager &mui,
+ render_container &container,
+ machine_filter_data &filter_data,
+ std::function<void ()> &&handler)
+ : menu_simple_game_options(mui, container, std::move(handler))
+ , m_filter_data(filter_data)
+ , m_main_filter(filter_data.get_current_filter_type())
+{
+}
+
+//-------------------------------------------------
+// dtor
+//-------------------------------------------------
+
+menu_game_options::~menu_game_options()
+{
+ m_filter_data.set_current_filter_type(m_main_filter);
+}
+
+//-------------------------------------------------
+// handle
+//-------------------------------------------------
+
+void menu_game_options::handle()
+{
+ // process the menu
+ process_parent();
+ event const *const menu_event(process(PROCESS_LR_REPEAT | PROCESS_NOIMAGE));
+ if (menu_event && menu_event->itemref)
+ handle_item_event(*menu_event);
+}
+
+//-------------------------------------------------
+// populate
+//-------------------------------------------------
+
+void menu_game_options::populate(float &customtop, float &custombottom)
+{
+ // set filter arrow
+ std::string fbuff;
+
+ // add filter item
+ uint32_t arrow_flags = get_arrow_flags<uint16_t>(machine_filter::FIRST, machine_filter::LAST, m_main_filter);
+ machine_filter &active_filter(m_filter_data.get_filter(m_main_filter));
+ item_append(_("Filter"), active_filter.display_name(), arrow_flags, (void *)(uintptr_t)FILTER_MENU);
+
+ // add subitem if the filter wants it
+ if (active_filter.wants_adjuster())
+ {
+ std::string name("^!");
+ convert_command_glyph(name);
+ item_append(name, active_filter.adjust_text(), active_filter.arrow_flags(), (void *)(FILTER_ADJUST));
+ }
+
+ item_append(menu_item_type::SEPARATOR);
+
+ // add options items
+ item_append(_("Customize UI"), "", 0, (void *)(uintptr_t)CUSTOM_MENU);
+ item_append(_("Configure Directories"), "", 0, (void *)(uintptr_t)CONF_DIR);
+
+ // add the options that don't relate to the UI
+ menu_simple_game_options::populate(customtop, custombottom);
+}
+
+//-------------------------------------------------
+// handle item
+//-------------------------------------------------
+
+void menu_game_options::handle_item_event(event const &menu_event)
+{
+ bool changed = false;
+
+ switch ((uintptr_t)menu_event.itemref)
+ {
+ case FILTER_MENU:
+ if (menu_event.iptkey == IPT_UI_LEFT || menu_event.iptkey == IPT_UI_RIGHT)
+ {
+ (menu_event.iptkey == IPT_UI_RIGHT) ? ++m_main_filter : --m_main_filter;
+ changed = true;
+ }
+ else if (menu_event.iptkey == IPT_UI_SELECT)
+ {
+ std::vector<std::string> s_sel(machine_filter::COUNT);
+ for (unsigned index = 0; index < s_sel.size(); ++index)
+ s_sel[index] = machine_filter::display_name(machine_filter::type(index));
+
+ menu::stack_push<menu_selector>(
+ ui(), container(), std::move(s_sel), m_main_filter,
+ [this] (int selection)
+ {
+ m_main_filter = machine_filter::type(selection);
+ reset(reset_options::REMEMBER_REF);
+ });
+ }
+ break;
+ case FILTER_ADJUST:
+ if (menu_event.iptkey == IPT_UI_LEFT)
+ {
+ changed = m_filter_data.get_filter(m_main_filter).adjust_left();
+ }
+ else if (menu_event.iptkey == IPT_UI_RIGHT)
+ {
+ changed = m_filter_data.get_filter(m_main_filter).adjust_right();
+ }
+ else if (menu_event.iptkey == IPT_UI_SELECT)
+ {
+ m_filter_data.get_filter(m_main_filter).show_ui(
+ ui(),
+ container(),
+ [this] (machine_filter &filter)
+ {
+ if (machine_filter::CUSTOM == filter.get_type())
+ {
+ emu_file file(ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
+ if (file.open("custom_", emulator_info::get_configname(), "_filter.ini") == osd_file::error::NONE)
+ {
+ filter.save_ini(file, 0);
+ file.close();
+ }
+ }
+ reset(reset_options::REMEMBER_REF);
+ });
+ }
+ break;
+ case CONF_DIR:
+ if (menu_event.iptkey == IPT_UI_SELECT)
+ menu::stack_push<menu_directory>(ui(), container());
+ break;
+ case CUSTOM_MENU:
+ if (menu_event.iptkey == IPT_UI_SELECT)
+ menu::stack_push<menu_custom_ui>(ui(), container());
+ break;
+ default:
+ menu_simple_game_options::handle_item_event(menu_event);
+ return;
+ }
+
+ if (changed)
+ reset(reset_options::REMEMBER_REF);
+}
+
} // namespace ui