diff --git a/src/frontend/mame/cheat.cpp b/src/frontend/mame/cheat.cpp index 32dc85df1b6..f3005ab33e9 100644 --- a/src/frontend/mame/cheat.cpp +++ b/src/frontend/mame/cheat.cpp @@ -956,7 +956,7 @@ void cheat_entry::menu_text(std::string &description, std::string &state, UINT32 if (description.empty()) description.assign(MENU_SEPARATOR_ITEM); } - flags = MENU_FLAG_DISABLE; + flags = ui::menu::FLAG_DISABLE; } // if we have no parameter and no run or off script, it's a oneshot cheat @@ -967,7 +967,7 @@ void cheat_entry::menu_text(std::string &description, std::string &state, UINT32 else if (is_onoff()) { state.assign((m_state == SCRIPT_STATE_RUN) ? "On" : "Off"); - flags = (m_state != 0) ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW; + flags = (m_state != 0) ? ui::menu::FLAG_LEFT_ARROW : ui::menu::FLAG_RIGHT_ARROW; } // if we have a value parameter, compute it @@ -976,14 +976,14 @@ void cheat_entry::menu_text(std::string &description, std::string &state, UINT32 if (m_state == SCRIPT_STATE_OFF) { state.assign(is_oneshot_parameter() ? "Set" : "Off"); - flags = MENU_FLAG_RIGHT_ARROW; + flags = ui::menu::FLAG_RIGHT_ARROW; } else { state.assign(m_parameter->text()); - flags = MENU_FLAG_LEFT_ARROW; + flags = ui::menu::FLAG_LEFT_ARROW; if (!m_parameter->is_maximum()) - flags |= MENU_FLAG_RIGHT_ARROW; + flags |= ui::menu::FLAG_RIGHT_ARROW; } } } diff --git a/src/frontend/mame/mame.cpp b/src/frontend/mame/mame.cpp index 5bbd7d15a02..c4487609ed3 100644 --- a/src/frontend/mame/mame.cpp +++ b/src/frontend/mame/mame.cpp @@ -314,9 +314,9 @@ void emulator_info::display_ui_chooser(running_machine& machine) mame_ui_manager &mui = mame_machine_manager::instance()->ui(); render_container *container = &machine.render().ui_container(); if (strcmp(machine.options().ui(), "simple") == 0) - ui_simple_menu_select_game::force_game_select(mui, container); + ui::simple_menu_select_game::force_game_select(mui, container); else - ui_menu_select_game::force_game_select(mui, container); + ui::menu_select_game::force_game_select(mui, container); } int emulator_info::start_frontend(emu_options &options, osd_interface &osd, int argc, char *argv[]) diff --git a/src/frontend/mame/ui/auditmenu.cpp b/src/frontend/mame/ui/auditmenu.cpp index 3ced1d2fd3e..8c148c09c00 100644 --- a/src/frontend/mame/ui/auditmenu.cpp +++ b/src/frontend/mame/ui/auditmenu.cpp @@ -17,6 +17,8 @@ extern const char UI_VERSION_TAG[]; +namespace ui { + //------------------------------------------------- // sort //------------------------------------------------- @@ -84,8 +86,8 @@ bool sorted_game_list(const game_driver *x, const game_driver *y) // ctor / dtor //------------------------------------------------- -ui_menu_audit::ui_menu_audit(mame_ui_manager &mui, render_container *container, vptr_game &availablesorted, vptr_game &unavailablesorted, int _audit_mode) - : ui_menu(mui, container) +menu_audit::menu_audit(mame_ui_manager &mui, render_container *container, vptr_game &availablesorted, vptr_game &unavailablesorted, int _audit_mode) + : menu(mui, container) , m_availablesorted(availablesorted) , m_unavailablesorted(unavailablesorted) , m_audit_mode(_audit_mode) @@ -98,7 +100,7 @@ ui_menu_audit::ui_menu_audit(mame_ui_manager &mui, render_container *container, } } -ui_menu_audit::~ui_menu_audit() +menu_audit::~menu_audit() { } @@ -106,9 +108,9 @@ ui_menu_audit::~ui_menu_audit() // handle //------------------------------------------------- -void ui_menu_audit::handle() +void menu_audit::handle() { - process(UI_MENU_PROCESS_CUSTOM_ONLY); + process(PROCESS_CUSTOM_ONLY); if (m_first) { @@ -157,15 +159,15 @@ void ui_menu_audit::handle() std::stable_sort(m_availablesorted.begin(), m_availablesorted.end(), sorted_game_list); std::stable_sort(m_unavailablesorted.begin(), m_unavailablesorted.end(), sorted_game_list); save_available_machines(); - ui_menu::menu_stack->parent->reset(UI_MENU_RESET_SELECT_FIRST); - ui_menu::stack_pop(machine()); + reset_parent(reset_options::SELECT_FIRST); + menu::stack_pop(machine()); } //------------------------------------------------- // populate //------------------------------------------------- -void ui_menu_audit::populate() +void menu_audit::populate() { item_append("Dummy", nullptr, 0, (void *)(FPTR)1); } @@ -174,7 +176,7 @@ void ui_menu_audit::populate() // save drivers infos to file //------------------------------------------------- -void ui_menu_audit::save_available_machines() +void menu_audit::save_available_machines() { // attempt to open the output file emu_file file(ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); @@ -203,3 +205,5 @@ void ui_menu_audit::save_available_machines() file.close(); } } + +} // namespace ui diff --git a/src/frontend/mame/ui/auditmenu.h b/src/frontend/mame/ui/auditmenu.h index 6d7b6a9cbcd..957fc79ae00 100644 --- a/src/frontend/mame/ui/auditmenu.h +++ b/src/frontend/mame/ui/auditmenu.h @@ -10,19 +10,23 @@ #pragma once -#ifndef __UI_AUDIT_H__ -#define __UI_AUDIT_H__ +#ifndef MAME_FRONTEND_UI_AUDITMENU_H +#define MAME_FRONTEND_UI_AUDITMENU_H + +#include "ui/menu.h" + +namespace ui { //------------------------------------------------- // class audit menu //------------------------------------------------- using vptr_game = std::vector; -class ui_menu_audit : public ui_menu +class menu_audit : public menu { public: - ui_menu_audit(mame_ui_manager &mui, render_container *container, vptr_game &availablesorted, vptr_game &unavailablesorted, int audit_mode); - virtual ~ui_menu_audit(); + menu_audit(mame_ui_manager &mui, render_container *container, vptr_game &availablesorted, vptr_game &unavailablesorted, int audit_mode); + virtual ~menu_audit() override; virtual void populate() override; virtual void handle() override; @@ -35,7 +39,8 @@ private: bool m_first; }; -inline int cs_stricmp(const char *s1, const char *s2); bool sorted_game_list(const game_driver *x, const game_driver *y); -#endif /* __UI_AUDIT_H__ */ +} // namespace ui + +#endif /* MAME_FRONTEND_UI_AUDITMENU_H */ diff --git a/src/frontend/mame/ui/barcode.cpp b/src/frontend/mame/ui/barcode.cpp index 449341755d7..fc6b6b0da64 100644 --- a/src/frontend/mame/ui/barcode.cpp +++ b/src/frontend/mame/ui/barcode.cpp @@ -9,9 +9,11 @@ ***************************************************************************/ #include "emu.h" -#include "ui/ui.h" -#include "ui/menu.h" + #include "ui/barcode.h" +#include "ui/ui.h" + +namespace ui { // itemrefs for key menu items #define ITEMREF_NEW_BARCODE ((void *) 0x0001) @@ -30,8 +32,8 @@ // ctor //------------------------------------------------- -ui_menu_barcode_reader::ui_menu_barcode_reader(mame_ui_manager &mui, render_container *container, barcode_reader_device *device) - : ui_menu_device_control(mui, container, device) +menu_barcode_reader::menu_barcode_reader(mame_ui_manager &mui, render_container *container, barcode_reader_device *device) + : menu_device_control(mui, container, device) { } @@ -40,7 +42,7 @@ ui_menu_barcode_reader::ui_menu_barcode_reader(mame_ui_manager &mui, render_cont // dtor //------------------------------------------------- -ui_menu_barcode_reader::~ui_menu_barcode_reader() +menu_barcode_reader::~menu_barcode_reader() { } @@ -48,7 +50,7 @@ ui_menu_barcode_reader::~ui_menu_barcode_reader() // populate - populates the barcode input menu //------------------------------------------------- -void ui_menu_barcode_reader::populate() +void menu_barcode_reader::populate() { if (current_device()) { @@ -72,7 +74,7 @@ void ui_menu_barcode_reader::populate() item_append(_("New Barcode:"), new_barcode, 0, ITEMREF_NEW_BARCODE); // finish up the menu - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); item_append(_("Enter Code"), nullptr, 0, ITEMREF_ENTER_BARCODE); customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; @@ -84,14 +86,14 @@ void ui_menu_barcode_reader::populate() // handle - manages inputs in the barcode input menu //------------------------------------------------- -void ui_menu_barcode_reader::handle() +void menu_barcode_reader::handle() { // rebuild the menu (so to update the selected device, if the user has pressed L or R) - reset(UI_MENU_RESET_REMEMBER_POSITION); + reset(reset_options::REMEMBER_POSITION); populate(); // process the menu - const ui_menu_event *event = process(UI_MENU_PROCESS_LR_REPEAT); + const event *event = process(PROCESS_LR_REPEAT); // process the event if (event != nullptr) @@ -99,56 +101,58 @@ void ui_menu_barcode_reader::handle() // handle selections switch (event->iptkey) { - case IPT_UI_LEFT: - if (event->itemref == ITEMREF_SELECT_READER) - previous(); - break; + case IPT_UI_LEFT: + if (event->itemref == ITEMREF_SELECT_READER) + previous(); + break; - case IPT_UI_RIGHT: - if (event->itemref == ITEMREF_SELECT_READER) - next(); - break; + case IPT_UI_RIGHT: + if (event->itemref == ITEMREF_SELECT_READER) + next(); + break; - case IPT_UI_SELECT: - if (event->itemref == ITEMREF_ENTER_BARCODE) + case IPT_UI_SELECT: + if (event->itemref == ITEMREF_ENTER_BARCODE) + { + std::string tmp_file(m_barcode_buffer); + //printf("code %s\n", m_barcode_buffer); + if (!current_device()->is_valid(tmp_file.length())) + ui().popup_time(5, "%s", _("Barcode length invalid!")); + else { - std::string tmp_file(m_barcode_buffer); - //printf("code %s\n", m_barcode_buffer); - if (!current_device()->is_valid(tmp_file.length())) - ui().popup_time(5, "%s", _("Barcode length invalid!")); - else - { - current_device()->write_code(tmp_file.c_str(), tmp_file.length()); - // if sending was successful, reset char buffer - if (m_barcode_buffer[0] != '\0') - memset(m_barcode_buffer, '\0', ARRAY_LENGTH(m_barcode_buffer)); - reset(UI_MENU_RESET_REMEMBER_POSITION); - } + current_device()->write_code(tmp_file.c_str(), tmp_file.length()); + // if sending was successful, reset char buffer + if (m_barcode_buffer[0] != '\0') + memset(m_barcode_buffer, '\0', ARRAY_LENGTH(m_barcode_buffer)); + reset(reset_options::REMEMBER_POSITION); } - break; + } + break; - case IPT_SPECIAL: - if (get_selection() == ITEMREF_NEW_BARCODE) + case IPT_SPECIAL: + if (get_selection() == ITEMREF_NEW_BARCODE) + { + int buflen = strlen(m_barcode_buffer); + + // if it's a backspace and we can handle it, do so + if ((event->unichar == 8 || event->unichar == 0x7f) && buflen > 0) + *(char *)utf8_previous_char(&m_barcode_buffer[buflen]) = 0; + else if (event->unichar >= '0' && event->unichar <= '9') { - int buflen = strlen(m_barcode_buffer); - - // if it's a backspace and we can handle it, do so - if ((event->unichar == 8 || event->unichar == 0x7f) && buflen > 0) - *(char *)utf8_previous_char(&m_barcode_buffer[buflen]) = 0; - else if (event->unichar >= '0' && event->unichar <= '9') - { - buflen += utf8_from_uchar(&m_barcode_buffer[buflen], ARRAY_LENGTH(m_barcode_buffer) - buflen, event->unichar); - m_barcode_buffer[buflen] = 0; - } - reset(UI_MENU_RESET_REMEMBER_POSITION); + buflen += utf8_from_uchar(&m_barcode_buffer[buflen], ARRAY_LENGTH(m_barcode_buffer) - buflen, event->unichar); + m_barcode_buffer[buflen] = 0; } - break; + reset(reset_options::REMEMBER_POSITION); + } + break; - case IPT_UI_CANCEL: - // reset the char buffer also in this case - if (m_barcode_buffer[0] != '\0') - memset(m_barcode_buffer, '\0', ARRAY_LENGTH(m_barcode_buffer)); - break; + case IPT_UI_CANCEL: + // reset the char buffer also in this case + if (m_barcode_buffer[0] != '\0') + memset(m_barcode_buffer, '\0', ARRAY_LENGTH(m_barcode_buffer)); + break; } } } + +} // namespace ui \ No newline at end of file diff --git a/src/frontend/mame/ui/barcode.h b/src/frontend/mame/ui/barcode.h index f0f584e8cce..5e42e64ce65 100644 --- a/src/frontend/mame/ui/barcode.h +++ b/src/frontend/mame/ui/barcode.h @@ -10,16 +10,18 @@ #pragma once -#ifndef __UI_BARCODE_H__ -#define __UI_BARCODE_H__ +#ifndef MAME_FRONTEND_UI_BARCODE_H +#define MAME_FRONTEND_UI_BARCODE_H #include "machine/bcreader.h" #include "ui/devctrl.h" -class ui_menu_barcode_reader : public ui_menu_device_control { +namespace ui { + +class menu_barcode_reader : public menu_device_control { public: - ui_menu_barcode_reader(mame_ui_manager &mui, render_container *container, barcode_reader_device *device); - virtual ~ui_menu_barcode_reader(); + menu_barcode_reader(mame_ui_manager &mui, render_container *container, barcode_reader_device *device); + virtual ~menu_barcode_reader() override; virtual void populate() override; virtual void handle() override; @@ -27,5 +29,6 @@ private: char m_barcode_buffer[20]; }; +} // namespace ui -#endif // __UI_BARCODE_H__ +#endif // MAME_FRONTEND_UI_BARCODE_H diff --git a/src/frontend/mame/ui/cheatopt.cpp b/src/frontend/mame/ui/cheatopt.cpp index 87b748fb3cc..34a4f253c6d 100644 --- a/src/frontend/mame/ui/cheatopt.cpp +++ b/src/frontend/mame/ui/cheatopt.cpp @@ -16,14 +16,29 @@ #include "ui/menu.h" #include "ui/cheatopt.h" + +namespace ui { + +// itemrefs for key menu items +#define ITEMREF_CHEATS_RESET_ALL ((void *) 0x0001) +#define ITEMREF_CHEATS_RELOAD_ALL ((void *) 0x0002) +#define ITEMREF_CHEATS_AUTOFIRE_SETTINGS ((void *) 0x0003) +#define ITEMREF_CHEATS_FIRST_ITEM ((void *) 0x0004) + +// itemrefs for key menu items +#define ITEMREF_AUTOFIRE_STATUS ((void *) 0x0001) +#define ITEMREF_AUTOFIRE_DELAY ((void *) 0x0002) +#define ITEMREF_AUTOFIRE_FIRST_BUTTON ((void *) 0x0003) + + /*------------------------------------------------- menu_cheat - handle the cheat menu -------------------------------------------------*/ -void ui_menu_cheat::handle() +void menu_cheat::handle() { /* process the menu */ - const ui_menu_event *menu_event = process(UI_MENU_PROCESS_LR_REPEAT); + const event *menu_event = process(PROCESS_LR_REPEAT); /* handle events */ @@ -87,19 +102,19 @@ void ui_menu_cheat::handle() mame_machine_manager::instance()->cheat().reload(); /* display the reloaded cheats */ - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); machine().popmessage(_("All cheats reloaded")); } /* handle autofire menu */ if (menu_event->itemref == ITEMREF_CHEATS_AUTOFIRE_SETTINGS && menu_event->iptkey == IPT_UI_SELECT) { - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); } /* if things changed, update */ if (changed) - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); } } @@ -108,11 +123,11 @@ void ui_menu_cheat::handle() menu_cheat_populate - populate the cheat menu -------------------------------------------------*/ -ui_menu_cheat::ui_menu_cheat(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container) +menu_cheat::menu_cheat(mame_ui_manager &mui, render_container *container) : menu(mui, container) { } -void ui_menu_cheat::populate() +void menu_cheat::populate() { /* iterate over cheats */ std::string text; @@ -122,7 +137,7 @@ void ui_menu_cheat::populate() item_append(_("Autofire Settings"), nullptr, 0, (void *)ITEMREF_CHEATS_AUTOFIRE_SETTINGS); /* add a separator */ - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); // add other cheats if (!mame_machine_manager::instance()->cheat().entries().empty()) { @@ -134,7 +149,7 @@ void ui_menu_cheat::populate() } /* add a separator */ - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); /* add a reset all option */ item_append(_("Reset All"), nullptr, 0, (void *)ITEMREF_CHEATS_RESET_ALL); @@ -144,7 +159,7 @@ void ui_menu_cheat::populate() } } -ui_menu_cheat::~ui_menu_cheat() +menu_cheat::~menu_cheat() { } @@ -157,7 +172,7 @@ ui_menu_cheat::~ui_menu_cheat() menu -------------------------------------------------*/ -ui_menu_autofire::ui_menu_autofire(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container), last_toggle(false) +menu_autofire::menu_autofire(mame_ui_manager &mui, render_container *container) : menu(mui, container), last_toggle(false) { const screen_device *screen = mui.machine().first_screen(); @@ -171,17 +186,17 @@ ui_menu_autofire::ui_menu_autofire(mame_ui_manager &mui, render_container *conta } } -ui_menu_autofire::~ui_menu_autofire() +menu_autofire::~menu_autofire() { } -void ui_menu_autofire::handle() +void menu_autofire::handle() { ioport_field *field; bool changed = false; /* process the menu */ - const ui_menu_event *menu_event = process(0); + const event *menu_event = process(0); /* handle events */ if (menu_event != nullptr && menu_event->itemref != nullptr) @@ -237,7 +252,7 @@ void ui_menu_autofire::handle() /* if something changed, rebuild the menu */ if (changed) { - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); } } @@ -247,14 +262,14 @@ void ui_menu_autofire::handle() menu -------------------------------------------------*/ -void ui_menu_autofire::populate() +void menu_autofire::populate() { char temp_text[64]; /* add autofire toggle item */ bool autofire_toggle = machine().ioport().get_autofire_toggle(); item_append(_("Autofire Status"), (autofire_toggle ? _("Disabled") : _("Enabled")), - (autofire_toggle ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW), (void *)ITEMREF_AUTOFIRE_STATUS); + (autofire_toggle ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW), (void *)ITEMREF_AUTOFIRE_STATUS); /* iterate over the input ports and add autofire toggle items */ int menu_items = 0; @@ -272,7 +287,7 @@ void ui_menu_autofire::populate() if (is_first_button) { /* add a separator for each player */ - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); is_first_button = false; } /* add an autofire item */ @@ -280,13 +295,13 @@ void ui_menu_autofire::populate() { // item is enabled and can be switched to values on/off item_append(field.name(), (settings.autofire ? _("On") : _("Off")), - (settings.autofire ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW), (void *)&field); + (settings.autofire ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW), (void *)&field); } else { // item is disabled item_append(field.name(), (settings.autofire ? _("On") : _("Off")), - MENU_FLAG_DISABLE | MENU_FLAG_INVERT, nullptr); + FLAG_DISABLE | FLAG_INVERT, nullptr); } } } @@ -295,27 +310,29 @@ void ui_menu_autofire::populate() /* add text item if no buttons found */ if (menu_items==0) { - item_append(ui_menu_item_type::SEPARATOR); - item_append(_("No buttons found on this machine!"), nullptr, MENU_FLAG_DISABLE, nullptr); + item_append(menu_item_type::SEPARATOR); + item_append(_("No buttons found on this machine!"), nullptr, FLAG_DISABLE, nullptr); } /* add a separator */ - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); /* add autofire delay item */ int value = machine().ioport().get_autofire_delay(); snprintf(temp_text, ARRAY_LENGTH(temp_text), "%d = %.2f Hz", value, (float)refresh/value); if (!autofire_toggle) { - item_append(_("Autofire Delay"), temp_text, MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)ITEMREF_AUTOFIRE_DELAY); + item_append(_("Autofire Delay"), temp_text, FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, (void *)ITEMREF_AUTOFIRE_DELAY); } else { - item_append(_("Autofire Delay"), temp_text, MENU_FLAG_DISABLE | MENU_FLAG_INVERT, nullptr); + item_append(_("Autofire Delay"), temp_text, FLAG_DISABLE | FLAG_INVERT, nullptr); } /* add a separator */ - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); last_toggle = autofire_toggle; } + +} // namespace ui diff --git a/src/frontend/mame/ui/cheatopt.h b/src/frontend/mame/ui/cheatopt.h index 3087dc6217d..1bad6fbab9c 100644 --- a/src/frontend/mame/ui/cheatopt.h +++ b/src/frontend/mame/ui/cheatopt.h @@ -10,33 +10,28 @@ #pragma once -#ifndef __UI_CHEATOPT_H__ -#define __UI_CHEATOPT_H__ +#ifndef MAME_FRONTEND_UI_CHEATOPT_H +#define MAME_FRONTEND_UI_CHEATOPT_H -// itemrefs for key menu items -#define ITEMREF_CHEATS_RESET_ALL ((void *) 0x0001) -#define ITEMREF_CHEATS_RELOAD_ALL ((void *) 0x0002) -#define ITEMREF_CHEATS_AUTOFIRE_SETTINGS ((void *) 0x0003) -#define ITEMREF_CHEATS_FIRST_ITEM ((void *) 0x0004) +#include "ui/menu.h" -class ui_menu_cheat : public ui_menu { +namespace ui { + +class menu_cheat : public menu +{ public: - ui_menu_cheat(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_cheat(); + menu_cheat(mame_ui_manager &mui, render_container *container); + virtual ~menu_cheat() override; virtual void populate() override; virtual void handle() override; }; -// itemrefs for key menu items -#define ITEMREF_AUTOFIRE_STATUS ((void *) 0x0001) -#define ITEMREF_AUTOFIRE_DELAY ((void *) 0x0002) -#define ITEMREF_AUTOFIRE_FIRST_BUTTON ((void *) 0x0003) - -class ui_menu_autofire : public ui_menu { +class menu_autofire : public menu +{ public: - ui_menu_autofire(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_autofire(); + menu_autofire(mame_ui_manager &mui, render_container *container); + virtual ~menu_autofire() override; virtual void populate() override; virtual void handle() override; @@ -45,5 +40,6 @@ private: bool last_toggle; }; +} // namespace ui -#endif /* __UI_CHEATOPT_H__ */ +#endif /* MAME_FRONTEND_UI_CHEATOPT_H */ diff --git a/src/frontend/mame/ui/custmenu.cpp b/src/frontend/mame/ui/custmenu.cpp index d44206ef6c8..62a12d3ac99 100644 --- a/src/frontend/mame/ui/custmenu.cpp +++ b/src/frontend/mame/ui/custmenu.cpp @@ -10,56 +10,59 @@ #include "emu.h" #include "ui/ui.h" -#include "ui/menu.h" #include "ui/custmenu.h" #include "ui/selector.h" #include "ui/inifile.h" + #include "rendfont.h" + +namespace ui { + /************************************************** MENU CUSTOM FILTER **************************************************/ //------------------------------------------------- // ctor / dtor //------------------------------------------------- -ui_menu_custom_filter::ui_menu_custom_filter(mame_ui_manager &mui, render_container *container, bool _single_menu) - : ui_menu(mui, container) +menu_custom_filter::menu_custom_filter(mame_ui_manager &mui, render_container *container, bool _single_menu) + : menu(mui, container) , m_single_menu(_single_menu) , m_added(false) { } -ui_menu_custom_filter::~ui_menu_custom_filter() +menu_custom_filter::~menu_custom_filter() { if (m_single_menu) - ui_menu::menu_stack->reset(UI_MENU_RESET_SELECT_FIRST); + reset_topmost(reset_options::SELECT_FIRST); save_custom_filters(); } //------------------------------------------------- // handle //------------------------------------------------- -void ui_menu_custom_filter::handle() +void menu_custom_filter::handle() { bool changed = false; m_added = false; // process the menu - const ui_menu_event *m_event = process(UI_MENU_PROCESS_LR_REPEAT); - if (m_event != nullptr && m_event->itemref != nullptr) + const event *menu_event = process(PROCESS_LR_REPEAT); + if (menu_event != nullptr && menu_event->itemref != nullptr) { - switch ((FPTR)m_event->itemref) + switch ((FPTR)menu_event->itemref) { case MAIN_FILTER: - if (m_event->iptkey == IPT_UI_LEFT || m_event->iptkey == IPT_UI_RIGHT) + if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) { - (m_event->iptkey == IPT_UI_RIGHT) ? custfltr::main++ : custfltr::main--; + (menu_event->iptkey == IPT_UI_RIGHT) ? custfltr::main++ : custfltr::main--; changed = true; } break; case ADD_FILTER: - if (m_event->iptkey == IPT_UI_SELECT) + if (menu_event->iptkey == IPT_UI_SELECT) { custfltr::numother++; custfltr::other[custfltr::numother] = FILTER_UNAVAILABLE + 1; @@ -68,7 +71,7 @@ void ui_menu_custom_filter::handle() break; case REMOVE_FILTER: - if (m_event->iptkey == IPT_UI_SELECT) + if (menu_event->iptkey == IPT_UI_SELECT) { custfltr::other[custfltr::numother] = FILTER_UNAVAILABLE + 1; custfltr::numother--; @@ -77,24 +80,24 @@ void ui_menu_custom_filter::handle() break; } - if ((FPTR)m_event->itemref >= OTHER_FILTER && (FPTR)m_event->itemref < OTHER_FILTER + MAX_CUST_FILTER) + if ((FPTR)menu_event->itemref >= OTHER_FILTER && (FPTR)menu_event->itemref < OTHER_FILTER + MAX_CUST_FILTER) { - int pos = (int)((FPTR)m_event->itemref - OTHER_FILTER); - if (m_event->iptkey == IPT_UI_LEFT && custfltr::other[pos] > FILTER_UNAVAILABLE + 1) + int pos = (int)((FPTR)menu_event->itemref - OTHER_FILTER); + if (menu_event->iptkey == IPT_UI_LEFT && custfltr::other[pos] > FILTER_UNAVAILABLE + 1) { custfltr::other[pos]--; for ( ; custfltr::other[pos] > FILTER_UNAVAILABLE && (custfltr::other[pos] == FILTER_CATEGORY || custfltr::other[pos] == FILTER_FAVORITE); custfltr::other[pos]--) { }; changed = true; } - else if (m_event->iptkey == IPT_UI_RIGHT && custfltr::other[pos] < FILTER_LAST - 1) + else if (menu_event->iptkey == IPT_UI_RIGHT && custfltr::other[pos] < FILTER_LAST - 1) { custfltr::other[pos]++; for ( ; custfltr::other[pos] < FILTER_LAST && (custfltr::other[pos] == FILTER_CATEGORY || custfltr::other[pos] == FILTER_FAVORITE); custfltr::other[pos]++) { }; changed = true; } - else if (m_event->iptkey == IPT_UI_SELECT) + else if (menu_event->iptkey == IPT_UI_SELECT) { size_t total = main_filters::length; std::vector s_sel(total); @@ -104,53 +107,53 @@ void ui_menu_custom_filter::handle() else s_sel[index] = main_filters::text[index]; - ui_menu::stack_push(global_alloc_clear(ui(), container, s_sel, custfltr::other[pos])); + menu::stack_push(ui(), container, s_sel, custfltr::other[pos]); } } - else if ((FPTR)m_event->itemref >= YEAR_FILTER && (FPTR)m_event->itemref < YEAR_FILTER + MAX_CUST_FILTER) + else if ((FPTR)menu_event->itemref >= YEAR_FILTER && (FPTR)menu_event->itemref < YEAR_FILTER + MAX_CUST_FILTER) { - int pos = (int)((FPTR)m_event->itemref - YEAR_FILTER); - if (m_event->iptkey == IPT_UI_LEFT && custfltr::year[pos] > 0) + int pos = (int)((FPTR)menu_event->itemref - YEAR_FILTER); + if (menu_event->iptkey == IPT_UI_LEFT && custfltr::year[pos] > 0) { custfltr::year[pos]--; changed = true; } - else if (m_event->iptkey == IPT_UI_RIGHT && custfltr::year[pos] < c_year::ui.size() - 1) + else if (menu_event->iptkey == IPT_UI_RIGHT && custfltr::year[pos] < c_year::ui.size() - 1) { custfltr::year[pos]++; changed = true; } - else if (m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container, c_year::ui, custfltr::year[pos])); + else if (menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container, c_year::ui, custfltr::year[pos]); } - else if ((FPTR)m_event->itemref >= MNFCT_FILTER && (FPTR)m_event->itemref < MNFCT_FILTER + MAX_CUST_FILTER) + else if ((FPTR)menu_event->itemref >= MNFCT_FILTER && (FPTR)menu_event->itemref < MNFCT_FILTER + MAX_CUST_FILTER) { - int pos = (int)((FPTR)m_event->itemref - MNFCT_FILTER); - if (m_event->iptkey == IPT_UI_LEFT && custfltr::mnfct[pos] > 0) + int pos = (int)((FPTR)menu_event->itemref - MNFCT_FILTER); + if (menu_event->iptkey == IPT_UI_LEFT && custfltr::mnfct[pos] > 0) { custfltr::mnfct[pos]--; changed = true; } - else if (m_event->iptkey == IPT_UI_RIGHT && custfltr::mnfct[pos] < c_mnfct::ui.size() - 1) + else if (menu_event->iptkey == IPT_UI_RIGHT && custfltr::mnfct[pos] < c_mnfct::ui.size() - 1) { custfltr::mnfct[pos]++; changed = true; } - else if (m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container, c_mnfct::ui, custfltr::mnfct[pos])); + else if (menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container, c_mnfct::ui, custfltr::mnfct[pos]); } } if (changed) - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); else if (m_added) - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); } //------------------------------------------------- // populate //------------------------------------------------- -void ui_menu_custom_filter::populate() +void menu_custom_filter::populate() { // add main filter UINT32 arrow_flags = get_arrow_flags((int)FILTER_ALL, (int)FILTER_UNAVAILABLE, custfltr::main); @@ -159,7 +162,7 @@ void ui_menu_custom_filter::populate() // add other filters for (int x = 1; x <= custfltr::numother; x++) { - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); // add filter items arrow_flags = get_arrow_flags((int)FILTER_UNAVAILABLE + 1, (int)FILTER_LAST - 1, custfltr::other[x]); @@ -187,7 +190,7 @@ void ui_menu_custom_filter::populate() } } - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); if (custfltr::numother > 0) item_append(_("Remove last filter"), nullptr, 0, (void *)(FPTR)REMOVE_FILTER); @@ -195,14 +198,14 @@ void ui_menu_custom_filter::populate() if (custfltr::numother < MAX_CUST_FILTER - 2) item_append(_("Add filter"), nullptr, 0, (void *)(FPTR)ADD_FILTER); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } //------------------------------------------------- // perform our special rendering //------------------------------------------------- -void ui_menu_custom_filter::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_custom_filter::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float width; @@ -235,7 +238,7 @@ void ui_menu_custom_filter::custom_render(void *selectedref, float top, float bo // save custom filters info to file //------------------------------------------------- -void ui_menu_custom_filter::save_custom_filters() +void menu_custom_filter::save_custom_filters() { // attempt to open the output file emu_file file(ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); @@ -265,44 +268,44 @@ void ui_menu_custom_filter::save_custom_filters() //------------------------------------------------- // ctor / dtor //------------------------------------------------- -ui_menu_swcustom_filter::ui_menu_swcustom_filter(mame_ui_manager &mui, render_container *container, const game_driver *_driver, s_filter &_filter) : - ui_menu(mui, container) +menu_swcustom_filter::menu_swcustom_filter(mame_ui_manager &mui, render_container *container, const game_driver *_driver, s_filter &_filter) + : menu(mui, container) , m_added(false) , m_filter(_filter) , m_driver(_driver) { } -ui_menu_swcustom_filter::~ui_menu_swcustom_filter() +menu_swcustom_filter::~menu_swcustom_filter() { - ui_menu::menu_stack->reset(UI_MENU_RESET_SELECT_FIRST); + reset_topmost(reset_options::SELECT_FIRST); save_sw_custom_filters(); } //------------------------------------------------- // handle //------------------------------------------------- -void ui_menu_swcustom_filter::handle() +void menu_swcustom_filter::handle() { bool changed = false; m_added = false; // process the menu - const ui_menu_event *m_event = process(UI_MENU_PROCESS_LR_REPEAT); - if (m_event != nullptr && m_event->itemref != nullptr) + const event *menu_event = process(PROCESS_LR_REPEAT); + if (menu_event != nullptr && menu_event->itemref != nullptr) { - switch ((FPTR)m_event->itemref) + switch ((FPTR)menu_event->itemref) { case MAIN_FILTER: - if (m_event->iptkey == IPT_UI_LEFT || m_event->iptkey == IPT_UI_RIGHT) + if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) { - (m_event->iptkey == IPT_UI_RIGHT) ? sw_custfltr::main++ : sw_custfltr::main--; + (menu_event->iptkey == IPT_UI_RIGHT) ? sw_custfltr::main++ : sw_custfltr::main--; changed = true; } break; case ADD_FILTER: - if (m_event->iptkey == IPT_UI_SELECT) + if (menu_event->iptkey == IPT_UI_SELECT) { sw_custfltr::numother++; sw_custfltr::other[sw_custfltr::numother] = UI_SW_UNAVAILABLE + 1; @@ -311,7 +314,7 @@ void ui_menu_swcustom_filter::handle() break; case REMOVE_FILTER: - if (m_event->iptkey == IPT_UI_SELECT) + if (menu_event->iptkey == IPT_UI_SELECT) { sw_custfltr::other[sw_custfltr::numother] = UI_SW_UNAVAILABLE + 1; sw_custfltr::numother--; @@ -320,20 +323,20 @@ void ui_menu_swcustom_filter::handle() break; } - if ((FPTR)m_event->itemref >= OTHER_FILTER && (FPTR)m_event->itemref < OTHER_FILTER + MAX_CUST_FILTER) + if ((FPTR)menu_event->itemref >= OTHER_FILTER && (FPTR)menu_event->itemref < OTHER_FILTER + MAX_CUST_FILTER) { - int pos = (int)((FPTR)m_event->itemref - OTHER_FILTER); - if (m_event->iptkey == IPT_UI_LEFT && sw_custfltr::other[pos] > UI_SW_UNAVAILABLE + 1) + int pos = (int)((FPTR)menu_event->itemref - OTHER_FILTER); + if (menu_event->iptkey == IPT_UI_LEFT && sw_custfltr::other[pos] > UI_SW_UNAVAILABLE + 1) { sw_custfltr::other[pos]--; changed = true; } - else if (m_event->iptkey == IPT_UI_RIGHT && sw_custfltr::other[pos] < UI_SW_LAST - 1) + else if (menu_event->iptkey == IPT_UI_RIGHT && sw_custfltr::other[pos] < UI_SW_LAST - 1) { sw_custfltr::other[pos]++; changed = true; } - else if (m_event->iptkey == IPT_UI_SELECT) + else if (menu_event->iptkey == IPT_UI_SELECT) { size_t total = sw_filters::length; std::vector s_sel(total); @@ -343,101 +346,101 @@ void ui_menu_swcustom_filter::handle() else s_sel[index] = sw_filters::text[index]; - ui_menu::stack_push(global_alloc_clear(ui(), container, s_sel, sw_custfltr::other[pos])); + menu::stack_push(ui(), container, s_sel, sw_custfltr::other[pos]); } } - else if ((FPTR)m_event->itemref >= YEAR_FILTER && (FPTR)m_event->itemref < YEAR_FILTER + MAX_CUST_FILTER) + else if ((FPTR)menu_event->itemref >= YEAR_FILTER && (FPTR)menu_event->itemref < YEAR_FILTER + MAX_CUST_FILTER) { - int pos = (int)((FPTR)m_event->itemref - YEAR_FILTER); - if (m_event->iptkey == IPT_UI_LEFT && sw_custfltr::year[pos] > 0) + int pos = (int)((FPTR)menu_event->itemref - YEAR_FILTER); + if (menu_event->iptkey == IPT_UI_LEFT && sw_custfltr::year[pos] > 0) { sw_custfltr::year[pos]--; changed = true; } - else if (m_event->iptkey == IPT_UI_RIGHT && sw_custfltr::year[pos] < m_filter.year.ui.size() - 1) + else if (menu_event->iptkey == IPT_UI_RIGHT && sw_custfltr::year[pos] < m_filter.year.ui.size() - 1) { sw_custfltr::year[pos]++; changed = true; } - else if (m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container, m_filter.year.ui, sw_custfltr::year[pos])); + else if (menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container, m_filter.year.ui, sw_custfltr::year[pos]); } - else if ((FPTR)m_event->itemref >= TYPE_FILTER && (FPTR)m_event->itemref < TYPE_FILTER + MAX_CUST_FILTER) + else if ((FPTR)menu_event->itemref >= TYPE_FILTER && (FPTR)menu_event->itemref < TYPE_FILTER + MAX_CUST_FILTER) { - int pos = (int)((FPTR)m_event->itemref - TYPE_FILTER); - if (m_event->iptkey == IPT_UI_LEFT && sw_custfltr::type[pos] > 0) + int pos = (int)((FPTR)menu_event->itemref - TYPE_FILTER); + if (menu_event->iptkey == IPT_UI_LEFT && sw_custfltr::type[pos] > 0) { sw_custfltr::type[pos]--; changed = true; } - else if (m_event->iptkey == IPT_UI_RIGHT && sw_custfltr::type[pos] < m_filter.type.ui.size() - 1) + else if (menu_event->iptkey == IPT_UI_RIGHT && sw_custfltr::type[pos] < m_filter.type.ui.size() - 1) { sw_custfltr::type[pos]++; changed = true; } - else if (m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container, m_filter.type.ui, sw_custfltr::type[pos])); + else if (menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container, m_filter.type.ui, sw_custfltr::type[pos]); } - else if ((FPTR)m_event->itemref >= MNFCT_FILTER && (FPTR)m_event->itemref < MNFCT_FILTER + MAX_CUST_FILTER) + else if ((FPTR)menu_event->itemref >= MNFCT_FILTER && (FPTR)menu_event->itemref < MNFCT_FILTER + MAX_CUST_FILTER) { - int pos = (int)((FPTR)m_event->itemref - MNFCT_FILTER); - if (m_event->iptkey == IPT_UI_LEFT && sw_custfltr::mnfct[pos] > 0) + int pos = (int)((FPTR)menu_event->itemref - MNFCT_FILTER); + if (menu_event->iptkey == IPT_UI_LEFT && sw_custfltr::mnfct[pos] > 0) { sw_custfltr::mnfct[pos]--; changed = true; } - else if (m_event->iptkey == IPT_UI_RIGHT && sw_custfltr::mnfct[pos] < m_filter.publisher.ui.size() - 1) + else if (menu_event->iptkey == IPT_UI_RIGHT && sw_custfltr::mnfct[pos] < m_filter.publisher.ui.size() - 1) { sw_custfltr::mnfct[pos]++; changed = true; } - else if (m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container, m_filter.publisher.ui, sw_custfltr::mnfct[pos])); + else if (menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container, m_filter.publisher.ui, sw_custfltr::mnfct[pos]); } - else if ((FPTR)m_event->itemref >= REGION_FILTER && (FPTR)m_event->itemref < REGION_FILTER + MAX_CUST_FILTER) + else if ((FPTR)menu_event->itemref >= REGION_FILTER && (FPTR)menu_event->itemref < REGION_FILTER + MAX_CUST_FILTER) { - int pos = (int)((FPTR)m_event->itemref - REGION_FILTER); - if (m_event->iptkey == IPT_UI_LEFT && sw_custfltr::region[pos] > 0) + int pos = (int)((FPTR)menu_event->itemref - REGION_FILTER); + if (menu_event->iptkey == IPT_UI_LEFT && sw_custfltr::region[pos] > 0) { sw_custfltr::region[pos]--; changed = true; } - else if (m_event->iptkey == IPT_UI_RIGHT && sw_custfltr::region[pos] < m_filter.region.ui.size() - 1) + else if (menu_event->iptkey == IPT_UI_RIGHT && sw_custfltr::region[pos] < m_filter.region.ui.size() - 1) { sw_custfltr::region[pos]++; changed = true; } - else if (m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container, m_filter.region.ui, sw_custfltr::region[pos])); + else if (menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container, m_filter.region.ui, sw_custfltr::region[pos]); } - else if ((FPTR)m_event->itemref >= LIST_FILTER && (FPTR)m_event->itemref < LIST_FILTER + MAX_CUST_FILTER) + else if ((FPTR)menu_event->itemref >= LIST_FILTER && (FPTR)menu_event->itemref < LIST_FILTER + MAX_CUST_FILTER) { - int pos = (int)((FPTR)m_event->itemref - LIST_FILTER); - if (m_event->iptkey == IPT_UI_LEFT && sw_custfltr::list[pos] > 0) + int pos = (int)((FPTR)menu_event->itemref - LIST_FILTER); + if (menu_event->iptkey == IPT_UI_LEFT && sw_custfltr::list[pos] > 0) { sw_custfltr::list[pos]--; changed = true; } - else if (m_event->iptkey == IPT_UI_RIGHT && sw_custfltr::list[pos] < m_filter.swlist.name.size() - 1) + else if (menu_event->iptkey == IPT_UI_RIGHT && sw_custfltr::list[pos] < m_filter.swlist.name.size() - 1) { sw_custfltr::list[pos]++; changed = true; } - else if (m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container, m_filter.swlist.description, sw_custfltr::list[pos])); + else if (menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container, m_filter.swlist.description, sw_custfltr::list[pos]); } } if (changed) - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); else if (m_added) - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); } //------------------------------------------------- // populate //------------------------------------------------- -void ui_menu_swcustom_filter::populate() +void menu_swcustom_filter::populate() { // add main filter UINT32 arrow_flags = get_arrow_flags((int)UI_SW_ALL, (int)UI_SW_UNAVAILABLE, sw_custfltr::main); @@ -446,7 +449,7 @@ void ui_menu_swcustom_filter::populate() // add other filters for (int x = 1; x <= sw_custfltr::numother; x++) { - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); // add filter items arrow_flags = get_arrow_flags((int)UI_SW_UNAVAILABLE + 1, (int)UI_SW_LAST - 1, sw_custfltr::other[x]); @@ -501,7 +504,7 @@ void ui_menu_swcustom_filter::populate() } } - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); if (sw_custfltr::numother > 0) item_append(_("Remove last filter"), nullptr, 0, (void *)(FPTR)REMOVE_FILTER); @@ -509,7 +512,7 @@ void ui_menu_swcustom_filter::populate() if (sw_custfltr::numother < MAX_CUST_FILTER - 2) item_append(_("Add filter"), nullptr, 0, (void *)(FPTR)ADD_FILTER); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } @@ -517,7 +520,7 @@ void ui_menu_swcustom_filter::populate() //------------------------------------------------- // perform our special rendering //------------------------------------------------- -void ui_menu_swcustom_filter::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_swcustom_filter::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float width; @@ -550,7 +553,7 @@ void ui_menu_swcustom_filter::custom_render(void *selectedref, float top, float // save custom filters info to file //------------------------------------------------- -void ui_menu_swcustom_filter::save_sw_custom_filters() +void menu_swcustom_filter::save_sw_custom_filters() { // attempt to open the output file emu_file file(ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); @@ -579,3 +582,5 @@ void ui_menu_swcustom_filter::save_sw_custom_filters() file.close(); } } + +} // namespace ui diff --git a/src/frontend/mame/ui/custmenu.h b/src/frontend/mame/ui/custmenu.h index c0c4508d7fe..6394e7d245e 100644 --- a/src/frontend/mame/ui/custmenu.h +++ b/src/frontend/mame/ui/custmenu.h @@ -11,11 +11,14 @@ #pragma once -#ifndef __UI_CUSTMENU_H__ -#define __UI_CUSTMENU_H__ +#ifndef MAME_FRONTEND_UI_CUSTMENU_H +#define MAME_FRONTEND_UI_CUSTMENU_H +#include "ui/menu.h" #include "ui/utils.h" +namespace ui { + // Software region struct c_sw_region { @@ -70,11 +73,11 @@ struct s_filter //------------------------------------------------- // custom software filter menu class //------------------------------------------------- -class ui_menu_swcustom_filter : public ui_menu +class menu_swcustom_filter : public menu { public: - ui_menu_swcustom_filter(mame_ui_manager &mui, render_container *container, const game_driver *_driver, s_filter &_filter); - virtual ~ui_menu_swcustom_filter(); + menu_swcustom_filter(mame_ui_manager &mui, render_container *container, const game_driver *_driver, s_filter &_filter); + virtual ~menu_swcustom_filter() override; virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -103,11 +106,11 @@ private: //------------------------------------------------- // custom filter menu class //------------------------------------------------- -class ui_menu_custom_filter : public ui_menu +class menu_custom_filter : public menu { public: - ui_menu_custom_filter(mame_ui_manager &mui, render_container *container, bool _single_menu = false); - virtual ~ui_menu_custom_filter(); + menu_custom_filter(mame_ui_manager &mui, render_container *container, bool _single_menu = false); + virtual ~menu_custom_filter() override; virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -128,4 +131,6 @@ private: void save_custom_filters(); }; -#endif /* __UI_CUSTMENU_H__ */ +} // namespace ui + +#endif /* MAME_FRONTEND_UI_CUSTMENU_H */ diff --git a/src/frontend/mame/ui/custui.cpp b/src/frontend/mame/ui/custui.cpp index 5f79508d404..9b52715b50d 100644 --- a/src/frontend/mame/ui/custui.cpp +++ b/src/frontend/mame/ui/custui.cpp @@ -9,15 +9,19 @@ *********************************************************************/ #include "emu.h" -#include "emuopts.h" -#include "osdepend.h" -#include "ui/ui.h" -#include "ui/menu.h" -#include "ui/selector.h" -#include "ui/utils.h" + #include "ui/custui.h" -const char *const ui_menu_custom_ui::hide_status[] = { +#include "ui/ui.h" +#include "ui/selector.h" +#include "ui/utils.h" + +#include "emuopts.h" +#include "osdepend.h" + +namespace ui { + +const char *const menu_custom_ui::hide_status[] = { __("Show All"), __("Hide Filters"), __("Hide Info/Image"), @@ -27,7 +31,7 @@ const char *const ui_menu_custom_ui::hide_status[] = { // ctor //------------------------------------------------- -ui_menu_custom_ui::ui_menu_custom_ui(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container) +menu_custom_ui::menu_custom_ui(mame_ui_manager &mui, render_container *container) : menu(mui, container) { // load languages file_enumerator path(mui.machine().options().language_path()); @@ -51,7 +55,7 @@ ui_menu_custom_ui::ui_menu_custom_ui(mame_ui_manager &mui, render_container *con // dtor //------------------------------------------------- -ui_menu_custom_ui::~ui_menu_custom_ui() +menu_custom_ui::~menu_custom_ui() { std::string error_string; ui().options().set_value(OPTION_HIDE_PANELS, ui_globals::panels_status, OPTION_PRIORITY_CMDLINE, error_string); @@ -68,58 +72,58 @@ ui_menu_custom_ui::~ui_menu_custom_ui() // handle //------------------------------------------------- -void ui_menu_custom_ui::handle() +void menu_custom_ui::handle() { bool changed = false; // process the menu - const ui_menu_event *m_event = process(0); + const event *menu_event = process(0); - if (m_event != nullptr && m_event->itemref != nullptr) + if (menu_event != nullptr && menu_event->itemref != nullptr) { - switch ((FPTR)m_event->itemref) + switch ((FPTR)menu_event->itemref) { case FONT_MENU: - if (m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container)); + if (menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container); break; case COLORS_MENU: - if (m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container)); + if (menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container); break; case HIDE_MENU: { - if (m_event->iptkey == IPT_UI_LEFT || m_event->iptkey == IPT_UI_RIGHT) + if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) { changed = true; - (m_event->iptkey == IPT_UI_RIGHT) ? ui_globals::panels_status++ : ui_globals::panels_status--; + (menu_event->iptkey == IPT_UI_RIGHT) ? ui_globals::panels_status++ : ui_globals::panels_status--; } - else if (m_event->iptkey == IPT_UI_SELECT) + else if (menu_event->iptkey == IPT_UI_SELECT) { int total = ARRAY_LENGTH(hide_status); std::vector s_sel(total); for (int index = 0; index < total; ++index) s_sel[index] = _(hide_status[index]); - ui_menu::stack_push(global_alloc_clear(ui(), container, s_sel, ui_globals::panels_status)); + menu::stack_push(ui(), container, s_sel, ui_globals::panels_status); } break; } case LANGUAGE_MENU: { - if (m_event->iptkey == IPT_UI_LEFT || m_event->iptkey == IPT_UI_RIGHT) + if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) { changed = true; - (m_event->iptkey == IPT_UI_RIGHT) ? m_currlang++ : m_currlang--; + (menu_event->iptkey == IPT_UI_RIGHT) ? m_currlang++ : m_currlang--; } - else if (m_event->iptkey == IPT_UI_SELECT) + else if (menu_event->iptkey == IPT_UI_SELECT) { int total = m_lang.size(); std::vector s_sel(total); for (int index = 0; index < total; ++index) s_sel[index] = m_lang[index]; - ui_menu::stack_push(global_alloc_clear(ui(), container, s_sel, m_currlang)); + menu::stack_push(ui(), container, s_sel, m_currlang); } break; } @@ -127,14 +131,14 @@ void ui_menu_custom_ui::handle() } if (changed) - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); } //------------------------------------------------- // populate //------------------------------------------------- -void ui_menu_custom_ui::populate() +void menu_custom_ui::populate() { UINT32 arrow_flags; item_append(_("Fonts"), nullptr, 0, (void *)(FPTR)FONT_MENU); @@ -149,7 +153,7 @@ void ui_menu_custom_ui::populate() arrow_flags = get_arrow_flags(0, (int)HIDE_BOTH, ui_globals::panels_status); item_append(_("Show side panels"), _(hide_status[ui_globals::panels_status]), arrow_flags, (void *)(FPTR)HIDE_MENU); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } @@ -157,7 +161,7 @@ void ui_menu_custom_ui::populate() // perform our special rendering //------------------------------------------------- -void ui_menu_custom_ui::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_custom_ui::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float width; @@ -189,7 +193,7 @@ void ui_menu_custom_ui::custom_render(void *selectedref, float top, float bottom // ctor //------------------------------------------------- -ui_menu_font_ui::ui_menu_font_ui(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container) +menu_font_ui::menu_font_ui(mame_ui_manager &mui, render_container *container) : menu(mui, container) { ui_options &moptions = mui.options(); std::string name(mui.machine().options().ui_font()); @@ -234,7 +238,7 @@ ui_menu_font_ui::ui_menu_font_ui(mame_ui_manager &mui, render_container *contain // create fonts list //------------------------------------------------- -void ui_menu_font_ui::list() +void menu_font_ui::list() { machine().osd().get_font_families(machine().options().font_path(), m_fonts); @@ -246,7 +250,7 @@ void ui_menu_font_ui::list() // dtor //------------------------------------------------- -ui_menu_font_ui::~ui_menu_font_ui() +menu_font_ui::~menu_font_ui() { std::string error_string; ui_options &moptions = ui().options(); @@ -272,45 +276,45 @@ ui_menu_font_ui::~ui_menu_font_ui() // handle //------------------------------------------------- -void ui_menu_font_ui::handle() +void menu_font_ui::handle() { bool changed = false; // process the menu - const ui_menu_event *m_event = process(UI_MENU_PROCESS_LR_REPEAT); + const event *menu_event = process(PROCESS_LR_REPEAT); - if (m_event != nullptr && m_event->itemref != nullptr) - switch ((FPTR)m_event->itemref) + if (menu_event != nullptr && menu_event->itemref != nullptr) + switch ((FPTR)menu_event->itemref) { case INFOS_SIZE: - if (m_event->iptkey == IPT_UI_LEFT || m_event->iptkey == IPT_UI_RIGHT) + if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) { - (m_event->iptkey == IPT_UI_RIGHT) ? m_info_size += 0.05f : m_info_size -= 0.05f; + (menu_event->iptkey == IPT_UI_RIGHT) ? m_info_size += 0.05f : m_info_size -= 0.05f; changed = true; } break; case FONT_SIZE: - if (m_event->iptkey == IPT_UI_LEFT || m_event->iptkey == IPT_UI_RIGHT) + if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) { - (m_event->iptkey == IPT_UI_RIGHT) ? m_font_size++ : m_font_size--; + (menu_event->iptkey == IPT_UI_RIGHT) ? m_font_size++ : m_font_size--; changed = true; } break; case MUI_FNT: - if (m_event->iptkey == IPT_UI_LEFT || m_event->iptkey == IPT_UI_RIGHT) + if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) { - (m_event->iptkey == IPT_UI_RIGHT) ? m_actual++ : m_actual--; + (menu_event->iptkey == IPT_UI_RIGHT) ? m_actual++ : m_actual--; changed = true; } - else if (m_event->iptkey == IPT_UI_SELECT) + else if (menu_event->iptkey == IPT_UI_SELECT) { std::vector display_names; display_names.reserve(m_fonts.size()); for (auto const &font : m_fonts) display_names.emplace_back(font.second); - ui_menu::stack_push(global_alloc_clear(ui(), container, std::move(display_names), m_actual)); + menu::stack_push(ui(), container, std::move(display_names), m_actual); changed = true; } break; @@ -318,9 +322,9 @@ void ui_menu_font_ui::handle() #ifdef UI_WINDOWS case MUI_BOLD: case MUI_ITALIC: - if (m_event->iptkey == IPT_UI_LEFT || m_event->iptkey == IPT_UI_RIGHT || m_event->iptkey == IPT_UI_SELECT) + if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT || menu_event->iptkey == IPT_UI_SELECT) { - ((FPTR)m_event->itemref == MUI_BOLD) ? m_bold = !m_bold : m_italic = !m_italic; + ((FPTR)menu_event->itemref == MUI_BOLD) ? m_bold = !m_bold : m_italic = !m_italic; changed = true; } break; @@ -328,14 +332,14 @@ void ui_menu_font_ui::handle() } if (changed) - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); } //------------------------------------------------- // populate //------------------------------------------------- -void ui_menu_font_ui::populate() +void menu_font_ui::populate() { // set filter arrow UINT32 arrow_flags; @@ -347,21 +351,21 @@ void ui_menu_font_ui::populate() #ifdef UI_WINDOWS if (m_fonts[m_actual].first != "default") { - item_append(_("Bold"), m_bold ? "On" : "Off", m_bold ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)(FPTR)MUI_BOLD); - item_append(_("Italic"), m_italic ? "On" : "Off", m_italic ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)(FPTR)MUI_ITALIC); + item_append(_("Bold"), m_bold ? "On" : "Off", m_bold ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW, (void *)(FPTR)MUI_BOLD); + item_append(_("Italic"), m_italic ? "On" : "Off", m_italic ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW, (void *)(FPTR)MUI_ITALIC); } #endif arrow_flags = get_arrow_flags(m_font_min, m_font_max, m_font_size); item_append(_("Lines"), string_format("%2d", m_font_size).c_str(), arrow_flags, (void *)(FPTR)FONT_SIZE); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); // add item arrow_flags = get_arrow_flags(m_info_min, m_info_max, m_info_size); item_append(_("Infos text size"), string_format("%3.2f", m_info_size).c_str(), arrow_flags, (void *)(FPTR)INFOS_SIZE); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); custombottom = customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } @@ -370,7 +374,7 @@ void ui_menu_font_ui::populate() // perform our special rendering //------------------------------------------------- -void ui_menu_font_ui::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_font_ui::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float width; @@ -434,7 +438,7 @@ void ui_menu_font_ui::custom_render(void *selectedref, float top, float bottom, //------------------------------------------------- #define SET_COLOR_UI(var, opt) var[M##opt].color = opt; var[M##opt].option = OPTION_##opt -ui_menu_colors_ui::ui_menu_colors_ui(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container) +menu_colors_ui::menu_colors_ui(mame_ui_manager &mui, render_container *container) : menu(mui, container) { SET_COLOR_UI(m_color_table, UI_BACKGROUND_COLOR); SET_COLOR_UI(m_color_table, UI_BORDER_COLOR); @@ -458,7 +462,7 @@ ui_menu_colors_ui::ui_menu_colors_ui(mame_ui_manager &mui, render_container *con // dtor //------------------------------------------------- -ui_menu_colors_ui::~ui_menu_colors_ui() +menu_colors_ui::~menu_colors_ui() { std::string error_string, dec_color; for (int index = 1; index < MUI_RESTORE; index++) @@ -472,17 +476,17 @@ ui_menu_colors_ui::~ui_menu_colors_ui() // handle //------------------------------------------------- -void ui_menu_colors_ui::handle() +void menu_colors_ui::handle() { bool changed = false; // process the menu - const ui_menu_event *m_event = process(0); + const event *menu_event = process(0); - if (m_event != nullptr && m_event->itemref != nullptr && m_event->iptkey == IPT_UI_SELECT) + if (menu_event != nullptr && menu_event->itemref != nullptr && menu_event->iptkey == IPT_UI_SELECT) { - if ((FPTR)m_event->itemref != MUI_RESTORE) - ui_menu::stack_push(global_alloc_clear(ui(), container, &m_color_table[(FPTR)m_event->itemref].color, item[selected].text)); + if ((FPTR)menu_event->itemref != MUI_RESTORE) + menu::stack_push(ui(), container, &m_color_table[(FPTR)menu_event->itemref].color, item[selected].text); else { changed = true; @@ -491,14 +495,14 @@ void ui_menu_colors_ui::handle() } if (changed) - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); } //------------------------------------------------- // populate //------------------------------------------------- -void ui_menu_colors_ui::populate() +void menu_colors_ui::populate() { item_append(_("Normal text"), nullptr, 0, (void *)(FPTR)MUI_TEXT_COLOR); item_append(_("Selected color"), nullptr, 0, (void *)(FPTR)MUI_SELECTED_COLOR); @@ -517,7 +521,7 @@ void ui_menu_colors_ui::populate() item_append(_("Mouse down color"), nullptr, 0, (void *)(FPTR)MUI_MOUSEDOWN_COLOR); item_append(_("Mouse down background color"), nullptr, 0, (void *)(FPTR)MUI_MOUSEDOWN_BG_COLOR); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); item_append(_("Restore originals colors"), nullptr, 0, (void *)(FPTR)MUI_RESTORE); custombottom = customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; @@ -527,7 +531,7 @@ void ui_menu_colors_ui::populate() // perform our special rendering //------------------------------------------------- -void ui_menu_colors_ui::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float width, maxwidth = origx2 - origx1; float line_height = ui().get_line_height(); @@ -674,7 +678,7 @@ void ui_menu_colors_ui::custom_render(void *selectedref, float top, float bottom // restore original colors //------------------------------------------------- -void ui_menu_colors_ui::restore_colors() +void menu_colors_ui::restore_colors() { ui_options options; for (int index = 1; index < MUI_RESTORE; index++) @@ -685,7 +689,7 @@ void ui_menu_colors_ui::restore_colors() // ctor //------------------------------------------------- -ui_menu_rgb_ui::ui_menu_rgb_ui(mame_ui_manager &mui, render_container *container, rgb_t *_color, std::string _title) : ui_menu(mui, container) +menu_rgb_ui::menu_rgb_ui(mame_ui_manager &mui, render_container *container, rgb_t *_color, std::string _title) : menu(mui, container) { m_color = _color; m_key_active = false; @@ -698,7 +702,7 @@ ui_menu_rgb_ui::ui_menu_rgb_ui(mame_ui_manager &mui, render_container *container // dtor //------------------------------------------------- -ui_menu_rgb_ui::~ui_menu_rgb_ui() +menu_rgb_ui::~menu_rgb_ui() { } @@ -706,125 +710,125 @@ ui_menu_rgb_ui::~ui_menu_rgb_ui() // handle //------------------------------------------------- -void ui_menu_rgb_ui::handle() +void menu_rgb_ui::handle() { bool changed = false; // process the menu - const ui_menu_event *m_event; + const event *menu_event; if (!m_key_active) - m_event = process(UI_MENU_PROCESS_LR_REPEAT); + menu_event = process(PROCESS_LR_REPEAT); else - m_event = process(UI_MENU_PROCESS_ONLYCHAR); + menu_event = process(PROCESS_ONLYCHAR); - if (m_event != nullptr && m_event->itemref != nullptr) + if (menu_event != nullptr && menu_event->itemref != nullptr) { - switch ((FPTR)m_event->itemref) + switch ((FPTR)menu_event->itemref) { case RGB_ALPHA: - if (m_event->iptkey == IPT_UI_LEFT && m_color->a() > 1) + if (menu_event->iptkey == IPT_UI_LEFT && m_color->a() > 1) { m_color->set_a(m_color->a() - 1); changed = true; } - else if (m_event->iptkey == IPT_UI_RIGHT && m_color->a() < 255) + else if (menu_event->iptkey == IPT_UI_RIGHT && m_color->a() < 255) { m_color->set_a(m_color->a() + 1); changed = true; } - else if (m_event->iptkey == IPT_UI_SELECT || m_event->iptkey == IPT_SPECIAL) + else if (menu_event->iptkey == IPT_UI_SELECT || menu_event->iptkey == IPT_SPECIAL) { - inkey_special(m_event); + inkey_special(menu_event); changed = true; } break; case RGB_RED: - if (m_event->iptkey == IPT_UI_LEFT && m_color->r() > 1) + if (menu_event->iptkey == IPT_UI_LEFT && m_color->r() > 1) { m_color->set_r(m_color->r() - 1); changed = true; } - else if (m_event->iptkey == IPT_UI_RIGHT && m_color->r() < 255) + else if (menu_event->iptkey == IPT_UI_RIGHT && m_color->r() < 255) { m_color->set_r(m_color->r() + 1); changed = true; } - else if (m_event->iptkey == IPT_UI_SELECT || m_event->iptkey == IPT_SPECIAL) + else if (menu_event->iptkey == IPT_UI_SELECT || menu_event->iptkey == IPT_SPECIAL) { - inkey_special(m_event); + inkey_special(menu_event); changed = true; } break; case RGB_GREEN: - if (m_event->iptkey == IPT_UI_LEFT && m_color->g() > 1) + if (menu_event->iptkey == IPT_UI_LEFT && m_color->g() > 1) { m_color->set_g(m_color->g() - 1); changed = true; } - else if (m_event->iptkey == IPT_UI_RIGHT && m_color->g() < 255) + else if (menu_event->iptkey == IPT_UI_RIGHT && m_color->g() < 255) { m_color->set_g(m_color->g() + 1); changed = true; } - else if (m_event->iptkey == IPT_UI_SELECT || m_event->iptkey == IPT_SPECIAL) + else if (menu_event->iptkey == IPT_UI_SELECT || menu_event->iptkey == IPT_SPECIAL) { - inkey_special(m_event); + inkey_special(menu_event); changed = true; } break; case RGB_BLUE: - if (m_event->iptkey == IPT_UI_LEFT && m_color->b() > 1) + if (menu_event->iptkey == IPT_UI_LEFT && m_color->b() > 1) { m_color->set_b(m_color->b() - 1); changed = true; } - else if (m_event->iptkey == IPT_UI_RIGHT && m_color->b() < 255) + else if (menu_event->iptkey == IPT_UI_RIGHT && m_color->b() < 255) { m_color->set_b(m_color->b() + 1); changed = true; } - else if (m_event->iptkey == IPT_UI_SELECT || m_event->iptkey == IPT_SPECIAL) + else if (menu_event->iptkey == IPT_UI_SELECT || menu_event->iptkey == IPT_SPECIAL) { - inkey_special(m_event); + inkey_special(menu_event); changed = true; } break; case PALETTE_CHOOSE: - if (m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container, *m_color)); + if (menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container, *m_color); break; } } if (changed) - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); } //------------------------------------------------- // populate //------------------------------------------------- -void ui_menu_rgb_ui::populate() +void menu_rgb_ui::populate() { // set filter arrow - UINT32 arrow_flags = MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW; + UINT32 arrow_flags = FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW; std::string s_text = std::string(m_search).append("_"); if (m_lock_ref != RGB_ALPHA) @@ -859,9 +863,9 @@ void ui_menu_rgb_ui::populate() else item_append(_("Blue"), s_text.c_str(), 0, (void *)(FPTR)RGB_BLUE); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); item_append(_("Choose from palette"), nullptr, 0, (void *)(FPTR)PALETTE_CHOOSE); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); custombottom = customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } @@ -870,7 +874,7 @@ void ui_menu_rgb_ui::populate() // perform our special rendering //------------------------------------------------- -void ui_menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float width, maxwidth = origx2 - origx1; @@ -937,19 +941,19 @@ void ui_menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, f // handle special key event //------------------------------------------------- -void ui_menu_rgb_ui::inkey_special(const ui_menu_event *m_event) +void menu_rgb_ui::inkey_special(const event *menu_event) { - if (m_event->iptkey == IPT_UI_SELECT) + if (menu_event->iptkey == IPT_UI_SELECT) { m_key_active = !m_key_active; - m_lock_ref = (FPTR)m_event->itemref; + m_lock_ref = (FPTR)menu_event->itemref; if (!m_key_active) { int val = atoi(m_search); val = m_color->clamp(val); - switch ((FPTR)m_event->itemref) + switch ((FPTR)menu_event->itemref) { case RGB_ALPHA: m_color->set_a(val); @@ -983,18 +987,18 @@ void ui_menu_rgb_ui::inkey_special(const ui_menu_event *m_event) int buflen = strlen(m_search); // if it's a backspace and we can handle it, do so - if (((m_event->unichar == 8 || m_event->unichar == 0x7f) && buflen > 0)) + if (((menu_event->unichar == 8 || menu_event->unichar == 0x7f) && buflen > 0)) *(char *)utf8_previous_char(&m_search[buflen]) = 0; else if (buflen >= 3) return; // if it's any other key and we're not maxed out, update - else if ((m_event->unichar >= '0' && m_event->unichar <= '9')) - buflen += utf8_from_uchar(&m_search[buflen], ARRAY_LENGTH(m_search) - buflen, m_event->unichar); + else if ((menu_event->unichar >= '0' && menu_event->unichar <= '9')) + buflen += utf8_from_uchar(&m_search[buflen], ARRAY_LENGTH(m_search) - buflen, menu_event->unichar); m_search[buflen] = 0; } -ui_menu_palette_sel::palcolor ui_menu_palette_sel::m_palette[] = { +menu_palette_sel::palcolor menu_palette_sel::m_palette[] = { { __("White"), "FFFFFFFF" }, { __("Silver"), "FFC0C0C0" }, { __("Gray"), "FF808080" }, @@ -1011,8 +1015,8 @@ ui_menu_palette_sel::palcolor ui_menu_palette_sel::m_palette[] = { // ctor //------------------------------------------------- -ui_menu_palette_sel::ui_menu_palette_sel(mame_ui_manager &mui, render_container *container, rgb_t &_color) - : ui_menu(mui, container), m_original(_color) +menu_palette_sel::menu_palette_sel(mame_ui_manager &mui, render_container *container, rgb_t &_color) + : menu(mui, container), m_original(_color) { } @@ -1020,7 +1024,7 @@ ui_menu_palette_sel::ui_menu_palette_sel(mame_ui_manager &mui, render_container // dtor //------------------------------------------------- -ui_menu_palette_sel::~ui_menu_palette_sel() +menu_palette_sel::~menu_palette_sel() { } @@ -1028,17 +1032,17 @@ ui_menu_palette_sel::~ui_menu_palette_sel() // handle //------------------------------------------------- -void ui_menu_palette_sel::handle() +void menu_palette_sel::handle() { // process the menu - const ui_menu_event *m_event = process(MENU_FLAG_UI_PALETTE); - if (m_event != nullptr && m_event->itemref != nullptr) + const event *menu_event = process(FLAG_UI_PALETTE); + if (menu_event != nullptr && menu_event->itemref != nullptr) { - if (m_event->iptkey == IPT_UI_SELECT) + if (menu_event->iptkey == IPT_UI_SELECT) { m_original = rgb_t((UINT32)strtoul(item[selected].subtext, nullptr, 16)); - ui_menu::menu_stack->parent->reset(UI_MENU_RESET_SELECT_FIRST); - ui_menu::stack_pop(machine()); + reset_parent(reset_options::SELECT_FIRST); + menu::stack_pop(machine()); } } } @@ -1047,18 +1051,20 @@ void ui_menu_palette_sel::handle() // populate //------------------------------------------------- -void ui_menu_palette_sel::populate() +void menu_palette_sel::populate() { for (int x = 0; x < ARRAY_LENGTH(m_palette); ++x) - item_append(_(m_palette[x].name), m_palette[x].argb, MENU_FLAG_UI_PALETTE, (void *)(FPTR)(x + 1)); + item_append(_(m_palette[x].name), m_palette[x].argb, FLAG_UI_PALETTE, (void *)(FPTR)(x + 1)); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); } //------------------------------------------------- // perform our special rendering //------------------------------------------------- -void ui_menu_palette_sel::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_palette_sel::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { } + +} // namespace ui diff --git a/src/frontend/mame/ui/custui.h b/src/frontend/mame/ui/custui.h index ec271485f6c..217bc4e6ac4 100644 --- a/src/frontend/mame/ui/custui.h +++ b/src/frontend/mame/ui/custui.h @@ -10,18 +10,22 @@ #pragma once -#ifndef MAME_EMU_UI_UI_CUSTUI_H -#define MAME_EMU_UI_UI_CUSTUI_H +#ifndef MAME_FRONTEND_UI_CUSTUI_H +#define MAME_FRONTEND_UI_CUSTUI_H + +#include "ui/menu.h" + +namespace ui { //------------------------------------------------- // Custom UI menu //------------------------------------------------- -class ui_menu_custom_ui : public ui_menu +class menu_custom_ui : public menu { public: - ui_menu_custom_ui(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_custom_ui(); + menu_custom_ui(mame_ui_manager &mui, render_container *container); + virtual ~menu_custom_ui() override; virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -43,11 +47,11 @@ private: // Font UI menu //------------------------------------------------- -class ui_menu_font_ui : public ui_menu +class menu_font_ui : public menu { public: - ui_menu_font_ui(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_font_ui(); + menu_font_ui(mame_ui_manager &mui, render_container *container); + virtual ~menu_font_ui() override; virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -78,11 +82,11 @@ private: // Colors UI menu //------------------------------------------------- -class ui_menu_colors_ui : public ui_menu +class menu_colors_ui : public menu { public: - ui_menu_colors_ui(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_colors_ui(); + menu_colors_ui(mame_ui_manager &mui, render_container *container); + virtual ~menu_colors_ui() override; virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -123,11 +127,11 @@ private: // ARGB UI menu //------------------------------------------------- -class ui_menu_rgb_ui : public ui_menu +class menu_rgb_ui : public menu { public: - ui_menu_rgb_ui(mame_ui_manager &mui, render_container *container, rgb_t *_color, std::string _title); - virtual ~ui_menu_rgb_ui(); + menu_rgb_ui(mame_ui_manager &mui, render_container *container, rgb_t *_color, std::string _title); + virtual ~menu_rgb_ui() override; virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -148,18 +152,18 @@ private: PALETTE_CHOOSE }; - void inkey_special(const ui_menu_event *menu_event); + void inkey_special(const event *menu_event); }; //------------------------------------------------- // Palette UI menu //------------------------------------------------- -class ui_menu_palette_sel : public ui_menu +class menu_palette_sel : public menu { public: - ui_menu_palette_sel(mame_ui_manager &mui, render_container *container, rgb_t &_color); - virtual ~ui_menu_palette_sel(); + menu_palette_sel(mame_ui_manager &mui, render_container *container, rgb_t &_color); + virtual ~menu_palette_sel() override; virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -175,4 +179,6 @@ private: rgb_t &m_original; }; -#endif // MAME_EMU_UI_UI_CUSTUI_H +} // namespace ui + +#endif // MAME_FRONTEND_UI_CUSTUI_H diff --git a/src/frontend/mame/ui/datmenu.cpp b/src/frontend/mame/ui/datmenu.cpp index 7c6d8079780..fe3fc622699 100644 --- a/src/frontend/mame/ui/datmenu.cpp +++ b/src/frontend/mame/ui/datmenu.cpp @@ -9,21 +9,24 @@ *********************************************************************/ #include "emu.h" -#include "mame.h" + #include "ui/ui.h" -#include "ui/menu.h" -#include "rendfont.h" #include "ui/datfile.h" #include "ui/datmenu.h" #include "ui/utils.h" + +#include "mame.h" +#include "rendfont.h" #include "softlist.h" +namespace ui { + //------------------------------------------------- // ctor / dtor //------------------------------------------------- -ui_menu_dats_view::ui_menu_dats_view(mame_ui_manager &mui, render_container *container, const game_driver *driver) - : ui_menu(mui, container) +menu_dats_view::menu_dats_view(mame_ui_manager &mui, render_container *container, const game_driver *driver) + : menu(mui, container) , m_actual(0) , m_driver((driver == nullptr) ? &mui.machine().system() : driver) , m_issoft(false) @@ -47,8 +50,8 @@ ui_menu_dats_view::ui_menu_dats_view(mame_ui_manager &mui, render_container *con // ctor //------------------------------------------------- -ui_menu_dats_view::ui_menu_dats_view(mame_ui_manager &mui, render_container *container, ui_software_info *swinfo, const game_driver *driver) - : ui_menu(mui, container) +menu_dats_view::menu_dats_view(mame_ui_manager &mui, render_container *container, ui_software_info *swinfo, const game_driver *driver) + : menu(mui, container) , m_actual(0) , m_driver((driver == nullptr) ? &mui.machine().system() : driver) , m_swinfo(swinfo) @@ -69,7 +72,7 @@ ui_menu_dats_view::ui_menu_dats_view(mame_ui_manager &mui, render_container *con // dtor //------------------------------------------------- -ui_menu_dats_view::~ui_menu_dats_view() +menu_dats_view::~menu_dats_view() { } @@ -77,21 +80,21 @@ ui_menu_dats_view::~ui_menu_dats_view() // handle //------------------------------------------------- -void ui_menu_dats_view::handle() +void menu_dats_view::handle() { - const ui_menu_event *m_event = process(MENU_FLAG_UI_DATS); - if (m_event != nullptr) + const event *menu_event = process(FLAG_UI_DATS); + if (menu_event != nullptr) { - if (m_event->iptkey == IPT_UI_LEFT && m_actual > 0) + if (menu_event->iptkey == IPT_UI_LEFT && m_actual > 0) { m_actual--; - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); } - if (m_event->iptkey == IPT_UI_RIGHT && m_actual < m_items_list.size() - 1) + if (menu_event->iptkey == IPT_UI_RIGHT && m_actual < m_items_list.size() - 1) { m_actual++; - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); } } } @@ -100,7 +103,7 @@ void ui_menu_dats_view::handle() // populate //------------------------------------------------- -void ui_menu_dats_view::populate() +void menu_dats_view::populate() { bool paused = machine().paused(); if (!paused) @@ -108,7 +111,7 @@ void ui_menu_dats_view::populate() (m_issoft == true) ? get_data_sw() : get_data(); - item_append(MENU_SEPARATOR_ITEM, nullptr, (MENU_FLAG_UI_DATS | MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW), nullptr); + item_append(MENU_SEPARATOR_ITEM, nullptr, (FLAG_UI_DATS | FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW), nullptr); customtop = 2.0f * ui().get_line_height() + 4.0f * UI_BOX_TB_BORDER; custombottom = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; @@ -120,7 +123,7 @@ void ui_menu_dats_view::populate() // perform our special rendering //------------------------------------------------- -void ui_menu_dats_view::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_dats_view::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float maxwidth = origx2 - origx1; float width; @@ -219,7 +222,7 @@ void ui_menu_dats_view::custom_render(void *selectedref, float top, float bottom // load data from DATs //------------------------------------------------- -void ui_menu_dats_view::get_data() +void menu_dats_view::get_data() { std::vector xstart; std::vector xend; @@ -248,11 +251,11 @@ void ui_menu_dats_view::get_data() for (int x = 0; x < lines; ++x) { std::string tempbuf(buffer.substr(xstart[x], xend[x] - xstart[x])); - item_append(tempbuf.c_str(), nullptr, (MENU_FLAG_UI_DATS | MENU_FLAG_DISABLE), (void *)(FPTR)(x + 1)); + item_append(tempbuf.c_str(), nullptr, (FLAG_UI_DATS | FLAG_DISABLE), (void *)(FPTR)(x + 1)); } } -void ui_menu_dats_view::get_data_sw() +void menu_dats_view::get_data_sw() { std::vector xstart; std::vector xend; @@ -271,11 +274,11 @@ void ui_menu_dats_view::get_data_sw() for (int x = 0; x < lines; ++x) { std::string tempbuf(buffer.substr(xstart[x], xend[x] - xstart[x])); - item_append(tempbuf.c_str(), nullptr, (MENU_FLAG_UI_DATS | MENU_FLAG_DISABLE), (void *)(FPTR)(x + 1)); + item_append(tempbuf.c_str(), nullptr, (FLAG_UI_DATS | FLAG_DISABLE), (void *)(FPTR)(x + 1)); } } -void ui_menu_dats_view::init_items() +void menu_dats_view::init_items() { datfile_manager &datfile = mame_machine_manager::instance()->datfile(); if (datfile.has_history(m_driver)) @@ -293,3 +296,5 @@ void ui_menu_dats_view::init_items() if (datfile.has_command(m_driver)) m_items_list.emplace_back(_("Command"), UI_COMMAND_LOAD, ""); } + +} // namespace ui diff --git a/src/frontend/mame/ui/datmenu.h b/src/frontend/mame/ui/datmenu.h index 4592bca5b4b..44797dd243c 100644 --- a/src/frontend/mame/ui/datmenu.h +++ b/src/frontend/mame/ui/datmenu.h @@ -11,21 +11,29 @@ #pragma once -#ifndef __UI_DATMENU_H__ -#define __UI_DATMENU_H__ +#ifndef MAME_FRONTEND_UI_DATMENU_H +#define MAME_FRONTEND_UI_DATMENU_H + +#include "ui/menu.h" + +#include +#include + struct ui_software_info; +namespace ui { + //------------------------------------------------- // class dats menu //------------------------------------------------- -class ui_menu_dats_view : public ui_menu +class menu_dats_view : public menu { public: - ui_menu_dats_view(mame_ui_manager &mui, render_container *container, ui_software_info *swinfo, const game_driver *driver = nullptr); - ui_menu_dats_view(mame_ui_manager &mui, render_container *container, const game_driver *driver = nullptr); - virtual ~ui_menu_dats_view(); + menu_dats_view(mame_ui_manager &mui, render_container *container, ui_software_info *swinfo, const game_driver *driver = nullptr); + menu_dats_view(mame_ui_manager &mui, render_container *container, const game_driver *driver = nullptr); + virtual ~menu_dats_view() override; virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -49,4 +57,6 @@ private: std::vector m_items_list; }; -#endif /* __UI_DATMENU_H__ */ +} // namespace ui + +#endif /* MAME_FRONTEND_UI_DATMENU_H */ diff --git a/src/frontend/mame/ui/devctrl.h b/src/frontend/mame/ui/devctrl.h index 252981da1bd..23c8243ffce 100644 --- a/src/frontend/mame/ui/devctrl.h +++ b/src/frontend/mame/ui/devctrl.h @@ -20,17 +20,21 @@ #pragma once -#ifndef __UI_DEVCTRL_H__ -#define __UI_DEVCTRL_H__ +#ifndef MAME_FRONTEND_UI_DEVCTRL_H +#define MAME_FRONTEND_UI_DEVCTRL_H -template -class ui_menu_device_control : public ui_menu +#include "ui/menu.h" + +namespace ui { + +template +class menu_device_control : public menu { public: - ui_menu_device_control(mame_ui_manager &mui, render_container *container, _DeviceType *device); + menu_device_control(mame_ui_manager &mui, render_container *container, DeviceType *device); protected: - _DeviceType *current_device() { return m_device; } + DeviceType *current_device() { return m_device; } int count() { return m_count; } int current_index(); @@ -41,9 +45,9 @@ protected: private: // device iterator - typedef device_type_iterator<&device_creator<_DeviceType>, _DeviceType> iterator; + typedef device_type_iterator<&device_creator, DeviceType> iterator; - _DeviceType * m_device; + DeviceType * m_device; int m_count; }; @@ -52,9 +56,9 @@ private: // ctor //------------------------------------------------- -template -ui_menu_device_control<_DeviceType>::ui_menu_device_control(mame_ui_manager &mui, render_container *container, _DeviceType *device) - : ui_menu(mui, container) +template +menu_device_control::menu_device_control(mame_ui_manager &mui, render_container *container, DeviceType *device) + : menu(mui, container) { iterator iter(mui.machine().root_device()); m_count = iter.count(); @@ -66,8 +70,8 @@ ui_menu_device_control<_DeviceType>::ui_menu_device_control(mame_ui_manager &mui // current_index //------------------------------------------------- -template -int ui_menu_device_control<_DeviceType>::current_index() +template +int menu_device_control::current_index() { iterator iter(machine().root_device()); return iter.indexof(*m_device); @@ -78,8 +82,8 @@ int ui_menu_device_control<_DeviceType>::current_index() // previous //------------------------------------------------- -template -void ui_menu_device_control<_DeviceType>::previous() +template +void menu_device_control::previous() { // left arrow - rotate left through cassette devices if (m_device != nullptr) @@ -99,8 +103,8 @@ void ui_menu_device_control<_DeviceType>::previous() // next //------------------------------------------------- -template -void ui_menu_device_control<_DeviceType>::next() +template +void menu_device_control::next() { // right arrow - rotate right through cassette devices if (m_device != nullptr) @@ -120,8 +124,8 @@ void ui_menu_device_control<_DeviceType>::next() // current_display_name //------------------------------------------------- -template -std::string ui_menu_device_control<_DeviceType>::current_display_name() +template +std::string menu_device_control::current_display_name() { std::string display_name; display_name.assign(current_device()->name()); @@ -135,19 +139,20 @@ std::string ui_menu_device_control<_DeviceType>::current_display_name() // current_display_flags //------------------------------------------------- -template -UINT32 ui_menu_device_control<_DeviceType>::current_display_flags() +template +UINT32 menu_device_control::current_display_flags() { UINT32 flags = 0; if (count() > 1) { if (current_index() > 0) - flags |= MENU_FLAG_LEFT_ARROW; + flags |= FLAG_LEFT_ARROW; if (current_index() < count() - 1) - flags |= MENU_FLAG_RIGHT_ARROW; + flags |= FLAG_RIGHT_ARROW; } return flags; } +} // namespace ui -#endif /* __UI_DEVCTRL_H__ */ +#endif /* MAME_FRONTEND_UI_DEVCTRL_H */ diff --git a/src/frontend/mame/ui/devopt.cpp b/src/frontend/mame/ui/devopt.cpp index 3ebc5974506..3b8fa1442c1 100644 --- a/src/frontend/mame/ui/devopt.cpp +++ b/src/frontend/mame/ui/devopt.cpp @@ -10,22 +10,24 @@ #include "emu.h" #include "ui/ui.h" -#include "ui/menu.h" #include "ui/devopt.h" + +namespace ui { + /*------------------------------------------------- - ui_device_config - handle the game information + device_config - handle the game information menu -------------------------------------------------*/ -ui_menu_device_config::ui_menu_device_config(mame_ui_manager &mui, render_container *container, device_slot_interface *slot, device_slot_option *option) : ui_menu(mui, container) +menu_device_config::menu_device_config(mame_ui_manager &mui, render_container *container, device_slot_interface *slot, device_slot_option *option) : menu(mui, container) { m_option = option; m_owner = slot; m_mounted = slot->device().subdevice(option->name()) != nullptr; } -void ui_menu_device_config::populate() +void menu_device_config::populate() { std::ostringstream str; device_t *dev; @@ -265,15 +267,17 @@ void ui_menu_device_config::populate() str << "[None]\n"; const_cast(machine().config()).device_remove(&machine().config().root_device(), m_option->name()); - item_append(str.str().c_str(), nullptr, MENU_FLAG_MULTILINE, nullptr); + item_append(str.str().c_str(), nullptr, FLAG_MULTILINE, nullptr); } -void ui_menu_device_config::handle() +void menu_device_config::handle() { /* process the menu */ process(0); } -ui_menu_device_config::~ui_menu_device_config() +menu_device_config::~menu_device_config() { } + +} // namespace ui diff --git a/src/frontend/mame/ui/devopt.h b/src/frontend/mame/ui/devopt.h index 57233b4d216..7cc3f26516d 100644 --- a/src/frontend/mame/ui/devopt.h +++ b/src/frontend/mame/ui/devopt.h @@ -10,13 +10,18 @@ #pragma once -#ifndef __UI_DEVOPT_H__ -#define __UI_DEVOPT_H__ +#ifndef MAME_FRONTEND_UI_DEVOPT_H +#define MAME_FRONTEND_UI_DEVOPT_H -class ui_menu_device_config : public ui_menu { +#include "ui/menu.h" + +namespace ui { + +class menu_device_config : public menu +{ public: - ui_menu_device_config(mame_ui_manager &mui, render_container *container, device_slot_interface *slot, device_slot_option *option); - virtual ~ui_menu_device_config(); + menu_device_config(mame_ui_manager &mui, render_container *container, device_slot_interface *slot, device_slot_option *option); + virtual ~menu_device_config() override; virtual void populate() override; virtual void handle() override; @@ -26,5 +31,6 @@ private: bool m_mounted; }; +} // namespace ui -#endif /* __UI_DEVOPT_H__ */ +#endif /* MAME_FRONTEND_UI_DEVOPT_H */ diff --git a/src/frontend/mame/ui/dirmenu.cpp b/src/frontend/mame/ui/dirmenu.cpp index 4391ee440d0..48569f713ca 100644 --- a/src/frontend/mame/ui/dirmenu.cpp +++ b/src/frontend/mame/ui/dirmenu.cpp @@ -9,15 +9,19 @@ *********************************************************************/ #include "emu.h" -#include "emuopts.h" -#include "mame.h" + #include "ui/ui.h" -#include "ui/menu.h" #include "ui/dirmenu.h" #include "ui/datfile.h" #include "ui/utils.h" #include "ui/optsmenu.h" +#include "emuopts.h" +#include "mame.h" + + +namespace ui { + static int ADDING = 1; static int CHANGE = 2; @@ -68,11 +72,11 @@ static const folders_entry s_folders[] = // ctor / dtor //------------------------------------------------- -ui_menu_directory::ui_menu_directory(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container) +menu_directory::menu_directory(mame_ui_manager &mui, render_container *container) : menu(mui, container) { } -ui_menu_directory::~ui_menu_directory() +menu_directory::~menu_directory() { ui().save_ui_options(); ui_globals::reset = true; @@ -83,25 +87,25 @@ ui_menu_directory::~ui_menu_directory() // handle //------------------------------------------------- -void ui_menu_directory::handle() +void menu_directory::handle() { // process the menu - const ui_menu_event *m_event = process(0); + const event *menu_event = process(0); - if (m_event != nullptr && m_event->itemref != nullptr && m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container, selected)); + if (menu_event != nullptr && menu_event->itemref != nullptr && menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container, selected); } //------------------------------------------------- // populate //------------------------------------------------- -void ui_menu_directory::populate() +void menu_directory::populate() { for (auto & elem : s_folders) item_append(_(elem.name), nullptr, 0, (void *)(FPTR)elem.action); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } @@ -109,7 +113,7 @@ void ui_menu_directory::populate() // perform our special rendering //------------------------------------------------- -void ui_menu_directory::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_directory::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float width; @@ -145,12 +149,12 @@ void ui_menu_directory::custom_render(void *selectedref, float top, float bottom // ctor / dtor //------------------------------------------------- -ui_menu_display_actual::ui_menu_display_actual(mame_ui_manager &mui, render_container *container, int ref) - : ui_menu(mui, container), m_ref(ref) +menu_display_actual::menu_display_actual(mame_ui_manager &mui, render_container *container, int ref) + : menu(mui, container), m_ref(ref) { } -ui_menu_display_actual::~ui_menu_display_actual() +menu_display_actual::~menu_display_actual() { } @@ -158,20 +162,20 @@ ui_menu_display_actual::~ui_menu_display_actual() // handle //------------------------------------------------- -void ui_menu_display_actual::handle() +void menu_display_actual::handle() { // process the menu - const ui_menu_event *m_event = process(0); - if (m_event != nullptr && m_event->itemref != nullptr && m_event->iptkey == IPT_UI_SELECT) - switch ((FPTR)m_event->itemref) + const event *menu_event = process(0); + if (menu_event != nullptr && menu_event->itemref != nullptr && menu_event->iptkey == IPT_UI_SELECT) + switch ((FPTR)menu_event->itemref) { - case REMOVE: - ui_menu::stack_push(global_alloc_clear(ui(), container, m_ref)); - break; + case REMOVE: + menu::stack_push(ui(), container, m_ref); + break; - case ADD_CHANGE: - ui_menu::stack_push(global_alloc_clear(ui(), container, m_ref)); - break; + case ADD_CHANGE: + menu::stack_push(ui(), container, m_ref); + break; } } @@ -179,7 +183,7 @@ void ui_menu_display_actual::handle() // populate //------------------------------------------------- -void ui_menu_display_actual::populate() +void menu_display_actual::populate() { m_tempbuf = string_format(_("Current %1$s Folders"), _(s_folders[m_ref].name)); if (ui().options().exists(s_folders[m_ref].option)) @@ -198,7 +202,7 @@ void ui_menu_display_actual::populate() if (m_folders.size() > 1) item_append(_("Remove Folder"), nullptr, 0, (void *)REMOVE); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); customtop = (m_folders.size() + 1) * ui().get_line_height() + 6.0f * UI_BOX_TB_BORDER; } @@ -206,7 +210,7 @@ void ui_menu_display_actual::populate() // perform our special rendering //------------------------------------------------- -void ui_menu_display_actual::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_display_actual::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float width, maxwidth = origx2 - origx1; float lineh = ui().get_line_height(); @@ -272,7 +276,7 @@ MENU ADD FOLDER // ctor / dtor //------------------------------------------------- -ui_menu_add_change_folder::ui_menu_add_change_folder(mame_ui_manager &mui, render_container *container, int ref) : ui_menu(mui, container) +menu_add_change_folder::menu_add_change_folder(mame_ui_manager &mui, render_container *container, int ref) : menu(mui, container) { m_ref = ref; m_change = (s_folders[ref].action == CHANGE); @@ -293,7 +297,7 @@ ui_menu_add_change_folder::ui_menu_add_change_folder(mame_ui_manager &mui, rende m_folders.push_back(curpath); } -ui_menu_add_change_folder::~ui_menu_add_change_folder() +menu_add_change_folder::~menu_add_change_folder() { } @@ -301,17 +305,17 @@ ui_menu_add_change_folder::~ui_menu_add_change_folder() // handle //------------------------------------------------- -void ui_menu_add_change_folder::handle() +void menu_add_change_folder::handle() { // process the menu - const ui_menu_event *m_event = process(0); + const event *menu_event = process(0); - if (m_event != nullptr && m_event->itemref != nullptr) + if (menu_event != nullptr && menu_event->itemref != nullptr) { - if (m_event->iptkey == IPT_UI_SELECT) + if (menu_event->iptkey == IPT_UI_SELECT) { - int index = (FPTR)m_event->itemref - 1; - const ui_menu_item &pitem = item[index]; + int index = (FPTR)menu_event->itemref - 1; + const menu_item &pitem = item[index]; // go up to the parent path if (!strcmp(pitem.text, "..")) @@ -338,28 +342,28 @@ void ui_menu_add_change_folder::handle() // reset the char buffer also in this case if (m_search[0] != 0) m_search[0] = '\0'; - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); } - else if (m_event->iptkey == IPT_SPECIAL) + else if (menu_event->iptkey == IPT_SPECIAL) { int buflen = strlen(m_search); bool update_selected = FALSE; // if it's a backspace and we can handle it, do so - if ((m_event->unichar == 8 || m_event->unichar == 0x7f) && buflen > 0) + if ((menu_event->unichar == 8 || menu_event->unichar == 0x7f) && buflen > 0) { *(char *)utf8_previous_char(&m_search[buflen]) = 0; update_selected = TRUE; } // if it's any other key and we're not maxed out, update - else if (m_event->unichar >= ' ' && m_event->unichar < 0x7f) + else if (menu_event->unichar >= ' ' && menu_event->unichar < 0x7f) { - buflen += utf8_from_uchar(&m_search[buflen], ARRAY_LENGTH(m_search) - buflen, m_event->unichar); + buflen += utf8_from_uchar(&m_search[buflen], ARRAY_LENGTH(m_search) - buflen, menu_event->unichar); m_search[buflen] = 0; update_selected = TRUE; } // Tab key, save current path - else if (m_event->unichar == 0x09) + else if (menu_event->unichar == 0x09) { std::string error_string; if (m_change) @@ -393,8 +397,8 @@ void ui_menu_add_change_folder::handle() } } - ui_menu::menu_stack->parent->reset(UI_MENU_RESET_SELECT_FIRST); - ui_menu::stack_pop(machine()); + reset_parent(reset_options::SELECT_FIRST); + menu::stack_pop(machine()); } // check for entries which matches our search buffer @@ -443,7 +447,7 @@ void ui_menu_add_change_folder::handle() top_line = selected - (visible_lines / 2); } } - else if (m_event->iptkey == IPT_UI_CANCEL) + else if (menu_event->iptkey == IPT_UI_CANCEL) { // reset the char buffer also in this case if (m_search[0] != 0) @@ -456,7 +460,7 @@ void ui_menu_add_change_folder::handle() // populate //------------------------------------------------- -void ui_menu_add_change_folder::populate() +void menu_add_change_folder::populate() { // open a path const char *volume_name = nullptr; @@ -475,7 +479,7 @@ void ui_menu_add_change_folder::populate() item_append(dirent->name, "[DIR]", 0, (void *)(FPTR)++folders_count); } - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); // configure the custom rendering customtop = 2.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; @@ -486,7 +490,7 @@ void ui_menu_add_change_folder::populate() // perform our special rendering //------------------------------------------------- -void ui_menu_add_change_folder::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_add_change_folder::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float width, maxwidth = origx2 - origx1; std::string tempbuf[2]; @@ -564,7 +568,7 @@ void ui_menu_add_change_folder::custom_render(void *selectedref, float top, floa // ctor / dtor //------------------------------------------------- -ui_menu_remove_folder::ui_menu_remove_folder(mame_ui_manager &mui, render_container *container, int ref) : ui_menu(mui, container) +menu_remove_folder::menu_remove_folder(mame_ui_manager &mui, render_container *container, int ref) : menu(mui, container) { m_ref = ref; if (mui.options().exists(s_folders[m_ref].option)) @@ -578,7 +582,7 @@ ui_menu_remove_folder::ui_menu_remove_folder(mame_ui_manager &mui, render_contai m_folders.push_back(curpath); } -ui_menu_remove_folder::~ui_menu_remove_folder() +menu_remove_folder::~menu_remove_folder() { } @@ -586,11 +590,11 @@ ui_menu_remove_folder::~ui_menu_remove_folder() // handle //------------------------------------------------- -void ui_menu_remove_folder::handle() +void menu_remove_folder::handle() { // process the menu - const ui_menu_event *m_event = process(0); - if (m_event != nullptr && m_event->itemref != nullptr && m_event->iptkey == IPT_UI_SELECT) + const event *menu_event = process(0); + if (menu_event != nullptr && menu_event->itemref != nullptr && menu_event->iptkey == IPT_UI_SELECT) { std::string tmppath, error_string; m_folders.erase(m_folders.begin() + selected); @@ -609,8 +613,8 @@ void ui_menu_remove_folder::handle() machine().options().mark_changed(s_folders[m_ref].option); } - ui_menu::menu_stack->parent->reset(UI_MENU_RESET_REMEMBER_REF); - ui_menu::stack_pop(machine()); + reset_parent(reset_options::REMEMBER_REF); + menu::stack_pop(machine()); } } @@ -618,13 +622,13 @@ void ui_menu_remove_folder::handle() // populate menu //------------------------------------------------- -void ui_menu_remove_folder::populate() +void menu_remove_folder::populate() { int folders_count = 0; for (auto & elem : m_folders) item_append(elem.c_str(), nullptr, 0, (void *)(FPTR)++folders_count); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } @@ -632,7 +636,7 @@ void ui_menu_remove_folder::populate() // perform our special rendering //------------------------------------------------- -void ui_menu_remove_folder::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_remove_folder::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float width; std::string tempbuf = string_format(_("Remove %1$s Folder"), _(s_folders[m_ref].name)); @@ -660,3 +664,5 @@ void ui_menu_remove_folder::custom_render(void *selectedref, float top, float bo ui().draw_text_full(container, tempbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); } + +} // namespace ui diff --git a/src/frontend/mame/ui/dirmenu.h b/src/frontend/mame/ui/dirmenu.h index 223776e44d1..17cf28726aa 100644 --- a/src/frontend/mame/ui/dirmenu.h +++ b/src/frontend/mame/ui/dirmenu.h @@ -10,18 +10,25 @@ #pragma once -#ifndef __UI_DIRMENU_H__ -#define __UI_DIRMENU_H__ +#ifndef MAME_FRONTEND_UI_DIRMENU_H +#define MAME_FRONTEND_UI_DIRMENU_H + +#include "ui/menu.h" + +#include +#include + +namespace ui { //------------------------------------------------- // class directory menu //------------------------------------------------- -class ui_menu_directory : public ui_menu +class menu_directory : public menu { public: - ui_menu_directory(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_directory(); + menu_directory(mame_ui_manager &mui, render_container *container); + virtual ~menu_directory() override; virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -31,11 +38,11 @@ public: // class directory specific menu //------------------------------------------------- -class ui_menu_display_actual : public ui_menu +class menu_display_actual : public menu { public: - ui_menu_display_actual(mame_ui_manager &mui, render_container *container, int selectedref); - virtual ~ui_menu_display_actual(); + menu_display_actual(mame_ui_manager &mui, render_container *container, int selectedref); + virtual ~menu_display_actual() override; virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -56,11 +63,11 @@ private: // class remove folder menu //------------------------------------------------- -class ui_menu_remove_folder : public ui_menu +class menu_remove_folder : public menu { public: - ui_menu_remove_folder(mame_ui_manager &mui, render_container *container, int ref); - virtual ~ui_menu_remove_folder(); + menu_remove_folder(mame_ui_manager &mui, render_container *container, int ref); + virtual ~menu_remove_folder() override; virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -75,11 +82,11 @@ private: // class add / change folder menu //------------------------------------------------- -class ui_menu_add_change_folder : public ui_menu +class menu_add_change_folder : public menu { public: - ui_menu_add_change_folder(mame_ui_manager &mui, render_container *container, int ref); - virtual ~ui_menu_add_change_folder(); + menu_add_change_folder(mame_ui_manager &mui, render_container *container, int ref); + virtual ~menu_add_change_folder() override; virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -94,4 +101,6 @@ private: std::vector m_folders; }; -#endif /* __UI_DIRMENU_H__ */ +} // namesapce ui + +#endif /* MAME_FRONTEND_UI_DIRMENU_H */ diff --git a/src/frontend/mame/ui/filemngr.cpp b/src/frontend/mame/ui/filemngr.cpp index ac455d4c591..ee24c78aa33 100644 --- a/src/frontend/mame/ui/filemngr.cpp +++ b/src/frontend/mame/ui/filemngr.cpp @@ -22,6 +22,8 @@ #include "softlist.h" +namespace ui { + /*************************************************************************** FILE MANAGER ***************************************************************************/ @@ -30,7 +32,7 @@ // ctor //------------------------------------------------- -ui_menu_file_manager::ui_menu_file_manager(mame_ui_manager &mui, render_container *container, const char *warnings) : ui_menu(mui, container), selected_device(nullptr) +menu_file_manager::menu_file_manager(mame_ui_manager &mui, render_container *container, const char *warnings) : menu(mui, container), selected_device(nullptr) { // This warning string is used when accessing from the force_file_manager call, i.e. // when the file manager is loaded top front in the case of mandatory image devices @@ -47,7 +49,7 @@ ui_menu_file_manager::ui_menu_file_manager(mame_ui_manager &mui, render_containe // dtor //------------------------------------------------- -ui_menu_file_manager::~ui_menu_file_manager() +menu_file_manager::~menu_file_manager() { } @@ -56,7 +58,7 @@ ui_menu_file_manager::~ui_menu_file_manager() // custom_render - perform our special rendering //------------------------------------------------- -void ui_menu_file_manager::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_file_manager::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { const char *path; @@ -66,7 +68,7 @@ void ui_menu_file_manager::custom_render(void *selectedref, float top, float bot } -void ui_menu_file_manager::fill_image_line(device_image_interface *img, std::string &instance, std::string &filename) +void menu_file_manager::fill_image_line(device_image_interface *img, std::string &instance, std::string &filename) { // get the image type/id instance = string_format("%s (%s)", img->instance_name(), img->brief_instance_name()); @@ -102,15 +104,15 @@ void ui_menu_file_manager::fill_image_line(device_image_interface *img, std::str // populate //------------------------------------------------- -void ui_menu_file_manager::populate() +void menu_file_manager::populate() { std::string tmp_inst, tmp_name; bool first_entry = true; if (!m_warnings.empty()) { - item_append(m_warnings.c_str(), nullptr, MENU_FLAG_DISABLE, nullptr); - item_append("", nullptr, MENU_FLAG_DISABLE, nullptr); + item_append(m_warnings.c_str(), nullptr, FLAG_DISABLE, nullptr); + item_append("", nullptr, FLAG_DISABLE, nullptr); } // cycle through all devices for this system @@ -141,7 +143,7 @@ void ui_menu_file_manager::populate() if (first_entry) first_entry = false; else - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); item_append(string_format("[root%s]", dev.tag()).c_str(), nullptr, 0, nullptr); tag_appended = true; } @@ -152,7 +154,7 @@ void ui_menu_file_manager::populate() } } } - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); item_append("Reset", nullptr, 0, (void *)1); custombottom = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; @@ -163,10 +165,10 @@ void ui_menu_file_manager::populate() // handle //------------------------------------------------- -void ui_menu_file_manager::handle() +void menu_file_manager::handle() { // process the menu - const ui_menu_event *event = process(0); + const event *event = process(0); if (event != nullptr && event->itemref != nullptr && event->iptkey == IPT_UI_SELECT) { if ((FPTR)event->itemref == 1) @@ -183,30 +185,28 @@ void ui_menu_file_manager::handle() floppy_image_device *floppy_device = dynamic_cast(selected_device); if (floppy_device != nullptr) { - ui_menu::stack_push(global_alloc_clear(ui(), container, floppy_device)); + menu::stack_push(ui(), container, floppy_device); } else { - ui_menu::stack_push(global_alloc_clear(ui(), container, selected_device)); + menu::stack_push(ui(), container, selected_device); } // reset the existing menu - reset(UI_MENU_RESET_REMEMBER_POSITION); + reset(reset_options::REMEMBER_POSITION); } } } } // force file manager menu -void ui_menu_file_manager::force_file_manager(mame_ui_manager &mui, render_container *container, const char *warnings) +void menu_file_manager::force_file_manager(mame_ui_manager &mui, render_container *container, const char *warnings) { // reset the menu stack - ui_menu::stack_reset(mui.machine()); + menu::stack_reset(mui.machine()); // add the quit entry followed by the game select entry - ui_menu *quit = global_alloc_clear(mui, container); - quit->set_special_main_menu(true); - ui_menu::stack_push(quit); - ui_menu::stack_push(global_alloc_clear(mui, container, warnings)); + menu::stack_push_special_main(mui, container); + menu::stack_push(mui, container, warnings); // force the menus on mui.show_menu(); @@ -214,3 +214,5 @@ void ui_menu_file_manager::force_file_manager(mame_ui_manager &mui, render_conta // make sure MAME is paused mui.machine().pause(); } + +} // namespace ui \ No newline at end of file diff --git a/src/frontend/mame/ui/filemngr.h b/src/frontend/mame/ui/filemngr.h index 74c1c6dcacf..4fa88531290 100644 --- a/src/frontend/mame/ui/filemngr.h +++ b/src/frontend/mame/ui/filemngr.h @@ -10,10 +10,13 @@ #pragma once -#ifndef __UI_FILEMNGR_H__ -#define __UI_FILEMNGR_H__ +#ifndef MAME_FRONTEND_UI_FILEMNGR_H +#define MAME_FRONTEND_UI_FILEMNGR_H -class ui_menu_file_manager : public ui_menu { +namespace ui { + +class menu_file_manager : public menu +{ public: std::string current_directory; std::string current_file; @@ -21,8 +24,8 @@ public: static void force_file_manager(mame_ui_manager &mui, render_container *container, const char *warnings); - ui_menu_file_manager(mame_ui_manager &mui, render_container *container, const char *warnings); - virtual ~ui_menu_file_manager(); + menu_file_manager(mame_ui_manager &mui, render_container *container, const char *warnings); + virtual ~menu_file_manager(); virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -34,4 +37,6 @@ private: bool m_curr_selected; }; -#endif /* __UI_FILEMNGR_H__ */ +} // namespace ui + +#endif /* MAME_FRONTEND_UI_FILEMNGR_H */ diff --git a/src/frontend/mame/ui/filesel.cpp b/src/frontend/mame/ui/filesel.cpp index c9c22010d55..5077d7d0a53 100644 --- a/src/frontend/mame/ui/filesel.cpp +++ b/src/frontend/mame/ui/filesel.cpp @@ -13,15 +13,19 @@ ***************************************************************************/ #include "emu.h" -#include "ui/ui.h" -#include "ui/menu.h" -#include "zippath.h" + #include "ui/filesel.h" +#include "ui/ui.h" + #include "imagedev/floppy.h" +#include "zippath.h" + #include +namespace ui { + /*************************************************************************** CONSTANTS ***************************************************************************/ @@ -74,8 +78,8 @@ static void input_character(char *buffer, size_t buffer_length, unicode_char uni // ctor //------------------------------------------------- -ui_menu_confirm_save_as::ui_menu_confirm_save_as(mame_ui_manager &mui, render_container *container, bool *yes) - : ui_menu(mui, container) +menu_confirm_save_as::menu_confirm_save_as(mame_ui_manager &mui, render_container *container, bool *yes) + : menu(mui, container) { m_yes = yes; *m_yes = false; @@ -86,7 +90,7 @@ ui_menu_confirm_save_as::ui_menu_confirm_save_as(mame_ui_manager &mui, render_co // dtor //------------------------------------------------- -ui_menu_confirm_save_as::~ui_menu_confirm_save_as() +menu_confirm_save_as::~menu_confirm_save_as() { } @@ -95,10 +99,10 @@ ui_menu_confirm_save_as::~ui_menu_confirm_save_as() // populate //------------------------------------------------- -void ui_menu_confirm_save_as::populate() +void menu_confirm_save_as::populate() { - item_append(_("File Already Exists - Override?"), nullptr, MENU_FLAG_DISABLE, nullptr); - item_append(MENU_SEPARATOR_ITEM, nullptr, MENU_FLAG_DISABLE, nullptr); + item_append(_("File Already Exists - Override?"), nullptr, FLAG_DISABLE, nullptr); + item_append(MENU_SEPARATOR_ITEM, nullptr, FLAG_DISABLE, nullptr); item_append(_("No"), nullptr, 0, ITEMREF_NO); item_append(_("Yes"), nullptr, 0, ITEMREF_YES); } @@ -107,10 +111,10 @@ void ui_menu_confirm_save_as::populate() // handle - confirm save as menu //------------------------------------------------- -void ui_menu_confirm_save_as::handle() +void menu_confirm_save_as::handle() { // process the menu - const ui_menu_event *event = process(0); + const event *event = process(0); // process the event if ((event != nullptr) && (event->iptkey == IPT_UI_SELECT)) @@ -119,7 +123,7 @@ void ui_menu_confirm_save_as::handle() *m_yes = true; // no matter what, pop out - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); } } @@ -156,11 +160,11 @@ static int is_valid_filename_char(unicode_char unichar) // ctor //------------------------------------------------- -ui_menu_file_create::ui_menu_file_create(mame_ui_manager &mui, render_container *container, device_image_interface *image, std::string ¤t_directory, std::string ¤t_file, bool *ok) - : ui_menu(mui, container), - m_current_directory(current_directory), - m_current_file(current_file), - m_current_format(nullptr) +menu_file_create::menu_file_create(mame_ui_manager &mui, render_container *container, device_image_interface *image, std::string ¤t_directory, std::string ¤t_file, bool *ok) + : menu(mui, container) + , m_current_directory(current_directory) + , m_current_file(current_file) + , m_current_format(nullptr) { m_image = image; m_ok = ok; @@ -174,7 +178,7 @@ ui_menu_file_create::ui_menu_file_create(mame_ui_manager &mui, render_container // dtor //------------------------------------------------- -ui_menu_file_create::~ui_menu_file_create() +menu_file_create::~menu_file_create() { } @@ -183,7 +187,7 @@ ui_menu_file_create::~ui_menu_file_create() // custom_render - perform our special rendering //------------------------------------------------- -void ui_menu_file_create::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_file_create::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { extra_text_render(top, bottom, origx1, origy1, origx2, origy2, m_current_directory.c_str(), @@ -195,7 +199,7 @@ void ui_menu_file_create::custom_render(void *selectedref, float top, float bott // populate - populates the file creator menu //------------------------------------------------- -void ui_menu_file_create::populate() +void menu_file_create::populate() { std::string buffer; const image_device_format *format; @@ -222,7 +226,7 @@ void ui_menu_file_create::populate() } // finish up the menu - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); item_append(_("Create"), nullptr, 0, ITEMREF_CREATE); customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; @@ -233,10 +237,10 @@ void ui_menu_file_create::populate() // handle - file creator menu //------------------------------------------------- -void ui_menu_file_create::handle() +void menu_file_create::handle() { // process the menu - const ui_menu_event *event = process(0); + const event *event = process(0); // process the event if (event != nullptr) @@ -251,7 +255,7 @@ void ui_menu_file_create::handle() if (tmp_file.find(".") != -1 && tmp_file.find(".") < tmp_file.length() - 1) { m_current_file = m_filename_buffer; - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); } else ui().popup_time(1, "%s", _("Please enter a file extension too")); @@ -266,7 +270,7 @@ void ui_menu_file_create::handle() ARRAY_LENGTH(m_filename_buffer), event->unichar, is_valid_filename_char); - reset(UI_MENU_RESET_REMEMBER_POSITION); + reset(reset_options::REMEMBER_POSITION); } break; case IPT_UI_CANCEL: @@ -284,11 +288,11 @@ void ui_menu_file_create::handle() // ctor //------------------------------------------------- -ui_menu_file_selector::ui_menu_file_selector(mame_ui_manager &mui, render_container *container, device_image_interface *image, std::string ¤t_directory, std::string ¤t_file, bool has_empty, bool has_softlist, bool has_create, int *result) - : ui_menu(mui, container), - m_current_directory(current_directory), - m_current_file(current_file), - m_entrylist(nullptr) +menu_file_selector::menu_file_selector(mame_ui_manager &mui, render_container *container, device_image_interface *image, std::string ¤t_directory, std::string ¤t_file, bool has_empty, bool has_softlist, bool has_create, int *result) + : menu(mui, container) + , m_current_directory(current_directory) + , m_current_file(current_file) + , m_entrylist(nullptr) { m_image = image; m_has_empty = has_empty; @@ -302,7 +306,7 @@ ui_menu_file_selector::ui_menu_file_selector(mame_ui_manager &mui, render_contai // dtor //------------------------------------------------- -ui_menu_file_selector::~ui_menu_file_selector() +menu_file_selector::~menu_file_selector() { } @@ -311,7 +315,7 @@ ui_menu_file_selector::~ui_menu_file_selector() // custom_render - perform our special rendering //------------------------------------------------- -void ui_menu_file_selector::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_file_selector::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { extra_text_render(top, bottom, origx1, origy1, origx2, origy2, @@ -326,7 +330,7 @@ void ui_menu_file_selector::custom_render(void *selectedref, float top, float bo // for file selector entries //------------------------------------------------- -int ui_menu_file_selector::compare_entries(const file_selector_entry *e1, const file_selector_entry *e2) +int menu_file_selector::compare_entries(const file_selector_entry *e1, const file_selector_entry *e2) { int result; const char *e1_basename = (e1->basename != nullptr) ? e1->basename : ""; @@ -365,7 +369,7 @@ int ui_menu_file_selector::compare_entries(const file_selector_entry *e1, const // file selector entry to an entry list //------------------------------------------------- -ui_menu_file_selector::file_selector_entry *ui_menu_file_selector::append_entry( +menu_file_selector::file_selector_entry *menu_file_selector::append_entry( file_selector_entry_type entry_type, const char *entry_basename, const char *entry_fullpath) { file_selector_entry *entry; @@ -395,7 +399,7 @@ ui_menu_file_selector::file_selector_entry *ui_menu_file_selector::append_entry( // a menu item for a file selector entry //------------------------------------------------- -ui_menu_file_selector::file_selector_entry *ui_menu_file_selector::append_dirent_entry(const osd_directory_entry *dirent) +menu_file_selector::file_selector_entry *menu_file_selector::append_dirent_entry(const osd_directory_entry *dirent) { std::string buffer; file_selector_entry_type entry_type; @@ -434,7 +438,7 @@ ui_menu_file_selector::file_selector_entry *ui_menu_file_selector::append_dirent // a menu item for a file selector entry //------------------------------------------------- -void ui_menu_file_selector::append_entry_menu_item(const file_selector_entry *entry) +void menu_file_selector::append_entry_menu_item(const file_selector_entry *entry) { const char *text = nullptr; const char *subtext = nullptr; @@ -476,7 +480,7 @@ void ui_menu_file_selector::append_entry_menu_item(const file_selector_entry *en // populate //------------------------------------------------- -void ui_menu_file_selector::populate() +void menu_file_selector::populate() { util::zippath_directory *directory = nullptr; osd_file::error err; @@ -562,7 +566,7 @@ void ui_menu_file_selector::populate() // handle //------------------------------------------------- -void ui_menu_file_selector::handle() +void menu_file_selector::handle() { osd_file::error err; const file_selector_entry *entry; @@ -570,7 +574,7 @@ void ui_menu_file_selector::handle() int bestmatch = 0; // process the menu - const ui_menu_event *event = process(0); + const event *event = process(0); if (event != nullptr && event->itemref != nullptr) { // handle selections @@ -582,18 +586,18 @@ void ui_menu_file_selector::handle() case SELECTOR_ENTRY_TYPE_EMPTY: // empty slot - unload *m_result = R_EMPTY; - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); break; case SELECTOR_ENTRY_TYPE_CREATE: // create *m_result = R_CREATE; - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); break; case SELECTOR_ENTRY_TYPE_SOFTWARE_LIST: *m_result = R_SOFTLIST; - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); break; case SELECTOR_ENTRY_TYPE_DRIVE: @@ -607,14 +611,14 @@ void ui_menu_file_selector::handle() break; } m_current_directory.assign(entry->fullpath); - reset((ui_menu_reset_options)0); + reset(reset_options::SELECT_FIRST); break; case SELECTOR_ENTRY_TYPE_FILE: // file m_current_file.assign(entry->fullpath); *m_result = R_FILE; - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); break; } @@ -717,8 +721,8 @@ void ui_menu_file_selector::handle() // ctor //------------------------------------------------- -ui_menu_select_format::ui_menu_select_format(mame_ui_manager &mui, render_container *container, floppy_image_format_t **formats, int ext_match, int total_usable, int *result) - : ui_menu(mui, container) +menu_select_format::menu_select_format(mame_ui_manager &mui, render_container *container, floppy_image_format_t **formats, int ext_match, int total_usable, int *result) + : menu(mui, container) { m_formats = formats; m_ext_match = ext_match; @@ -731,7 +735,7 @@ ui_menu_select_format::ui_menu_select_format(mame_ui_manager &mui, render_contai // dtor //------------------------------------------------- -ui_menu_select_format::~ui_menu_select_format() +menu_select_format::~menu_select_format() { } @@ -740,15 +744,15 @@ ui_menu_select_format::~ui_menu_select_format() // populate //------------------------------------------------- -void ui_menu_select_format::populate() +void menu_select_format::populate() { - item_append(_("Select image format"), nullptr, MENU_FLAG_DISABLE, nullptr); + item_append(_("Select image format"), nullptr, FLAG_DISABLE, nullptr); for (int i = 0; i < m_total_usable; i++) { const floppy_image_format_t *fmt = m_formats[i]; if (i && i == m_ext_match) - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); item_append(fmt->description(), fmt->name(), 0, (void *)(FPTR)i); } } @@ -758,14 +762,14 @@ void ui_menu_select_format::populate() // handle //------------------------------------------------- -void ui_menu_select_format::handle() +void menu_select_format::handle() { // process the menu - const ui_menu_event *event = process(0); + const event *event = process(0); if (event != nullptr && event->iptkey == IPT_UI_SELECT) { *m_result = int(FPTR(event->itemref)); - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); } } @@ -778,9 +782,9 @@ void ui_menu_select_format::handle() // ctor //------------------------------------------------- -ui_menu_select_rw::ui_menu_select_rw(mame_ui_manager &mui, render_container *container, +menu_select_rw::menu_select_rw(mame_ui_manager &mui, render_container *container, bool can_in_place, int *result) - : ui_menu(mui, container) + : menu(mui, container) { m_can_in_place = can_in_place; m_result = result; @@ -791,7 +795,7 @@ ui_menu_select_rw::ui_menu_select_rw(mame_ui_manager &mui, render_container *con // dtor //------------------------------------------------- -ui_menu_select_rw::~ui_menu_select_rw() +menu_select_rw::~menu_select_rw() { } @@ -800,9 +804,9 @@ ui_menu_select_rw::~ui_menu_select_rw() // populate //------------------------------------------------- -void ui_menu_select_rw::populate() +void menu_select_rw::populate() { - item_append(_("Select access mode"), nullptr, MENU_FLAG_DISABLE, nullptr); + item_append(_("Select access mode"), nullptr, FLAG_DISABLE, nullptr); item_append(_("Read-only"), nullptr, 0, (void *)READONLY); if (m_can_in_place) item_append(_("Read-write"), nullptr, 0, (void *)READWRITE); @@ -815,13 +819,15 @@ void ui_menu_select_rw::populate() // handle //------------------------------------------------- -void ui_menu_select_rw::handle() +void menu_select_rw::handle() { // process the menu - const ui_menu_event *event = process(0); + const event *event = process(0); if (event != nullptr && event->iptkey == IPT_UI_SELECT) { *m_result = int(FPTR(event->itemref)); - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); } } + +} // namespace ui diff --git a/src/frontend/mame/ui/filesel.h b/src/frontend/mame/ui/filesel.h index decf940253f..e7988ed7912 100644 --- a/src/frontend/mame/ui/filesel.h +++ b/src/frontend/mame/ui/filesel.h @@ -10,16 +10,22 @@ #pragma once -#ifndef __UI_FILESEL_H__ -#define __UI_FILESEL_H__ +#ifndef MAME_FRONTEND_UI_FILESEL_H +#define MAME_FRONTEND_UI_FILESEL_H -// ======================> ui_menu_confirm_save_as +#include "ui/menu.h" -class ui_menu_confirm_save_as : public ui_menu +class floppy_image_format_t; + +namespace ui { + +// ======================> menu_confirm_save_as + +class menu_confirm_save_as : public menu { public: - ui_menu_confirm_save_as(mame_ui_manager &mui, render_container *container, bool *yes); - virtual ~ui_menu_confirm_save_as(); + menu_confirm_save_as(mame_ui_manager &mui, render_container *container, bool *yes); + virtual ~menu_confirm_save_as() override; virtual void populate() override; virtual void handle() override; @@ -28,13 +34,13 @@ private: }; -// ======================> ui_menu_file_create +// ======================> menu_file_create -class ui_menu_file_create : public ui_menu +class menu_file_create : public menu { public: - ui_menu_file_create(mame_ui_manager &mui, render_container *container, device_image_interface *image, std::string ¤t_directory, std::string ¤t_file, bool *ok); - virtual ~ui_menu_file_create(); + menu_file_create(mame_ui_manager &mui, render_container *container, device_image_interface *image, std::string ¤t_directory, std::string ¤t_file, bool *ok); + virtual ~menu_file_create() override; virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -51,14 +57,14 @@ protected: }; -// ======================> ui_menu_file_selector +// ======================> menu_file_selector -class ui_menu_file_selector : public ui_menu +class menu_file_selector : public menu { public: enum { R_EMPTY, R_SOFTLIST, R_CREATE, R_FILE }; - ui_menu_file_selector(mame_ui_manager &mui, render_container *container, device_image_interface *image, std::string ¤t_directory, std::string ¤t_file, bool has_empty, bool has_softlist, bool has_create, int *result); - virtual ~ui_menu_file_selector(); + menu_file_selector(mame_ui_manager &mui, render_container *container, device_image_interface *image, std::string ¤t_directory, std::string ¤t_file, bool has_empty, bool has_softlist, bool has_create, int *result); + virtual ~menu_file_selector() override; virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -102,14 +108,14 @@ private: }; -// ======================> ui_menu_select_format +// ======================> menu_select_format -class ui_menu_select_format : public ui_menu +class menu_select_format : public menu { public: - ui_menu_select_format(mame_ui_manager &mui, render_container *container, - class floppy_image_format_t **formats, int ext_match, int total_usable, int *result); - virtual ~ui_menu_select_format(); + menu_select_format(mame_ui_manager &mui, render_container *container, + floppy_image_format_t **formats, int ext_match, int total_usable, int *result); + virtual ~menu_select_format() override; virtual void populate() override; virtual void handle() override; @@ -122,15 +128,15 @@ private: }; -// ======================> ui_menu_select_rw +// ======================> menu_select_rw -class ui_menu_select_rw : public ui_menu +class menu_select_rw : public menu { public: enum { READONLY, READWRITE, WRITE_OTHER, WRITE_DIFF }; - ui_menu_select_rw(mame_ui_manager &mui, render_container *container, + menu_select_rw(mame_ui_manager &mui, render_container *container, bool can_in_place, int *result); - virtual ~ui_menu_select_rw(); + virtual ~menu_select_rw() override; virtual void populate() override; virtual void handle() override; @@ -140,4 +146,6 @@ private: int * m_result; }; -#endif /* __UI_FILESEL_H__ */ +} // namespace ui + +#endif /* MAME_FRONTEND_UI_FILESEL_H */ diff --git a/src/frontend/mame/ui/floppycntrl.cpp b/src/frontend/mame/ui/floppycntrl.cpp index a8ffc764a4b..e80f51babcb 100644 --- a/src/frontend/mame/ui/floppycntrl.cpp +++ b/src/frontend/mame/ui/floppycntrl.cpp @@ -7,17 +7,20 @@ ***************************************************************************/ #include "emu.h" -#include "zippath.h" -#include "ui/menu.h" -#include "ui/imgcntrl.h" + #include "ui/filesel.h" #include "ui/floppycntrl.h" +#include "zippath.h" + + +namespace ui { + /*************************************************************************** IMPLEMENTATION ***************************************************************************/ -ui_menu_control_floppy_image::ui_menu_control_floppy_image(mame_ui_manager &mui, render_container *container, device_image_interface *_image) : ui_menu_control_device_image(mui, container, _image) +menu_control_floppy_image::menu_control_floppy_image(mame_ui_manager &mui, render_container *container, device_image_interface *_image) : menu_control_device_image(mui, container, _image) { floppy_image_device *fd = static_cast(image); const floppy_image_format_t *fif_list = fd->get_formats(); @@ -30,12 +33,12 @@ ui_menu_control_floppy_image::ui_menu_control_floppy_image(mame_ui_manager &mui, input_filename = output_filename = ""; } -ui_menu_control_floppy_image::~ui_menu_control_floppy_image() +menu_control_floppy_image::~menu_control_floppy_image() { global_free_array(format_array); } -void ui_menu_control_floppy_image::do_load_create() +void menu_control_floppy_image::do_load_create() { floppy_image_device *fd = static_cast(image); if(input_filename.compare("")==0) { @@ -58,13 +61,13 @@ void ui_menu_control_floppy_image::do_load_create() } } -void ui_menu_control_floppy_image::hook_load(std::string filename, bool softlist) +void menu_control_floppy_image::hook_load(std::string filename, bool softlist) { if (softlist) { machine().popmessage("When loaded from software list, the disk is Read-only.\n"); image->load(filename.c_str()); - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); return; } @@ -74,7 +77,7 @@ void ui_menu_control_floppy_image::hook_load(std::string filename, bool softlist if (!input_format) { machine().popmessage("Error: %s\n", image->error()); - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); return; } @@ -91,11 +94,11 @@ void ui_menu_control_floppy_image::hook_load(std::string filename, bool softlist can_in_place = false; } submenu_result = -1; - ui_menu::stack_push(global_alloc_clear(ui(), container, can_in_place, &submenu_result)); + menu::stack_push(ui(), container, can_in_place, &submenu_result); state = SELECT_RW; } -void ui_menu_control_floppy_image::handle() +void menu_control_floppy_image::handle() { floppy_image_device *fd = static_cast(image); switch (state) { @@ -117,7 +120,7 @@ void ui_menu_control_floppy_image::handle() format_array[total_usable++] = i; } submenu_result = -1; - ui_menu::stack_push(global_alloc_clear(ui(), container, format_array, ext_match, total_usable, &submenu_result)); + menu::stack_push(ui(), container, format_array, ext_match, total_usable, &submenu_result); state = SELECT_FORMAT; break; @@ -131,30 +134,30 @@ void ui_menu_control_floppy_image::handle() util::zippath_combine(output_filename, current_directory.c_str(), current_file.c_str()); output_format = format_array[submenu_result]; do_load_create(); - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); } break; case SELECT_RW: switch(submenu_result) { - case ui_menu_select_rw::READONLY: + case menu_select_rw::READONLY: do_load_create(); - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); break; - case ui_menu_select_rw::READWRITE: + case menu_select_rw::READWRITE: output_format = input_format; do_load_create(); - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); break; - case ui_menu_select_rw::WRITE_DIFF: + case menu_select_rw::WRITE_DIFF: machine().popmessage("Sorry, diffs are not supported yet\n"); - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); break; - case ui_menu_select_rw::WRITE_OTHER: - ui_menu::stack_push(global_alloc_clear(ui(), container, image, current_directory, current_file, &create_ok)); + case menu_select_rw::WRITE_OTHER: + menu::stack_push(ui(), container, image, current_directory, current_file, &create_ok); state = CHECK_CREATE; break; @@ -165,6 +168,8 @@ void ui_menu_control_floppy_image::handle() break; default: - ui_menu_control_device_image::handle(); + menu_control_device_image::handle(); } } + +} // namespace ui diff --git a/src/frontend/mame/ui/floppycntrl.h b/src/frontend/mame/ui/floppycntrl.h index 6a5e7dae054..2c9cc310c0d 100644 --- a/src/frontend/mame/ui/floppycntrl.h +++ b/src/frontend/mame/ui/floppycntrl.h @@ -8,16 +8,21 @@ #pragma once -#ifndef __UI_FLOPPY_IMAGE_H__ -#define __UI_FLOPPY_IMAGE_H__ +#ifndef MAME_FRONTEND_UI_FLOPPYCNTRL_H +#define MAME_FRONTEND_UI_FLOPPYCNTRL_H + +#include "ui/imgcntrl.h" #include "imagedev/floppy.h" #include "formats/flopimg.h" -class ui_menu_control_floppy_image : public ui_menu_control_device_image { +namespace ui { + +class menu_control_floppy_image : public menu_control_device_image +{ public: - ui_menu_control_floppy_image(mame_ui_manager &ui, render_container *container, device_image_interface *image); - virtual ~ui_menu_control_floppy_image(); + menu_control_floppy_image(mame_ui_manager &ui, render_container *container, device_image_interface *image); + virtual ~menu_control_floppy_image() override; virtual void handle() override; @@ -32,5 +37,6 @@ protected: virtual void hook_load(std::string filename, bool softlist) override; }; +} // namespace ui -#endif /* __UI_FLOPPY_IMAGE_H__ */ +#endif /* MAME_FRONTEND_UI_FLOPPYCNTRL_H */ diff --git a/src/frontend/mame/ui/imgcntrl.cpp b/src/frontend/mame/ui/imgcntrl.cpp index bf83c7c21d0..bc713bbca53 100644 --- a/src/frontend/mame/ui/imgcntrl.cpp +++ b/src/frontend/mame/ui/imgcntrl.cpp @@ -9,17 +9,21 @@ ***************************************************************************/ #include "emu.h" -#include "emuopts.h" -#include "ui/ui.h" -#include "ui/menu.h" + #include "ui/imgcntrl.h" + +#include "ui/ui.h" #include "ui/filesel.h" #include "ui/swlist.h" -#include "zippath.h" -#include "drivenum.h" -#include "audit.h" -#include "softlist.h" +#include "audit.h" +#include "drivenum.h" +#include "emuopts.h" +#include "softlist.h" +#include "zippath.h" + + +namespace ui { /*************************************************************************** IMPLEMENTATION @@ -29,8 +33,8 @@ // ctor //------------------------------------------------- -ui_menu_control_device_image::ui_menu_control_device_image(mame_ui_manager &mui, render_container *container, device_image_interface *_image) - : ui_menu(mui, container), +menu_control_device_image::menu_control_device_image(mame_ui_manager &mui, render_container *container, device_image_interface *_image) + : menu(mui, container), submenu_result(0), create_ok(false), create_confirmed(false) @@ -72,7 +76,7 @@ ui_menu_control_device_image::ui_menu_control_device_image(mame_ui_manager &mui, // dtor //------------------------------------------------- -ui_menu_control_device_image::~ui_menu_control_device_image() +menu_control_device_image::~menu_control_device_image() { } @@ -81,7 +85,7 @@ ui_menu_control_device_image::~ui_menu_control_device_image() // test_create - creates a new disk image //------------------------------------------------- -void ui_menu_control_device_image::test_create(bool &can_create, bool &need_confirm) +void menu_control_device_image::test_create(bool &can_create, bool &need_confirm) { std::string path; osd_directory_entry *entry; @@ -130,7 +134,7 @@ void ui_menu_control_device_image::test_create(bool &can_create, bool &need_conf // load_software_part //------------------------------------------------- -void ui_menu_control_device_image::load_software_part() +void menu_control_device_image::load_software_part() { std::string temp_name = std::string(sld->list_name()).append(":").append(swi->shortname()).append(":").append(swp->name()); @@ -153,11 +157,11 @@ void ui_menu_control_device_image::load_software_part() // hook_load //------------------------------------------------- -void ui_menu_control_device_image::hook_load(std::string name, bool softlist) +void menu_control_device_image::hook_load(std::string name, bool softlist) { if (image->is_reset_on_load()) image->set_init_phase(); image->load(name.c_str()); - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); } @@ -165,7 +169,7 @@ void ui_menu_control_device_image::hook_load(std::string name, bool softlist) // populate //------------------------------------------------- -void ui_menu_control_device_image::populate() +void menu_control_device_image::populate() { } @@ -174,7 +178,7 @@ void ui_menu_control_device_image::populate() // handle //------------------------------------------------- -void ui_menu_control_device_image::handle() +void menu_control_device_image::handle() { switch(state) { case START_FILE: { @@ -187,31 +191,31 @@ void ui_menu_control_device_image::handle() util::zippath_closedir(directory); } submenu_result = -1; - ui_menu::stack_push(global_alloc_clear(ui(), container, image, current_directory, current_file, true, image->image_interface()!=nullptr, can_create, &submenu_result)); + menu::stack_push(ui(), container, image, current_directory, current_file, true, image->image_interface()!=nullptr, can_create, &submenu_result); state = SELECT_FILE; break; } case START_SOFTLIST: sld = nullptr; - ui_menu::stack_push(global_alloc_clear(ui(), container, image->image_interface(), &sld)); + menu::stack_push(ui(), container, image->image_interface(), &sld); state = SELECT_SOFTLIST; break; case START_OTHER_PART: { submenu_result = -1; - ui_menu::stack_push(global_alloc_clear(ui(), container, swi, swp->interface(), &swp, true, &submenu_result)); + menu::stack_push(ui(), container, swi, swp->interface(), &swp, true, &submenu_result); state = SELECT_OTHER_PART; break; } case SELECT_SOFTLIST: if(!sld) { - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); break; } software_info_name = ""; - ui_menu::stack_push(global_alloc_clear(ui(), container, sld, image->image_interface(), software_info_name)); + menu::stack_push(ui(), container, sld, image->image_interface(), software_info_name); state = SELECT_PARTLIST; break; @@ -223,7 +227,7 @@ void ui_menu_control_device_image::handle() { submenu_result = -1; swp = nullptr; - ui_menu::stack_push(global_alloc_clear(ui(), container, swi, image->image_interface(), &swp, false, &submenu_result)); + menu::stack_push(ui(), container, swi, image->image_interface(), &swp, false, &submenu_result); state = SELECT_ONE_PART; } else @@ -235,7 +239,7 @@ void ui_menu_control_device_image::handle() case SELECT_ONE_PART: switch(submenu_result) { - case ui_menu_software_parts::T_ENTRY: { + case menu_software_parts::T_ENTRY: { load_software_part(); break; } @@ -249,27 +253,27 @@ void ui_menu_control_device_image::handle() case SELECT_OTHER_PART: switch(submenu_result) { - case ui_menu_software_parts::T_ENTRY: + case menu_software_parts::T_ENTRY: load_software_part(); break; - case ui_menu_software_parts::T_FMGR: + case menu_software_parts::T_FMGR: state = START_FILE; handle(); break; - case ui_menu_software_parts::T_EMPTY: + case menu_software_parts::T_EMPTY: image->unload(); - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); break; - case ui_menu_software_parts::T_SWLIST: + case menu_software_parts::T_SWLIST: state = START_SOFTLIST; handle(); break; case -1: // return to system - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); break; } @@ -277,27 +281,27 @@ void ui_menu_control_device_image::handle() case SELECT_FILE: switch(submenu_result) { - case ui_menu_file_selector::R_EMPTY: + case menu_file_selector::R_EMPTY: image->unload(); - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); break; - case ui_menu_file_selector::R_FILE: + case menu_file_selector::R_FILE: hook_load(current_file, false); break; - case ui_menu_file_selector::R_CREATE: - ui_menu::stack_push(global_alloc_clear(ui(), container, image, current_directory, current_file, &create_ok)); + case menu_file_selector::R_CREATE: + menu::stack_push(ui(), container, image, current_directory, current_file, &create_ok); state = CHECK_CREATE; break; - case ui_menu_file_selector::R_SOFTLIST: + case menu_file_selector::R_SOFTLIST: state = START_SOFTLIST; handle(); break; case -1: // return to system - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); break; } break; @@ -307,7 +311,7 @@ void ui_menu_control_device_image::handle() test_create(can_create, need_confirm); if(can_create) { if(need_confirm) { - ui_menu::stack_push(global_alloc_clear(ui(), container, &create_confirmed)); + menu::stack_push(ui(), container, &create_confirmed); state = CREATE_CONFIRM; } else { state = DO_CREATE; @@ -336,8 +340,10 @@ void ui_menu_control_device_image::handle() int err = image->create(path.c_str(), nullptr, nullptr); if (err != 0) machine().popmessage("Error: %s", image->error()); - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); break; } } } + +} // namespace ui diff --git a/src/frontend/mame/ui/imgcntrl.h b/src/frontend/mame/ui/imgcntrl.h index 9af104a45f6..aac63a65702 100644 --- a/src/frontend/mame/ui/imgcntrl.h +++ b/src/frontend/mame/ui/imgcntrl.h @@ -10,15 +10,20 @@ #pragma once -#ifndef __UI_IMGCNTRL_H__ -#define __UI_IMGCNTRL_H__ +#ifndef MAME_FRONTEND_UI_IMAGECNTRL_H +#define MAME_FRONTEND_UI_IMAGECNTRL_H -// ======================> ui_menu_control_device_image +#include "ui/menu.h" -class ui_menu_control_device_image : public ui_menu { +namespace ui { + +// ======================> menu_control_device_image + +class menu_control_device_image : public menu +{ public: - ui_menu_control_device_image(mame_ui_manager &mui, render_container *container, device_image_interface *image); - virtual ~ui_menu_control_device_image(); + menu_control_device_image(mame_ui_manager &mui, render_container *container, device_image_interface *image); + virtual ~menu_control_device_image() override; virtual void populate() override; virtual void handle() override; @@ -56,5 +61,6 @@ private: void load_software_part(); }; +} // namespace ui -#endif /* __UI_IMGCNTRL_H__ */ +#endif /* MAME_FRONTEND_UI_IMAGECNTRL_H */ diff --git a/src/frontend/mame/ui/info.cpp b/src/frontend/mame/ui/info.cpp index f524413fd88..f76d14b89ce 100644 --- a/src/frontend/mame/ui/info.cpp +++ b/src/frontend/mame/ui/info.cpp @@ -9,31 +9,34 @@ ***************************************************************************/ #include "emu.h" -#include "ui/menu.h" + #include "ui/info.h" #include "ui/ui.h" + #include "softlist.h" +namespace ui { + /*------------------------------------------------- menu_game_info - handle the game information menu -------------------------------------------------*/ -ui_menu_game_info::ui_menu_game_info(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container) +menu_game_info::menu_game_info(mame_ui_manager &mui, render_container *container) : menu(mui, container) { } -ui_menu_game_info::~ui_menu_game_info() +menu_game_info::~menu_game_info() { } -void ui_menu_game_info::populate() +void menu_game_info::populate() { std::string tempstring; - item_append(ui().game_info_astring(tempstring).c_str(), nullptr, MENU_FLAG_MULTILINE, nullptr); + item_append(ui().game_info_astring(tempstring).c_str(), nullptr, FLAG_MULTILINE, nullptr); } -void ui_menu_game_info::handle() +void menu_game_info::handle() { // process the menu process(0); @@ -41,28 +44,28 @@ void ui_menu_game_info::handle() /*------------------------------------------------- - ui_menu_image_info - handle the image information + menu_image_info - handle the image information menu -------------------------------------------------*/ -ui_menu_image_info::ui_menu_image_info(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container) +menu_image_info::menu_image_info(mame_ui_manager &mui, render_container *container) : menu(mui, container) { } -ui_menu_image_info::~ui_menu_image_info() +menu_image_info::~menu_image_info() { } -void ui_menu_image_info::populate() +void menu_image_info::populate() { - item_append(machine().system().description, nullptr, MENU_FLAG_DISABLE, nullptr); - item_append("", nullptr, MENU_FLAG_DISABLE, nullptr); + item_append(machine().system().description, nullptr, FLAG_DISABLE, nullptr); + item_append("", nullptr, FLAG_DISABLE, nullptr); for (device_image_interface &image : image_interface_iterator(machine().root_device())) image_info(&image); } -void ui_menu_image_info::handle() +void menu_image_info::handle() { // process the menu process(0); @@ -74,7 +77,7 @@ void ui_menu_image_info::handle() image interface device -------------------------------------------------*/ -void ui_menu_image_info::image_info(device_image_interface *image) +void menu_image_info::image_info(device_image_interface *image) { if (image->exists()) { @@ -85,19 +88,19 @@ void ui_menu_image_info::image_info(device_image_interface *image) if (image->software_entry()) { // display long filename - item_append(image->longname(), "", MENU_FLAG_DISABLE, nullptr); + item_append(image->longname(), "", FLAG_DISABLE, nullptr); // display manufacturer and year - item_append(string_format("%s, %s", image->manufacturer(), image->year()).c_str(), "", MENU_FLAG_DISABLE, nullptr); + item_append(string_format("%s, %s", image->manufacturer(), image->year()).c_str(), "", FLAG_DISABLE, nullptr); // display supported information, if available switch (image->supported()) { case SOFTWARE_SUPPORTED_NO: - item_append(_("Not supported"), "", MENU_FLAG_DISABLE, nullptr); + item_append(_("Not supported"), "", FLAG_DISABLE, nullptr); break; case SOFTWARE_SUPPORTED_PARTIAL: - item_append(_("Partially supported"), "", MENU_FLAG_DISABLE, nullptr); + item_append(_("Partially supported"), "", FLAG_DISABLE, nullptr); break; default: break; @@ -106,5 +109,7 @@ void ui_menu_image_info::image_info(device_image_interface *image) } else item_append(image->brief_instance_name(), _("[empty]"), 0, nullptr); - item_append("", nullptr, MENU_FLAG_DISABLE, nullptr); + item_append("", nullptr, FLAG_DISABLE, nullptr); } + +} // namespace ui diff --git a/src/frontend/mame/ui/info.h b/src/frontend/mame/ui/info.h index 2815f839cd4..5e9e6719b2b 100644 --- a/src/frontend/mame/ui/info.h +++ b/src/frontend/mame/ui/info.h @@ -10,23 +10,28 @@ #pragma once -#ifndef __UI_INFO_H__ -#define __UI_INFO_H__ +#ifndef MAME_FRONTEND_UI_INFO_H +#define MAME_FRONTEND_UI_INFO_H -class ui_menu_game_info : public ui_menu { +#include "ui/menu.h" + +namespace ui { + +class menu_game_info : public menu +{ public: - ui_menu_game_info(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_game_info(); + menu_game_info(mame_ui_manager &mui, render_container *container); + virtual ~menu_game_info() override; virtual void populate() override; virtual void handle() override; }; -class ui_menu_image_info : public ui_menu +class menu_image_info : public menu { public: - ui_menu_image_info(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_image_info(); + menu_image_info(mame_ui_manager &mui, render_container *container); + virtual ~menu_image_info() override; virtual void populate() override; virtual void handle() override; @@ -34,4 +39,6 @@ private: void image_info(device_image_interface *image); }; -#endif // __UI_INFO_H__ +} // namespace ui + +#endif // MAME_FRONTEND_UI_INFO_H diff --git a/src/frontend/mame/ui/info_pty.cpp b/src/frontend/mame/ui/info_pty.cpp index e87776306e1..30567a03453 100644 --- a/src/frontend/mame/ui/info_pty.cpp +++ b/src/frontend/mame/ui/info_pty.cpp @@ -9,35 +9,40 @@ ***************************************************************************/ #include "emu.h" -#include "ui/menu.h" + #include "ui/info_pty.h" -ui_menu_pty_info::ui_menu_pty_info(mame_ui_manager &mui, render_container *container) : - ui_menu(mui, container) + +namespace ui { + +menu_pty_info::menu_pty_info(mame_ui_manager &mui, render_container *container) : + menu(mui, container) { } -ui_menu_pty_info::~ui_menu_pty_info() +menu_pty_info::~menu_pty_info() { } -void ui_menu_pty_info::populate() +void menu_pty_info::populate() { - item_append(_("Pseudo terminals"), nullptr, MENU_FLAG_DISABLE, nullptr); - item_append("", nullptr, MENU_FLAG_DISABLE, nullptr); + item_append(_("Pseudo terminals"), nullptr, FLAG_DISABLE, nullptr); + item_append("", nullptr, FLAG_DISABLE, nullptr); for (device_pty_interface &pty : pty_interface_iterator(machine().root_device())) { const char *port_name = pty.device().owner()->tag() + 1; if (pty.is_open()) - item_append(port_name, pty.slave_name(), MENU_FLAG_DISABLE, nullptr); + item_append(port_name, pty.slave_name(), FLAG_DISABLE, nullptr); else - item_append(port_name, _("[failed]"), MENU_FLAG_DISABLE, nullptr); - item_append("", nullptr, MENU_FLAG_DISABLE, nullptr); + item_append(port_name, _("[failed]"), FLAG_DISABLE, nullptr); + item_append("", nullptr, FLAG_DISABLE, nullptr); } } -void ui_menu_pty_info::handle() +void menu_pty_info::handle() { process(0); } + +} // namespace ui diff --git a/src/frontend/mame/ui/info_pty.h b/src/frontend/mame/ui/info_pty.h index d5ccc43054b..acad9005906 100644 --- a/src/frontend/mame/ui/info_pty.h +++ b/src/frontend/mame/ui/info_pty.h @@ -10,15 +10,22 @@ #pragma once -#ifndef __UI_INFO_PTY_H__ -#define __UI_INFO_PTY_H__ +#ifndef MAME_FRONTEND_UI_INFO_PTY_H +#define MAME_FRONTEND_UI_INFO_PTY_H -class ui_menu_pty_info : public ui_menu { +#include "ui/menu.h" + +namespace ui { + +class menu_pty_info : public menu +{ public: - ui_menu_pty_info(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_pty_info(); + menu_pty_info(mame_ui_manager &mui, render_container *container); + virtual ~menu_pty_info() override; virtual void populate() override; virtual void handle() override; }; -#endif // __UI_INFO_PTY_H__ +} // namespace ui + +#endif // MAME_FRONTEND_UI_INFO_PTY_H diff --git a/src/frontend/mame/ui/inputmap.cpp b/src/frontend/mame/ui/inputmap.cpp index 340b19f62ae..5552f46d38c 100644 --- a/src/frontend/mame/ui/inputmap.cpp +++ b/src/frontend/mame/ui/inputmap.cpp @@ -16,6 +16,8 @@ #include "ui/inputmap.h" +namespace ui { + /*************************************************************************** CONSTANTS ***************************************************************************/ @@ -40,11 +42,11 @@ input groups menu -------------------------------------------------*/ -ui_menu_input_groups::ui_menu_input_groups(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container) +menu_input_groups::menu_input_groups(mame_ui_manager &mui, render_container *container) : menu(mui, container) { } -void ui_menu_input_groups::populate() +void menu_input_groups::populate() { int player; @@ -59,7 +61,7 @@ void ui_menu_input_groups::populate() item_append(_("Other Controls"), nullptr, 0, (void *)(FPTR)(IPG_OTHER + 1)); } -ui_menu_input_groups::~ui_menu_input_groups() +menu_input_groups::~menu_input_groups() { } @@ -68,12 +70,12 @@ ui_menu_input_groups::~ui_menu_input_groups() menu -------------------------------------------------*/ -void ui_menu_input_groups::handle() +void menu_input_groups::handle() { /* process the menu */ - const ui_menu_event *menu_event = process(0); + const event *menu_event = process(0); if (menu_event != nullptr && menu_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container, int((long long)(menu_event->itemref)-1))); + menu::stack_push(ui(), container, int((long long)(menu_event->itemref)-1)); } @@ -83,12 +85,12 @@ void ui_menu_input_groups::handle() input menu -------------------------------------------------*/ -ui_menu_input_general::ui_menu_input_general(mame_ui_manager &mui, render_container *container, int _group) : ui_menu_input(mui, container) +menu_input_general::menu_input_general(mame_ui_manager &mui, render_container *container, int _group) : menu_input(mui, container) { group = _group; } -void ui_menu_input_general::populate() +void menu_input_general::populate() { input_item_data *itemlist = nullptr; int suborder[SEQ_TYPE_TOTAL]; @@ -137,7 +139,7 @@ void ui_menu_input_general::populate() populate_and_sort(itemlist); } -ui_menu_input_general::~ui_menu_input_general() +menu_input_general::~menu_input_general() { } @@ -146,11 +148,11 @@ ui_menu_input_general::~ui_menu_input_general() input menu -------------------------------------------------*/ -ui_menu_input_specific::ui_menu_input_specific(mame_ui_manager &mui, render_container *container) : ui_menu_input(mui, container) +menu_input_specific::menu_input_specific(mame_ui_manager &mui, render_container *container) : menu_input(mui, container) { } -void ui_menu_input_specific::populate() +void menu_input_specific::populate() { input_item_data *itemlist = nullptr; int suborder[SEQ_TYPE_TOTAL]; @@ -216,21 +218,21 @@ void ui_menu_input_specific::populate() populate_and_sort(itemlist); } -ui_menu_input_specific::~ui_menu_input_specific() +menu_input_specific::~menu_input_specific() { } /*------------------------------------------------- menu_input - display a menu for inputs -------------------------------------------------*/ -ui_menu_input::ui_menu_input(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container), last_sortorder(0), record_next(false) +menu_input::menu_input(mame_ui_manager &mui, render_container *container) : menu(mui, container), last_sortorder(0), record_next(false) { pollingitem = nullptr; pollingref = nullptr; pollingseq = SEQ_TYPE_STANDARD; } -ui_menu_input::~ui_menu_input() +menu_input::~menu_input() { } @@ -239,7 +241,7 @@ ui_menu_input::~ui_menu_input() and the default item -------------------------------------------------*/ -void ui_menu_input::toggle_none_default(input_seq &selected_seq, input_seq &original_seq, const input_seq &selected_defseq) +void menu_input::toggle_none_default(input_seq &selected_seq, input_seq &original_seq, const input_seq &selected_defseq) { /* if we used to be "none", toggle to the default value */ if (original_seq.length() == 0) @@ -250,14 +252,14 @@ void ui_menu_input::toggle_none_default(input_seq &selected_seq, input_seq &orig selected_seq.reset(); } -void ui_menu_input::handle() +void menu_input::handle() { input_item_data *seqchangeditem = nullptr; - const ui_menu_event *menu_event; + const event *menu_event; int invalidate = false; /* process the menu */ - menu_event = process((pollingitem != nullptr) ? UI_MENU_PROCESS_NOKEYS : 0); + menu_event = process((pollingitem != nullptr) ? PROCESS_NOKEYS : 0); /* if we are polling, handle as a special case */ if (pollingitem != nullptr) @@ -330,17 +332,17 @@ void ui_menu_input::handle() pollingref = pollingitem->ref; pollingseq = pollingitem->seqtype; } - reset(UI_MENU_RESET_REMEMBER_POSITION); + reset(reset_options::REMEMBER_POSITION); } } -void ui_menu_input_general::update_input(struct input_item_data *seqchangeditem) +void menu_input_general::update_input(struct input_item_data *seqchangeditem) { const input_type_entry *entry = (const input_type_entry *)seqchangeditem->ref; machine().ioport().set_type_seq(entry->type(), entry->player(), seqchangeditem->seqtype, seqchangeditem->seq); } -void ui_menu_input_specific::update_input(struct input_item_data *seqchangeditem) +void menu_input_specific::update_input(struct input_item_data *seqchangeditem) { ioport_field::user_settings settings; @@ -355,7 +357,7 @@ void ui_menu_input_specific::update_input(struct input_item_data *seqchangeditem items for quicksort -------------------------------------------------*/ -int ui_menu_input::compare_items(const void *i1, const void *i2) +int menu_input::compare_items(const void *i1, const void *i2) { const input_item_data * const *data1 = (const input_item_data * const *)i1; const input_item_data * const *data2 = (const input_item_data * const *)i2; @@ -373,7 +375,7 @@ int ui_menu_input::compare_items(const void *i1, const void *i2) menu from them -------------------------------------------------*/ -void ui_menu_input::populate_and_sort(input_item_data *itemlist) +void menu_input::populate_and_sort(input_item_data *itemlist) { const char *nameformat[INPUT_TYPE_TOTAL] = { nullptr }; input_item_data **itemarray, *item; @@ -414,7 +416,7 @@ void ui_menu_input::populate_and_sort(input_item_data *itemlist) if (first_entry) first_entry = false; else - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); item_append(string_format("[root%s]", item->owner_name).c_str(), nullptr, 0, nullptr); prev_owner.assign(item->owner_name); } @@ -425,14 +427,14 @@ void ui_menu_input::populate_and_sort(input_item_data *itemlist) if (pollingref == item->ref) { subtext.assign(" "); - flags |= MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW; + flags |= FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW; } /* otherwise, generate the sequence name and invert it if different from the default */ else { subtext = machine().input().seq_name(item->seq); - flags |= (item->seq != *item->defseq) ? MENU_FLAG_INVERT : 0; + flags |= (item->seq != *item->defseq) ? FLAG_INVERT : 0; } /* add the item */ @@ -446,11 +448,11 @@ void ui_menu_input::populate_and_sort(input_item_data *itemlist) switches menu -------------------------------------------------*/ -ui_menu_settings_dip_switches::ui_menu_settings_dip_switches(mame_ui_manager &mui, render_container *container) : ui_menu_settings(mui, container, IPT_DIPSWITCH) +menu_settings_dip_switches::menu_settings_dip_switches(mame_ui_manager &mui, render_container *container) : menu_settings(mui, container, IPT_DIPSWITCH) { } -ui_menu_settings_dip_switches::~ui_menu_settings_dip_switches() +menu_settings_dip_switches::~menu_settings_dip_switches() { } @@ -459,11 +461,11 @@ ui_menu_settings_dip_switches::~ui_menu_settings_dip_switches() driver config menu -------------------------------------------------*/ -ui_menu_settings_driver_config::ui_menu_settings_driver_config(mame_ui_manager &mui, render_container *container) : ui_menu_settings(mui, container, IPT_CONFIG) +menu_settings_driver_config::menu_settings_driver_config(mame_ui_manager &mui, render_container *container) : menu_settings(mui, container, IPT_CONFIG) { } -ui_menu_settings_driver_config::~ui_menu_settings_driver_config() +menu_settings_driver_config::~menu_settings_driver_config() { } @@ -472,10 +474,10 @@ ui_menu_settings_driver_config::~ui_menu_settings_driver_config() switches menus -------------------------------------------------*/ -void ui_menu_settings::handle() +void menu_settings::handle() { // process the menu - const ui_menu_event *menu_event = process(0); + const event *menu_event = process(0); // handle events if (menu_event != nullptr && menu_event->itemref != nullptr) @@ -495,30 +497,30 @@ void ui_menu_settings::handle() switch (menu_event->iptkey) { - /* if selected, reset to default value */ - case IPT_UI_SELECT: - field->get_user_settings(settings); - settings.value = field->defvalue(); - field->set_user_settings(settings); - changed = true; - break; + /* if selected, reset to default value */ + case IPT_UI_SELECT: + field->get_user_settings(settings); + settings.value = field->defvalue(); + field->set_user_settings(settings); + changed = true; + break; - /* left goes to previous setting */ - case IPT_UI_LEFT: - field->select_previous_setting(); - changed = true; - break; + /* left goes to previous setting */ + case IPT_UI_LEFT: + field->select_previous_setting(); + changed = true; + break; - /* right goes to next setting */ - case IPT_UI_RIGHT: - field->select_next_setting(); - changed = true; - break; + /* right goes to next setting */ + case IPT_UI_RIGHT: + field->select_next_setting(); + changed = true; + break; } /* if anything changed, rebuild the menu, trying to stay on the same field */ if (changed) - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); } } } @@ -529,12 +531,12 @@ void ui_menu_settings::handle() switches menus -------------------------------------------------*/ -ui_menu_settings::ui_menu_settings(mame_ui_manager &mui, render_container *container, UINT32 _type) : ui_menu(mui, container), diplist(nullptr), dipcount(0) +menu_settings::menu_settings(mame_ui_manager &mui, render_container *container, UINT32 _type) : menu(mui, container), diplist(nullptr), dipcount(0) { type = _type; } -void ui_menu_settings::populate() +void menu_settings::populate() { dip_descriptor **diplist_tailptr; std::string prev_owner; @@ -554,9 +556,9 @@ void ui_menu_settings::populate() /* set the left/right flags appropriately */ if (field.has_previous_setting()) - flags |= MENU_FLAG_LEFT_ARROW; + flags |= FLAG_LEFT_ARROW; if (field.has_next_setting()) - flags |= MENU_FLAG_RIGHT_ARROW; + flags |= FLAG_RIGHT_ARROW; /* add the menu item */ if (strcmp(field.device().tag(), prev_owner.c_str()) != 0) @@ -564,7 +566,7 @@ void ui_menu_settings::populate() if (first_entry) first_entry = false; else - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); string_format("[root%s]", field.device().tag()); item_append(string_format("[root%s]", field.device().tag()).c_str(), nullptr, 0, nullptr); prev_owner.assign(field.device().tag()); @@ -617,11 +619,11 @@ void ui_menu_settings::populate() if (type == IPT_DIPSWITCH) custombottom = dipcount ? dipcount * (DIP_SWITCH_HEIGHT + DIP_SWITCH_SPACING) + DIP_SWITCH_SPACING : 0; - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); item_append(_("Reset"), nullptr, 0, (void *)1); } -ui_menu_settings::~ui_menu_settings() +menu_settings::~menu_settings() { } @@ -630,7 +632,7 @@ ui_menu_settings::~ui_menu_settings() rendering -------------------------------------------------*/ -void ui_menu_settings_dip_switches::custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) +void menu_settings_dip_switches::custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) { // catch if no diploc has to be drawn if (bottom == 0) @@ -672,7 +674,7 @@ void ui_menu_settings_dip_switches::custom_render(void *selectedref, float top, DIP switch -------------------------------------------------*/ -void ui_menu_settings_dip_switches::custom_render_one(float x1, float y1, float x2, float y2, const dip_descriptor *dip, UINT32 selectedmask) +void menu_settings_dip_switches::custom_render_one(float x1, float y1, float x2, float y2, const dip_descriptor *dip, UINT32 selectedmask) { float switch_field_width = SINGLE_TOGGLE_SWITCH_FIELD_WIDTH * container->manager().ui_aspect(); float switch_width = SINGLE_TOGGLE_SWITCH_WIDTH * container->manager().ui_aspect(); @@ -741,10 +743,10 @@ void ui_menu_settings_dip_switches::custom_render_one(float x1, float y1, float menu_analog - handle the analog settings menu -------------------------------------------------*/ -void ui_menu_analog::handle() +void menu_analog::handle() { /* process the menu */ - const ui_menu_event *menu_event = process(UI_MENU_PROCESS_LR_REPEAT); + const event *menu_event = process(PROCESS_LR_REPEAT); /* handle events */ if (menu_event != nullptr && menu_event->itemref != nullptr) @@ -793,7 +795,7 @@ void ui_menu_analog::handle() data->field->set_user_settings(settings); /* rebuild the menu */ - reset(UI_MENU_RESET_REMEMBER_POSITION); + reset(reset_options::REMEMBER_POSITION); } } } @@ -804,11 +806,11 @@ void ui_menu_analog::handle() settings menu -------------------------------------------------*/ -ui_menu_analog::ui_menu_analog(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container) +menu_analog::menu_analog(mame_ui_manager &mui, render_container *container) : menu(mui, container) { } -void ui_menu_analog::populate() +void menu_analog::populate() { std::string text; std::string subtext; @@ -861,7 +863,7 @@ void ui_menu_analog::populate() if (first_entry) first_entry = false; else - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); item_append(string_format("[root%s]", field.device().tag()).c_str(), nullptr, 0, nullptr); prev_owner.assign(field.device().tag()); } @@ -914,9 +916,9 @@ void ui_menu_analog::populate() /* put on arrows */ if (data->cur > data->min) - flags |= MENU_FLAG_LEFT_ARROW; + flags |= FLAG_LEFT_ARROW; if (data->cur < data->max) - flags |= MENU_FLAG_RIGHT_ARROW; + flags |= FLAG_RIGHT_ARROW; /* append a menu item */ item_append(text.c_str(), subtext.c_str(), flags, data); @@ -924,6 +926,8 @@ void ui_menu_analog::populate() } } -ui_menu_analog::~ui_menu_analog() +menu_analog::~menu_analog() { } + +} // namespace ui diff --git a/src/frontend/mame/ui/inputmap.h b/src/frontend/mame/ui/inputmap.h index 508b0a4dd02..ef14ef9b064 100644 --- a/src/frontend/mame/ui/inputmap.h +++ b/src/frontend/mame/ui/inputmap.h @@ -10,21 +10,28 @@ #pragma once -#ifndef __UI_INPUTMAP_H__ -#define __UI_INPUTMAP_H__ +#ifndef MAME_FRONTEND_UI_INPUTMAP_H +#define MAME_FRONTEND_UI_INPUTMAP_H -class ui_menu_input_groups : public ui_menu { +#include "ui/menu.h" + + +namespace ui { + +class menu_input_groups : public menu +{ public: - ui_menu_input_groups(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_input_groups(); + menu_input_groups(mame_ui_manager &mui, render_container *container); + virtual ~menu_input_groups() override; virtual void populate() override; virtual void handle() override; }; -class ui_menu_input : public ui_menu { +class menu_input : public menu +{ public: - ui_menu_input(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_input(); + menu_input(mame_ui_manager &mui, render_container *container); + virtual ~menu_input() override; virtual void handle() override; protected: @@ -37,7 +44,8 @@ protected: }; /* internal input menu item data */ - struct input_item_data { + struct input_item_data + { input_item_data * next; /* pointer to next item in the list */ const void * ref; /* reference to type description for global inputs or field for game inputs */ input_seq_type seqtype; /* sequence type */ @@ -66,10 +74,11 @@ private: static int compare_items(const void *i1, const void *i2); }; -class ui_menu_input_general : public ui_menu_input { +class menu_input_general : public menu_input +{ public: - ui_menu_input_general(mame_ui_manager &mui, render_container *container, int group); - virtual ~ui_menu_input_general(); + menu_input_general(mame_ui_manager &mui, render_container *container, int group); + virtual ~menu_input_general() override; virtual void populate() override; protected: @@ -77,26 +86,29 @@ protected: virtual void update_input(struct input_item_data *seqchangeditem) override; }; -class ui_menu_input_specific : public ui_menu_input { +class menu_input_specific : public menu_input +{ public: - ui_menu_input_specific(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_input_specific(); + menu_input_specific(mame_ui_manager &mui, render_container *container); + virtual ~menu_input_specific() override; virtual void populate() override; protected: virtual void update_input(struct input_item_data *seqchangeditem) override; }; -class ui_menu_settings : public ui_menu { +class menu_settings : public menu +{ public: - ui_menu_settings(mame_ui_manager &mui, render_container *container, UINT32 type); - virtual ~ui_menu_settings(); + menu_settings(mame_ui_manager &mui, render_container *container, UINT32 type); + virtual ~menu_settings() override; virtual void populate() override; virtual void handle() override; protected: /* DIP switch descriptor */ - struct dip_descriptor { + struct dip_descriptor + { dip_descriptor * next; const char * name; UINT32 mask; @@ -108,26 +120,29 @@ protected: int type; }; -class ui_menu_settings_dip_switches : public ui_menu_settings { +class menu_settings_dip_switches : public menu_settings +{ public: - ui_menu_settings_dip_switches(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_settings_dip_switches(); + menu_settings_dip_switches(mame_ui_manager &mui, render_container *container); + virtual ~menu_settings_dip_switches() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; private: void custom_render_one(float x1, float y1, float x2, float y2, const dip_descriptor *dip, UINT32 selectedmask); }; -class ui_menu_settings_driver_config : public ui_menu_settings { +class menu_settings_driver_config : public menu_settings +{ public: - ui_menu_settings_driver_config(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_settings_driver_config(); + menu_settings_driver_config(mame_ui_manager &mui, render_container *container); + virtual ~menu_settings_driver_config(); }; -class ui_menu_analog : public ui_menu { +class menu_analog : public menu +{ public: - ui_menu_analog(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_analog(); + menu_analog(mame_ui_manager &mui, render_container *container); + virtual ~menu_analog() override; virtual void populate() override; virtual void handle() override; @@ -150,4 +165,6 @@ private: }; }; -#endif /* __UI_INPUTMAP_H__ */ +} // namesapce ui + +#endif /* MAME_FRONTEND_UI_INPUTMAP_H */ diff --git a/src/frontend/mame/ui/mainmenu.cpp b/src/frontend/mame/ui/mainmenu.cpp index dc861a96b0b..7f0147b0eca 100644 --- a/src/frontend/mame/ui/mainmenu.cpp +++ b/src/frontend/mame/ui/mainmenu.cpp @@ -35,19 +35,21 @@ #include "ui/pluginopt.h" +namespace ui { + /*************************************************************************** MENU HANDLERS ***************************************************************************/ /*------------------------------------------------- - ui_menu_main constructor - populate the main menu + menu_main constructor - populate the main menu -------------------------------------------------*/ -ui_menu_main::ui_menu_main(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container) +menu_main::menu_main(mame_ui_manager &mui, render_container *container) : menu(mui, container) { } -void ui_menu_main::populate() +void menu_main::populate() { /* add input menu items */ item_append(_("Input (general)"), nullptr, 0, (void *)INPUT_GROUPS); @@ -131,7 +133,7 @@ void ui_menu_main::populate() if (ui().options().enabled_dats() && mame_machine_manager::instance()->datfile().has_data()) item_append(_("External DAT View"), nullptr, 0, (void *)EXTERNAL_DATS); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); /* add favorite menu */ if (!mame_machine_manager::instance()->favorite().isgame_favorite()) @@ -139,7 +141,7 @@ void ui_menu_main::populate() else item_append(_("Remove From Favorites"), nullptr, 0, (void *)REMOVE_FAVORITE); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); // item_append(_("Quit from Machine"), nullptr, 0, (void *)QUIT_GAME); @@ -147,7 +149,7 @@ void ui_menu_main::populate() item_append(_("Select New Machine"), nullptr, 0, (void *)SELECT_GAME); } -ui_menu_main::~ui_menu_main() +menu_main::~menu_main() { } @@ -155,129 +157,130 @@ ui_menu_main::~ui_menu_main() menu_main - handle the main menu -------------------------------------------------*/ -void ui_menu_main::handle() +void menu_main::handle() { /* process the menu */ - const ui_menu_event *menu_event = process(0); + const event *menu_event = process(0); if (menu_event != nullptr && menu_event->iptkey == IPT_UI_SELECT) { switch((long long)(menu_event->itemref)) { case INPUT_GROUPS: - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); break; case INPUT_SPECIFIC: - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); break; case SETTINGS_DIP_SWITCHES: - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); break; case SETTINGS_DRIVER_CONFIG: - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); break; case ANALOG: - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); break; case BOOKKEEPING: - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); break; case GAME_INFO: - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); break; case IMAGE_MENU_IMAGE_INFO: - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); break; case IMAGE_MENU_FILE_MANAGER: - ui_menu::stack_push(global_alloc_clear(ui(), container, nullptr)); + menu::stack_push(ui(), container, nullptr); break; case TAPE_CONTROL: - ui_menu::stack_push(global_alloc_clear(ui(), container, nullptr)); + menu::stack_push(ui(), container, nullptr); break; case PTY_INFO: - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); break; case SLOT_DEVICES: - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); break; case NETWORK_DEVICES: - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); break; case KEYBOARD_MODE: - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); break; case SLIDERS: - ui_menu::stack_push(global_alloc_clear(ui(), container, false)); + menu::stack_push(ui(), container, false); break; case VIDEO_TARGETS: - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); break; case VIDEO_OPTIONS: - ui_menu::stack_push(global_alloc_clear(ui(), container, machine().render().first_target())); + menu::stack_push(ui(), container, machine().render().first_target()); break; case CROSSHAIR: - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); break; case CHEAT: - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); break; case PLUGINS: - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); break; case SELECT_GAME: - if (strcmp(machine().options().ui(),"simple")==0) { - ui_menu::stack_push(global_alloc_clear(ui(), container, nullptr)); - } else { - ui_menu::stack_push(global_alloc_clear(ui(), container, nullptr)); - } + if (strcmp(machine().options().ui(),"simple")==0) + menu::stack_push(ui(), container, nullptr); + else + menu::stack_push(ui(), container, nullptr); break; case BIOS_SELECTION: - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); break; case BARCODE_READ: - ui_menu::stack_push(global_alloc_clear(ui(), container, nullptr)); + menu::stack_push(ui(), container, nullptr); break; case EXTERNAL_DATS: - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); break; case ADD_FAVORITE: mame_machine_manager::instance()->favorite().add_favorite_game(); - reset(UI_MENU_RESET_REMEMBER_POSITION); + reset(reset_options::REMEMBER_POSITION); break; case REMOVE_FAVORITE: mame_machine_manager::instance()->favorite().remove_favorite_game(); - reset(UI_MENU_RESET_REMEMBER_POSITION); + reset(reset_options::REMEMBER_POSITION); break; case QUIT_GAME: - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); ui().request_quit(); break; default: - fatalerror("ui_menu_main::handle - unknown reference\n"); + fatalerror("ui::menu_main::handle - unknown reference\n"); } } } + +} // namespace ui diff --git a/src/frontend/mame/ui/mainmenu.h b/src/frontend/mame/ui/mainmenu.h index dc565f0256e..40063bab0d3 100644 --- a/src/frontend/mame/ui/mainmenu.h +++ b/src/frontend/mame/ui/mainmenu.h @@ -10,13 +10,16 @@ #pragma once -#ifndef __UI_MAINMENU_H__ -#define __UI_MAINMENU_H__ +#ifndef MAME_FRONTEND_UI_MAINMENU_H +#define MAME_FRONTEND_UI_MAINMENU_H -class ui_menu_main : public ui_menu { +namespace ui { + +class menu_main : public menu +{ public: - ui_menu_main(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_main(); + menu_main(mame_ui_manager &mui, render_container *container); + virtual ~menu_main(); virtual void populate() override; virtual void handle() override; @@ -50,8 +53,8 @@ private: REMOVE_FAVORITE, QUIT_GAME }; - - //bool submenu; }; -#endif /* __UI_MAINMENU_H__ */ +} // namespace ui + +#endif /* MAME_FRONTEND_UI_MAINMENU_H */ diff --git a/src/frontend/mame/ui/menu.cpp b/src/frontend/mame/ui/menu.cpp index c2d329db905..ffc5310f81b 100644 --- a/src/frontend/mame/ui/menu.cpp +++ b/src/frontend/mame/ui/menu.cpp @@ -25,6 +25,8 @@ #include "drivenum.h" +namespace ui { + /*************************************************************************** CONSTANTS ***************************************************************************/ @@ -32,12 +34,12 @@ #define UI_MENU_POOL_SIZE 65536 #define MAX_ICONS_RENDER 40 -struct ui_arts_info +struct arts_info { const char *title, *path; }; -static const ui_arts_info arts_info[] = +static const arts_info arts_info[] = { { __("Snapshots"), OPTION_SNAPSHOT_DIRECTORY }, { __("Cabinets"), OPTION_CABINETS_PATH }, @@ -69,26 +71,26 @@ static const char *hover_msg[] = { GLOBAL VARIABLES ***************************************************************************/ -ui_menu *ui_menu::menu_stack; -ui_menu *ui_menu::menu_free; -std::unique_ptr ui_menu::hilight_bitmap; -render_texture *ui_menu::hilight_texture; -render_texture *ui_menu::arrow_texture; -render_texture *ui_menu::snapx_texture; -render_texture *ui_menu::hilight_main_texture; -render_texture *ui_menu::bgrnd_texture; -render_texture *ui_menu::star_texture; -render_texture *ui_menu::toolbar_texture[UI_TOOLBAR_BUTTONS]; -render_texture *ui_menu::sw_toolbar_texture[UI_TOOLBAR_BUTTONS]; -render_texture *ui_menu::icons_texture[MAX_ICONS_RENDER]; -std::unique_ptr ui_menu::snapx_bitmap; -std::unique_ptr ui_menu::no_avail_bitmap; -std::unique_ptr ui_menu::star_bitmap; -std::unique_ptr ui_menu::bgrnd_bitmap; -bitmap_argb32 *ui_menu::icons_bitmap[MAX_ICONS_RENDER]; -std::unique_ptr ui_menu::hilight_main_bitmap; -bitmap_argb32 *ui_menu::toolbar_bitmap[UI_TOOLBAR_BUTTONS]; -bitmap_argb32 *ui_menu::sw_toolbar_bitmap[UI_TOOLBAR_BUTTONS]; +std::unique_ptr menu::menu_stack; +std::unique_ptr menu::menu_free; +std::unique_ptr menu::hilight_bitmap; +render_texture *menu::hilight_texture; +render_texture *menu::arrow_texture; +render_texture *menu::snapx_texture; +render_texture *menu::hilight_main_texture; +render_texture *menu::bgrnd_texture; +render_texture *menu::star_texture; +render_texture *menu::toolbar_texture[UI_TOOLBAR_BUTTONS]; +render_texture *menu::sw_toolbar_texture[UI_TOOLBAR_BUTTONS]; +render_texture *menu::icons_texture[MAX_ICONS_RENDER]; +std::unique_ptr menu::snapx_bitmap; +std::unique_ptr menu::no_avail_bitmap; +std::unique_ptr menu::star_bitmap; +std::unique_ptr menu::bgrnd_bitmap; +bitmap_argb32 *menu::icons_bitmap[MAX_ICONS_RENDER]; +std::unique_ptr menu::hilight_main_bitmap; +bitmap_argb32 *menu::toolbar_bitmap[UI_TOOLBAR_BUTTONS]; +bitmap_argb32 *menu::sw_toolbar_bitmap[UI_TOOLBAR_BUTTONS]; /*************************************************************************** INLINE FUNCTIONS @@ -99,9 +101,9 @@ bitmap_argb32 *ui_menu::sw_toolbar_bitmap[UI_TOOLBAR_BUTTONS]; // item is selectable //------------------------------------------------- -inline bool ui_menu_item::is_selectable() const +inline bool is_selectable(menu_item const &item) { - return ((flags & (MENU_FLAG_MULTILINE | MENU_FLAG_DISABLE)) == 0 && strcmp(text, MENU_SEPARATOR_ITEM) != 0); + return ((item.flags & (menu::FLAG_MULTILINE | menu::FLAG_DISABLE)) == 0 && strcmp(item.text, MENU_SEPARATOR_ITEM) != 0); } @@ -111,11 +113,11 @@ inline bool ui_menu_item::is_selectable() const // reported a key //------------------------------------------------- -inline bool ui_menu::exclusive_input_pressed(int key, int repeat) +inline bool menu::exclusive_input_pressed(int key, int repeat) { - if (menu_event.iptkey == IPT_INVALID && machine().ui_input().pressed_repeat(key, repeat)) + if (m_event.iptkey == IPT_INVALID && machine().ui_input().pressed_repeat(key, repeat)) { - menu_event.iptkey = key; + m_event.iptkey = key; return true; } return false; @@ -131,10 +133,10 @@ inline bool ui_menu::exclusive_input_pressed(int key, int repeat) // init - initialize the menu system //------------------------------------------------- -void ui_menu::init(running_machine &machine, ui_options &mopt) +void menu::init(running_machine &machine, ui_options &mopt) { // initialize the menu stack - ui_menu::stack_reset(machine); + menu::stack_reset(machine); // create a texture for hilighting items hilight_bitmap = std::make_unique(256, 1); @@ -155,7 +157,7 @@ void ui_menu::init(running_machine &machine, ui_options &mopt) init_ui(machine, mopt); // add an exit callback to free memory - machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(ui_menu::exit), &machine)); + machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(menu::exit), &machine)); } @@ -163,11 +165,11 @@ void ui_menu::init(running_machine &machine, ui_options &mopt) // exit - clean up after ourselves //------------------------------------------------- -void ui_menu::exit(running_machine &machine) +void menu::exit(running_machine &machine) { // free menus - ui_menu::stack_reset(machine); - ui_menu::clear_free_list(machine); + menu::stack_reset(machine); + menu::clear_free_list(machine); // free textures render_manager &mre = machine.render(); @@ -195,31 +197,37 @@ void ui_menu::exit(running_machine &machine) ***************************************************************************/ //------------------------------------------------- -// ui_menu - menu constructor +// menu - menu constructor //------------------------------------------------- -ui_menu::ui_menu(mame_ui_manager &mui, render_container *_container) : m_ui(mui) +menu::menu(mame_ui_manager &mui, render_container *_container) + : m_special_main_menu(false) + , m_ui(mui) + , m_parent() + , m_pressed(false) + , m_repeat(0) + , m_event() + , m_pool(nullptr) { - m_special_main_menu = false; container = _container; - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); top_line = 0; } //------------------------------------------------- -// ~ui_menu - menu destructor +// ~menu - menu destructor //------------------------------------------------- -ui_menu::~ui_menu() +menu::~menu() { // free the pools - while (pool) + while (m_pool) { - ui_menu_pool *ppool = pool; - pool = pool->next; + pool *const ppool = m_pool; + m_pool = m_pool->next; global_free(ppool); } } @@ -230,37 +238,39 @@ ui_menu::~ui_menu() // and all memory allocated from the memory pool //------------------------------------------------- -void ui_menu::reset(ui_menu_reset_options options) +void menu::reset(reset_options options) { // based on the reset option, set the reset info resetpos = 0; resetref = nullptr; - if (options == UI_MENU_RESET_REMEMBER_POSITION) + if (options == reset_options::REMEMBER_POSITION) resetpos = selected; - else if (options == UI_MENU_RESET_REMEMBER_REF) + else if (options == reset_options::REMEMBER_REF) resetref = item[selected].ref; // reset all the pools and the item.size() back to 0 - for (ui_menu_pool *ppool = pool; ppool != nullptr; ppool = ppool->next) + for (pool *ppool = m_pool; ppool != nullptr; ppool = ppool->next) ppool->top = (UINT8 *)(ppool + 1); item.clear(); visitems = 0; selected = 0; // add an item to return - if (parent == nullptr) + if (!m_parent) + { item_append(_("Return to Machine"), nullptr, 0, nullptr); - else if (parent->is_special_main_menu()) + } + else if (m_parent->is_special_main_menu()) { if (strcmp(machine().options().ui(), "simple") == 0) item_append(_("Exit"), nullptr, 0, nullptr); else - item_append(_("Exit"), nullptr, MENU_FLAG_UI | MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, nullptr); + item_append(_("Exit"), nullptr, FLAG_UI | FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, nullptr); } else { - if (strcmp(machine().options().ui(), "simple") != 0 && ui_menu::stack_has_special_main_menu()) - item_append(_("Return to Previous Menu"), nullptr, MENU_FLAG_UI | MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, nullptr); + if (strcmp(machine().options().ui(), "simple") != 0 && menu::stack_has_special_main_menu()) + item_append(_("Return to Previous Menu"), nullptr, FLAG_UI | FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, nullptr); else item_append(_("Return to Previous Menu"), nullptr, 0, nullptr); } @@ -273,7 +283,7 @@ void ui_menu::reset(ui_menu_reset_options options) // menu has special needs //------------------------------------------------- -bool ui_menu::is_special_main_menu() const +bool menu::is_special_main_menu() const { return m_special_main_menu; } @@ -284,7 +294,7 @@ bool ui_menu::is_special_main_menu() const // menu has special needs //------------------------------------------------- -void ui_menu::set_special_main_menu(bool special) +void menu::set_special_main_menu(bool special) { m_special_main_menu = special; } @@ -295,7 +305,7 @@ void ui_menu::set_special_main_menu(bool special) // end of the menu //------------------------------------------------- -void ui_menu::item_append(ui_menu_item item) +void menu::item_append(menu_item item) { item_append(item.text, item.subtext, item.flags, item.ref, item.type); } @@ -305,9 +315,9 @@ void ui_menu::item_append(ui_menu_item item) // end of the menu //------------------------------------------------- -void ui_menu::item_append(ui_menu_item_type type) +void menu::item_append(menu_item_type type) { - if (type == ui_menu_item_type::SEPARATOR) + if (type == menu_item_type::SEPARATOR) item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); } @@ -316,18 +326,18 @@ void ui_menu::item_append(ui_menu_item_type type) // end of the menu //------------------------------------------------- -void ui_menu::item_append(const char *text, const char *subtext, UINT32 flags, void *ref, ui_menu_item_type type) +void menu::item_append(const char *text, const char *subtext, UINT32 flags, void *ref, menu_item_type type) { // only allow multiline as the first item - if ((flags & MENU_FLAG_MULTILINE) != 0) + if ((flags & FLAG_MULTILINE) != 0) assert(item.size() == 1); // only allow a single multi-line item else if (item.size() >= 2) - assert((item[0].flags & MENU_FLAG_MULTILINE) == 0); + assert((item[0].flags & FLAG_MULTILINE) == 0); // allocate a new item and populate it - ui_menu_item pitem; + menu_item pitem; pitem.text = (text != nullptr) ? pool_strdup(text) : nullptr; pitem.subtext = (subtext != nullptr) ? pool_strdup(subtext) : nullptr; pitem.flags = flags; @@ -357,51 +367,51 @@ void ui_menu::item_append(const char *text, const char *subtext, UINT32 flags, v // and returning any interesting events //------------------------------------------------- -const ui_menu_event *ui_menu::process(UINT32 flags, float x0, float y0) +const menu::event *menu::process(UINT32 flags, float x0, float y0) { - // reset the menu_event - menu_event.iptkey = IPT_INVALID; + // reset the event + m_event.iptkey = IPT_INVALID; // first make sure our selection is valid validate_selection(1); // draw the menu - if (item.size() > 1 && (item[0].flags & MENU_FLAG_MULTILINE) != 0) + if (item.size() > 1 && (item[0].flags & FLAG_MULTILINE) != 0) draw_text_box(); - else if ((item[0].flags & MENU_FLAG_UI) != 0 || (item[0].flags & MENU_FLAG_UI_SWLIST) != 0) - draw_select_game((flags & UI_MENU_PROCESS_NOINPUT)); - else if ((item[0].flags & MENU_FLAG_UI_PALETTE) != 0) + else if ((item[0].flags & FLAG_UI) != 0 || (item[0].flags & FLAG_UI_SWLIST) != 0) + draw_select_game((flags & PROCESS_NOINPUT)); + else if ((item[0].flags & FLAG_UI_PALETTE) != 0) draw_palette_menu(); - else if ((item[0].flags & MENU_FLAG_UI_DATS) != 0) + else if ((item[0].flags & FLAG_UI_DATS) != 0) draw_dats_menu(); else draw(flags, x0, y0); // process input - if (!(flags & UI_MENU_PROCESS_NOKEYS) && !(flags & UI_MENU_PROCESS_NOINPUT)) + if (!(flags & PROCESS_NOKEYS) && !(flags & PROCESS_NOINPUT)) { // read events - if ((item[0].flags & MENU_FLAG_UI ) != 0 || (item[0].flags & MENU_FLAG_UI_SWLIST ) != 0) + if ((item[0].flags & FLAG_UI ) != 0 || (item[0].flags & FLAG_UI_SWLIST ) != 0) handle_main_events(flags); else handle_events(flags); - // handle the keys if we don't already have an menu_event - if (menu_event.iptkey == IPT_INVALID) + // handle the keys if we don't already have an event + if (m_event.iptkey == IPT_INVALID) { - if ((item[0].flags & MENU_FLAG_UI ) != 0 || (item[0].flags & MENU_FLAG_UI_SWLIST ) != 0) + if ((item[0].flags & FLAG_UI) != 0 || (item[0].flags & FLAG_UI_SWLIST) != 0) handle_main_keys(flags); else handle_keys(flags); } } - // update the selected item in the menu_event - if (menu_event.iptkey != IPT_INVALID && selected >= 0 && selected < item.size()) + // update the selected item in the event + if (m_event.iptkey != IPT_INVALID && selected >= 0 && selected < item.size()) { - menu_event.itemref = item[selected].ref; - menu_event.type = item[selected].type; - return &menu_event; + m_event.itemref = item[selected].ref; + m_event.type = item[selected].type; + return &m_event; } return nullptr; } @@ -412,27 +422,27 @@ const ui_menu_event *ui_menu::process(UINT32 flags, float x0, float y0) // from the menu's memory pool //------------------------------------------------- -void *ui_menu::m_pool_alloc(size_t size) +void *menu::m_pool_alloc(size_t size) { - ui_menu_pool *ppool; - assert(size < UI_MENU_POOL_SIZE); // find a pool with enough room - for (ppool = pool; ppool != nullptr; ppool = ppool->next) + for (pool *ppool = m_pool; ppool != nullptr; ppool = ppool->next) + { if (ppool->end - ppool->top >= size) { void *result = ppool->top; ppool->top += size; return result; } + } // allocate a new pool - ppool = (ui_menu_pool *)global_alloc_array_clear(sizeof(*ppool) + UI_MENU_POOL_SIZE); + pool *ppool = (pool *)global_alloc_array_clear(sizeof(*ppool) + UI_MENU_POOL_SIZE); // wire it up - ppool->next = pool; - pool = ppool; + ppool->next = m_pool; + m_pool = ppool; ppool->top = (UINT8 *)(ppool + 1); ppool->end = ppool->top + UI_MENU_POOL_SIZE; return m_pool_alloc(size); @@ -444,7 +454,7 @@ void *ui_menu::m_pool_alloc(size_t size) // copy in the menu's memory pool //------------------------------------------------- -const char *ui_menu::pool_strdup(const char *string) +const char *menu::pool_strdup(const char *string) { return strcpy((char *)m_pool_alloc(strlen(string) + 1), string); } @@ -455,7 +465,7 @@ const char *ui_menu::pool_strdup(const char *string) // of the currently selected menu item //------------------------------------------------- -void *ui_menu::get_selection() +void *menu::get_selection() { return (selected >= 0 && selected < item.size()) ? item[selected].ref : nullptr; } @@ -466,7 +476,7 @@ void *ui_menu::get_selection() // of the currently selected menu item //------------------------------------------------- -void ui_menu::set_selection(void *selected_itemref) +void menu::set_selection(void *selected_itemref) { selected = -1; for (int itemnum = 0; itemnum < item.size(); itemnum++) @@ -487,18 +497,18 @@ void ui_menu::set_selection(void *selected_itemref) // draw - draw a menu //------------------------------------------------- -void ui_menu::draw(UINT32 flags, float origx0, float origy0) +void menu::draw(UINT32 flags, float origx0, float origy0) { // first draw the FPS counter if (ui().show_fps_counter()) { ui().draw_text_full(container, machine().video().speed_text().c_str(), 0.0f, 0.0f, 1.0f, - JUSTIFY_RIGHT, WRAP_WORD, DRAW_OPAQUE, rgb_t::white, rgb_t::black, nullptr, nullptr); + JUSTIFY_RIGHT, WRAP_WORD, DRAW_OPAQUE, rgb_t::white, rgb_t::black, nullptr, nullptr); } - bool customonly = (flags & UI_MENU_PROCESS_CUSTOM_ONLY); - bool noimage = (flags & UI_MENU_PROCESS_NOIMAGE); - bool noinput = (flags & UI_MENU_PROCESS_NOINPUT); + bool const customonly = (flags & PROCESS_CUSTOM_ONLY); + bool const noimage = (flags & PROCESS_NOIMAGE); + bool const noinput = (flags & PROCESS_NOINPUT); float line_height = ui().get_line_height(); float lr_arrow_width = 0.4f * line_height * machine().render().ui_aspect(); float ud_arrow_width = line_height * machine().render().ui_aspect(); @@ -517,7 +527,7 @@ void ui_menu::draw(UINT32 flags, float origx0, float origy0) float visible_main_menu_height = 0; for (itemnum = 0; itemnum < item.size(); itemnum++) { - const ui_menu_item &pitem = item[itemnum]; + const menu_item &pitem = item[itemnum]; float total_width; // compute width of left hand side @@ -647,7 +657,7 @@ void ui_menu::draw(UINT32 flags, float origx0, float origy0) { float line_y = visible_top + (float)linenum * line_height; itemnum = top_line + linenum; - const ui_menu_item &pitem = item[itemnum]; + const menu_item &pitem = item[itemnum]; const char *itemtext = pitem.text; rgb_t fgcolor = UI_TEXT_COLOR; rgb_t bgcolor = UI_TEXT_BG_COLOR; @@ -657,7 +667,7 @@ void ui_menu::draw(UINT32 flags, float origx0, float origy0) float line_y1 = line_y + line_height; // set the hover if this is our item - if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y && pitem.is_selectable()) + if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y && is_selectable(pitem)) hover = itemnum; // if we're selected, draw with a different background @@ -717,7 +727,7 @@ void ui_menu::draw(UINT32 flags, float origx0, float origy0) // if we don't have a subitem, just draw the string centered else if (pitem.subtext == nullptr) { - if (pitem.flags & MENU_FLAG_UI_HEADING) + if (pitem.flags & FLAG_UI_HEADING) { float heading_width = ui().get_string_width(itemtext); container->add_line(visible_left, line_y + 0.5f * line_height, visible_left + ((visible_width - heading_width) / 2) - UI_BOX_LR_BORDER, line_y + 0.5f * line_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); @@ -730,7 +740,7 @@ void ui_menu::draw(UINT32 flags, float origx0, float origy0) // otherwise, draw the item on the left and the subitem text on the right else { - int subitem_invert = pitem.flags & MENU_FLAG_INVERT; + int subitem_invert = pitem.flags & FLAG_INVERT; const char *subitem_text = pitem.subtext; float item_width, subitem_width; @@ -764,7 +774,7 @@ void ui_menu::draw(UINT32 flags, float origx0, float origy0) JUSTIFY_RIGHT, WRAP_TRUNCATE, DRAW_NORMAL, subitem_invert ? fgcolor3 : fgcolor2, bgcolor, &subitem_width, nullptr); // apply arrows - if (itemnum == selected && (pitem.flags & MENU_FLAG_LEFT_ARROW)) + if (itemnum == selected && (pitem.flags & FLAG_LEFT_ARROW)) { draw_arrow(container, effective_left + effective_width - subitem_width - gutter_width, @@ -774,7 +784,7 @@ void ui_menu::draw(UINT32 flags, float origx0, float origy0) fgcolor, ROT90 ^ ORIENTATION_FLIP_X); } - if (itemnum == selected && (pitem.flags & MENU_FLAG_RIGHT_ARROW)) + if (itemnum == selected && (pitem.flags & FLAG_RIGHT_ARROW)) { draw_arrow(container, effective_left + effective_width + gutter_width - lr_arrow_width, @@ -791,8 +801,8 @@ void ui_menu::draw(UINT32 flags, float origx0, float origy0) // if the selected subitem is too big, display it in a separate offset box if (selected_subitem_too_big) { - const ui_menu_item &pitem = item[selected]; - int subitem_invert = pitem.flags & MENU_FLAG_INVERT; + const menu_item &pitem = item[selected]; + int subitem_invert = pitem.flags & FLAG_INVERT; linenum = selected - top_line; float line_y = visible_top + (float)linenum * line_height; float target_width, target_height; @@ -810,19 +820,19 @@ void ui_menu::draw(UINT32 flags, float origx0, float origy0) // add a box around that ui().draw_outlined_box(container, target_x - UI_BOX_LR_BORDER, - target_y - UI_BOX_TB_BORDER, - target_x + target_width + UI_BOX_LR_BORDER, - target_y + target_height + UI_BOX_TB_BORDER, - subitem_invert ? UI_SELECTED_BG_COLOR : UI_BACKGROUND_COLOR); + target_y - UI_BOX_TB_BORDER, + target_x + target_width + UI_BOX_LR_BORDER, + target_y + target_height + UI_BOX_TB_BORDER, + subitem_invert ? UI_SELECTED_BG_COLOR : UI_BACKGROUND_COLOR); ui().draw_text_full(container, pitem.subtext, target_x, target_y, target_width, - JUSTIFY_RIGHT, WRAP_WORD, DRAW_NORMAL, UI_SELECTED_COLOR, UI_SELECTED_BG_COLOR, nullptr, nullptr); + JUSTIFY_RIGHT, WRAP_WORD, DRAW_NORMAL, UI_SELECTED_COLOR, UI_SELECTED_BG_COLOR, nullptr, nullptr); } // if there is something special to add, do it by calling the virtual method custom_render((selected >= 0 && selected < item.size()) ? item[selected].ref : nullptr, customtop, custombottom, x1, y1, x2, y2); } -void ui_menu::custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) +void menu::custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) { } @@ -832,7 +842,7 @@ void ui_menu::custom_render(void *selectedref, float top, float bottom, float x, // bottom //------------------------------------------------- -void ui_menu::draw_text_box() +void menu::draw_text_box() { const char *text = item[0].text; const char *backtext = item[1].text; @@ -872,7 +882,7 @@ void ui_menu::draw_text_box() target_y - UI_BOX_TB_BORDER, target_x + target_width + gutter_width + UI_BOX_LR_BORDER, target_y + target_height + UI_BOX_TB_BORDER, - (item[0].flags & MENU_FLAG_REDTEXT) ? UI_RED_COLOR : UI_BACKGROUND_COLOR); + (item[0].flags & FLAG_REDTEXT) ? UI_RED_COLOR : UI_BACKGROUND_COLOR); ui().draw_text_full(container, text, target_x, target_y, target_width, JUSTIFY_LEFT, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); @@ -896,7 +906,7 @@ void ui_menu::draw_text_box() // input events for a menu //------------------------------------------------- -void ui_menu::handle_events(UINT32 flags) +void menu::handle_events(UINT32 flags) { bool stop = false; ui_event local_menu_event; @@ -908,13 +918,13 @@ void ui_menu::handle_events(UINT32 flags) { // if we are hovering over a valid item, select it with a single click case UI_EVENT_MOUSE_DOWN: - if ((flags & UI_MENU_PROCESS_ONLYCHAR) == 0) + if ((flags & PROCESS_ONLYCHAR) == 0) { if (hover >= 0 && hover < item.size()) selected = hover; else if (hover == HOVER_ARROW_UP) { - if ((flags & MENU_FLAG_UI_DATS) != 0) + if ((flags & FLAG_UI_DATS) != 0) { top_line -= visitems - (top_line + visible_lines == item.size() - 1); return; @@ -926,7 +936,7 @@ void ui_menu::handle_events(UINT32 flags) } else if (hover == HOVER_ARROW_DOWN) { - if ((flags & MENU_FLAG_UI_DATS) != 0) + if ((flags & FLAG_UI_DATS) != 0) { top_line += visible_lines - 2; return; @@ -941,14 +951,14 @@ void ui_menu::handle_events(UINT32 flags) // if we are hovering over a valid item, fake a UI_SELECT with a double-click case UI_EVENT_MOUSE_DOUBLE_CLICK: - if ((flags & UI_MENU_PROCESS_ONLYCHAR) == 0 && hover >= 0 && hover < item.size()) + if ((flags & PROCESS_ONLYCHAR) == 0 && hover >= 0 && hover < item.size()) { selected = hover; - menu_event.iptkey = IPT_UI_SELECT; + m_event.iptkey = IPT_UI_SELECT; if (selected == item.size() - 1) { - menu_event.iptkey = IPT_UI_CANCEL; - ui_menu::stack_pop(machine()); + m_event.iptkey = IPT_UI_CANCEL; + menu::stack_pop(machine()); } stop = true; } @@ -956,11 +966,11 @@ void ui_menu::handle_events(UINT32 flags) // caught scroll event case UI_EVENT_MOUSE_WHEEL: - if ((flags & UI_MENU_PROCESS_ONLYCHAR) == 0) + if ((flags & PROCESS_ONLYCHAR) == 0) { if (local_menu_event.zdelta > 0) { - if ((flags & MENU_FLAG_UI_DATS) != 0) + if ((flags & FLAG_UI_DATS) != 0) { top_line -= local_menu_event.num_lines; return; @@ -973,7 +983,7 @@ void ui_menu::handle_events(UINT32 flags) } else { - if ((flags & MENU_FLAG_UI_DATS) != 0) + if ((flags & FLAG_UI_DATS) != 0) { top_line += local_menu_event.num_lines; return; @@ -989,8 +999,8 @@ void ui_menu::handle_events(UINT32 flags) // translate CHAR events into specials case UI_EVENT_CHAR: - menu_event.iptkey = IPT_SPECIAL; - menu_event.unichar = local_menu_event.ch; + m_event.iptkey = IPT_SPECIAL; + m_event.unichar = local_menu_event.ch; stop = true; break; @@ -1007,9 +1017,9 @@ void ui_menu::handle_events(UINT32 flags) // keys for a menu //------------------------------------------------- -void ui_menu::handle_keys(UINT32 flags) +void menu::handle_keys(UINT32 flags) { - bool ignorepause = ui_menu::stack_has_special_main_menu(); + bool ignorepause = menu::stack_has_special_main_menu(); int code; // bail if no items @@ -1021,21 +1031,21 @@ void ui_menu::handle_keys(UINT32 flags) { if (selected == item.size() - 1) { - menu_event.iptkey = IPT_UI_CANCEL; - ui_menu::stack_pop(machine()); + m_event.iptkey = IPT_UI_CANCEL; + menu::stack_pop(machine()); } return; } // bail out - if ((flags & UI_MENU_PROCESS_ONLYCHAR) != 0) + if ((flags & PROCESS_ONLYCHAR) != 0) return; // hitting cancel also pops the stack if (exclusive_input_pressed(IPT_UI_CANCEL, 0)) { if (!menu_has_search_active()) - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); return; } @@ -1043,22 +1053,22 @@ void ui_menu::handle_keys(UINT32 flags) validate_selection(1); // swallow left/right keys if they are not appropriate - bool ignoreleft = ((item[selected].flags & MENU_FLAG_LEFT_ARROW) == 0); - bool ignoreright = ((item[selected].flags & MENU_FLAG_RIGHT_ARROW) == 0); + bool ignoreleft = ((item[selected].flags & FLAG_LEFT_ARROW) == 0); + bool ignoreright = ((item[selected].flags & FLAG_RIGHT_ARROW) == 0); - if ((item[0].flags & MENU_FLAG_UI_DATS) != 0) + if ((item[0].flags & FLAG_UI_DATS) != 0) ignoreleft = ignoreright = false; // accept left/right keys as-is with repeat - if (!ignoreleft && exclusive_input_pressed(IPT_UI_LEFT, (flags & UI_MENU_PROCESS_LR_REPEAT) ? 6 : 0)) + if (!ignoreleft && exclusive_input_pressed(IPT_UI_LEFT, (flags & PROCESS_LR_REPEAT) ? 6 : 0)) return; - if (!ignoreright && exclusive_input_pressed(IPT_UI_RIGHT, (flags & UI_MENU_PROCESS_LR_REPEAT) ? 6 : 0)) + if (!ignoreright && exclusive_input_pressed(IPT_UI_RIGHT, (flags & PROCESS_LR_REPEAT) ? 6 : 0)) return; // up backs up by one item if (exclusive_input_pressed(IPT_UI_UP, 6)) { - if ((item[0].flags & MENU_FLAG_UI_DATS) != 0) + if ((item[0].flags & FLAG_UI_DATS) != 0) { top_line--; return; @@ -1073,7 +1083,7 @@ void ui_menu::handle_keys(UINT32 flags) // down advances by one item if (exclusive_input_pressed(IPT_UI_DOWN, 6)) { - if ((item[0].flags & MENU_FLAG_UI_DATS) != 0) + if ((item[0].flags & FLAG_UI_DATS) != 0) { top_line++; return; @@ -1134,7 +1144,7 @@ void ui_menu::handle_keys(UINT32 flags) mame_machine_manager::instance()->cheat().set_enable(!mame_machine_manager::instance()->cheat().enabled()); // see if any other UI keys are pressed - if (menu_event.iptkey == IPT_INVALID) + if (m_event.iptkey == IPT_INVALID) for (code = IPT_UI_FIRST + 1; code < IPT_UI_LAST; code++) { if (code == IPT_UI_CONFIGURE || (code == IPT_UI_LEFT && ignoreleft) || (code == IPT_UI_RIGHT && ignoreright) || (code == IPT_UI_PAUSE && ignorepause)) @@ -1151,7 +1161,7 @@ void ui_menu::handle_keys(UINT32 flags) // correct item //------------------------------------------------- -void ui_menu::validate_selection(int scandir) +void menu::validate_selection(int scandir) { // clamp to be in range if (selected < 0) @@ -1160,7 +1170,7 @@ void ui_menu::validate_selection(int scandir) selected = item.size() - 1; // skip past unselectable items - while (!item[selected].is_selectable()) + while (!is_selectable(item[selected])) selected = (selected + item.size() + scandir) % item.size(); } @@ -1171,14 +1181,10 @@ void ui_menu::validate_selection(int scandir) // accumulated in the free list //------------------------------------------------- -void ui_menu::clear_free_list(running_machine &machine) +void menu::clear_free_list(running_machine &machine) { - while (menu_free != nullptr) - { - ui_menu *menu = menu_free; - menu_free = menu->parent; - global_free(menu); - } + while (menu_free) + menu_free = std::move(menu_free->m_parent); } @@ -1188,13 +1194,13 @@ void ui_menu::clear_free_list(running_machine &machine) ***************************************************************************/ //------------------------------------------------- -// ui_menu::stack_reset - reset the menu stack +// menu::stack_reset - reset the menu stack //------------------------------------------------- -void ui_menu::stack_reset(running_machine &machine) +void menu::stack_reset(running_machine &machine) { - while (menu_stack != nullptr) - ui_menu::stack_pop(machine); + while (menu_stack) + menu::stack_pop(machine); } @@ -1203,12 +1209,12 @@ void ui_menu::stack_reset(running_machine &machine) // stack //------------------------------------------------- -void ui_menu::stack_push(ui_menu *menu) +void menu::stack_push(std::unique_ptr &&menu) { - menu->parent = menu_stack; - menu_stack = menu; - menu->reset(UI_MENU_RESET_SELECT_FIRST); - menu->machine().ui_input().reset(); + menu->m_parent = std::move(menu_stack); + menu_stack = std::move(menu); + menu_stack->reset(reset_options::SELECT_FIRST); + menu_stack->machine().ui_input().reset(); } @@ -1216,36 +1222,34 @@ void ui_menu::stack_push(ui_menu *menu) // stack_pop - pop a menu from the stack //------------------------------------------------- -void ui_menu::stack_pop(running_machine &machine) +void menu::stack_pop(running_machine &machine) { - if (menu_stack != nullptr) + if (menu_stack) { - ui_menu *menu = menu_stack; - menu_stack = menu->parent; - menu->parent = menu_free; - menu_free = menu; + std::unique_ptr menu(std::move(menu_stack)); + menu_stack = std::move(menu->m_parent); + menu->m_parent = std::move(menu_free); + menu_free = std::move(menu); machine.ui_input().reset(); } } //------------------------------------------------- -// ui_menu::stack_has_special_main_menu - +// menu::stack_has_special_main_menu - // check in the special main menu is in the stack //------------------------------------------------- -bool ui_menu::stack_has_special_main_menu() +bool menu::stack_has_special_main_menu() { - ui_menu *menu; - - for (menu = menu_stack; menu != nullptr; menu = menu->parent) + for (auto menu = menu_stack.get(); menu != nullptr; menu = menu->m_parent.get()) if (menu->is_special_main_menu()) return true; return false; } -void ui_menu::do_handle() +void menu::do_handle() { if(item.size() < 2) populate(); @@ -1262,14 +1266,14 @@ void ui_menu::do_handle() // and calls the menu handler //------------------------------------------------- -UINT32 ui_menu::ui_handler(mame_ui_manager &mui, render_container *container, UINT32 state) +UINT32 menu::ui_handler(mame_ui_manager &mui, render_container *container, UINT32 state) { // if we have no menus stacked up, start with the main menu - if (menu_stack == nullptr) - stack_push(global_alloc_clear(mui, container)); + if (!menu_stack) + stack_push(std::unique_ptr(global_alloc_clear(mui, container))); // update the menu state - if (menu_stack != nullptr) + if (menu_stack) menu_stack->do_handle(); // clear up anything pending to be released @@ -1292,7 +1296,7 @@ UINT32 ui_menu::ui_handler(mame_ui_manager &mui, render_container *container, UI // indicators //------------------------------------------------- -void ui_menu::render_triangle(bitmap_argb32 &dest, bitmap_argb32 &source, const rectangle &sbounds, void *param) +void menu::render_triangle(bitmap_argb32 &dest, bitmap_argb32 &source, const rectangle &sbounds, void *param) { int halfwidth = dest.width() / 2; int height = dest.height(); @@ -1345,7 +1349,7 @@ void ui_menu::render_triangle(bitmap_argb32 &dest, bitmap_argb32 &source, const // highlight //------------------------------------------------- -void ui_menu::highlight(render_container *container, float x0, float y0, float x1, float y1, rgb_t bgcolor) +void menu::highlight(render_container *container, float x0, float y0, float x1, float y1, rgb_t bgcolor) { container->add_quad(x0, y0, x1, y1, bgcolor, hilight_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE) | PRIMFLAG_PACKABLE); } @@ -1355,7 +1359,7 @@ void ui_menu::highlight(render_container *container, float x0, float y0, float x // draw_arrow //------------------------------------------------- -void ui_menu::draw_arrow(render_container *container, float x0, float y0, float x1, float y1, rgb_t fgcolor, UINT32 orientation) +void menu::draw_arrow(render_container *container, float x0, float y0, float x1, float y1, rgb_t fgcolor, UINT32 orientation) { container->add_quad(x0, y0, x1, y1, fgcolor, arrow_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXORIENT(orientation) | PRIMFLAG_PACKABLE); } @@ -1364,7 +1368,7 @@ void ui_menu::draw_arrow(render_container *container, float x0, float y0, float // init - initialize the ui menu system //------------------------------------------------- -void ui_menu::init_ui(running_machine &machine, ui_options &mopt) +void menu::init_ui(running_machine &machine, ui_options &mopt) { render_manager &mrender = machine.render(); // create a texture for hilighting items in main menu @@ -1459,9 +1463,9 @@ void ui_menu::init_ui(running_machine &machine, ui_options &mopt) // draw main menu //------------------------------------------------- -void ui_menu::draw_select_game(UINT32 flags) +void menu::draw_select_game(UINT32 flags) { - bool noinput = (flags & UI_MENU_PROCESS_NOINPUT); + bool noinput = (flags & PROCESS_NOINPUT); float line_height = ui().get_line_height(); float ud_arrow_width = line_height * machine().render().ui_aspect(); float gutter_width = 0.52f * ud_arrow_width; @@ -1470,8 +1474,8 @@ void ui_menu::draw_select_game(UINT32 flags) float visible_width = 1.0f - 4.0f * UI_BOX_LR_BORDER; float primary_left = (1.0f - visible_width) * 0.5f; float primary_width = visible_width; - bool is_swlist = ((item[0].flags & MENU_FLAG_UI_SWLIST) != 0); - bool is_favorites = ((item[0].flags & MENU_FLAG_UI_FAVORITE) != 0); + bool is_swlist = ((item[0].flags & FLAG_UI_SWLIST) != 0); + bool is_favorites = ((item[0].flags & FLAG_UI_FAVORITE) != 0); // draw background image if available if (ui().options().use_background_image() && bgrnd_bitmap->valid()) @@ -1545,7 +1549,7 @@ void ui_menu::draw_select_game(UINT32 flags) { float line_y = visible_top + (float)linenum * line_height; int itemnum = top_line + linenum; - const ui_menu_item &pitem = item[itemnum]; + const menu_item &pitem = item[itemnum]; const char *itemtext = pitem.text; rgb_t fgcolor = UI_TEXT_COLOR; rgb_t bgcolor = UI_TEXT_BG_COLOR; @@ -1556,7 +1560,7 @@ void ui_menu::draw_select_game(UINT32 flags) float line_y1 = line_y + line_height; // set the hover if this is our item - if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y && pitem.is_selectable()) + if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y && is_selectable(pitem)) hover = itemnum; // if we're selected, draw with a different background @@ -1608,7 +1612,7 @@ void ui_menu::draw_select_game(UINT32 flags) // draw the item centered else if (pitem.subtext == nullptr) { - int item_invert = pitem.flags & MENU_FLAG_INVERT; + int item_invert = pitem.flags & FLAG_INVERT; float space = 0.0f; if (ui_globals::has_icons && !is_swlist) @@ -1629,7 +1633,7 @@ void ui_menu::draw_select_game(UINT32 flags) } else { - int item_invert = pitem.flags & MENU_FLAG_INVERT; + int item_invert = pitem.flags & FLAG_INVERT; const char *subitem_text = pitem.subtext; float item_width, subitem_width; @@ -1650,7 +1654,7 @@ void ui_menu::draw_select_game(UINT32 flags) for (size_t count = visible_items; count < item.size(); count++) { - const ui_menu_item &pitem = item[count]; + const menu_item &pitem = item[count]; const char *itemtext = pitem.text; float line_x0 = x1 + 0.5f * UI_LINE_WIDTH; float line_y0 = line; @@ -1659,7 +1663,7 @@ void ui_menu::draw_select_game(UINT32 flags) rgb_t fgcolor = UI_TEXT_COLOR; rgb_t bgcolor = UI_TEXT_BG_COLOR; - if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y && pitem.is_selectable()) + if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y && is_selectable(pitem)) hover = count; // if we're selected, draw with a different background @@ -1720,7 +1724,7 @@ void ui_menu::draw_select_game(UINT32 flags) // get title and search path for right panel //------------------------------------------------- -void ui_menu::get_title_search(std::string &snaptext, std::string &searchstr) +void menu::get_title_search(std::string &snaptext, std::string &searchstr) { // get arts title text snaptext.assign(_(arts_info[ui_globals::curimage_view].title)); @@ -1758,9 +1762,9 @@ void ui_menu::get_title_search(std::string &snaptext, std::string &searchstr) // handle keys for main menu //------------------------------------------------- -void ui_menu::handle_main_keys(UINT32 flags) +void menu::handle_main_keys(UINT32 flags) { - bool ignorepause = ui_menu::stack_has_special_main_menu(); + bool ignorepause = menu::stack_has_special_main_menu(); // bail if no items if (item.size() == 0) @@ -1771,8 +1775,8 @@ void ui_menu::handle_main_keys(UINT32 flags) { if (selected == item.size() - 1 && m_focus == focused_menu::main) { - menu_event.iptkey = IPT_UI_CANCEL; - ui_menu::stack_pop(machine()); + m_event.iptkey = IPT_UI_CANCEL; + menu::stack_pop(machine()); } return; } @@ -1781,7 +1785,7 @@ void ui_menu::handle_main_keys(UINT32 flags) if (exclusive_input_pressed(IPT_UI_CANCEL, 0)) { if (!ui_error && !menu_has_search_active()) - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); return; } @@ -1789,25 +1793,25 @@ void ui_menu::handle_main_keys(UINT32 flags) validate_selection(1); // swallow left/right keys if they are not appropriate - bool ignoreleft = ((item[selected].flags & MENU_FLAG_LEFT_ARROW) == 0); - bool ignoreright = ((item[selected].flags & MENU_FLAG_RIGHT_ARROW) == 0); + bool ignoreleft = ((item[selected].flags & FLAG_LEFT_ARROW) == 0); + bool ignoreright = ((item[selected].flags & FLAG_RIGHT_ARROW) == 0); bool leftclose = (ui_globals::panels_status == HIDE_BOTH || ui_globals::panels_status == HIDE_LEFT_PANEL); bool rightclose = (ui_globals::panels_status == HIDE_BOTH || ui_globals::panels_status == HIDE_RIGHT_PANEL); // accept left/right keys as-is with repeat - if (!ignoreleft && exclusive_input_pressed(IPT_UI_LEFT, (flags & UI_MENU_PROCESS_LR_REPEAT) ? 6 : 0)) + if (!ignoreleft && exclusive_input_pressed(IPT_UI_LEFT, (flags & PROCESS_LR_REPEAT) ? 6 : 0)) { // Swap the right panel if (m_focus == focused_menu::righttop) - menu_event.iptkey = IPT_UI_LEFT_PANEL; + m_event.iptkey = IPT_UI_LEFT_PANEL; return; } - if (!ignoreright && exclusive_input_pressed(IPT_UI_RIGHT, (flags & UI_MENU_PROCESS_LR_REPEAT) ? 6 : 0)) + if (!ignoreright && exclusive_input_pressed(IPT_UI_RIGHT, (flags & PROCESS_LR_REPEAT) ? 6 : 0)) { // Swap the right panel if (m_focus == focused_menu::righttop) - menu_event.iptkey = IPT_UI_RIGHT_PANEL; + m_event.iptkey = IPT_UI_RIGHT_PANEL; return; } @@ -1817,14 +1821,14 @@ void ui_menu::handle_main_keys(UINT32 flags) // Filter if (!leftclose && m_focus == focused_menu::left) { - menu_event.iptkey = IPT_UI_UP_FILTER; + m_event.iptkey = IPT_UI_UP_FILTER; return; } // Infos if (!rightclose && m_focus == focused_menu::rightbottom) { - menu_event.iptkey = IPT_UI_UP_PANEL; + m_event.iptkey = IPT_UI_UP_PANEL; topline_datsview--; return; } @@ -1844,14 +1848,14 @@ void ui_menu::handle_main_keys(UINT32 flags) // Filter if (!leftclose && m_focus == focused_menu::left) { - menu_event.iptkey = IPT_UI_DOWN_FILTER; + m_event.iptkey = IPT_UI_DOWN_FILTER; return; } // Infos if (!rightclose && m_focus == focused_menu::rightbottom) { - menu_event.iptkey = IPT_UI_DOWN_PANEL; + m_event.iptkey = IPT_UI_DOWN_PANEL; topline_datsview++; return; } @@ -1871,7 +1875,7 @@ void ui_menu::handle_main_keys(UINT32 flags) // Infos if (!rightclose && m_focus == focused_menu::rightbottom) { - menu_event.iptkey = IPT_UI_DOWN_PANEL; + m_event.iptkey = IPT_UI_DOWN_PANEL; topline_datsview -= right_visible_lines - 1; return; } @@ -1893,7 +1897,7 @@ void ui_menu::handle_main_keys(UINT32 flags) // Infos if (!rightclose && m_focus == focused_menu::rightbottom) { - menu_event.iptkey = IPT_UI_DOWN_PANEL; + m_event.iptkey = IPT_UI_DOWN_PANEL; topline_datsview += right_visible_lines - 1; return; } @@ -1915,7 +1919,7 @@ void ui_menu::handle_main_keys(UINT32 flags) // Infos if (!rightclose && m_focus == focused_menu::rightbottom) { - menu_event.iptkey = IPT_UI_DOWN_PANEL; + m_event.iptkey = IPT_UI_DOWN_PANEL; topline_datsview = 0; return; } @@ -1933,7 +1937,7 @@ void ui_menu::handle_main_keys(UINT32 flags) // Infos if (!rightclose && m_focus == focused_menu::rightbottom) { - menu_event.iptkey = IPT_UI_DOWN_PANEL; + m_event.iptkey = IPT_UI_DOWN_PANEL; topline_datsview = totallines; return; } @@ -1956,7 +1960,7 @@ void ui_menu::handle_main_keys(UINT32 flags) mame_machine_manager::instance()->cheat().set_enable(!mame_machine_manager::instance()->cheat().enabled()); // see if any other UI keys are pressed - if (menu_event.iptkey == IPT_INVALID) + if (m_event.iptkey == IPT_INVALID) for (int code = IPT_UI_FIRST + 1; code < IPT_UI_LAST; code++) { if (ui_error || code == IPT_UI_CONFIGURE || (code == IPT_UI_LEFT && ignoreleft) || (code == IPT_UI_RIGHT && ignoreright) || (code == IPT_UI_PAUSE && ignorepause)) @@ -1971,7 +1975,7 @@ void ui_menu::handle_main_keys(UINT32 flags) // handle input events for main menu //------------------------------------------------- -void ui_menu::handle_main_events(UINT32 flags) +void menu::handle_main_events(UINT32 flags) { bool stop = false; ui_event local_menu_event; @@ -2001,7 +2005,7 @@ void ui_menu::handle_main_events(UINT32 flags) { if (ui_error) { - menu_event.iptkey = IPT_OTHER; + m_event.iptkey = IPT_OTHER; stop = true; } else @@ -2030,9 +2034,9 @@ void ui_menu::handle_main_events(UINT32 flags) set_pressed(); } else if (hover == HOVER_UI_RIGHT) - menu_event.iptkey = IPT_UI_RIGHT; + m_event.iptkey = IPT_UI_RIGHT; else if (hover == HOVER_UI_LEFT) - menu_event.iptkey = IPT_UI_LEFT; + m_event.iptkey = IPT_UI_LEFT; else if (hover == HOVER_DAT_DOWN) topline_datsview += right_visible_lines - 1; else if (hover == HOVER_DAT_UP) @@ -2061,17 +2065,17 @@ void ui_menu::handle_main_events(UINT32 flags) } else if (hover == HOVER_B_FAV) { - menu_event.iptkey = IPT_UI_FAVORITES; + m_event.iptkey = IPT_UI_FAVORITES; stop = true; } else if (hover == HOVER_B_EXPORT) { - menu_event.iptkey = IPT_UI_EXPORT; + m_event.iptkey = IPT_UI_EXPORT; stop = true; } else if (hover == HOVER_B_DATS) { - menu_event.iptkey = IPT_UI_DATS; + m_event.iptkey = IPT_UI_DATS; stop = true; } else if (hover >= HOVER_RP_FIRST && hover <= HOVER_RP_LAST) @@ -2082,13 +2086,13 @@ void ui_menu::handle_main_events(UINT32 flags) else if (hover >= HOVER_SW_FILTER_FIRST && hover <= HOVER_SW_FILTER_LAST) { l_sw_hover = (HOVER_SW_FILTER_FIRST - hover) * (-1); - menu_event.iptkey = IPT_OTHER; + m_event.iptkey = IPT_OTHER; stop = true; } else if (hover >= HOVER_FILTER_FIRST && hover <= HOVER_FILTER_LAST) { l_hover = (HOVER_FILTER_FIRST - hover) * (-1); - menu_event.iptkey = IPT_OTHER; + m_event.iptkey = IPT_OTHER; stop = true; } } @@ -2100,13 +2104,13 @@ void ui_menu::handle_main_events(UINT32 flags) if (hover >= 0 && hover < item.size()) { selected = hover; - menu_event.iptkey = IPT_UI_SELECT; + m_event.iptkey = IPT_UI_SELECT; } if (selected == item.size() - 1) { - menu_event.iptkey = IPT_UI_CANCEL; - ui_menu::stack_pop(machine()); + m_event.iptkey = IPT_UI_CANCEL; + menu::stack_pop(machine()); } stop = true; break; @@ -2140,13 +2144,13 @@ void ui_menu::handle_main_events(UINT32 flags) case UI_EVENT_CHAR: if (exclusive_input_pressed(IPT_UI_CONFIGURE, 0)) { - menu_event.iptkey = IPT_UI_CONFIGURE; + m_event.iptkey = IPT_UI_CONFIGURE; stop = true; } else { - menu_event.iptkey = IPT_SPECIAL; - menu_event.unichar = local_menu_event.ch; + m_event.iptkey = IPT_SPECIAL; + m_event.unichar = local_menu_event.ch; stop = true; } break; @@ -2157,9 +2161,9 @@ void ui_menu::handle_main_events(UINT32 flags) selected = hover; m_prev_selected = item[selected].ref; m_focus = focused_menu::main; - menu_event.iptkey = IPT_CUSTOM; - menu_event.mouse.x0 = local_menu_event.mouse_x; - menu_event.mouse.y0 = local_menu_event.mouse_y; + m_event.iptkey = IPT_CUSTOM; + m_event.mouse.x0 = local_menu_event.mouse_x; + m_event.mouse.y0 = local_menu_event.mouse_y; stop = true; } break; @@ -2175,7 +2179,7 @@ void ui_menu::handle_main_events(UINT32 flags) // draw right box title //------------------------------------------------- -float ui_menu::draw_right_box_title(float x1, float y1, float x2, float y2) +float menu::draw_right_box_title(float x1, float y1, float x2, float y2) { float line_height = ui().get_line_height(); float midl = (x2 - x1) * 0.5f; @@ -2245,7 +2249,7 @@ float ui_menu::draw_right_box_title(float x1, float y1, float x2, float y2) // common function for images render //------------------------------------------------- -std::string ui_menu::arts_render_common(float origx1, float origy1, float origx2, float origy2) +std::string menu::arts_render_common(float origx1, float origy1, float origx2, float origy2) { float line_height = ui().get_line_height(); std::string snaptext, searchstr; @@ -2289,7 +2293,7 @@ std::string ui_menu::arts_render_common(float origx1, float origy1, float origx2 // draw favorites star //------------------------------------------------- -void ui_menu::draw_star(float x0, float y0) +void menu::draw_star(float x0, float y0) { float y1 = y0 + ui().get_line_height(); float x1 = x0 + ui().get_line_height() * container->manager().ui_aspect(); @@ -2300,7 +2304,7 @@ void ui_menu::draw_star(float x0, float y0) // draw toolbar //------------------------------------------------- -void ui_menu::draw_toolbar(float x1, float y1, float x2, float y2, bool software) +void menu::draw_toolbar(float x1, float y1, float x2, float y2, bool software) { // draw a box ui().draw_outlined_box(container, x1, y1, x2, y2, rgb_t(0xEF, 0x12, 0x47, 0x7B)); @@ -2353,7 +2357,7 @@ void ui_menu::draw_toolbar(float x1, float y1, float x2, float y2, bool software // perform rendering of image //------------------------------------------------- -void ui_menu::arts_render_images(bitmap_argb32 *tmp_bitmap, float origx1, float origy1, float origx2, float origy2, bool software) +void menu::arts_render_images(bitmap_argb32 *tmp_bitmap, float origx1, float origy1, float origx2, float origy2, bool software) { bool no_available = false; float line_height = ui().get_line_height(); @@ -2441,7 +2445,7 @@ void ui_menu::arts_render_images(bitmap_argb32 *tmp_bitmap, float origx1, float // draw common arrows //------------------------------------------------- -void ui_menu::draw_common_arrow(float origx1, float origy1, float origx2, float origy2, int current, int dmin, int dmax, float title_size) +void menu::draw_common_arrow(float origx1, float origy1, float origx2, float origy2, int current, int dmin, int dmax, float title_size) { float line_height = ui().get_line_height(); float lr_arrow_width = 0.4f * line_height * machine().render().ui_aspect(); @@ -2493,7 +2497,7 @@ void ui_menu::draw_common_arrow(float origx1, float origy1, float origx2, float // draw icons //------------------------------------------------- -void ui_menu::draw_icon(int linenum, void *selectedref, float x0, float y0) +void menu::draw_icon(int linenum, void *selectedref, float x0, float y0) { static const game_driver *olddriver[MAX_ICONS_RENDER] = { nullptr }; float x1 = x0 + ui().get_line_height() * container->manager().ui_aspect(container); @@ -2598,7 +2602,7 @@ void ui_menu::draw_icon(int linenum, void *selectedref, float x0, float y0) // draw info arrow //------------------------------------------------- -void ui_menu::info_arrow(int ub, float origx1, float origx2, float oy1, float line_height, float text_size, float ud_arrow_width) +void menu::info_arrow(int ub, float origx1, float origx2, float oy1, float line_height, float text_size, float ud_arrow_width) { rgb_t fgcolor = UI_TEXT_COLOR; UINT32 orientation = (!ub) ? ROT0 : ROT0 ^ ORIENTATION_FLIP_Y; @@ -2619,7 +2623,7 @@ void ui_menu::info_arrow(int ub, float origx1, float origx2, float oy1, float li // draw - draw palette menu //------------------------------------------------- -void ui_menu::draw_palette_menu() +void menu::draw_palette_menu() { float line_height = ui().get_line_height(); float lr_arrow_width = 0.4f * line_height * machine().render().ui_aspect(); @@ -2635,7 +2639,7 @@ void ui_menu::draw_palette_menu() float visible_main_menu_height = 0; for (itemnum = 0; itemnum < item.size(); itemnum++) { - const ui_menu_item &pitem = item[itemnum]; + const menu_item &pitem = item[itemnum]; // compute width of left hand side float total_width = gutter_width + ui().get_string_width(pitem.text) + gutter_width; @@ -2712,7 +2716,7 @@ void ui_menu::draw_palette_menu() { float line_y = visible_top + (float)linenum * line_height; itemnum = top_line + linenum; - const ui_menu_item &pitem = item[itemnum]; + const menu_item &pitem = item[itemnum]; const char *itemtext = pitem.text; rgb_t fgcolor = UI_TEXT_COLOR; rgb_t bgcolor = UI_TEXT_BG_COLOR; @@ -2720,7 +2724,7 @@ void ui_menu::draw_palette_menu() float line_y1 = line_y + line_height; // set the hover if this is our item - if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y && pitem.is_selectable()) + if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y && is_selectable(pitem)) hover = itemnum; // if we're selected, draw with a different background @@ -2807,7 +2811,7 @@ void ui_menu::draw_palette_menu() // draw - draw dats menu //------------------------------------------------- -void ui_menu::draw_dats_menu() +void menu::draw_dats_menu() { float line_height = ui().get_line_height(); float ud_arrow_width = line_height * machine().render().ui_aspect(); @@ -2870,7 +2874,7 @@ void ui_menu::draw_dats_menu() { float line_y = visible_top + (float)linenum * line_height; int itemnum = top_line + linenum; - const ui_menu_item &pitem = item[itemnum]; + const menu_item &pitem = item[itemnum]; const char *itemtext = pitem.text; rgb_t fgcolor = UI_TEXT_COLOR; rgb_t bgcolor = UI_TEXT_BG_COLOR; @@ -2918,7 +2922,7 @@ void ui_menu::draw_dats_menu() for (size_t count = visible_items; count < item.size(); count++) { - const ui_menu_item &pitem = item[count]; + const menu_item &pitem = item[count]; const char *itemtext = pitem.text; float line_x0 = x1 + 0.5f * UI_LINE_WIDTH; float line_y0 = line; @@ -2927,7 +2931,7 @@ void ui_menu::draw_dats_menu() rgb_t fgcolor = UI_SELECTED_COLOR; rgb_t bgcolor = UI_SELECTED_BG_COLOR; - if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y && pitem.is_selectable()) + if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y && is_selectable(pitem)) hover = count; if (strcmp(itemtext, MENU_SEPARATOR_ITEM) == 0) @@ -2949,7 +2953,7 @@ void ui_menu::draw_dats_menu() visitems = visible_lines - (top_line != 0) - (top_line + visible_lines != visible_items); } -void ui_menu::set_pressed() +void menu::set_pressed() { (m_repeat == 0) ? m_repeat = osd_ticks() + osd_ticks_per_second() / 2 : m_repeat = osd_ticks() + osd_ticks_per_second() / 4; m_pressed = true; @@ -2961,7 +2965,7 @@ void ui_menu::set_pressed() // or footer text //------------------------------------------------- -void ui_menu::extra_text_draw_box(float origx1, float origx2, float origy, float yspan, const char *text, int direction) +void menu::extra_text_draw_box(float origx1, float origx2, float origy, float yspan, const char *text, int direction) { float text_width, text_height; float width, maxwidth; @@ -3004,7 +3008,7 @@ void ui_menu::extra_text_draw_box(float origx1, float origx2, float origy, float // and footer text //------------------------------------------------- -void ui_menu::extra_text_render(float top, float bottom, +void menu::extra_text_render(float top, float bottom, float origx1, float origy1, float origx2, float origy2, const char *header, const char *footer) { @@ -3016,3 +3020,5 @@ void ui_menu::extra_text_render(float top, float bottom, if (footer != nullptr) extra_text_draw_box(origx1, origx2, origy2, bottom, footer, +1); } + +} // namespace ui diff --git a/src/frontend/mame/ui/menu.h b/src/frontend/mame/ui/menu.h index c7638925cb0..7e7c12387c4 100644 --- a/src/frontend/mame/ui/menu.h +++ b/src/frontend/mame/ui/menu.h @@ -10,102 +10,62 @@ #pragma once -#ifndef __UI_MENU_H__ -#define __UI_MENU_H__ +#ifndef MAME_FRONTEND_UI_MENU_H +#define MAME_FRONTEND_UI_MENU_H #include "render.h" #include "language.h" #include "ui/ui.h" #include "ui/menuitem.h" -/*************************************************************************** - CONSTANTS -***************************************************************************/ -// flags for menu items -#define MENU_FLAG_LEFT_ARROW (1 << 0) -#define MENU_FLAG_RIGHT_ARROW (1 << 1) -#define MENU_FLAG_INVERT (1 << 2) -#define MENU_FLAG_MULTILINE (1 << 3) -#define MENU_FLAG_REDTEXT (1 << 4) -#define MENU_FLAG_DISABLE (1 << 5) -#define MENU_FLAG_UI (1 << 6) -#define MENU_FLAG_UI_DATS (1 << 7) -#define MENU_FLAG_UI_SWLIST (1 << 8) -#define MENU_FLAG_UI_FAVORITE (1 << 9) -#define MENU_FLAG_UI_PALETTE (1 << 10) -#define MENU_FLAG_UI_HEADING (1 << 11) +#include -// flags to pass to ui_menu_process -#define UI_MENU_PROCESS_NOKEYS 1 -#define UI_MENU_PROCESS_LR_REPEAT 2 -#define UI_MENU_PROCESS_CUSTOM_ONLY 4 -#define UI_MENU_PROCESS_ONLYCHAR 8 -#define UI_MENU_PROCESS_NOINPUT 16 -#define UI_MENU_PROCESS_NOIMAGE 32 - -// options for ui_menu_reset -enum ui_menu_reset_options -{ - UI_MENU_RESET_SELECT_FIRST, - UI_MENU_RESET_REMEMBER_POSITION, - UI_MENU_RESET_REMEMBER_REF -}; +namespace ui { /*************************************************************************** TYPE DEFINITIONS ***************************************************************************/ -// menu-related events -struct ui_menu_event -{ - void *itemref; // reference for the selected item - ui_menu_item_type type; // item type (eventually will go away when itemref is proper ui_menu_item class rather than void*) - int iptkey; // one of the IPT_* values from inptport.h - unicode_char unichar; // unicode character if iptkey == IPT_SPECIAL - render_bounds mouse; // mouse position if iptkey == IPT_CUSTOM -}; - -struct ui_menu_pool -{ - ui_menu_pool *next; // chain to next one - UINT8 *top; // top of the pool - UINT8 *end; // end of the pool -}; - - -class ui_menu +class menu { public: - ui_menu(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu(); + // flags for menu items + enum + { + FLAG_LEFT_ARROW = (1 << 0), + FLAG_RIGHT_ARROW = (1 << 1), + FLAG_INVERT = (1 << 2), + FLAG_MULTILINE = (1 << 3), + FLAG_REDTEXT = (1 << 4), + FLAG_DISABLE = (1 << 5), + FLAG_UI = (1 << 6), + FLAG_UI_DATS = (1 << 7), + FLAG_UI_SWLIST = (1 << 8), + FLAG_UI_FAVORITE = (1 << 9), + FLAG_UI_PALETTE = (1 << 10), + FLAG_UI_HEADING = (1 << 11) + }; + + virtual ~menu(); mame_ui_manager &ui() const { return m_ui; } running_machine &machine() const { return m_ui.machine(); } - render_container *container; // render_container we render to - ui_menu_event menu_event; // the UI menu_event that occurred - ui_menu *parent; // pointer to parent menu - int resetpos; // reset position - void *resetref; // reset reference - int selected; // which item is selected - int hover; // which item is being hovered over - int visitems; // number of visible items - float customtop; // amount of extra height to add at the top - float custombottom; // amount of extra height to add at the bottom - ui_menu_pool *pool; // list of memory pools - std::vector item; // array of items - - // free all items in the menu, and all memory allocated from the memory pool - void reset(ui_menu_reset_options options); + render_container *container; // render_container we render to + int resetpos; // reset position + void *resetref; // reset reference + int selected; // which item is selected + int hover; // which item is being hovered over + int visitems; // number of visible items + float customtop; // amount of extra height to add at the top + float custombottom; // amount of extra height to add at the bottom + std::vector item; // array of items // append a new item to the end of the menu - void item_append(const char *text, const char *subtext, UINT32 flags, void *ref, ui_menu_item_type type = ui_menu_item_type::UNKNOWN); - void item_append(ui_menu_item item); - void item_append(ui_menu_item_type type); - - // process a menu, drawing it and returning any interesting events - const ui_menu_event *process(UINT32 flags, float x0 = 0.0f, float y0 = 0.0f); + void item_append(const char *text, const char *subtext, UINT32 flags, void *ref, menu_item_type type = menu_item_type::UNKNOWN); + void item_append(menu_item item); + void item_append(menu_item_type type); // configure the menu for custom rendering virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2); @@ -124,7 +84,6 @@ public: // request the specific handling of the game selection main menu bool is_special_main_menu() const; - void set_special_main_menu(bool disable); // Global initialization static void init(running_machine &machine, ui_options &mopt); @@ -134,7 +93,18 @@ public: static void stack_reset(running_machine &machine); // push a new menu onto the stack - static void stack_push(ui_menu *menu); + template + static void stack_push(Params &&... args) + { + stack_push(std::unique_ptr(global_alloc_clear(std::forward(args)...))); + } + template + static void stack_push_special_main(Params &&... args) + { + std::unique_ptr ptr(global_alloc_clear(std::forward(args)...)); + ptr->set_special_main_menu(true); + stack_push(std::move(ptr)); + } // pop a menu from the stack static void stack_pop(running_machine &machine); @@ -153,7 +123,6 @@ public: // Used by sliders void validate_selection(int scandir); - static ui_menu *menu_stack; void do_handle(); @@ -167,13 +136,9 @@ public: virtual bool menu_has_search_active() { return false; } private: - static ui_menu *menu_free; static std::unique_ptr hilight_bitmap; static render_texture *hilight_texture, *arrow_texture; - bool m_special_main_menu; - mame_ui_manager &m_ui; // UI we are attached to - void draw(UINT32 flags, float x0 = 0.0f, float y0 = 0.0f); void draw_text_box(); void handle_events(UINT32 flags); @@ -227,10 +192,39 @@ public: if (max == 0) return 0; else - return ((actual <= min) ? MENU_FLAG_RIGHT_ARROW : (actual >= max ? MENU_FLAG_LEFT_ARROW : (MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW))); + return ((actual <= min) ? FLAG_RIGHT_ARROW : (actual >= max ? FLAG_LEFT_ARROW : (FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW))); } protected: + // flags to pass to process + enum + { + PROCESS_NOKEYS = 1, + PROCESS_LR_REPEAT = 2, + PROCESS_CUSTOM_ONLY = 4, + PROCESS_ONLYCHAR = 8, + PROCESS_NOINPUT = 16, + PROCESS_NOIMAGE = 32 + }; + + // options for reset + enum class reset_options + { + SELECT_FIRST, + REMEMBER_POSITION, + REMEMBER_REF + }; + + // menu-related events + struct event + { + void *itemref; // reference for the selected item + menu_item_type type; // item type (eventually will go away when itemref is proper ui_menu_item class rather than void*) + int iptkey; // one of the IPT_* values from inptport.h + unicode_char unichar; // unicode character if iptkey == IPT_SPECIAL + render_bounds mouse; // mouse position if iptkey == IPT_CUSTOM + }; + int topline_datsview; // right box top line int top_line; // main box top line int l_sw_hover; @@ -238,6 +232,17 @@ protected: int totallines; int skip_main_items; + menu(mame_ui_manager &mui, render_container *container); + + // free all items in the menu, and all memory allocated from the memory pool + void reset(reset_options options); + void reset_parent(reset_options options) { m_parent->reset(options); } + static void reset_topmost(reset_options options) { if (menu_stack) menu_stack->reset(options); } + + // process a menu, drawing it and returning any interesting events + const event *process(UINT32 flags, float x0 = 0.0f, float y0 = 0.0f); + void process_parent() { m_parent->process(PROCESS_NOINPUT); } + // draw right box float draw_right_box_title(float x1, float y1, float x2, float y2); @@ -252,6 +257,9 @@ protected: // draw header and footer text void extra_text_render(float top, float bottom, float origx1, float origy1, float origx2, float origy2, const char *header, const char *footer); + template + static T *topmost_menu() { return dynamic_cast(menu_stack.get()); } + int visible_lines; // main box visible lines int right_visible_lines; // right box lines @@ -260,11 +268,16 @@ protected: static std::unique_ptr hilight_main_bitmap; static render_texture *hilight_main_texture; -private: - // mouse button held down - bool m_pressed = false; - osd_ticks_t m_repeat = 0; +private: + struct pool + { + pool *next; // chain to next one + UINT8 *top; // top of the pool + UINT8 *end; // end of the pool + }; + + void reset_pressed() { m_pressed = false; m_repeat = 0; } bool mouse_pressed() { return (osd_ticks() >= m_repeat); } void set_pressed(); @@ -274,6 +287,12 @@ private: static bitmap_argb32 *icons_bitmap[]; static render_texture *icons_texture[]; + // request the specific handling of the game selection main menu + void set_special_main_menu(bool disable); + + // push a new menu onto the stack + static void stack_push(std::unique_ptr &&menu); + // toolbar static bitmap_argb32 *toolbar_bitmap[], *sw_toolbar_bitmap[]; static render_texture *toolbar_texture[], *sw_toolbar_texture[]; @@ -297,6 +316,19 @@ private: void draw_icon(int linenum, void *selectedref, float x1, float y1); void extra_text_draw_box(float origx1, float origx2, float origy, float yspan, const char *text, int direction); + + bool m_special_main_menu; + mame_ui_manager &m_ui; // UI we are attached to + std::unique_ptr m_parent; // pointer to parent menu + bool m_pressed; // mouse button held down + osd_ticks_t m_repeat; + event m_event; // the UI event that occurred + pool *m_pool; // list of memory pools + + static std::unique_ptr menu_stack; + static std::unique_ptr menu_free; }; -#endif // __UI_MENU_H__ +} // namespace ui + +#endif // MAME_FRONTEND_UI_MENU_H diff --git a/src/frontend/mame/ui/menuitem.h b/src/frontend/mame/ui/menuitem.h index 3fac820b5e7..58a8b50d07b 100644 --- a/src/frontend/mame/ui/menuitem.h +++ b/src/frontend/mame/ui/menuitem.h @@ -11,32 +11,34 @@ #pragma once -#ifndef __UI_MENUITEM__ -#define __UI_MENUITEM__ +#ifndef MAME_FRONTEND_UI_MENUITEM_H +#define MAME_FRONTEND_UI_MENUITEM_H #include "emu.h" +namespace ui { + // special menu item for separators #define MENU_SEPARATOR_ITEM "---" // types of menu items (TODO: please expand) -enum class ui_menu_item_type +enum class menu_item_type { UNKNOWN, SLIDER, SEPARATOR }; -class ui_menu_item +class menu_item { public: - const char *text; - const char *subtext; - UINT32 flags; - void *ref; - ui_menu_item_type type; // item type (eventually will go away when itemref is proper ui_menu_item class rather than void*) - - inline bool is_selectable() const; + const char *text; + const char *subtext; + UINT32 flags; + void *ref; + menu_item_type type; // item type (eventually will go away when itemref is proper ui_menu_item class rather than void*) }; -#endif // __UI_MENUITEM__ +} // namespace ui + +#endif // MAME_FRONTEND_UI_MENUITEM_H diff --git a/src/frontend/mame/ui/miscmenu.cpp b/src/frontend/mame/ui/miscmenu.cpp index 7053a8d78a3..3158055febd 100644 --- a/src/frontend/mame/ui/miscmenu.cpp +++ b/src/frontend/mame/ui/miscmenu.cpp @@ -23,56 +23,58 @@ #include "ui/inifile.h" #include "ui/submenu.h" +namespace ui { + /*************************************************************************** MENU HANDLERS ***************************************************************************/ /*------------------------------------------------- - ui_menu_keyboard_mode - menu that + menu_keyboard_mode - menu that -------------------------------------------------*/ -ui_menu_keyboard_mode::ui_menu_keyboard_mode(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container) +menu_keyboard_mode::menu_keyboard_mode(mame_ui_manager &mui, render_container *container) : menu(mui, container) { } -void ui_menu_keyboard_mode::populate() +void menu_keyboard_mode::populate() { bool natural = ui().use_natural_keyboard(); - item_append(_("Keyboard Mode:"), natural ? _("Natural") : _("Emulated"), natural ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, nullptr); + item_append(_("Keyboard Mode:"), natural ? _("Natural") : _("Emulated"), natural ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW, nullptr); } -ui_menu_keyboard_mode::~ui_menu_keyboard_mode() +menu_keyboard_mode::~menu_keyboard_mode() { } -void ui_menu_keyboard_mode::handle() +void menu_keyboard_mode::handle() { bool natural = ui().use_natural_keyboard(); /* process the menu */ - const ui_menu_event *menu_event = process(0); + const event *menu_event = process(0); if (menu_event != nullptr) { if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) { ui().set_use_natural_keyboard(natural ^ true); - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); } } } /*------------------------------------------------- - ui_menu_bios_selection - populates the main + menu_bios_selection - populates the main bios selection menu -------------------------------------------------*/ -ui_menu_bios_selection::ui_menu_bios_selection(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container) +menu_bios_selection::menu_bios_selection(mame_ui_manager &mui, render_container *container) : menu(mui, container) { } -void ui_menu_bios_selection::populate() +void menu_bios_selection::populate() { /* cycle through all devices for this system */ for (device_t &device : device_iterator(machine().root_device())) @@ -87,26 +89,26 @@ void ui_menu_bios_selection::populate() val = ROM_GETHASHDATA(rom); } } - item_append(device.owner() == nullptr ? "driver" : device.tag()+1, val, MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)&device); + item_append(device.owner() == nullptr ? "driver" : device.tag()+1, val, FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, (void *)&device); } } - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); item_append(_("Reset"), nullptr, 0, (void *)1); } -ui_menu_bios_selection::~ui_menu_bios_selection() +menu_bios_selection::~menu_bios_selection() { } /*------------------------------------------------- - ui_menu_bios_selection - menu that + menu_bios_selection - menu that -------------------------------------------------*/ -void ui_menu_bios_selection::handle() +void menu_bios_selection::handle() { /* process the menu */ - const ui_menu_event *menu_event = process(0); + const event *menu_event = process(0); if (menu_event != nullptr && menu_event->itemref != nullptr) { @@ -134,18 +136,18 @@ void ui_menu_bios_selection::handle() machine().options().set_value(dev->owner()->tag()+1, value.c_str(), OPTION_PRIORITY_CMDLINE, error); assert(error.empty()); } - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); } } } -ui_menu_network_devices::ui_menu_network_devices(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container) +menu_network_devices::menu_network_devices(mame_ui_manager &mui, render_container *container) : menu(mui, container) { } -ui_menu_network_devices::~ui_menu_network_devices() +menu_network_devices::~menu_network_devices() { } @@ -154,7 +156,7 @@ ui_menu_network_devices::~ui_menu_network_devices() network device menu -------------------------------------------------*/ -void ui_menu_network_devices::populate() +void menu_network_devices::populate() { /* cycle through all devices for this system */ for (device_network_interface &network : network_interface_iterator(machine().root_device())) @@ -170,18 +172,18 @@ void ui_menu_network_devices::populate() entry = entry->m_next; } - item_append(network.device().tag(), (title) ? title : "------", MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)network); + item_append(network.device().tag(), (title) ? title : "------", FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, (void *)network); } } /*------------------------------------------------- - ui_menu_network_devices - menu that + menu_network_devices - menu that -------------------------------------------------*/ -void ui_menu_network_devices::handle() +void menu_network_devices::handle() { /* process the menu */ - const ui_menu_event *menu_event = process(0); + const event *menu_event = process(0); if (menu_event != nullptr && menu_event->itemref != nullptr) { @@ -191,7 +193,7 @@ void ui_menu_network_devices::handle() if (menu_event->iptkey == IPT_UI_LEFT) curr--; else curr++; if (curr==-2) curr = netdev_count() - 1; network->set_interface(curr); - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); } } } @@ -202,7 +204,7 @@ void ui_menu_network_devices::handle() information menu -------------------------------------------------*/ -void ui_menu_bookkeeping::handle() +void menu_bookkeeping::handle() { attotime curtime; @@ -210,7 +212,7 @@ void ui_menu_bookkeeping::handle() curtime = machine().time(); if (prevtime.seconds() != curtime.seconds()) { - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); prevtime = curtime; populate(); } @@ -224,15 +226,15 @@ void ui_menu_bookkeeping::handle() menu_bookkeeping - handle the bookkeeping information menu -------------------------------------------------*/ -ui_menu_bookkeeping::ui_menu_bookkeeping(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container) +menu_bookkeeping::menu_bookkeeping(mame_ui_manager &mui, render_container *container) : menu(mui, container) { } -ui_menu_bookkeeping::~ui_menu_bookkeeping() +menu_bookkeeping::~menu_bookkeeping() { } -void ui_menu_bookkeeping::populate() +void menu_bookkeeping::populate() { int tickets = machine().bookkeeping().get_dispensed_tickets(); std::ostringstream tempstring; @@ -264,7 +266,7 @@ void ui_menu_bookkeeping::populate() } /* append the single item */ - item_append(tempstring.str().c_str(), nullptr, MENU_FLAG_MULTILINE, nullptr); + item_append(tempstring.str().c_str(), nullptr, FLAG_MULTILINE, nullptr); } /*------------------------------------------------- @@ -272,10 +274,10 @@ void ui_menu_bookkeeping::populate() menu -------------------------------------------------*/ -void ui_menu_crosshair::handle() +void menu_crosshair::handle() { /* process the menu */ - const ui_menu_event *menu_event = process(UI_MENU_PROCESS_LR_REPEAT); + const event *menu_event = process(PROCESS_LR_REPEAT); /* handle events */ if (menu_event != nullptr && menu_event->itemref != nullptr) @@ -362,7 +364,7 @@ void ui_menu_crosshair::handle() machine().crosshair().set_user_settings(data->player, &settings); /* rebuild the menu */ - reset(UI_MENU_RESET_REMEMBER_POSITION); + reset(reset_options::REMEMBER_POSITION); } } } @@ -373,11 +375,11 @@ void ui_menu_crosshair::handle() crosshair settings menu -------------------------------------------------*/ -ui_menu_crosshair::ui_menu_crosshair(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container) +menu_crosshair::menu_crosshair(mame_ui_manager &mui, render_container *container) : menu(mui, container) { } -void ui_menu_crosshair::populate() +void menu_crosshair::populate() { crosshair_user_settings settings; crosshair_item_data *data; @@ -412,9 +414,9 @@ void ui_menu_crosshair::populate() /* put on arrows */ if (data->cur > data->min) - flags |= MENU_FLAG_LEFT_ARROW; + flags |= FLAG_LEFT_ARROW; if (data->cur < data->max) - flags |= MENU_FLAG_RIGHT_ARROW; + flags |= FLAG_RIGHT_ARROW; /* add CROSSHAIR_ITEM_VIS menu */ sprintf(temp_text, "P%d Visibility", player + 1); @@ -489,9 +491,9 @@ void ui_menu_crosshair::populate() /* setup the selection flags */ flags = 0; if (finished) - flags |= MENU_FLAG_RIGHT_ARROW; + flags |= FLAG_RIGHT_ARROW; if (found) - flags |= MENU_FLAG_LEFT_ARROW; + flags |= FLAG_LEFT_ARROW; /* add CROSSHAIR_ITEM_PIC menu */ sprintf(temp_text, "P%d Crosshair", player + 1); @@ -513,9 +515,9 @@ void ui_menu_crosshair::populate() /* put on arrows in visible menu */ if (data->cur > data->min) - flags |= MENU_FLAG_LEFT_ARROW; + flags |= FLAG_LEFT_ARROW; if (data->cur < data->max) - flags |= MENU_FLAG_RIGHT_ARROW; + flags |= FLAG_RIGHT_ARROW; /* add CROSSHAIR_ITEM_AUTO_TIME menu */ sprintf(temp_text, "%d", settings.auto_time); @@ -526,7 +528,7 @@ void ui_menu_crosshair::populate() // item_append("", "", nullptr, nullptr); } -ui_menu_crosshair::~ui_menu_crosshair() +menu_crosshair::~menu_crosshair() { } @@ -535,37 +537,37 @@ ui_menu_crosshair::~ui_menu_crosshair() quitting the game -------------------------------------------------*/ -ui_menu_quit_game::ui_menu_quit_game(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container) +menu_quit_game::menu_quit_game(mame_ui_manager &mui, render_container *container) : menu(mui, container) { } -ui_menu_quit_game::~ui_menu_quit_game() +menu_quit_game::~menu_quit_game() { } -void ui_menu_quit_game::populate() +void menu_quit_game::populate() { } -void ui_menu_quit_game::handle() +void menu_quit_game::handle() { /* request a reset */ machine().schedule_exit(); /* reset the menu stack */ - ui_menu::stack_reset(machine()); + menu::stack_reset(machine()); } //------------------------------------------------- // ctor / dtor //------------------------------------------------- -ui_menu_export::ui_menu_export(mame_ui_manager &mui, render_container *container, std::vector drvlist) - : ui_menu(mui, container), m_list(drvlist) +menu_export::menu_export(mame_ui_manager &mui, render_container *container, std::vector drvlist) + : menu(mui, container), m_list(drvlist) { } -ui_menu_export::~ui_menu_export() +menu_export::~menu_export() { } @@ -573,19 +575,19 @@ ui_menu_export::~ui_menu_export() // handlethe options menu //------------------------------------------------- -void ui_menu_export::handle() +void menu_export::handle() { // process the menu - ui_menu::menu_stack->parent->process(UI_MENU_PROCESS_NOINPUT); - const ui_menu_event *m_event = process(UI_MENU_PROCESS_NOIMAGE); - if (m_event != nullptr && m_event->itemref != nullptr) + process_parent(); + const event *menu_event = process(PROCESS_NOIMAGE); + if (menu_event != nullptr && menu_event->itemref != nullptr) { - switch ((FPTR)m_event->itemref) + switch ((FPTR)menu_event->itemref) { case 1: case 3: { - if (m_event->iptkey == IPT_UI_SELECT) + if (menu_event->iptkey == IPT_UI_SELECT) { std::string filename("exported"); emu_file infile(ui().options().ui_path(), OPEN_FLAG_READ); @@ -616,7 +618,7 @@ void ui_menu_export::handle() drvlist.include(driver_list::find(*elem)); info_xml_creator creator(drvlist); - creator.output(pfile, ((FPTR)m_event->itemref == 1) ? false : true); + creator.output(pfile, ((FPTR)menu_event->itemref == 1) ? false : true); fclose(pfile); machine().popmessage(_("%s.xml saved under ui folder."), filename.c_str()); } @@ -625,7 +627,7 @@ void ui_menu_export::handle() } case 2: { - if (m_event->iptkey == IPT_UI_SELECT) + if (menu_event->iptkey == IPT_UI_SELECT) { std::string filename("exported"); emu_file infile(ui().options().ui_path(), OPEN_FLAG_READ); @@ -673,21 +675,21 @@ void ui_menu_export::handle() // populate //------------------------------------------------- -void ui_menu_export::populate() +void menu_export::populate() { // add options items item_append(_("Export list in XML format (like -listxml)"), nullptr, 0, (void *)(FPTR)1); item_append(_("Export list in XML format (like -listxml, but exclude devices)"), nullptr, 0, (void *)(FPTR)3); item_append(_("Export list in TXT format (like -listfull)"), nullptr, 0, (void *)(FPTR)2); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); } //------------------------------------------------- // ctor / dtor //------------------------------------------------- -ui_menu_machine_configure::ui_menu_machine_configure(mame_ui_manager &mui, render_container *container, const game_driver *prev, float _x0, float _y0) - : ui_menu(mui, container) +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) @@ -700,7 +702,7 @@ ui_menu_machine_configure::ui_menu_machine_configure(mame_ui_manager &mui, rende setup_bios(); } -ui_menu_machine_configure::~ui_menu_machine_configure() +menu_machine_configure::~menu_machine_configure() { } @@ -708,16 +710,16 @@ ui_menu_machine_configure::~ui_menu_machine_configure() // handlethe options menu //------------------------------------------------- -void ui_menu_machine_configure::handle() +void menu_machine_configure::handle() { // process the menu - ui_menu::menu_stack->parent->process(UI_MENU_PROCESS_NOINPUT); - const ui_menu_event *m_event = process(UI_MENU_PROCESS_NOIMAGE, x0, y0); - if (m_event != nullptr && m_event->itemref != nullptr) + process_parent(); + const event *menu_event = process(PROCESS_NOIMAGE, x0, y0); + if (menu_event != nullptr && menu_event->itemref != nullptr) { - if (m_event->iptkey == IPT_UI_SELECT) + if (menu_event->iptkey == IPT_UI_SELECT) { - switch ((FPTR)m_event->itemref) + switch ((FPTR)menu_event->itemref) { case SAVE: { @@ -734,36 +736,36 @@ void ui_menu_machine_configure::handle() } case ADDFAV: mame_machine_manager::instance()->favorite().add_favorite_game(m_drv); - reset(UI_MENU_RESET_REMEMBER_POSITION); + reset(reset_options::REMEMBER_POSITION); break; case DELFAV: mame_machine_manager::instance()->favorite().remove_favorite_game(); - reset(UI_MENU_RESET_REMEMBER_POSITION); + reset(reset_options::REMEMBER_POSITION); break; case CONTROLLER: - if (m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container, control_submenu_options, m_drv, &m_opts)); + if (menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container, submenu::control_options, m_drv, &m_opts); break; case VIDEO: - if (m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container, video_submenu_options, m_drv, &m_opts)); + if (menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container, submenu::video_options, m_drv, &m_opts); break; case ADVANCED: - if (m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container, advanced_submenu_options, m_drv, &m_opts)); + if (menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container, submenu::advanced_options, m_drv, &m_opts); break; default: break; } } - else if (m_event->iptkey == IPT_UI_LEFT || m_event->iptkey == IPT_UI_RIGHT) + else if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) { - (m_event->iptkey == IPT_UI_LEFT) ? --m_curbios : ++m_curbios; + (menu_event->iptkey == IPT_UI_LEFT) ? --m_curbios : ++m_curbios; 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(UI_MENU_RESET_REMEMBER_POSITION); + reset(reset_options::REMEMBER_POSITION); } } } @@ -772,32 +774,32 @@ void ui_menu_machine_configure::handle() // populate //------------------------------------------------- -void ui_menu_machine_configure::populate() +void menu_machine_configure::populate() { // add options items - item_append(_("Bios"), nullptr, MENU_FLAG_DISABLE | MENU_FLAG_UI_HEADING, nullptr); + item_append(_("Bios"), nullptr, FLAG_DISABLE | FLAG_UI_HEADING, nullptr); if (!m_bios.empty()) { UINT32 arrows = get_arrow_flags(0, m_bios.size() - 1, m_curbios); item_append(_("Driver"), m_bios[m_curbios].first.c_str(), arrows, (void *)(FPTR)BIOS); } else - item_append(_("This machine has no bios."), nullptr, MENU_FLAG_DISABLE, nullptr); + item_append(_("This machine has no bios."), nullptr, FLAG_DISABLE, nullptr); - item_append(ui_menu_item_type::SEPARATOR); - item_append(_(advanced_submenu_options[0].description), nullptr, 0, (void *)(FPTR)ADVANCED); - item_append(_(video_submenu_options[0].description), nullptr, 0, (void *)(FPTR)VIDEO); - item_append(_(control_submenu_options[0].description), nullptr, 0, (void *)(FPTR)CONTROLLER); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); + item_append(_(submenu::advanced_options[0].description), nullptr, 0, (void *)(FPTR)ADVANCED); + item_append(_(submenu::video_options[0].description), nullptr, 0, (void *)(FPTR)VIDEO); + item_append(_(submenu::control_options[0].description), nullptr, 0, (void *)(FPTR)CONTROLLER); + item_append(menu_item_type::SEPARATOR); if (!mame_machine_manager::instance()->favorite().isgame_favorite(m_drv)) item_append(_("Add To Favorites"), nullptr, 0, (void *)ADDFAV); else item_append(_("Remove From Favorites"), nullptr, 0, (void *)DELFAV); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); item_append(_("Save machine configuration"), nullptr, 0, (void *)(FPTR)SAVE); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); customtop = 2.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } @@ -805,7 +807,7 @@ void ui_menu_machine_configure::populate() // perform our special rendering //------------------------------------------------- -void ui_menu_machine_configure::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_machine_configure::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float width; std::string text[2]; @@ -846,7 +848,7 @@ void ui_menu_machine_configure::custom_render(void *selectedref, float top, floa } } -void ui_menu_machine_configure::setup_bios() +void menu_machine_configure::setup_bios() { if (m_drv->rom == nullptr) return; @@ -889,12 +891,12 @@ void ui_menu_machine_configure::setup_bios() // ctor / dtor //------------------------------------------------- -ui_menu_plugins_configure::ui_menu_plugins_configure(mame_ui_manager &mui, render_container *container) - : ui_menu(mui, container) +menu_plugins_configure::menu_plugins_configure(mame_ui_manager &mui, render_container *container) + : menu(mui, container) { } -ui_menu_plugins_configure::~ui_menu_plugins_configure() +menu_plugins_configure::~menu_plugins_configure() { emu_file file_plugin(OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); if (file_plugin.open("plugin.ini") != osd_file::error::NONE) @@ -907,32 +909,32 @@ ui_menu_plugins_configure::~ui_menu_plugins_configure() // handlethe options menu //------------------------------------------------- -void ui_menu_plugins_configure::handle() +void menu_plugins_configure::handle() { // process the menu bool changed = false; plugin_options& plugins = mame_machine_manager::instance()->plugins(); - ui_menu::menu_stack->parent->process(UI_MENU_PROCESS_NOINPUT); - const ui_menu_event *m_event = process(UI_MENU_PROCESS_NOIMAGE); - if (m_event != nullptr && m_event->itemref != nullptr) + process_parent(); + const event *menu_event = process(PROCESS_NOIMAGE); + if (menu_event != nullptr && menu_event->itemref != nullptr) { - if (m_event->iptkey == IPT_UI_LEFT || m_event->iptkey == IPT_UI_RIGHT || m_event->iptkey == IPT_UI_SELECT) + 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*)m_event->itemref); + int oldval = plugins.int_value((const char*)menu_event->itemref); std::string error_string; - plugins.set_value((const char*)m_event->itemref, oldval == 1 ? 0 : 1, OPTION_PRIORITY_CMDLINE, error_string); + plugins.set_value((const char*)menu_event->itemref, oldval == 1 ? 0 : 1, OPTION_PRIORITY_CMDLINE, error_string); changed = true; } } if (changed) - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); } //------------------------------------------------- // populate //------------------------------------------------- -void ui_menu_plugins_configure::populate() +void menu_plugins_configure::populate() { plugin_options& plugins = mame_machine_manager::instance()->plugins(); @@ -942,10 +944,10 @@ void ui_menu_plugins_configure::populate() { auto enabled = std::string(curentry.value()) == "1"; item_append(curentry.description(), enabled ? _("On") : _("Off"), - enabled ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)(FPTR)curentry.name()); + enabled ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW, (void *)(FPTR)curentry.name()); } } - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER); } @@ -953,7 +955,7 @@ void ui_menu_plugins_configure::populate() // perform our special rendering //------------------------------------------------- -void ui_menu_plugins_configure::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_plugins_configure::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float width; @@ -980,3 +982,5 @@ void ui_menu_plugins_configure::custom_render(void *selectedref, float top, floa ui().draw_text_full(container, _("Plugins"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); } + +} // namespace ui \ No newline at end of file diff --git a/src/frontend/mame/ui/miscmenu.h b/src/frontend/mame/ui/miscmenu.h index 286e5f30912..01348d4be41 100644 --- a/src/frontend/mame/ui/miscmenu.h +++ b/src/frontend/mame/ui/miscmenu.h @@ -10,34 +10,41 @@ #pragma once -#ifndef __UI_MISCMENU_H__ -#define __UI_MISCMENU_H__ +#ifndef MAME_FRONTEND_UI_MISCMENU_H +#define MAME_FRONTEND_UI_MISCMENU_H #include "crsshair.h" #include "emuopts.h" -using s_bios = std::vector>; +#include +#include -class ui_menu_keyboard_mode : public ui_menu { + +namespace ui { + +class menu_keyboard_mode : public menu +{ public: - ui_menu_keyboard_mode(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_keyboard_mode(); + menu_keyboard_mode(mame_ui_manager &mui, render_container *container); + virtual ~menu_keyboard_mode(); virtual void populate() override; virtual void handle() override; }; -class ui_menu_network_devices : public ui_menu { +class menu_network_devices : public menu +{ public: - ui_menu_network_devices(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_network_devices(); + menu_network_devices(mame_ui_manager &mui, render_container *container); + virtual ~menu_network_devices(); virtual void populate() override; virtual void handle() override; }; -class ui_menu_bookkeeping : public ui_menu { +class menu_bookkeeping : public menu +{ public: - ui_menu_bookkeeping(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_bookkeeping(); + menu_bookkeeping(mame_ui_manager &mui, render_container *container); + virtual ~menu_bookkeeping(); virtual void populate() override; virtual void handle() override; @@ -45,10 +52,11 @@ private: attotime prevtime; }; -class ui_menu_crosshair : public ui_menu { +class menu_crosshair : public menu +{ public: - ui_menu_crosshair(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_crosshair(); + menu_crosshair(mame_ui_manager &mui, render_container *container); + virtual ~menu_crosshair(); virtual void populate() override; virtual void handle() override; @@ -71,18 +79,20 @@ private: }; }; -class ui_menu_quit_game : public ui_menu { +class menu_quit_game : public menu +{ public: - ui_menu_quit_game(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_quit_game(); + menu_quit_game(mame_ui_manager &mui, render_container *container); + virtual ~menu_quit_game(); virtual void populate() override; virtual void handle() override; }; -class ui_menu_bios_selection : public ui_menu { +class menu_bios_selection : public menu +{ public: - ui_menu_bios_selection(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_bios_selection(); + menu_bios_selection(mame_ui_manager &mui, render_container *container); + virtual ~menu_bios_selection(); virtual void populate() override; virtual void handle() override; }; @@ -92,11 +102,11 @@ public: // export menu //------------------------------------------------- -class ui_menu_export : public ui_menu +class menu_export : public menu { public: - ui_menu_export(mame_ui_manager &mui, render_container *container, std::vector list); - virtual ~ui_menu_export(); + menu_export(mame_ui_manager &mui, render_container *container, std::vector list); + virtual ~menu_export(); virtual void populate() override; virtual void handle() override; @@ -108,16 +118,18 @@ private: // machine configure menu //------------------------------------------------- -class ui_menu_machine_configure : public ui_menu +class menu_machine_configure : public menu { public: - ui_menu_machine_configure(mame_ui_manager &mui, render_container *container, const game_driver *prev, float x0 = 0.0f, float y0 = 0.0f); - virtual ~ui_menu_machine_configure(); + menu_machine_configure(mame_ui_manager &mui, render_container *container, const game_driver *prev, float x0 = 0.0f, float y0 = 0.0f); + virtual ~menu_machine_configure(); virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; private: + using s_bios = std::vector>; + enum { ADDFAV = 1, @@ -141,14 +153,16 @@ private: // plugins configure menu //------------------------------------------------- -class ui_menu_plugins_configure : public ui_menu +class menu_plugins_configure : public menu { public: - ui_menu_plugins_configure(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_plugins_configure(); + menu_plugins_configure(mame_ui_manager &mui, render_container *container); + virtual ~menu_plugins_configure(); virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; }; -#endif /* __UI_MISCMENU_H__ */ +} // namespace ui + +#endif /* MAME_FRONTEND_UI_MISCMENU_H */ diff --git a/src/frontend/mame/ui/optsmenu.cpp b/src/frontend/mame/ui/optsmenu.cpp index 5c9009e7604..2ba2b902f46 100644 --- a/src/frontend/mame/ui/optsmenu.cpp +++ b/src/frontend/mame/ui/optsmenu.cpp @@ -9,26 +9,30 @@ *********************************************************************/ #include "emu.h" -#include "mame.h" -#include "mameopts.h" + +#include "ui/optsmenu.h" + #include "ui/ui.h" -#include "ui/menu.h" #include "ui/submenu.h" #include "ui/inifile.h" #include "ui/selector.h" #include "ui/custui.h" #include "ui/sndmenu.h" -#include "ui/optsmenu.h" #include "ui/custmenu.h" #include "ui/inputmap.h" #include "ui/dirmenu.h" + +#include "mame.h" +#include "mameopts.h" #include "rendfont.h" +namespace ui { + //------------------------------------------------- // ctor //------------------------------------------------- -ui_menu_game_options::ui_menu_game_options(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container) +menu_game_options::menu_game_options(mame_ui_manager &mui, render_container *container) : menu(mui, container) { m_main = main_filters::actual; } @@ -37,11 +41,10 @@ ui_menu_game_options::ui_menu_game_options(mame_ui_manager &mui, render_containe // dtor //------------------------------------------------- -ui_menu_game_options::~ui_menu_game_options() +menu_game_options::~menu_game_options() { main_filters::actual = m_main; - if (ui_menu::menu_stack != nullptr) - ui_menu::menu_stack->reset(UI_MENU_RESET_SELECT_FIRST); + reset_topmost(reset_options::SELECT_FIRST); ui().save_ui_options(); ui_globals::switch_image = true; } @@ -50,56 +53,56 @@ ui_menu_game_options::~ui_menu_game_options() // handle //------------------------------------------------- -void ui_menu_game_options::handle() +void menu_game_options::handle() { bool changed = false; // process the menu - const ui_menu_event *m_event; + const event *menu_event; if (strcmp(machine().options().ui(), "simple") == 0) { - m_event = process(UI_MENU_PROCESS_LR_REPEAT); + menu_event = process(PROCESS_LR_REPEAT); } else { - ui_menu::menu_stack->parent->process(UI_MENU_PROCESS_NOINPUT); - m_event = process(UI_MENU_PROCESS_LR_REPEAT | UI_MENU_PROCESS_NOIMAGE); + process_parent(); + menu_event = process(PROCESS_LR_REPEAT | PROCESS_NOIMAGE); } - if (m_event != nullptr && m_event->itemref != nullptr) - switch ((FPTR)m_event->itemref) + if (menu_event != nullptr && menu_event->itemref != nullptr) + switch ((FPTR)menu_event->itemref) { case FILTER_MENU: { - if (m_event->iptkey == IPT_UI_LEFT || m_event->iptkey == IPT_UI_RIGHT) + if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) { - (m_event->iptkey == IPT_UI_RIGHT) ? ++m_main : --m_main; + (menu_event->iptkey == IPT_UI_RIGHT) ? ++m_main : --m_main; changed = true; } - else if (m_event->iptkey == IPT_UI_SELECT) + else if (menu_event->iptkey == IPT_UI_SELECT) { int total = main_filters::length; std::vector s_sel(total); for (int index = 0; index < total; ++index) s_sel[index] = main_filters::text[index]; - ui_menu::stack_push(global_alloc_clear(ui(), container, s_sel, m_main)); + menu::stack_push(ui(), container, s_sel, m_main); } break; } case FILE_CATEGORY_FILTER: { - if (m_event->iptkey == IPT_UI_LEFT) + if (menu_event->iptkey == IPT_UI_LEFT) { mame_machine_manager::instance()->inifile().move_file(-1); changed = true; } - else if (m_event->iptkey == IPT_UI_RIGHT) + else if (menu_event->iptkey == IPT_UI_RIGHT) { mame_machine_manager::instance()->inifile().move_file(1); changed = true; } - else if (m_event->iptkey == IPT_UI_SELECT) + else if (menu_event->iptkey == IPT_UI_SELECT) { inifile_manager &ifile = mame_machine_manager::instance()->inifile(); int total = ifile.total(); @@ -108,23 +111,23 @@ void ui_menu_game_options::handle() for (size_t index = 0; index < total; ++index) s_sel[index] = ifile.get_file(index); - ui_menu::stack_push(global_alloc_clear(ui(), container, s_sel, ifile.cur_file(), SELECTOR_INIFILE)); + menu::stack_push(ui(), container, s_sel, ifile.cur_file(), menu_selector::INIFILE); } break; } case CATEGORY_FILTER: { - if (m_event->iptkey == IPT_UI_LEFT) + if (menu_event->iptkey == IPT_UI_LEFT) { mame_machine_manager::instance()->inifile().move_cat(-1); changed = true; } - else if (m_event->iptkey == IPT_UI_RIGHT) + else if (menu_event->iptkey == IPT_UI_RIGHT) { mame_machine_manager::instance()->inifile().move_cat(1); changed = true; } - else if (m_event->iptkey == IPT_UI_SELECT) + else if (menu_event->iptkey == IPT_UI_SELECT) { inifile_manager &ifile = mame_machine_manager::instance()->inifile(); int total = ifile.cat_total(); @@ -132,93 +135,93 @@ void ui_menu_game_options::handle() for (int index = 0; index < total; ++index) s_sel[index] = ifile.get_category(index); - ui_menu::stack_push(global_alloc_clear(ui(), container, s_sel, ifile.cur_cat(), SELECTOR_CATEGORY)); + menu::stack_push(ui(), container, s_sel, ifile.cur_cat(), menu_selector::CATEGORY); } break; } case MANUFACT_CAT_FILTER: - if (m_event->iptkey == IPT_UI_LEFT || m_event->iptkey == IPT_UI_RIGHT) + if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) { - (m_event->iptkey == IPT_UI_RIGHT) ? c_mnfct::actual++ : c_mnfct::actual--; + (menu_event->iptkey == IPT_UI_RIGHT) ? c_mnfct::actual++ : c_mnfct::actual--; changed = true; } - else if (m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container, c_mnfct::ui, c_mnfct::actual)); + else if (menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container, c_mnfct::ui, c_mnfct::actual); break; case YEAR_CAT_FILTER: - if (m_event->iptkey == IPT_UI_LEFT || m_event->iptkey == IPT_UI_RIGHT) + if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) { - (m_event->iptkey == IPT_UI_RIGHT) ? c_year::actual++ : c_year::actual--; + (menu_event->iptkey == IPT_UI_RIGHT) ? c_year::actual++ : c_year::actual--; changed = true; } - else if (m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container, c_year::ui, c_year::actual)); + else if (menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container, c_year::ui, c_year::actual); break; case CONF_DIR: - if (m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container)); + if (menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container); break; case MISC_MENU: - if (m_event->iptkey == IPT_UI_SELECT) + if (menu_event->iptkey == IPT_UI_SELECT) { - ui_menu::stack_push(global_alloc_clear(ui(), container, misc_submenu_options)); + menu::stack_push(ui(), container, submenu::misc_options); ui_globals::reset = true; } break; case SOUND_MENU: - if (m_event->iptkey == IPT_UI_SELECT) + if (menu_event->iptkey == IPT_UI_SELECT) { - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); ui_globals::reset = true; } break; case DISPLAY_MENU: - if (m_event->iptkey == IPT_UI_SELECT) + if (menu_event->iptkey == IPT_UI_SELECT) { - ui_menu::stack_push(global_alloc_clear(ui(), container, video_submenu_options)); + menu::stack_push(ui(), container, submenu::video_options); ui_globals::reset = true; } break; case CUSTOM_MENU: - if (m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container)); + if (menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container); break; case CONTROLLER_MENU: - if (m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container, control_submenu_options)); + if (menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container, submenu::control_options); break; case CGI_MENU: - if (m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container)); + if (menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container); break; case CUSTOM_FILTER: - if (m_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container)); + if (menu_event->iptkey == IPT_UI_SELECT) + menu::stack_push(ui(), container); break; case ADVANCED_MENU: - if (m_event->iptkey == IPT_UI_SELECT) + if (menu_event->iptkey == IPT_UI_SELECT) { - ui_menu::stack_push(global_alloc_clear(ui(), container, advanced_submenu_options)); + menu::stack_push(ui(), container, submenu::advanced_options); ui_globals::reset = true; } break; case SAVE_CONFIG: - if (m_event->iptkey == IPT_UI_SELECT) + if (menu_event->iptkey == IPT_UI_SELECT) ui().save_main_option(); break; } if (changed) - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); } //------------------------------------------------- // populate //------------------------------------------------- -void ui_menu_game_options::populate() +void menu_game_options::populate() { if (strcmp(machine().options().ui(),"simple")!=0) { @@ -268,19 +271,19 @@ void ui_menu_game_options::populate() item_append(fbuff.c_str(), nullptr, 0, (void *)(FPTR)CUSTOM_FILTER); } - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); // add options items item_append(_("Customize UI"), nullptr, 0, (void *)(FPTR)CUSTOM_MENU); item_append(_("Configure Directories"), nullptr, 0, (void *)(FPTR)CONF_DIR); } - item_append(_(video_submenu_options[0].description), nullptr, 0, (void *)(FPTR)DISPLAY_MENU); + item_append(_(submenu::video_options[0].description), nullptr, 0, (void *)(FPTR)DISPLAY_MENU); item_append(_("Sound Options"), nullptr, 0, (void *)(FPTR)SOUND_MENU); - item_append(_(misc_submenu_options[0].description), nullptr, 0, (void *)(FPTR)MISC_MENU); - item_append(_(control_submenu_options[0].description), nullptr, 0, (void *)(FPTR)CONTROLLER_MENU); + item_append(_(submenu::misc_options[0].description), nullptr, 0, (void *)(FPTR)MISC_MENU); + item_append(_(submenu::control_options[0].description), nullptr, 0, (void *)(FPTR)CONTROLLER_MENU); item_append(_("General Inputs"), nullptr, 0, (void *)(FPTR)CGI_MENU); - item_append(_(advanced_submenu_options[0].description), nullptr, 0, (void *)(FPTR)ADVANCED_MENU); - item_append(ui_menu_item_type::SEPARATOR); + item_append(_(submenu::advanced_options[0].description), nullptr, 0, (void *)(FPTR)ADVANCED_MENU); + item_append(menu_item_type::SEPARATOR); item_append(_("Save Configuration"), nullptr, 0, (void *)(FPTR)SAVE_CONFIG); custombottom = 2.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; @@ -291,7 +294,7 @@ void ui_menu_game_options::populate() // perform our special rendering //------------------------------------------------- -void ui_menu_game_options::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_game_options::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float width; ui().draw_text_full(container, _("Settings"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, @@ -317,3 +320,6 @@ void ui_menu_game_options::custom_render(void *selectedref, float top, float bot ui().draw_text_full(container, _("Settings"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); } + + +} // namespace ui diff --git a/src/frontend/mame/ui/optsmenu.h b/src/frontend/mame/ui/optsmenu.h index 9a87918f8f6..b8ee8ebc628 100644 --- a/src/frontend/mame/ui/optsmenu.h +++ b/src/frontend/mame/ui/optsmenu.h @@ -10,14 +10,18 @@ #pragma once -#ifndef __UI_OPTSMENU_H__ -#define __UI_OPTSMENU_H__ +#ifndef MAME_FRONTEND_UI_OPTSMENU_H +#define MAME_FRONTEND_UI_OPTSMENU_H -class ui_menu_game_options : public ui_menu +#include "ui/menu.h" + +namespace ui { + +class menu_game_options : public menu { public: - ui_menu_game_options(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_game_options(); + menu_game_options(mame_ui_manager &mui, render_container *container); + virtual ~menu_game_options() override; virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -46,4 +50,6 @@ private: }; }; -#endif /* __UI_OPTSMENU_H__ */ +} // namespace ui + +#endif /* MAME_FRONTEND_UI_OPTSMENU_H */ diff --git a/src/frontend/mame/ui/pluginopt.cpp b/src/frontend/mame/ui/pluginopt.cpp index a8fd53475a8..71a0a0aceee 100644 --- a/src/frontend/mame/ui/pluginopt.cpp +++ b/src/frontend/mame/ui/pluginopt.cpp @@ -9,48 +9,52 @@ *********************************************************************/ #include "emu.h" -#include "mame.h" -#include "luaengine.h" #include "ui/pluginopt.h" -void ui_menu_plugin::handle() +#include "mame.h" +#include "luaengine.h" + + +namespace ui { + +void menu_plugin::handle() { - const ui_menu_event *menu_event = process(0); + const event *menu_event = process(0); if (menu_event != nullptr && menu_event->itemref != nullptr) { if (menu_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(global_alloc_clear(ui(), container, (char *)menu_event->itemref)); + menu::stack_push(ui(), container, (char *)menu_event->itemref); } } -ui_menu_plugin::ui_menu_plugin(mame_ui_manager &mui, render_container *container) : - ui_menu(mui, container), +menu_plugin::menu_plugin(mame_ui_manager &mui, render_container *container) : + menu(mui, container), m_plugins(mame_machine_manager::instance()->lua()->get_menu()) { } -void ui_menu_plugin::populate() +void menu_plugin::populate() { for (auto &curplugin : m_plugins) item_append(curplugin.c_str(), nullptr, 0, (void *)curplugin.c_str()); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); } -ui_menu_plugin::~ui_menu_plugin() +menu_plugin::~menu_plugin() { } -ui_menu_plugin_opt::ui_menu_plugin_opt(mame_ui_manager &mui, render_container *container, char *menu) : - ui_menu(mui, container), +menu_plugin_opt::menu_plugin_opt(mame_ui_manager &mui, render_container *container, char *menu) : + ui::menu(mui, container), m_menu(menu) { } -void ui_menu_plugin_opt::handle() +void menu_plugin_opt::handle() { - const ui_menu_event *menu_event = process(0); + const event *menu_event = process(0); if (menu_event != nullptr && (FPTR)menu_event->itemref) { @@ -82,11 +86,11 @@ void ui_menu_plugin_opt::handle() return; } if(mame_machine_manager::instance()->lua()->menu_callback(m_menu, (FPTR)menu_event->itemref, key)) - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); } } -void ui_menu_plugin_opt::populate() +void menu_plugin_opt::populate() { std::vector menu_list; mame_machine_manager::instance()->lua()->menu_populate(m_menu, menu_list); @@ -95,19 +99,21 @@ void ui_menu_plugin_opt::populate() { UINT32 flags = 0; if(item.flags == "off") - flags = MENU_FLAG_DISABLE; + flags = FLAG_DISABLE; else if(item.flags == "l") - flags = MENU_FLAG_LEFT_ARROW; + flags = FLAG_LEFT_ARROW; else if(item.flags == "r") - flags = MENU_FLAG_RIGHT_ARROW; + flags = FLAG_RIGHT_ARROW; else if(item.flags == "lr") - flags = MENU_FLAG_RIGHT_ARROW | MENU_FLAG_LEFT_ARROW; + flags = FLAG_RIGHT_ARROW | FLAG_LEFT_ARROW; item_append(item.text.c_str(), item.subtext.c_str(), flags, (void *)i++); } - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); } -ui_menu_plugin_opt::~ui_menu_plugin_opt() +menu_plugin_opt::~menu_plugin_opt() { } + +} // namespace ui diff --git a/src/frontend/mame/ui/pluginopt.h b/src/frontend/mame/ui/pluginopt.h index 53f67bad810..9a4470d11f7 100644 --- a/src/frontend/mame/ui/pluginopt.h +++ b/src/frontend/mame/ui/pluginopt.h @@ -10,29 +10,40 @@ #pragma once -#ifndef __UI_PLUGINOPT_H__ -#define __UI_PLUGINOPT_H__ +#ifndef MAME_FRONTEND_UI_PLUGINOPT_H +#define MAME_FRONTEND_UI_PLUGINOPT_H #include "ui/ui.h" #include "ui/menu.h" -class ui_menu_plugin : public ui_menu { +#include +#include + + +namespace ui { + +class menu_plugin : public menu +{ public: - ui_menu_plugin(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_plugin(); + menu_plugin(mame_ui_manager &mui, render_container *container); + virtual ~menu_plugin(); virtual void populate() override; virtual void handle() override; private: std::vector &m_plugins; }; -class ui_menu_plugin_opt : public ui_menu { +class menu_plugin_opt : public menu +{ public: - ui_menu_plugin_opt(mame_ui_manager &mui, render_container *container, char *menu); - virtual ~ui_menu_plugin_opt(); + menu_plugin_opt(mame_ui_manager &mui, render_container *container, char *menu); + virtual ~menu_plugin_opt(); virtual void populate() override; virtual void handle() override; private: std::string m_menu; }; -#endif /* __UI_PLUGINOPT_H__ */ + +} // namespace ui + +#endif /* MAME_FRONTEND_UI_PLUGINOPT_H */ diff --git a/src/frontend/mame/ui/selector.cpp b/src/frontend/mame/ui/selector.cpp index 34b911f2ddf..a1c3ad0aa16 100644 --- a/src/frontend/mame/ui/selector.cpp +++ b/src/frontend/mame/ui/selector.cpp @@ -9,18 +9,21 @@ *********************************************************************/ #include "emu.h" -#include "mame.h" -#include "ui/ui.h" -#include "ui/menu.h" + #include "ui/selector.h" +#include "ui/ui.h" #include "ui/inifile.h" +#include "mame.h" + +namespace ui { + //------------------------------------------------- // ctor / dtor //------------------------------------------------- -ui_menu_selector::ui_menu_selector(mame_ui_manager &mui, render_container *container, std::vector const &s_sel, UINT16 &s_actual, int category, int _hover) - : ui_menu(mui, container) +menu_selector::menu_selector(mame_ui_manager &mui, render_container *container, std::vector const &s_sel, UINT16 &s_actual, int category, int _hover) + : menu(mui, container) , m_selector(s_actual) , m_category(category) , m_hover(_hover) @@ -31,8 +34,8 @@ ui_menu_selector::ui_menu_selector(mame_ui_manager &mui, render_container *conta m_searchlist[0] = nullptr; } -ui_menu_selector::ui_menu_selector(mame_ui_manager &mui, render_container *container, std::vector &&s_sel, UINT16 &s_actual, int category, int _hover) - : ui_menu(mui, container) +menu_selector::menu_selector(mame_ui_manager &mui, render_container *container, std::vector &&s_sel, UINT16 &s_actual, int category, int _hover) + : menu(mui, container) , m_selector(s_actual) , m_category(category) , m_hover(_hover) @@ -43,7 +46,7 @@ ui_menu_selector::ui_menu_selector(mame_ui_manager &mui, render_container *conta m_searchlist[0] = nullptr; } -ui_menu_selector::~ui_menu_selector() +menu_selector::~menu_selector() { } @@ -51,75 +54,75 @@ ui_menu_selector::~ui_menu_selector() // handle //------------------------------------------------- -void ui_menu_selector::handle() +void menu_selector::handle() { // process the menu - const ui_menu_event *m_event = process(0); + const event *menu_event = process(0); - if (m_event != nullptr && m_event->itemref != nullptr) + if (menu_event != nullptr && menu_event->itemref != nullptr) { - if (m_event->iptkey == IPT_UI_SELECT) + if (menu_event->iptkey == IPT_UI_SELECT) { for (size_t idx = 0; idx < m_str_items.size(); ++idx) - if ((void*)&m_str_items[idx] == m_event->itemref) + if ((void*)&m_str_items[idx] == menu_event->itemref) m_selector = idx; switch (m_category) { - case SELECTOR_INIFILE: - mame_machine_manager::instance()->inifile().set_file(m_selector); - mame_machine_manager::instance()->inifile().set_cat(0); - ui_menu::menu_stack->parent->reset(UI_MENU_RESET_REMEMBER_REF); - break; + case INIFILE: + mame_machine_manager::instance()->inifile().set_file(m_selector); + mame_machine_manager::instance()->inifile().set_cat(0); + reset_parent(reset_options::REMEMBER_REF); + break; - case SELECTOR_CATEGORY: - mame_machine_manager::instance()->inifile().set_cat(m_selector); - ui_menu::menu_stack->parent->reset(UI_MENU_RESET_REMEMBER_REF); - break; + case CATEGORY: + mame_machine_manager::instance()->inifile().set_cat(m_selector); + reset_parent(reset_options::REMEMBER_REF); + break; - case SELECTOR_GAME: - main_filters::actual = m_hover; - ui_menu::menu_stack->parent->reset(UI_MENU_RESET_SELECT_FIRST); - break; + case GAME: + main_filters::actual = m_hover; + reset_parent(reset_options::SELECT_FIRST); + break; - case SELECTOR_SOFTWARE: - sw_filters::actual = m_hover; - ui_menu::menu_stack->parent->reset(UI_MENU_RESET_SELECT_FIRST); - break; + case SOFTWARE: + sw_filters::actual = m_hover; + reset_parent(reset_options::SELECT_FIRST); + break; - default: - ui_menu::menu_stack->parent->reset(UI_MENU_RESET_REMEMBER_REF); - break; + default: + reset_parent(reset_options::REMEMBER_REF); + break; } ui_globals::switch_image = true; - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); } - else if (m_event->iptkey == IPT_SPECIAL) + else if (menu_event->iptkey == IPT_SPECIAL) { int buflen = strlen(m_search); // if it's a backspace and we can handle it, do so - if ((m_event->unichar == 8 || m_event->unichar == 0x7f) && buflen > 0) + if ((menu_event->unichar == 8 || menu_event->unichar == 0x7f) && buflen > 0) { *(char *)utf8_previous_char(&m_search[buflen]) = 0; - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); } // if it's any other key and we're not maxed out, update - else if (m_event->unichar >= ' ' && m_event->unichar < 0x7f) + else if (menu_event->unichar >= ' ' && menu_event->unichar < 0x7f) { - buflen += utf8_from_uchar(&m_search[buflen], ARRAY_LENGTH(m_search) - buflen, m_event->unichar); + buflen += utf8_from_uchar(&m_search[buflen], ARRAY_LENGTH(m_search) - buflen, menu_event->unichar); m_search[buflen] = 0; - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); } } // escape pressed with non-empty text clears the text - else if (m_event->iptkey == IPT_UI_CANCEL && m_search[0] != 0) + else if (menu_event->iptkey == IPT_UI_CANCEL && m_search[0] != 0) { m_search[0] = '\0'; - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); } } } @@ -128,7 +131,7 @@ void ui_menu_selector::handle() // populate //------------------------------------------------- -void ui_menu_selector::populate() +void menu_selector::populate() { if (m_search[0] != 0) { @@ -150,7 +153,7 @@ void ui_menu_selector::populate() } } - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); customtop = custombottom = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; m_first_pass = false; } @@ -159,7 +162,7 @@ void ui_menu_selector::populate() // perform our special rendering //------------------------------------------------- -void ui_menu_selector::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_selector::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float width; std::string tempbuf = std::string(_("Selection List - Search: ")).append(m_search).append("_"); @@ -221,7 +224,7 @@ void ui_menu_selector::custom_render(void *selectedref, float top, float bottom, // find approximate matches //------------------------------------------------- -void ui_menu_selector::find_matches(const char *str) +void menu_selector::find_matches(const char *str) { // allocate memory to track the penalty value std::vector penalty(VISIBLE_GAMES_IN_SEARCH, 9999); @@ -255,3 +258,5 @@ void ui_menu_selector::find_matches(const char *str) } (index < VISIBLE_GAMES_IN_SEARCH) ? m_searchlist[index] = nullptr : m_searchlist[VISIBLE_GAMES_IN_SEARCH] = nullptr; } + +} // namespace ui diff --git a/src/frontend/mame/ui/selector.h b/src/frontend/mame/ui/selector.h index 28e09b6325a..9c13b15c3b3 100644 --- a/src/frontend/mame/ui/selector.h +++ b/src/frontend/mame/ui/selector.h @@ -10,27 +10,31 @@ #pragma once -#ifndef __UI_SELECTOR_H__ -#define __UI_SELECTOR_H__ +#ifndef MAME_FRONTEND_UI_SELECTOR_H +#define MAME_FRONTEND_UI_SELECTOR_H -enum -{ - SELECTOR_INIFILE = 1, - SELECTOR_CATEGORY, - SELECTOR_GAME, - SELECTOR_SOFTWARE -}; +#include "ui/menu.h" + +namespace ui { //------------------------------------------------- // class selector menu //------------------------------------------------- -class ui_menu_selector : public ui_menu +class menu_selector : public menu { public: - ui_menu_selector(mame_ui_manager &mui, render_container *container, std::vector const &_sel, UINT16 &_actual, int _category = 0, int _hover = 0); - ui_menu_selector(mame_ui_manager &mui, render_container *container, std::vector &&_sel, UINT16 &_actual, int _category = 0, int _hover = 0); - virtual ~ui_menu_selector(); + enum + { + INIFILE = 1, + CATEGORY, + GAME, + SOFTWARE + }; + + menu_selector(mame_ui_manager &mui, render_container *container, std::vector const &_sel, UINT16 &_actual, int _category = 0, int _hover = 0); + menu_selector(mame_ui_manager &mui, render_container *container, std::vector &&_sel, UINT16 &_actual, int _category = 0, int _hover = 0); + virtual ~menu_selector() override; virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -49,4 +53,6 @@ private: void find_matches(const char *str); }; -#endif /* __UI_SELECTOR_H__ */ +} // namespace ui + +#endif /* MAME_FRONTEND_UI_SELECTOR_H */ diff --git a/src/frontend/mame/ui/selgame.cpp b/src/frontend/mame/ui/selgame.cpp index 8e88cd7be07..36d6b3a0cbb 100644 --- a/src/frontend/mame/ui/selgame.cpp +++ b/src/frontend/mame/ui/selgame.cpp @@ -9,29 +9,35 @@ *********************************************************************/ #include "emu.h" -#include "mame.h" -#include "emuopts.h" -#include "ui/ui.h" -#include "uiinput.h" + #include "ui/selgame.h" + +#include "ui/ui.h" #include "ui/miscmenu.h" -#include "drivenum.h" -#include "audit.h" #include "ui/datfile.h" #include "ui/inifile.h" -#include "rendfont.h" #include "ui/datmenu.h" #include "ui/optsmenu.h" #include "ui/selector.h" #include "ui/selsoft.h" #include "ui/custmenu.h" -#include "../info.h" #include "ui/auditmenu.h" + +#include "../info.h" + +#include "audit.h" +#include "drivenum.h" +#include "emuopts.h" +#include "mame.h" +#include "rendfont.h" #include "rendutil.h" #include "softlist.h" +#include "uiinput.h" extern const char UI_VERSION_TAG[]; +namespace ui { + static bool first_start = true; static const char *dats_info[] = { __("General Info"), @@ -43,14 +49,14 @@ static const char *dats_info[] = { __("Gameinit"), __("Mamescore") }; -std::vector ui_menu_select_game::m_sortedlist; -int ui_menu_select_game::m_isabios = 0; +std::vector menu_select_game::m_sortedlist; +int menu_select_game::m_isabios = 0; //------------------------------------------------- // ctor //------------------------------------------------- -ui_menu_select_game::ui_menu_select_game(mame_ui_manager &mui, render_container *container, const char *gamename) : ui_menu(mui, container) +menu_select_game::menu_select_game(mame_ui_manager &mui, render_container *container, const char *gamename) : menu(mui, container) { m_focus = focused_menu::main; highlight = 0; @@ -137,7 +143,7 @@ ui_menu_select_game::ui_menu_select_game(mame_ui_manager &mui, render_container // dtor //------------------------------------------------- -ui_menu_select_game::~ui_menu_select_game() +menu_select_game::~menu_select_game() { std::string error_string, last_driver; const game_driver *driver = nullptr; @@ -170,7 +176,7 @@ ui_menu_select_game::~ui_menu_select_game() // handle //------------------------------------------------- -void ui_menu_select_game::handle() +void menu_select_game::handle() { if (m_prev_selected == nullptr) m_prev_selected = item[0].ref; @@ -183,7 +189,7 @@ void ui_menu_select_game::handle() { ui_globals::reset = false; machine().schedule_hard_reset(); - ui_menu::stack_reset(machine()); + menu::stack_reset(machine()); return; } @@ -191,7 +197,7 @@ void ui_menu_select_game::handle() if (reselect_last::get()) { const game_driver *driver = (const game_driver *)item[selected].ref; - ui_menu::stack_push(global_alloc_clear(ui(), container, driver)); + menu::stack_push(ui(), container, driver); return; } @@ -199,10 +205,10 @@ void ui_menu_select_game::handle() machine().ui_input().pressed(IPT_UI_PAUSE); // process the menu - const ui_menu_event *m_event = process(UI_MENU_PROCESS_LR_REPEAT); - if (m_event != nullptr && m_event->itemref != nullptr) + const event *menu_event = process(PROCESS_LR_REPEAT); + if (menu_event != nullptr && menu_event->itemref != nullptr) { - // reset the error on any future m_event + // reset the error on any future menu_event if (ui_error) { ui_error = false; @@ -210,14 +216,14 @@ void ui_menu_select_game::handle() } // handle selections - else if (m_event->iptkey == IPT_UI_SELECT) + else if (menu_event->iptkey == IPT_UI_SELECT) { if (m_focus == focused_menu::main) { if (isfavorite()) - inkey_select_favorite(m_event); + inkey_select_favorite(menu_event); else - inkey_select(m_event); + inkey_select(menu_event); } else if (m_focus == focused_menu::left) { @@ -228,14 +234,14 @@ void ui_menu_select_game::handle() } // handle IPT_CUSTOM (mouse right click) - else if (m_event->iptkey == IPT_CUSTOM) + else if (menu_event->iptkey == IPT_CUSTOM) { if (!isfavorite()) - ui_menu::stack_push(global_alloc_clear(ui(), container, (const game_driver *)m_prev_selected, m_event->mouse.x0, m_event->mouse.y0)); + menu::stack_push(ui(), container, (const game_driver *)m_prev_selected, menu_event->mouse.x0, menu_event->mouse.y0); } // handle UI_LEFT - else if (m_event->iptkey == IPT_UI_LEFT) + else if (menu_event->iptkey == IPT_UI_LEFT) { // Images if (ui_globals::rpanel == RP_IMAGES && ui_globals::curimage_view > FIRST_VIEW) @@ -250,7 +256,7 @@ void ui_menu_select_game::handle() { if (!isfavorite()) { - const game_driver *drv = (const game_driver *)m_event->itemref; + const game_driver *drv = (const game_driver *)menu_event->itemref; if ((FPTR)drv > skip_main_items && ui_globals::curdats_view > UI_FIRST_LOAD) { ui_globals::curdats_view--; @@ -259,7 +265,7 @@ void ui_menu_select_game::handle() } else { - ui_software_info *drv = (ui_software_info *)m_event->itemref; + ui_software_info *drv = (ui_software_info *)menu_event->itemref; if (drv->startempty == 1 && ui_globals::curdats_view > UI_FIRST_LOAD) { ui_globals::curdats_view--; @@ -275,7 +281,7 @@ void ui_menu_select_game::handle() } // handle UI_RIGHT - else if (m_event->iptkey == IPT_UI_RIGHT) + else if (menu_event->iptkey == IPT_UI_RIGHT) { // Images if (ui_globals::rpanel == RP_IMAGES && ui_globals::curimage_view < LAST_VIEW) @@ -290,7 +296,7 @@ void ui_menu_select_game::handle() { if (!isfavorite()) { - const game_driver *drv = (const game_driver *)m_event->itemref; + const game_driver *drv = (const game_driver *)menu_event->itemref; if ((FPTR)drv > skip_main_items && ui_globals::curdats_view < UI_LAST_LOAD) { ui_globals::curdats_view++; @@ -299,7 +305,7 @@ void ui_menu_select_game::handle() } else { - ui_software_info *drv = (ui_software_info *)m_event->itemref; + ui_software_info *drv = (ui_software_info *)menu_event->itemref; if (drv->startempty == 1 && ui_globals::curdats_view < UI_LAST_LOAD) { ui_globals::curdats_view++; @@ -315,62 +321,62 @@ void ui_menu_select_game::handle() } // handle UI_UP_FILTER - else if (m_event->iptkey == IPT_UI_UP_FILTER && highlight > FILTER_FIRST) + else if (menu_event->iptkey == IPT_UI_UP_FILTER && highlight > FILTER_FIRST) { highlight--; } // handle UI_DOWN_FILTER - else if (m_event->iptkey == IPT_UI_DOWN_FILTER && highlight < FILTER_LAST) + else if (menu_event->iptkey == IPT_UI_DOWN_FILTER && highlight < FILTER_LAST) { highlight++; } // handle UI_LEFT_PANEL - else if (m_event->iptkey == IPT_UI_LEFT_PANEL) + else if (menu_event->iptkey == IPT_UI_LEFT_PANEL) ui_globals::rpanel = RP_IMAGES; // handle UI_RIGHT_PANEL - else if (m_event->iptkey == IPT_UI_RIGHT_PANEL) + else if (menu_event->iptkey == IPT_UI_RIGHT_PANEL) ui_globals::rpanel = RP_INFOS; // escape pressed with non-empty text clears the text - else if (m_event->iptkey == IPT_UI_CANCEL && m_search[0] != 0) + else if (menu_event->iptkey == IPT_UI_CANCEL && m_search[0] != 0) { m_search[0] = '\0'; - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); } // handle UI_DATS - else if (m_event->iptkey == IPT_UI_DATS && enabled_dats) + else if (menu_event->iptkey == IPT_UI_DATS && enabled_dats) { if (!isfavorite()) { - const game_driver *driver = (const game_driver *)m_event->itemref; + const game_driver *driver = (const game_driver *)menu_event->itemref; if ((FPTR)driver > skip_main_items && mame_machine_manager::instance()->datfile().has_data(driver)) - ui_menu::stack_push(global_alloc_clear(ui(), container, driver)); + menu::stack_push(ui(), container, driver); } else { - ui_software_info *ui_swinfo = (ui_software_info *)m_event->itemref; + ui_software_info *ui_swinfo = (ui_software_info *)menu_event->itemref; datfile_manager &mdat = mame_machine_manager::instance()->datfile(); if ((FPTR)ui_swinfo > skip_main_items) { if (ui_swinfo->startempty == 1 && mdat.has_history(ui_swinfo->driver)) - ui_menu::stack_push(global_alloc_clear(ui(), container, ui_swinfo->driver)); + menu::stack_push(ui(), container, ui_swinfo->driver); else if (mdat.has_software(ui_swinfo->listname, ui_swinfo->shortname, ui_swinfo->parentname) || !ui_swinfo->usage.empty()) - ui_menu::stack_push(global_alloc_clear(ui(), container, ui_swinfo)); + menu::stack_push(ui(), container, ui_swinfo); } } } // handle UI_FAVORITES - else if (m_event->iptkey == IPT_UI_FAVORITES) + else if (menu_event->iptkey == IPT_UI_FAVORITES) { if (!isfavorite()) { - const game_driver *driver = (const game_driver *)m_event->itemref; + const game_driver *driver = (const game_driver *)menu_event->itemref; if ((FPTR)driver > skip_main_items) { favorite_manager &mfav = mame_machine_manager::instance()->favorite(); @@ -389,36 +395,36 @@ void ui_menu_select_game::handle() } else { - ui_software_info *swinfo = (ui_software_info *)m_event->itemref; + ui_software_info *swinfo = (ui_software_info *)menu_event->itemref; if ((FPTR)swinfo > skip_main_items) { machine().popmessage(_("%s\n removed from favorites list."), swinfo->longname.c_str()); mame_machine_manager::instance()->favorite().remove_favorite_game(*swinfo); - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); } } } // handle UI_EXPORT - else if (m_event->iptkey == IPT_UI_EXPORT && !isfavorite()) + else if (menu_event->iptkey == IPT_UI_EXPORT && !isfavorite()) inkey_export(); // handle UI_AUDIT_FAST - else if (m_event->iptkey == IPT_UI_AUDIT_FAST && !m_unavailsortedlist.empty()) - ui_menu::stack_push(global_alloc_clear(ui(), container, m_availsortedlist, m_unavailsortedlist, 1)); + else if (menu_event->iptkey == IPT_UI_AUDIT_FAST && !m_unavailsortedlist.empty()) + menu::stack_push(ui(), container, m_availsortedlist, m_unavailsortedlist, 1); // handle UI_AUDIT_ALL - else if (m_event->iptkey == IPT_UI_AUDIT_ALL) - ui_menu::stack_push(global_alloc_clear(ui(), container, m_availsortedlist, m_unavailsortedlist, 2)); + else if (menu_event->iptkey == IPT_UI_AUDIT_ALL) + menu::stack_push(ui(), container, m_availsortedlist, m_unavailsortedlist, 2); // typed characters append to the buffer - else if (m_event->iptkey == IPT_SPECIAL) - inkey_special(m_event); + else if (menu_event->iptkey == IPT_SPECIAL) + inkey_special(menu_event); - else if (m_event->iptkey == IPT_UI_CONFIGURE) - inkey_configure(m_event); + else if (menu_event->iptkey == IPT_UI_CONFIGURE) + inkey_configure(menu_event); - else if (m_event->iptkey == IPT_OTHER) + else if (menu_event->iptkey == IPT_OTHER) { m_prev_selected = nullptr; check_filter = true; @@ -426,13 +432,13 @@ void ui_menu_select_game::handle() } } - if (m_event != nullptr && m_event->itemref == nullptr) + if (menu_event != nullptr && menu_event->itemref == nullptr) { - if (m_event->iptkey == IPT_SPECIAL) - inkey_special(m_event); - else if (m_event->iptkey == IPT_UI_CONFIGURE) - inkey_configure(m_event); - else if (m_event->iptkey == IPT_OTHER) + if (menu_event->iptkey == IPT_SPECIAL) + inkey_special(menu_event); + else if (menu_event->iptkey == IPT_UI_CONFIGURE) + inkey_configure(menu_event); + else if (menu_event->iptkey == IPT_OTHER) { m_focus = focused_menu::left; m_prev_selected = nullptr; @@ -440,13 +446,13 @@ void ui_menu_select_game::handle() check_filter = true; } // handle UI_UP_FILTER - else if (m_event->iptkey == IPT_UI_UP_FILTER && highlight > FILTER_FIRST) + else if (menu_event->iptkey == IPT_UI_UP_FILTER && highlight > FILTER_FIRST) { highlight--; } // handle UI_DOWN_FILTER - else if (m_event->iptkey == IPT_UI_DOWN_FILTER && highlight < FILTER_LAST) + else if (menu_event->iptkey == IPT_UI_DOWN_FILTER && highlight < FILTER_LAST) { highlight++; } @@ -464,22 +470,22 @@ void ui_menu_select_game::handle() if (l_hover == FILTER_CATEGORY) { main_filters::actual = l_hover; - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); } else if (l_hover == FILTER_CUSTOM) { main_filters::actual = l_hover; - ui_menu::stack_push(global_alloc_clear(ui(), container, true)); + menu::stack_push(ui(), container, true); } else if (l_hover == FILTER_MANUFACTURER) - ui_menu::stack_push(global_alloc_clear(ui(), container, c_mnfct::ui, c_mnfct::actual, SELECTOR_GAME, l_hover)); + menu::stack_push(ui(), container, c_mnfct::ui, c_mnfct::actual, menu_selector::GAME, l_hover); else if (l_hover == FILTER_YEAR) - ui_menu::stack_push(global_alloc_clear(ui(), container, c_year::ui, c_year::actual, SELECTOR_GAME, l_hover)); + menu::stack_push(ui(), container, c_year::ui, c_year::actual, menu_selector::GAME, l_hover); else { if (l_hover >= FILTER_ALL) main_filters::actual = l_hover; - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); } } } @@ -488,7 +494,7 @@ void ui_menu_select_game::handle() // populate //------------------------------------------------- -void ui_menu_select_game::populate() +void menu_select_game::populate() { ui_globals::redraw_icon = true; ui_globals::switch_image = true; @@ -529,7 +535,7 @@ void ui_menu_select_game::populate() int curitem = 0; for (auto & elem : m_displaylist) { - UINT32 flags_ui = MENU_FLAG_UI | MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW; + UINT32 flags_ui = FLAG_UI | FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW; if (old_item_selected == -1 && elem->name == reselect_last::driver) old_item_selected = curitem; @@ -542,7 +548,7 @@ void ui_menu_select_game::populate() cloneof = false; } if (cloneof) - flags_ui |= MENU_FLAG_INVERT; + flags_ui |= FLAG_INVERT; item_append(elem->description, nullptr, flags_ui, (void *)elem); curitem++; @@ -557,7 +563,7 @@ void ui_menu_select_game::populate() // iterate over entries for (auto & mfavorite : mame_machine_manager::instance()->favorite().m_list) { - UINT32 flags_ui = MENU_FLAG_UI | MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW | MENU_FLAG_UI_FAVORITE; + UINT32 flags_ui = FLAG_UI | FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW | FLAG_UI_FAVORITE; if (mfavorite.startempty == 1) { if (old_item_selected == -1 && mfavorite.shortname == reselect_last::driver) @@ -571,7 +577,7 @@ void ui_menu_select_game::populate() cloneof = false; } if (cloneof) - flags_ui |= MENU_FLAG_INVERT; + flags_ui |= FLAG_INVERT; item_append(mfavorite.longname.c_str(), nullptr, flags_ui, (void *)&mfavorite); } @@ -580,18 +586,18 @@ void ui_menu_select_game::populate() if (old_item_selected == -1 && mfavorite.shortname == reselect_last::driver) old_item_selected = curitem; item_append(mfavorite.longname.c_str(), mfavorite.devicetype.c_str(), - mfavorite.parentname.empty() ? flags_ui : (MENU_FLAG_INVERT | flags_ui), (void *)&mfavorite); + mfavorite.parentname.empty() ? flags_ui : (FLAG_INVERT | flags_ui), (void *)&mfavorite); } curitem++; } } - item_append(MENU_SEPARATOR_ITEM, nullptr, MENU_FLAG_UI, nullptr); + item_append(MENU_SEPARATOR_ITEM, nullptr, FLAG_UI, nullptr); // add special items - if (ui_menu::stack_has_special_main_menu()) + if (menu::stack_has_special_main_menu()) { - UINT32 flags_ui = MENU_FLAG_UI | MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW; + UINT32 flags_ui = FLAG_UI | FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW; item_append(_("Configure Options"), nullptr, flags_ui, (void *)(FPTR)CONF_OPTS); item_append(_("Configure Machine"), nullptr, flags_ui, (void *)(FPTR)CONF_MACHINE); skip_main_items = 2; @@ -628,7 +634,7 @@ void ui_menu_select_game::populate() // build a list of available drivers //------------------------------------------------- -void ui_menu_select_game::build_available_list() +void menu_select_game::build_available_list() { int m_total = driver_list::total(); std::vector m_included(m_total, false); @@ -743,7 +749,7 @@ void ui_menu_select_game::build_available_list() // perform our special rendering //------------------------------------------------- -void ui_menu_select_game::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_select_game::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { const game_driver *driver = nullptr; ui_software_info *swinfo = nullptr; @@ -990,16 +996,14 @@ void ui_menu_select_game::custom_render(void *selectedref, float top, float bott // and inescapable //------------------------------------------------- -void ui_menu_select_game::force_game_select(mame_ui_manager &mui, render_container *container) +void menu_select_game::force_game_select(mame_ui_manager &mui, render_container *container) { // reset the menu stack - ui_menu::stack_reset(mui.machine()); + menu::stack_reset(mui.machine()); // add the quit entry followed by the game select entry - ui_menu *quit = global_alloc_clear(mui, container); - quit->set_special_main_menu(true); - ui_menu::stack_push(quit); - ui_menu::stack_push(global_alloc_clear(mui, container, nullptr)); + menu::stack_push_special_main(mui, container); + menu::stack_push(mui, container, nullptr); // force the menus on mui.show_menu(); @@ -1012,19 +1016,19 @@ void ui_menu_select_game::force_game_select(mame_ui_manager &mui, render_contain // handle select key event //------------------------------------------------- -void ui_menu_select_game::inkey_select(const ui_menu_event *m_event) +void menu_select_game::inkey_select(const event *menu_event) { - const game_driver *driver = (const game_driver *)m_event->itemref; + const game_driver *driver = (const game_driver *)menu_event->itemref; // special case for configure options if ((FPTR)driver == CONF_OPTS) - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); // special case for configure machine else if ((FPTR)driver == CONF_MACHINE) { if (m_prev_selected != nullptr) - ui_menu::stack_push(global_alloc_clear(ui(), container, (const game_driver *)m_prev_selected)); + menu::stack_push(ui(), container, (const game_driver *)m_prev_selected); else return; } @@ -1032,7 +1036,7 @@ void ui_menu_select_game::inkey_select(const ui_menu_event *m_event) // special case for configure plugins else if ((FPTR)driver == CONF_PLUGINS) { - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); } // anything else is a driver else @@ -1051,14 +1055,14 @@ void ui_menu_select_game::inkey_select(const ui_menu_event *m_event) for (software_list_device &swlistdev : software_list_device_iterator(enumerator.config().root_device())) if (!swlistdev.get_info().empty()) { - ui_menu::stack_push(global_alloc_clear(ui(), container, driver)); + menu::stack_push(ui(), container, driver); return; } } s_bios biosname; if (!ui().options().skip_bios_menu() && has_multiple_bios(driver, biosname)) - ui_menu::stack_push(global_alloc_clear(ui(), container, biosname, (void *)driver, false, false)); + menu::stack_push(ui(), container, biosname, (void *)driver, false, false); else { reselect_last::driver = driver->name; @@ -1066,13 +1070,13 @@ void ui_menu_select_game::inkey_select(const ui_menu_event *m_event) reselect_last::swlist.clear(); mame_machine_manager::instance()->schedule_new_driver(*driver); machine().schedule_hard_reset(); - ui_menu::stack_reset(machine()); + menu::stack_reset(machine()); } } // otherwise, display an error else { - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); ui_error = true; } } @@ -1082,14 +1086,14 @@ void ui_menu_select_game::inkey_select(const ui_menu_event *m_event) // handle select key event for favorites menu //------------------------------------------------- -void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event) +void menu_select_game::inkey_select_favorite(const event *menu_event) { - ui_software_info *ui_swinfo = (ui_software_info *)m_event->itemref; + ui_software_info *ui_swinfo = (ui_software_info *)menu_event->itemref; ui_options &mopt = ui().options(); // special case for configure options if ((FPTR)ui_swinfo == CONF_OPTS) - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); /* special case for configure machine TODO else if ((FPTR)ui_swinfo == CONF_MACHINE) { @@ -1097,7 +1101,7 @@ void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event) { ui_software_info *swinfo = (ui_software_info *)m_prev_selected; if (swinfo->startempty == 1) - ui_menu::stack_push(global_alloc_clear(ui(), container, swinfo->driver)); + menu::stack_push(ui(), container, swinfo->driver); } else return; @@ -1105,7 +1109,7 @@ void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event) // special case for configure plugins else if ((FPTR)ui_swinfo == CONF_PLUGINS) { - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); } else if (ui_swinfo->startempty == 1) { @@ -1120,7 +1124,7 @@ void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event) { s_bios biosname; if (!mopt.skip_bios_menu() && has_multiple_bios(ui_swinfo->driver, biosname)) - ui_menu::stack_push(global_alloc_clear(ui(), container, biosname, (void *)ui_swinfo->driver, false, false)); + menu::stack_push(ui(), container, biosname, (void *)ui_swinfo->driver, false, false); else { reselect_last::driver = ui_swinfo->driver->name; @@ -1129,14 +1133,14 @@ void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event) reselect_last::set(true); mame_machine_manager::instance()->schedule_new_driver(*ui_swinfo->driver); machine().schedule_hard_reset(); - ui_menu::stack_reset(machine()); + menu::stack_reset(machine()); } } // otherwise, display an error else { - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); ui_error = true; } } @@ -1154,7 +1158,7 @@ void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event) s_bios biosname; if (!mopt.skip_bios_menu() && has_multiple_bios(ui_swinfo->driver, biosname)) { - ui_menu::stack_push(global_alloc_clear(ui(), container, biosname, (void *)ui_swinfo, true, false)); + menu::stack_push(ui(), container, biosname, (void *)ui_swinfo, true, false); return; } else if (!mopt.skip_parts_menu() && swinfo->has_multiple_parts(ui_swinfo->interface.c_str())) @@ -1170,7 +1174,7 @@ void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event) parts.emplace(swpart.name(), menu_part_name); } } - ui_menu::stack_push(global_alloc_clear(ui(), container, parts, ui_swinfo)); + menu::stack_push(ui(), container, parts, ui_swinfo); return; } @@ -1184,12 +1188,12 @@ void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event) reselect_last::swlist = ui_swinfo->listname; mame_machine_manager::instance()->schedule_new_driver(drv.driver()); machine().schedule_hard_reset(); - ui_menu::stack_reset(machine()); + menu::stack_reset(machine()); } // otherwise, display an error else { - reset(UI_MENU_RESET_REMEMBER_POSITION); + reset(reset_options::REMEMBER_POSITION); ui_error = true; } } @@ -1199,7 +1203,7 @@ void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event) // returns if the search can be activated //------------------------------------------------- -inline bool ui_menu_select_game::isfavorite() +inline bool menu_select_game::isfavorite() { return (main_filters::actual == FILTER_FAVORITE); } @@ -1208,27 +1212,27 @@ inline bool ui_menu_select_game::isfavorite() // handle special key event //------------------------------------------------- -void ui_menu_select_game::inkey_special(const ui_menu_event *m_event) +void menu_select_game::inkey_special(const event *menu_event) { int buflen = strlen(m_search); // if it's a backspace and we can handle it, do so - if (((m_event->unichar == 8 || m_event->unichar == 0x7f) && buflen > 0) && !isfavorite()) + if (((menu_event->unichar == 8 || menu_event->unichar == 0x7f) && buflen > 0) && !isfavorite()) { *(char *)utf8_previous_char(&m_search[buflen]) = 0; - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); } - else if ((m_event->unichar >= ' ' && m_event->unichar < 0x7f) && !isfavorite()) + else if ((menu_event->unichar >= ' ' && menu_event->unichar < 0x7f) && !isfavorite()) { // if it's any other key and we're not maxed out, update - buflen += utf8_from_uchar(&m_search[buflen], ARRAY_LENGTH(m_search) - buflen, m_event->unichar); + buflen += utf8_from_uchar(&m_search[buflen], ARRAY_LENGTH(m_search) - buflen, menu_event->unichar); m_search[buflen] = 0; - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); } } -void ui_menu_select_game::inkey_configure(const ui_menu_event *m_event) +void menu_select_game::inkey_configure(const event *menu_event) { if (selected <= visible_items && m_focus == focused_menu::main) { @@ -1288,7 +1292,7 @@ void ui_menu_select_game::inkey_configure(const ui_menu_event *m_event) // build list //------------------------------------------------- -void ui_menu_select_game::build_list(const char *filter_text, int filter, bool bioscheck, std::vector s_drivers) +void menu_select_game::build_list(const char *filter_text, int filter, bool bioscheck, std::vector s_drivers) { int cx = 0; bool cloneof = false; @@ -1311,94 +1315,94 @@ void ui_menu_select_game::build_list(const char *filter_text, int filter, bool b switch (filter) { - case FILTER_ALL: - case FILTER_AVAILABLE: - case FILTER_UNAVAILABLE: + case FILTER_ALL: + case FILTER_AVAILABLE: + case FILTER_UNAVAILABLE: + m_displaylist.push_back(s_driver); + break; + + case FILTER_WORKING: + if (!(s_driver->flags & MACHINE_NOT_WORKING)) m_displaylist.push_back(s_driver); - break; + break; - case FILTER_WORKING: - if (!(s_driver->flags & MACHINE_NOT_WORKING)) - m_displaylist.push_back(s_driver); - break; + case FILTER_NOT_MECHANICAL: + if (!(s_driver->flags & MACHINE_MECHANICAL)) + m_displaylist.push_back(s_driver); + break; - case FILTER_NOT_MECHANICAL: - if (!(s_driver->flags & MACHINE_MECHANICAL)) - m_displaylist.push_back(s_driver); - break; + case FILTER_BIOS: + if (s_driver->flags & MACHINE_IS_BIOS_ROOT) + m_displaylist.push_back(s_driver); + break; - case FILTER_BIOS: - if (s_driver->flags & MACHINE_IS_BIOS_ROOT) - m_displaylist.push_back(s_driver); - break; + case FILTER_PARENT: + case FILTER_CLONES: + cloneof = strcmp(s_driver->parent, "0"); + if (cloneof) + { + cx = driver_list::find(s_driver->parent); + if (cx != -1 && ((driver_list::driver(cx).flags & MACHINE_IS_BIOS_ROOT) != 0)) + cloneof = false; + } - case FILTER_PARENT: - case FILTER_CLONES: - cloneof = strcmp(s_driver->parent, "0"); - if (cloneof) - { - cx = driver_list::find(s_driver->parent); - if (cx != -1 && ((driver_list::driver(cx).flags & MACHINE_IS_BIOS_ROOT) != 0)) - cloneof = false; - } + if (filter == FILTER_CLONES && cloneof) + m_displaylist.push_back(s_driver); + else if (filter == FILTER_PARENT && !cloneof) + m_displaylist.push_back(s_driver); + break; - if (filter == FILTER_CLONES && cloneof) - m_displaylist.push_back(s_driver); - else if (filter == FILTER_PARENT && !cloneof) - m_displaylist.push_back(s_driver); - break; + case FILTER_NOT_WORKING: + if (s_driver->flags & MACHINE_NOT_WORKING) + m_displaylist.push_back(s_driver); + break; - case FILTER_NOT_WORKING: - if (s_driver->flags & MACHINE_NOT_WORKING) - m_displaylist.push_back(s_driver); - break; + case FILTER_MECHANICAL: + if (s_driver->flags & MACHINE_MECHANICAL) + m_displaylist.push_back(s_driver); + break; - case FILTER_MECHANICAL: - if (s_driver->flags & MACHINE_MECHANICAL) - m_displaylist.push_back(s_driver); - break; + case FILTER_SAVE: + if (s_driver->flags & MACHINE_SUPPORTS_SAVE) + m_displaylist.push_back(s_driver); + break; - case FILTER_SAVE: - if (s_driver->flags & MACHINE_SUPPORTS_SAVE) - m_displaylist.push_back(s_driver); - break; + case FILTER_NOSAVE: + if (!(s_driver->flags & MACHINE_SUPPORTS_SAVE)) + m_displaylist.push_back(s_driver); + break; - case FILTER_NOSAVE: - if (!(s_driver->flags & MACHINE_SUPPORTS_SAVE)) - m_displaylist.push_back(s_driver); - break; + case FILTER_YEAR: + if (!core_stricmp(filter_text, s_driver->year)) + m_displaylist.push_back(s_driver); + break; - case FILTER_YEAR: - if (!core_stricmp(filter_text, s_driver->year)) - m_displaylist.push_back(s_driver); - break; + case FILTER_VERTICAL: + if (s_driver->flags & ORIENTATION_SWAP_XY) + m_displaylist.push_back(s_driver); + break; - case FILTER_VERTICAL: - if (s_driver->flags & ORIENTATION_SWAP_XY) - m_displaylist.push_back(s_driver); - break; + case FILTER_HORIZONTAL: + if (!(s_driver->flags & ORIENTATION_SWAP_XY)) + m_displaylist.push_back(s_driver); + break; - case FILTER_HORIZONTAL: - if (!(s_driver->flags & ORIENTATION_SWAP_XY)) - m_displaylist.push_back(s_driver); - break; - - case FILTER_MANUFACTURER: + case FILTER_MANUFACTURER: { std::string name = c_mnfct::getname(s_driver->manufacturer); if (!core_stricmp(filter_text, name.c_str())) m_displaylist.push_back(s_driver); - break; } - case FILTER_CHD: - for (const rom_entry *rom = s_driver->rom; !ROMENTRY_ISEND(rom); ++rom) - if (ROMENTRY_ISREGION(rom) && ROMREGION_ISDISKDATA(rom)) - { - m_displaylist.push_back(s_driver); - break; - } - break; - case FILTER_NOCHD: + break; + case FILTER_CHD: + for (const rom_entry *rom = s_driver->rom; !ROMENTRY_ISEND(rom); ++rom) + if (ROMENTRY_ISREGION(rom) && ROMREGION_ISDISKDATA(rom)) + { + m_displaylist.push_back(s_driver); + break; + } + break; + case FILTER_NOCHD: { bool found = false; for (const rom_entry *rom = s_driver->rom; !ROMENTRY_ISEND(rom); ++rom) @@ -1409,8 +1413,8 @@ void ui_menu_select_game::build_list(const char *filter_text, int filter, bool b } if (!found) m_displaylist.push_back(s_driver); - break; } + break; } } } @@ -1419,7 +1423,7 @@ void ui_menu_select_game::build_list(const char *filter_text, int filter, bool b // build custom display list //------------------------------------------------- -void ui_menu_select_game::build_custom() +void menu_select_game::build_custom() { std::vector s_drivers; bool bioscheck = false; @@ -1468,7 +1472,7 @@ void ui_menu_select_game::build_custom() // build category list //------------------------------------------------- -void ui_menu_select_game::build_category() +void menu_select_game::build_category() { m_displaylist.clear(); std::vector temp_filter; @@ -1484,7 +1488,7 @@ void ui_menu_select_game::build_category() // populate search list //------------------------------------------------- -void ui_menu_select_game::populate_search() +void menu_select_game::populate_search() { // allocate memory to track the penalty value std::vector penalty(VISIBLE_GAMES_IN_SEARCH, 9999); @@ -1516,7 +1520,7 @@ void ui_menu_select_game::populate_search() } (index < VISIBLE_GAMES_IN_SEARCH) ? m_searchlist[index] = nullptr : m_searchlist[VISIBLE_GAMES_IN_SEARCH] = nullptr; - UINT32 flags_ui = MENU_FLAG_UI | MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW; + UINT32 flags_ui = FLAG_UI | FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW; for (int curitem = 0; m_searchlist[curitem]; ++curitem) { bool cloneof = strcmp(m_searchlist[curitem]->parent, "0"); @@ -1526,7 +1530,7 @@ void ui_menu_select_game::populate_search() if (cx != -1 && ((driver_list::driver(cx).flags & MACHINE_IS_BIOS_ROOT) != 0)) cloneof = false; } - item_append(m_searchlist[curitem]->description, nullptr, (!cloneof) ? flags_ui : (MENU_FLAG_INVERT | flags_ui), + item_append(m_searchlist[curitem]->description, nullptr, (!cloneof) ? flags_ui : (FLAG_INVERT | flags_ui), (void *)m_searchlist[curitem]); } } @@ -1535,7 +1539,7 @@ void ui_menu_select_game::populate_search() // generate general info //------------------------------------------------- -void ui_menu_select_game::general_info(const game_driver *driver, std::string &buffer) +void menu_select_game::general_info(const game_driver *driver, std::string &buffer) { std::ostringstream str; @@ -1617,7 +1621,7 @@ void ui_menu_select_game::general_info(const game_driver *driver, std::string &b buffer = str.str(); } -void ui_menu_select_game::inkey_export() +void menu_select_game::inkey_export() { std::vector list; if (m_search[0] != 0) @@ -1631,14 +1635,14 @@ void ui_menu_select_game::inkey_export() { list = m_displaylist; } - ui_menu::stack_push(global_alloc_clear(ui(), container, list)); + menu::stack_push(ui(), container, list); } //------------------------------------------------- // save drivers infos to file //------------------------------------------------- -void ui_menu_select_game::init_sorted_list() +void menu_select_game::init_sorted_list() { if (!m_sortedlist.empty()) return; @@ -1667,7 +1671,7 @@ void ui_menu_select_game::init_sorted_list() // load drivers infos from file //------------------------------------------------- -bool ui_menu_select_game::load_available_machines() +bool menu_select_game::load_available_machines() { // try to load available drivers from file emu_file file(ui().options().ui_path(), OPEN_FLAG_READ); @@ -1719,7 +1723,7 @@ bool ui_menu_select_game::load_available_machines() // load custom filters info from file //------------------------------------------------- -void ui_menu_select_game::load_custom_filters() +void menu_select_game::load_custom_filters() { // attempt to open the output file emu_file file(ui().options().ui_path(), OPEN_FLAG_READ); @@ -1779,7 +1783,7 @@ void ui_menu_select_game::load_custom_filters() // draw left box //------------------------------------------------- -float ui_menu_select_game::draw_left_panel(float x1, float y1, float x2, float y2) +float menu_select_game::draw_left_panel(float x1, float y1, float x2, float y2) { float line_height = ui().get_line_height(); @@ -1837,7 +1841,7 @@ float ui_menu_select_game::draw_left_panel(float x1, float y1, float x2, float y bgcolor = UI_MOUSEOVER_BG_COLOR; fgcolor = UI_MOUSEOVER_COLOR; hover = phover + filter; - ui_menu::highlight(container, x1, y1, x2, y1+ line_height_max, bgcolor); + menu::highlight(container, x1, y1, x2, y1+ line_height_max, bgcolor); } if (highlight == filter && m_focus == focused_menu::left) @@ -1937,7 +1941,7 @@ float ui_menu_select_game::draw_left_panel(float x1, float y1, float x2, float y // draw infos //------------------------------------------------- -void ui_menu_select_game::infos_render(void *selectedref, float origx1, float origy1, float origx2, float origy2) +void menu_select_game::infos_render(void *selectedref, float origx1, float origy1, float origx2, float origy2) { float line_height = ui().get_line_height(); static std::string buffer; @@ -1946,7 +1950,7 @@ void ui_menu_select_game::infos_render(void *selectedref, float origx1, float or float text_size = ui().options().infos_size(); const game_driver *driver = nullptr; ui_software_info *soft = nullptr; - bool is_favorites = ((item[0].flags & MENU_FLAG_UI_FAVORITE) != 0); + bool is_favorites = ((item[0].flags & FLAG_UI_FAVORITE) != 0); static ui_software_info *oldsoft = nullptr; static const game_driver *olddriver = nullptr; static int oldview = -1; @@ -2251,7 +2255,7 @@ void ui_menu_select_game::infos_render(void *selectedref, float origx1, float or // draw right panel //------------------------------------------------- -void ui_menu_select_game::draw_right_panel(void *selectedref, float origx1, float origy1, float origx2, float origy2) +void menu_select_game::draw_right_panel(void *selectedref, float origx1, float origy1, float origx2, float origy2) { rgb_t fgcolor = UI_TEXT_COLOR; bool hide = (ui_globals::panels_status == HIDE_RIGHT_PANEL || ui_globals::panels_status == HIDE_BOTH); @@ -2293,10 +2297,10 @@ void ui_menu_select_game::draw_right_panel(void *selectedref, float origx1, floa // perform our special rendering //------------------------------------------------- -void ui_menu_select_game::arts_render(void *selectedref, float origx1, float origy1, float origx2, float origy2) +void menu_select_game::arts_render(void *selectedref, float origx1, float origy1, float origx2, float origy2) { float line_height = ui().get_line_height(); - bool is_favorites = ((item[0].flags & MENU_FLAG_UI_FAVORITE) != 0); + bool is_favorites = ((item[0].flags & FLAG_UI_FAVORITE) != 0); static ui_software_info *oldsoft = nullptr; static const game_driver *olddriver = nullptr; const game_driver *driver = nullptr; @@ -2488,3 +2492,5 @@ void ui_menu_select_game::arts_render(void *selectedref, float origx1, float ori } } } + +} // namespace ui diff --git a/src/frontend/mame/ui/selgame.h b/src/frontend/mame/ui/selgame.h index 7ad48e537df..fc4281d9117 100644 --- a/src/frontend/mame/ui/selgame.h +++ b/src/frontend/mame/ui/selgame.h @@ -10,16 +10,19 @@ #pragma once -#ifndef __UI_MAIN_H__ -#define __UI_MAIN_H__ +#ifndef MAME_FRONTEND_UI_SELGAME_H +#define MAME_FRONTEND_UI_SELGAME_H #include "ui/menu.h" -class ui_menu_select_game : public ui_menu + +namespace ui { + +class menu_select_game : public menu { public: - ui_menu_select_game(mame_ui_manager &mui, render_container *container, const char *gamename); - virtual ~ui_menu_select_game(); + menu_select_game(mame_ui_manager &mui, render_container *container, const char *gamename); + virtual ~menu_select_game(); virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -74,12 +77,13 @@ private: void infos_render(void *selectedref, float x1, float y1, float x2, float y2); // handlers - void inkey_select(const ui_menu_event *menu_event); - void inkey_select_favorite(const ui_menu_event *menu_event); - void inkey_special(const ui_menu_event *menu_event); + void inkey_select(const event *menu_event); + void inkey_select_favorite(const event *menu_event); + void inkey_special(const event *menu_event); void inkey_export(); - void inkey_configure(const ui_menu_event *menu_event); + void inkey_configure(const event *menu_event); }; +} // namespace ui -#endif /* __UI_MAIN_H__ */ +#endif // MAME_FRONTEND_UI_SELGAME_H diff --git a/src/frontend/mame/ui/selsoft.cpp b/src/frontend/mame/ui/selsoft.cpp index c5f33b8c701..469bcd3a158 100644 --- a/src/frontend/mame/ui/selsoft.cpp +++ b/src/frontend/mame/ui/selsoft.cpp @@ -9,21 +9,26 @@ ***************************************************************************/ #include "emu.h" -#include "mame.h" -#include "emuopts.h" -#include "ui/ui.h" -#include "ui/menu.h" -#include "uiinput.h" -#include "audit.h" -#include "drivenum.h" + #include "ui/selsoft.h" + +#include "ui/ui.h" #include "ui/datmenu.h" #include "ui/datfile.h" #include "ui/inifile.h" #include "ui/selector.h" + +#include "audit.h" +#include "drivenum.h" +#include "emuopts.h" +#include "mame.h" #include "rendfont.h" #include "rendutil.h" #include "softlist.h" +#include "uiinput.h" + + +namespace ui { std::string reselect_last::driver; std::string reselect_last::software; @@ -121,7 +126,7 @@ bool has_multiple_bios(const game_driver *driver, s_bios &biosname) // ctor //------------------------------------------------- -ui_menu_select_software::ui_menu_select_software(mame_ui_manager &mui, render_container *container, const game_driver *driver) : ui_menu(mui, container) +menu_select_software::menu_select_software(mame_ui_manager &mui, render_container *container, const game_driver *driver) : menu(mui, container) { if (reselect_last::get()) reselect_last::set(false); @@ -145,7 +150,7 @@ ui_menu_select_software::ui_menu_select_software(mame_ui_manager &mui, render_co // dtor //------------------------------------------------- -ui_menu_select_software::~ui_menu_select_software() +menu_select_software::~menu_select_software() { ui_globals::curimage_view = CABINETS_VIEW; ui_globals::switch_image = true; @@ -155,7 +160,7 @@ ui_menu_select_software::~ui_menu_select_software() // handle //------------------------------------------------- -void ui_menu_select_software::handle() +void menu_select_software::handle() { if (m_prev_selected == nullptr) m_prev_selected = item[0].ref; @@ -166,11 +171,11 @@ void ui_menu_select_software::handle() machine().ui_input().pressed(IPT_UI_PAUSE); // process the menu - const ui_menu_event *m_event = process(UI_MENU_PROCESS_LR_REPEAT); + const event *menu_event = process(PROCESS_LR_REPEAT); - if (m_event != nullptr && m_event->itemref != nullptr) + if (menu_event != nullptr && menu_event->itemref != nullptr) { - // reset the error on any future m_event + // reset the error on any future event if (ui_error) { ui_error = false; @@ -178,11 +183,11 @@ void ui_menu_select_software::handle() } // handle selections - else if (m_event->iptkey == IPT_UI_SELECT) + else if (menu_event->iptkey == IPT_UI_SELECT) { if (m_focus == focused_menu::main) { - inkey_select(m_event); + inkey_select(menu_event); } else if (m_focus == focused_menu::left) { @@ -193,7 +198,7 @@ void ui_menu_select_software::handle() } // handle UI_LEFT - else if (m_event->iptkey == IPT_UI_LEFT) + else if (menu_event->iptkey == IPT_UI_LEFT) { // Images if (ui_globals::rpanel == RP_IMAGES && ui_globals::curimage_view > FIRST_VIEW) @@ -212,7 +217,7 @@ void ui_menu_select_software::handle() } // handle UI_RIGHT - else if (m_event->iptkey == IPT_UI_RIGHT) + else if (menu_event->iptkey == IPT_UI_RIGHT) { // Images if (ui_globals::rpanel == RP_IMAGES && ui_globals::curimage_view < LAST_VIEW) @@ -231,48 +236,48 @@ void ui_menu_select_software::handle() } // handle UI_UP_FILTER - else if (m_event->iptkey == IPT_UI_UP_FILTER && highlight > UI_SW_FIRST) + else if (menu_event->iptkey == IPT_UI_UP_FILTER && highlight > UI_SW_FIRST) { highlight--; } // handle UI_DOWN_FILTER - else if (m_event->iptkey == IPT_UI_DOWN_FILTER && highlight < UI_SW_LAST) + else if (menu_event->iptkey == IPT_UI_DOWN_FILTER && highlight < UI_SW_LAST) { highlight++; } // handle UI_DATS - else if (m_event->iptkey == IPT_UI_DATS && ui().options().enabled_dats()) + else if (menu_event->iptkey == IPT_UI_DATS && ui().options().enabled_dats()) { - ui_software_info *ui_swinfo = (ui_software_info *)m_event->itemref; + ui_software_info *ui_swinfo = (ui_software_info *)menu_event->itemref; datfile_manager &mdat = mame_machine_manager::instance()->datfile(); if (ui_swinfo->startempty == 1 && mdat.has_history(ui_swinfo->driver)) - ui_menu::stack_push(global_alloc_clear(ui(), container, ui_swinfo->driver)); + menu::stack_push(ui(), container, ui_swinfo->driver); else if (mdat.has_software(ui_swinfo->listname, ui_swinfo->shortname, ui_swinfo->parentname) || !ui_swinfo->usage.empty()) - ui_menu::stack_push(global_alloc_clear(ui(), container, ui_swinfo)); + menu::stack_push(ui(), container, ui_swinfo); } // handle UI_LEFT_PANEL - else if (m_event->iptkey == IPT_UI_LEFT_PANEL) + else if (menu_event->iptkey == IPT_UI_LEFT_PANEL) ui_globals::rpanel = RP_IMAGES; // handle UI_RIGHT_PANEL - else if (m_event->iptkey == IPT_UI_RIGHT_PANEL) + else if (menu_event->iptkey == IPT_UI_RIGHT_PANEL) ui_globals::rpanel = RP_INFOS; // escape pressed with non-empty text clears the text - else if (m_event->iptkey == IPT_UI_CANCEL && m_search[0] != 0) + else if (menu_event->iptkey == IPT_UI_CANCEL && m_search[0] != 0) { m_search[0] = '\0'; - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); } // handle UI_FAVORITES - else if (m_event->iptkey == IPT_UI_FAVORITES) + else if (menu_event->iptkey == IPT_UI_FAVORITES) { - ui_software_info *swinfo = (ui_software_info *)m_event->itemref; + ui_software_info *swinfo = (ui_software_info *)menu_event->itemref; if ((FPTR)swinfo > 2) { @@ -292,27 +297,27 @@ void ui_menu_select_software::handle() } // typed characters append to the buffer - else if (m_event->iptkey == IPT_SPECIAL) - inkey_special(m_event); + else if (menu_event->iptkey == IPT_SPECIAL) + inkey_special(menu_event); - else if (m_event->iptkey == IPT_OTHER) + else if (menu_event->iptkey == IPT_OTHER) { highlight = l_sw_hover; check_filter = true; m_prev_selected = nullptr; } - else if (m_event->iptkey == IPT_UI_CONFIGURE) - inkey_configure(m_event); + else if (menu_event->iptkey == IPT_UI_CONFIGURE) + inkey_configure(menu_event); } - if (m_event != nullptr && m_event->itemref == nullptr) + if (menu_event && !menu_event->itemref) { - if (m_event->iptkey == IPT_UI_CONFIGURE) - inkey_configure(m_event); + if (menu_event->iptkey == IPT_UI_CONFIGURE) + inkey_configure(menu_event); // handle UI_LEFT - else if (m_event->iptkey == IPT_UI_LEFT) + else if (menu_event->iptkey == IPT_UI_LEFT) { // Images if (ui_globals::rpanel == RP_IMAGES && ui_globals::curimage_view > FIRST_VIEW) @@ -331,7 +336,7 @@ void ui_menu_select_software::handle() } // handle UI_RIGHT - else if (m_event->iptkey == IPT_UI_RIGHT) + else if (menu_event->iptkey == IPT_UI_RIGHT) { // Images if (ui_globals::rpanel == RP_IMAGES && ui_globals::curimage_view < LAST_VIEW) @@ -350,25 +355,25 @@ void ui_menu_select_software::handle() } // handle UI_LEFT_PANEL - else if (m_event->iptkey == IPT_UI_LEFT_PANEL) + else if (menu_event->iptkey == IPT_UI_LEFT_PANEL) ui_globals::rpanel = RP_IMAGES; // handle UI_RIGHT_PANEL - else if (m_event->iptkey == IPT_UI_RIGHT_PANEL) + else if (menu_event->iptkey == IPT_UI_RIGHT_PANEL) ui_globals::rpanel = RP_INFOS; // handle UI_UP_FILTER - else if (m_event->iptkey == IPT_UI_UP_FILTER && highlight > UI_SW_FIRST) + else if (menu_event->iptkey == IPT_UI_UP_FILTER && highlight > UI_SW_FIRST) { highlight--; } // handle UI_DOWN_FILTER - else if (m_event->iptkey == IPT_UI_DOWN_FILTER && highlight < UI_SW_LAST) + else if (menu_event->iptkey == IPT_UI_DOWN_FILTER && highlight < UI_SW_LAST) { highlight++; } - else if (m_event->iptkey == IPT_OTHER && m_focus == focused_menu::left) + else if (menu_event->iptkey == IPT_OTHER && m_focus == focused_menu::left) { l_sw_hover = highlight; check_filter = true; @@ -389,34 +394,29 @@ void ui_menu_select_software::handle() m_search[0] = '\0'; switch (l_sw_hover) { - case UI_SW_REGION: - ui_menu::stack_push(global_alloc_clear(ui(), container, m_filter.region.ui, - m_filter.region.actual, SELECTOR_SOFTWARE, l_sw_hover)); - break; - case UI_SW_YEARS: - ui_menu::stack_push(global_alloc_clear(ui(), container, m_filter.year.ui, - m_filter.year.actual, SELECTOR_SOFTWARE, l_sw_hover)); - break; - case UI_SW_LIST: - ui_menu::stack_push(global_alloc_clear(ui(), container, m_filter.swlist.description, - m_filter.swlist.actual, SELECTOR_SOFTWARE, l_sw_hover)); - break; - case UI_SW_TYPE: - ui_menu::stack_push(global_alloc_clear(ui(), container, m_filter.type.ui, - m_filter.type.actual, SELECTOR_SOFTWARE, l_sw_hover)); - break; - case UI_SW_PUBLISHERS: - ui_menu::stack_push(global_alloc_clear(ui(), container, m_filter.publisher.ui, - m_filter.publisher.actual, SELECTOR_SOFTWARE, l_sw_hover)); - break; - case UI_SW_CUSTOM: - sw_filters::actual = l_sw_hover; - ui_menu::stack_push(global_alloc_clear(ui(), container, m_driver, m_filter)); - break; - default: - sw_filters::actual = l_sw_hover; - reset(UI_MENU_RESET_SELECT_FIRST); - break; + case UI_SW_REGION: + menu::stack_push(ui(), container, m_filter.region.ui, m_filter.region.actual, menu_selector::SOFTWARE, l_sw_hover); + break; + case UI_SW_YEARS: + menu::stack_push(ui(), container, m_filter.year.ui, m_filter.year.actual, menu_selector::SOFTWARE, l_sw_hover); + break; + case UI_SW_LIST: + menu::stack_push(ui(), container, m_filter.swlist.description, m_filter.swlist.actual, menu_selector::SOFTWARE, l_sw_hover); + break; + case UI_SW_TYPE: + menu::stack_push(ui(), container, m_filter.type.ui, m_filter.type.actual, menu_selector::SOFTWARE, l_sw_hover); + break; + case UI_SW_PUBLISHERS: + menu::stack_push(ui(), container, m_filter.publisher.ui, m_filter.publisher.actual, menu_selector::SOFTWARE, l_sw_hover); + break; + case UI_SW_CUSTOM: + sw_filters::actual = l_sw_hover; + menu::stack_push(ui(), container, m_driver, m_filter); + break; + default: + sw_filters::actual = l_sw_hover; + reset(reset_options::SELECT_FIRST); + break; } } } @@ -425,9 +425,9 @@ void ui_menu_select_software::handle() // populate //------------------------------------------------- -void ui_menu_select_software::populate() +void menu_select_software::populate() { - UINT32 flags_ui = MENU_FLAG_UI_SWLIST | MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW; + UINT32 flags_ui = FLAG_UI_SWLIST | FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW; m_has_empty_start = true; int old_software = -1; @@ -490,7 +490,7 @@ void ui_menu_select_software::populate() old_software = m_has_empty_start ? curitem + 1 : curitem; item_append(m_displaylist[curitem]->longname.c_str(), m_displaylist[curitem]->devicetype.c_str(), - m_displaylist[curitem]->parentname.empty() ? flags_ui : (MENU_FLAG_INVERT | flags_ui), (void *)m_displaylist[curitem]); + m_displaylist[curitem]->parentname.empty() ? flags_ui : (FLAG_INVERT | flags_ui), (void *)m_displaylist[curitem]); } } @@ -500,7 +500,7 @@ void ui_menu_select_software::populate() for (int curitem = 0; m_searchlist[curitem] != nullptr; ++curitem) item_append(m_searchlist[curitem]->longname.c_str(), m_searchlist[curitem]->devicetype.c_str(), - m_searchlist[curitem]->parentname.empty() ? flags_ui : (MENU_FLAG_INVERT | flags_ui), + m_searchlist[curitem]->parentname.empty() ? flags_ui : (FLAG_INVERT | flags_ui), (void *)m_searchlist[curitem]); } @@ -523,7 +523,7 @@ void ui_menu_select_software::populate() // build a list of software //------------------------------------------------- -void ui_menu_select_software::build_software_list() +void menu_select_software::build_software_list() { // add start empty item m_swinfo.emplace_back(m_driver->name, m_driver->description, "", "", "", 0, "", m_driver, "", "", "", 1, "", "", "", true); @@ -665,7 +665,7 @@ void ui_menu_select_software::build_software_list() // perform our special rendering //------------------------------------------------- -void ui_menu_select_software::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_select_software::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { ui_software_info *swinfo = (selectedref != nullptr) ? (ui_software_info *)selectedref : ((m_prev_selected != nullptr) ? (ui_software_info *)m_prev_selected : nullptr); const game_driver *driver = nullptr; @@ -893,16 +893,16 @@ void ui_menu_select_software::custom_render(void *selectedref, float top, float // handle select key event //------------------------------------------------- -void ui_menu_select_software::inkey_select(const ui_menu_event *m_event) +void menu_select_software::inkey_select(const event *menu_event) { - ui_software_info *ui_swinfo = (ui_software_info *)m_event->itemref; + ui_software_info *ui_swinfo = (ui_software_info *)menu_event->itemref; ui_options &mopt = ui().options(); if (ui_swinfo->startempty == 1) { s_bios biosname; if (!mopt.skip_bios_menu() && has_multiple_bios(ui_swinfo->driver, biosname)) - ui_menu::stack_push(global_alloc_clear(ui(), container, biosname, (void *)ui_swinfo->driver, false, true)); + menu::stack_push(ui(), container, biosname, (void *)ui_swinfo->driver, false, true); else { reselect_last::driver = ui_swinfo->driver->name; @@ -911,7 +911,7 @@ void ui_menu_select_software::inkey_select(const ui_menu_event *m_event) reselect_last::set(true); mame_machine_manager::instance()->schedule_new_driver(*ui_swinfo->driver); machine().schedule_hard_reset(); - ui_menu::stack_reset(machine()); + menu::stack_reset(machine()); } } @@ -931,7 +931,7 @@ void ui_menu_select_software::inkey_select(const ui_menu_event *m_event) s_bios biosname; if (!mopt.skip_bios_menu() && has_multiple_bios(ui_swinfo->driver, biosname)) { - ui_menu::stack_push(global_alloc_clear(ui(), container, biosname, (void *)ui_swinfo, true, false)); + menu::stack_push(ui(), container, biosname, (void *)ui_swinfo, true, false); return; } else if (!mopt.skip_parts_menu() && swinfo->has_multiple_parts(ui_swinfo->interface.c_str())) @@ -947,7 +947,7 @@ void ui_menu_select_software::inkey_select(const ui_menu_event *m_event) parts.emplace(swpart.name(), menu_part_name); } } - ui_menu::stack_push(global_alloc_clear(ui(), container, parts, ui_swinfo)); + menu::stack_push(ui(), container, parts, ui_swinfo); return; } std::string error_string; @@ -961,13 +961,13 @@ void ui_menu_select_software::inkey_select(const ui_menu_event *m_event) reselect_last::set(true); mame_machine_manager::instance()->schedule_new_driver(drivlist.driver()); machine().schedule_hard_reset(); - ui_menu::stack_reset(machine()); + menu::stack_reset(machine()); } // otherwise, display an error else { - reset(UI_MENU_RESET_REMEMBER_POSITION); + reset(reset_options::REMEMBER_POSITION); ui_error = true; } } @@ -977,27 +977,27 @@ void ui_menu_select_software::inkey_select(const ui_menu_event *m_event) // handle special key event //------------------------------------------------- -void ui_menu_select_software::inkey_special(const ui_menu_event *m_event) +void menu_select_software::inkey_special(const event *menu_event) { int buflen = strlen(m_search); // if it's a backspace and we can handle it, do so - if ((m_event->unichar == 8 || m_event->unichar == 0x7f) && buflen > 0) + if ((menu_event->unichar == 8 || menu_event->unichar == 0x7f) && buflen > 0) { *(char *)utf8_previous_char(&m_search[buflen]) = 0; - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); } // if it's any other key and we're not maxed out, update - else if (m_event->unichar >= ' ' && m_event->unichar < 0x7f) + else if (menu_event->unichar >= ' ' && menu_event->unichar < 0x7f) { - buflen += utf8_from_uchar(&m_search[buflen], ARRAY_LENGTH(m_search) - buflen, m_event->unichar); + buflen += utf8_from_uchar(&m_search[buflen], ARRAY_LENGTH(m_search) - buflen, menu_event->unichar); m_search[buflen] = 0; - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); } } -void ui_menu_select_software::inkey_configure(const ui_menu_event *m_event) +void menu_select_software::inkey_configure(const event *menu_event) { if (selected <= visible_items && m_focus == focused_menu::main) { @@ -1057,7 +1057,7 @@ void ui_menu_select_software::inkey_configure(const ui_menu_event *m_event) // load custom filters info from file //------------------------------------------------- -void ui_menu_select_software::load_sw_custom_filters() +void menu_select_software::load_sw_custom_filters() { // attempt to open the output file emu_file file(ui().options().ui_path(), OPEN_FLAG_READ); @@ -1218,7 +1218,7 @@ std::string c_sw_publisher::getname(std::string &str) //------------------------------------------------- // build display list //------------------------------------------------- -void ui_menu_select_software::build_list(std::vector &s_drivers, const char *filter_text, int filter) +void menu_select_software::build_list(std::vector &s_drivers, const char *filter_text, int filter) { if (s_drivers.empty() && filter == -1) { @@ -1231,77 +1231,77 @@ void ui_menu_select_software::build_list(std::vector &s_driv { switch (filter) { - case UI_SW_PARENTS: - if (s_driver->parentname.empty()) - m_displaylist.push_back(s_driver); + case UI_SW_PARENTS: + if (s_driver->parentname.empty()) + m_displaylist.push_back(s_driver); + break; + + case UI_SW_CLONES: + if (!s_driver->parentname.empty()) + m_displaylist.push_back(s_driver); + break; + + case UI_SW_AVAILABLE: + if (s_driver->available) + m_displaylist.push_back(s_driver); break; - case UI_SW_CLONES: - if (!s_driver->parentname.empty()) - m_displaylist.push_back(s_driver); + case UI_SW_UNAVAILABLE: + if (!s_driver->available) + m_displaylist.push_back(s_driver); break; - case UI_SW_AVAILABLE: - if (s_driver->available) - m_displaylist.push_back(s_driver); - break; + case UI_SW_SUPPORTED: + if (s_driver->supported == SOFTWARE_SUPPORTED_YES) + m_displaylist.push_back(s_driver); + break; - case UI_SW_UNAVAILABLE: - if (!s_driver->available) - m_displaylist.push_back(s_driver); - break; + case UI_SW_PARTIAL_SUPPORTED: + if (s_driver->supported == SOFTWARE_SUPPORTED_PARTIAL) + m_displaylist.push_back(s_driver); + break; - case UI_SW_SUPPORTED: - if (s_driver->supported == SOFTWARE_SUPPORTED_YES) - m_displaylist.push_back(s_driver); - break; + case UI_SW_UNSUPPORTED: + if (s_driver->supported == SOFTWARE_SUPPORTED_NO) + m_displaylist.push_back(s_driver); + break; - case UI_SW_PARTIAL_SUPPORTED: - if (s_driver->supported == SOFTWARE_SUPPORTED_PARTIAL) - m_displaylist.push_back(s_driver); - break; - - case UI_SW_UNSUPPORTED: - if (s_driver->supported == SOFTWARE_SUPPORTED_NO) - m_displaylist.push_back(s_driver); - break; - - case UI_SW_REGION: + case UI_SW_REGION: { std::string name = m_filter.region.getname(s_driver->longname); if(!name.empty() && name == filter_text) m_displaylist.push_back(s_driver); - break; } + break; - case UI_SW_PUBLISHERS: + case UI_SW_PUBLISHERS: { std::string name = m_filter.publisher.getname(s_driver->publisher); if(!name.empty() && name == filter_text) m_displaylist.push_back(s_driver); - break; } + break; - case UI_SW_YEARS: - if(s_driver->year == filter_text) - m_displaylist.push_back(s_driver); - break; - - case UI_SW_LIST: - if(s_driver->listname == filter_text) - m_displaylist.push_back(s_driver); - break; - - case UI_SW_TYPE: - if(s_driver->devicetype == filter_text) - m_displaylist.push_back(s_driver); - break; - - default: + case UI_SW_YEARS: + if(s_driver->year == filter_text) m_displaylist.push_back(s_driver); - break; + break; + + case UI_SW_LIST: + if(s_driver->listname == filter_text) + m_displaylist.push_back(s_driver); + break; + + case UI_SW_TYPE: + if(s_driver->devicetype == filter_text) + m_displaylist.push_back(s_driver); + break; + + default: + m_displaylist.push_back(s_driver); + break; } } } @@ -1310,7 +1310,7 @@ void ui_menu_select_software::build_list(std::vector &s_driv // find approximate matches //------------------------------------------------- -void ui_menu_select_software::find_matches(const char *str, int count) +void menu_select_software::find_matches(const char *str, int count) { // allocate memory to track the penalty value std::vector penalty(count, 9999); @@ -1348,7 +1348,7 @@ void ui_menu_select_software::find_matches(const char *str, int count) // build custom display list //------------------------------------------------- -void ui_menu_select_software::build_custom() +void menu_select_software::build_custom() { std::vector s_drivers; @@ -1388,7 +1388,7 @@ void ui_menu_select_software::build_custom() // draw left box //------------------------------------------------- -float ui_menu_select_software::draw_left_panel(float x1, float y1, float x2, float y2) +float menu_select_software::draw_left_panel(float x1, float y1, float x2, float y2) { if (ui_globals::panels_status == SHOW_PANELS || ui_globals::panels_status == HIDE_RIGHT_PANEL) { @@ -1546,7 +1546,7 @@ float ui_menu_select_software::draw_left_panel(float x1, float y1, float x2, flo // draw infos //------------------------------------------------- -void ui_menu_select_software::infos_render(void *selectedref, float origx1, float origy1, float origx2, float origy2) +void menu_select_software::infos_render(void *selectedref, float origx1, float origy1, float origx2, float origy2) { float line_height = ui().get_line_height(); static std::string buffer; @@ -1689,7 +1689,7 @@ void ui_menu_select_software::infos_render(void *selectedref, float origx1, floa // perform our special rendering //------------------------------------------------- -void ui_menu_select_software::arts_render(void *selectedref, float origx1, float origy1, float origx2, float origy2) +void menu_select_software::arts_render(void *selectedref, float origx1, float origy1, float origx2, float origy2) { float line_height = ui().get_line_height(); static ui_software_info *oldsoft = nullptr; @@ -1874,7 +1874,7 @@ void ui_menu_select_software::arts_render(void *selectedref, float origx1, float } } -void ui_menu_select_software::draw_right_panel(void *selectedref, float origx1, float origy1, float origx2, float origy2) +void menu_select_software::draw_right_panel(void *selectedref, float origx1, float origy1, float origx2, float origy2) { rgb_t fgcolor = UI_TEXT_COLOR; bool hide = (ui_globals::panels_status == HIDE_RIGHT_PANEL || ui_globals::panels_status == HIDE_BOTH); @@ -1916,7 +1916,7 @@ void ui_menu_select_software::draw_right_panel(void *selectedref, float origx1, // ctor //------------------------------------------------- -ui_software_parts::ui_software_parts(mame_ui_manager &mui, render_container *container, s_parts parts, ui_software_info *ui_info) : ui_menu(mui, container) +software_parts::software_parts(mame_ui_manager &mui, render_container *container, s_parts parts, ui_software_info *ui_info) : menu(mui, container) { m_parts = parts; m_uiinfo = ui_info; @@ -1926,7 +1926,7 @@ ui_software_parts::ui_software_parts(mame_ui_manager &mui, render_container *con // dtor //------------------------------------------------- -ui_software_parts::~ui_software_parts() +software_parts::~software_parts() { } @@ -1934,12 +1934,12 @@ ui_software_parts::~ui_software_parts() // populate //------------------------------------------------- -void ui_software_parts::populate() +void software_parts::populate() { for (auto & elem : m_parts) item_append(elem.first.c_str(), elem.second.c_str(), 0, (void *)&elem); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER); } @@ -1947,13 +1947,15 @@ void ui_software_parts::populate() // handle //------------------------------------------------- -void ui_software_parts::handle() +void software_parts::handle() { // process the menu - const ui_menu_event *event = process(0); - if (event != nullptr && event->iptkey == IPT_UI_SELECT && event->itemref != nullptr) + const event *menu_event = process(0); + if (menu_event && (menu_event->iptkey) == IPT_UI_SELECT && menu_event->itemref) + { for (auto & elem : m_parts) - if ((void*)&elem == event->itemref) + { + 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); @@ -1969,15 +1971,17 @@ void ui_software_parts::handle() mame_machine_manager::instance()->schedule_new_driver(*m_uiinfo->driver); machine().schedule_hard_reset(); - ui_menu::stack_reset(machine()); + menu::stack_reset(machine()); } + } + } } //------------------------------------------------- // perform our special rendering //------------------------------------------------- -void ui_software_parts::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void software_parts::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float width; ui().draw_text_full(container, _("Software part selection:"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, @@ -2008,7 +2012,7 @@ void ui_software_parts::custom_render(void *selectedref, float top, float bottom // ctor //------------------------------------------------- -ui_bios_selection::ui_bios_selection(mame_ui_manager &mui, render_container *container, s_bios biosname, void *_driver, bool _software, bool _inlist) : ui_menu(mui, container) +bios_selection::bios_selection(mame_ui_manager &mui, render_container *container, s_bios biosname, void *_driver, bool _software, bool _inlist) : menu(mui, container) { m_bios = biosname; m_driver = _driver; @@ -2020,7 +2024,7 @@ ui_bios_selection::ui_bios_selection(mame_ui_manager &mui, render_container *con // dtor //------------------------------------------------- -ui_bios_selection::~ui_bios_selection() +bios_selection::~bios_selection() { } @@ -2028,12 +2032,12 @@ ui_bios_selection::~ui_bios_selection() // populate //------------------------------------------------- -void ui_bios_selection::populate() +void bios_selection::populate() { for (auto & elem : m_bios) item_append(elem.first.c_str(), nullptr, 0, (void *)&elem.first); - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER); } @@ -2041,14 +2045,16 @@ void ui_bios_selection::populate() // handle //------------------------------------------------- -void ui_bios_selection::handle() +void bios_selection::handle() { // process the menu - const ui_menu_event *event = process(0); + const event *menu_event = process(0); emu_options &moptions = machine().options(); - if (event != nullptr && event->iptkey == IPT_UI_SELECT && event->itemref != nullptr) + if (menu_event && menu_event->iptkey == IPT_UI_SELECT && menu_event->itemref) + { for (auto & elem : m_bios) - if ((void*)&elem.first == event->itemref) + { + if ((void*)&elem.first == menu_event->itemref) { if (!m_software) { @@ -2067,7 +2073,7 @@ void ui_bios_selection::handle() moptions.set_value(OPTION_BIOS, elem.second, OPTION_PRIORITY_CMDLINE, error); mame_machine_manager::instance()->schedule_new_driver(*s_driver); machine().schedule_hard_reset(); - ui_menu::stack_reset(machine()); + menu::stack_reset(machine()); } else { @@ -2091,7 +2097,7 @@ void ui_bios_selection::handle() parts.emplace(swpart.name(), menu_part_name); } } - ui_menu::stack_push(global_alloc_clear(ui(), container, parts, ui_swinfo)); + menu::stack_push(ui(), container, parts, ui_swinfo); return; } std::string error_string; @@ -2105,16 +2111,18 @@ void ui_bios_selection::handle() reselect_last::set(true); mame_machine_manager::instance()->schedule_new_driver(drivlist.driver()); machine().schedule_hard_reset(); - ui_menu::stack_reset(machine()); + menu::stack_reset(machine()); } } + } + } } //------------------------------------------------- // perform our special rendering //------------------------------------------------- -void ui_bios_selection::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void bios_selection::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float width; ui().draw_text_full(container, _("Bios selection:"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, @@ -2140,3 +2148,5 @@ void ui_bios_selection::custom_render(void *selectedref, float top, float bottom ui().draw_text_full(container, _("Bios selection:"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); } + +} // namespace ui diff --git a/src/frontend/mame/ui/selsoft.h b/src/frontend/mame/ui/selsoft.h index e65adc277d9..f5cca6a2ac5 100644 --- a/src/frontend/mame/ui/selsoft.h +++ b/src/frontend/mame/ui/selsoft.h @@ -9,20 +9,22 @@ ***************************************************************************/ #pragma once -#ifndef __UI_SELSOFT_H__ -#define __UI_SELSOFT_H__ +#ifndef MAME_FRONTEND_UI_SELSOFT_H +#define MAME_FRONTEND_UI_SELSOFT_H #include "ui/custmenu.h" +namespace ui { + using s_bios = std::vector>; using s_parts = std::unordered_map; // Menu Class -class ui_menu_select_software : public ui_menu +class menu_select_software : public menu { public: - ui_menu_select_software(mame_ui_manager &mui, render_container *container, const game_driver *driver); - virtual ~ui_menu_select_software(); + menu_select_software(mame_ui_manager &mui, render_container *container, const game_driver *driver); + virtual ~menu_select_software() override; virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -57,16 +59,16 @@ private: void infos_render(void *selectedref, float x1, float y1, float x2, float y2); // handlers - void inkey_select(const ui_menu_event *menu_event); - void inkey_special(const ui_menu_event *menu_event); - void inkey_configure(const ui_menu_event *menu_event); + void inkey_select(const event *menu_event); + void inkey_special(const event *menu_event); + void inkey_configure(const event *menu_event); }; -class ui_software_parts : public ui_menu +class software_parts : public menu { public: - ui_software_parts(mame_ui_manager &mui, render_container *container, s_parts parts, ui_software_info *ui_info); - virtual ~ui_software_parts(); + software_parts(mame_ui_manager &mui, render_container *container, s_parts parts, ui_software_info *ui_info); + virtual ~software_parts() override; virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -76,11 +78,11 @@ private: s_parts m_parts; }; -class ui_bios_selection : public ui_menu +class bios_selection : public menu { public: - ui_bios_selection(mame_ui_manager &mui, render_container *container, s_bios biosname, void *driver, bool software, bool inlist); - virtual ~ui_bios_selection(); + bios_selection(mame_ui_manager &mui, render_container *container, s_bios biosname, void *driver, bool software, bool inlist); + virtual ~bios_selection() override; virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -106,5 +108,6 @@ private: // Getter bool has_multiple_bios(const game_driver *driver, s_bios &biosname); +} // namespace ui -#endif /* __UI_SELSOFT_H__ */ +#endif /* MAME_FRONTEND_UI_SELSOFT_H */ diff --git a/src/frontend/mame/ui/simpleselgame.cpp b/src/frontend/mame/ui/simpleselgame.cpp index 6225d1e8467..ff73ca12d59 100644 --- a/src/frontend/mame/ui/simpleselgame.cpp +++ b/src/frontend/mame/ui/simpleselgame.cpp @@ -9,24 +9,29 @@ ***************************************************************************/ #include "emu.h" -#include "mame.h" -#include "emuopts.h" -#include "ui/ui.h" -#include "ui/menu.h" -#include "uiinput.h" + #include "ui/simpleselgame.h" + +#include "ui/ui.h" #include "ui/miscmenu.h" #include "ui/optsmenu.h" -#include "drivenum.h" + #include "audit.h" +#include "drivenum.h" +#include "emuopts.h" +#include "mame.h" +#include "uiinput.h" + #include +namespace ui { + //------------------------------------------------- // ctor //------------------------------------------------- -ui_simple_menu_select_game::ui_simple_menu_select_game(mame_ui_manager &mui, render_container *container, const char *gamename) : ui_menu(mui, container), m_driverlist(driver_list::total() + 1) +simple_menu_select_game::simple_menu_select_game(mame_ui_manager &mui, render_container *container, const char *gamename) : menu(mui, container), m_driverlist(driver_list::total() + 1) { build_driver_list(); if(gamename) @@ -39,7 +44,7 @@ ui_simple_menu_select_game::ui_simple_menu_select_game(mame_ui_manager &mui, ren // dtor //------------------------------------------------- -ui_simple_menu_select_game::~ui_simple_menu_select_game() +simple_menu_select_game::~simple_menu_select_game() { } @@ -50,7 +55,7 @@ ui_simple_menu_select_game::~ui_simple_menu_select_game() // drivers //------------------------------------------------- -void ui_simple_menu_select_game::build_driver_list() +void simple_menu_select_game::build_driver_list() { // start with an empty list m_drivlist = std::make_unique(machine().options()); @@ -93,13 +98,13 @@ void ui_simple_menu_select_game::build_driver_list() // handle - handle the game select menu //------------------------------------------------- -void ui_simple_menu_select_game::handle() +void simple_menu_select_game::handle() { // ignore pause keys by swallowing them before we process the menu machine().ui_input().pressed(IPT_UI_PAUSE); // process the menu - const ui_menu_event *menu_event = process(0); + const event *menu_event = process(0); if (menu_event != nullptr && menu_event->itemref != nullptr) { // reset the error on any future menu_event @@ -140,13 +145,13 @@ void ui_simple_menu_select_game::handle() // inkey_select //------------------------------------------------- -void ui_simple_menu_select_game::inkey_select(const ui_menu_event *menu_event) +void simple_menu_select_game::inkey_select(const event *menu_event) { const game_driver *driver = (const game_driver *)menu_event->itemref; // special case for configure inputs if ((FPTR)driver == 1) - ui_menu::stack_push(global_alloc_clear(ui(), container)); + menu::stack_push(ui(), container); // anything else is a driver else { @@ -161,13 +166,13 @@ void ui_simple_menu_select_game::inkey_select(const ui_menu_event *menu_event) { mame_machine_manager::instance()->schedule_new_driver(*driver); machine().schedule_hard_reset(); - ui_menu::stack_reset(machine()); + menu::stack_reset(machine()); } // otherwise, display an error else { - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); m_error = true; } } @@ -178,13 +183,13 @@ void ui_simple_menu_select_game::inkey_select(const ui_menu_event *menu_event) // inkey_cancel //------------------------------------------------- -void ui_simple_menu_select_game::inkey_cancel(const ui_menu_event *menu_event) +void simple_menu_select_game::inkey_cancel(const event *menu_event) { // escape pressed with non-empty text clears the text if (m_search[0] != 0) { m_search[0] = '\0'; - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); } } @@ -193,7 +198,7 @@ void ui_simple_menu_select_game::inkey_cancel(const ui_menu_event *menu_event) // inkey_special - typed characters append to the buffer //------------------------------------------------- -void ui_simple_menu_select_game::inkey_special(const ui_menu_event *menu_event) +void simple_menu_select_game::inkey_special(const event *menu_event) { // typed characters append to the buffer int buflen = strlen(m_search); @@ -203,7 +208,7 @@ void ui_simple_menu_select_game::inkey_special(const ui_menu_event *menu_event) { *(char *)utf8_previous_char(&m_search[buflen]) = 0; m_rerandomize = true; - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); } // if it's any other key and we're not maxed out, update @@ -211,7 +216,7 @@ void ui_simple_menu_select_game::inkey_special(const ui_menu_event *menu_event) { buflen += utf8_from_uchar(&m_search[buflen], ARRAY_LENGTH(m_search) - buflen, menu_event->unichar); m_search[buflen] = 0; - reset(UI_MENU_RESET_SELECT_FIRST); + reset(reset_options::SELECT_FIRST); } } @@ -220,7 +225,7 @@ void ui_simple_menu_select_game::inkey_special(const ui_menu_event *menu_event) // populate - populate the game select menu //------------------------------------------------- -void ui_simple_menu_select_game::populate() +void simple_menu_select_game::populate() { int matchcount; int curitem; @@ -238,7 +243,7 @@ void ui_simple_menu_select_game::populate() "the docs directory for information on configuring %2$s."), emulator_info::get_configname(), emulator_info::get_appname()); - item_append(txt.c_str(), nullptr, MENU_FLAG_MULTILINE | MENU_FLAG_REDTEXT, nullptr); + item_append(txt.c_str(), nullptr, FLAG_MULTILINE | FLAG_REDTEXT, nullptr); return; } @@ -255,14 +260,14 @@ void ui_simple_menu_select_game::populate() if (curmatch != -1) { int cloneof = m_drivlist->non_bios_clone(curmatch); - item_append(m_drivlist->driver(curmatch).name, m_drivlist->driver(curmatch).description, (cloneof == -1) ? 0 : MENU_FLAG_INVERT, (void *)&m_drivlist->driver(curmatch)); + item_append(m_drivlist->driver(curmatch).name, m_drivlist->driver(curmatch).description, (cloneof == -1) ? 0 : FLAG_INVERT, (void *)&m_drivlist->driver(curmatch)); } } // if we're forced into this, allow general input configuration as well - if (ui_menu::stack_has_special_main_menu()) + if (menu::stack_has_special_main_menu()) { - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); item_append(_("Configure Options"), nullptr, 0, (void *)1); skip_main_items = 1; } @@ -277,7 +282,7 @@ void ui_simple_menu_select_game::populate() // custom_render - perform our special rendering //------------------------------------------------- -void ui_simple_menu_select_game::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void simple_menu_select_game::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { const game_driver *driver; float width, maxwidth; @@ -425,18 +430,16 @@ void ui_simple_menu_select_game::custom_render(void *selectedref, float top, flo // select menu to be visible and inescapable //------------------------------------------------- -void ui_simple_menu_select_game::force_game_select(mame_ui_manager &mui, render_container *container) +void simple_menu_select_game::force_game_select(mame_ui_manager &mui, render_container *container) { char *gamename = (char *)mui.machine().options().system_name(); // reset the menu stack - ui_menu::stack_reset(mui.machine()); + menu::stack_reset(mui.machine()); // add the quit entry followed by the game select entry - ui_menu *quit = global_alloc_clear(mui, container); - quit->set_special_main_menu(true); - ui_menu::stack_push(quit); - ui_menu::stack_push(global_alloc_clear(mui, container, gamename)); + menu::stack_push_special_main(mui, container); + menu::stack_push(mui, container, gamename); // force the menus on mui.show_menu(); @@ -444,3 +447,5 @@ void ui_simple_menu_select_game::force_game_select(mame_ui_manager &mui, render_ // make sure MAME is paused mui.machine().pause(); } + +} // namespace ui diff --git a/src/frontend/mame/ui/simpleselgame.h b/src/frontend/mame/ui/simpleselgame.h index 7ab68394e95..707777937b4 100644 --- a/src/frontend/mame/ui/simpleselgame.h +++ b/src/frontend/mame/ui/simpleselgame.h @@ -10,17 +10,19 @@ #pragma once -#ifndef __UI_SIMPLESELGAME_H__ -#define __UI_SIMPLESELGAME_H__ +#ifndef MAME_FRONTEND_UI_SIMPLESELGAME_H +#define MAME_FRONTEND_UI_SIMPLESELGAME_H #include "menu.h" class driver_enumerator; -class ui_simple_menu_select_game : public ui_menu { +namespace ui { + +class simple_menu_select_game : public menu { public: - ui_simple_menu_select_game(mame_ui_manager &mui, render_container *container, const char *gamename); - virtual ~ui_simple_menu_select_game(); + simple_menu_select_game(mame_ui_manager &mui, render_container *container, const char *gamename); + virtual ~simple_menu_select_game(); virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -41,9 +43,11 @@ private: // internal methods void build_driver_list(); - void inkey_select(const ui_menu_event *menu_event); - void inkey_cancel(const ui_menu_event *menu_event); - void inkey_special(const ui_menu_event *menu_event); + void inkey_select(const event *menu_event); + void inkey_cancel(const event *menu_event); + void inkey_special(const event *menu_event); }; -#endif /* __UI_SELGAME_H__ */ +} // namespace ui + +#endif /* MAME_FRONTEND_UI_SIMPLESELGAME_H */ diff --git a/src/frontend/mame/ui/sliders.cpp b/src/frontend/mame/ui/sliders.cpp index 54121bcc400..920d2ede4b4 100644 --- a/src/frontend/mame/ui/sliders.cpp +++ b/src/frontend/mame/ui/sliders.cpp @@ -11,17 +11,19 @@ #include "emu.h" #include "osdepend.h" + #include "ui/ui.h" -#include "ui/menu.h" #include "ui/sliders.h" #include "ui/slider.h" -ui_menu_sliders::ui_menu_sliders(mame_ui_manager &mui, render_container *container, bool menuless_mode) : ui_menu(mui, container) +namespace ui { + +menu_sliders::menu_sliders(mame_ui_manager &mui, render_container *container, bool menuless_mode) : menu(mui, container) { m_menuless_mode = m_hidden = menuless_mode; } -ui_menu_sliders::~ui_menu_sliders() +menu_sliders::~menu_sliders() { } @@ -29,16 +31,16 @@ ui_menu_sliders::~ui_menu_sliders() menu_sliders - handle the sliders menu -------------------------------------------------*/ -void ui_menu_sliders::handle() +void menu_sliders::handle() { - const ui_menu_event *menu_event; + const event *menu_event; /* process the menu */ - menu_event = process(UI_MENU_PROCESS_LR_REPEAT | (m_hidden ? UI_MENU_PROCESS_CUSTOM_ONLY : 0)); + menu_event = process(PROCESS_LR_REPEAT | (m_hidden ? PROCESS_CUSTOM_ONLY : 0)); if (menu_event != nullptr) { /* handle keys if there is a valid item selected */ - if (menu_event->itemref != nullptr && menu_event->type == ui_menu_item_type::SLIDER) + if (menu_event->itemref != nullptr && menu_event->type == menu_item_type::SLIDER) { const slider_state *slider = (const slider_state *)menu_event->itemref; INT32 curvalue = (*slider->update)(machine(), slider->arg, slider->id, nullptr, SLIDER_NOCHANGE); @@ -52,7 +54,7 @@ void ui_menu_sliders::handle() /* toggle visibility */ case IPT_UI_ON_SCREEN_DISPLAY: if (m_menuless_mode) - ui_menu::stack_pop(machine()); + menu::stack_pop(machine()); else m_hidden = !m_hidden; break; @@ -104,7 +106,7 @@ void ui_menu_sliders::handle() /* update the slider and recompute the menu */ (*slider->update)(machine(), slider->arg, slider->id, nullptr, newvalue); - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); } } @@ -134,24 +136,24 @@ void ui_menu_sliders::handle() menu -------------------------------------------------*/ -void ui_menu_sliders::populate() +void menu_sliders::populate() { std::string tempstring; /* add UI sliders */ - std::vector ui_sliders = ui().get_slider_list(); - for (ui_menu_item item : ui_sliders) + std::vector ui_sliders = ui().get_slider_list(); + for (menu_item item : ui_sliders) { - if (item.type == ui_menu_item_type::SLIDER) + if (item.type == menu_item_type::SLIDER) { slider_state* slider = reinterpret_cast(item.ref); INT32 curval = (*slider->update)(machine(), slider->arg, slider->id, &tempstring, SLIDER_NOCHANGE); UINT32 flags = 0; if (curval > slider->minval) - flags |= MENU_FLAG_LEFT_ARROW; + flags |= FLAG_LEFT_ARROW; if (curval < slider->maxval) - flags |= MENU_FLAG_RIGHT_ARROW; - item_append(slider->description, tempstring.c_str(), flags, (void *)slider, ui_menu_item_type::SLIDER); + flags |= FLAG_RIGHT_ARROW; + item_append(slider->description, tempstring.c_str(), flags, (void *)slider, menu_item_type::SLIDER); } else { @@ -159,22 +161,22 @@ void ui_menu_sliders::populate() } } - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); /* add OSD options */ - std::vector osd_sliders = machine().osd().get_slider_list(); - for (ui_menu_item item : osd_sliders) + std::vector osd_sliders = machine().osd().get_slider_list(); + for (menu_item item : osd_sliders) { - if (item.type == ui_menu_item_type::SLIDER) + if (item.type == menu_item_type::SLIDER) { slider_state* slider = reinterpret_cast(item.ref); INT32 curval = (*slider->update)(machine(), slider->arg, slider->id, &tempstring, SLIDER_NOCHANGE); UINT32 flags = 0; if (curval > slider->minval) - flags |= MENU_FLAG_LEFT_ARROW; + flags |= FLAG_LEFT_ARROW; if (curval < slider->maxval) - flags |= MENU_FLAG_RIGHT_ARROW; - item_append(slider->description, tempstring.c_str(), flags, (void *)slider, ui_menu_item_type::SLIDER); + flags |= FLAG_RIGHT_ARROW; + item_append(slider->description, tempstring.c_str(), flags, (void *)slider, menu_item_type::SLIDER); } else { @@ -190,7 +192,7 @@ void ui_menu_sliders::populate() rendering -------------------------------------------------*/ -void ui_menu_sliders::custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) +void menu_sliders::custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) { const slider_state *curslider = (const slider_state *)selectedref; if (curslider != nullptr) @@ -257,26 +259,28 @@ void ui_menu_sliders::custom_render(void *selectedref, float top, float bottom, /*------------------------------------------------- - ui_slider_ui_handler - pushes the slider + slider_ui_handler - pushes the slider menu on the stack and hands off to the standard menu handler -------------------------------------------------*/ -UINT32 ui_menu_sliders::ui_handler(mame_ui_manager &mui, render_container *container, UINT32 state) +UINT32 menu_sliders::ui_handler(mame_ui_manager &mui, render_container *container, UINT32 state) { UINT32 result; /* if this is the first call, push the sliders menu */ if (state) - ui_menu::stack_push(global_alloc_clear(mui, container, true)); + menu::stack_push(mui, container, true); /* handle standard menus */ - result = ui_menu::ui_handler(mui, container, state); + result = menu::ui_handler(mui, container, state); /* if we are cancelled, pop the sliders menu */ if (result == UI_HANDLER_CANCEL) - ui_menu::stack_pop(mui.machine()); + menu::stack_pop(mui.machine()); - ui_menu_sliders *uim = dynamic_cast(menu_stack); + menu_sliders *uim = topmost_menu(); return uim && uim->m_menuless_mode ? 0 : UI_HANDLER_CANCEL; } + +} // namespace ui diff --git a/src/frontend/mame/ui/sliders.h b/src/frontend/mame/ui/sliders.h index eea36538384..6a7090058cc 100644 --- a/src/frontend/mame/ui/sliders.h +++ b/src/frontend/mame/ui/sliders.h @@ -10,15 +10,18 @@ #pragma once -#ifndef __UI_SLIDERS_H__ -#define __UI_SLIDERS_H__ +#ifndef MAME_FRONTEND_UI_SLIDERS_H +#define MAME_FRONTEND_UI_SLIDERS_H -#include +#include "ui/menu.h" -class ui_menu_sliders : public ui_menu { +namespace ui { + +class menu_sliders : public menu +{ public: - ui_menu_sliders(mame_ui_manager &mui, render_container *container, bool menuless_mode = false); - virtual ~ui_menu_sliders(); + menu_sliders(mame_ui_manager &mui, render_container *container, bool menuless_mode = false); + virtual ~menu_sliders() override; virtual void populate() override; virtual void handle() override; @@ -35,5 +38,6 @@ private: bool m_hidden; }; +} // namespace ui -#endif /* __UI_SLIDERS_H__ */ +#endif /* MAME_FRONTEND_UI_SLIDERS_H */ diff --git a/src/frontend/mame/ui/slotopt.cpp b/src/frontend/mame/ui/slotopt.cpp index 5908ffb4fa6..2da3a411599 100644 --- a/src/frontend/mame/ui/slotopt.cpp +++ b/src/frontend/mame/ui/slotopt.cpp @@ -9,18 +9,21 @@ *********************************************************************/ #include "emu.h" -#include "emuopts.h" -#include "mameopts.h" + #include "ui/ui.h" -#include "ui/menu.h" #include "ui/slotopt.h" #include "ui/devopt.h" +#include "emuopts.h" +#include "mameopts.h" + + +namespace ui { /*------------------------------------------------- - ui_slot_get_current_option - returns + slot_get_current_option - returns -------------------------------------------------*/ -device_slot_option *ui_menu_slot_devices::slot_get_current_option(device_slot_interface &slot) +device_slot_option *menu_slot_devices::slot_get_current_option(device_slot_interface &slot) { std::string current; if (slot.fixed()) @@ -37,9 +40,9 @@ device_slot_option *ui_menu_slot_devices::slot_get_current_option(device_slot_in } /*------------------------------------------------- - ui_slot_get_current_index - returns + slot_get_current_index - returns -------------------------------------------------*/ -int ui_menu_slot_devices::slot_get_current_index(device_slot_interface &slot) +int menu_slot_devices::slot_get_current_index(device_slot_interface &slot) { const device_slot_option *current = slot_get_current_option(slot); @@ -60,9 +63,9 @@ int ui_menu_slot_devices::slot_get_current_index(device_slot_interface &slot) } /*------------------------------------------------- - ui_slot_get_length - returns + slot_get_length - returns -------------------------------------------------*/ -int ui_menu_slot_devices::slot_get_length(device_slot_interface &slot) +int menu_slot_devices::slot_get_length(device_slot_interface &slot) { int val = 0; for (const device_slot_option &option : slot.option_list()) @@ -73,9 +76,9 @@ int ui_menu_slot_devices::slot_get_length(device_slot_interface &slot) } /*------------------------------------------------- - ui_slot_get_next - returns + slot_get_next - returns -------------------------------------------------*/ -const char *ui_menu_slot_devices::slot_get_next(device_slot_interface &slot) +const char *menu_slot_devices::slot_get_next(device_slot_interface &slot) { int idx = slot_get_current_index(slot); if (idx < 0) @@ -90,9 +93,9 @@ const char *ui_menu_slot_devices::slot_get_next(device_slot_interface &slot) } /*------------------------------------------------- - ui_slot_get_prev - returns + slot_get_prev - returns -------------------------------------------------*/ -const char *ui_menu_slot_devices::slot_get_prev(device_slot_interface &slot) +const char *menu_slot_devices::slot_get_prev(device_slot_interface &slot) { int idx = slot_get_current_index(slot); if (idx < 0) @@ -107,9 +110,9 @@ const char *ui_menu_slot_devices::slot_get_prev(device_slot_interface &slot) } /*------------------------------------------------- - ui_slot_get_option - returns + slot_get_option - returns -------------------------------------------------*/ -const char *ui_menu_slot_devices::slot_get_option(device_slot_interface &slot, int index) +const char *menu_slot_devices::slot_get_option(device_slot_interface &slot, int index) { if (index >= 0) { @@ -129,11 +132,11 @@ const char *ui_menu_slot_devices::slot_get_option(device_slot_interface &slot, i /*------------------------------------------------- - ui_set_use_natural_keyboard - specifies + set_use_natural_keyboard - specifies whether the natural keyboard is active -------------------------------------------------*/ -void ui_menu_slot_devices::set_slot_device(device_slot_interface &slot, const char *val) +void menu_slot_devices::set_slot_device(device_slot_interface &slot, const char *val) { std::string error; machine().options().set_value(slot.device().tag()+1, val, OPTION_PRIORITY_CMDLINE, error); @@ -145,11 +148,11 @@ void ui_menu_slot_devices::set_slot_device(device_slot_interface &slot, const ch slot device menu -------------------------------------------------*/ -ui_menu_slot_devices::ui_menu_slot_devices(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container) +menu_slot_devices::menu_slot_devices(mame_ui_manager &mui, render_container *container) : menu(mui, container) { } -void ui_menu_slot_devices::populate() +void menu_slot_devices::populate() { /* cycle through all devices for this system */ for (device_slot_interface &slot : slot_interface_iterator(machine().root_device())) @@ -166,24 +169,24 @@ void ui_menu_slot_devices::populate() opt_name.append(_(" [internal]")); } - item_append(slot.device().tag() + 1, opt_name.c_str(), (slot.fixed() || slot_get_length(slot) == 0) ? 0 : (MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW), (void *)&slot); + item_append(slot.device().tag() + 1, opt_name.c_str(), (slot.fixed() || slot_get_length(slot) == 0) ? 0 : (FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW), (void *)&slot); } - item_append(ui_menu_item_type::SEPARATOR); + item_append(menu_item_type::SEPARATOR); item_append(_("Reset"), nullptr, 0, (void *)1); } -ui_menu_slot_devices::~ui_menu_slot_devices() +menu_slot_devices::~menu_slot_devices() { } /*------------------------------------------------- - ui_menu_slot_devices - menu that + menu_slot_devices - menu that -------------------------------------------------*/ -void ui_menu_slot_devices::handle() +void menu_slot_devices::handle() { /* process the menu */ - const ui_menu_event *menu_event = process(0); + const event *menu_event = process(0); if (menu_event != nullptr && menu_event->itemref != nullptr) { @@ -197,14 +200,16 @@ void ui_menu_slot_devices::handle() device_slot_interface *slot = (device_slot_interface *)menu_event->itemref; const char *val = (menu_event->iptkey == IPT_UI_LEFT) ? slot_get_prev(*slot) : slot_get_next(*slot); set_slot_device(*slot, val); - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); } else if (menu_event->iptkey == IPT_UI_SELECT) { device_slot_interface *slot = (device_slot_interface *)menu_event->itemref; device_slot_option *option = slot_get_current_option(*slot); if (option) - ui_menu::stack_push(global_alloc_clear(ui(), container, slot, option)); + menu::stack_push(ui(), container, slot, option); } } } + +} // namespace ui diff --git a/src/frontend/mame/ui/slotopt.h b/src/frontend/mame/ui/slotopt.h index 190d310a49c..923c6131d5e 100644 --- a/src/frontend/mame/ui/slotopt.h +++ b/src/frontend/mame/ui/slotopt.h @@ -10,13 +10,19 @@ #pragma once -#ifndef __UI_SLOTOPT_H__ -#define __UI_SLOTOPT_H__ +#ifndef MAME_FRONTEND_UI_SLOTOPT_H +#define MAME_FRONTEND_UI_SLOTOPT_H -class ui_menu_slot_devices : public ui_menu { +#include "ui/menu.h" + + +namespace ui { + +class menu_slot_devices : public menu +{ public: - ui_menu_slot_devices(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_slot_devices(); + menu_slot_devices(mame_ui_manager &mui, render_container *container); + virtual ~menu_slot_devices() override; virtual void populate() override; virtual void handle() override; @@ -30,4 +36,6 @@ private: void set_slot_device(device_slot_interface &slot, const char *val); }; -#endif /* __UI_SLOTOPT_H__ */ +} // namespace ui + +#endif /* MAME_FRONTEND_UI_SLOTOPT_H */ diff --git a/src/frontend/mame/ui/sndmenu.cpp b/src/frontend/mame/ui/sndmenu.cpp index 79a654b29cf..486c3ad53a6 100644 --- a/src/frontend/mame/ui/sndmenu.cpp +++ b/src/frontend/mame/ui/sndmenu.cpp @@ -10,18 +10,19 @@ #include "emu.h" #include "ui/ui.h" -#include "ui/menu.h" #include "ui/sndmenu.h" #include "ui/selector.h" #include "../osd/modules/lib/osdobj_common.h" // TODO: remove -const int ui_menu_sound_options::m_sound_rate[] = { 11025, 22050, 44100, 48000 }; +namespace ui { + +const int menu_sound_options::m_sound_rate[] = { 11025, 22050, 44100, 48000 }; //------------------------------------------------- // ctor //------------------------------------------------- -ui_menu_sound_options::ui_menu_sound_options(mame_ui_manager &mui, render_container *container) : ui_menu(mui, container) +menu_sound_options::menu_sound_options(mame_ui_manager &mui, render_container *container) : menu(mui, container) { osd_options &options = downcast(mui.machine().options()); @@ -43,7 +44,7 @@ ui_menu_sound_options::ui_menu_sound_options(mame_ui_manager &mui, render_contai // dtor //------------------------------------------------- -ui_menu_sound_options::~ui_menu_sound_options() +menu_sound_options::~menu_sound_options() { std::string error_string; emu_options &moptions = machine().options(); @@ -69,54 +70,54 @@ ui_menu_sound_options::~ui_menu_sound_options() // handle //------------------------------------------------- -void ui_menu_sound_options::handle() +void menu_sound_options::handle() { bool changed = false; // process the menu - const ui_menu_event *m_event = process(0); + const event *menu_event = process(0); - if (m_event != nullptr && m_event->itemref != nullptr) + if (menu_event != nullptr && menu_event->itemref != nullptr) { - switch ((FPTR)m_event->itemref) + switch ((FPTR)menu_event->itemref) { - case ENABLE_SOUND: - if (m_event->iptkey == IPT_UI_LEFT || m_event->iptkey == IPT_UI_RIGHT || m_event->iptkey == IPT_UI_SELECT) - { - m_sound = !m_sound; - changed = true; - } - break; + case ENABLE_SOUND: + if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT || menu_event->iptkey == IPT_UI_SELECT) + { + m_sound = !m_sound; + changed = true; + } + break; - case SAMPLE_RATE: - if (m_event->iptkey == IPT_UI_LEFT || m_event->iptkey == IPT_UI_RIGHT) - { - (m_event->iptkey == IPT_UI_LEFT) ? m_cur_rates-- : m_cur_rates++; - changed = true; - } - else if (m_event->iptkey == IPT_UI_SELECT) - { - int total = ARRAY_LENGTH(m_sound_rate); - std::vector s_sel(total); - for (int index = 0; index < total; index++) - s_sel[index] = std::to_string(m_sound_rate[index]); + case SAMPLE_RATE: + if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) + { + (menu_event->iptkey == IPT_UI_LEFT) ? m_cur_rates-- : m_cur_rates++; + changed = true; + } + else if (menu_event->iptkey == IPT_UI_SELECT) + { + int total = ARRAY_LENGTH(m_sound_rate); + std::vector s_sel(total); + for (int index = 0; index < total; index++) + s_sel[index] = std::to_string(m_sound_rate[index]); - ui_menu::stack_push(global_alloc_clear(ui(), container, s_sel, m_cur_rates)); - } - break; + menu::stack_push(ui(), container, s_sel, m_cur_rates); + } + break; - case ENABLE_SAMPLES: - if (m_event->iptkey == IPT_UI_LEFT || m_event->iptkey == IPT_UI_RIGHT || m_event->iptkey == IPT_UI_SELECT) - { - m_samples = !m_samples; - changed = true; - } - break; + case ENABLE_SAMPLES: + if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT || menu_event->iptkey == IPT_UI_SELECT) + { + m_samples = !m_samples; + changed = true; + } + break; } } if (changed) - reset(UI_MENU_RESET_REMEMBER_REF); + reset(reset_options::REMEMBER_REF); } @@ -124,16 +125,16 @@ void ui_menu_sound_options::handle() // populate //------------------------------------------------- -void ui_menu_sound_options::populate() +void menu_sound_options::populate() { UINT32 arrow_flags = get_arrow_flags(0, ARRAY_LENGTH(m_sound_rate) - 1, m_cur_rates); m_sample_rate = m_sound_rate[m_cur_rates]; // add options items - item_append(_("Sound"), m_sound ? _("On") : _("Off"), m_sound ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)(FPTR)ENABLE_SOUND); + item_append(_("Sound"), m_sound ? _("On") : _("Off"), m_sound ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW, (void *)(FPTR)ENABLE_SOUND); item_append(_("Sample Rate"), string_format("%d", m_sample_rate).c_str(), arrow_flags, (void *)(FPTR)SAMPLE_RATE); - item_append(_("Use External Samples"), m_samples ? _("On") : _("Off"), m_samples ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)(FPTR)ENABLE_SAMPLES); - item_append(ui_menu_item_type::SEPARATOR); + item_append(_("Use External Samples"), m_samples ? _("On") : _("Off"), m_samples ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW, (void *)(FPTR)ENABLE_SAMPLES); + item_append(menu_item_type::SEPARATOR); customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER); } @@ -142,7 +143,7 @@ void ui_menu_sound_options::populate() // perform our special rendering //------------------------------------------------- -void ui_menu_sound_options::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +void menu_sound_options::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float width; ui().draw_text_full(container, _("Sound Options"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, @@ -168,3 +169,5 @@ void ui_menu_sound_options::custom_render(void *selectedref, float top, float bo ui().draw_text_full(container, _("Sound Options"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); } + +} // namespace ui diff --git a/src/frontend/mame/ui/sndmenu.h b/src/frontend/mame/ui/sndmenu.h index 8c6a2aef1eb..bc7fbeb21b8 100644 --- a/src/frontend/mame/ui/sndmenu.h +++ b/src/frontend/mame/ui/sndmenu.h @@ -10,17 +10,21 @@ #pragma once -#ifndef __UI_SNDMENU_H__ -#define __UI_SNDMENU_H__ +#ifndef MAME_FRONTEND_UI_SNDMENU_H +#define MAME_FRONTEND_UI_SNDMENU_H + +#include "ui/menu.h" + +namespace ui { //------------------------------------------------- // class sound options menu //------------------------------------------------- -class ui_menu_sound_options : public ui_menu +class menu_sound_options : public menu { public: - ui_menu_sound_options(mame_ui_manager &mui, render_container *container); - virtual ~ui_menu_sound_options(); + menu_sound_options(mame_ui_manager &mui, render_container *container); + virtual ~menu_sound_options() override; virtual void populate() override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; @@ -39,4 +43,6 @@ private: bool m_samples, m_sound; }; -#endif /* __UI_SNDMENU_H__ */ +} // namespace ui + +#endif /* MAME_FRONTEND_UI_SNDMENU_H */ diff --git a/src/frontend/mame/ui/submenu.cpp b/src/frontend/mame/ui/submenu.cpp index c70d56b0f2c..2d93b7cc4f0 100644 --- a/src/frontend/mame/ui/submenu.cpp +++ b/src/frontend/mame/ui/submenu.cpp @@ -13,14 +13,118 @@ #include "ui/submenu.h" #include "ui/utils.h" #include "ui/menuitem.h" + #include +namespace ui { + +std::vector submenu::misc_options = { + { submenu::option_type::HEAD, __("Miscellaneous Options") }, + { submenu::option_type::UI, __("Re-select last machine played"), OPTION_REMEMBER_LAST }, + { submenu::option_type::UI, __("Enlarge images in the right panel"), OPTION_ENLARGE_SNAPS }, + { submenu::option_type::UI, __("DATs info"), OPTION_DATS_ENABLED }, + { submenu::option_type::EMU, __("Cheats"), OPTION_CHEAT }, + { submenu::option_type::EMU, __("Show mouse pointer"), OPTION_UI_MOUSE }, + { submenu::option_type::EMU, __("Confirm quit from machines"), OPTION_CONFIRM_QUIT }, + { submenu::option_type::EMU, __("Skip information screen at startup"), OPTION_SKIP_GAMEINFO }, + { submenu::option_type::UI, __("Force 4:3 aspect for snapshot display"), OPTION_FORCED4X3 }, + { submenu::option_type::UI, __("Use image as background"), OPTION_USE_BACKGROUND }, + { submenu::option_type::UI, __("Skip bios selection menu"), OPTION_SKIP_BIOS_MENU }, + { submenu::option_type::UI, __("Skip software parts selection menu"), OPTION_SKIP_PARTS_MENU }, + { submenu::option_type::UI, __("Info auto audit"), OPTION_INFO_AUTO_AUDIT }, +}; + +std::vector submenu::advanced_options = { + { submenu::option_type::HEAD, __("Advanced Options") }, + { submenu::option_type::HEAD, __("Performance Options") }, + { submenu::option_type::EMU, __("Auto frame skip"), OPTION_AUTOFRAMESKIP }, + { submenu::option_type::EMU, __("Frame skip"), OPTION_FRAMESKIP }, + { submenu::option_type::EMU, __("Throttle"), OPTION_THROTTLE }, + { submenu::option_type::EMU, __("Sleep"), OPTION_SLEEP }, + { submenu::option_type::EMU, __("Speed"), OPTION_SPEED }, + { submenu::option_type::EMU, __("Refresh speed"), OPTION_REFRESHSPEED }, + + { submenu::option_type::HEAD, __("Rotation Options") }, + { submenu::option_type::EMU, __("Rotate"), OPTION_ROTATE }, + { submenu::option_type::EMU, __("Rotate right"), OPTION_ROR }, + { submenu::option_type::EMU, __("Rotate left"), OPTION_ROL }, + { submenu::option_type::EMU, __("Auto rotate right"), OPTION_AUTOROR }, + { submenu::option_type::EMU, __("Auto rotate left"), OPTION_AUTOROL }, + { submenu::option_type::EMU, __("Flip X"), OPTION_FLIPX }, + { submenu::option_type::EMU, __("Flip Y"), OPTION_FLIPY }, + + { submenu::option_type::HEAD, __("Artwork Options") }, + { submenu::option_type::EMU, __("Artwork Crop"), OPTION_ARTWORK_CROP }, + { submenu::option_type::EMU, __("Use Backdrops"), OPTION_USE_BACKDROPS }, + { submenu::option_type::EMU, __("Use Overlays"), OPTION_USE_OVERLAYS }, + { submenu::option_type::EMU, __("Use Bezels"), OPTION_USE_BEZELS }, + { submenu::option_type::EMU, __("Use Control Panels"), OPTION_USE_CPANELS }, + { submenu::option_type::EMU, __("Use Marquees"), OPTION_USE_MARQUEES }, + + { submenu::option_type::HEAD, __("State/Playback Options") }, + { submenu::option_type::EMU, __("Automatic save/restore"), OPTION_AUTOSAVE }, + { submenu::option_type::EMU, __("Bilinear snapshot"), OPTION_SNAPBILINEAR }, + { submenu::option_type::EMU, __("Burn-in"), OPTION_BURNIN }, + + { submenu::option_type::HEAD, __("Input Options") }, + { submenu::option_type::EMU, __("Coin lockout"), OPTION_COIN_LOCKOUT }, + { submenu::option_type::EMU, __("Mouse"), OPTION_MOUSE }, + { submenu::option_type::EMU, __("Joystick"), OPTION_JOYSTICK }, + { submenu::option_type::EMU, __("Lightgun"), OPTION_LIGHTGUN }, + { submenu::option_type::EMU, __("Multi-keyboard"), OPTION_MULTIKEYBOARD }, + { submenu::option_type::EMU, __("Multi-mouse"), OPTION_MULTIMOUSE }, + { submenu::option_type::EMU, __("Steadykey"), OPTION_STEADYKEY }, + { submenu::option_type::EMU, __("UI active"), OPTION_UI_ACTIVE }, + { submenu::option_type::EMU, __("Offscreen reload"), OPTION_OFFSCREEN_RELOAD }, + { submenu::option_type::EMU, __("Joystick deadzone"), OPTION_JOYSTICK_DEADZONE }, + { submenu::option_type::EMU, __("Joystick saturation"), OPTION_JOYSTICK_SATURATION }, + { submenu::option_type::EMU, __("Natural keyboard"), OPTION_NATURAL_KEYBOARD }, + { submenu::option_type::EMU, __("Simultaneous contradictory"), OPTION_JOYSTICK_CONTRADICTORY }, + { submenu::option_type::EMU, __("Coin impulse"), OPTION_COIN_IMPULSE }, +}; + +std::vector submenu::control_options = { + { submenu::option_type::HEAD, __("Device Mapping") }, + { submenu::option_type::EMU, __("Lightgun Device Assignment"), OPTION_LIGHTGUN_DEVICE }, + { submenu::option_type::EMU, __("Trackball Device Assignment"), OPTION_TRACKBALL_DEVICE }, + { submenu::option_type::EMU, __("Pedal Device Assignment"), OPTION_PEDAL_DEVICE }, + { submenu::option_type::EMU, __("Adstick Device Assignment"), OPTION_ADSTICK_DEVICE }, + { submenu::option_type::EMU, __("Paddle Device Assignment"), OPTION_PADDLE_DEVICE }, + { submenu::option_type::EMU, __("Dial Device Assignment"), OPTION_DIAL_DEVICE }, + { submenu::option_type::EMU, __("Positional Device Assignment"), OPTION_POSITIONAL_DEVICE }, + { submenu::option_type::EMU, __("Mouse Device Assignment"), OPTION_MOUSE_DEVICE } +}; + +std::vector submenu::video_options = { + { submenu::option_type::HEAD, __("Video Options") }, + { submenu::option_type::OSD, __("Video Mode"), OSDOPTION_VIDEO }, + { submenu::option_type::OSD, __("Number Of Screens"), OSDOPTION_NUMSCREENS }, +#if defined(UI_WINDOWS) && !defined(UI_SDL) + { submenu::option_type::OSD, __("Triple Buffering"), WINOPTION_TRIPLEBUFFER }, + { submenu::option_type::OSD, __("HLSL"), WINOPTION_HLSL_ENABLE }, +#endif + { submenu::option_type::OSD, __("GLSL"), OSDOPTION_GL_GLSL }, + { submenu::option_type::OSD, __("Bilinear Filtering"), OSDOPTION_FILTER }, + { submenu::option_type::OSD, __("Bitmap Prescaling"), OSDOPTION_PRESCALE }, + { submenu::option_type::OSD, __("Window Mode"), OSDOPTION_WINDOW }, + { submenu::option_type::EMU, __("Enforce Aspect Ratio"), OPTION_KEEPASPECT }, + { submenu::option_type::OSD, __("Start Out Maximized"), OSDOPTION_MAXIMIZE }, + { submenu::option_type::OSD, __("Synchronized Refresh"), OSDOPTION_SYNCREFRESH }, + { submenu::option_type::OSD, __("Wait Vertical Sync"), OSDOPTION_WAITVSYNC } +}; + +//std::vector submenu::export_options = { +// { ui_submenu::option_type::COMMAND, __("Export XML format (like -listxml)"), "exportxml" }, +// { ui_submenu::option_type::COMMAND, __("Export TXT format (like -listfull)"), "exporttxt" }, +//}; + + //------------------------------------------------- // ctor / dtor //------------------------------------------------- -ui_submenu::ui_submenu(mame_ui_manager &mui, render_container *container, std::vector &suboptions, const game_driver *drv, emu_options *options) - : ui_menu(mui, container) +submenu::submenu(mame_ui_manager &mui, render_container *container, std::vector