FullscreenUI: Fix pause menu light theme shadow colour

This commit is contained in:
Stenzek 2025-03-12 00:19:32 +10:00
parent aeadd4c280
commit 72a0ba1e8e
No known key found for this signature in database
3 changed files with 36 additions and 29 deletions

View File

@ -103,7 +103,6 @@ using ImGuiFullscreen::CancelPendingMenuClose;
using ImGuiFullscreen::CenterImage; using ImGuiFullscreen::CenterImage;
using ImGuiFullscreen::DarkerColor; using ImGuiFullscreen::DarkerColor;
using ImGuiFullscreen::DefaultActiveButton; using ImGuiFullscreen::DefaultActiveButton;
using ImGuiFullscreen::DrawShadowedText;
using ImGuiFullscreen::EndFixedPopupModal; using ImGuiFullscreen::EndFixedPopupModal;
using ImGuiFullscreen::EndFullscreenColumns; using ImGuiFullscreen::EndFullscreenColumns;
using ImGuiFullscreen::EndFullscreenColumnWindow; using ImGuiFullscreen::EndFullscreenColumnWindow;
@ -6433,8 +6432,9 @@ void FullscreenUI::DrawPauseMenu()
buffer.assign(Path::GetFileName(s_state.current_game_path)); 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); 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(), RenderShadowedTextClipped(dl, UIStyle.LargeFont, text_pos, display_size, title_text_color,
s_state.current_game_title.c_str() + s_state.current_game_title.size()); 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; text_pos.y += UIStyle.LargeFont->FontSize + scaled_text_spacing;
if (Achievements::IsActive()) if (Achievements::IsActive())
@ -6442,12 +6442,14 @@ void FullscreenUI::DrawPauseMenu()
const auto lock = Achievements::GetLock(); const auto lock = Achievements::GetLock();
if (const std::string& rp = Achievements::GetRichPresenceString(); !rp.empty()) 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; 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 // current time / play time
buffer.format("{:%X}", fmt::localtime(std::time(nullptr))); 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<float>::max(), ImVec2 text_size = UIStyle.LargeFont->CalcTextSizeA(UIStyle.LargeFont->FontSize, std::numeric_limits<float>::max(),
-1.0f, buffer.c_str(), buffer.end_ptr()); -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); 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; text_pos.y += UIStyle.LargeFont->FontSize + scaled_text_spacing;
if (!s_state.current_game_serial.empty()) if (!s_state.current_game_serial.empty())
@ -6467,14 +6470,16 @@ void FullscreenUI::DrawPauseMenu()
text_size = ImVec2(UIStyle.MediumFont->CalcTextSizeA( text_size = ImVec2(UIStyle.MediumFont->CalcTextSizeA(
UIStyle.MediumFont->FontSize, std::numeric_limits<float>::max(), -1.0f, buffer.c_str(), buffer.end_ptr())); UIStyle.MediumFont->FontSize, std::numeric_limits<float>::max(), -1.0f, buffer.c_str(), buffer.end_ptr()));
text_pos.x = display_size.x - scaled_top_bar_padding - text_size.x; 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; text_pos.y += UIStyle.MediumFont->FontSize + scaled_text_spacing;
buffer.format(FSUI_FSTR("All Time: {}"), GameList::FormatTimespan(cached_played_time + session_time, true)); buffer.format(FSUI_FSTR("All Time: {}"), GameList::FormatTimespan(cached_played_time + session_time, true));
text_size = ImVec2(UIStyle.MediumFont->CalcTextSizeA( text_size = ImVec2(UIStyle.MediumFont->CalcTextSizeA(
UIStyle.MediumFont->FontSize, std::numeric_limits<float>::max(), -1.0f, buffer.c_str(), buffer.end_ptr())); UIStyle.MediumFont->FontSize, std::numeric_limits<float>::max(), -1.0f, buffer.c_str(), buffer.end_ptr()));
text_pos.x = display_size.x - scaled_top_bar_padding - text_size.x; 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; text_pos.y += UIStyle.MediumFont->FontSize + scaled_text_spacing;
} }
} }

View File

@ -1297,9 +1297,9 @@ void ImGuiFullscreen::ResetMenuButtonFrame()
s_state.has_hovered_menu_item = false; s_state.has_hovered_menu_item = false;
} }
void ImGuiFullscreen::RenderShadowedTextClipped(ImFont* font, const ImVec2& pos_min, const ImVec2& pos_max, u32 color, void ImGuiFullscreen::RenderShadowedTextClipped(ImDrawList* draw_list, ImFont* font, const ImVec2& pos_min,
const char* text, const char* text_end, const ImVec2& pos_max, u32 color, const char* text,
const ImVec2* text_size_if_known /* = nullptr */, const char* text_end, const ImVec2* text_size_if_known /* = nullptr */,
const ImVec2& align /* = ImVec2(0, 0)*/, float wrap_width /* = 0.0f*/, const ImVec2& align /* = ImVec2(0, 0)*/, float wrap_width /* = 0.0f*/,
const ImRect* clip_rect /* = nullptr */) const ImRect* clip_rect /* = nullptr */)
{ {
@ -1327,24 +1327,32 @@ void ImGuiFullscreen::RenderShadowedTextClipped(ImFont* font, const ImVec2& pos_
if (align.y > 0.0f) if (align.y > 0.0f)
pos.y = ImMax(pos.y, pos.y + (pos_max.y - pos.y - text_size.y) * align.y); pos.y = ImMax(pos.y, pos.y + (pos_max.y - pos.y - text_size.y) * align.y);
ImDrawList* const dl = ImGui::GetWindowDrawList();
// Render // Render
if (need_clipping) if (need_clipping)
{ {
ImVec4 fine_clip_rect(clip_min->x, clip_min->y, clip_max->x, clip_max->y); 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), 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); 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, color, text, text_display_end, wrap_width, &fine_clip_rect);
} }
else else
{ {
dl->AddText(font, font->FontSize, pos + LayoutScale(LAYOUT_SHADOW_OFFSET, LAYOUT_SHADOW_OFFSET), draw_list->AddText(font, font->FontSize, pos + LayoutScale(LAYOUT_SHADOW_OFFSET, LAYOUT_SHADOW_OFFSET),
UIStyle.ShadowColor, text, text_display_end, wrap_width, nullptr); 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, 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*/) void ImGuiFullscreen::MenuHeading(const char* title, bool draw_line /*= true*/)
{ {
const float line_thickness = draw_line ? LayoutScale(1.0f) : 0.0f; 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; 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*/, void ImGuiFullscreen::BeginNavBar(float x_padding /*= LAYOUT_MENU_BUTTON_X_PADDING*/,
float y_padding /*= LAYOUT_MENU_BUTTON_Y_PADDING*/) float y_padding /*= LAYOUT_MENU_BUTTON_Y_PADDING*/)
{ {

View File

@ -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 char* text_end, const ImVec2* text_size_if_known = nullptr,
const ImVec2& align = ImVec2(0, 0), float wrap_width = 0.0f, const ImVec2& align = ImVec2(0, 0), float wrap_width = 0.0f,
const ImRect* clip_rect = nullptr); 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); 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 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, 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 BeginNavBar(float x_padding = LAYOUT_MENU_BUTTON_X_PADDING, float y_padding = LAYOUT_MENU_BUTTON_Y_PADDING);
void EndNavBar(); void EndNavBar();
void NavTitle(const char* title, float height = LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, ImFont* font = UIStyle.LargeFont); void NavTitle(const char* title, float height = LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, ImFont* font = UIStyle.LargeFont);