From 72a0ba1e8ed52594c55cd871878514bc6ce03d65 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 12 Mar 2025 00:19:32 +1000 Subject: [PATCH] FullscreenUI: Fix pause menu light theme shadow colour --- src/core/fullscreen_ui.cpp | 21 ++++++++++++-------- src/util/imgui_fullscreen.cpp | 37 ++++++++++++++++++----------------- src/util/imgui_fullscreen.h | 7 ++++--- 3 files changed, 36 insertions(+), 29 deletions(-) diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index c688b364d..f7482f380 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -103,7 +103,6 @@ using ImGuiFullscreen::CancelPendingMenuClose; using ImGuiFullscreen::CenterImage; using ImGuiFullscreen::DarkerColor; using ImGuiFullscreen::DefaultActiveButton; -using ImGuiFullscreen::DrawShadowedText; using ImGuiFullscreen::EndFixedPopupModal; using ImGuiFullscreen::EndFullscreenColumns; using ImGuiFullscreen::EndFullscreenColumnWindow; @@ -6433,8 +6432,9 @@ void FullscreenUI::DrawPauseMenu() buffer.assign(Path::GetFileName(s_state.current_game_path)); ImVec2 text_pos = ImVec2(scaled_top_bar_padding + image_size + scaled_top_bar_padding, scaled_top_bar_padding); - DrawShadowedText(dl, UIStyle.LargeFont, text_pos, title_text_color, s_state.current_game_title.c_str(), - s_state.current_game_title.c_str() + s_state.current_game_title.size()); + RenderShadowedTextClipped(dl, UIStyle.LargeFont, text_pos, display_size, title_text_color, + s_state.current_game_title.c_str(), + s_state.current_game_title.c_str() + s_state.current_game_title.size()); text_pos.y += UIStyle.LargeFont->FontSize + scaled_text_spacing; if (Achievements::IsActive()) @@ -6442,12 +6442,14 @@ void FullscreenUI::DrawPauseMenu() const auto lock = Achievements::GetLock(); if (const std::string& rp = Achievements::GetRichPresenceString(); !rp.empty()) { - DrawShadowedText(dl, UIStyle.MediumFont, text_pos, title_text_color, rp.data(), rp.data() + rp.length()); + RenderShadowedTextClipped(dl, UIStyle.MediumFont, text_pos, display_size, title_text_color, rp.data(), + rp.data() + rp.length()); text_pos.y += UIStyle.MediumFont->FontSize + scaled_text_spacing; } } - DrawShadowedText(dl, UIStyle.MediumFont, text_pos, text_color, buffer.c_str(), buffer.end_ptr()); + RenderShadowedTextClipped(dl, UIStyle.MediumFont, text_pos, display_size, text_color, buffer.c_str(), + buffer.end_ptr()); // current time / play time buffer.format("{:%X}", fmt::localtime(std::time(nullptr))); @@ -6455,7 +6457,8 @@ void FullscreenUI::DrawPauseMenu() ImVec2 text_size = UIStyle.LargeFont->CalcTextSizeA(UIStyle.LargeFont->FontSize, std::numeric_limits::max(), -1.0f, buffer.c_str(), buffer.end_ptr()); text_pos = ImVec2(display_size.x - scaled_top_bar_padding - text_size.x, scaled_top_bar_padding); - DrawShadowedText(dl, UIStyle.LargeFont, text_pos, title_text_color, buffer.c_str(), buffer.end_ptr()); + RenderShadowedTextClipped(dl, UIStyle.LargeFont, text_pos, display_size, title_text_color, buffer.c_str(), + buffer.end_ptr()); text_pos.y += UIStyle.LargeFont->FontSize + scaled_text_spacing; if (!s_state.current_game_serial.empty()) @@ -6467,14 +6470,16 @@ void FullscreenUI::DrawPauseMenu() text_size = ImVec2(UIStyle.MediumFont->CalcTextSizeA( UIStyle.MediumFont->FontSize, std::numeric_limits::max(), -1.0f, buffer.c_str(), buffer.end_ptr())); text_pos.x = display_size.x - scaled_top_bar_padding - text_size.x; - DrawShadowedText(dl, UIStyle.MediumFont, text_pos, text_color, buffer.c_str(), buffer.end_ptr()); + RenderShadowedTextClipped(dl, UIStyle.MediumFont, text_pos, display_size, text_color, buffer.c_str(), + buffer.end_ptr()); text_pos.y += UIStyle.MediumFont->FontSize + scaled_text_spacing; buffer.format(FSUI_FSTR("All Time: {}"), GameList::FormatTimespan(cached_played_time + session_time, true)); text_size = ImVec2(UIStyle.MediumFont->CalcTextSizeA( UIStyle.MediumFont->FontSize, std::numeric_limits::max(), -1.0f, buffer.c_str(), buffer.end_ptr())); text_pos.x = display_size.x - scaled_top_bar_padding - text_size.x; - DrawShadowedText(dl, UIStyle.MediumFont, text_pos, text_color, buffer.c_str(), buffer.end_ptr()); + RenderShadowedTextClipped(dl, UIStyle.MediumFont, text_pos, display_size, text_color, buffer.c_str(), + buffer.end_ptr()); text_pos.y += UIStyle.MediumFont->FontSize + scaled_text_spacing; } } diff --git a/src/util/imgui_fullscreen.cpp b/src/util/imgui_fullscreen.cpp index 4ef779b17..a13ba921d 100644 --- a/src/util/imgui_fullscreen.cpp +++ b/src/util/imgui_fullscreen.cpp @@ -1297,9 +1297,9 @@ void ImGuiFullscreen::ResetMenuButtonFrame() s_state.has_hovered_menu_item = false; } -void ImGuiFullscreen::RenderShadowedTextClipped(ImFont* font, const ImVec2& pos_min, const ImVec2& pos_max, u32 color, - const char* text, const char* text_end, - const ImVec2* text_size_if_known /* = nullptr */, +void ImGuiFullscreen::RenderShadowedTextClipped(ImDrawList* draw_list, ImFont* font, const ImVec2& pos_min, + const ImVec2& pos_max, u32 color, const char* text, + const char* text_end, const ImVec2* text_size_if_known /* = nullptr */, const ImVec2& align /* = ImVec2(0, 0)*/, float wrap_width /* = 0.0f*/, const ImRect* clip_rect /* = nullptr */) { @@ -1327,24 +1327,32 @@ void ImGuiFullscreen::RenderShadowedTextClipped(ImFont* font, const ImVec2& pos_ if (align.y > 0.0f) pos.y = ImMax(pos.y, pos.y + (pos_max.y - pos.y - text_size.y) * align.y); - ImDrawList* const dl = ImGui::GetWindowDrawList(); - // Render if (need_clipping) { ImVec4 fine_clip_rect(clip_min->x, clip_min->y, clip_max->x, clip_max->y); - dl->AddText(font, font->FontSize, pos + LayoutScale(LAYOUT_SHADOW_OFFSET, LAYOUT_SHADOW_OFFSET), - UIStyle.ShadowColor, text, text_display_end, wrap_width, &fine_clip_rect); - dl->AddText(font, font->FontSize, pos, color, text, text_display_end, wrap_width, &fine_clip_rect); + draw_list->AddText(font, font->FontSize, pos + LayoutScale(LAYOUT_SHADOW_OFFSET, LAYOUT_SHADOW_OFFSET), + UIStyle.ShadowColor, text, text_display_end, wrap_width, &fine_clip_rect); + draw_list->AddText(font, font->FontSize, pos, color, text, text_display_end, wrap_width, &fine_clip_rect); } else { - dl->AddText(font, font->FontSize, pos + LayoutScale(LAYOUT_SHADOW_OFFSET, LAYOUT_SHADOW_OFFSET), - UIStyle.ShadowColor, text, text_display_end, wrap_width, nullptr); - dl->AddText(font, font->FontSize, pos, color, text, text_display_end, wrap_width, nullptr); + draw_list->AddText(font, font->FontSize, pos + LayoutScale(LAYOUT_SHADOW_OFFSET, LAYOUT_SHADOW_OFFSET), + UIStyle.ShadowColor, text, text_display_end, wrap_width, nullptr); + draw_list->AddText(font, font->FontSize, pos, color, text, text_display_end, wrap_width, nullptr); } } +void ImGuiFullscreen::RenderShadowedTextClipped(ImFont* font, const ImVec2& pos_min, const ImVec2& pos_max, u32 color, + const char* text, const char* text_end, + const ImVec2* text_size_if_known /* = nullptr */, + const ImVec2& align /* = ImVec2(0, 0)*/, float wrap_width /* = 0.0f*/, + const ImRect* clip_rect /* = nullptr */) +{ + RenderShadowedTextClipped(ImGui::GetWindowDrawList(), font, pos_min, pos_max, color, text, text_end, + text_size_if_known, align, wrap_width, clip_rect); +} + void ImGuiFullscreen::MenuHeading(const char* title, bool draw_line /*= true*/) { const float line_thickness = draw_line ? LayoutScale(1.0f) : 0.0f; @@ -1949,13 +1957,6 @@ bool ImGuiFullscreen::EnumChoiceButtonImpl(const char* title, const char* summar return changed; } -void ImGuiFullscreen::DrawShadowedText(ImDrawList* dl, ImFont* font, const ImVec2& pos, u32 col, const char* text, - const char* text_end /*= nullptr*/, float wrap_width /*= 0.0f*/) -{ - dl->AddText(font, font->FontSize, pos + LayoutScale(1.0f, 1.0f), IM_COL32(0, 0, 0, 100), text, text_end, wrap_width); - dl->AddText(font, font->FontSize, pos, col, text, text_end, wrap_width); -} - void ImGuiFullscreen::BeginNavBar(float x_padding /*= LAYOUT_MENU_BUTTON_X_PADDING*/, float y_padding /*= LAYOUT_MENU_BUTTON_Y_PADDING*/) { diff --git a/src/util/imgui_fullscreen.h b/src/util/imgui_fullscreen.h index 757c2ceef..be1945152 100644 --- a/src/util/imgui_fullscreen.h +++ b/src/util/imgui_fullscreen.h @@ -243,6 +243,10 @@ void RenderShadowedTextClipped(ImFont* font, const ImVec2& pos_min, const ImVec2 const char* text_end, const ImVec2* text_size_if_known = nullptr, const ImVec2& align = ImVec2(0, 0), float wrap_width = 0.0f, const ImRect* clip_rect = nullptr); +void RenderShadowedTextClipped(ImDrawList* draw_list, ImFont* font, const ImVec2& pos_min, const ImVec2& pos_max, + u32 color, const char* text, const char* text_end, + const ImVec2* text_size_if_known = nullptr, const ImVec2& align = ImVec2(0, 0), + float wrap_width = 0.0f, const ImRect* clip_rect = nullptr); void MenuHeading(const char* title, bool draw_line = true); bool MenuHeadingButton(const char* title, const char* value = nullptr, bool enabled = true, bool draw_line = true); bool ActiveButton(const char* title, bool is_active, bool enabled = true, @@ -308,9 +312,6 @@ ALWAYS_INLINE static bool EnumChoiceButton(const char* title, const char* summar } } -void DrawShadowedText(ImDrawList* dl, ImFont* font, const ImVec2& pos, u32 col, const char* text, - const char* text_end = nullptr, float wrap_width = 0.0f); - void BeginNavBar(float x_padding = LAYOUT_MENU_BUTTON_X_PADDING, float y_padding = LAYOUT_MENU_BUTTON_Y_PADDING); void EndNavBar(); void NavTitle(const char* title, float height = LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, ImFont* font = UIStyle.LargeFont);