summaryrefslogtreecommitdiffstats
path: root/src/frontend/mame/ui/mainmenu.cpp
diff options
context:
space:
mode:
author Vas Crabb <cuavas@users.noreply.github.com>2021-10-31 12:31:16 +1100
committer GitHub <noreply@github.com>2021-10-31 12:31:16 +1100
commitd64ea5331b2312f81df464fb22dcef0191216d86 (patch)
treea3f3784371da401e6a675e5b6b9734b88281a08d /src/frontend/mame/ui/mainmenu.cpp
parentcfffc54b61cabc5ef9533396bf87324eb5eeb63e (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/mainmenu.cpp')
-rw-r--r--src/frontend/mame/ui/mainmenu.cpp49
1 files changed, 34 insertions, 15 deletions
diff --git a/src/frontend/mame/ui/mainmenu.cpp b/src/frontend/mame/ui/mainmenu.cpp
index a50c346a1fe..132902b8f81 100644
--- a/src/frontend/mame/ui/mainmenu.cpp
+++ b/src/frontend/mame/ui/mainmenu.cpp
@@ -84,7 +84,7 @@ enum : unsigned {
***************************************************************************/
/*-------------------------------------------------
- menu_main constructor - populate the main menu
+ menu_main constructor/destructor
-------------------------------------------------*/
menu_main::menu_main(mame_ui_manager &mui, render_container &container) : menu(mui, container)
@@ -92,9 +92,30 @@ menu_main::menu_main(mame_ui_manager &mui, render_container &container) : menu(m
set_needs_prev_menu_item(false);
}
+menu_main::~menu_main()
+{
+}
+
+
+/*-------------------------------------------------
+ menu_activated - handle coming to foreground
+-------------------------------------------------*/
+
+void menu_main::menu_activated()
+{
+ if (machine().phase() != m_phase)
+ reset(reset_options::REMEMBER_REF);
+}
+
+
+/*-------------------------------------------------
+ populate - populate main menu items
+-------------------------------------------------*/
+
void menu_main::populate(float &customtop, float &custombottom)
{
- /* add main menu items */
+ m_phase = machine().phase();
+
item_append(_("Input (general)"), 0, (void *)INPUT_GROUPS);
item_append(_("Input (this Machine)"), 0, (void *)INPUT_SPECIFIC);
@@ -156,7 +177,7 @@ void menu_main::populate(float &customtop, float &custombottom)
if (machine().options().cheat())
item_append(_("Cheat"), 0, (void *)CHEAT);
- if (machine().phase() >= machine_phase::RESET)
+ if (machine_phase::RESET <= m_phase)
{
if (machine().options().plugins() && !mame_machine_manager::instance()->lua()->get_menu().empty())
item_append(_("Plugin Options"), 0, (void *)PLUGINS);
@@ -180,7 +201,7 @@ void menu_main::populate(float &customtop, float &custombottom)
// item_append(_("Quit from Machine"), 0, (void *)QUIT_GAME);
- if (machine().phase() == machine_phase::INIT)
+ if (machine_phase::INIT == m_phase)
{
item_append(_("Start Machine"), 0, (void *)DISMISS);
}
@@ -191,20 +212,18 @@ void menu_main::populate(float &customtop, float &custombottom)
}
}
-menu_main::~menu_main()
-{
-}
/*-------------------------------------------------
- menu_main - handle the main menu
+ handle - handle main menu events
-------------------------------------------------*/
-void menu_main::handle()
+void menu_main::handle(event const *ev)
{
- /* process the menu */
- const event *menu_event = process(0);
- if (menu_event != nullptr && menu_event->iptkey == IPT_UI_SELECT) {
- switch(uintptr_t(menu_event->itemref)) {
+ // process the menu
+ if (ev && (ev->iptkey == IPT_UI_SELECT))
+ {
+ switch (uintptr_t(ev->itemref))
+ {
case INPUT_GROUPS:
menu::stack_push<menu_input_groups>(ui(), container());
break;
@@ -314,12 +333,12 @@ void menu_main::handle()
case ADD_FAVORITE:
mame_machine_manager::instance()->favorite().add_favorite(machine());
- reset(reset_options::REMEMBER_POSITION);
+ reset(reset_options::REMEMBER_REF);
break;
case REMOVE_FAVORITE:
mame_machine_manager::instance()->favorite().remove_favorite(machine());
- reset(reset_options::REMEMBER_POSITION);
+ reset(reset_options::REMEMBER_REF);
break;
case QUIT_GAME: