From dddc091221f5133183c16b8d3b0079e41cc5c265 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 27 May 2026 15:53:07 +1000 Subject: [PATCH] FullscreenUI: Fix double scaling of some UI elements --- src/core/fullscreenui_game_list.cpp | 6 ++++-- src/core/fullscreenui_settings.cpp | 4 +--- src/core/fullscreenui_widgets.cpp | 32 ++++++++++++++++++----------- src/core/fullscreenui_widgets.h | 4 ++++ 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/core/fullscreenui_game_list.cpp b/src/core/fullscreenui_game_list.cpp index d015a7bb3..bc9681c81 100644 --- a/src/core/fullscreenui_game_list.cpp +++ b/src/core/fullscreenui_game_list.cpp @@ -582,12 +582,13 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size) // region { const bool display_as_language = (selected_entry->dbentry && selected_entry->dbentry->HasAnyLanguage()); + const ImVec2 size = LayoutScale(23.0f, 16.0f); ImGui::PushFont(UIStyle.Font, UIStyle.MediumFontSize, UIStyle.BoldFontWeight); TextUnformatted( FSUI_ICONVSTR(ICON_EMOJI_GLOBE, display_as_language ? FSUI_CSTR("Language: ") : FSUI_CSTR("Region: "))); ImGui::PopFont(); ImGui::SameLine(); - ImGui::Image(GetCachedTexture(selected_entry->GetLanguageIconName(), 23, 16), LayoutScale(23.0f, 16.0f)); + ImGui::Image(GetCachedTexture(selected_entry->GetLanguageIconName(), size), size); ImGui::SameLine(); ImGui::PushStyleColor(ImGuiCol_Text, subtitle_text_color); if (display_as_language) @@ -650,11 +651,12 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size) } // compatibility + const ImVec2 compatibility_size = LayoutScale(88.0f, 16.0f); ImGui::PushFont(UIStyle.Font, UIStyle.MediumFontSize, UIStyle.BoldFontWeight); TextUnformatted(FSUI_ICONSTR(ICON_EMOJI_STAR, FSUI_VSTR("Compatibility: "))); ImGui::PopFont(); ImGui::SameLine(); - ImGui::Image(GetCachedTexture(selected_entry->GetCompatibilityIconFileName(), 88, 16), LayoutScale(88.0f, 16.0f)); + ImGui::Image(GetCachedTexture(selected_entry->GetCompatibilityIconFileName(), compatibility_size), compatibility_size); ImGui::SameLine(); ImGui::PushStyleColor(ImGuiCol_Text, subtitle_text_color); ImGui::Text(" (%s)", GameDatabase::GetCompatibilityRatingDisplayName( diff --git a/src/core/fullscreenui_settings.cpp b/src/core/fullscreenui_settings.cpp index 48875326f..d3d9f4248 100644 --- a/src/core/fullscreenui_settings.cpp +++ b/src/core/fullscreenui_settings.cpp @@ -5332,9 +5332,7 @@ void FullscreenUI::DrawAchievementsLoginWindow() const float ra_title_spacing = LayoutScale(10.0f); const ImVec2 ra_logo_size = ImVec2(UIStyle.LargeFontSize * 2.0f, UIStyle.LargeFontSize); const ImRect ra_logo_rect = CenterImage(ra_logo_size, ImVec2(454.0f, 245.0f)); - GPUTexture* const ra_logo = - GetCachedTexture(Achievements::RA_LOGO_SVG_ICON_NAME, static_cast(ra_logo_rect.GetWidth()), - static_cast(ra_logo_rect.GetHeight())); + GPUTexture* const ra_logo = GetCachedTexture(Achievements::RA_LOGO_SVG_ICON_NAME, ra_logo_rect.GetSize()); const ImRect work_rect = ImGui::GetCurrentWindow()->WorkRect; const float indent = (work_rect.GetWidth() - (ra_logo_size.x + ra_title_spacing + ra_title_size.x)) * 0.5f; ImDrawList* const dl = ImGui::GetWindowDrawList(); diff --git a/src/core/fullscreenui_widgets.cpp b/src/core/fullscreenui_widgets.cpp index 22d632a20..909fc0813 100644 --- a/src/core/fullscreenui_widgets.cpp +++ b/src/core/fullscreenui_widgets.cpp @@ -839,13 +839,15 @@ std::shared_ptr FullscreenUI::LoadTexture(std::string_view name, u32 if (!TextureNeedsSVGDimensions(name)) return LoadTexture(name, name, 0, 0); - svg_width = static_cast(std::ceil(LayoutScale(static_cast(svg_width)))); - svg_height = static_cast(std::ceil(LayoutScale(static_cast(svg_height)))); - const SmallString wh_name = SmallString::from_format("{}#{}x{}", name, svg_width, svg_height); return LoadTexture(name, wh_name, svg_width, svg_height); } +std::shared_ptr FullscreenUI::LoadTexture(std::string_view name, const ImVec2& size) +{ + return LoadTexture(name, name, static_cast(size.x), static_cast(size.y)); +} + GPUTexture* FullscreenUI::FindCachedTexture(std::string_view name) { std::shared_ptr* tex_ptr = s_state.texture_cache.Lookup(name); @@ -858,14 +860,16 @@ GPUTexture* FullscreenUI::FindCachedTexture(std::string_view name, u32 svg_width if (!TextureNeedsSVGDimensions(name)) return FindCachedTexture(name); - svg_width = static_cast(std::ceil(LayoutScale(static_cast(svg_width)))); - svg_height = static_cast(std::ceil(LayoutScale(static_cast(svg_height)))); - const SmallString wh_name = SmallString::from_format("{}#{}x{}", name, svg_width, svg_height); std::shared_ptr* tex_ptr = s_state.texture_cache.Lookup(wh_name.view()); return tex_ptr ? tex_ptr->get() : nullptr; } +GPUTexture* FullscreenUI::FindCachedTexture(std::string_view name, const ImVec2& size) +{ + return FindCachedTexture(name, static_cast(size.x), static_cast(size.y)); +} + GPUTexture* FullscreenUI::GetCachedTexture(std::string_view name) { return GetCachedTexture(name, name); @@ -889,9 +893,6 @@ GPUTexture* FullscreenUI::GetCachedTexture(std::string_view name, u32 svg_width, if (!TextureNeedsSVGDimensions(name)) return GetCachedTexture(name); - svg_width = static_cast(std::ceil(LayoutScale(static_cast(svg_width)))); - svg_height = static_cast(std::ceil(LayoutScale(static_cast(svg_height)))); - const SmallString wh_name = SmallString::from_format("{}#{}x{}", name, svg_width, svg_height); std::shared_ptr* tex_ptr = s_state.texture_cache.Lookup(wh_name.view()); if (!tex_ptr) @@ -903,6 +904,11 @@ GPUTexture* FullscreenUI::GetCachedTexture(std::string_view name, u32 svg_width, return tex_ptr->get(); } +GPUTexture* FullscreenUI::GetCachedTexture(std::string_view name, const ImVec2& size) +{ + return GetCachedTexture(name, static_cast(size.x), static_cast(size.y)); +} + GPUTexture* FullscreenUI::LookupCachedTextureAsync(std::string_view path, std::string_view name, u32 svg_width, u32 svg_height) { @@ -977,13 +983,15 @@ GPUTexture* FullscreenUI::GetCachedTextureAsync(std::string_view name, u32 svg_w if (!TextureNeedsSVGDimensions(name)) return LookupCachedTextureAsync(name, {}, 0, 0); - svg_width = static_cast(std::ceil(LayoutScale(static_cast(svg_width)))); - svg_height = static_cast(std::ceil(LayoutScale(static_cast(svg_height)))); - const SmallString wh_name = SmallString::from_format("{}#{}x{}", name, svg_width, svg_height); return LookupCachedTextureAsync(name, wh_name.view(), svg_width, svg_height); } +GPUTexture* FullscreenUI::GetCachedTextureAsync(std::string_view name, const ImVec2& size) +{ + return GetCachedTextureAsync(name, static_cast(size.x), static_cast(size.y)); +} + bool FullscreenUI::InvalidateCachedTexture(std::string_view path) { // need to do a partial match on this because SVG diff --git a/src/core/fullscreenui_widgets.h b/src/core/fullscreenui_widgets.h index 414386d61..eff3f5639 100644 --- a/src/core/fullscreenui_widgets.h +++ b/src/core/fullscreenui_widgets.h @@ -260,14 +260,18 @@ const std::shared_ptr& GetPlaceholderTexture(); std::shared_ptr LoadTexture(std::string_view path); std::shared_ptr LoadTexture(std::string_view path, std::string_view name); std::shared_ptr LoadTexture(std::string_view path, u32 svg_width, u32 svg_height); +std::shared_ptr LoadTexture(std::string_view path, const ImVec2& size); GPUTexture* FindCachedTexture(std::string_view name); GPUTexture* FindCachedTexture(std::string_view name, u32 svg_width, u32 svg_height); +GPUTexture* FindCachedTexture(std::string_view name, const ImVec2& size); GPUTexture* GetCachedTexture(std::string_view name); GPUTexture* GetCachedTexture(std::string_view path, std::string_view name); GPUTexture* GetCachedTexture(std::string_view name, u32 svg_width, u32 svg_height); +GPUTexture* GetCachedTexture(std::string_view name, const ImVec2& size); GPUTexture* GetCachedTextureAsync(std::string_view name); GPUTexture* GetCachedTextureAsync(std::string_view path, std::string_view name); GPUTexture* GetCachedTextureAsync(std::string_view name, u32 svg_width, u32 svg_height); +GPUTexture* GetCachedTextureAsync(std::string_view name, const ImVec2& size); bool InvalidateCachedTexture(std::string_view path); bool TextureNeedsSVGDimensions(std::string_view path); void UploadAsyncTextures();