diff options
Diffstat (limited to 'src/frontend/mame/ui/custui.cpp')
-rw-r--r-- | src/frontend/mame/ui/custui.cpp | 136 |
1 files changed, 83 insertions, 53 deletions
diff --git a/src/frontend/mame/ui/custui.cpp b/src/frontend/mame/ui/custui.cpp index 861fc99bc90..6eb4352e0c5 100644 --- a/src/frontend/mame/ui/custui.cpp +++ b/src/frontend/mame/ui/custui.cpp @@ -20,7 +20,7 @@ #include "osdepend.h" namespace ui { -std::vector<std::string> menu_custom_ui::hide_status = { +const char *const menu_custom_ui::hide_status[] = { __("Show All"), __("Hide Filters"), __("Hide Info/Image"), @@ -30,8 +30,7 @@ std::vector<std::string> menu_custom_ui::hide_status = { // ctor //------------------------------------------------- -menu_custom_ui::menu_custom_ui(mame_ui_manager &mui, render_container *container) - : menu(mui, container) +menu_custom_ui::menu_custom_ui(mame_ui_manager &mui, render_container *container) : menu(mui, container) { // load languages file_enumerator path(mui.machine().options().language_path()); @@ -45,7 +44,7 @@ menu_custom_ui::menu_custom_ui(mame_ui_manager &mui, render_container *container auto i = strreplace(name, "_", " ("); if (i > 0) name = name.append(")"); m_lang.push_back(name); - if (name == lang) + if (strcmp(name.c_str(), lang) == 0) m_currlang = cnt; ++cnt; } @@ -74,10 +73,10 @@ menu_custom_ui::~menu_custom_ui() void menu_custom_ui::handle() { - auto changed = false; + bool changed = false; // process the menu - auto menu_event = process(0); + const event *menu_event = process(0); if (menu_event != nullptr && menu_event->itemref != nullptr) { @@ -99,7 +98,14 @@ void menu_custom_ui::handle() (menu_event->iptkey == IPT_UI_RIGHT) ? ui_globals::panels_status++ : ui_globals::panels_status--; } else if (menu_event->iptkey == IPT_UI_SELECT) - menu::stack_push<menu_selector>(ui(), container, hide_status, ui_globals::panels_status); + { + int total = ARRAY_LENGTH(hide_status); + std::vector<std::string> s_sel(total); + for (int index = 0; index < total; ++index) + s_sel[index] = _(hide_status[index]); + + menu::stack_push<menu_selector>(ui(), container, s_sel, ui_globals::panels_status); + } break; } case LANGUAGE_MENU: @@ -110,7 +116,14 @@ void menu_custom_ui::handle() (menu_event->iptkey == IPT_UI_RIGHT) ? m_currlang++ : m_currlang--; } else if (menu_event->iptkey == IPT_UI_SELECT) - menu::stack_push<menu_selector>(ui(), container, m_lang, m_currlang); + { + int total = m_lang.size(); + std::vector<std::string> s_sel(total); + for (int index = 0; index < total; ++index) + s_sel[index] = m_lang[index]; + + menu::stack_push<menu_selector>(ui(), container, s_sel, m_currlang); + } break; } } @@ -137,7 +150,7 @@ void menu_custom_ui::populate() } arrow_flags = get_arrow_flags(0, (int)HIDE_BOTH, ui_globals::panels_status); - item_append(_("Show side panels"), _(hide_status[ui_globals::panels_status].c_str()), arrow_flags, (void *)(FPTR)HIDE_MENU); + item_append(_("Show side panels"), _(hide_status[ui_globals::panels_status]), arrow_flags, (void *)(FPTR)HIDE_MENU); item_append(menu_item_type::SEPARATOR); customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; @@ -152,7 +165,7 @@ void menu_custom_ui::custom_render(void *selectedref, float top, float bottom, f float width; ui().draw_text_full(container, _("Custom UI Settings"), 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); + mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); width += 2 * UI_BOX_LR_BORDER; float maxwidth = MAX(origx2 - origx1, width); @@ -172,7 +185,7 @@ void menu_custom_ui::custom_render(void *selectedref, float top, float bottom, f // draw the text within it ui().draw_text_full(container, _("Custom UI Settings"), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, - mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); + mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); } //------------------------------------------------- @@ -181,7 +194,7 @@ void menu_custom_ui::custom_render(void *selectedref, float top, float bottom, f menu_font_ui::menu_font_ui(mame_ui_manager &mui, render_container *container) : menu(mui, container) { - auto moptions = mui.options(); + ui_options &moptions = mui.options(); std::string name(mui.machine().options().ui_font()); list(); @@ -191,7 +204,7 @@ menu_font_ui::menu_font_ui(mame_ui_manager &mui, render_container *container) : #endif m_actual = 0; - for (size_t index = 0; index < m_fonts.size(); ++index) + for (size_t index = 0; index < m_fonts.size(); index++) { if (m_fonts[index].first == name) { @@ -217,6 +230,7 @@ menu_font_ui::menu_font_ui(mame_ui_manager &mui, render_container *container) : m_font_min = atof(f_entry.minimum()); } } + } //------------------------------------------------- @@ -238,7 +252,7 @@ void menu_font_ui::list() menu_font_ui::~menu_font_ui() { std::string error_string; - auto moptions = ui().options(); + ui_options &moptions = ui().options(); std::string name(m_fonts[m_actual].first); #ifdef UI_WINDOWS @@ -263,10 +277,10 @@ menu_font_ui::~menu_font_ui() void menu_font_ui::handle() { - auto changed = false; + bool changed = false; // process the menu - auto menu_event = process(PROCESS_LR_REPEAT); + const event *menu_event = process(PROCESS_LR_REPEAT); if (menu_event != nullptr && menu_event->itemref != nullptr) switch ((FPTR)menu_event->itemref) @@ -326,8 +340,11 @@ void menu_font_ui::handle() void menu_font_ui::populate() { + // set filter arrow + UINT32 arrow_flags; + // add fonts option - auto arrow_flags = get_arrow_flags(0, m_fonts.size() - 1, m_actual); + arrow_flags = get_arrow_flags(0, m_fonts.size() - 1, m_actual); item_append(_("UI Font"), m_fonts[m_actual].second, arrow_flags, (void *)(FPTR)MUI_FNT); #ifdef UI_WINDOWS @@ -364,7 +381,7 @@ void menu_font_ui::custom_render(void *selectedref, float top, float bottom, flo std::string topbuf(_("UI Fonts Settings")); ui().draw_text_full(container, topbuf.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); + mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); width += 2 * UI_BOX_LR_BORDER; float maxwidth = MAX(origx2 - origx1, width); @@ -384,14 +401,14 @@ void menu_font_ui::custom_render(void *selectedref, float top, float bottom, flo // draw the text within it ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, - mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); + mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); if ((FPTR)selectedref == INFOS_SIZE) { topbuf = _("Sample text - Lorem ipsum dolor sit amet, consectetur adipiscing elit."); ui().draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::LEFT, ui::text_layout::NEVER, - mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr, m_info_size); + mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr, m_info_size); width += 2 * UI_BOX_LR_BORDER; maxwidth = MAX(origx2 - origx1, width); @@ -411,7 +428,7 @@ void menu_font_ui::custom_render(void *selectedref, float top, float bottom, flo // draw the text within it ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::LEFT, ui::text_layout::NEVER, - mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, m_info_size); + mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, m_info_size); } } @@ -447,7 +464,7 @@ menu_colors_ui::menu_colors_ui(mame_ui_manager &mui, render_container *container menu_colors_ui::~menu_colors_ui() { std::string error_string, dec_color; - for (int index = 1; index < MUI_RESTORE; ++index) + for (int index = 1; index < MUI_RESTORE; index++) { dec_color = string_format("%x", (UINT32)m_color_table[index].color); ui().options().set_value(m_color_table[index].option, dec_color.c_str(), OPTION_PRIORITY_CMDLINE, error_string); @@ -460,10 +477,10 @@ menu_colors_ui::~menu_colors_ui() void menu_colors_ui::handle() { - auto changed = false; + bool changed = false; // process the menu - auto menu_event = process(0); + const event *menu_event = process(0); if (menu_event != nullptr && menu_event->itemref != nullptr && menu_event->iptkey == IPT_UI_SELECT) { @@ -522,7 +539,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f std::string topbuf(_("UI Colors Settings")); ui().draw_text_full(container, topbuf.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); + mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); width += 2 * UI_BOX_LR_BORDER; maxwidth = MAX(maxwidth, width); @@ -542,7 +559,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f // draw the text within it ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, - mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); + mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); // bottom text // get the text for 'UI Select' @@ -550,7 +567,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f topbuf = string_format(_("Double click or press %1$s to change the color value"), ui_select_text); ui().draw_text_full(container, topbuf.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); + mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); width += 2 * UI_BOX_LR_BORDER; maxwidth = MAX(maxwidth, width); @@ -570,13 +587,13 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f // draw the text within it ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, - mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); + mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); // compute maxwidth topbuf = _("Menu Preview"); ui().draw_text_full(container, topbuf.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); + mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); maxwidth = width + 2.0f * UI_BOX_LR_BORDER; std::string sampletxt[5]; @@ -590,7 +607,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f for (auto & elem: sampletxt) { 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); + mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); width += 2 * UI_BOX_LR_BORDER; maxwidth = MAX(maxwidth, width); } @@ -612,7 +629,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f // draw the text within it ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, - mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); + mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); // compute our bounds for menu preview x1 -= UI_BOX_LR_BORDER; @@ -630,29 +647,29 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f // draw normal text ui().draw_text_full(container, sampletxt[0].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, - mame_ui_manager::NORMAL, m_color_table[MUI_TEXT_COLOR].color, m_color_table[MUI_TEXT_BG_COLOR].color, nullptr, nullptr); + mame_ui_manager::NORMAL, m_color_table[MUI_TEXT_COLOR].color, m_color_table[MUI_TEXT_BG_COLOR].color, nullptr, nullptr); y1 += line_height; // draw subitem text ui().draw_text_full(container, sampletxt[1].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, - mame_ui_manager::NORMAL, m_color_table[MUI_SUBITEM_COLOR].color, m_color_table[MUI_TEXT_BG_COLOR].color, nullptr, nullptr); + mame_ui_manager::NORMAL, m_color_table[MUI_SUBITEM_COLOR].color, m_color_table[MUI_TEXT_BG_COLOR].color, nullptr, nullptr); y1 += line_height; // draw selected text highlight(container, x1, y1, x2, y1 + line_height, m_color_table[MUI_SELECTED_BG_COLOR].color); ui().draw_text_full(container, sampletxt[2].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, - mame_ui_manager::NORMAL, m_color_table[MUI_SELECTED_COLOR].color, m_color_table[MUI_SELECTED_BG_COLOR].color, nullptr, nullptr); + mame_ui_manager::NORMAL, m_color_table[MUI_SELECTED_COLOR].color, m_color_table[MUI_SELECTED_BG_COLOR].color, nullptr, nullptr); y1 += line_height; // draw mouse over text highlight(container, x1, y1, x2, y1 + line_height, m_color_table[MUI_MOUSEOVER_BG_COLOR].color); ui().draw_text_full(container, sampletxt[3].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, - mame_ui_manager::NORMAL, m_color_table[MUI_MOUSEOVER_COLOR].color, m_color_table[MUI_MOUSEOVER_BG_COLOR].color, nullptr, nullptr); + mame_ui_manager::NORMAL, m_color_table[MUI_MOUSEOVER_COLOR].color, m_color_table[MUI_MOUSEOVER_BG_COLOR].color, nullptr, nullptr); y1 += line_height; // draw clone text ui().draw_text_full(container, sampletxt[4].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, - mame_ui_manager::NORMAL, m_color_table[MUI_CLONE_COLOR].color, m_color_table[MUI_TEXT_BG_COLOR].color, nullptr, nullptr); + mame_ui_manager::NORMAL, m_color_table[MUI_CLONE_COLOR].color, m_color_table[MUI_TEXT_BG_COLOR].color, nullptr, nullptr); } @@ -663,7 +680,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f void menu_colors_ui::restore_colors() { ui_options options; - for (int index = 1; index < MUI_RESTORE; ++index) + for (int index = 1; index < MUI_RESTORE; index++) m_color_table[index].color = rgb_t((UINT32)strtoul(options.value(m_color_table[index].option), nullptr, 16)); } @@ -671,9 +688,12 @@ void menu_colors_ui::restore_colors() // ctor //------------------------------------------------- -menu_rgb_ui::menu_rgb_ui(mame_ui_manager &mui, render_container *container, rgb_t *_color, std::string _title) - : menu(mui, container), m_color(_color), m_key_active(false), m_lock_ref(0), m_title(_title) +menu_rgb_ui::menu_rgb_ui(mame_ui_manager &mui, render_container *container, rgb_t *_color, std::string _title) : menu(mui, container) { + m_color = _color; + m_key_active = false; + m_lock_ref = 0; + m_title = _title; m_search[0] = '\0'; } @@ -691,7 +711,7 @@ menu_rgb_ui::~menu_rgb_ui() void menu_rgb_ui::handle() { - auto changed = false; + bool changed = false; // process the menu const event *menu_event; @@ -860,7 +880,7 @@ void menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, floa // top text std::string topbuf = std::string(m_title).append(_(" - ARGB Settings")); ui().draw_text_full(container, topbuf.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); + mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); width += 2 * UI_BOX_LR_BORDER; maxwidth = MAX(maxwidth, width); @@ -880,12 +900,12 @@ void menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, floa // draw the text within it ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, - mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); + mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); std::string sampletxt(_("Color preview =")); maxwidth = origx2 - origx1; 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, nullptr); + mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); width += 2 * UI_BOX_LR_BORDER; maxwidth = MAX(maxwidth, width); @@ -905,7 +925,7 @@ void menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, floa // draw the normal text ui().draw_text_full(container, sampletxt.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, - mame_ui_manager::NORMAL, rgb_t::white, rgb_t::black, nullptr, nullptr); + mame_ui_manager::NORMAL, rgb_t::white, rgb_t::black, nullptr, nullptr); float t_x2 = x1 - UI_BOX_LR_BORDER + maxwidth; x1 = x2 + 2.0f * UI_BOX_LR_BORDER; @@ -929,15 +949,26 @@ void menu_rgb_ui::inkey_special(const event *menu_event) if (!m_key_active) { - auto val = atoi(m_search); + int val = atoi(m_search); val = m_color->clamp(val); switch ((FPTR)menu_event->itemref) { - case RGB_ALPHA: m_color->set_a(val); break; - case RGB_RED: m_color->set_r(val); break; - case RGB_GREEN: m_color->set_g(val); break; - case RGB_BLUE: m_color->set_b(val); break; + case RGB_ALPHA: + m_color->set_a(val); + break; + + case RGB_RED: + m_color->set_r(val); + break; + + case RGB_GREEN: + m_color->set_g(val); + break; + + case RGB_BLUE: + m_color->set_b(val); + break; } m_search[0] = 0; @@ -1007,7 +1038,7 @@ menu_palette_sel::~menu_palette_sel() void menu_palette_sel::handle() { // process the menu - auto menu_event = process(FLAG_UI_PALETTE); + const event *menu_event = process(FLAG_UI_PALETTE); if (menu_event != nullptr && menu_event->itemref != nullptr) { if (menu_event->iptkey == IPT_UI_SELECT) @@ -1025,9 +1056,8 @@ void menu_palette_sel::handle() void menu_palette_sel::populate() { - int x = 0; - for (auto & e : m_palette) - item_append(_(e.first), e.second, FLAG_UI_PALETTE, (void *)(FPTR)(++x)); + for (int x = 0; x < m_palette.size(); ++x) + item_append(_(m_palette[x].first), m_palette[x].second, FLAG_UI_PALETTE, (void *)(FPTR)(x + 1)); item_append(menu_item_type::SEPARATOR); } |