diff options
author | 2016-07-10 02:42:38 +1000 | |
---|---|---|
committer | 2016-07-10 03:01:13 +1000 | |
commit | 1abf53ca6a7a01ae2d4491825a97b0a4baef634a (patch) | |
tree | 2a061c81dab912dbf52f8cdd54f97507820029dd /src/frontend/mame/ui/selgame.cpp | |
parent | 2364b48f0dd496de3908fa4d3bcd24693a5f6231 (diff) |
UI code refactoring: [Vas Crabb]
* Split out main menu and dat box drawing from base class
* Make a bunch of class statics proper per-machine persistent objects
* Object lifecycle fixes
Diffstat (limited to 'src/frontend/mame/ui/selgame.cpp')
-rw-r--r-- | src/frontend/mame/ui/selgame.cpp | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/src/frontend/mame/ui/selgame.cpp b/src/frontend/mame/ui/selgame.cpp index 992cab5c758..6f451a3018e 100644 --- a/src/frontend/mame/ui/selgame.cpp +++ b/src/frontend/mame/ui/selgame.cpp @@ -55,7 +55,8 @@ int menu_select_game::m_isabios = 0; // ctor //------------------------------------------------- -menu_select_game::menu_select_game(mame_ui_manager &mui, render_container *container, const char *gamename) : menu(mui, container) +menu_select_game::menu_select_game(mame_ui_manager &mui, render_container *container, const char *gamename) + : menu_select_launch(mui, container, false) { set_focus(focused_menu::main); highlight = 0; @@ -184,7 +185,7 @@ void menu_select_game::handle() { ui_globals::reset = false; machine().schedule_hard_reset(); - menu::stack_reset(machine()); + stack_reset(); return; } @@ -203,10 +204,10 @@ void menu_select_game::handle() const event *menu_event = process(PROCESS_LR_REPEAT); if (menu_event && menu_event->itemref) { - if (ui_error) + if (m_ui_error) { // reset the error on any future menu_event - ui_error = false; + m_ui_error = false; machine().ui_input().reset(); } else if (menu_event->iptkey == IPT_UI_SELECT) @@ -257,7 +258,7 @@ void menu_select_game::handle() if ((FPTR)drv > skip_main_items && ui_globals::curdats_view > UI_FIRST_LOAD) { ui_globals::curdats_view--; - topline_datsview = 0; + m_topline_datsview = 0; } } else @@ -266,12 +267,12 @@ void menu_select_game::handle() if (drv->startempty == 1 && ui_globals::curdats_view > UI_FIRST_LOAD) { ui_globals::curdats_view--; - topline_datsview = 0; + m_topline_datsview = 0; } else if ((FPTR)drv > skip_main_items && ui_globals::cur_sw_dats_view > 0) { ui_globals::cur_sw_dats_view--; - topline_datsview = 0; + m_topline_datsview = 0; } } } @@ -295,7 +296,7 @@ void menu_select_game::handle() if ((FPTR)drv > skip_main_items && ui_globals::curdats_view < UI_LAST_LOAD) { ui_globals::curdats_view++; - topline_datsview = 0; + m_topline_datsview = 0; } } else @@ -304,12 +305,12 @@ void menu_select_game::handle() if (drv->startempty == 1 && ui_globals::curdats_view < UI_LAST_LOAD) { ui_globals::curdats_view++; - topline_datsview = 0; + m_topline_datsview = 0; } else if ((FPTR)drv > skip_main_items && ui_globals::cur_sw_dats_view < 1) { ui_globals::cur_sw_dats_view++; - topline_datsview = 0; + m_topline_datsview = 0; } } } @@ -457,7 +458,7 @@ void menu_select_game::handle() } // if we're in an error state, overlay an error message - if (ui_error) + if (m_ui_error) ui().draw_text_box(container, _("The selected machine is missing one or more required ROM or CHD images. " "Please select a different machine.\n\nPress any key to continue."), ui::text_layout::CENTER, 0.5f, 0.5f, UI_RED_COLOR); @@ -497,7 +498,7 @@ void menu_select_game::populate() ui_globals::redraw_icon = true; ui_globals::switch_image = true; int old_item_selected = -1; - UINT32 flags_ui = FLAG_UI | FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW; + UINT32 flags_ui = FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW; if (!isfavorite()) { @@ -588,7 +589,7 @@ void menu_select_game::populate() item_append(menu_item_type::SEPARATOR, flags_ui); // add special items - if (menu::stack_has_special_main_menu()) + if (stack_has_special_main_menu()) { item_append(_("Configure Options"), "", flags_ui, (void *)(FPTR)CONF_OPTS); item_append(_("Configure Machine"), "", flags_ui, (void *)(FPTR)CONF_MACHINE); @@ -1064,14 +1065,14 @@ void menu_select_game::inkey_select(const event *menu_event) reselect_last::swlist.clear(); mame_machine_manager::instance()->schedule_new_driver(*driver); machine().schedule_hard_reset(); - menu::stack_reset(machine()); + stack_reset(); } } // otherwise, display an error else { reset(reset_options::REMEMBER_REF); - ui_error = true; + m_ui_error = true; } } } @@ -1125,7 +1126,7 @@ void menu_select_game::inkey_select_favorite(const event *menu_event) reselect_last::set(true); mame_machine_manager::instance()->schedule_new_driver(*ui_swinfo->driver); machine().schedule_hard_reset(); - menu::stack_reset(machine()); + stack_reset(); } } @@ -1133,7 +1134,7 @@ void menu_select_game::inkey_select_favorite(const event *menu_event) else { reset(reset_options::REMEMBER_REF); - ui_error = true; + m_ui_error = true; } } else @@ -1182,14 +1183,14 @@ void menu_select_game::inkey_select_favorite(const event *menu_event) reselect_last::swlist = ui_swinfo->listname; mame_machine_manager::instance()->schedule_new_driver(drv.driver()); machine().schedule_hard_reset(); - menu::stack_reset(machine()); + stack_reset(); } // otherwise, display an error else { reset(reset_options::REMEMBER_POSITION); - ui_error = true; + m_ui_error = true; } } } @@ -1531,7 +1532,7 @@ void menu_select_game::populate_search() } (index < VISIBLE_GAMES_IN_SEARCH) ? m_searchlist[index] = nullptr : m_searchlist[VISIBLE_GAMES_IN_SEARCH] = nullptr; - UINT32 flags_ui = FLAG_UI | FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW; + UINT32 flags_ui = FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW; for (int curitem = 0; m_searchlist[curitem]; ++curitem) { bool cloneof = strcmp(m_searchlist[curitem]->parent, "0"); @@ -2040,8 +2041,8 @@ void menu_select_game::infos_render(void *selectedref, float origx1, float origy buffer.clear(); olddriver = driver; oldview = ui_globals::curdats_view; - topline_datsview = 0; - totallines = 0; + m_topline_datsview = 0; + m_total_lines = 0; std::vector<std::string> m_item; if (ui_globals::curdats_view == UI_GENERAL_LOAD) @@ -2072,29 +2073,29 @@ void menu_select_game::infos_render(void *selectedref, float origx1, float origy return; } else if (ui_globals::curdats_view != UI_STORY_LOAD && ui_globals::curdats_view != UI_COMMAND_LOAD) - totallines = ui().wrap_text(container, buffer.c_str(), origx1, origy1, origx2 - origx1 - (2.0f * gutter_width), xstart, xend, text_size); + m_total_lines = ui().wrap_text(container, buffer.c_str(), origx1, origy1, origx2 - origx1 - (2.0f * gutter_width), xstart, xend, text_size); else - totallines = ui().wrap_text(container, buffer.c_str(), 0.0f, 0.0f, 1.0f - (2.0f * gutter_width), xstart, xend, text_size); + m_total_lines = ui().wrap_text(container, buffer.c_str(), 0.0f, 0.0f, 1.0f - (2.0f * gutter_width), xstart, xend, text_size); int r_visible_lines = floor((origy2 - oy1) / (line_height * text_size)); - if (totallines < r_visible_lines) - r_visible_lines = totallines; - if (topline_datsview < 0) - topline_datsview = 0; - if (topline_datsview + r_visible_lines >= totallines) - topline_datsview = totallines - r_visible_lines; + if (m_total_lines < r_visible_lines) + r_visible_lines = m_total_lines; + if (m_topline_datsview < 0) + m_topline_datsview = 0; + if (m_topline_datsview + r_visible_lines >= m_total_lines) + m_topline_datsview = m_total_lines - r_visible_lines; sc = origx2 - origx1 - (2.0f * UI_BOX_LR_BORDER); for (int r = 0; r < r_visible_lines; ++r) { - int itemline = r + topline_datsview; + int itemline = r + m_topline_datsview; std::string tempbuf(buffer.substr(xstart[itemline], xend[itemline] - xstart[itemline])); // up arrow - if (r == 0 && topline_datsview != 0) + if (r == 0 && m_topline_datsview != 0) info_arrow(0, origx1, origx2, oy1, line_height, text_size, ud_arrow_width); // bottom arrow - else if (r == r_visible_lines - 1 && itemline != totallines - 1) + else if (r == r_visible_lines - 1 && itemline != m_total_lines - 1) info_arrow(1, origx1, origx2, oy1, line_height, text_size, ud_arrow_width); // special case for mamescore else if (ui_globals::curdats_view == UI_STORY_LOAD) @@ -2159,7 +2160,7 @@ void menu_select_game::infos_render(void *selectedref, float origx1, float origy } // return the number of visible lines, minus 1 for top arrow and 1 for bottom arrow - right_visible_lines = r_visible_lines - (topline_datsview != 0) - (topline_datsview + r_visible_lines != totallines); + right_visible_lines = r_visible_lines - (m_topline_datsview != 0) - (m_topline_datsview + r_visible_lines != m_total_lines); } else if (soft) { @@ -2233,26 +2234,26 @@ void menu_select_game::infos_render(void *selectedref, float origx1, float origy return; } else - totallines = ui().wrap_text(container, buffer.c_str(), origx1, origy1, origx2 - origx1 - (2.0f * gutter_width), xstart, xend, text_size); + m_total_lines = ui().wrap_text(container, buffer.c_str(), origx1, origy1, origx2 - origx1 - (2.0f * gutter_width), xstart, xend, text_size); int r_visible_lines = floor((origy2 - oy1) / (line_height * text_size)); - if (totallines < r_visible_lines) - r_visible_lines = totallines; - if (topline_datsview < 0) - topline_datsview = 0; - if (topline_datsview + r_visible_lines >= totallines) - topline_datsview = totallines - r_visible_lines; + if (m_total_lines < r_visible_lines) + r_visible_lines = m_total_lines; + if (m_topline_datsview < 0) + m_topline_datsview = 0; + if (m_topline_datsview + r_visible_lines >= m_total_lines) + m_topline_datsview = m_total_lines - r_visible_lines; for (int r = 0; r < r_visible_lines; ++r) { - int itemline = r + topline_datsview; + int itemline = r + m_topline_datsview; std::string tempbuf(buffer.substr(xstart[itemline], xend[itemline] - xstart[itemline])); // up arrow - if (r == 0 && topline_datsview != 0) + if (r == 0 && m_topline_datsview != 0) info_arrow(0, origx1, origx2, oy1, line_height, text_size, ud_arrow_width); // bottom arrow - else if (r == r_visible_lines - 1 && itemline != totallines - 1) + else if (r == r_visible_lines - 1 && itemline != m_total_lines - 1) info_arrow(1, origx1, origx2, oy1, line_height, text_size, ud_arrow_width); else ui().draw_text_full(container, tempbuf.c_str(), origx1 + gutter_width, oy1, origx2 - origx1, ui::text_layout::LEFT, @@ -2261,7 +2262,7 @@ void menu_select_game::infos_render(void *selectedref, float origx1, float origy } // return the number of visible lines, minus 1 for top arrow and 1 for bottom arrow - right_visible_lines = r_visible_lines - (topline_datsview != 0) - (topline_datsview + r_visible_lines != totallines); + right_visible_lines = r_visible_lines - (m_topline_datsview != 0) - (m_topline_datsview + r_visible_lines != m_total_lines); } } |