summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend/mame/ui/ui.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2021-10-17 06:58:12 +1100
committer Vas Crabb <vas@vastheman.com>2021-10-17 06:58:12 +1100
commit22f52553f746c9ade11ecb8a0873507682d0f1cb (patch)
tree0e147d0ba4465a0c8cbb6a2a2088f036c87e3bd6 /src/frontend/mame/ui/ui.cpp
parentaa3ae2cf17d832eaa6e70e4506da44bac1a31508 (diff)
frontend: Cleaned up rendering of info views.
Put the description for systems in the info box - it's useful for the fruit machines with very long names that are truncated in the list. Also stopped truncating manufactuer and parent name in the info box. Made the text layout class capable of handling lines containing combinatations of left/centre/right-justified text and got rid of the legacy UI manager text wrapping function. Made the system/software selection menus and the info viewer share the same code for formatting info text. This means the multi-column layout works properly in the info viewer now, and the code is a lot simpler. Also the system/software selection menus don't have to redo the text layout every frame now. Made the info viewer update the text layout if the output aspect ratio changes, and cleaned up more legacy code. The lines in the info viewer are no longer bogus "menu items", and there's a lot less special-case code to support it in the base menu class. This commit includes an update to the Chinese translations from YuiFAN.
Diffstat (limited to 'src/frontend/mame/ui/ui.cpp')
-rw-r--r--src/frontend/mame/ui/ui.cpp70
1 files changed, 36 insertions, 34 deletions
diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp
index c2f50d8c33a..fb3c437fb74 100644
--- a/src/frontend/mame/ui/ui.cpp
+++ b/src/frontend/mame/ui/ui.cpp
@@ -212,7 +212,7 @@ void mame_ui_manager::init()
ui_callback_type::GENERAL,
[this] (render_container &container) -> uint32_t
{
- draw_text_box(container, messagebox_text, ui::text_layout::LEFT, 0.5f, 0.5f, colors().background_color());
+ draw_text_box(container, messagebox_text, ui::text_layout::text_justify::LEFT, 0.5f, 0.5f, colors().background_color());
return 0;
});
m_non_char_keys_down = std::make_unique<uint8_t[]>((std::size(non_char_keys) + 7) / 8);
@@ -436,7 +436,7 @@ void mame_ui_manager::display_startup_screens(bool first_time)
[this, &poller, &warning_text, &warning_color, &config_menu] (render_container &container) -> uint32_t
{
// draw a standard message window
- draw_text_box(container, warning_text, ui::text_layout::LEFT, 0.5f, 0.5f, warning_color);
+ draw_text_box(container, warning_text, ui::text_layout::text_justify::LEFT, 0.5f, 0.5f, warning_color);
if (machine().ui_input().pressed(IPT_UI_CANCEL))
{
@@ -673,7 +673,7 @@ void mame_ui_manager::update_and_render(render_container &container)
// display any popup messages
if (osd_ticks() < m_popup_text_end)
- draw_text_box(container, messagebox_poptext, ui::text_layout::CENTER, 0.5f, 0.9f, colors().background_color());
+ draw_text_box(container, messagebox_poptext, ui::text_layout::text_justify::CENTER, 0.5f, 0.9f, colors().background_color());
else
m_popup_text_end = 0;
@@ -818,7 +818,12 @@ void mame_ui_manager::draw_outlined_box(render_container &container, float x0, f
void mame_ui_manager::draw_text(render_container &container, std::string_view 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::text_justify::LEFT, ui::text_layout::word_wrapping::WORD,
+ mame_ui_manager::NORMAL, colors().text_color(), colors().text_bg_color(), nullptr, nullptr);
}
@@ -884,8 +889,8 @@ 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::clamp(xpos - actual_width / 2, box_lr_border(), 1.0f - actual_width - box_lr_border());
+ auto y = std::clamp(ypos - actual_height / 2, box_tb_border(), 1.0f - actual_height - box_tb_border());
// add a box around that
draw_outlined_box(container,
@@ -1120,8 +1125,12 @@ bool mame_ui_manager::can_paste()
void mame_ui_manager::draw_fps_counter(render_container &container)
{
- draw_text_full(container, machine().video().speed_text(), 0.0f, 0.0f, 1.0f,
- ui::text_layout::RIGHT, ui::text_layout::WORD, OPAQUE_, rgb_t::white(), rgb_t::black(), nullptr, nullptr);
+ draw_text_full(
+ container,
+ machine().video().speed_text(),
+ 0.0f, 0.0f, 1.0f,
+ ui::text_layout::text_justify::RIGHT, ui::text_layout::word_wrapping::WORD,
+ OPAQUE_, rgb_t::white(), rgb_t::black(), nullptr, nullptr);
}
@@ -1132,8 +1141,12 @@ void mame_ui_manager::draw_fps_counter(render_container &container)
void mame_ui_manager::draw_timecode_counter(render_container &container)
{
std::string tempstring;
- draw_text_full(container, machine().video().timecode_text(tempstring), 0.0f, 0.0f, 1.0f,
- ui::text_layout::RIGHT, ui::text_layout::WORD, OPAQUE_, rgb_t(0xf0, 0xf0, 0x10, 0x10), rgb_t::black(), nullptr, nullptr);
+ draw_text_full(
+ container,
+ machine().video().timecode_text(tempstring),
+ 0.0f, 0.0f, 1.0f,
+ ui::text_layout::text_justify::RIGHT, ui::text_layout::word_wrapping::WORD,
+ OPAQUE_, rgb_t(0xf0, 0xf0, 0x10, 0x10), rgb_t::black(), nullptr, nullptr);
}
@@ -1144,8 +1157,12 @@ void mame_ui_manager::draw_timecode_counter(render_container &container)
void mame_ui_manager::draw_timecode_total(render_container &container)
{
std::string tempstring;
- draw_text_full(container, machine().video().timecode_total_text(tempstring), 0.0f, 0.0f, 1.0f,
- ui::text_layout::LEFT, ui::text_layout::WORD, OPAQUE_, rgb_t(0xf0, 0x10, 0xf0, 0x10), rgb_t::black(), nullptr, nullptr);
+ draw_text_full(
+ container,
+ machine().video().timecode_total_text(tempstring),
+ 0.0f, 0.0f, 1.0f,
+ ui::text_layout::text_justify::LEFT, ui::text_layout::word_wrapping::WORD,
+ OPAQUE_, rgb_t(0xf0, 0x10, 0xf0, 0x10), rgb_t::black(), nullptr, nullptr);
}
@@ -1156,7 +1173,12 @@ void mame_ui_manager::draw_timecode_total(render_container &container)
void mame_ui_manager::draw_profiler(render_container &container)
{
std::string_view text = g_profiler.text(machine());
- draw_text_full(container, text, 0.0f, 0.0f, 1.0f, ui::text_layout::LEFT, ui::text_layout::WORD, OPAQUE_, rgb_t::white(), rgb_t::black(), nullptr, nullptr);
+ draw_text_full(
+ container,
+ text,
+ 0.0f, 0.0f, 1.0f,
+ ui::text_layout::text_justify::LEFT, ui::text_layout::word_wrapping::WORD,
+ OPAQUE_, rgb_t::white(), rgb_t::black(), nullptr, nullptr);
}
@@ -1467,7 +1489,7 @@ uint32_t mame_ui_manager::handler_confirm_quit(render_container &container)
ui_select_text,
ui_cancel_text);
- draw_text_box(container, quit_message, ui::text_layout::CENTER, 0.5f, 0.5f, UI_RED_COLOR);
+ draw_text_box(container, quit_message, ui::text_layout::text_justify::CENTER, 0.5f, 0.5f, UI_RED_COLOR);
machine().pause();
// if the user press ENTER, quit the game
@@ -2101,26 +2123,6 @@ ui::text_layout mame_ui_manager::create_layout(render_container &container, floa
//-------------------------------------------------
-// wrap_text
-//-------------------------------------------------
-
-int mame_ui_manager::wrap_text(render_container &container, std::string_view origs, float x, float y, float origwrapwidth, std::vector<int> &xstart, std::vector<int> &xend, float text_size)
-{
- // create the layout
- auto layout = create_layout(container, origwrapwidth, ui::text_layout::LEFT, ui::text_layout::WORD);
-
- // add the text
- layout.add_text(
- origs,
- rgb_t::black(),
- rgb_t::black(),
- text_size);
-
- // and get the wrapping info
- return layout.get_wrap_info(xstart, xend);
-}
-
-//-------------------------------------------------
// draw_textured_box - add primitives to
// draw an outlined box with the given
// textured background and line color