diff --git a/src/core/achievements.cpp b/src/core/achievements.cpp index cc65e0f4d..a9da8ea40 100644 --- a/src/core/achievements.cpp +++ b/src/core/achievements.cpp @@ -603,6 +603,11 @@ const std::string& Achievements::GetGameTitle() return s_state.game_title; } +const std::string& Achievements::GetGamePath() +{ + return s_state.game_path; +} + const std::string& Achievements::GetGameIconPath() { return s_state.game_icon; diff --git a/src/core/achievements.h b/src/core/achievements.h index 0ce6149f3..51eb33fb1 100644 --- a/src/core/achievements.h +++ b/src/core/achievements.h @@ -155,10 +155,16 @@ const std::string& GetRichPresenceString(); /// Returns the URL for the current icon of the game const std::string& GetGameIconURL(); +/// Returns the path for the current icon of the game +const std::string& GetGameIconPath(); + /// Returns the RetroAchievements title for the current game. /// Should be called with the lock held. const std::string& GetGameTitle(); +/// Returns the path for the game that is current hashed/running. +const std::string& GetGamePath(); + /// Returns the logged-in user name. const char* GetLoggedInUserName(); diff --git a/src/core/achievements_private.h b/src/core/achievements_private.h index 0444d4c0c..89483f4e9 100644 --- a/src/core/achievements_private.h +++ b/src/core/achievements_private.h @@ -13,7 +13,6 @@ namespace Achievements { rc_client_t* GetClient(); const rc_client_user_game_summary_t& GetGameSummary(); -const std::string& GetGameIconPath(); std::string GetAchievementBadgePath(const rc_client_achievement_t* achievement, int state, bool download_if_missing = true); diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index b4faea4a4..b9419713f 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -448,7 +448,8 @@ static void DrawGameListSettingsWindow(); static void SwitchToGameList(); static void PopulateGameListEntryList(); static GPUTexture* GetTextureForGameListEntryType(GameList::EntryType type); -static GPUTexture* GetGameListCover(const GameList::Entry* entry, bool fallback_to_icon); +static GPUTexture* GetGameListCover(const GameList::Entry* entry, bool fallback_to_achievements_icon, + bool fallback_to_icon); static GPUTexture* GetGameListCoverTrophy(const GameList::Entry* entry, const ImVec2& image_size); static GPUTexture* GetCoverForCurrentGame(); @@ -7527,7 +7528,7 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size) if (!visible) continue; - GPUTexture* cover_texture = GetGameListCover(entry, true); + GPUTexture* cover_texture = GetGameListCover(entry, false, true); if (entry->serial.empty()) { @@ -7589,7 +7590,7 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size) { static constexpr float info_top_margin = 20.0f; static constexpr float cover_size = 320.0f; - GPUTexture* cover_texture = selected_entry ? GetGameListCover(selected_entry, false) : + GPUTexture* cover_texture = selected_entry ? GetGameListCover(selected_entry, false, false) : GetTextureForGameListEntryType(GameList::EntryType::Count); if (cover_texture) { @@ -7803,7 +7804,7 @@ void FullscreenUI::DrawGameGrid(const ImVec2& heading_size) bb.Min += style.FramePadding; bb.Max -= style.FramePadding; - GPUTexture* const cover_texture = GetGameListCover(entry, false); + GPUTexture* const cover_texture = GetGameListCover(entry, false, false); const ImRect image_rect( CenterImage(ImRect(bb.Min, bb.Min + image_size), ImVec2(static_cast(cover_texture->GetWidth()), static_cast(cover_texture->GetHeight())))); @@ -8202,7 +8203,8 @@ void FullscreenUI::SwitchToGameList() QueueResetFocus(FocusResetType::ViewChanged); } -GPUTexture* FullscreenUI::GetGameListCover(const GameList::Entry* entry, bool fallback_to_icon) +GPUTexture* FullscreenUI::GetGameListCover(const GameList::Entry* entry, bool fallback_to_achievements_icon, + bool fallback_to_icon) { // lookup and grab cover image auto cover_it = s_state.cover_image_map.find(entry->path); @@ -8210,12 +8212,18 @@ GPUTexture* FullscreenUI::GetGameListCover(const GameList::Entry* entry, bool fa { std::string cover_path = GameList::GetCoverImagePathForEntry(entry); cover_it = s_state.cover_image_map.emplace(entry->path, std::move(cover_path)).first; - } - if (fallback_to_icon && cover_it->second.empty()) - { - std::string icon_path = GameList::GetGameIconPath(entry->serial, entry->path); - cover_it = s_state.icon_image_map.emplace(entry->path, std::move(icon_path)).first; + // try achievements image before memcard icon + if (fallback_to_achievements_icon && cover_it->second.empty() && Achievements::IsActive()) + { + const auto lock = Achievements::GetLock(); + if (Achievements::GetGamePath() == entry->path) + cover_it->second = Achievements::GetGameIconPath(); + } + + // because memcard icons are crap res + if (fallback_to_icon && cover_it->second.empty()) + cover_it->second = GameList::GetGameIconPath(entry->serial, entry->path); } GPUTexture* tex = (!cover_it->second.empty()) ? GetCachedTextureAsync(cover_it->second.c_str()) : nullptr; @@ -8265,7 +8273,7 @@ GPUTexture* FullscreenUI::GetCoverForCurrentGame() if (!entry) return s_state.fallback_disc_texture.get(); - return GetGameListCover(entry, true); + return GetGameListCover(entry, true, true); } //////////////////////////////////////////////////////////////////////////