diff options
Diffstat (limited to 'src/emu/ui/custui.cpp')
-rw-r--r-- | src/emu/ui/custui.cpp | 172 |
1 files changed, 111 insertions, 61 deletions
diff --git a/src/emu/ui/custui.cpp b/src/emu/ui/custui.cpp index 355f486918a..6492faebabf 100644 --- a/src/emu/ui/custui.cpp +++ b/src/emu/ui/custui.cpp @@ -16,7 +16,11 @@ #include "ui/utils.h" #include <algorithm> -const char *ui_menu_custom_ui::hide_status[] = { "Show All", "Hide Filters", "Hide Info/Image", "Hide Both" }; +const char *ui_menu_custom_ui::hide_status[] = { + __("Show All"), + __("Hide Filters"), + __("Hide Info/Image"), + __("Hide Both") }; //------------------------------------------------- // ctor @@ -24,6 +28,22 @@ const char *ui_menu_custom_ui::hide_status[] = { "Show All", "Hide Filters", "Hi ui_menu_custom_ui::ui_menu_custom_ui(running_machine &machine, render_container *container) : ui_menu(machine, container) { + // load languages + file_enumerator path(machine.options().language_path()); + const char *lang = machine.options().language(); + const osd_directory_entry *dirent; + int cnt = 0; + while ((dirent = path.next()) != nullptr) + if (dirent->type == ENTTYPE_DIR && strcmp(dirent->name, ".") != 0 && strcmp(dirent->name, "..") != 0) + { + auto name = std::string(dirent->name); + int i = strreplace(name, "_", " ("); + if (i > 0) name = name.append(")"); + m_lang.push_back(name); + if (strcmp(name.c_str(), lang) == 0) + m_currlang = cnt; + ++cnt; + } } //------------------------------------------------- @@ -34,6 +54,12 @@ ui_menu_custom_ui::~ui_menu_custom_ui() { std::string error_string; machine().ui().options().set_value(OPTION_HIDE_PANELS, ui_globals::panels_status, OPTION_PRIORITY_CMDLINE, error_string); + if (!m_lang.empty()) + { + machine().options().set_value(OPTION_LANGUAGE, m_lang[m_currlang].c_str(), OPTION_PRIORITY_CMDLINE, error_string); + machine().options().mark_changed(OPTION_LANGUAGE); + load_translation(machine().options()); + } ui_globals::reset = true; } @@ -50,34 +76,50 @@ void ui_menu_custom_ui::handle() if (m_event != nullptr && m_event->itemref != nullptr) { - if (m_event->iptkey == IPT_UI_LEFT || m_event->iptkey == IPT_UI_RIGHT) - { - changed = true; - (m_event->iptkey == IPT_UI_RIGHT) ? ui_globals::panels_status++ : ui_globals::panels_status--; - } - - - else if (m_event->iptkey == IPT_UI_SELECT) + switch ((FPTR)m_event->itemref) { - switch ((FPTR)m_event->itemref) - { - case FONT_MENU: + case FONT_MENU: + if (m_event->iptkey == IPT_UI_SELECT) ui_menu::stack_push(global_alloc_clear<ui_menu_font_ui>(machine(), container)); - break; - - case COLORS_MENU: + break; + case COLORS_MENU: + if (m_event->iptkey == IPT_UI_SELECT) ui_menu::stack_push(global_alloc_clear<ui_menu_colors_ui>(machine(), container)); - break; - case HIDE_MENU: + break; + case HIDE_MENU: + { + if (m_event->iptkey == IPT_UI_LEFT || m_event->iptkey == IPT_UI_RIGHT) + { + changed = true; + (m_event->iptkey == IPT_UI_RIGHT) ? ui_globals::panels_status++ : ui_globals::panels_status--; + } + else if (m_event->iptkey == IPT_UI_SELECT) { 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]; + s_sel[index] = _(hide_status[index]); ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, s_sel, ui_globals::panels_status)); } } + case LANGUAGE_MENU: + { + if (m_event->iptkey == IPT_UI_LEFT || m_event->iptkey == IPT_UI_RIGHT) + { + changed = true; + (m_event->iptkey == IPT_UI_RIGHT) ? m_currlang++ : m_currlang--; + } + else if (m_event->iptkey == IPT_UI_SELECT) + { + 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]; + + ui_menu::stack_push(global_alloc_clear<ui_menu_selector>(machine(), container, s_sel, m_currlang)); + } + } } } @@ -91,11 +133,18 @@ void ui_menu_custom_ui::handle() void ui_menu_custom_ui::populate() { - item_append("Fonts", nullptr, 0, (void *)(FPTR)FONT_MENU); - item_append("Colors", nullptr, 0, (void *)(FPTR)COLORS_MENU); + UINT32 arrow_flags; + item_append(_("Fonts"), nullptr, 0, (void *)(FPTR)FONT_MENU); + item_append(_("Colors"), nullptr, 0, (void *)(FPTR)COLORS_MENU); + + if (!m_lang.empty()) + { + arrow_flags = get_arrow_flags(0, m_lang.size() - 1, m_currlang); + item_append(_("Language"), m_lang[m_currlang].c_str(), arrow_flags, (void *)(FPTR)LANGUAGE_MENU); + } - UINT32 arrow_flags = get_arrow_flags(0, (int)HIDE_BOTH, ui_globals::panels_status); - item_append("Filters and Info/Image", hide_status[ui_globals::panels_status], arrow_flags, (void *)(FPTR)HIDE_MENU); + arrow_flags = get_arrow_flags(0, (int)HIDE_BOTH, ui_globals::panels_status); + item_append(_("Show side panels"), _(hide_status[ui_globals::panels_status]), arrow_flags, (void *)(FPTR)HIDE_MENU); item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); customtop = machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; @@ -110,7 +159,7 @@ void ui_menu_custom_ui::custom_render(void *selectedref, float top, float bottom float width; ui_manager &mui = machine().ui(); - mui.draw_text_full(container, "Custom UI Settings", 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, + mui.draw_text_full(container, _("Custom UI Settings"), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr); width += 2 * UI_BOX_LR_BORDER; float maxwidth = MAX(origx2 - origx1, width); @@ -130,7 +179,7 @@ void ui_menu_custom_ui::custom_render(void *selectedref, float top, float bottom y1 += UI_BOX_TB_BORDER; // draw the text within it - mui.draw_text_full(container, "Custom UI Settings", x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, + mui.draw_text_full(container, _("Custom UI Settings"), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); } @@ -143,7 +192,7 @@ ui_menu_font_ui::ui_menu_font_ui(running_machine &machine, render_container *con ui_options &moptions = machine.ui().options(); #ifdef UI_WINDOWS - std::string name(machine.ui().options().ui_font()); + std::string name(machine.options().ui_font()); list(); m_bold = (strreplace(name, "[B]", "") + strreplace(name, "[b]", "") > 0); @@ -236,7 +285,8 @@ ui_menu_font_ui::~ui_menu_font_ui() if (m_bold) name.insert(0, "[B]"); } - moptions.set_value(OPTION_UI_FONT, name.c_str(), OPTION_PRIORITY_CMDLINE, error_string); + machine().options().set_value(OPTION_UI_FONT, name.c_str(), OPTION_PRIORITY_CMDLINE, error_string); + machine().options().mark_changed(OPTION_UI_FONT); #endif moptions.set_value(OPTION_INFOS_SIZE, m_info_size, OPTION_PRIORITY_CMDLINE, error_string); @@ -317,18 +367,18 @@ void ui_menu_font_ui::populate() // add fonts option arrow_flags = get_arrow_flags(0, m_fonts.size() - 1, m_actual); std::string name(m_fonts[m_actual]); - item_append("UI Font", name.c_str(), arrow_flags, (void *)(FPTR)MUI_FNT); + item_append(_("UI Font"), name.c_str(), arrow_flags, (void *)(FPTR)MUI_FNT); if (name != "default") { - item_append("Bold", m_bold ? "On" : "Off", m_bold ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)(FPTR)MUI_BOLD); - item_append("Italic", m_italic ? "On" : "Off", m_italic ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)(FPTR)MUI_ITALIC); + item_append(_("Bold"), m_bold ? "On" : "Off", m_bold ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)(FPTR)MUI_BOLD); + item_append(_("Italic"), m_italic ? "On" : "Off", m_italic ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)(FPTR)MUI_ITALIC); } #endif arrow_flags = get_arrow_flags(m_font_min, m_font_max, m_font_size); strprintf(tmptxt, "%2d", m_font_size); - item_append("Lines", tmptxt.c_str(), arrow_flags, (void *)(FPTR)FONT_SIZE); + item_append(_("Lines"), tmptxt.c_str(), arrow_flags, (void *)(FPTR)FONT_SIZE); item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); @@ -336,7 +386,7 @@ void ui_menu_font_ui::populate() tmptxt.clear(); strprintf(tmptxt, "%3.2f", m_info_size); arrow_flags = get_arrow_flags(m_info_min, m_info_max, m_info_size); - item_append("Infos text size", tmptxt.c_str(), arrow_flags, (void *)(FPTR)INFOS_SIZE); + item_append(_("Infos text size"), tmptxt.c_str(), arrow_flags, (void *)(FPTR)INFOS_SIZE); item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); @@ -353,7 +403,7 @@ void ui_menu_font_ui::custom_render(void *selectedref, float top, float bottom, ui_manager &mui = machine().ui(); // top text - std::string topbuf("UI Fonts Settings"); + std::string topbuf(_("UI Fonts Settings")); mui.draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr); @@ -380,7 +430,7 @@ void ui_menu_font_ui::custom_render(void *selectedref, float top, float bottom, if ((FPTR)selectedref == INFOS_SIZE) { - topbuf = "Sample text - Lorem ipsum dolor sit amet, consectetur adipiscing elit."; + topbuf = _("Sample text - Lorem ipsum dolor sit amet, consectetur adipiscing elit."); mui.draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_NEVER, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr, m_info_size); @@ -478,25 +528,25 @@ void ui_menu_colors_ui::handle() void ui_menu_colors_ui::populate() { - item_append("Normal text", nullptr, 0, (void *)(FPTR)MUI_TEXT_COLOR); - item_append("Selected color", nullptr, 0, (void *)(FPTR)MUI_SELECTED_COLOR); - item_append("Normal text background", nullptr, 0, (void *)(FPTR)MUI_TEXT_BG_COLOR); - item_append("Selected background color", nullptr, 0, (void *)(FPTR)MUI_SELECTED_BG_COLOR); - item_append("Subitem color", nullptr, 0, (void *)(FPTR)MUI_SUBITEM_COLOR); - item_append("Clone", nullptr, 0, (void *)(FPTR)MUI_CLONE_COLOR); - item_append("Border", nullptr, 0, (void *)(FPTR)MUI_BORDER_COLOR); - item_append("Background", nullptr, 0, (void *)(FPTR)MUI_BACKGROUND_COLOR); - item_append("Dipswitch", nullptr, 0, (void *)(FPTR)MUI_DIPSW_COLOR); - item_append("Unavailable color", nullptr, 0, (void *)(FPTR)MUI_UNAVAILABLE_COLOR); - item_append("Slider color", nullptr, 0, (void *)(FPTR)MUI_SLIDER_COLOR); - item_append("Gfx viewer background", nullptr, 0, (void *)(FPTR)MUI_GFXVIEWER_BG_COLOR); - item_append("Mouse over color", nullptr, 0, (void *)(FPTR)MUI_MOUSEOVER_COLOR); - item_append("Mouse over background color", nullptr, 0, (void *)(FPTR)MUI_MOUSEOVER_BG_COLOR); - item_append("Mouse down color", nullptr, 0, (void *)(FPTR)MUI_MOUSEDOWN_COLOR); - item_append("Mouse down background color", nullptr, 0, (void *)(FPTR)MUI_MOUSEDOWN_BG_COLOR); + item_append(_("Normal text"), nullptr, 0, (void *)(FPTR)MUI_TEXT_COLOR); + item_append(_("Selected color"), nullptr, 0, (void *)(FPTR)MUI_SELECTED_COLOR); + item_append(_("Normal text background"), nullptr, 0, (void *)(FPTR)MUI_TEXT_BG_COLOR); + item_append(_("Selected background color"), nullptr, 0, (void *)(FPTR)MUI_SELECTED_BG_COLOR); + item_append(_("Subitem color"), nullptr, 0, (void *)(FPTR)MUI_SUBITEM_COLOR); + item_append(_("Clone"), nullptr, 0, (void *)(FPTR)MUI_CLONE_COLOR); + item_append(_("Border"), nullptr, 0, (void *)(FPTR)MUI_BORDER_COLOR); + item_append(_("Background"), nullptr, 0, (void *)(FPTR)MUI_BACKGROUND_COLOR); + item_append(_("Dipswitch"), nullptr, 0, (void *)(FPTR)MUI_DIPSW_COLOR); + item_append(_("Unavailable color"), nullptr, 0, (void *)(FPTR)MUI_UNAVAILABLE_COLOR); + item_append(_("Slider color"), nullptr, 0, (void *)(FPTR)MUI_SLIDER_COLOR); + item_append(_("Gfx viewer background"), nullptr, 0, (void *)(FPTR)MUI_GFXVIEWER_BG_COLOR); + item_append(_("Mouse over color"), nullptr, 0, (void *)(FPTR)MUI_MOUSEOVER_COLOR); + item_append(_("Mouse over background color"), nullptr, 0, (void *)(FPTR)MUI_MOUSEOVER_BG_COLOR); + item_append(_("Mouse down color"), nullptr, 0, (void *)(FPTR)MUI_MOUSEDOWN_COLOR); + item_append(_("Mouse down background color"), nullptr, 0, (void *)(FPTR)MUI_MOUSEDOWN_BG_COLOR); item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); - item_append("Restore originals colors", nullptr, 0, (void *)(FPTR)MUI_RESTORE); + item_append(_("Restore originals colors"), nullptr, 0, (void *)(FPTR)MUI_RESTORE); custombottom = customtop = machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; } @@ -512,7 +562,7 @@ void ui_menu_colors_ui::custom_render(void *selectedref, float top, float bottom float line_height = mui.get_line_height(); // top text - std::string topbuf("UI Colors Settings"); + std::string topbuf(_("UI Colors Settings")); mui.draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr); @@ -540,7 +590,7 @@ void ui_menu_colors_ui::custom_render(void *selectedref, float top, float bottom // bottom text // get the text for 'UI Select' std::string ui_select_text = machine().input().seq_name(machine().ioport().type_seq(IPT_UI_SELECT, 0, SEQ_TYPE_STANDARD)); - topbuf.assign("Double click or press ").append(ui_select_text.c_str()).append(" to change the color value"); + topbuf.assign(_("Double click or press ")).append(ui_select_text.c_str()).append(_(" to change the color value")); mui.draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr); @@ -566,7 +616,7 @@ void ui_menu_colors_ui::custom_render(void *selectedref, float top, float bottom DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); // compute maxwidth - topbuf = "Menu Preview"; + topbuf = _("Menu Preview"); mui.draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr); @@ -574,11 +624,11 @@ void ui_menu_colors_ui::custom_render(void *selectedref, float top, float bottom std::string sampletxt[5]; - sampletxt[0] = "Normal"; - sampletxt[1] = "Subitem"; - sampletxt[2] = "Selected"; - sampletxt[3] = "Mouse Over"; - sampletxt[4] = "Clone"; + sampletxt[0] = _("Normal"); + sampletxt[1] = _("Subitem"); + sampletxt[2] = _("Selected"); + sampletxt[3] = _("Mouse Over"); + sampletxt[4] = _("Clone"); for (auto & elem: sampletxt) { @@ -844,7 +894,7 @@ void ui_menu_rgb_ui::populate() item_append("Blue", s_text.c_str(), 0, (void *)(FPTR)RGB_BLUE); item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); - item_append("Choose from palette", nullptr, 0, (void *)(FPTR)PALETTE_CHOOSE); + item_append(_("Choose from palette"), nullptr, 0, (void *)(FPTR)PALETTE_CHOOSE); item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); custombottom = customtop = machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; @@ -860,7 +910,7 @@ void ui_menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, f ui_manager &mui = machine().ui(); // top text - std::string topbuf = std::string(m_title).append(" - ARGB Settings"); + std::string topbuf = std::string(m_title).append(_(" - ARGB Settings")); mui.draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr); width += 2 * UI_BOX_LR_BORDER; @@ -884,7 +934,7 @@ void ui_menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, f mui.draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); - std::string sampletxt("Color preview ="); + std::string sampletxt(_("Color preview =")); maxwidth = origx2 - origx1; mui.draw_text_full(container, sampletxt.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr); |