Skip to content

Commit d6ab840

Browse files
committed
FullscreenUI: Use RetroAchievements game icon as fallback game image
1 parent 492a55e commit d6ab840

4 files changed

Lines changed: 30 additions & 12 deletions

File tree

src/core/achievements.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,11 @@ const std::string& Achievements::GetGameTitle()
603603
return s_state.game_title;
604604
}
605605

606+
const std::string& Achievements::GetGamePath()
607+
{
608+
return s_state.game_path;
609+
}
610+
606611
const std::string& Achievements::GetGameIconPath()
607612
{
608613
return s_state.game_icon;

src/core/achievements.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,16 @@ const std::string& GetRichPresenceString();
155155
/// Returns the URL for the current icon of the game
156156
const std::string& GetGameIconURL();
157157

158+
/// Returns the path for the current icon of the game
159+
const std::string& GetGameIconPath();
160+
158161
/// Returns the RetroAchievements title for the current game.
159162
/// Should be called with the lock held.
160163
const std::string& GetGameTitle();
161164

165+
/// Returns the path for the game that is current hashed/running.
166+
const std::string& GetGamePath();
167+
162168
/// Returns the logged-in user name.
163169
const char* GetLoggedInUserName();
164170

src/core/achievements_private.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ namespace Achievements {
1313
rc_client_t* GetClient();
1414

1515
const rc_client_user_game_summary_t& GetGameSummary();
16-
const std::string& GetGameIconPath();
1716

1817
std::string GetAchievementBadgePath(const rc_client_achievement_t* achievement, int state,
1918
bool download_if_missing = true);

src/core/fullscreen_ui.cpp

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,8 @@ static void DrawGameListSettingsWindow();
448448
static void SwitchToGameList();
449449
static void PopulateGameListEntryList();
450450
static GPUTexture* GetTextureForGameListEntryType(GameList::EntryType type);
451-
static GPUTexture* GetGameListCover(const GameList::Entry* entry, bool fallback_to_icon);
451+
static GPUTexture* GetGameListCover(const GameList::Entry* entry, bool fallback_to_achievements_icon,
452+
bool fallback_to_icon);
452453
static GPUTexture* GetGameListCoverTrophy(const GameList::Entry* entry, const ImVec2& image_size);
453454
static GPUTexture* GetCoverForCurrentGame();
454455

@@ -7527,7 +7528,7 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
75277528
if (!visible)
75287529
continue;
75297530

7530-
GPUTexture* cover_texture = GetGameListCover(entry, true);
7531+
GPUTexture* cover_texture = GetGameListCover(entry, false, true);
75317532

75327533
if (entry->serial.empty())
75337534
{
@@ -7589,7 +7590,7 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
75897590
{
75907591
static constexpr float info_top_margin = 20.0f;
75917592
static constexpr float cover_size = 320.0f;
7592-
GPUTexture* cover_texture = selected_entry ? GetGameListCover(selected_entry, false) :
7593+
GPUTexture* cover_texture = selected_entry ? GetGameListCover(selected_entry, false, false) :
75937594
GetTextureForGameListEntryType(GameList::EntryType::Count);
75947595
if (cover_texture)
75957596
{
@@ -7803,7 +7804,7 @@ void FullscreenUI::DrawGameGrid(const ImVec2& heading_size)
78037804
bb.Min += style.FramePadding;
78047805
bb.Max -= style.FramePadding;
78057806

7806-
GPUTexture* const cover_texture = GetGameListCover(entry, false);
7807+
GPUTexture* const cover_texture = GetGameListCover(entry, false, false);
78077808
const ImRect image_rect(
78087809
CenterImage(ImRect(bb.Min, bb.Min + image_size), ImVec2(static_cast<float>(cover_texture->GetWidth()),
78097810
static_cast<float>(cover_texture->GetHeight()))));
@@ -8202,20 +8203,27 @@ void FullscreenUI::SwitchToGameList()
82028203
QueueResetFocus(FocusResetType::ViewChanged);
82038204
}
82048205

8205-
GPUTexture* FullscreenUI::GetGameListCover(const GameList::Entry* entry, bool fallback_to_icon)
8206+
GPUTexture* FullscreenUI::GetGameListCover(const GameList::Entry* entry, bool fallback_to_achievements_icon,
8207+
bool fallback_to_icon)
82068208
{
82078209
// lookup and grab cover image
82088210
auto cover_it = s_state.cover_image_map.find(entry->path);
82098211
if (cover_it == s_state.cover_image_map.end())
82108212
{
82118213
std::string cover_path = GameList::GetCoverImagePathForEntry(entry);
82128214
cover_it = s_state.cover_image_map.emplace(entry->path, std::move(cover_path)).first;
8213-
}
82148215

8215-
if (fallback_to_icon && cover_it->second.empty())
8216-
{
8217-
std::string icon_path = GameList::GetGameIconPath(entry->serial, entry->path);
8218-
cover_it = s_state.icon_image_map.emplace(entry->path, std::move(icon_path)).first;
8216+
// try achievements image before memcard icon
8217+
if (fallback_to_achievements_icon && cover_it->second.empty() && Achievements::IsActive())
8218+
{
8219+
const auto lock = Achievements::GetLock();
8220+
if (Achievements::GetGamePath() == entry->path)
8221+
cover_it->second = Achievements::GetGameIconPath();
8222+
}
8223+
8224+
// because memcard icons are crap res
8225+
if (fallback_to_icon && cover_it->second.empty())
8226+
cover_it->second = GameList::GetGameIconPath(entry->serial, entry->path);
82198227
}
82208228

82218229
GPUTexture* tex = (!cover_it->second.empty()) ? GetCachedTextureAsync(cover_it->second.c_str()) : nullptr;
@@ -8265,7 +8273,7 @@ GPUTexture* FullscreenUI::GetCoverForCurrentGame()
82658273
if (!entry)
82668274
return s_state.fallback_disc_texture.get();
82678275

8268-
return GetGameListCover(entry, true);
8276+
return GetGameListCover(entry, true, true);
82698277
}
82708278

82718279
//////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)