FullscreenUI: Fix double scaling of some UI elements

pull/3745/head
Stenzek 4 months ago
parent 099f8bdd22
commit dddc091221
No known key found for this signature in database

@ -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(

@ -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<u32>(ra_logo_rect.GetWidth()),
static_cast<u32>(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();

@ -839,13 +839,15 @@ std::shared_ptr<GPUTexture> FullscreenUI::LoadTexture(std::string_view name, u32
if (!TextureNeedsSVGDimensions(name))
return LoadTexture(name, name, 0, 0);
svg_width = static_cast<u32>(std::ceil(LayoutScale(static_cast<float>(svg_width))));
svg_height = static_cast<u32>(std::ceil(LayoutScale(static_cast<float>(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<GPUTexture> FullscreenUI::LoadTexture(std::string_view name, const ImVec2& size)
{
return LoadTexture(name, name, static_cast<u32>(size.x), static_cast<u32>(size.y));
}
GPUTexture* FullscreenUI::FindCachedTexture(std::string_view name)
{
std::shared_ptr<GPUTexture>* 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<u32>(std::ceil(LayoutScale(static_cast<float>(svg_width))));
svg_height = static_cast<u32>(std::ceil(LayoutScale(static_cast<float>(svg_height))));
const SmallString wh_name = SmallString::from_format("{}#{}x{}", name, svg_width, svg_height);
std::shared_ptr<GPUTexture>* 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<u32>(size.x), static_cast<u32>(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<u32>(std::ceil(LayoutScale(static_cast<float>(svg_width))));
svg_height = static_cast<u32>(std::ceil(LayoutScale(static_cast<float>(svg_height))));
const SmallString wh_name = SmallString::from_format("{}#{}x{}", name, svg_width, svg_height);
std::shared_ptr<GPUTexture>* 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<u32>(size.x), static_cast<u32>(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<u32>(std::ceil(LayoutScale(static_cast<float>(svg_width))));
svg_height = static_cast<u32>(std::ceil(LayoutScale(static_cast<float>(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<u32>(size.x), static_cast<u32>(size.y));
}
bool FullscreenUI::InvalidateCachedTexture(std::string_view path)
{
// need to do a partial match on this because SVG

@ -260,14 +260,18 @@ const std::shared_ptr<GPUTexture>& GetPlaceholderTexture();
std::shared_ptr<GPUTexture> LoadTexture(std::string_view path);
std::shared_ptr<GPUTexture> LoadTexture(std::string_view path, std::string_view name);
std::shared_ptr<GPUTexture> LoadTexture(std::string_view path, u32 svg_width, u32 svg_height);
std::shared_ptr<GPUTexture> 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();

Loading…
Cancel
Save