diff options
author | 2019-06-28 17:30:09 -0400 | |
---|---|---|
committer | 2019-06-28 17:30:09 -0400 | |
commit | 697ff7bd7149d635a838543b65409dd42d739087 (patch) | |
tree | 23d49d81fd2b87ed565fac5c758b73b678fa7ad2 /src/frontend/mame/ui/custui.cpp | |
parent | cec557538d0d55b11780e83ac60e0fef68b37e0d (diff) |
Changed the various usages of UI_*COLOR to be calls to src/frontend/mame/ui/moptions.h (#5282)
* Changed the various usages of UI_*COLOR to be calls to
src/frontend/mame/ui/moptions.h
The various UI_*COLOR macros were implemented as calls to
decode_ui_color, which cached the values for the various options in a
static array, which was obviously a gross hack.
This refactoring is strategic because I am trying to confine awareness
of mame_ui_manager to code in src/frontend/mame/ui, and the
implementation of decode_ui_color() relied on the ability to access
mame_ui_manager as a singleton from outside this code.
* Created a ui_colors object, so that queries for UI RGB values would not
always require parsing strings
* Converted a few more options().zyx_color() to colors().zyx_color()
* A few more misses from earlier
Diffstat (limited to 'src/frontend/mame/ui/custui.cpp')
-rw-r--r-- | src/frontend/mame/ui/custui.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/frontend/mame/ui/custui.cpp b/src/frontend/mame/ui/custui.cpp index 186a5bc1c2d..cfd786dd6e3 100644 --- a/src/frontend/mame/ui/custui.cpp +++ b/src/frontend/mame/ui/custui.cpp @@ -175,7 +175,7 @@ void menu_custom_ui::custom_render(void *selectedref, float top, float bottom, f std::begin(text), std::end(text), origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); + ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); } //------------------------------------------------- @@ -364,7 +364,7 @@ void menu_font_ui::custom_render(void *selectedref, float top, float bottom, flo std::begin(toptext), std::end(toptext), origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); + ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); if (uintptr_t(selectedref) == INFOS_SIZE) { @@ -373,14 +373,14 @@ void menu_font_ui::custom_render(void *selectedref, float top, float bottom, flo std::begin(bottomtext), std::end(bottomtext), origx1, origx2, origy2 + UI_BOX_TB_BORDER, origy2 + bottom, ui::text_layout::LEFT, ui::text_layout::NEVER, false, - UI_TEXT_COLOR, UI_GREEN_COLOR, m_info_size); + ui().colors().text_color(), UI_GREEN_COLOR, m_info_size); } } //------------------------------------------------- // ctor //------------------------------------------------- -#define SET_COLOR_UI(var, opt) var[M##opt].color = opt; var[M##opt].option = OPTION_##opt +#define SET_COLOR_UI(var, opt) var[M##opt].color = mui.options().rgb_value(OPTION_##opt); var[M##opt].option = OPTION_##opt menu_colors_ui::menu_colors_ui(mame_ui_manager &mui, render_container &container) : menu(mui, container) { @@ -414,6 +414,9 @@ 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()); } //------------------------------------------------- @@ -483,7 +486,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f std::begin(toptext), std::end(toptext), origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - UI_TEXT_COLOR, UI_GREEN_COLOR, 1.0f); + ui().colors().text_color(), UI_GREEN_COLOR, 1.0f); // bottom text // get the text for 'UI Select' @@ -492,7 +495,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f std::begin(bottomtext), std::end(bottomtext), origx1, origx2, origy2 + UI_BOX_TB_BORDER, origy2 + bottom, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, - UI_TEXT_COLOR, UI_RED_COLOR, 1.0f); + ui().colors().text_color(), UI_RED_COLOR, 1.0f); // compute maxwidth char const *const topbuf = _("Menu Preview"); @@ -535,7 +538,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, 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().colors().text_color(), ui().colors().text_bg_color(), nullptr, nullptr); // compute our bounds for menu preview float line_height = ui().get_line_height(); @@ -808,7 +811,7 @@ void menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, floa // 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_TEXT_COLOR, UI_TEXT_BG_COLOR); + mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().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, |