mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-07 20:15:32 +00:00
FullscreenUI: Use RetroAchievements game icon as fallback game image
This commit is contained in:
parent
492a55ee8b
commit
d6ab840e4b
@ -603,6 +603,11 @@ const std::string& Achievements::GetGameTitle()
|
|||||||
return s_state.game_title;
|
return s_state.game_title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& Achievements::GetGamePath()
|
||||||
|
{
|
||||||
|
return s_state.game_path;
|
||||||
|
}
|
||||||
|
|
||||||
const std::string& Achievements::GetGameIconPath()
|
const std::string& Achievements::GetGameIconPath()
|
||||||
{
|
{
|
||||||
return s_state.game_icon;
|
return s_state.game_icon;
|
||||||
|
@ -155,10 +155,16 @@ const std::string& GetRichPresenceString();
|
|||||||
/// Returns the URL for the current icon of the game
|
/// Returns the URL for the current icon of the game
|
||||||
const std::string& GetGameIconURL();
|
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.
|
/// Returns the RetroAchievements title for the current game.
|
||||||
/// Should be called with the lock held.
|
/// Should be called with the lock held.
|
||||||
const std::string& GetGameTitle();
|
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.
|
/// Returns the logged-in user name.
|
||||||
const char* GetLoggedInUserName();
|
const char* GetLoggedInUserName();
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ namespace Achievements {
|
|||||||
rc_client_t* GetClient();
|
rc_client_t* GetClient();
|
||||||
|
|
||||||
const rc_client_user_game_summary_t& GetGameSummary();
|
const rc_client_user_game_summary_t& GetGameSummary();
|
||||||
const std::string& GetGameIconPath();
|
|
||||||
|
|
||||||
std::string GetAchievementBadgePath(const rc_client_achievement_t* achievement, int state,
|
std::string GetAchievementBadgePath(const rc_client_achievement_t* achievement, int state,
|
||||||
bool download_if_missing = true);
|
bool download_if_missing = true);
|
||||||
|
@ -448,7 +448,8 @@ static void DrawGameListSettingsWindow();
|
|||||||
static void SwitchToGameList();
|
static void SwitchToGameList();
|
||||||
static void PopulateGameListEntryList();
|
static void PopulateGameListEntryList();
|
||||||
static GPUTexture* GetTextureForGameListEntryType(GameList::EntryType type);
|
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* GetGameListCoverTrophy(const GameList::Entry* entry, const ImVec2& image_size);
|
||||||
static GPUTexture* GetCoverForCurrentGame();
|
static GPUTexture* GetCoverForCurrentGame();
|
||||||
|
|
||||||
@ -7527,7 +7528,7 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
|
|||||||
if (!visible)
|
if (!visible)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
GPUTexture* cover_texture = GetGameListCover(entry, true);
|
GPUTexture* cover_texture = GetGameListCover(entry, false, true);
|
||||||
|
|
||||||
if (entry->serial.empty())
|
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 info_top_margin = 20.0f;
|
||||||
static constexpr float cover_size = 320.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);
|
GetTextureForGameListEntryType(GameList::EntryType::Count);
|
||||||
if (cover_texture)
|
if (cover_texture)
|
||||||
{
|
{
|
||||||
@ -7803,7 +7804,7 @@ void FullscreenUI::DrawGameGrid(const ImVec2& heading_size)
|
|||||||
bb.Min += style.FramePadding;
|
bb.Min += style.FramePadding;
|
||||||
bb.Max -= 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(
|
const ImRect image_rect(
|
||||||
CenterImage(ImRect(bb.Min, bb.Min + image_size), ImVec2(static_cast<float>(cover_texture->GetWidth()),
|
CenterImage(ImRect(bb.Min, bb.Min + image_size), ImVec2(static_cast<float>(cover_texture->GetWidth()),
|
||||||
static_cast<float>(cover_texture->GetHeight()))));
|
static_cast<float>(cover_texture->GetHeight()))));
|
||||||
@ -8202,7 +8203,8 @@ void FullscreenUI::SwitchToGameList()
|
|||||||
QueueResetFocus(FocusResetType::ViewChanged);
|
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
|
// lookup and grab cover image
|
||||||
auto cover_it = s_state.cover_image_map.find(entry->path);
|
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);
|
std::string cover_path = GameList::GetCoverImagePathForEntry(entry);
|
||||||
cover_it = s_state.cover_image_map.emplace(entry->path, std::move(cover_path)).first;
|
cover_it = s_state.cover_image_map.emplace(entry->path, std::move(cover_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())
|
if (fallback_to_icon && cover_it->second.empty())
|
||||||
{
|
cover_it->second = GameList::GetGameIconPath(entry->serial, entry->path);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GPUTexture* tex = (!cover_it->second.empty()) ? GetCachedTextureAsync(cover_it->second.c_str()) : nullptr;
|
GPUTexture* tex = (!cover_it->second.empty()) ? GetCachedTextureAsync(cover_it->second.c_str()) : nullptr;
|
||||||
@ -8265,7 +8273,7 @@ GPUTexture* FullscreenUI::GetCoverForCurrentGame()
|
|||||||
if (!entry)
|
if (!entry)
|
||||||
return s_state.fallback_disc_texture.get();
|
return s_state.fallback_disc_texture.get();
|
||||||
|
|
||||||
return GetGameListCover(entry, true);
|
return GetGameListCover(entry, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user