diff options
-rw-r--r-- | src/emu/emuopts.cpp | 4 | ||||
-rw-r--r-- | src/emu/emuopts.h | 2 | ||||
-rw-r--r-- | src/emu/ui/menu.cpp | 336 | ||||
-rw-r--r-- | src/emu/ui/menu.h | 9 | ||||
-rw-r--r-- | src/emu/ui/miscmenu.cpp | 161 | ||||
-rw-r--r-- | src/emu/ui/miscmenu.h | 41 | ||||
-rw-r--r-- | src/emu/ui/selgame.cpp | 20 | ||||
-rw-r--r-- | src/emu/ui/selgame.h | 2 | ||||
-rw-r--r-- | src/emu/ui/submenu.cpp | 25 | ||||
-rw-r--r-- | src/emu/ui/submenu.h | 6 | ||||
-rw-r--r-- | src/emu/uiinput.cpp | 30 | ||||
-rw-r--r-- | src/emu/uiinput.h | 4 | ||||
-rw-r--r-- | src/osd/modules/input/input_sdl.cpp | 21 | ||||
-rw-r--r-- | src/osd/windows/window.cpp | 8 |
14 files changed, 453 insertions, 216 deletions
diff --git a/src/emu/emuopts.cpp b/src/emu/emuopts.cpp index b3de757e453..d23a03ac479 100644 --- a/src/emu/emuopts.cpp +++ b/src/emu/emuopts.cpp @@ -451,7 +451,7 @@ bool emu_options::parse_command_line(int argc, char *argv[], std::string &error_ // of INI files //------------------------------------------------- -void emu_options::parse_standard_inis(std::string &error_string) +void emu_options::parse_standard_inis(std::string &error_string, const game_driver *driver) { // start with an empty string error_string.clear(); @@ -466,7 +466,7 @@ void emu_options::parse_standard_inis(std::string &error_string) parse_one_ini("debug", OPTION_PRIORITY_DEBUG_INI, &error_string); // if we have a valid system driver, parse system-specific INI files - const game_driver *cursystem = system(); + const game_driver *cursystem = (driver == nullptr) ? system() : driver; if (cursystem == nullptr) return; diff --git a/src/emu/emuopts.h b/src/emu/emuopts.h index 522f128961e..a0e20153241 100644 --- a/src/emu/emuopts.h +++ b/src/emu/emuopts.h @@ -229,7 +229,7 @@ public: // parsing wrappers bool parse_command_line(int argc, char *argv[], std::string &error_string); - void parse_standard_inis(std::string &error_string); + void parse_standard_inis(std::string &error_string, const game_driver *driver = nullptr); bool parse_slot_devices(int argc, char *argv[], std::string &error_string, const char *name = nullptr, const char *value = nullptr, const software_part *swpart = nullptr); // core options diff --git a/src/emu/ui/menu.cpp b/src/emu/ui/menu.cpp index 52c2eba048a..08cb46a703e 100644 --- a/src/emu/ui/menu.cpp +++ b/src/emu/ui/menu.cpp @@ -24,6 +24,7 @@ #include "ui/custmenu.h" #include "ui/icorender.h" #include "ui/toolbar.h" +#include "ui/miscmenu.h" /*************************************************************************** @@ -358,26 +359,25 @@ 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) +const ui_menu_event *ui_menu::process(UINT32 flags, float x0, float y0) { // reset the menu_event menu_event.iptkey = IPT_INVALID; // first make sure our selection is valid -// if (!(flags & UI_MENU_PROCESS_NOINPUT)) - validate_selection(1); + validate_selection(1); // draw the menu if (item.size() > 1 && (item[0].flags & MENU_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 & 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) draw_palette_menu(); else if ((item[0].flags & MENU_FLAG_UI_DATS) != 0) draw_dats_menu(); else - draw(flags & UI_MENU_PROCESS_CUSTOM_ONLY, flags & UI_MENU_PROCESS_NOIMAGE, flags & UI_MENU_PROCESS_NOINPUT); + draw(flags, x0, y0); // process input if (!(flags & UI_MENU_PROCESS_NOKEYS) && !(flags & UI_MENU_PROCESS_NOINPUT)) @@ -489,15 +489,18 @@ void ui_menu::set_selection(void *selected_itemref) // draw - draw a menu //------------------------------------------------- -void ui_menu::draw(bool customonly, bool noimage, bool noinput) +void ui_menu::draw(UINT32 flags, float origx0, float origy0) { // first draw the FPS counter if (machine().ui().show_fps_counter()) { machine().ui().draw_text_full(container, machine().video().speed_text().c_str(), 0.0f, 0.0f, 1.0f, - JUSTIFY_RIGHT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, nullptr, nullptr); + JUSTIFY_RIGHT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_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); float line_height = machine().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(); @@ -557,6 +560,38 @@ void ui_menu::draw(bool customonly, bool noimage, bool noinput) float visible_left = (1.0f - visible_width) * 0.5f; float visible_top = (1.0f - (visible_main_menu_height + visible_extra_menu_height)) * 0.5f; +/* float visible_left; + float visible_top; + if (origx0 == 0.0f && origy0 == 0.0f) + { + visible_left = (1.0f - visible_width) * 0.5f; + visible_top = (1.0f - (visible_main_menu_height + visible_extra_menu_height)) * 0.5f; + } + else + { + INT32 mouse_target_x, mouse_target_y; + float m_x, m_y; + render_target *mouse_target = machine().ui_input().find_mouse(&mouse_target_x, &mouse_target_y, &mouse_button); + if (mouse_target != nullptr) + { + if (mouse_target->map_point_container(origx0, origy0, *container, m_x, m_y)) + { + visible_left = m_x; + visible_top = m_y; + } + else + { + visible_left = (1.0f - visible_width) * 0.5f; + visible_top = (1.0f - (visible_main_menu_height + visible_extra_menu_height)) * 0.5f; + } + } + else + { + visible_left = (1.0f - visible_width) * 0.5f; + visible_top = (1.0f - (visible_main_menu_height + visible_extra_menu_height)) * 0.5f; + } + } +*/ // if the menu is at the bottom of the extra, adjust visible_top += customtop; @@ -1427,8 +1462,9 @@ void ui_menu::init_ui(running_machine &machine) // draw main menu //------------------------------------------------- -void ui_menu::draw_select_game(bool noinput) +void ui_menu::draw_select_game(UINT32 flags) { + bool noinput = (flags & UI_MENU_PROCESS_NOINPUT); float line_height = machine().ui().get_line_height(); float ud_arrow_width = line_height * machine().render().ui_aspect(); float gutter_width = 0.52f * ud_arrow_width; @@ -1965,160 +2001,176 @@ void ui_menu::handle_main_events(UINT32 flags) switch (local_menu_event.event_type) { // if we are hovering over a valid item, select it with a single click - case UI_EVENT_MOUSE_DOWN: - { - if (ui_error) - { - menu_event.iptkey = IPT_OTHER; - stop = true; - } - else + case UI_EVENT_MOUSE_DOWN: { - if (hover >= 0 && hover < item.size()) - { - if (hover >= visible_items - 1 && selected < visible_items) - m_prev_selected = item[selected].ref; - selected = hover; - m_focus = focused_menu::main; - } - else if (hover == HOVER_ARROW_UP) - { - selected -= visitems; - if (selected < 0) - selected = 0; - top_line -= visitems - (top_line + visible_lines == visible_items); - set_pressed(); - } - else if (hover == HOVER_ARROW_DOWN) - { - selected += visible_lines - 2 + (selected == 0); - if (selected >= visible_items) - selected = visible_items - 1; - top_line += visible_lines - 2; - set_pressed(); - } - else if (hover == HOVER_UI_RIGHT) - menu_event.iptkey = IPT_UI_RIGHT; - else if (hover == HOVER_UI_LEFT) - menu_event.iptkey = IPT_UI_LEFT; - else if (hover == HOVER_DAT_DOWN) - topline_datsview += right_visible_lines - 1; - else if (hover == HOVER_DAT_UP) - topline_datsview -= right_visible_lines - 1; - else if (hover == HOVER_LPANEL_ARROW) + if (ui_error) { - if (ui_globals::panels_status == HIDE_LEFT_PANEL) - ui_globals::panels_status = SHOW_PANELS; - else if (ui_globals::panels_status == HIDE_BOTH) - ui_globals::panels_status = HIDE_RIGHT_PANEL; - else if (ui_globals::panels_status == SHOW_PANELS) - ui_globals::panels_status = HIDE_LEFT_PANEL; - else if (ui_globals::panels_status == HIDE_RIGHT_PANEL) - ui_globals::panels_status = HIDE_BOTH; + menu_event.iptkey = IPT_OTHER; + stop = true; } - else if (hover == HOVER_RPANEL_ARROW) + else { - if (ui_globals::panels_status == HIDE_RIGHT_PANEL) - ui_globals::panels_status = SHOW_PANELS; - else if (ui_globals::panels_status == HIDE_BOTH) - ui_globals::panels_status = HIDE_LEFT_PANEL; - else if (ui_globals::panels_status == SHOW_PANELS) - ui_globals::panels_status = HIDE_RIGHT_PANEL; - else if (ui_globals::panels_status == HIDE_LEFT_PANEL) - ui_globals::panels_status = HIDE_BOTH; + if (hover >= 0 && hover < item.size()) + { + if (hover >= visible_items - 1 && selected < visible_items) + m_prev_selected = item[selected].ref; + selected = hover; + m_focus = focused_menu::main; + } + else if (hover == HOVER_ARROW_UP) + { + selected -= visitems; + if (selected < 0) + selected = 0; + top_line -= visitems - (top_line + visible_lines == visible_items); + set_pressed(); + } + else if (hover == HOVER_ARROW_DOWN) + { + selected += visible_lines - 2 + (selected == 0); + if (selected >= visible_items) + selected = visible_items - 1; + top_line += visible_lines - 2; + set_pressed(); + } + else if (hover == HOVER_UI_RIGHT) + menu_event.iptkey = IPT_UI_RIGHT; + else if (hover == HOVER_UI_LEFT) + menu_event.iptkey = IPT_UI_LEFT; + else if (hover == HOVER_DAT_DOWN) + topline_datsview += right_visible_lines - 1; + else if (hover == HOVER_DAT_UP) + topline_datsview -= right_visible_lines - 1; + else if (hover == HOVER_LPANEL_ARROW) + { + if (ui_globals::panels_status == HIDE_LEFT_PANEL) + ui_globals::panels_status = SHOW_PANELS; + else if (ui_globals::panels_status == HIDE_BOTH) + ui_globals::panels_status = HIDE_RIGHT_PANEL; + else if (ui_globals::panels_status == SHOW_PANELS) + ui_globals::panels_status = HIDE_LEFT_PANEL; + else if (ui_globals::panels_status == HIDE_RIGHT_PANEL) + ui_globals::panels_status = HIDE_BOTH; + } + else if (hover == HOVER_RPANEL_ARROW) + { + if (ui_globals::panels_status == HIDE_RIGHT_PANEL) + ui_globals::panels_status = SHOW_PANELS; + else if (ui_globals::panels_status == HIDE_BOTH) + ui_globals::panels_status = HIDE_LEFT_PANEL; + else if (ui_globals::panels_status == SHOW_PANELS) + ui_globals::panels_status = HIDE_RIGHT_PANEL; + else if (ui_globals::panels_status == HIDE_LEFT_PANEL) + ui_globals::panels_status = HIDE_BOTH; + } + else if (hover == HOVER_B_FAV) + { + menu_event.iptkey = IPT_UI_FAVORITES; + stop = true; + } + else if (hover == HOVER_B_EXPORT) + { + menu_event.iptkey = IPT_UI_EXPORT; + stop = true; + } + else if (hover == HOVER_B_DATS) + { + menu_event.iptkey = IPT_UI_DATS; + stop = true; + } + else if (hover >= HOVER_RP_FIRST && hover <= HOVER_RP_LAST) + { + ui_globals::rpanel = (HOVER_RP_FIRST - hover) * (-1); + stop = true; + } + 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; + stop = true; + } + else if (hover >= HOVER_FILTER_FIRST && hover <= HOVER_FILTER_LAST) + { + l_hover = (HOVER_FILTER_FIRST - hover) * (-1); + menu_event.iptkey = IPT_OTHER; + stop = true; + } } - else if (hover == HOVER_B_FAV) + break; + } + + // if we are hovering over a valid item, fake a UI_SELECT with a double-click + case UI_EVENT_MOUSE_DOUBLE_CLICK: + if (hover >= 0 && hover < item.size()) { - menu_event.iptkey = IPT_UI_FAVORITES; - stop = true; + selected = hover; + menu_event.iptkey = IPT_UI_SELECT; } - else if (hover == HOVER_B_EXPORT) + + if (selected == item.size() - 1) { - menu_event.iptkey = IPT_UI_EXPORT; - stop = true; + menu_event.iptkey = IPT_UI_CANCEL; + ui_menu::stack_pop(machine()); } - else if (hover == HOVER_B_DATS) + stop = true; + break; + + // caught scroll event + case UI_EVENT_MOUSE_WHEEL: + if (hover >= 0 && hover < item.size() - skip_main_items - 1) { - menu_event.iptkey = IPT_UI_DATS; - stop = true; + if (local_menu_event.zdelta > 0) + { + if (selected >= visible_items || selected == 0 || ui_error) + break; + selected -= local_menu_event.num_lines; + if (selected < top_line + (top_line != 0)) + top_line -= local_menu_event.num_lines; + } + else + { + if (selected >= visible_items - 1 || ui_error) + break; + selected += local_menu_event.num_lines; + if (selected > visible_items - 1) + selected = visible_items - 1; + if (selected >= top_line + visitems + (top_line != 0)) + top_line += local_menu_event.num_lines; + } } - else if (hover >= HOVER_RP_FIRST && hover <= HOVER_RP_LAST) + break; + + // translate CHAR events into specials + case UI_EVENT_CHAR: + if (exclusive_input_pressed(IPT_UI_CONFIGURE, 0)) { - ui_globals::rpanel = (HOVER_RP_FIRST - hover) * (-1); + menu_event.iptkey = IPT_UI_CONFIGURE; stop = true; } - else if (hover >= HOVER_SW_FILTER_FIRST && hover <= HOVER_SW_FILTER_LAST) + else { - l_sw_hover = (HOVER_SW_FILTER_FIRST - hover) * (-1); - menu_event.iptkey = IPT_OTHER; + menu_event.iptkey = IPT_SPECIAL; + menu_event.unichar = local_menu_event.ch; stop = true; } - else if (hover >= HOVER_FILTER_FIRST && hover <= HOVER_FILTER_LAST) + break; + + case UI_EVENT_MOUSE_RDOWN: + if (hover >= 0 && hover < item.size() - skip_main_items - 1) { - l_hover = (HOVER_FILTER_FIRST - hover) * (-1); - menu_event.iptkey = IPT_OTHER; + 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; stop = true; } - } - break; - } - - // if we are hovering over a valid item, fake a UI_SELECT with a double-click - case UI_EVENT_MOUSE_DOUBLE_CLICK: - if (hover >= 0 && hover < item.size()) - { - selected = hover; - menu_event.iptkey = IPT_UI_SELECT; - } - - if (selected == item.size() - 1) - { - menu_event.iptkey = IPT_UI_CANCEL; - ui_menu::stack_pop(machine()); - } - stop = true; - break; - - // caught scroll event - case UI_EVENT_MOUSE_WHEEL: - if (local_menu_event.zdelta > 0) - { - if (selected >= visible_items || selected == 0 || ui_error) - break; - selected -= local_menu_event.num_lines; - if (selected < top_line + (top_line != 0)) - top_line -= local_menu_event.num_lines; - } - else - { - if (selected >= visible_items - 1 || ui_error) - break; - selected += local_menu_event.num_lines; - if (selected > visible_items - 1) - selected = visible_items - 1; - if (selected >= top_line + visitems + (top_line != 0)) - top_line += local_menu_event.num_lines; - } - break; - - // translate CHAR events into specials - case UI_EVENT_CHAR: - if (exclusive_input_pressed(IPT_UI_CONFIGURE, 0)) - { - menu_event.iptkey = IPT_UI_CONFIGURE; - stop = true; - } - else - { - menu_event.iptkey = IPT_SPECIAL; - menu_event.unichar = local_menu_event.ch; - stop = true; - } - break; + break; // ignore everything else - default: - break; + default: + break; } } } diff --git a/src/emu/ui/menu.h b/src/emu/ui/menu.h index 7c8aa73a1d8..2b79990f2b8 100644 --- a/src/emu/ui/menu.h +++ b/src/emu/ui/menu.h @@ -70,9 +70,10 @@ enum class ui_menu_item_type 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*) + 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 @@ -125,7 +126,7 @@ public: 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); + const ui_menu_event *process(UINT32 flags, float x0 = 0.0f, float y0 = 0.0f); // configure the menu for custom rendering virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2); @@ -194,7 +195,7 @@ private: bool m_special_main_menu; running_machine &m_machine; // machine we are attached to - void draw(bool customonly, bool noimage, bool noinput); + void draw(UINT32 flags, float x0 = 0.0f, float y0 = 0.0f); void draw_text_box(); void handle_events(UINT32 flags); void handle_keys(UINT32 flags); @@ -296,7 +297,7 @@ private: static render_texture *toolbar_texture[], *sw_toolbar_texture[]; // draw game list - void draw_select_game(bool noinput); + void draw_select_game(UINT32 flags); // draw palette menu void draw_palette_menu(); diff --git a/src/emu/ui/miscmenu.cpp b/src/emu/ui/miscmenu.cpp index 69f36b6cfda..3ae58da9aa4 100644 --- a/src/emu/ui/miscmenu.cpp +++ b/src/emu/ui/miscmenu.cpp @@ -17,6 +17,8 @@ #include "ui/miscmenu.h" #include "ui/utils.h" #include "../info.h" +#include "ui/inifile.h" +#include "ui/submenu.h" /*************************************************************************** MENU HANDLERS @@ -86,7 +88,7 @@ void ui_menu_bios_selection::populate() } } - item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); + item_append(ui_menu_item_type::SEPARATOR); item_append(_("Reset"), nullptr, 0, (void *)1); } @@ -579,6 +581,7 @@ void ui_menu_export::handle() switch ((FPTR)m_event->itemref) { case 1: + case 3: { if (m_event->iptkey == IPT_UI_SELECT) { @@ -611,7 +614,7 @@ void ui_menu_export::handle() drvlist.include(driver_list::find(*elem)); info_xml_creator creator(drvlist); - creator.output(pfile, false); + creator.output(pfile, ((FPTR)m_event->itemref == 1) ? false : true); fclose(pfile); machine().popmessage(_("%s.xml saved under ui folder."), filename.c_str()); } @@ -671,18 +674,28 @@ void ui_menu_export::handle() void ui_menu_export::populate() { // add options items - item_append(_("Export XML format (like -listxml)"), nullptr, 0, (void *)(FPTR)1); - item_append(_("Export TXT format (like -listfull)"), nullptr, 0, (void *)(FPTR)2); - item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); + 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); } //------------------------------------------------- // ctor / dtor //------------------------------------------------- -ui_menu_machine_configure::ui_menu_machine_configure(running_machine &machine, render_container *container, const game_driver *prev) - : ui_menu(machine, container), m_drv(prev) +ui_menu_machine_configure::ui_menu_machine_configure(running_machine &machine, render_container *container, const game_driver *prev, float _x0, float _y0) + : ui_menu(machine, container) + , m_drv(prev) + , m_opts(machine.options()) + , x0(_x0) + , y0(_y0) + , m_curbios(0) { + // parse the INI file + std::string error; + m_opts.parse_standard_inis(error, m_drv); + setup_bios(); } ui_menu_machine_configure::~ui_menu_machine_configure() @@ -697,28 +710,54 @@ void ui_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); + const ui_menu_event *m_event = process(UI_MENU_PROCESS_NOIMAGE, x0, y0); if (m_event != nullptr && m_event->itemref != nullptr) { - switch ((FPTR)m_event->itemref) + if (m_event->iptkey == IPT_UI_SELECT) { - case 1: + switch ((FPTR)m_event->itemref) { - if (m_event->iptkey == IPT_UI_SELECT) + case SAVE: { std::string filename(m_drv->name); emu_file file(machine().options().ini_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE); osd_file::error filerr = file.open(filename.c_str(), ".ini"); if (filerr == osd_file::error::NONE) { - std::string inistring = machine().options().output_ini(); + std::string inistring = m_opts.output_ini(); file.puts(inistring.c_str()); + machine().ui().popup_time(2, "%s", _("\n Configuration saved \n\n")); } + break; } - break; + case ADDFAV: + machine().favorite().add_favorite_game(m_drv); + reset(UI_MENU_RESET_REMEMBER_POSITION); + break; + + case DELFAV: + machine().favorite().remove_favorite_game(); + reset(UI_MENU_RESET_REMEMBER_POSITION); + break; + case CONTROLLER: + if (m_event->iptkey == IPT_UI_SELECT) + ui_menu::stack_push(global_alloc_clear<ui_submenu>(machine(), container, control_submenu_options, m_drv, &m_opts)); + break; + case VIDEO: + if (m_event->iptkey == IPT_UI_SELECT) + ui_menu::stack_push(global_alloc_clear<ui_submenu>(machine(), container, video_submenu_options, m_drv, &m_opts)); + break; + default: + break; } - default: - break; + } + else if (m_event->iptkey == IPT_UI_LEFT || m_event->iptkey == IPT_UI_RIGHT) + { + (m_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); } } } @@ -730,11 +769,27 @@ void ui_menu_machine_configure::handle() void ui_menu_machine_configure::populate() { // add options items - item_append(_("Dummy"), nullptr, 0, (void *)(FPTR)10); - item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); - item_append(_("Save machine configuration"), nullptr, 0, (void *)(FPTR)1); - item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); - customtop = machine().ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER); + if (!m_bios.empty()) + { + item_append(_("Bios"), nullptr, MENU_FLAG_DISABLE | MENU_FLAG_UI_HEADING, nullptr); + 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); + } + + item_append(ui_menu_item_type::SEPARATOR); + 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); + + if (!machine().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(_("Save machine configuration"), nullptr, 0, (void *)(FPTR)SAVE); + item_append(ui_menu_item_type::SEPARATOR); + customtop = 2.0f * machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } //------------------------------------------------- @@ -745,14 +800,23 @@ void ui_menu_machine_configure::custom_render(void *selectedref, float top, floa { float width; ui_manager &mui = machine().ui(); + std::string text[2]; + float maxwidth = origx2 - origx1; - mui.draw_text_full(container, m_drv->description, 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, - DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr); - width += 2 * UI_BOX_LR_BORDER; - float maxwidth = MAX(origx2 - origx1, width); + text[0] = _("Configure machine:"); + text[1] = m_drv->description; + + for (auto & elem : text) + { + mui.draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, + DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr); + width += 2 * UI_BOX_LR_BORDER; + maxwidth = MAX(maxwidth, width); + } // compute our bounds float x1 = 0.5f - 0.5f * maxwidth; +// float x1 = origx1; float x2 = x1 + maxwidth; float y1 = origy1 - top; float y2 = origy1 - UI_BOX_TB_BORDER; @@ -766,8 +830,51 @@ void ui_menu_machine_configure::custom_render(void *selectedref, float top, floa y1 += UI_BOX_TB_BORDER; // draw the text within it - mui.draw_text_full(container, m_drv->description, x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, - DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); + for (auto & elem : text) + { + mui.draw_text_full(container, elem.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, + DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); + y1 += mui.get_line_height(); + } +} + +void ui_menu_machine_configure::setup_bios() +{ + if (m_drv->rom == nullptr) + return; + + std::string specbios(m_opts.bios()); + std::string default_name; + for (const rom_entry *rom = m_drv->rom; !ROMENTRY_ISEND(rom); ++rom) + if (ROMENTRY_ISDEFAULT_BIOS(rom)) + default_name = ROM_GETNAME(rom); + + int bios_count = 0; + for (const rom_entry *rom = m_drv->rom; !ROMENTRY_ISEND(rom); ++rom) + { + if (ROMENTRY_ISSYSTEM_BIOS(rom)) + { + std::string name(ROM_GETHASHDATA(rom)); + std::string biosname(ROM_GETNAME(rom)); + int bios_flags = ROM_GETBIOSFLAGS(rom); + std::string bios_number = std::to_string(bios_flags - 1); + + // check biosnumber and name + if (bios_number == specbios || biosname == specbios) + m_curbios = bios_count; + + if (biosname == default_name) + { + name.append(_(" (default)")); + if (specbios == "default") + m_curbios = bios_count; + } + + m_bios.emplace_back(name, bios_flags - 1); + bios_count++; + } + } + } //------------------------------------------------- @@ -830,7 +937,7 @@ void ui_menu_plugins_configure::populate() enabled ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)(FPTR)curentry.name()); } } - item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); + item_append(ui_menu_item_type::SEPARATOR); customtop = machine().ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER); } diff --git a/src/emu/ui/miscmenu.h b/src/emu/ui/miscmenu.h index 00a7ccf4edc..c8881cbaf8d 100644 --- a/src/emu/ui/miscmenu.h +++ b/src/emu/ui/miscmenu.h @@ -15,6 +15,8 @@ #include "drivenum.h" #include "crsshair.h" +#include "emuopts.h" +#include "ui/selsoft.h" class ui_menu_keyboard_mode : public ui_menu { public: @@ -85,28 +87,6 @@ public: virtual void handle() override; }; -//------------------------------------------------- -// class miscellaneous options menu -//------------------------------------------------- -class ui_menu_misc_options : public ui_menu -{ -public: - ui_menu_misc_options(running_machine &machine, render_container *container); - virtual ~ui_menu_misc_options(); - 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: - struct misc_option - { - bool status; - const char *description; - const char *option; - }; - - static misc_option m_options[]; -}; //------------------------------------------------- // export menu @@ -131,14 +111,29 @@ private: class ui_menu_machine_configure : public ui_menu { public: - ui_menu_machine_configure(running_machine &machine, render_container *container, const game_driver *prev); + ui_menu_machine_configure(running_machine &machine, render_container *container, const game_driver *prev, float x0 = 0.0f, float y0 = 0.0f); virtual ~ui_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: + enum + { + ADDFAV = 1, + DELFAV, + SAVE, + CONTROLLER, + VIDEO, + BIOS, + LAST = BIOS + }; const game_driver *m_drv; + emu_options m_opts; + float x0, y0; + s_bios m_bios; + int m_curbios; + void setup_bios(); }; //------------------------------------------------- diff --git a/src/emu/ui/selgame.cpp b/src/emu/ui/selgame.cpp index daaa072f9ef..a0c7f02fead 100644 --- a/src/emu/ui/selgame.cpp +++ b/src/emu/ui/selgame.cpp @@ -228,6 +228,13 @@ void ui_menu_select_game::handle() } } + // handle IPT_CUSTOM (mouse right click) + else if (m_event->iptkey == IPT_CUSTOM) + { + if (!isfavorite()) + ui_menu::stack_push(global_alloc_clear<ui_menu_machine_configure>(machine(), container, (const game_driver *)m_prev_selected, m_event->mouse.x0, m_event->mouse.y0)); + } + // handle UI_LEFT else if (m_event->iptkey == IPT_UI_LEFT) { @@ -425,8 +432,9 @@ void ui_menu_select_game::handle() inkey_special(m_event); else if (m_event->iptkey == IPT_UI_CONFIGURE) inkey_configure(m_event); - else if (m_event->iptkey == IPT_UI_SELECT && m_focus == focused_menu::left) + else if (m_event->iptkey == IPT_OTHER) { + m_focus = focused_menu::left; m_prev_selected = nullptr; l_hover = highlight; check_filter = true; @@ -585,8 +593,8 @@ void ui_menu_select_game::populate() { UINT32 flags_ui = MENU_FLAG_UI | MENU_FLAG_LEFT_ARROW | MENU_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); TODO - skip_main_items = 1; + item_append(_("Configure Machine"), nullptr, flags_ui, (void *)(FPTR)CONF_MACHINE); + skip_main_items = 2; if (machine().options().plugins()) { item_append(_("Plugins"), nullptr, flags_ui, (void *)(FPTR)CONF_PLUGINS); @@ -1011,14 +1019,16 @@ void ui_menu_select_game::inkey_select(const ui_menu_event *m_event) // special case for configure options if ((FPTR)driver == CONF_OPTS) ui_menu::stack_push(global_alloc_clear<ui_menu_game_options>(machine(), container)); - /* special case for configure machine TODO + + // special case for configure machine else if ((FPTR)driver == CONF_MACHINE) { if (m_prev_selected != nullptr) ui_menu::stack_push(global_alloc_clear<ui_menu_machine_configure>(machine(), container, (const game_driver *)m_prev_selected)); else return; - } */ + } + // special case for configure plugins else if ((FPTR)driver == CONF_PLUGINS) { diff --git a/src/emu/ui/selgame.h b/src/emu/ui/selgame.h index 11dee880927..06401d3523d 100644 --- a/src/emu/ui/selgame.h +++ b/src/emu/ui/selgame.h @@ -40,7 +40,7 @@ private: enum { CONF_OPTS = 1, -// CONF_MACHINE, + CONF_MACHINE, CONF_PLUGINS, }; diff --git a/src/emu/ui/submenu.cpp b/src/emu/ui/submenu.cpp index a06d75adb83..ae85db7d7a8 100644 --- a/src/emu/ui/submenu.cpp +++ b/src/emu/ui/submenu.cpp @@ -19,17 +19,24 @@ // ctor / dtor //------------------------------------------------- -ui_submenu::ui_submenu(running_machine &machine, render_container *container, std::vector<ui_submenu::option> &suboptions) - : ui_menu(machine, container), - m_options(suboptions) +ui_submenu::ui_submenu(running_machine &machine, render_container *container, std::vector<ui_submenu::option> &suboptions, const game_driver *drv, emu_options *options) + : ui_menu(machine, container) + , m_options(suboptions) + , m_driver(drv) { + core_options *opts = nullptr; + if (m_driver == nullptr) + opts = dynamic_cast<core_options*>(&machine.options()); + else + opts = dynamic_cast<core_options*>(options); + for (auto & sm_option : m_options) { switch (sm_option.type) { case ui_submenu::EMU: - sm_option.entry = machine.options().get_entry(sm_option.name); - sm_option.options = dynamic_cast<core_options*>(&machine.options()); + sm_option.entry = opts->get_entry(sm_option.name); + sm_option.options = opts; if (sm_option.entry->type() == OPTION_STRING) { sm_option.value.clear(); @@ -52,8 +59,8 @@ ui_submenu::ui_submenu(running_machine &machine, render_container *container, st } break; case ui_submenu::OSD: - sm_option.entry = machine.options().get_entry(sm_option.name); - sm_option.options = dynamic_cast<core_options*>(&machine.options()); + sm_option.entry = opts->get_entry(sm_option.name); + sm_option.options = opts; if (sm_option.entry->type() == OPTION_STRING) { sm_option.value.clear(); @@ -208,7 +215,7 @@ void ui_submenu::populate() item_append(_(sm_option->description), nullptr, MENU_FLAG_DISABLE | MENU_FLAG_UI_HEADING, nullptr); break; case ui_submenu::SEP: - item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); + item_append(ui_menu_item_type::SEPARATOR); break; case ui_submenu::CMD: item_append(_(sm_option->description), nullptr, 0, static_cast<void*>(&(*sm_option))); @@ -292,7 +299,7 @@ void ui_submenu::populate() } } - item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); + item_append(ui_menu_item_type::SEPARATOR); custombottom = customtop = machine().ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER); } diff --git a/src/emu/ui/submenu.h b/src/emu/ui/submenu.h index 3e25ba18c94..8168ab4bb7a 100644 --- a/src/emu/ui/submenu.h +++ b/src/emu/ui/submenu.h @@ -46,7 +46,7 @@ public: std::vector<std::string> value; }; - ui_submenu(running_machine &machine, render_container *container, std::vector<ui_submenu::option> &suboptions); + ui_submenu(running_machine &machine, render_container *container, std::vector<ui_submenu::option> &suboptions, const game_driver *drv = nullptr, emu_options *options = nullptr); virtual ~ui_submenu(); virtual void populate() override; virtual void handle() override; @@ -54,6 +54,7 @@ public: private: std::vector<option> &m_options; + const game_driver *m_driver; }; static std::vector<ui_submenu::option> misc_submenu_options = { @@ -134,8 +135,9 @@ static std::vector<ui_submenu::option> control_submenu_options = { }; static std::vector<ui_submenu::option> video_submenu_options = { - { ui_submenu::HEAD, __("Display Options") }, + { ui_submenu::HEAD, __("Video Options") }, { ui_submenu::OSD, __("Video Mode"), OSDOPTION_VIDEO }, + { ui_submenu::OSD, __("Number Of Screens"), OSDOPTION_NUMSCREENS }, #if defined(UI_WINDOWS) && !defined(UI_SDL) { ui_submenu::OSD, __("Triple Buffering"), WINOPTION_TRIPLEBUFFER }, { ui_submenu::OSD, __("HLSL"), WINOPTION_HLSL_ENABLE }, diff --git a/src/emu/uiinput.cpp b/src/emu/uiinput.cpp index 1b65388bc14..8d710ebcbfc 100644 --- a/src/emu/uiinput.cpp +++ b/src/emu/uiinput.cpp @@ -298,6 +298,36 @@ void ui_input_manager::push_mouse_up_event(render_target* target, INT32 x, INT32 } /*------------------------------------------------- +push_mouse_down_event - pushes a mouse +down event to the specified render_target +-------------------------------------------------*/ + +void ui_input_manager::push_mouse_rdown_event(render_target* target, INT32 x, INT32 y) +{ + ui_event event = { UI_EVENT_NONE }; + event.event_type = UI_EVENT_MOUSE_RDOWN; + event.target = target; + event.mouse_x = x; + event.mouse_y = y; + push_event(event); +} + +/*------------------------------------------------- +push_mouse_down_event - pushes a mouse +down event to the specified render_target +-------------------------------------------------*/ + +void ui_input_manager::push_mouse_rup_event(render_target* target, INT32 x, INT32 y) +{ + ui_event event = { UI_EVENT_NONE }; + event.event_type = UI_EVENT_MOUSE_RUP; + event.target = target; + event.mouse_x = x; + event.mouse_y = y; + push_event(event); +} + +/*------------------------------------------------- push_mouse_double_click_event - pushes a mouse double-click event to the specified render_target diff --git a/src/emu/uiinput.h b/src/emu/uiinput.h index fecc61c0c1a..2bd715e01aa 100644 --- a/src/emu/uiinput.h +++ b/src/emu/uiinput.h @@ -32,6 +32,8 @@ enum ui_event_type UI_EVENT_MOUSE_LEAVE, UI_EVENT_MOUSE_DOWN, UI_EVENT_MOUSE_UP, + UI_EVENT_MOUSE_RDOWN, + UI_EVENT_MOUSE_RUP, UI_EVENT_MOUSE_DOUBLE_CLICK, UI_EVENT_MOUSE_WHEEL, UI_EVENT_CHAR @@ -86,6 +88,8 @@ public: void push_mouse_leave_event(render_target* target); void push_mouse_down_event(render_target* target, INT32 x, INT32 y); void push_mouse_up_event(render_target* target, INT32 x, INT32 y); + void push_mouse_rdown_event(render_target* target, INT32 x, INT32 y); + void push_mouse_rup_event(render_target* target, INT32 x, INT32 y); void push_mouse_double_click_event(render_target* target, INT32 x, INT32 y); void push_char_event(render_target* target, unicode_char ch); void push_mouse_wheel_event(render_target *target, INT32 x, INT32 y, short delta, int ucNumLines); diff --git a/src/osd/modules/input/input_sdl.cpp b/src/osd/modules/input/input_sdl.cpp index 06096a6961b..8814cfe3876 100644 --- a/src/osd/modules/input/input_sdl.cpp +++ b/src/osd/modules/input/input_sdl.cpp @@ -248,6 +248,17 @@ public: } } } + + else if (sdlevent.button.button == 3) + { + int cx, cy; + sdl_window_info *window = GET_FOCUS_WINDOW(&sdlevent.button); + + if (window != NULL && window->xy_to_render_target(sdlevent.button.x, sdlevent.button.y, &cx, &cy)) + { + machine().ui_input().push_mouse_rdown_event(window->target(), cx, cy); + } + } break; case SDL_MOUSEBUTTONUP: @@ -264,6 +275,16 @@ public: machine().ui_input().push_mouse_up_event(window->target(), cx, cy); } } + else if (sdlevent.button.button == 3) + { + int cx, cy; + sdl_window_info *window = GET_FOCUS_WINDOW(&sdlevent.button); + + if (window != NULL && window->xy_to_render_target(sdlevent.button.x, sdlevent.button.y, &cx, &cy)) + { + machine().ui_input().push_mouse_rup_event(window->target(), cx, cy); + } + } break; case SDL_MOUSEWHEEL: diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp index 0e30da1b93d..faf16c9e4b8 100644 --- a/src/osd/windows/window.cpp +++ b/src/osd/windows/window.cpp @@ -1372,6 +1372,14 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR window->machine().ui_input().push_mouse_up_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); break; + case WM_RBUTTONDOWN: + window->machine().ui_input().push_mouse_rdown_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); + break; + + case WM_RBUTTONUP: + window->machine().ui_input().push_mouse_rup_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); + break; + case WM_CHAR: window->machine().ui_input().push_char_event(window->m_target, (unicode_char) wparam); break; |