diff options
Diffstat (limited to 'src/emu/ui/menu.cpp')
-rw-r--r-- | src/emu/ui/menu.cpp | 75 |
1 files changed, 41 insertions, 34 deletions
diff --git a/src/emu/ui/menu.cpp b/src/emu/ui/menu.cpp index f831ffa725f..3803790c359 100644 --- a/src/emu/ui/menu.cpp +++ b/src/emu/ui/menu.cpp @@ -59,12 +59,12 @@ static const ui_arts_info arts_info[] = { nullptr } }; -static const char *hover_msg[] = { - "Add or remove favorites", - "Export displayed list to file", - "Show DATs view", - "Setup directories", - "Configure options" +static const char *hover_msg[] = { + "Add or remove favorites", + "Export displayed list to file", + "Show DATs view", + "Setup directories", + "Configure options" }; /*************************************************************************** @@ -249,7 +249,7 @@ void ui_menu::reset(ui_menu_reset_options options) visitems = 0; selected = 0; std::string backtext; - strprintf(backtext, "Return to %s", emulator_info::get_capstartgamenoun()); + strprintf(backtext, "Return to Machine"); // add an item to return if (parent == nullptr) @@ -460,6 +460,13 @@ void ui_menu::set_selection(void *selected_itemref) void ui_menu::draw(bool customonly, bool noimage, bool noinput) { + // 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); + } + 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(); @@ -530,6 +537,8 @@ void ui_menu::draw(bool customonly, bool noimage, bool noinput) machine().ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR); // determine the first visible line based on the current selection + if (selected > top_line + visible_lines) + top_line = selected - (visible_lines / 2); if (top_line < 0 || selected == 0) top_line = 0; if (top_line + visible_lines >= item.size()) @@ -1251,7 +1260,7 @@ void ui_menu::render_triangle(bitmap_argb32 &dest, bitmap_argb32 &source, const void ui_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)); + container->add_quad(x0, y0, x1, y1, bgcolor, hilight_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE) | PRIMFLAG_PACKABLE); } @@ -1261,7 +1270,7 @@ void ui_menu::highlight(render_container *container, float x0, float y0, float x void ui_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)); + container->add_quad(x0, y0, x1, y1, fgcolor, arrow_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXORIENT(orientation) | PRIMFLAG_PACKABLE); } //------------------------------------------------- @@ -1302,7 +1311,7 @@ void ui_menu::init_ui(running_machine &machine) star_texture = mrender.texture_alloc(); star_texture->set_bitmap(*star_bitmap, star_bitmap->cliprect(), TEXFORMAT_ARGB32); - // allocates icons bitmap and texture + // allocate icons for (int i = 0; i < MAX_ICONS_RENDER; i++) { icons_bitmap[i] = auto_alloc(machine, bitmap_argb32); @@ -1343,7 +1352,7 @@ void ui_menu::init_ui(running_machine &machine) toolbar_texture[x]->set_bitmap(*toolbar_bitmap[x], toolbar_bitmap[x]->cliprect(), TEXFORMAT_ARGB32); else toolbar_bitmap[x]->reset(); - + if (x == 0 || x == 2) { dst = &sw_toolbar_bitmap[x]->pix32(0); @@ -1383,8 +1392,8 @@ void ui_menu::draw_select_game(bool noinput) container->add_quad(0.0f, 0.0f, 1.0f, 1.0f, ARGB_WHITE, bgrnd_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); hover = item.size() + 1; - visible_items = (is_swlist) ? item.size() - 2 : item.size() - 5; - float extra_height = (is_swlist) ? 2.0f * line_height : 5.0f * line_height; + visible_items = (is_swlist) ? item.size() - 2 : item.size() - 2 - skip_main_items; + float extra_height = (is_swlist) ? 2.0f * line_height : (2.0f + skip_main_items) * line_height; float visible_extra_menu_height = customtop + custombottom + extra_height; // locate mouse @@ -1480,7 +1489,7 @@ void ui_menu::draw_select_game(bool noinput) // if we have some background hilighting to do, add a quad behind everything else if (bgcolor != UI_TEXT_BG_COLOR) - mui.draw_textured_box(container, line_x0 + 0.01f, line_y0, line_x1 - 0.01f, line_y1, bgcolor, rgb_t(255, 43, 43, 43), + mui.draw_textured_box(container, line_x0 + 0.01f, line_y0, line_x1 - 0.01f, line_y1, bgcolor, rgb_t(255, 43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE)); // if we're on the top line, display the up arrow @@ -1511,7 +1520,7 @@ void ui_menu::draw_select_game(bool noinput) int item_invert = pitem.flags & MENU_FLAG_INVERT; float space = 0.0f; - if (!is_swlist) + if (ui_globals::has_icons && !is_swlist) { if (is_favorites) { @@ -1524,7 +1533,7 @@ void ui_menu::draw_select_game(bool noinput) space = mui.get_line_height() * container->manager().ui_aspect() * 1.5f; } - mui.draw_text_full(container, itemtext, effective_left + space, line_y, effective_width - space, JUSTIFY_LEFT, WRAP_TRUNCATE, + mui.draw_text_full(container, itemtext, effective_left + space, line_y, effective_width - space, JUSTIFY_LEFT, WRAP_TRUNCATE, DRAW_NORMAL, item_invert ? fgcolor3 : fgcolor, bgcolor, nullptr, nullptr); } else @@ -1584,7 +1593,7 @@ void ui_menu::draw_select_game(bool noinput) container->add_line(visible_left, line + 0.5f * line_height, visible_left + visible_width, line + 0.5f * line_height, UI_LINE_WIDTH, UI_TEXT_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); else - mui.draw_text_full(container, itemtext, effective_left, line, effective_width, JUSTIFY_CENTER, WRAP_TRUNCATE, + mui.draw_text_full(container, itemtext, effective_left, line, effective_width, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr); line += line_height; } @@ -2109,7 +2118,7 @@ void ui_menu::draw_star(float x0, float y0) { float y1 = y0 + machine().ui().get_line_height(); float x1 = x0 + machine().ui().get_line_height() * container->manager().ui_aspect(); - container->add_quad(x0, y0, x1, y1, ARGB_WHITE, star_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); + container->add_quad(x0, y0, x1, y1, ARGB_WHITE, star_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_PACKABLE); } //------------------------------------------------- @@ -2174,7 +2183,6 @@ void ui_menu::arts_render_images(bitmap_argb32 *tmp_bitmap, float origx1, float // if it fails, use the default image if (!tmp_bitmap->valid()) { - //tmp_bitmap->reset(); tmp_bitmap->allocate(256, 256); for (int x = 0; x < 256; x++) for (int y = 0; y < 256; y++) @@ -2219,11 +2227,11 @@ void ui_menu::arts_render_images(bitmap_argb32 *tmp_bitmap, float origx1, float } bitmap_argb32 *dest_bitmap; - dest_bitmap = auto_alloc(machine(), bitmap_argb32); // resample if necessary if (dest_xPixel != tmp_bitmap->width() || dest_yPixel != tmp_bitmap->height()) { + dest_bitmap = auto_alloc(machine(), bitmap_argb32); dest_bitmap->allocate(dest_xPixel, dest_yPixel); render_color color = { 1.0f, 1.0f, 1.0f, 1.0f }; render_resample_argb_bitmap_hq(*dest_bitmap, *tmp_bitmap, color, true); @@ -2231,7 +2239,6 @@ void ui_menu::arts_render_images(bitmap_argb32 *tmp_bitmap, float origx1, float else dest_bitmap = tmp_bitmap; - //snapx_bitmap->reset(); snapx_bitmap->allocate(panel_width_pixel, panel_height_pixel); int x1 = (0.5f * panel_width_pixel) - (0.5f * dest_xPixel); int y1 = (0.5f * panel_height_pixel) - (0.5f * dest_yPixel); @@ -2291,13 +2298,13 @@ void ui_menu::draw_common_arrow(float origx1, float origy1, float origx2, float // apply arrow if (current == dmin) - container->add_quad(ar_x0, ar_y0, ar_x1, ar_y1, fgcolor_right, arrow_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXORIENT(ROT90)); + container->add_quad(ar_x0, ar_y0, ar_x1, ar_y1, fgcolor_right, arrow_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXORIENT(ROT90) | PRIMFLAG_PACKABLE); else if (current == dmax) - container->add_quad(al_x0, al_y0, al_x1, al_y1, fgcolor_left, arrow_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXORIENT(ROT90 ^ ORIENTATION_FLIP_X)); + container->add_quad(al_x0, al_y0, al_x1, al_y1, fgcolor_left, arrow_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXORIENT(ROT90 ^ ORIENTATION_FLIP_X) | PRIMFLAG_PACKABLE); else { - container->add_quad(ar_x0, ar_y0, ar_x1, ar_y1, fgcolor_right, arrow_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXORIENT(ROT90)); - container->add_quad(al_x0, al_y0, al_x1, al_y1, fgcolor_left, arrow_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXORIENT(ROT90 ^ ORIENTATION_FLIP_X)); + container->add_quad(ar_x0, ar_y0, ar_x1, ar_y1, fgcolor_right, arrow_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXORIENT(ROT90) | PRIMFLAG_PACKABLE); + container->add_quad(al_x0, al_y0, al_x1, al_y1, fgcolor_left, arrow_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXORIENT(ROT90 ^ ORIENTATION_FLIP_X) | PRIMFLAG_PACKABLE); } } @@ -2310,10 +2317,7 @@ void ui_menu::draw_icon(int linenum, void *selectedref, float x0, float y0) static const game_driver *olddriver[MAX_ICONS_RENDER] = { nullptr }; float x1 = x0 + machine().ui().get_line_height() * container->manager().ui_aspect(container); float y1 = y0 + machine().ui().get_line_height(); - const game_driver *driver = ((FPTR)selectedref > 2) ? (const game_driver *)selectedref : nullptr; - - if (driver == nullptr) - return; + const game_driver *driver = (const game_driver *)selectedref; if (olddriver[linenum] != driver || ui_globals::redraw_icon) { @@ -2395,14 +2399,17 @@ void ui_menu::draw_icon(int linenum, void *selectedref, float x0, float y0) icons_texture[linenum]->set_bitmap(*icons_bitmap[linenum], icons_bitmap[linenum]->cliprect(), TEXFORMAT_ARGB32); } - else - icons_bitmap[linenum]->reset(); - + else { + if (icons_bitmap[linenum] != nullptr) + { + icons_bitmap[linenum]->reset(); + } + } auto_free(machine(), tmp); } - if (icons_bitmap[linenum]->valid()) - container->add_quad(x0, y0, x1, y1, ARGB_WHITE, icons_texture[linenum], PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); + if (icons_bitmap[linenum] != nullptr && icons_bitmap[linenum]->valid()) + container->add_quad(x0, y0, x1, y1, ARGB_WHITE, icons_texture[linenum], PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_PACKABLE); } //------------------------------------------------- |