diff options
author | 2021-10-31 12:31:16 +1100 | |
---|---|---|
committer | 2021-10-31 12:31:16 +1100 | |
commit | d64ea5331b2312f81df464fb22dcef0191216d86 (patch) | |
tree | a3f3784371da401e6a675e5b6b9734b88281a08d /src/frontend/mame/ui/simpleselgame.cpp | |
parent | cfffc54b61cabc5ef9533396bf87324eb5eeb63e (diff) |
-frontend: Refactored menu event handling and fixed a number of issues. (#8777)
* Moved common code for drawing about box, info viewer, and other text box menus to a base class; removed the last of the info viewer logic and the multi-line item hack from the base menu class.
* Added previous/next group navigation for general inputs and plugin input selection menus.
* Moved message catalog logic to lib/util, allowing osd and emu to use localised messages.
* Made the base menu class use the UI manager’s feature for holding session state rather than a static map and mutex.
* Improved menu event handling model, and fixed many issues, particularly with menus behaving badly when hidden/shown.
* Added better support for menus that don’t participate in the usual menu stack, like the menuless sliders and the save/load state menus.
* Made a number of menus refresh state when being shown after being hidden (fixes MT08121 among other issues).
* Fixed indication of mounted slot option in the slot option details menu.
* Improved appearance of background menus when emulation isn't running - draw all menus in the stack, and darken the background menus to make the edges of the active menu clearer.
* Fixed locale issues in -listxml.
-debugger: Made GUI debuggers more uniform.
* Added new memory view features to Win32 debugger.
* Fixed spelling of hexadecimal in Cocoa debugger and added decimal address option.
* Fixed duplicate keyboard shortcut in Cocoa debugger (Shift-Cmd-D was both new device window and 64-bit float format).
* Made keyboard shortcuts slightly more consistent across debuggers.
-plugins: Moved input selection menu and sequence polling code to a common library. Fixed the issue that prevented keyboard inputs being mapped with -steadykey on.
-docs: Started adding some documentation for MAME's internal UI, and updated the list of example front-ends.
-Regenerated message catalog sources. For translators, the new strings are mostly:
* The names of the inputs provided by the OS-dependent layer for things like fullscreen and video features. These show up in the user interface inputs menu.
* The names for automatically generated views. These show up in the video options menu - test with a system with a lot of screens to see more variants.
* The input macro plugin UI.
* A few format strings for analog input assignments.
* A few strings for the about box header.
Diffstat (limited to 'src/frontend/mame/ui/simpleselgame.cpp')
-rw-r--r-- | src/frontend/mame/ui/simpleselgame.cpp | 96 |
1 files changed, 51 insertions, 45 deletions
diff --git a/src/frontend/mame/ui/simpleselgame.cpp b/src/frontend/mame/ui/simpleselgame.cpp index 9ad2fe62dc3..4803b390247 100644 --- a/src/frontend/mame/ui/simpleselgame.cpp +++ b/src/frontend/mame/ui/simpleselgame.cpp @@ -35,7 +35,7 @@ namespace ui { simple_menu_select_game::simple_menu_select_game(mame_ui_manager &mui, render_container &container, const char *gamename) : menu(mui, container) - , m_error(false), m_rerandomize(false) + , m_nomatch(false), m_error(false), m_rerandomize(false) , m_search() , m_driverlist(driver_list::total() + 1) , m_drivlist() @@ -44,6 +44,7 @@ simple_menu_select_game::simple_menu_select_game(mame_ui_manager &mui, render_co , m_cached_unemulated(device_t::feature::NONE), m_cached_imperfect(device_t::feature::NONE) , m_cached_color(ui().colors().background_color()) { + set_process_flags(PROCESS_IGNOREPAUSE); set_needs_prev_menu_item(false); build_driver_list(); if (gamename) @@ -109,34 +110,30 @@ void simple_menu_select_game::build_driver_list() // handle - handle the game select menu //------------------------------------------------- -void simple_menu_select_game::handle() +void simple_menu_select_game::handle(event const *ev) { - // ignore pause keys by swallowing them before we process the menu - machine().ui_input().pressed(IPT_UI_PAUSE); - // process the menu - const event *menu_event = process(0); - if (menu_event) + if (ev) { if (m_error) { - // reset the error on any future menu_event + // reset the error on any subsequent menu event m_error = false; machine().ui_input().reset(); } else { // handle selections - switch(menu_event->iptkey) + switch(ev->iptkey) { case IPT_UI_SELECT: - inkey_select(menu_event); + inkey_select(*ev); break; case IPT_UI_CANCEL: inkey_cancel(); break; case IPT_SPECIAL: - inkey_special(menu_event); + inkey_special(*ev); break; } } @@ -158,9 +155,9 @@ void simple_menu_select_game::handle() // inkey_select //------------------------------------------------- -void simple_menu_select_game::inkey_select(const event *menu_event) +void simple_menu_select_game::inkey_select(const event &menu_event) { - const game_driver *driver = (const game_driver *)menu_event->itemref; + const game_driver *driver = (const game_driver *)menu_event.itemref; if ((uintptr_t)driver == 1) // special case for configure inputs { @@ -217,11 +214,11 @@ void simple_menu_select_game::inkey_cancel() // inkey_special - typed characters append to the buffer //------------------------------------------------- -void simple_menu_select_game::inkey_special(const event *menu_event) +void simple_menu_select_game::inkey_special(const event &menu_event) { // typed characters append to the buffer size_t old_size = m_search.size(); - if (input_character(m_search, menu_event->unichar, uchar_is_printable)) + if (input_character(m_search, menu_event.unichar, uchar_is_printable)) { if (m_search.size() < old_size) m_rerandomize = true; @@ -243,49 +240,41 @@ void simple_menu_select_game::populate(float &customtop, float &custombottom) matchcount++; // if nothing there, add a single multiline item and return - if (matchcount == 0) - { - std::string txt = string_format( - _("No machines found. Please check the rompath specified in the %1$s.ini file.\n\n" - "If this is your first time using %2$s, please see the config.txt file in " - "the docs directory for information on configuring %2$s."), - emulator_info::get_configname(), - emulator_info::get_appname()); - item_append(txt, FLAG_MULTILINE | FLAG_REDTEXT, nullptr); - return; - } + m_nomatch = !matchcount; // otherwise, rebuild the match list - assert(m_drivlist != nullptr); - if (!m_search.empty() || m_matchlist[0] == -1 || m_rerandomize) - m_drivlist->find_approximate_matches(m_search, matchcount, m_matchlist); - m_rerandomize = false; - - // iterate over entries - for (curitem = 0; curitem < matchcount; curitem++) + if (matchcount) { - int curmatch = m_matchlist[curitem]; - if (curmatch != -1) + assert(m_drivlist != nullptr); + if (!m_search.empty() || m_matchlist[0] == -1 || m_rerandomize) + m_drivlist->find_approximate_matches(m_search, matchcount, m_matchlist); + m_rerandomize = false; + + // iterate over entries + for (curitem = 0; curitem < matchcount; curitem++) { - int cloneof = m_drivlist->non_bios_clone(curmatch); - item_append( - m_drivlist->driver(curmatch).type.fullname(), - m_drivlist->driver(curmatch).name, - (cloneof == -1) ? 0 : FLAG_INVERT, - (void *)&m_drivlist->driver(curmatch)); + int curmatch = m_matchlist[curitem]; + if (curmatch != -1) + { + int cloneof = m_drivlist->non_bios_clone(curmatch); + item_append( + m_drivlist->driver(curmatch).type.fullname(), + m_drivlist->driver(curmatch).name, + (cloneof == -1) ? 0 : FLAG_INVERT, + (void *)&m_drivlist->driver(curmatch)); + } } + item_append(menu_item_type::SEPARATOR); } // if we're forced into this, allow general input configuration as well if (stack_has_special_main_menu()) { - item_append(menu_item_type::SEPARATOR); item_append(_("Configure Options"), 0, (void *)1); item_append(_("Exit"), 0, nullptr); } else { - item_append(menu_item_type::SEPARATOR); item_append(_("Return to Previous Menu"), 0, nullptr); } @@ -301,6 +290,23 @@ void simple_menu_select_game::populate(float &customtop, float &custombottom) void simple_menu_select_game::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { + // if no matches, display the error message + if (m_nomatch) + { + ui().draw_text_box( + container(), + string_format( + _("No machines found. Please check the rompath specified in the %1$s.ini file.\n\n" + "If this is your first time using %2$s, please see the config.txt file in " + "the docs directory for information on configuring %2$s."), + emulator_info::get_configname(), + emulator_info::get_appname()), + text_layout::text_justify::CENTER, + 0.5f, origy2 + ui().box_tb_border() + (0.5f * (bottom - ui().box_tb_border())), + UI_RED_COLOR); + return; + } + const game_driver *driver; std::string tempbuf[5]; @@ -328,7 +334,7 @@ void simple_menu_select_game::custom_render(void *selectedref, float top, float tempbuf[1] = string_format(_("%1$s, %2$-.100s"), driver->year, driver->manufacturer); // next line source path - tempbuf[2] = string_format(_("Driver: %1$-.100s"), core_filename_extract_base(driver->type.source())); + tempbuf[2] = string_format(_("Driver: %1$s"), core_filename_extract_base(driver->type.source())); // update cached values if selection changed if (driver != m_cached_driver) @@ -411,7 +417,7 @@ void simple_menu_select_game::force_game_select(mame_ui_manager &mui, render_con char *gamename = (char *)mui.machine().options().system_name(); // reset the menu stack - menu::stack_reset(mui.machine()); + menu::stack_reset(mui); // add the quit entry followed by the game select entry menu::stack_push_special_main<menu_quit_game>(mui, container); |