diff options
Diffstat (limited to 'src/frontend/mame/ui')
31 files changed, 566 insertions, 514 deletions
diff --git a/src/frontend/mame/ui/auditmenu.cpp b/src/frontend/mame/ui/auditmenu.cpp index 2289762ae49..7d5cbfd7305 100644 --- a/src/frontend/mame/ui/auditmenu.cpp +++ b/src/frontend/mame/ui/auditmenu.cpp @@ -115,9 +115,9 @@ void menu_audit::custom_render(void *selectedref, float top, float bottom, float case phase::CONSENT: draw_text_box( std::begin(m_prompt), std::end(m_prompt), - x, x2, y - top, y - ui().box_tb_border(), + x, x2, y - top, y - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::NEVER, false, - ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); + UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); break; case phase::AUDIT: @@ -140,7 +140,7 @@ void menu_audit::custom_render(void *selectedref, float top, float bottom, float void menu_audit::populate(float &customtop, float &custombottom) { item_append(_("Start Audit"), "", 0, ITEMREF_START); - customtop = (ui().get_line_height() * 2.0f) + (ui().box_tb_border() * 3.0f); + customtop = (ui().get_line_height() * 2.0f) + (UI_BOX_TB_BORDER * 3.0f); } void menu_audit::handle() diff --git a/src/frontend/mame/ui/barcode.cpp b/src/frontend/mame/ui/barcode.cpp index 2cda13f4a51..7945e70fd07 100644 --- a/src/frontend/mame/ui/barcode.cpp +++ b/src/frontend/mame/ui/barcode.cpp @@ -77,7 +77,7 @@ void menu_barcode_reader::populate(float &customtop, float &custombottom) item_append(menu_item_type::SEPARATOR); item_append(_("Enter Code"), "", 0, ITEMREF_ENTER_BARCODE); - customtop = ui().get_line_height() + 3.0f * ui().box_tb_border(); + customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } } diff --git a/src/frontend/mame/ui/custui.cpp b/src/frontend/mame/ui/custui.cpp index 65b1ad2fa5e..186a5bc1c2d 100644 --- a/src/frontend/mame/ui/custui.cpp +++ b/src/frontend/mame/ui/custui.cpp @@ -161,7 +161,7 @@ void menu_custom_ui::populate(float &customtop, float &custombottom) item_append(_("Show side panels"), _(HIDE_STATUS[ui_globals::panels_status]), arrow_flags, (void *)(uintptr_t)HIDE_MENU); item_append(menu_item_type::SEPARATOR); - customtop = ui().get_line_height() + 3.0f * ui().box_tb_border(); + customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } //------------------------------------------------- @@ -173,9 +173,9 @@ void menu_custom_ui::custom_render(void *selectedref, float top, float bottom, f char const *const text[] = { _("Custom UI Settings") }; draw_text_box( std::begin(text), std::end(text), - origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(), + origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); + UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); } //------------------------------------------------- @@ -245,9 +245,6 @@ menu_font_ui::~menu_font_ui() machine().options().set_value(OPTION_UI_FONT, name, OPTION_PRIORITY_CMDLINE); moptions.set_value(OPTION_INFOS_SIZE, m_info_size, OPTION_PRIORITY_CMDLINE); moptions.set_value(OPTION_FONT_ROWS, m_font_size, OPTION_PRIORITY_CMDLINE); - - // OPTION_FONT_ROWS was changed; update the font info - ui().update_target_font_height(); } //------------------------------------------------- @@ -352,7 +349,7 @@ void menu_font_ui::populate(float &customtop, float &custombottom) item_append(menu_item_type::SEPARATOR); - custombottom = customtop = ui().get_line_height() + 3.0f * ui().box_tb_border(); + custombottom = customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } //------------------------------------------------- @@ -365,25 +362,25 @@ void menu_font_ui::custom_render(void *selectedref, float top, float bottom, flo char const *const toptext[] = { _("UI Fonts Settings") }; draw_text_box( std::begin(toptext), std::end(toptext), - origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(), + origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); + UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); if (uintptr_t(selectedref) == INFOS_SIZE) { char const *const bottomtext[] = { _("Sample text - Lorem ipsum dolor sit amet, consectetur adipiscing elit.") }; draw_text_box( std::begin(bottomtext), std::end(bottomtext), - origx1, origx2, origy2 + ui().box_tb_border(), origy2 + bottom, + origx1, origx2, origy2 + UI_BOX_TB_BORDER, origy2 + bottom, ui::text_layout::LEFT, ui::text_layout::NEVER, false, - ui().colors().text_color(), UI_GREEN_COLOR, m_info_size); + UI_TEXT_COLOR, UI_GREEN_COLOR, m_info_size); } } //------------------------------------------------- // ctor //------------------------------------------------- -#define SET_COLOR_UI(var, opt) var[M##opt].color = mui.options().rgb_value(OPTION_##opt); var[M##opt].option = OPTION_##opt +#define SET_COLOR_UI(var, opt) var[M##opt].color = opt; var[M##opt].option = OPTION_##opt menu_colors_ui::menu_colors_ui(mame_ui_manager &mui, render_container &container) : menu(mui, container) { @@ -417,9 +414,6 @@ menu_colors_ui::~menu_colors_ui() dec_color = string_format("%x", (uint32_t)m_color_table[index].color); ui().options().set_value(m_color_table[index].option, dec_color.c_str(), OPTION_PRIORITY_CMDLINE); } - - // refresh our cached colors - ui().colors().refresh(ui().options()); } //------------------------------------------------- @@ -474,7 +468,7 @@ void menu_colors_ui::populate(float &customtop, float &custombottom) item_append(menu_item_type::SEPARATOR); item_append(_("Restore originals colors"), "", 0, (void *)(uintptr_t)MUI_RESTORE); - custombottom = customtop = ui().get_line_height() + 3.0f * ui().box_tb_border(); + custombottom = customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } //------------------------------------------------- @@ -487,18 +481,18 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f char const *const toptext[] = { _("UI Colors Settings") }; draw_text_box( std::begin(toptext), std::end(toptext), - origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(), + origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); + UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); // bottom text // get the text for 'UI Select' std::string const bottomtext[] = { util::string_format(_("Double click or press %1$s to change the color value"), machine().input().seq_name(machine().ioport().type_seq(IPT_UI_SELECT, 0, SEQ_TYPE_STANDARD))) }; draw_text_box( std::begin(bottomtext), std::end(bottomtext), - origx1, origx2, origy2 + ui().box_tb_border(), origy2 + bottom, + origx1, origx2, origy2 + UI_BOX_TB_BORDER, origy2 + bottom, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - ui().colors().text_color(), UI_RED_COLOR, 1.0f); + UI_TEXT_COLOR, UI_RED_COLOR, 1.0f); // compute maxwidth char const *const topbuf = _("Menu Preview"); @@ -506,7 +500,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f float width; ui().draw_text_full(container(), topbuf, 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width, nullptr); - float maxwidth = width + 2.0f * ui().box_lr_border(); + float maxwidth = width + 2.0f * UI_BOX_LR_BORDER; std::string sampletxt[5]; @@ -520,43 +514,43 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f { ui().draw_text_full(container(), elem.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width, nullptr); - width += 2 * ui().box_lr_border(); + width += 2 * UI_BOX_LR_BORDER; maxwidth = std::max(maxwidth, width); } // compute our bounds for header - float x1 = origx2 + 2.0f * ui().box_lr_border(); + float x1 = origx2 + 2.0f * UI_BOX_LR_BORDER; float x2 = x1 + maxwidth; float y1 = origy1; - float y2 = y1 + bottom - ui().box_tb_border(); + float y2 = y1 + bottom - UI_BOX_TB_BORDER; // draw a box ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_GREEN_COLOR); // take off the borders - x1 += ui().box_lr_border(); - x2 -= ui().box_lr_border(); - y1 += ui().box_tb_border(); - y2 -= ui().box_tb_border(); + x1 += UI_BOX_LR_BORDER; + x2 -= UI_BOX_LR_BORDER; + y1 += UI_BOX_TB_BORDER; + y2 -= UI_BOX_TB_BORDER; // draw the text within it ui().draw_text_full(container(), topbuf, x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, - mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color(), nullptr, nullptr); + mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); // compute our bounds for menu preview float line_height = ui().get_line_height(); - x1 -= ui().box_lr_border(); - x2 += ui().box_lr_border(); - y1 = y2 + 2.0f * ui().box_tb_border(); - y2 = y1 + 5.0f * line_height + 2.0f * ui().box_tb_border(); + x1 -= UI_BOX_LR_BORDER; + x2 += UI_BOX_LR_BORDER; + y1 = y2 + 2.0f * UI_BOX_TB_BORDER; + y2 = y1 + 5.0f * line_height + 2.0f * UI_BOX_TB_BORDER; // draw a box ui().draw_outlined_box(container(), x1, y1, x2, y2, m_color_table[MUI_BACKGROUND_COLOR].color); // take off the borders - x1 += ui().box_lr_border(); - x2 -= ui().box_lr_border(); - y1 += ui().box_tb_border(); + x1 += UI_BOX_LR_BORDER; + x2 -= UI_BOX_LR_BORDER; + y1 += UI_BOX_TB_BORDER; // draw normal text ui().draw_text_full(container(), sampletxt[0].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, @@ -781,7 +775,7 @@ void menu_rgb_ui::populate(float &customtop, float &custombottom) item_append(_("Choose from palette"), "", 0, (void *)(uintptr_t)PALETTE_CHOOSE); item_append(menu_item_type::SEPARATOR); - custombottom = customtop = ui().get_line_height() + 3.0f * ui().box_tb_border(); + custombottom = customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } //------------------------------------------------- @@ -795,52 +789,52 @@ void menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, floa // top text ui().draw_text_full(container(), m_title.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width); - width += 2 * ui().box_lr_border(); + width += 2 * UI_BOX_LR_BORDER; maxwidth = std::max(maxwidth, width); // compute our bounds float x1 = 0.5f - 0.5f * maxwidth; float x2 = x1 + maxwidth; float y1 = origy1 - top; - float y2 = origy1 - ui().box_tb_border(); + float y2 = origy1 - UI_BOX_TB_BORDER; // draw a box ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_GREEN_COLOR); // take off the borders - x1 += ui().box_lr_border(); - x2 -= ui().box_lr_border(); - y1 += ui().box_tb_border(); + x1 += UI_BOX_LR_BORDER; + x2 -= UI_BOX_LR_BORDER; + y1 += UI_BOX_TB_BORDER; // draw the text within it ui().draw_text_full(container(), m_title.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, - mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color()); + mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR); std::string sampletxt(_("Color preview =")); ui().draw_text_full(container(), sampletxt.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width); - width += 2 * ui().box_lr_border(); + width += 2 * UI_BOX_LR_BORDER; maxwidth = std::max(origx2 - origx1, width); // compute our bounds x1 = 0.5f - 0.5f * maxwidth; x2 = x1 + maxwidth; - y1 = origy2 + ui().box_tb_border(); + y1 = origy2 + UI_BOX_TB_BORDER; y2 = origy2 + bottom; // draw a box ui().draw_outlined_box(container(), x1, y1, x1 + width, y2, UI_RED_COLOR); // take off the borders - x1 += ui().box_lr_border(); - y1 += ui().box_tb_border(); + x1 += UI_BOX_LR_BORDER; + y1 += UI_BOX_TB_BORDER; // draw the normal text - ui().draw_text_full(container(), sampletxt.c_str(), x1, y1, width - ui().box_lr_border(), ui::text_layout::CENTER, ui::text_layout::NEVER, + ui().draw_text_full(container(), sampletxt.c_str(), x1, y1, width - UI_BOX_LR_BORDER, ui::text_layout::CENTER, ui::text_layout::NEVER, mame_ui_manager::NORMAL, rgb_t::white(), rgb_t::black()); - x1 += width + ui().box_lr_border(); - y1 -= ui().box_tb_border(); + x1 += width + UI_BOX_LR_BORDER; + y1 -= UI_BOX_TB_BORDER; // draw color box ui().draw_outlined_box(container(), x1, y1, x2, y2, *m_color); diff --git a/src/frontend/mame/ui/datmenu.cpp b/src/frontend/mame/ui/datmenu.cpp index 7df7d2fe4b9..52e7416a43e 100644 --- a/src/frontend/mame/ui/datmenu.cpp +++ b/src/frontend/mame/ui/datmenu.cpp @@ -136,8 +136,8 @@ void menu_dats_view::populate(float &customtop, float &custombottom) (m_issoft == true) ? get_data_sw() : get_data(); item_append(menu_item_type::SEPARATOR, (FLAG_UI_DATS | FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW)); - customtop = 2.0f * ui().get_line_height() + 4.0f * ui().box_tb_border(); - custombottom = ui().get_line_height() + 3.0f * ui().box_tb_border(); + customtop = 2.0f * ui().get_line_height() + 4.0f * UI_BOX_TB_BORDER; + custombottom = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; if (!paused) machine().resume(); @@ -152,7 +152,7 @@ void menu_dats_view::draw(uint32_t flags) float const line_height = ui().get_line_height(); float const ud_arrow_width = line_height * machine().render().ui_aspect(); float const gutter_width = 0.52f * line_height * machine().render().ui_aspect(); - float const visible_width = 1.0f - (2.0f * ui().box_lr_border()); + float const visible_width = 1.0f - (2.0f * UI_BOX_LR_BORDER); float const visible_left = (1.0f - visible_width) * 0.5f; float const extra_height = 2.0f * line_height; float const visible_extra_menu_height = get_customtop() + get_custombottom() + extra_height; @@ -166,7 +166,7 @@ void menu_dats_view::draw(uint32_t flags) map_mouse(); // account for extra space at the top and bottom - float visible_main_menu_height = 1.0f - 2.0f * ui().box_tb_border() - visible_extra_menu_height; + float visible_main_menu_height = 1.0f - 2.0f * UI_BOX_TB_BORDER - visible_extra_menu_height; m_visible_lines = int(std::trunc(visible_main_menu_height / line_height)); visible_main_menu_height = float(m_visible_lines) * line_height; @@ -175,12 +175,12 @@ void menu_dats_view::draw(uint32_t flags) // compute left box size float x1 = visible_left; - float y1 = visible_top - ui().box_tb_border(); + float y1 = visible_top - UI_BOX_TB_BORDER; float x2 = x1 + visible_width; - float y2 = visible_top + visible_main_menu_height + ui().box_tb_border() + extra_height; + float y2 = visible_top + visible_main_menu_height + UI_BOX_TB_BORDER + extra_height; float line = visible_top + float(m_visible_lines) * line_height; - ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color()); + ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR); m_visible_lines = (std::min)(visible_items, m_visible_lines); top_line = (std::max)(0, top_line); @@ -200,16 +200,16 @@ void menu_dats_view::draw(uint32_t flags) float const line_x1 = x2 - 0.5f * UI_LINE_WIDTH; float const line_y1 = line_y + line_height; - rgb_t fgcolor = ui().colors().text_color(); - rgb_t bgcolor = ui().colors().text_bg_color(); + rgb_t fgcolor = UI_TEXT_COLOR; + rgb_t bgcolor = UI_TEXT_BG_COLOR; if (!linenum && top_line) { // if we're on the top line, display the up arrow if (mouse_in_rect(line_x0, line_y0, line_x1, line_y1)) { - fgcolor = ui().colors().mouseover_color(); - bgcolor = ui().colors().mouseover_bg_color(); + fgcolor = UI_MOUSEOVER_COLOR; + bgcolor = UI_MOUSEOVER_BG_COLOR; highlight(line_x0, line_y0, line_x1, line_y1, bgcolor); set_hover(HOVER_ARROW_UP); } @@ -223,8 +223,8 @@ void menu_dats_view::draw(uint32_t flags) // if we're on the bottom line, display the down arrow if (mouse_in_rect(line_x0, line_y0, line_x1, line_y1)) { - fgcolor = ui().colors().mouseover_color(); - bgcolor = ui().colors().mouseover_bg_color(); + fgcolor = UI_MOUSEOVER_COLOR; + bgcolor = UI_MOUSEOVER_BG_COLOR; highlight(line_x0, line_y0, line_x1, line_y1, bgcolor); set_hover(HOVER_ARROW_DOWN); } @@ -253,8 +253,8 @@ void menu_dats_view::draw(uint32_t flags) float const line_y0 = line; float const line_x1 = x2 - 0.5f * UI_LINE_WIDTH; float const line_y1 = line + line_height; - rgb_t const fgcolor = ui().colors().selected_color(); - rgb_t const bgcolor = ui().colors().selected_bg_color(); + rgb_t const fgcolor = UI_SELECTED_COLOR; + rgb_t const bgcolor = UI_SELECTED_BG_COLOR; if (mouse_in_rect(line_x0, line_y0, line_x1, line_y1) && is_selectable(pitem)) set_hover(count); @@ -263,7 +263,7 @@ void menu_dats_view::draw(uint32_t flags) { container().add_line( visible_left, line + 0.5f * line_height, visible_left + visible_width, line + 0.5f * line_height, - UI_LINE_WIDTH, ui().colors().text_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); + UI_LINE_WIDTH, UI_TEXT_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } else { @@ -297,25 +297,25 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f ui().draw_text_full(container(), driver.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width, nullptr); - width += 2 * ui().box_lr_border(); + width += 2 * UI_BOX_LR_BORDER; maxwidth = std::max(maxwidth, width); // compute our bounds float x1 = 0.5f - 0.5f * maxwidth; float x2 = x1 + maxwidth; float y1 = origy1 - top; - float y2 = origy1 - 2.0f * ui().box_tb_border() - ui().get_line_height(); + float y2 = origy1 - 2.0f * UI_BOX_TB_BORDER - ui().get_line_height(); // draw a box ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_GREEN_COLOR); // take off the borders - x1 += ui().box_lr_border(); - x2 -= ui().box_lr_border(); - y1 += ui().box_tb_border(); + x1 += UI_BOX_LR_BORDER; + x2 -= UI_BOX_LR_BORDER; + y1 += UI_BOX_TB_BORDER; ui().draw_text_full(container(), driver.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, - mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color(), nullptr, nullptr); + mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); maxwidth = 0; for (auto & elem : m_items_list) @@ -328,27 +328,27 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f float space = (1.0f - maxwidth) / (m_items_list.size() * 2); // compute our bounds - x1 -= ui().box_lr_border(); - x2 += ui().box_lr_border(); - y1 = y2 + ui().box_tb_border(); - y2 += ui().get_line_height() + 2.0f * ui().box_tb_border(); + x1 -= UI_BOX_LR_BORDER; + x2 += UI_BOX_LR_BORDER; + y1 = y2 + UI_BOX_TB_BORDER; + y2 += ui().get_line_height() + 2.0f * UI_BOX_TB_BORDER; // draw a box - ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color()); + ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR); // take off the borders - y1 += ui().box_tb_border(); + y1 += UI_BOX_TB_BORDER; // draw the text within it int x = 0; for (auto & elem : m_items_list) { x1 += space; - rgb_t fcolor = (m_actual == x) ? rgb_t(0xff, 0xff, 0xff, 0x00) : ui().colors().text_color(); - rgb_t bcolor = (m_actual == x) ? rgb_t(0xff, 0xff, 0xff, 0xff) : ui().colors().text_bg_color(); + rgb_t fcolor = (m_actual == x) ? rgb_t(0xff, 0xff, 0xff, 0x00) : UI_TEXT_COLOR; + rgb_t bcolor = (m_actual == x) ? rgb_t(0xff, 0xff, 0xff, 0xff) : UI_TEXT_BG_COLOR; ui().draw_text_full(container(), elem.label.c_str(), x1, y1, 1.0f, ui::text_layout::LEFT, ui::text_layout::NEVER, mame_ui_manager::NONE, fcolor, bcolor, &width, nullptr); - if (bcolor != ui().colors().text_bg_color()) + if (bcolor != UI_TEXT_BG_COLOR) ui().draw_textured_box(container(), x1 - (space / 2), y1, x1 + width + (space / 2), y2, bcolor, rgb_t(255, 43, 43, 43), hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1)); @@ -361,26 +361,26 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f std::string revision; revision.assign(_("Revision: ")).append(m_items_list[m_actual].revision); ui().draw_text_full(container(), revision.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width, nullptr); - width += 2 * ui().box_lr_border(); + width += 2 * UI_BOX_LR_BORDER; maxwidth = std::max(origx2 - origx1, width); // compute our bounds x1 = 0.5f - 0.5f * maxwidth; x2 = x1 + maxwidth; - y1 = origy2 + ui().box_tb_border(); + y1 = origy2 + UI_BOX_TB_BORDER; y2 = origy2 + bottom; // draw a box ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_GREEN_COLOR); // take off the borders - x1 += ui().box_lr_border(); - x2 -= ui().box_lr_border(); - y1 += ui().box_tb_border(); + x1 += UI_BOX_LR_BORDER; + x2 -= UI_BOX_LR_BORDER; + y1 += UI_BOX_TB_BORDER; // draw the text within it ui().draw_text_full(container(), revision.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, - mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color(), nullptr, nullptr); + mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); } //------------------------------------------------- @@ -395,7 +395,7 @@ void menu_dats_view::get_data() float const line_height = ui().get_line_height(); float const gutter_width = 0.52f * line_height * machine().render().ui_aspect(); - float const visible_width = 1.0f - (2.0f * ui().box_lr_border()); + float const visible_width = 1.0f - (2.0f * UI_BOX_LR_BORDER); float const effective_width = visible_width - 2.0f * gutter_width; auto lines = ui().wrap_text(container(), buffer.c_str(), 0.0f, 0.0f, effective_width, xstart, xend); @@ -417,7 +417,7 @@ void menu_dats_view::get_data_sw() else mame_machine_manager::instance()->lua()->call_plugin("data", m_items_list[m_actual].option - 1, buffer); - auto lines = ui().wrap_text(container(), buffer.c_str(), 0.0f, 0.0f, 1.0f - (4.0f * ui().box_lr_border()), xstart, xend); + auto lines = ui().wrap_text(container(), buffer.c_str(), 0.0f, 0.0f, 1.0f - (4.0f * UI_BOX_LR_BORDER), xstart, xend); for (int x = 0; x < lines; ++x) { std::string tempbuf(buffer.substr(xstart[x], xend[x] - xstart[x])); diff --git a/src/frontend/mame/ui/dirmenu.cpp b/src/frontend/mame/ui/dirmenu.cpp index 1d8166718f0..77e64b8463d 100644 --- a/src/frontend/mame/ui/dirmenu.cpp +++ b/src/frontend/mame/ui/dirmenu.cpp @@ -104,7 +104,7 @@ void menu_directory::populate(float &customtop, float &custombottom) item_append(_(elem.name), "", 0, (void *)(uintptr_t)elem.action); item_append(menu_item_type::SEPARATOR); - customtop = ui().get_line_height() + 3.0f * ui().box_tb_border(); + customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } //------------------------------------------------- @@ -116,9 +116,9 @@ void menu_directory::custom_render(void *selectedref, float top, float bottom, f char const *const toptext[] = { _("Folders Setup") }; draw_text_box( std::begin(toptext), std::end(toptext), - origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(), + origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); + UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); } /************************************************** @@ -182,7 +182,7 @@ void menu_display_actual::populate(float &customtop, float &custombottom) item_append(_("Remove Folder"), "", 0, (void *)REMOVE); item_append(menu_item_type::SEPARATOR); - customtop = (m_folders.size() + 1) * ui().get_line_height() + 6.0f * ui().box_tb_border(); + customtop = (m_folders.size() + 1) * ui().get_line_height() + 6.0f * UI_BOX_TB_BORDER; } //------------------------------------------------- @@ -194,14 +194,14 @@ void menu_display_actual::custom_render(void *selectedref, float top, float bott float const lineheight(ui().get_line_height()); float const maxwidth(draw_text_box( std::begin(m_folders), std::end(m_folders), - origx1, origx2, origy1 - (3.0f * ui().box_tb_border()) - (m_folders.size() * lineheight), origy1 - ui().box_tb_border(), + origx1, origx2, origy1 - (3.0f * UI_BOX_TB_BORDER) - (m_folders.size() * lineheight), origy1 - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - ui().colors().text_color(), ui().colors().background_color(), 1.0f)); + UI_TEXT_COLOR, UI_BACKGROUND_COLOR, 1.0f)); draw_text_box( std::begin(m_heading), std::end(m_heading), - 0.5f * (1.0f - maxwidth), 0.5f * (1.0f + maxwidth), origy1 - top, origy1 - top + lineheight + (2.0f * ui().box_tb_border()), + 0.5f * (1.0f - maxwidth), 0.5f * (1.0f + maxwidth), origy1 - top, origy1 - top + lineheight + (2.0f * UI_BOX_TB_BORDER), ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); + UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); } /************************************************** @@ -403,8 +403,8 @@ void menu_add_change_folder::populate(float &customtop, float &custombottom) item_append(menu_item_type::SEPARATOR); // configure the custom rendering - customtop = 2.0f * ui().get_line_height() + 3.0f * ui().box_tb_border(); - custombottom = 1.0f * ui().get_line_height() + 3.0f * ui().box_tb_border(); + customtop = 2.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; + custombottom = 1.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } //------------------------------------------------- @@ -421,17 +421,17 @@ void menu_add_change_folder::custom_render(void *selectedref, float top, float b m_current_path }; draw_text_box( std::begin(toptext), std::end(toptext), - origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(), + origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::NEVER, false, - ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); + UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); // bottom text char const *const bottomtext[] = { _("Press TAB to set") }; draw_text_box( std::begin(bottomtext), std::end(bottomtext), - origx1, origx2, origy2 + ui().box_tb_border(), origy2 + bottom, + origx1, origx2, origy2 + UI_BOX_TB_BORDER, origy2 + bottom, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - ui().colors().text_color(), UI_RED_COLOR, 1.0f); + UI_TEXT_COLOR, UI_RED_COLOR, 1.0f); } /************************************************** @@ -501,7 +501,7 @@ void menu_remove_folder::populate(float &customtop, float &custombottom) item_append(elem, "", 0, (void *)(uintptr_t)++folders_count); item_append(menu_item_type::SEPARATOR); - customtop = ui().get_line_height() + 3.0f * ui().box_tb_border(); + customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } //------------------------------------------------- @@ -513,9 +513,9 @@ void menu_remove_folder::custom_render(void *selectedref, float top, float botto std::string const toptext[] = {string_format(_("Remove %1$s Folder"), _(s_folders[m_ref].name)) }; draw_text_box( std::begin(toptext), std::end(toptext), - origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(), + origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); + UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); } } // namespace ui diff --git a/src/frontend/mame/ui/filecreate.cpp b/src/frontend/mame/ui/filecreate.cpp index 9928829ecf5..0cfef03b723 100644 --- a/src/frontend/mame/ui/filecreate.cpp +++ b/src/frontend/mame/ui/filecreate.cpp @@ -182,7 +182,7 @@ void menu_file_create::populate(float &customtop, float &custombottom) item_append(menu_item_type::SEPARATOR); item_append(_("Create"), "", 0, ITEMREF_CREATE); - customtop = ui().get_line_height() + 3.0f * ui().box_tb_border(); + customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } diff --git a/src/frontend/mame/ui/filemngr.cpp b/src/frontend/mame/ui/filemngr.cpp index cb3243e0544..07842f423aa 100644 --- a/src/frontend/mame/ui/filemngr.cpp +++ b/src/frontend/mame/ui/filemngr.cpp @@ -158,7 +158,7 @@ void menu_file_manager::populate(float &customtop, float &custombottom) if (m_warnings.empty() || m_curr_selected) item_append("Reset", "", 0, (void *)1); - custombottom = ui().get_line_height() + 3.0f * ui().box_tb_border(); + custombottom = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } diff --git a/src/frontend/mame/ui/filesel.cpp b/src/frontend/mame/ui/filesel.cpp index 49136d04f64..3907f007517 100644 --- a/src/frontend/mame/ui/filesel.cpp +++ b/src/frontend/mame/ui/filesel.cpp @@ -83,11 +83,11 @@ void menu_file_selector::custom_render(void *selectedref, float top, float botto extra_text_position(origx1, origx2, origy1, top, layout, -1, x1, y1, x2, y2); // draw a box - ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color()); + ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR); // take off the borders - x1 += ui().box_lr_border(); - y1 += ui().box_tb_border(); + x1 += UI_BOX_LR_BORDER; + y1 += UI_BOX_TB_BORDER; size_t hit_start = 0, hit_span = 0; if (is_mouse_hit() @@ -100,8 +100,8 @@ void menu_file_selector::custom_render(void *selectedref, float top, float botto m_hover_directory = m_current_directory.substr(0, target_dir_end + strlen(PATH_SEPARATOR)); // highlight the text in question - rgb_t fgcolor = ui().colors().mouseover_color(); - rgb_t bgcolor = ui().colors().mouseover_bg_color(); + rgb_t fgcolor = UI_MOUSEOVER_COLOR; + rgb_t bgcolor = UI_MOUSEOVER_BG_COLOR; layout.restyle(target_dir_start, target_dir_end - target_dir_start, &fgcolor, &bgcolor); } else @@ -464,7 +464,7 @@ void menu_file_selector::populate(float &customtop, float &custombottom) set_selection((void *)selected_entry); // set up custom render proc - customtop = ui().get_line_height() + 3.0f * ui().box_tb_border(); + customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } diff --git a/src/frontend/mame/ui/info.cpp b/src/frontend/mame/ui/info.cpp index 46d092722d2..e7235b89111 100644 --- a/src/frontend/mame/ui/info.cpp +++ b/src/frontend/mame/ui/info.cpp @@ -58,19 +58,18 @@ constexpr std::pair<device_t::feature_type, char const *> FEATURE_NAMES[] = { // machine_static_info - constructors //------------------------------------------------- -machine_static_info::machine_static_info(const ui_options &options, machine_config const &config) - : machine_static_info(options, config, nullptr) +machine_static_info::machine_static_info(machine_config const &config) + : machine_static_info(config, nullptr) { } -machine_static_info::machine_static_info(const ui_options &options, machine_config const &config, ioport_list const &ports) - : machine_static_info(options, config, &ports) +machine_static_info::machine_static_info(machine_config const &config, ioport_list const &ports) + : machine_static_info(config, &ports) { } -machine_static_info::machine_static_info(const ui_options &options, machine_config const &config, ioport_list const *ports) - : m_options(options) - , m_flags(config.gamedrv().flags) +machine_static_info::machine_static_info(machine_config const &config, ioport_list const *ports) + : m_flags(config.gamedrv().flags) , m_unemulated_features(config.gamedrv().type.unemulated_features()) , m_imperfect_features(config.gamedrv().type.imperfect_features()) , m_has_bioses(false) @@ -155,7 +154,7 @@ rgb_t machine_static_info::warnings_color() const else if ((machine_flags() & MACHINE_WARNINGS) || unemulated_features() || imperfect_features()) return UI_YELLOW_COLOR; else - return m_options.background_color(); + return UI_BACKGROUND_COLOR; } @@ -165,7 +164,7 @@ rgb_t machine_static_info::warnings_color() const //------------------------------------------------- machine_info::machine_info(running_machine &machine) - : machine_static_info(dynamic_cast<mame_ui_manager *>(&machine.ui())->options(), machine.config(), machine.ioport().ports()) + : machine_static_info(machine.config(), machine.ioport().ports()) , m_machine(machine) { } diff --git a/src/frontend/mame/ui/info.h b/src/frontend/mame/ui/info.h index cd97d16eae8..c5733b8073f 100644 --- a/src/frontend/mame/ui/info.h +++ b/src/frontend/mame/ui/info.h @@ -21,7 +21,7 @@ class machine_static_info { public: // construction - machine_static_info(const ui_options &options, machine_config const &config); + machine_static_info(machine_config const &config); // overall emulation status ::machine_flags::type machine_flags() const { return m_flags; } @@ -43,12 +43,10 @@ public: rgb_t warnings_color() const; protected: - machine_static_info(const ui_options &options, machine_config const &config, ioport_list const &ports); + machine_static_info(machine_config const &config, ioport_list const &ports); private: - machine_static_info(const ui_options &options, machine_config const &config, ioport_list const *ports); - - const ui_options & m_options; + machine_static_info(machine_config const &config, ioport_list const *ports); // overall feature status ::machine_flags::type m_flags; diff --git a/src/frontend/mame/ui/inputmap.cpp b/src/frontend/mame/ui/inputmap.cpp index a2bbf3b7a21..0aa0dc8dcd2 100644 --- a/src/frontend/mame/ui/inputmap.cpp +++ b/src/frontend/mame/ui/inputmap.cpp @@ -640,11 +640,11 @@ void menu_settings_dip_switches::custom_render(void *selectedref, float top, flo return; // add borders - y1 = y2 + ui().box_tb_border(); + y1 = y2 + UI_BOX_TB_BORDER; y2 = y1 + bottom; // draw extra menu area - ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color()); + ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR); y1 += (float)DIP_SWITCH_SPACING; // iterate over DIP switches @@ -693,12 +693,12 @@ void menu_settings_dip_switches::custom_render_one(float x1, float y1, float x2, ui().draw_text_full(container(), dip->name, 0, - y1 + (DIP_SWITCH_HEIGHT - ui().target_font_height()) / 2, + y1 + (DIP_SWITCH_HEIGHT - UI_TARGET_FONT_HEIGHT) / 2, x1 - ui().get_string_width(" "), ui::text_layout::RIGHT, ui::text_layout::NEVER, mame_ui_manager::NORMAL, - ui().colors().text_color(), + UI_TEXT_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA), nullptr , nullptr); @@ -714,7 +714,7 @@ void menu_settings_dip_switches::custom_render_one(float x1, float y1, float x2, float innerx1; /* first outline the switch */ - ui().draw_outlined_box(container(), x1, y1, x1 + switch_field_width, y2, ui().colors().background_color()); + ui().draw_outlined_box(container(), x1, y1, x1 + switch_field_width, y2, UI_BACKGROUND_COLOR); /* compute x1/x2 for the inner filled in switch */ innerx1 = x1 + (switch_field_width - switch_width) / 2; @@ -724,13 +724,13 @@ void menu_settings_dip_switches::custom_render_one(float x1, float y1, float x2, { float innery1 = (dip->state & (1 << toggle)) ? y1_on : y1_off; container().add_rect(innerx1, innery1, innerx1 + switch_width, innery1 + SINGLE_TOGGLE_SWITCH_HEIGHT, - (selectedmask & (1 << toggle)) ? ui().colors().dipsw_color() : ui().colors().text_color(), + (selectedmask & (1 << toggle)) ? UI_DIPSW_COLOR : UI_TEXT_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } else { container().add_rect(innerx1, y1_off, innerx1 + switch_width, y1_on + SINGLE_TOGGLE_SWITCH_HEIGHT, - ui().colors().unavailable_color(), + UI_UNAVAILABLE_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } diff --git a/src/frontend/mame/ui/menu.cpp b/src/frontend/mame/ui/menu.cpp index 69e08b5489d..d8f6725c922 100644 --- a/src/frontend/mame/ui/menu.cpp +++ b/src/frontend/mame/ui/menu.cpp @@ -594,12 +594,12 @@ void menu::draw(uint32_t flags) visible_main_menu_height += 0.01f; // if we are too wide or too tall, clamp it down - if (visible_width + 2.0f * ui().box_lr_border() > 1.0f) - visible_width = 1.0f - 2.0f * ui().box_lr_border(); + if (visible_width + 2.0f * UI_BOX_LR_BORDER > 1.0f) + visible_width = 1.0f - 2.0f * UI_BOX_LR_BORDER; // if the menu and extra menu won't fit, take away part of the regular menu, it will scroll - if (visible_main_menu_height + visible_extra_menu_height + 2.0f * ui().box_tb_border() > 1.0f) - visible_main_menu_height = 1.0f - 2.0f * ui().box_tb_border() - visible_extra_menu_height; + if (visible_main_menu_height + visible_extra_menu_height + 2.0f * UI_BOX_TB_BORDER > 1.0f) + visible_main_menu_height = 1.0f - 2.0f * UI_BOX_TB_BORDER - visible_extra_menu_height; m_visible_lines = std::min(int(std::floor(visible_main_menu_height / line_height)), int(unsigned(m_items.size()))); visible_main_menu_height = float(m_visible_lines) * line_height; @@ -609,12 +609,12 @@ void menu::draw(uint32_t flags) float const visible_top = ((1.0f - visible_main_menu_height - visible_extra_menu_height) * 0.5f) + m_customtop; // first add us a box - float const x1 = visible_left - ui().box_lr_border(); - float const y1 = visible_top - ui().box_tb_border(); - float const x2 = visible_left + visible_width + ui().box_lr_border(); - float const y2 = visible_top + visible_main_menu_height + ui().box_tb_border(); + float const x1 = visible_left - UI_BOX_LR_BORDER; + float const y1 = visible_top - UI_BOX_TB_BORDER; + float const x2 = visible_left + visible_width + UI_BOX_LR_BORDER; + float const y2 = visible_top + visible_main_menu_height + UI_BOX_TB_BORDER; if (!customonly) - ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color()); + ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR); if (top_line < 0 || is_first_selected()) top_line = 0; @@ -652,10 +652,10 @@ void menu::draw(uint32_t flags) auto const itemnum = top_line + linenum; menu_item const &pitem = m_items[itemnum]; char const *const itemtext = pitem.text.c_str(); - rgb_t fgcolor = ui().colors().text_color(); - rgb_t bgcolor = ui().colors().text_bg_color(); - rgb_t fgcolor2 = ui().colors().subitem_color(); - rgb_t fgcolor3 = ui().colors().clone_color(); + rgb_t fgcolor = UI_TEXT_COLOR; + rgb_t bgcolor = UI_TEXT_BG_COLOR; + rgb_t fgcolor2 = UI_SUBITEM_COLOR; + rgb_t fgcolor3 = UI_CLONE_COLOR; float const line_y0 = visible_top + (float)linenum * line_height; float const line_y1 = line_y0 + line_height; @@ -666,19 +666,19 @@ void menu::draw(uint32_t flags) // if we're selected, draw with a different background if (is_selected(itemnum)) { - fgcolor = fgcolor2 = fgcolor3 = ui().colors().selected_color(); - bgcolor = ui().colors().selected_bg_color(); + fgcolor = fgcolor2 = fgcolor3 = UI_SELECTED_COLOR; + bgcolor = UI_SELECTED_BG_COLOR; } // else if the mouse is over this item, draw with a different background else if (itemnum == m_hover) { - fgcolor = fgcolor2 = fgcolor3 = ui().colors().mouseover_color(); - bgcolor = ui().colors().mouseover_bg_color(); + fgcolor = fgcolor2 = fgcolor3 = UI_MOUSEOVER_COLOR; + bgcolor = UI_MOUSEOVER_BG_COLOR; } // if we have some background hilighting to do, add a quad behind everything else - if (bgcolor != ui().colors().text_bg_color()) + if (bgcolor != UI_TEXT_BG_COLOR) highlight(line_x0, line_y0, line_x1, line_y1, bgcolor); if (linenum == 0 && show_top_arrow) @@ -710,7 +710,7 @@ void menu::draw(uint32_t flags) else if (pitem.type == menu_item_type::SEPARATOR) { // if we're just a divider, draw a line - container().add_line(visible_left, line_y0 + 0.5f * line_height, visible_left + visible_width, line_y0 + 0.5f * line_height, UI_LINE_WIDTH, ui().colors().border_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); + container().add_line(visible_left, line_y0 + 0.5f * line_height, visible_left + visible_width, line_y0 + 0.5f * line_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } else if (pitem.subtext.empty()) { @@ -718,8 +718,8 @@ void menu::draw(uint32_t flags) if (pitem.flags & FLAG_UI_HEADING) { float heading_width = ui().get_string_width(itemtext); - container().add_line(visible_left, line_y0 + 0.5f * line_height, visible_left + ((visible_width - heading_width) / 2) - ui().box_lr_border(), line_y0 + 0.5f * line_height, UI_LINE_WIDTH, ui().colors().border_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); - container().add_line(visible_left + visible_width - ((visible_width - heading_width) / 2) + ui().box_lr_border(), line_y0 + 0.5f * line_height, visible_left + visible_width, line_y0 + 0.5f * line_height, UI_LINE_WIDTH, ui().colors().border_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); + container().add_line(visible_left, line_y0 + 0.5f * line_height, visible_left + ((visible_width - heading_width) / 2) - UI_BOX_LR_BORDER, line_y0 + 0.5f * line_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); + container().add_line(visible_left + visible_width - ((visible_width - heading_width) / 2) + UI_BOX_LR_BORDER, line_y0 + 0.5f * line_height, visible_left + visible_width, line_y0 + 0.5f * line_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } ui().draw_text_full(container(), itemtext, effective_left, line_y0, effective_width, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NORMAL, fgcolor, bgcolor, nullptr, nullptr); @@ -812,20 +812,20 @@ void menu::draw(uint32_t flags) ui::text_layout::RIGHT, ui::text_layout::WORD, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &target_width, &target_height); // determine the target location - float const target_x = visible_left + visible_width - target_width - ui().box_lr_border(); - float target_y = line_y + line_height + ui().box_tb_border(); - if (target_y + target_height + ui().box_tb_border() > visible_main_menu_height) - target_y = line_y - target_height - ui().box_tb_border(); + float const target_x = visible_left + visible_width - target_width - UI_BOX_LR_BORDER; + float target_y = line_y + line_height + UI_BOX_TB_BORDER; + if (target_y + target_height + UI_BOX_TB_BORDER > visible_main_menu_height) + target_y = line_y - target_height - UI_BOX_TB_BORDER; // 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().colors().selected_bg_color() : ui().colors().background_color()); + 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); ui().draw_text_full(container(), pitem.subtext.c_str(), target_x, target_y, target_width, - ui::text_layout::RIGHT, ui::text_layout::WORD, mame_ui_manager::NORMAL, ui().colors().selected_color(), ui().colors().selected_bg_color(), nullptr, nullptr); + ui::text_layout::RIGHT, ui::text_layout::WORD, mame_ui_manager::NORMAL, UI_SELECTED_COLOR, UI_SELECTED_BG_COLOR, nullptr, nullptr); } // if there is something special to add, do it by calling the virtual method @@ -853,11 +853,11 @@ void menu::draw_text_box() float target_x, target_y; // compute the multi-line target width/height - ui().draw_text_full(container(), text, 0, 0, 1.0f - 2.0f * ui().box_lr_border() - 2.0f * gutter_width, + ui().draw_text_full(container(), text, 0, 0, 1.0f - 2.0f * UI_BOX_LR_BORDER - 2.0f * gutter_width, ui::text_layout::LEFT, ui::text_layout::WORD, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &target_width, &target_height); target_height += 2.0f * line_height; - if (target_height > 1.0f - 2.0f * ui().box_tb_border()) - target_height = floorf((1.0f - 2.0f * ui().box_tb_border()) / line_height) * line_height; + if (target_height > 1.0f - 2.0f * UI_BOX_TB_BORDER) + target_height = floorf((1.0f - 2.0f * UI_BOX_TB_BORDER) / line_height) * line_height; // maximum against "return to prior menu" text prior_width = ui().get_string_width(backtext) + 2.0f * gutter_width; @@ -868,23 +868,23 @@ void menu::draw_text_box() target_y = 0.5f - 0.5f * target_height; // make sure we stay on-screen - if (target_x < ui().box_lr_border() + gutter_width) - target_x = ui().box_lr_border() + gutter_width; - if (target_x + target_width + gutter_width + ui().box_lr_border() > 1.0f) - target_x = 1.0f - ui().box_lr_border() - gutter_width - target_width; - if (target_y < ui().box_tb_border()) - target_y = ui().box_tb_border(); - if (target_y + target_height + ui().box_tb_border() > 1.0f) - target_y = 1.0f - ui().box_tb_border() - target_height; + if (target_x < UI_BOX_LR_BORDER + gutter_width) + target_x = UI_BOX_LR_BORDER + gutter_width; + if (target_x + target_width + gutter_width + UI_BOX_LR_BORDER > 1.0f) + target_x = 1.0f - UI_BOX_LR_BORDER - gutter_width - target_width; + if (target_y < UI_BOX_TB_BORDER) + target_y = UI_BOX_TB_BORDER; + if (target_y + target_height + UI_BOX_TB_BORDER > 1.0f) + target_y = 1.0f - UI_BOX_TB_BORDER - target_height; // add a box around that - ui().draw_outlined_box(container(), target_x - ui().box_lr_border() - gutter_width, - target_y - ui().box_tb_border(), - target_x + target_width + gutter_width + ui().box_lr_border(), - target_y + target_height + ui().box_tb_border(), - (m_items[0].flags & FLAG_REDTEXT) ? UI_RED_COLOR : ui().colors().background_color()); + ui().draw_outlined_box(container(), target_x - UI_BOX_LR_BORDER - gutter_width, + target_y - UI_BOX_TB_BORDER, + target_x + target_width + gutter_width + UI_BOX_LR_BORDER, + target_y + target_height + UI_BOX_TB_BORDER, + (m_items[0].flags & FLAG_REDTEXT) ? UI_RED_COLOR : UI_BACKGROUND_COLOR); ui().draw_text_full(container(), text, target_x, target_y, target_width, - ui::text_layout::LEFT, ui::text_layout::WORD, mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color(), nullptr, nullptr); + ui::text_layout::LEFT, ui::text_layout::WORD, mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); // draw the "return to prior menu" text with a hilight behind it highlight( @@ -892,9 +892,9 @@ void menu::draw_text_box() target_y + target_height - line_height, target_x + target_width - 0.5f * UI_LINE_WIDTH, target_y + target_height, - ui().colors().selected_bg_color()); + UI_SELECTED_BG_COLOR); ui().draw_text_full(container(), backtext, target_x, target_y + target_height - line_height, target_width, - ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NORMAL, ui().colors().selected_color(), ui().colors().selected_bg_color(), nullptr, nullptr); + ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NORMAL, UI_SELECTED_COLOR, UI_SELECTED_BG_COLOR, nullptr, nullptr); // artificially set the hover to the last item so a double-click exits m_hover = m_items.size() - 1; @@ -1334,11 +1334,11 @@ void menu::extra_text_draw_box(float origx1, float origx2, float origy, float ys extra_text_position(origx1, origx2, origy, yspan, layout, direction, x1, y1, x2, y2); // draw a box - ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color()); + ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR); // take off the borders - x1 += ui().box_lr_border(); - y1 += ui().box_tb_border(); + x1 += UI_BOX_LR_BORDER; + y1 += UI_BOX_TB_BORDER; // draw the text within it layout.emit(container(), x1, y1); @@ -1361,14 +1361,14 @@ void menu::draw_background() void menu::extra_text_position(float origx1, float origx2, float origy, float yspan, text_layout &layout, int direction, float &x1, float &y1, float &x2, float &y2) { - float width = layout.actual_width() + (2 * ui().box_lr_border()); + float width = layout.actual_width() + (2 * UI_BOX_LR_BORDER); float maxwidth = std::max(width, origx2 - origx1); // compute our bounds x1 = 0.5f - 0.5f * maxwidth; x2 = x1 + maxwidth; y1 = origy + (yspan * direction); - y2 = origy + (ui().box_tb_border() * direction); + y2 = origy + (UI_BOX_TB_BORDER * direction); if (y1 > y2) std::swap(y1, y2); diff --git a/src/frontend/mame/ui/menu.h b/src/frontend/mame/ui/menu.h index 8df66a92882..fa3249899c1 100644 --- a/src/frontend/mame/ui/menu.h +++ b/src/frontend/mame/ui/menu.h @@ -222,7 +222,7 @@ protected: 0.0f, 0.0f, 1.0f, justify, wrap, mame_ui_manager::NONE, rgb_t::black(), rgb_t::white(), &width, nullptr, text_size); - width += 2.0f * ui().box_lr_border(); + width += 2.0f * UI_BOX_LR_BORDER; maxwidth = (std::max)(maxwidth, width); } if (scale && ((origx2 - origx1) < maxwidth)) @@ -237,16 +237,16 @@ protected: ui().draw_outlined_box(container(), x1, y1, x2, y2, bgcolor); // inset box and draw content - x1 += ui().box_lr_border(); - x2 -= ui().box_lr_border(); - y1 += ui().box_tb_border(); - y2 -= ui().box_tb_border(); + x1 += UI_BOX_LR_BORDER; + x2 -= UI_BOX_LR_BORDER; + y1 += UI_BOX_TB_BORDER; + y2 -= UI_BOX_TB_BORDER; for (Iter it = begin; it != end; ++it) { ui().draw_text_full( container(), get_c_str(*it), x1, y1, x2 - x1, justify, wrap, - mame_ui_manager::NORMAL, fgcolor, ui().colors().text_bg_color(), + mame_ui_manager::NORMAL, fgcolor, UI_TEXT_BG_COLOR, nullptr, nullptr, text_size); y1 += ui().get_line_height(); } diff --git a/src/frontend/mame/ui/miscmenu.cpp b/src/frontend/mame/ui/miscmenu.cpp index fbb84d0aec3..e2f1f0615fc 100644 --- a/src/frontend/mame/ui/miscmenu.cpp +++ b/src/frontend/mame/ui/miscmenu.cpp @@ -790,7 +790,7 @@ void menu_machine_configure::populate(float &customtop, float &custombottom) item_append(menu_item_type::SEPARATOR); item_append(_("Save machine configuration"), "", 0, (void *)(uintptr_t)SAVE); item_append(menu_item_type::SEPARATOR); - customtop = 2.0f * ui().get_line_height() + 3.0f * ui().box_tb_border(); + customtop = 2.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } //------------------------------------------------- @@ -802,9 +802,9 @@ void menu_machine_configure::custom_render(void *selectedref, float top, float b char const *const text[] = { _("Configure machine:"), m_drv.type.fullname() }; draw_text_box( std::begin(text), std::end(text), - origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(), + origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); + UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); } void menu_machine_configure::setup_bios() @@ -906,7 +906,7 @@ void menu_plugins_configure::populate(float &customtop, float &custombottom) } } item_append(menu_item_type::SEPARATOR); - customtop = ui().get_line_height() + (3.0f * ui().box_tb_border()); + customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER); } //------------------------------------------------- @@ -918,9 +918,9 @@ void menu_plugins_configure::custom_render(void *selectedref, float top, float b char const *const toptext[] = { _("Plugins") }; draw_text_box( std::begin(toptext), std::end(toptext), - origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(), + origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); + UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); } } // namespace ui diff --git a/src/frontend/mame/ui/moptions.cpp b/src/frontend/mame/ui/moptions.cpp index 1b4779ddaf0..9b070962932 100644 --- a/src/frontend/mame/ui/moptions.cpp +++ b/src/frontend/mame/ui/moptions.cpp @@ -88,22 +88,3 @@ ui_options::ui_options() : core_options() { add_entries(ui_options::s_option_entries); } - -//------------------------------------------------- -// rgb_value - decode an RGB option -//------------------------------------------------- - -rgb_t ui_options::rgb_value(const char *option) const -{ - // find the entry - core_options::entry::shared_ptr entry = get_entry(option); - - // look up the value, and sanity check the result - const char *value = entry->value(); - int len = strlen(value); - if (len != 8) - value = entry->default_value().c_str(); - - // convert to an rgb_t - return rgb_t((uint32_t)strtoul(value, nullptr, 16)); -} diff --git a/src/frontend/mame/ui/moptions.h b/src/frontend/mame/ui/moptions.h index ddfa3971c3b..5630cdf40e7 100644 --- a/src/frontend/mame/ui/moptions.h +++ b/src/frontend/mame/ui/moptions.h @@ -119,25 +119,22 @@ public: int font_rows() const { return int_value(OPTION_FONT_ROWS); } int hide_panels() const { return int_value(OPTION_HIDE_PANELS); } - rgb_t border_color() const { return rgb_value(OPTION_UI_BORDER_COLOR); } - rgb_t background_color() const { return rgb_value(OPTION_UI_BACKGROUND_COLOR); } - rgb_t gfxviewer_bg_color() const { return rgb_value(OPTION_UI_GFXVIEWER_BG_COLOR); } - rgb_t unavailable_color() const { return rgb_value(OPTION_UI_UNAVAILABLE_COLOR); } - rgb_t text_color() const { return rgb_value(OPTION_UI_TEXT_COLOR); } - rgb_t text_bg_color() const { return rgb_value(OPTION_UI_TEXT_BG_COLOR); } - rgb_t subitem_color() const { return rgb_value(OPTION_UI_SUBITEM_COLOR); } - rgb_t clone_color() const { return rgb_value(OPTION_UI_CLONE_COLOR); } - rgb_t selected_color() const { return rgb_value(OPTION_UI_SELECTED_COLOR); } - rgb_t selected_bg_color() const { return rgb_value(OPTION_UI_SELECTED_BG_COLOR); } - rgb_t mouseover_color() const { return rgb_value(OPTION_UI_MOUSEOVER_COLOR); } - rgb_t mouseover_bg_color() const { return rgb_value(OPTION_UI_MOUSEOVER_BG_COLOR); } - rgb_t mousedown_color() const { return rgb_value(OPTION_UI_MOUSEDOWN_COLOR); } - rgb_t mousedown_bg_color() const { return rgb_value(OPTION_UI_MOUSEDOWN_BG_COLOR); } - rgb_t dipsw_color() const { return rgb_value(OPTION_UI_DIPSW_COLOR); } - rgb_t slider_color() const { return rgb_value(OPTION_UI_SLIDER_COLOR); } - - rgb_t rgb_value(const char *option) const; - + const char *ui_border_color() const { return value(OPTION_UI_BORDER_COLOR); } + const char *ui_bg_color() const { return value(OPTION_UI_BACKGROUND_COLOR); } + const char *ui_gfx_bg_color() const { return value(OPTION_UI_GFXVIEWER_BG_COLOR); } + const char *ui_unavail_color() const { return value(OPTION_UI_UNAVAILABLE_COLOR); } + const char *ui_text_color() const { return value(OPTION_UI_TEXT_COLOR); } + const char *ui_text_bg_color() const { return value(OPTION_UI_TEXT_BG_COLOR); } + const char *ui_subitem_color() const { return value(OPTION_UI_SUBITEM_COLOR); } + const char *ui_clone_color() const { return value(OPTION_UI_CLONE_COLOR); } + const char *ui_selected_color() const { return value(OPTION_UI_SELECTED_COLOR); } + const char *ui_selected_bg_color() const { return value(OPTION_UI_SELECTED_BG_COLOR); } + const char *ui_mouseover_color() const { return value(OPTION_UI_MOUSEOVER_COLOR); } + const char *ui_mouseover_bg_color() const { return value(OPTION_UI_MOUSEOVER_BG_COLOR); } + const char *ui_mousedown_color() const { return value(OPTION_UI_MOUSEDOWN_COLOR); } + const char *ui_mousedown_bg_color() const { return value(OPTION_UI_MOUSEDOWN_BG_COLOR); } + const char *ui_dipsw_color() const { return value(OPTION_UI_DIPSW_COLOR); } + const char *ui_slider_color() const { return value(OPTION_UI_SLIDER_COLOR); } private: static const options_entry s_option_entries[]; }; diff --git a/src/frontend/mame/ui/optsmenu.cpp b/src/frontend/mame/ui/optsmenu.cpp index 497d527e6cf..4452fae9bce 100644 --- a/src/frontend/mame/ui/optsmenu.cpp +++ b/src/frontend/mame/ui/optsmenu.cpp @@ -77,8 +77,8 @@ void menu_simple_game_options::populate(float &customtop, float &custombottom) item_append(menu_item_type::SEPARATOR); item_append(_("Save Configuration"), "", 0, (void *)(uintptr_t)SAVE_CONFIG); - custombottom = 2.0f * ui().get_line_height() + 3.0f * ui().box_tb_border(); - customtop = ui().get_line_height() + 3.0f * ui().box_tb_border(); + custombottom = 2.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; + customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } //------------------------------------------------- @@ -141,9 +141,9 @@ void menu_simple_game_options::custom_render(void *selectedref, float top, float char const *const toptext[] = { _("Settings") }; draw_text_box( std::begin(toptext), std::end(toptext), - origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(), + origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); + UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); } diff --git a/src/frontend/mame/ui/selector.cpp b/src/frontend/mame/ui/selector.cpp index e57012ca5af..3ad8aef995a 100644 --- a/src/frontend/mame/ui/selector.cpp +++ b/src/frontend/mame/ui/selector.cpp @@ -102,7 +102,7 @@ void menu_selector::populate(float &customtop, float &custombottom) } item_append(menu_item_type::SEPARATOR); - customtop = custombottom = ui().get_line_height() + 3.0f * ui().box_tb_border(); + customtop = custombottom = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; m_initial = -1; } @@ -115,17 +115,17 @@ void menu_selector::custom_render(void *selectedref, float top, float bottom, fl std::string tempbuf[1] = { std::string(_("Selection List - Search: ")).append(m_search).append("_") }; draw_text_box( std::begin(tempbuf), std::end(tempbuf), - origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(), + origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); + UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); // get the text for 'UI Select' tempbuf[0] = string_format(_("Double click or press %1$s to select"), machine().input().seq_name(machine().ioport().type_seq(IPT_UI_SELECT, 0, SEQ_TYPE_STANDARD))); draw_text_box( std::begin(tempbuf), std::end(tempbuf), - origx1, origx2, origy2 + ui().box_tb_border(), origy2 + bottom, + origx1, origx2, origy2 + UI_BOX_TB_BORDER, origy2 + bottom, ui::text_layout::CENTER, ui::text_layout::NEVER, false, - ui().colors().text_color(), UI_RED_COLOR, 1.0f); + UI_TEXT_COLOR, UI_RED_COLOR, 1.0f); } //------------------------------------------------- diff --git a/src/frontend/mame/ui/selgame.cpp b/src/frontend/mame/ui/selgame.cpp index ae86b2e2f52..b9a7fffed35 100644 --- a/src/frontend/mame/ui/selgame.cpp +++ b/src/frontend/mame/ui/selgame.cpp @@ -616,8 +616,8 @@ void menu_select_game::populate(float &customtop, float &custombottom) skip_main_items = 0; // configure the custom rendering - customtop = 3.0f * ui().get_line_height() + 5.0f * ui().box_tb_border(); - custombottom = 5.0f * ui().get_line_height() + 3.0f * ui().box_tb_border(); + customtop = 3.0f * ui().get_line_height() + 5.0f * UI_BOX_TB_BORDER; + custombottom = 5.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; // reselect prior game launched, if any if (old_item_selected != -1) diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp index 1833f61528c..40f83946262 100644 --- a/src/frontend/mame/ui/selmenu.cpp +++ b/src/frontend/mame/ui/selmenu.cpp @@ -228,7 +228,7 @@ void menu_select_launch::software_parts::populate(float &customtop, float &custo item_append(elem->first, elem->second, 0, (void *)&*elem); item_append(menu_item_type::SEPARATOR); - customtop = ui().get_line_height() + (3.0f * ui().box_tb_border()); + customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER); } //------------------------------------------------- @@ -261,9 +261,9 @@ void menu_select_launch::software_parts::custom_render(void *selectedref, float char const *const text[] = { _("Software part selection:") }; draw_text_box( std::begin(text), std::end(text), - origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(), + origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); + UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); } @@ -308,7 +308,7 @@ void menu_select_launch::bios_selection::populate(float &customtop, float &custo item_append(elem.first, "", 0, (void *)&elem.first); item_append(menu_item_type::SEPARATOR); - customtop = ui().get_line_height() + (3.0f * ui().box_tb_border()); + customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER); } //------------------------------------------------- @@ -367,9 +367,9 @@ void menu_select_launch::bios_selection::custom_render(void *selectedref, float char const *const text[] = { _("BIOS selection:") }; draw_text_box( std::begin(text), std::end(text), - origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(), + origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); + UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); } @@ -540,7 +540,7 @@ menu_select_launch::system_flags const &menu_select_launch::get_system_flags(gam // aggregate flags emu_options clean_options; machine_config const mconfig(driver, clean_options); - return m_flags.emplace(&driver, machine_static_info(ui().options(), mconfig)).first->second; + return m_flags.emplace(&driver, machine_static_info(mconfig)).first->second; } @@ -590,15 +590,15 @@ void menu_select_launch::custom_render(void *selectedref, float top, float botto // determine the text for the header make_topbox_text(tempbuf[0], tempbuf[1], tempbuf[2]); - float const y1 = origy1 - 3.0f * ui().box_tb_border() - ui().get_line_height(); + float const y1 = origy1 - 3.0f * UI_BOX_TB_BORDER - ui().get_line_height(); draw_text_box( tempbuf, tempbuf + 3, origx1, origx2, origy1 - top, y1, ui::text_layout::CENTER, ui::text_layout::NEVER, true, - ui().colors().text_color(), ui().colors().background_color(), 1.0f); + UI_TEXT_COLOR, UI_BACKGROUND_COLOR, 1.0f); // draw toolbar - draw_toolbar(origx1, y1, origx2, origy1 - ui().box_tb_border()); + draw_toolbar(origx1, y1, origx2, origy1 - UI_BOX_TB_BORDER); // determine the text to render below ui_software_info const *swinfo; @@ -606,7 +606,7 @@ void menu_select_launch::custom_render(void *selectedref, float top, float botto get_selection(swinfo, driver); bool isstar = false; - rgb_t color = ui().colors().background_color(); + rgb_t color = UI_BACKGROUND_COLOR; if (swinfo && ((swinfo->startempty != 1) || !driver)) { isstar = mame_machine_manager::instance()->favorite().is_favorite_system_software(*swinfo); @@ -704,13 +704,13 @@ void menu_select_launch::custom_render(void *selectedref, float top, float botto // draw the footer draw_text_box( std::begin(tempbuf), std::end(tempbuf), - origx1, origx2, origy2 + ui().box_tb_border(), origy2 + bottom, + origx1, origx2, origy2 + UI_BOX_TB_BORDER, origy2 + bottom, ui::text_layout::CENTER, ui::text_layout::NEVER, true, - ui().colors().text_color(), color, 1.0f); + UI_TEXT_COLOR, color, 1.0f); // is favorite? draw the star if (isstar) - draw_star(origx1 + ui().box_lr_border(), origy2 + (2.0f * ui().box_tb_border())); + draw_star(origx1 + UI_BOX_LR_BORDER, origy2 + (2.0f * UI_BOX_TB_BORDER)); } @@ -808,22 +808,22 @@ void menu_select_launch::draw_common_arrow(float origx1, float origy1, float ori float const al_y1 = origy1 + 0.9f * line_height; rgb_t fgcolor_right, fgcolor_left; - fgcolor_right = fgcolor_left = ui().colors().text_color(); + fgcolor_right = fgcolor_left = UI_TEXT_COLOR; // set hover if (mouse_in_rect(ar_x0, ar_y0, ar_x1, ar_y1) && current != dmax) { - ui().draw_textured_box(container(), ar_x0 + 0.01f, ar_y0, ar_x1 - 0.01f, ar_y1, ui().colors().mouseover_bg_color(), rgb_t(43, 43, 43), + ui().draw_textured_box(container(), ar_x0 + 0.01f, ar_y0, ar_x1 - 0.01f, ar_y1, UI_MOUSEOVER_BG_COLOR, rgb_t(43, 43, 43), hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1)); set_hover(HOVER_UI_RIGHT); - fgcolor_right = ui().colors().mouseover_color(); + fgcolor_right = UI_MOUSEOVER_COLOR; } else if (mouse_in_rect(al_x0, al_y0, al_x1, al_y1) && current != dmin) { - ui().draw_textured_box(container(), al_x0 + 0.01f, al_y0, al_x1 - 0.01f, al_y1, ui().colors().mouseover_bg_color(), rgb_t(43, 43, 43), + ui().draw_textured_box(container(), al_x0 + 0.01f, al_y0, al_x1 - 0.01f, al_y1, UI_MOUSEOVER_BG_COLOR, rgb_t(43, 43, 43), hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1)); set_hover(HOVER_UI_LEFT); - fgcolor_left = ui().colors().mouseover_color(); + fgcolor_left = UI_MOUSEOVER_COLOR; } // apply arrow @@ -847,15 +847,15 @@ void menu_select_launch::draw_common_arrow(float origx1, float origy1, float ori void menu_select_launch::draw_info_arrow(int ub, float origx1, float origx2, float oy1, float line_height, float text_size, float ud_arrow_width) { - rgb_t fgcolor = ui().colors().text_color(); + rgb_t fgcolor = UI_TEXT_COLOR; uint32_t orientation = (!ub) ? ROT0 : ROT0 ^ ORIENTATION_FLIP_Y; if (mouse_in_rect(origx1, oy1, origx2, oy1 + (line_height * text_size))) { - ui().draw_textured_box(container(), origx1 + 0.01f, oy1, origx2 - 0.01f, oy1 + (line_height * text_size), ui().colors().mouseover_bg_color(), + ui().draw_textured_box(container(), origx1 + 0.01f, oy1, origx2 - 0.01f, oy1 + (line_height * text_size), UI_MOUSEOVER_BG_COLOR, rgb_t(43, 43, 43), hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1)); set_hover((!ub) ? HOVER_DAT_UP : HOVER_DAT_DOWN); - fgcolor = ui().colors().mouseover_color(); + fgcolor = UI_MOUSEOVER_COLOR; } draw_arrow(0.5f * (origx1 + origx2) - 0.5f * (ud_arrow_width * text_size), oy1 + 0.25f * (line_height * text_size), @@ -883,7 +883,7 @@ float menu_select_launch::draw_left_panel( // calculate line height float const line_height(ui().get_line_height()); float const text_size(ui().options().infos_size()); - float const sc(y2 - y1 - (2.0f * ui().box_tb_border())); + float const sc(y2 - y1 - (2.0f * UI_BOX_TB_BORDER)); float line_height_max(line_height * text_size); if ((Filter::COUNT * line_height_max) > sc) { @@ -904,12 +904,12 @@ float menu_select_launch::draw_left_panel( // outline the box and inset by the border width float const origy1(y1); float const origy2(y2); - x2 = x1 + left_width + 2.0f * ui().box_lr_border();; - ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color()); - x1 += ui().box_lr_border(); - x2 -= ui().box_lr_border(); - y1 += ui().box_tb_border(); - y2 -= ui().box_tb_border(); + x2 = x1 + left_width + 2.0f * UI_BOX_LR_BORDER; + ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR); + x1 += UI_BOX_LR_BORDER; + x2 -= UI_BOX_LR_BORDER; + y1 += UI_BOX_TB_BORDER; + y2 -= UI_BOX_TB_BORDER; // now draw the rows auto const active_filter(filters.find(current)); @@ -931,12 +931,12 @@ float menu_select_launch::draw_left_panel( } // handle mouse hover in passing - rgb_t bgcolor = ui().colors().text_bg_color(); - rgb_t fgcolor = ui().colors().text_color(); + rgb_t bgcolor = UI_TEXT_BG_COLOR; + rgb_t fgcolor = UI_TEXT_COLOR; if (mouse_in_rect(x1, y1, x2, y1 + line_height_max)) { - bgcolor = ui().colors().mouseover_bg_color(); - fgcolor = ui().colors().mouseover_color(); + bgcolor = UI_MOUSEOVER_BG_COLOR; + fgcolor = UI_MOUSEOVER_COLOR; set_hover(HOVER_FILTER_FIRST + filter); highlight(x1, y1, x2, y1 + line_height_max, bgcolor); } @@ -964,8 +964,8 @@ float menu_select_launch::draw_left_panel( y1 += line_height_max; } - x1 = x2 + ui().box_lr_border(); - x2 = x1 + 2.0f * ui().box_lr_border(); + x1 = x2 + UI_BOX_LR_BORDER; + x2 = x1 + 2.0f * UI_BOX_LR_BORDER; y1 = origy1; y2 = origy2; float const space = x2 - x1; @@ -979,15 +979,15 @@ float menu_select_launch::draw_left_panel( ui().draw_outlined_box(container(), x1, y1, x2, y2, rgb_t(0xef, 0x12, 0x47, 0x7b)); - rgb_t fgcolor = ui().colors().text_color(); + rgb_t fgcolor = UI_TEXT_COLOR; if (mouse_in_rect(x1, y1, x2, y2)) { - fgcolor = ui().colors().mouseover_color(); + fgcolor = UI_MOUSEOVER_COLOR; set_hover(HOVER_LPANEL_ARROW); } draw_arrow(ar_x0, ar_y0, ar_x1, ar_y1, fgcolor, ROT90 ^ ORIENTATION_FLIP_X); - return x2 + ui().box_lr_border(); + return x2 + UI_BOX_LR_BORDER; } @@ -1181,10 +1181,10 @@ void menu_select_launch::draw_toolbar(float x1, float y1, float x2, float y2) ui().draw_outlined_box(container(), x1, y1, x2, y2, rgb_t(0xEF, 0x12, 0x47, 0x7B)); // take off the borders - x1 += ui().box_lr_border(); - x2 -= ui().box_lr_border(); - y1 += ui().box_tb_border(); - y2 -= ui().box_tb_border(); + x1 += UI_BOX_LR_BORDER; + x2 -= UI_BOX_LR_BORDER; + y1 += UI_BOX_TB_BORDER; + y2 -= UI_BOX_TB_BORDER; texture_ptr_vector const &t_texture(m_is_swlist ? m_cache->sw_toolbar_texture() : m_cache->toolbar_texture()); bitmap_vector const &t_bitmap(m_is_swlist ? m_cache->sw_toolbar_bitmap() : m_cache->toolbar_bitmap()); @@ -1205,8 +1205,8 @@ void menu_select_launch::draw_toolbar(float x1, float y1, float x2, float y2) { set_hover(HOVER_B_FAV + z); color = rgb_t::white(); - float ypos = y2 + ui().get_line_height() + 2.0f * ui().box_tb_border(); - ui().draw_text_box(container(), _(hover_msg[z]), ui::text_layout::CENTER, 0.5f, ypos, ui().colors().background_color()); + float ypos = y2 + ui().get_line_height() + 2.0f * UI_BOX_TB_BORDER; + ui().draw_text_box(container(), _(hover_msg[z]), ui::text_layout::CENTER, 0.5f, ypos, UI_BACKGROUND_COLOR); } container().add_quad(x1, y1, x2, y2, color, t_texture[z].get(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); @@ -1751,8 +1751,8 @@ void menu_select_launch::draw(uint32_t flags) float const ud_arrow_width = line_height * machine().render().ui_aspect(); float const gutter_width = 0.52f * ud_arrow_width; float const icon_offset = m_has_icons ? (1.5f * ud_arrow_width) : 0.0f; - float right_panel_size = (ui_globals::panels_status == HIDE_BOTH || ui_globals::panels_status == HIDE_RIGHT_PANEL) ? 2.0f * ui().box_lr_border() : 0.3f; - float visible_width = 1.0f - 4.0f * ui().box_lr_border(); + float right_panel_size = (ui_globals::panels_status == HIDE_BOTH || ui_globals::panels_status == HIDE_RIGHT_PANEL) ? 2.0f * UI_BOX_LR_BORDER : 0.3f; + 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; @@ -1770,7 +1770,7 @@ void menu_select_launch::draw(uint32_t flags) map_mouse(); // account for extra space at the top and bottom - float visible_main_menu_height = 1.0f - 2.0f * ui().box_tb_border() - visible_extra_menu_height; + float visible_main_menu_height = 1.0f - 2.0f * UI_BOX_TB_BORDER - visible_extra_menu_height; m_visible_lines = int(std::trunc(visible_main_menu_height / line_height)); visible_main_menu_height = float(m_visible_lines) * line_height; @@ -1787,20 +1787,20 @@ void menu_select_launch::draw(uint32_t flags) visible_top += get_customtop(); // compute left box size - float x1 = visible_left - ui().box_lr_border(); - float y1 = visible_top - ui().box_tb_border(); - float x2 = x1 + 2.0f * ui().box_lr_border(); - float y2 = visible_top + visible_main_menu_height + ui().box_tb_border() + extra_height; + float x1 = visible_left - UI_BOX_LR_BORDER; + float y1 = visible_top - UI_BOX_TB_BORDER; + float x2 = x1 + 2.0f * UI_BOX_LR_BORDER; + float y2 = visible_top + visible_main_menu_height + UI_BOX_TB_BORDER + extra_height; // add left box visible_left = draw_left_panel(x1, y1, x2, y2); - visible_width -= right_panel_size + visible_left - 2.0f * ui().box_lr_border(); + visible_width -= right_panel_size + visible_left - 2.0f * UI_BOX_LR_BORDER; // compute and add main box - x1 = visible_left - ui().box_lr_border(); - x2 = visible_left + visible_width + ui().box_lr_border(); + x1 = visible_left - UI_BOX_LR_BORDER; + x2 = visible_left + visible_width + UI_BOX_LR_BORDER; float line = visible_top + (float(m_visible_lines) * line_height); - ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color()); + ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR); if (visible_items < m_visible_lines) m_visible_lines = visible_items; @@ -1823,9 +1823,9 @@ void menu_select_launch::draw(uint32_t flags) int itemnum = top_line + linenum; const menu_item &pitem = item(itemnum); const char *itemtext = pitem.text.c_str(); - rgb_t fgcolor = ui().colors().text_color(); - rgb_t bgcolor = ui().colors().text_bg_color(); - rgb_t fgcolor3 = ui().colors().clone_color(); + rgb_t fgcolor = UI_TEXT_COLOR; + rgb_t bgcolor = UI_TEXT_BG_COLOR; + rgb_t fgcolor3 = UI_CLONE_COLOR; float line_x0 = x1 + 0.5f * UI_LINE_WIDTH; float line_y0 = line_y; float line_x1 = x2 - 0.5f * UI_LINE_WIDTH; @@ -1850,14 +1850,14 @@ void menu_select_launch::draw(uint32_t flags) else if (itemnum == hover()) { // else if the mouse is over this item, draw with a different background - fgcolor = fgcolor3 = ui().options().mouseover_color(); - bgcolor = ui().colors().mouseover_bg_color(); + fgcolor = fgcolor3 = UI_MOUSEOVER_COLOR; + bgcolor = UI_MOUSEOVER_BG_COLOR; highlight(line_x0, line_y0, line_x1, line_y1, bgcolor); } else if (pitem.ref == m_prev_selected) { - fgcolor = fgcolor3 = ui().options().mouseover_color(); - bgcolor = ui().colors().mouseover_bg_color(); + fgcolor = fgcolor3 = UI_MOUSEOVER_COLOR; + bgcolor = UI_MOUSEOVER_BG_COLOR; ui().draw_textured_box(container(), line_x0 + 0.01f, line_y0, line_x1 - 0.01f, line_y1, bgcolor, rgb_t(43, 43, 43), hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1)); } @@ -1884,7 +1884,7 @@ void menu_select_launch::draw(uint32_t flags) { // if we're just a divider, draw a line container().add_line(visible_left, line_y + 0.5f * line_height, visible_left + visible_width, line_y + 0.5f * line_height, - UI_LINE_WIDTH, ui().colors().text_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); + UI_LINE_WIDTH, UI_TEXT_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } else if (pitem.subtext.empty()) { @@ -1946,8 +1946,8 @@ void menu_select_launch::draw(uint32_t flags) float line_y0 = line; float line_x1 = x2 - 0.5f * UI_LINE_WIDTH; float line_y1 = line + line_height; - rgb_t fgcolor = ui().colors().text_color(); - rgb_t bgcolor = ui().colors().text_bg_color(); + rgb_t fgcolor = UI_TEXT_COLOR; + rgb_t bgcolor = UI_TEXT_BG_COLOR; if (mouse_in_rect(line_x0, line_y0, line_x1, line_y1) && is_selectable(pitem)) set_hover(count); @@ -1963,15 +1963,15 @@ void menu_select_launch::draw(uint32_t flags) // else if the mouse is over this item, draw with a different background else if (count == hover()) { - fgcolor = ui().options().mouseover_color(); - bgcolor = ui().colors().mouseover_bg_color(); + fgcolor = UI_MOUSEOVER_COLOR; + bgcolor = UI_MOUSEOVER_BG_COLOR; highlight(line_x0, line_y0, line_x1, line_y1, bgcolor); } if (pitem.type == menu_item_type::SEPARATOR) { container().add_line(visible_left, line + 0.5f * line_height, visible_left + visible_width, line + 0.5f * line_height, - UI_LINE_WIDTH, ui().colors().text_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); + UI_LINE_WIDTH, UI_TEXT_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } else { @@ -1986,8 +1986,8 @@ void menu_select_launch::draw(uint32_t flags) draw_right_panel(x1, y1, x2, y2); - x1 = primary_left - ui().box_lr_border(); - x2 = primary_left + primary_width + ui().box_lr_border(); + x1 = primary_left - UI_BOX_LR_BORDER; + x2 = primary_left + primary_width + UI_BOX_LR_BORDER; // if there is something special to add, do it by calling the virtual method custom_render(get_selection_ref(), get_customtop(), get_custombottom(), x1, y1, x2, y2); @@ -2014,7 +2014,7 @@ void menu_select_launch::draw(uint32_t flags) void menu_select_launch::draw_right_panel(float origx1, float origy1, float origx2, float origy2) { bool const hide((ui_globals::panels_status == HIDE_RIGHT_PANEL) || (ui_globals::panels_status == HIDE_BOTH)); - float const x2(hide ? origx2 : (origx1 + 2.0f * ui().box_lr_border())); + float const x2(hide ? origx2 : (origx1 + 2.0f * UI_BOX_LR_BORDER)); float const space(x2 - origx1); float const lr_arrow_width(0.4f * space * machine().render().ui_aspect()); @@ -2026,10 +2026,10 @@ void menu_select_launch::draw_right_panel(float origx1, float origy1, float orig ui().draw_outlined_box(container(), origx1, origy1, origx2, origy2, rgb_t(0xEF, 0x12, 0x47, 0x7B)); - rgb_t fgcolor(ui().colors().text_color()); + rgb_t fgcolor(UI_TEXT_COLOR); if (mouse_in_rect(origx1, origy1, x2, origy2)) { - fgcolor = ui().options().mouseover_color(); + fgcolor = UI_MOUSEOVER_COLOR; set_hover(HOVER_RPANEL_ARROW); } @@ -2059,10 +2059,10 @@ float menu_select_launch::draw_right_box_title(float x1, float y1, float x2, flo float const midl = (x2 - x1) * 0.5f; // add outlined box for options - ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color()); + ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR); // add separator line - container().add_line(x1 + midl, y1, x1 + midl, y1 + line_height, UI_LINE_WIDTH, ui().colors().border_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); + container().add_line(x1 + midl, y1, x1 + midl, y1 + line_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); std::string buffer[RP_LAST + 1]; buffer[RP_IMAGES] = _("Images"); @@ -2079,15 +2079,15 @@ float menu_select_launch::draw_right_box_title(float x1, float y1, float x2, flo for (int cells = RP_FIRST; cells <= RP_LAST; ++cells) { - rgb_t bgcolor = ui().colors().text_bg_color(); - rgb_t fgcolor = ui().colors().text_color(); + rgb_t bgcolor = UI_TEXT_BG_COLOR; + rgb_t fgcolor = UI_TEXT_COLOR; if (mouse_in_rect(x1, y1, x1 + midl, y1 + line_height)) { if (ui_globals::rpanel != cells) { - bgcolor = ui().colors().mouseover_bg_color(); - fgcolor = ui().options().mouseover_color(); + bgcolor = UI_MOUSEOVER_BG_COLOR; + fgcolor = UI_MOUSEOVER_COLOR; set_hover(HOVER_RP_FIRST + cells); } } @@ -2095,9 +2095,9 @@ float menu_select_launch::draw_right_box_title(float x1, float y1, float x2, flo if (ui_globals::rpanel != cells) { container().add_line(x1, y1 + line_height, x1 + midl, y1 + line_height, UI_LINE_WIDTH, - ui().colors().border_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); - if (fgcolor != ui().colors().mouseover_color()) - fgcolor = ui().colors().clone_color(); + UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); + if (fgcolor != UI_MOUSEOVER_COLOR) + fgcolor = UI_CLONE_COLOR; } if (m_focus == focused_menu::RIGHTTOP && ui_globals::rpanel == cells) @@ -2107,7 +2107,7 @@ float menu_select_launch::draw_right_box_title(float x1, float y1, float x2, flo ui().draw_textured_box(container(), x1 + UI_LINE_WIDTH, y1 + UI_LINE_WIDTH, x1 + midl - UI_LINE_WIDTH, y1 + line_height, bgcolor, rgb_t(43, 43, 43), hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1)); } - else if (bgcolor == ui().colors().mouseover_bg_color()) + else if (bgcolor == UI_MOUSEOVER_BG_COLOR) { container().add_rect(x1 + UI_LINE_WIDTH, y1 + UI_LINE_WIDTH, x1 + midl - UI_LINE_WIDTH, y1 + line_height, bgcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1)); @@ -2292,8 +2292,8 @@ std::string menu_select_launch::arts_render_common(float origx1, float origy1, f title_size = (std::max)(text_length + 0.01f, title_size); } - rgb_t const fgcolor = (m_focus == focused_menu::RIGHTBOTTOM) ? rgb_t(0xff, 0xff, 0x00) : ui().colors().text_color(); - rgb_t const bgcolor = (m_focus == focused_menu::RIGHTBOTTOM) ? rgb_t(0xff, 0xff, 0xff) : ui().colors().text_bg_color(); + rgb_t const fgcolor = (m_focus == focused_menu::RIGHTBOTTOM) ? rgb_t(0xff, 0xff, 0x00) : UI_TEXT_COLOR; + rgb_t const bgcolor = (m_focus == focused_menu::RIGHTBOTTOM) ? rgb_t(0xff, 0xff, 0xff) : UI_TEXT_BG_COLOR; float const middle = origx2 - origx1; // check size @@ -2301,22 +2301,22 @@ std::string menu_select_launch::arts_render_common(float origx1, float origy1, f float const tmp_size = (sc > middle) ? ((middle - 2.0f * gutter_width) / sc) : 1.0f; title_size *= tmp_size; - if (bgcolor != ui().colors().text_bg_color()) + if (bgcolor != UI_TEXT_BG_COLOR) { ui().draw_textured_box( container(), - origx1 + ((middle - title_size) * 0.5f), origy1 + ui().box_tb_border(), - origx1 + ((middle + title_size) * 0.5f), origy1 + ui().box_tb_border() + line_height, + origx1 + ((middle - title_size) * 0.5f), origy1 + UI_BOX_TB_BORDER, + origx1 + ((middle + title_size) * 0.5f), origy1 + UI_BOX_TB_BORDER + line_height, bgcolor, rgb_t(43, 43, 43), hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1)); } ui().draw_text_full(container(), - snaptext.c_str(), origx1, origy1 + ui().box_tb_border(), origx2 - origx1, + snaptext.c_str(), origx1, origy1 + UI_BOX_TB_BORDER, origx2 - origx1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NORMAL, fgcolor, bgcolor, nullptr, nullptr, tmp_size); - draw_common_arrow(origx1, origy1 + ui().box_tb_border(), origx2, origy2, m_image_view, FIRST_VIEW, LAST_VIEW, title_size); + draw_common_arrow(origx1, origy1 + UI_BOX_TB_BORDER, origx2, origy2, m_image_view, FIRST_VIEW, LAST_VIEW, title_size); return searchstr; } @@ -2348,7 +2348,7 @@ void menu_select_launch::arts_render_images(bitmap_argb32 &&tmp_bitmap, float or if (tmp_bitmap.valid()) { float panel_width = origx2 - origx1 - 0.02f; - float panel_height = origy2 - origy1 - 0.02f - (3.0f * ui().box_tb_border()) - (2.0f * line_height); + float panel_height = origy2 - origy1 - 0.02f - (3.0f * UI_BOX_TB_BORDER) - (2.0f * line_height); int screen_width = machine().render().ui_target().width(); int screen_height = machine().render().ui_target().height(); @@ -2426,8 +2426,8 @@ void menu_select_launch::draw_snapx(float origx1, float origy1, float origx2, fl float const line_height = ui().get_line_height(); float const x1 = origx1 + 0.01f; float const x2 = origx2 - 0.01f; - float const y1 = origy1 + (2.0f * ui().box_tb_border()) + line_height; - float const y2 = origy2 - ui().box_tb_border() - line_height; + float const y1 = origy1 + (2.0f * UI_BOX_TB_BORDER) + line_height; + float const y2 = origy2 - UI_BOX_TB_BORDER - line_height; // apply texture container().add_quad(x1, y1, x2, y2, rgb_t::white(), m_cache->snapx_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); @@ -2499,16 +2499,16 @@ float menu_select_launch::draw_collapsed_left_panel(float x1, float y1, float x2 ui().draw_outlined_box(container(), x1, y1, x2, y2, rgb_t(0xef, 0x12, 0x47, 0x7b)); // FIXME: magic numbers in colour? - rgb_t fgcolor = ui().colors().text_color(); + rgb_t fgcolor = UI_TEXT_COLOR; if (mouse_in_rect(x1, y1, x2, y2)) { - fgcolor = ui().options().mouseover_color(); + fgcolor = UI_MOUSEOVER_COLOR; set_hover(HOVER_LPANEL_ARROW); } draw_arrow(ar_x0, ar_y0, ar_x1, ar_y1, fgcolor, ROT90); - return x2 + ui().box_lr_border(); + return x2 + UI_BOX_LR_BORDER; } @@ -2601,7 +2601,7 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2, return; } - origy1 += ui().box_tb_border(); + origy1 += UI_BOX_TB_BORDER; float gutter_width = 0.4f * line_height * machine().render().ui_aspect() * 1.3f; float ud_arrow_width = line_height * machine().render().ui_aspect(); float oy1 = origy1 + line_height; @@ -2618,14 +2618,14 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2, container(), name, origx1, origy1, origx2 - origx1, ui::text_layout::CENTER, ui::text_layout::NEVER, - mame_ui_manager::NONE, ui().colors().text_color(), ui().colors().text_bg_color(), + mame_ui_manager::NONE, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, &txt_length, nullptr); txt_length += 0.01f; title_size = (std::max)(txt_length, title_size); } - rgb_t fgcolor = ui().colors().text_color(); - rgb_t bgcolor = ui().colors().text_bg_color(); + rgb_t fgcolor = UI_TEXT_COLOR; + rgb_t bgcolor = UI_TEXT_BG_COLOR; if (get_focus() == focused_menu::RIGHTBOTTOM) { fgcolor = rgb_t(0xff, 0xff, 0xff, 0x00); @@ -2639,7 +2639,7 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2, float tmp_size = (sc > middle) ? ((middle - 2.0f * gutter_width) / sc) : 1.0f; title_size *= tmp_size; - if (bgcolor != ui().colors().text_bg_color()) + if (bgcolor != UI_TEXT_BG_COLOR) { ui().draw_textured_box(container(), origx1 + ((middle - title_size) * 0.5f), origy1, origx1 + ((middle + title_size) * 0.5f), origy1 + line_height, bgcolor, rgb_t(255, 43, 43, 43), hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1)); @@ -2718,14 +2718,14 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2, container(), leftcol.c_str(), origx1 + gutter_width, oy1, sc, ui::text_layout::LEFT, ui::text_layout::TRUNCATE, - mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color(), + mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, tmp_size3); ui().draw_text_full( container(), rightcol.c_str(), origx1 + gutter_width, oy1, sc, ui::text_layout::RIGHT, ui::text_layout::TRUNCATE, - mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color(), + mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, tmp_size3); } @@ -2738,7 +2738,7 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2, container(), tempbuf.c_str(), origx1 + gutter_width, oy1, origx2 - origx1, ui::text_layout::LEFT, ui::text_layout::TRUNCATE, - mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color(), + mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, tmp_size3); } @@ -2748,7 +2748,7 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2, container(), tempbuf.c_str(), origx1 + gutter_width, oy1, origx2 - origx1, ui::text_layout::LEFT, ui::text_layout::TRUNCATE, - mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color(), + mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, text_size); } diff --git a/src/frontend/mame/ui/selsoft.cpp b/src/frontend/mame/ui/selsoft.cpp index 4c86aaae9a4..a5b5a5bb594 100644 --- a/src/frontend/mame/ui/selsoft.cpp +++ b/src/frontend/mame/ui/selsoft.cpp @@ -321,8 +321,8 @@ void menu_select_software::populate(float &customtop, float &custombottom) item_append(menu_item_type::SEPARATOR, flags_ui); // configure the custom rendering - customtop = 4.0f * ui().get_line_height() + 5.0f * ui().box_tb_border(); - custombottom = 5.0f * ui().get_line_height() + 4.0f * ui().box_tb_border(); + customtop = 4.0f * ui().get_line_height() + 5.0f * UI_BOX_TB_BORDER; + custombottom = 5.0f * ui().get_line_height() + 4.0f * UI_BOX_TB_BORDER; if (old_software != -1) { diff --git a/src/frontend/mame/ui/simpleselgame.cpp b/src/frontend/mame/ui/simpleselgame.cpp index a2334a3485d..e22e61b6a2b 100644 --- a/src/frontend/mame/ui/simpleselgame.cpp +++ b/src/frontend/mame/ui/simpleselgame.cpp @@ -42,7 +42,7 @@ simple_menu_select_game::simple_menu_select_game(mame_ui_manager &mui, render_co , m_cached_driver(nullptr) , m_cached_flags(machine_flags::NOT_WORKING) , m_cached_unemulated(device_t::feature::NONE), m_cached_imperfect(device_t::feature::NONE) - , m_cached_color(ui().colors().background_color()) + , m_cached_color(UI_BACKGROUND_COLOR) { build_driver_list(); if (gamename) @@ -279,8 +279,8 @@ void simple_menu_select_game::populate(float &customtop, float &custombottom) } // configure the custom rendering - customtop = ui().get_line_height() + 3.0f * ui().box_tb_border(); - custombottom = 4.0f * ui().get_line_height() + 3.0f * ui().box_tb_border(); + customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; + custombottom = 4.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } @@ -302,9 +302,9 @@ void simple_menu_select_game::custom_render(void *selectedref, float top, float // draw the top box draw_text_box( tempbuf, tempbuf + 1, - origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(), + origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - ui().colors().text_color(), ui().colors().background_color(), 1.0f); + UI_TEXT_COLOR, UI_BACKGROUND_COLOR, 1.0f); // determine the text to render below driver = ((uintptr_t)selectedref > skip_main_items) ? (const game_driver *)selectedref : nullptr; @@ -323,7 +323,7 @@ void simple_menu_select_game::custom_render(void *selectedref, float top, float if (driver != m_cached_driver) { emu_options clean_options; - machine_static_info const info(ui().options(), machine_config(*driver, clean_options)); + machine_static_info const info(machine_config(*driver, clean_options)); m_cached_driver = driver; m_cached_flags = info.machine_flags(); m_cached_unemulated = info.unemulated_features(); @@ -384,9 +384,9 @@ void simple_menu_select_game::custom_render(void *selectedref, float top, float // draw the bottom box draw_text_box( tempbuf, tempbuf + 4, - origx1, origx2, origy2 + ui().box_tb_border(), origy2 + bottom, + origx1, origx2, origy2 + UI_BOX_TB_BORDER, origy2 + bottom, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, true, - ui().colors().text_color(), driver ? m_cached_color : ui().colors().background_color(), 1.0f); + UI_TEXT_COLOR, driver ? m_cached_color : UI_BACKGROUND_COLOR, 1.0f); } diff --git a/src/frontend/mame/ui/sliders.cpp b/src/frontend/mame/ui/sliders.cpp index 12e15f1a19b..579a0cbc640 100644 --- a/src/frontend/mame/ui/sliders.cpp +++ b/src/frontend/mame/ui/sliders.cpp @@ -193,7 +193,7 @@ void menu_sliders::populate(float &customtop, float &custombottom) } } - custombottom = 2.0f * ui().get_line_height() + 2.0f * ui().box_tb_border(); + custombottom = 2.0f * ui().get_line_height() + 2.0f * UI_BOX_TB_BORDER; } //------------------------------------------------- @@ -224,23 +224,23 @@ void menu_sliders::custom_render(void *selectedref, float top, float bottom, flo tempstring.insert(0, " ").insert(0, curslider->description); // move us to the bottom of the screen, and expand to full width - y2 = 1.0f - ui().box_tb_border(); + y2 = 1.0f - UI_BOX_TB_BORDER; y1 = y2 - bottom; - x1 = ui().box_lr_border(); - x2 = 1.0f - ui().box_lr_border(); + x1 = UI_BOX_LR_BORDER; + x2 = 1.0f - UI_BOX_LR_BORDER; // draw extra menu area - ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color()); - y1 += ui().box_tb_border(); - + ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR); + y1 += UI_BOX_TB_BORDER; + // determine the text height - ui().draw_text_full(container(), tempstring.c_str(), 0, 0, x2 - x1 - 2.0f * ui().box_lr_border(), + ui().draw_text_full(container(), tempstring.c_str(), 0, 0, x2 - x1 - 2.0f * UI_BOX_LR_BORDER, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), nullptr, &text_height); // draw the thermometer - bar_left = x1 + ui().box_lr_border(); + bar_left = x1 + UI_BOX_LR_BORDER; bar_area_top = y1; - bar_width = x2 - x1 - 2.0f * ui().box_lr_border(); + bar_width = x2 - x1 - 2.0f * UI_BOX_LR_BORDER; bar_area_height = line_height; // compute positions @@ -250,19 +250,19 @@ void menu_sliders::custom_render(void *selectedref, float top, float bottom, flo current_x = bar_left + bar_width * percentage; // fill in the percentage - container().add_rect(bar_left, bar_top, current_x, bar_bottom, ui().colors().slider_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); + container().add_rect(bar_left, bar_top, current_x, bar_bottom, UI_SLIDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); // draw the top and bottom lines - container().add_line(bar_left, bar_top, bar_left + bar_width, bar_top, UI_LINE_WIDTH, ui().colors().border_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); - container().add_line(bar_left, bar_bottom, bar_left + bar_width, bar_bottom, UI_LINE_WIDTH, ui().colors().border_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); + container().add_line(bar_left, bar_top, bar_left + bar_width, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); + container().add_line(bar_left, bar_bottom, bar_left + bar_width, bar_bottom, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); // draw default marker - container().add_line(default_x, bar_area_top, default_x, bar_top, UI_LINE_WIDTH, ui().colors().border_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); - container().add_line(default_x, bar_bottom, default_x, bar_area_top + bar_area_height, UI_LINE_WIDTH, ui().colors().border_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); + container().add_line(default_x, bar_area_top, default_x, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); + container().add_line(default_x, bar_bottom, default_x, bar_area_top + bar_area_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); // draw the actual text - ui().draw_text_full(container(), tempstring.c_str(), x1 + ui().box_lr_border(), y1 + line_height, x2 - x1 - 2.0f * ui().box_lr_border(), - ui::text_layout::CENTER, ui::text_layout::WORD, mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color(), nullptr, &text_height); + ui().draw_text_full(container(), tempstring.c_str(), x1 + UI_BOX_LR_BORDER, y1 + line_height, x2 - x1 - 2.0f * UI_BOX_LR_BORDER, + ui::text_layout::CENTER, ui::text_layout::WORD, mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, &text_height); } } diff --git a/src/frontend/mame/ui/slotopt.cpp b/src/frontend/mame/ui/slotopt.cpp index 01493173731..b41e7f4c935 100644 --- a/src/frontend/mame/ui/slotopt.cpp +++ b/src/frontend/mame/ui/slotopt.cpp @@ -203,7 +203,7 @@ void menu_slot_devices::populate(float &customtop, float &custombottom) item_append(_("Reset"), "", 0, ITEMREF_RESET); // leave space for the name of the current option at the bottom - custombottom = ui().get_line_height() + 3.0f * ui().box_tb_border(); + custombottom = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } @@ -220,9 +220,9 @@ void menu_slot_devices::custom_render(void *selectedref, float top, float bottom char const *const text[] = { option ? option->devtype().fullname() : _("[empty slot]") }; draw_text_box( std::begin(text), std::end(text), - origx1, origx2, origy2 + ui().box_tb_border(), origy2 + bottom, + origx1, origx2, origy2 + UI_BOX_TB_BORDER, origy2 + bottom, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - ui().colors().text_color(), ui().colors().background_color(), 1.0f); + UI_TEXT_COLOR, UI_BACKGROUND_COLOR, 1.0f); } } diff --git a/src/frontend/mame/ui/sndmenu.cpp b/src/frontend/mame/ui/sndmenu.cpp index 01397bd8f74..501e8ffea1e 100644 --- a/src/frontend/mame/ui/sndmenu.cpp +++ b/src/frontend/mame/ui/sndmenu.cpp @@ -137,7 +137,7 @@ void menu_sound_options::populate(float &customtop, float &custombottom) item_append_on_off(_("Use External Samples"), m_samples, 0, (void *)(uintptr_t)ENABLE_SAMPLES); item_append(menu_item_type::SEPARATOR); - customtop = ui().get_line_height() + (3.0f * ui().box_tb_border()); + customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER); } //------------------------------------------------- @@ -149,9 +149,9 @@ void menu_sound_options::custom_render(void *selectedref, float top, float botto char const *const toptext[] = { _("Sound Options") }; draw_text_box( std::begin(toptext), std::end(toptext), - origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(), + origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); + UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); } } // namespace ui diff --git a/src/frontend/mame/ui/state.cpp b/src/frontend/mame/ui/state.cpp index f66b5af4a9a..28d47040d60 100644 --- a/src/frontend/mame/ui/state.cpp +++ b/src/frontend/mame/ui/state.cpp @@ -203,8 +203,8 @@ void menu_load_save_state_base::populate(float &customtop, float &custombottom) } // set up custom render proc - customtop = ui().get_line_height() + 3.0f * ui().box_tb_border(); - custombottom = ui().get_line_height() + 3.0f * ui().box_tb_border(); + customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; + custombottom = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; // pause if appropriate if (!m_pause_checked) diff --git a/src/frontend/mame/ui/submenu.cpp b/src/frontend/mame/ui/submenu.cpp index f9cff799c1f..598e4182540 100644 --- a/src/frontend/mame/ui/submenu.cpp +++ b/src/frontend/mame/ui/submenu.cpp @@ -410,7 +410,7 @@ void submenu::populate(float &customtop, float &custombottom) } item_append(menu_item_type::SEPARATOR); - custombottom = customtop = ui().get_line_height() + (3.0f * ui().box_tb_border()); + custombottom = customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER); } //------------------------------------------------- @@ -422,9 +422,9 @@ void submenu::custom_render(void *selectedref, float top, float bottom, float or char const *const toptext[] = { _(m_options[0].description) }; draw_text_box( std::begin(toptext), std::end(toptext), - origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(), + origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); + UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); if (selectedref) { @@ -434,9 +434,9 @@ void submenu::custom_render(void *selectedref, float top, float bottom, float or char const *const bottomtext[] = { selected_sm_option.entry->description() }; draw_text_box( std::begin(bottomtext), std::end(bottomtext), - origx1, origx2, origy2 + ui().box_tb_border(), origy2 + bottom, + origx1, origx2, origy2 + UI_BOX_TB_BORDER, origy2 + bottom, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - ui().colors().text_color(), UI_RED_COLOR, 1.0f); + UI_TEXT_COLOR, UI_RED_COLOR, 1.0f); } } } diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp index 62b84281b02..a0b55307dc6 100644 --- a/src/frontend/mame/ui/ui.cpp +++ b/src/frontend/mame/ui/ui.cpp @@ -30,6 +30,7 @@ #include "ui/state.h" #include "ui/viewgfx.h" #include "imagedev/cassette.h" +#include "config.h" #include "../osd/modules/lib/osdobj_common.h" @@ -93,6 +94,25 @@ static input_item_id const non_char_keys[] = ITEM_ID_CANCEL }; +static char const *const s_color_list[] = { + OPTION_UI_BORDER_COLOR, + OPTION_UI_BACKGROUND_COLOR, + OPTION_UI_GFXVIEWER_BG_COLOR, + OPTION_UI_UNAVAILABLE_COLOR, + OPTION_UI_TEXT_COLOR, + OPTION_UI_TEXT_BG_COLOR, + OPTION_UI_SUBITEM_COLOR, + OPTION_UI_CLONE_COLOR, + OPTION_UI_SELECTED_COLOR, + OPTION_UI_SELECTED_BG_COLOR, + OPTION_UI_MOUSEOVER_COLOR, + OPTION_UI_MOUSEOVER_BG_COLOR, + OPTION_UI_MOUSEDOWN_COLOR, + OPTION_UI_MOUSEDOWN_BG_COLOR, + OPTION_UI_DIPSW_COLOR, + OPTION_UI_SLIDER_COLOR +}; + /*************************************************************************** GLOBAL VARIABLES ***************************************************************************/ @@ -165,8 +185,7 @@ mame_ui_manager::mame_ui_manager(running_machine &machine) , m_popup_text_end(0) , m_mouse_bitmap(32, 32) , m_mouse_arrow_texture(nullptr) - , m_mouse_show(false) - , m_target_font_height(0) {} + , m_mouse_show(false) {} mame_ui_manager::~mame_ui_manager() { @@ -179,12 +198,10 @@ void mame_ui_manager::init() ui::menu::init(machine(), options()); ui_gfx_init(machine()); - m_ui_colors.refresh(options()); - - // update font row info from setting - update_target_font_height(); + get_font_rows(&machine()); + decode_ui_color(0, &machine()); - // more initialization + // more initialisation using namespace std::placeholders; set_handler(ui_callback_type::GENERAL, std::bind(&mame_ui_manager::handler_messagebox, this, _1)); m_non_char_keys_down = std::make_unique<uint8_t[]>((ARRAY_LENGTH(non_char_keys) + 7) / 8); @@ -192,6 +209,8 @@ void mame_ui_manager::init() // request a callback upon exiting machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(&mame_ui_manager::exit, this)); + // register callbacks + machine().configuration().config_register("sliders", config_load_delegate(&mame_ui_manager::config_load, this), config_save_delegate(&mame_ui_manager::config_save, this)); // create mouse bitmap uint32_t *dst = &m_mouse_bitmap.pix32(0); @@ -202,16 +221,6 @@ void mame_ui_manager::init() //------------------------------------------------- -// update_target_font_height -//------------------------------------------------- - -void mame_ui_manager::update_target_font_height() -{ - m_target_font_height = 1.0f / options().font_rows(); -} - - -//------------------------------------------------- // exit - clean up ourselves on exit //------------------------------------------------- @@ -302,7 +311,7 @@ void mame_ui_manager::display_startup_screens(bool first_time) for (int state = 0; state < maxstate && !machine().scheduled_event_pending() && !ui::menu::stack_has_special_main_menu(machine()); state++) { // default to standard colors - messagebox_backcolor = colors().background_color(); + messagebox_backcolor = UI_BACKGROUND_COLOR; messagebox_text.clear(); // pick the next state @@ -369,7 +378,7 @@ void mame_ui_manager::set_startup_text(const char *text, bool force) // copy in the new text messagebox_text.assign(text); - messagebox_backcolor = colors().background_color(); + messagebox_backcolor = UI_BACKGROUND_COLOR; // don't update more than 4 times/second if (force || (curtime - lastupdatetime) > osd_ticks_per_second() / 4) @@ -416,7 +425,8 @@ void mame_ui_manager::update_and_render(render_container &container) m_popup_text_end = 0; // display the internal mouse cursor - if (m_mouse_show || (is_menu_active() && machine().options().ui_mouse())) + if (machine().options().ui_mouse() && (m_mouse_show || is_menu_active())) //MESSUI - (NEWUI) system pointer always on; MAME pointer always off +// if (m_mouse_show || (is_menu_active() && machine().options().ui_mouse())) { int32_t mouse_target_x, mouse_target_y; bool mouse_button; @@ -428,7 +438,7 @@ void mame_ui_manager::update_and_render(render_container &container) if (mouse_target->map_point_container(mouse_target_x, mouse_target_y, container, mouse_x, mouse_y)) { const float cursor_size = 0.6 * get_line_height(); - container.add_quad(mouse_x, mouse_y, mouse_x + cursor_size * container.manager().ui_aspect(&container), mouse_y + cursor_size, colors().text_color(), m_mouse_arrow_texture, PRIMFLAG_ANTIALIAS(1) | PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); + container.add_quad(mouse_x, mouse_y, mouse_x + cursor_size * container.manager().ui_aspect(&container), mouse_y + cursor_size, UI_TEXT_COLOR, m_mouse_arrow_texture, PRIMFLAG_ANTIALIAS(1) | PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } } } @@ -472,7 +482,7 @@ float mame_ui_manager::get_line_height() one_to_one_line_height = (float)raw_font_pixel_height / (float)target_pixel_height; // determine the scale factor - scale_factor = target_font_height() / one_to_one_line_height; + scale_factor = UI_TARGET_FONT_HEIGHT / one_to_one_line_height; // if our font is small-ish, do integral scaling if (raw_font_pixel_height < 24) @@ -530,7 +540,7 @@ float mame_ui_manager::get_string_width(const char *s, float text_size) void mame_ui_manager::draw_outlined_box(render_container &container, float x0, float y0, float x1, float y1, rgb_t backcolor) { - draw_outlined_box(container, x0, y0, x1, y1, colors().border_color(), backcolor); + draw_outlined_box(container, x0, y0, x1, y1, UI_BORDER_COLOR, backcolor); } @@ -556,7 +566,7 @@ void mame_ui_manager::draw_outlined_box(render_container &container, float x0, f void mame_ui_manager::draw_text(render_container &container, const char *buf, float x, float y) { - draw_text_full(container, buf, x, y, 1.0f - x, ui::text_layout::LEFT, ui::text_layout::WORD, mame_ui_manager::NORMAL, colors().text_color(), colors().text_bg_color(), nullptr, nullptr); + draw_text_full(container, buf, x, y, 1.0f - x, ui::text_layout::LEFT, ui::text_layout::WORD, mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); } @@ -598,7 +608,7 @@ void mame_ui_manager::draw_text_full(render_container &container, const char *or void mame_ui_manager::draw_text_box(render_container &container, const char *text, ui::text_layout::text_justify justify, float xpos, float ypos, rgb_t backcolor) { // cap the maximum width - float maximum_width = 1.0f - box_lr_border() * 2; + float maximum_width = 1.0f - UI_BOX_LR_BORDER * 2; // create a layout ui::text_layout layout = create_layout(container, maximum_width, justify); @@ -622,15 +632,15 @@ void mame_ui_manager::draw_text_box(render_container &container, ui::text_layout auto actual_left = layout.actual_left(); auto actual_width = layout.actual_width(); auto actual_height = layout.actual_height(); - auto x = std::min(std::max(xpos - actual_width / 2, box_lr_border()), 1.0f - actual_width - box_lr_border()); - auto y = std::min(std::max(ypos - actual_height / 2, box_tb_border()), 1.0f - actual_height - box_tb_border()); + auto x = std::min(std::max(xpos - actual_width / 2, UI_BOX_LR_BORDER), 1.0f - actual_width - UI_BOX_LR_BORDER); + auto y = std::min(std::max(ypos - actual_height / 2, UI_BOX_TB_BORDER), 1.0f - actual_height - UI_BOX_TB_BORDER); // add a box around that draw_outlined_box(container, - x - box_lr_border(), - y - box_tb_border(), - x + actual_width + box_lr_border(), - y + actual_height + box_tb_border(), backcolor); + x - UI_BOX_LR_BORDER, + y - UI_BOX_TB_BORDER, + x + actual_width + UI_BOX_LR_BORDER, + y + actual_height + UI_BOX_TB_BORDER, backcolor); // emit the text layout.emit(container, x - actual_left, y); @@ -644,7 +654,7 @@ void mame_ui_manager::draw_text_box(render_container &container, ui::text_layout void mame_ui_manager::draw_message_window(render_container &container, const char *text) { - draw_text_box(container, text, ui::text_layout::text_justify::LEFT, 0.5f, 0.5f, colors().background_color()); + draw_text_box(container, text, ui::text_layout::text_justify::LEFT, 0.5f, 0.5f, UI_BACKGROUND_COLOR); } @@ -1022,8 +1032,8 @@ void mame_ui_manager::image_handler_ingame() if (!layout.empty()) { float x = 0.2f; - float y = 0.5f * get_line_height() + 2.0f * box_tb_border(); - draw_text_box(machine().render().ui_container(), layout, x, y, colors().background_color()); + float y = 0.5f * get_line_height() + 2.0f * UI_BOX_TB_BORDER; + draw_text_box(machine().render().ui_container(), layout, x, y, UI_BACKGROUND_COLOR); } } } @@ -1512,6 +1522,7 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine } } #endif + config_apply(); std::vector<ui::menu_item> items; for (auto &slider : m_sliders) @@ -2073,11 +2084,45 @@ void mame_ui_manager::draw_textured_box(render_container &container, float x0, f container.add_line(x0, y1, x0, y0, UI_LINE_WIDTH, linecolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } +//------------------------------------------------- +// decode UI color options +//------------------------------------------------- + +rgb_t decode_ui_color(int id, running_machine *machine) +{ + static rgb_t color[ARRAY_LENGTH(s_color_list)]; + + if (machine != nullptr) { + ui_options option; + for (int x = 0; x < ARRAY_LENGTH(s_color_list); ++x) { + const char *o_default = option.value(s_color_list[x]); + const char *s_option = mame_machine_manager::instance()->ui().options().value(s_color_list[x]); + int len = strlen(s_option); + if (len != 8) + color[x] = rgb_t((uint32_t)strtoul(o_default, nullptr, 16)); + else + color[x] = rgb_t((uint32_t)strtoul(s_option, nullptr, 16)); + } + } + return color[id]; +} + +//------------------------------------------------- +// get font rows from options +//------------------------------------------------- + +int get_font_rows(running_machine *machine) +{ + static int value; + + return ((machine != nullptr) ? value = mame_machine_manager::instance()->ui().options().font_rows() : value); +} + void mame_ui_manager::popup_time_string(int seconds, std::string message) { // extract the text messagebox_poptext = message; - messagebox_backcolor = colors().background_color(); + messagebox_backcolor = UI_BACKGROUND_COLOR; // set a timer m_popup_text_end = osd_ticks() + osd_ticks_per_second() * seconds; @@ -2197,22 +2242,80 @@ void mame_ui_manager::menu_reset() ui::menu::stack_reset(machine()); } -void ui_colors::refresh(const ui_options &options) -{ - m_border_color = options.border_color(); - m_background_color = options.background_color(); - m_gfxviewer_bg_color = options.gfxviewer_bg_color(); - m_unavailable_color = options.unavailable_color(); - m_text_color = options.text_color(); - m_text_bg_color = options.text_bg_color(); - m_subitem_color = options.subitem_color(); - m_clone_color = options.clone_color(); - m_selected_color = options.selected_color(); - m_selected_bg_color = options.selected_bg_color(); - m_mouseover_color = options.mouseover_color(); - m_mouseover_bg_color = options.mouseover_bg_color(); - m_mousedown_color = options.mousedown_color(); - m_mousedown_bg_color = options.mousedown_bg_color(); - m_dipsw_color = options.dipsw_color(); - m_slider_color = options.slider_color(); + +//------------------------------------------------- +// config_load - read data from the +// configuration file +//------------------------------------------------- + +void mame_ui_manager::config_load(config_type cfg_type, util::xml::data_node const *parentnode) +{ + // we only care about game files + if (cfg_type != config_type::GAME) + return; + + // might not have any data + if (parentnode == nullptr) + return; + + // iterate over slider nodes + for (util::xml::data_node const *slider_node = parentnode->get_child("slider"); slider_node; slider_node = slider_node->get_next_sibling("slider")) + { + const char *desc = slider_node->get_attribute_string("desc", ""); + int32_t saved_val = slider_node->get_attribute_int("value", 0); + + // create a dummy slider to store the saved value + m_sliders_saved.push_back(slider_alloc(0, desc, 0, saved_val, 0, 0, 0)); + } +} + + +//------------------------------------------------- +// config_appy - apply data from the conf. file +// This currently needs to be done on a separate +// step because sliders are not created yet when +// configuration file is loaded +//------------------------------------------------- + +void mame_ui_manager::config_apply(void) +{ + // iterate over sliders and restore saved values + for (auto &slider : m_sliders) + { + for (auto &slider_saved : m_sliders_saved) + { + if (!strcmp(slider->description.c_str(), slider_saved->description.c_str())) + { + std::string tempstring; + slider->update(machine(), slider->arg, slider->id, &tempstring, slider_saved->defval); + break; + } + } + } +} + + +//------------------------------------------------- +// config_save - save data to the configuration +// file +//------------------------------------------------- + +void mame_ui_manager::config_save(config_type cfg_type, util::xml::data_node *parentnode) +{ + // we only care about game files + if (cfg_type != config_type::GAME) + return; + + std::string tempstring; + util::xml::data_node *slider_node; + + // save UI sliders + for (auto &slider : m_sliders) + { + int32_t curval = slider->update(machine(), slider->arg, slider->id, &tempstring, SLIDER_NOCHANGE); + slider_node = parentnode->add_child("slider", nullptr); + slider_node->set_attribute("desc", slider->description.c_str()); + slider_node->set_attribute_int("value", curval); + } } + diff --git a/src/frontend/mame/ui/ui.h b/src/frontend/mame/ui/ui.h index 64189344dcb..9f37485e260 100644 --- a/src/frontend/mame/ui/ui.h +++ b/src/frontend/mame/ui/ui.h @@ -33,15 +33,39 @@ class machine_info; CONSTANTS ***************************************************************************/ +/* preferred font height; use ui_get_line_height() to get actual height */ +#define UI_TARGET_FONT_ROWS get_font_rows() + +#define UI_TARGET_FONT_HEIGHT (1.0f / (float)UI_TARGET_FONT_ROWS) #define UI_MAX_FONT_HEIGHT (1.0f / 15.0f) /* width of lines drawn in the UI */ #define UI_LINE_WIDTH (1.0f / 500.0f) +/* border between outlines and inner text on left/right and top/bottom sides */ +#define UI_BOX_LR_BORDER (UI_TARGET_FONT_HEIGHT * 0.25f) +#define UI_BOX_TB_BORDER (UI_TARGET_FONT_HEIGHT * 0.25f) + /* handy colors */ #define UI_GREEN_COLOR rgb_t(0xef,0x10,0x60,0x10) #define UI_YELLOW_COLOR rgb_t(0xef,0x60,0x60,0x10) #define UI_RED_COLOR rgb_t(0xf0,0x60,0x10,0x10) +#define UI_BORDER_COLOR decode_ui_color(0) +#define UI_BACKGROUND_COLOR decode_ui_color(1) +#define UI_GFXVIEWER_BG_COLOR decode_ui_color(2) +#define UI_UNAVAILABLE_COLOR decode_ui_color(3) +#define UI_TEXT_COLOR decode_ui_color(4) +#define UI_TEXT_BG_COLOR decode_ui_color(5) +#define UI_SUBITEM_COLOR decode_ui_color(6) +#define UI_CLONE_COLOR decode_ui_color(7) +#define UI_SELECTED_COLOR decode_ui_color(8) +#define UI_SELECTED_BG_COLOR decode_ui_color(9) +#define UI_MOUSEOVER_COLOR decode_ui_color(10) +#define UI_MOUSEOVER_BG_COLOR decode_ui_color(11) +#define UI_MOUSEDOWN_COLOR decode_ui_color(12) +#define UI_MOUSEDOWN_BG_COLOR decode_ui_color(13) +#define UI_DIPSW_COLOR decode_ui_color(14) +#define UI_SLIDER_COLOR decode_ui_color(15) /* cancel return value for a UI handler */ #define UI_HANDLER_CANCEL ((uint32_t)~0) @@ -115,49 +139,6 @@ enum class ui_callback_type VIEWER }; -// ======================> ui_colors - -class ui_colors -{ -public: - rgb_t border_color() const { return m_border_color; } - rgb_t background_color() const { return m_background_color; } - rgb_t gfxviewer_bg_color() const { return m_gfxviewer_bg_color; } - rgb_t unavailable_color() const { return m_unavailable_color; } - rgb_t text_color() const { return m_text_color; } - rgb_t text_bg_color() const { return m_text_bg_color; } - rgb_t subitem_color() const { return m_subitem_color; } - rgb_t clone_color() const { return m_clone_color; } - rgb_t selected_color() const { return m_selected_color; } - rgb_t selected_bg_color() const { return m_selected_bg_color; } - rgb_t mouseover_color() const { return m_mouseover_color; } - rgb_t mouseover_bg_color() const { return m_mouseover_bg_color; } - rgb_t mousedown_color() const { return m_mousedown_color; } - rgb_t mousedown_bg_color() const { return m_mousedown_bg_color; } - rgb_t dipsw_color() const { return m_dipsw_color; } - rgb_t slider_color() const { return m_slider_color; } - - void refresh(const ui_options &options); - -private: - rgb_t m_border_color; - rgb_t m_background_color; - rgb_t m_gfxviewer_bg_color; - rgb_t m_unavailable_color; - rgb_t m_text_color; - rgb_t m_text_bg_color; - rgb_t m_subitem_color; - rgb_t m_clone_color; - rgb_t m_selected_color; - rgb_t m_selected_bg_color; - rgb_t m_mouseover_color; - rgb_t m_mouseover_bg_color; - rgb_t m_mousedown_color; - rgb_t m_mousedown_bg_color; - rgb_t m_dipsw_color; - rgb_t m_slider_color; -}; - // ======================> mame_ui_manager class mame_ui_manager : public ui_manager, public slider_changed_notifier @@ -180,7 +161,6 @@ public: running_machine &machine() const { return m_machine; } bool single_step() const { return m_single_step; } ui_options &options() { return m_ui_options; } - ui_colors &colors() { return m_ui_colors; } ui::machine_info &machine_info() const { assert(m_machine_info); return *m_machine_info; } // setters @@ -235,15 +215,14 @@ public: void start_save_state(); void start_load_state(); + // config callbacks + void config_load(config_type cfg_type, util::xml::data_node const *parentnode); + void config_save(config_type cfg_type, util::xml::data_node *parentnode); + void config_apply(void); + // slider controls std::vector<ui::menu_item>& get_slider_list(void); - // metrics - float target_font_height() const { return m_target_font_height; } - float box_lr_border() const { return target_font_height() * 0.25f; } - float box_tb_border() const { return target_font_height() * 0.25f; } - void update_target_font_height(); - // other void process_natural_keyboard(); ui::text_layout create_layout(render_container &container, float width = 1.0, ui::text_layout::text_justify justify = ui::text_layout::LEFT, ui::text_layout::word_wrapping wrap = ui::text_layout::WORD); @@ -273,8 +252,6 @@ private: render_texture * m_mouse_arrow_texture; bool m_mouse_show; ui_options m_ui_options; - ui_colors m_ui_colors; - float m_target_font_height; std::unique_ptr<ui::machine_info> m_machine_info; @@ -327,12 +304,15 @@ private: #endif std::vector<std::unique_ptr<slider_state>> m_sliders; + std::vector<std::unique_ptr<slider_state>> m_sliders_saved; }; /*************************************************************************** FUNCTION PROTOTYPES ***************************************************************************/ +rgb_t decode_ui_color(int id, running_machine *machine = nullptr); +int get_font_rows(running_machine *machine = nullptr); template <typename Format, typename... Params> inline void mame_ui_manager::popup_time(int seconds, Format &&fmt, Params &&... args) diff --git a/src/frontend/mame/ui/utils.cpp b/src/frontend/mame/ui/utils.cpp index 58ee1e09f8d..7511a219bf8 100644 --- a/src/frontend/mame/ui/utils.cpp +++ b/src/frontend/mame/ui/utils.cpp @@ -356,9 +356,9 @@ private: char const *const text[] = { _("Select custom filters:") }; draw_text_box( std::begin(text), std::end(text), - x, x2, y - top, y - ui().box_tb_border(), + x, x2, y - top, y - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::NEVER, false, - ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); + UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); } private: @@ -525,7 +525,7 @@ void composite_filter_impl_base<Impl, Base, Type>::menu_configure::populate(floa item_append(menu_item_type::SEPARATOR); // leave space for heading - customtop = ui().get_line_height() + 3.0f * ui().box_tb_border(); + customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } template <class Impl, class Base, typename Base::type Type> @@ -966,9 +966,9 @@ private: char const *const text[] = { _("Select category:") }; draw_text_box( std::begin(text), std::end(text), - x, x2, y - top, y - ui().box_tb_border(), + x, x2, y - top, y - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::NEVER, false, - ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); + UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); } private: @@ -1055,7 +1055,7 @@ void category_machine_filter::menu_configure::populate(float &customtop, float & } } item_append(menu_item_type::SEPARATOR); - customtop = ui().get_line_height() + 3.0f * ui().box_tb_border(); + customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } void category_machine_filter::menu_configure::handle() diff --git a/src/frontend/mame/ui/viewgfx.cpp b/src/frontend/mame/ui/viewgfx.cpp index 1dd210fa88a..ff9ebd08016 100644 --- a/src/frontend/mame/ui/viewgfx.cpp +++ b/src/frontend/mame/ui/viewgfx.cpp @@ -437,7 +437,7 @@ static void palette_handler(mame_ui_manager &mui, render_container &container, u x0 = boxbounds.x0 - (0.5f - 0.5f * (titlewidth + chwidth)); // go ahead and draw the outer box now - mui.draw_outlined_box(container, boxbounds.x0 - x0, boxbounds.y0, boxbounds.x1 + x0, boxbounds.y1, mui.colors().gfxviewer_bg_color()); + mui.draw_outlined_box(container, boxbounds.x0 - x0, boxbounds.y0, boxbounds.x1 + x0, boxbounds.y1, UI_GFXVIEWER_BG_COLOR); // draw the title x0 = 0.5f - 0.5f * titlewidth; @@ -731,7 +731,7 @@ static void gfxset_handler(mame_ui_manager &mui, render_container &container, ui x0 = boxbounds.x0 - (0.5f - 0.5f * (titlewidth + chwidth)); // go ahead and draw the outer box now - mui.draw_outlined_box(container, boxbounds.x0 - x0, boxbounds.y0, boxbounds.x1 + x0, boxbounds.y1, mui.colors().gfxviewer_bg_color()); + mui.draw_outlined_box(container, boxbounds.x0 - x0, boxbounds.y0, boxbounds.x1 + x0, boxbounds.y1, UI_GFXVIEWER_BG_COLOR); // draw the title x0 = 0.5f - 0.5f * titlewidth; @@ -1140,7 +1140,7 @@ static void tilemap_handler(mame_ui_manager &mui, render_container &container, u } // go ahead and draw the outer box now - mui.draw_outlined_box(container, boxbounds.x0, boxbounds.y0, boxbounds.x1, boxbounds.y1, mui.colors().gfxviewer_bg_color()); + mui.draw_outlined_box(container, boxbounds.x0, boxbounds.y0, boxbounds.x1, boxbounds.y1, UI_GFXVIEWER_BG_COLOR); // draw the title x0 = 0.5f - 0.5f * titlewidth; |