From 90997d4a8b6fdb604f3516fa4ae3fe03610d7410 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 12 Dec 2020 12:23:53 +1000 Subject: [PATCH] GameList: Prioritize game title cover image over database title --- src/frontend-common/game_list.cpp | 32 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/frontend-common/game_list.cpp b/src/frontend-common/game_list.cpp index 84c65c9be..838638db6 100644 --- a/src/frontend-common/game_list.cpp +++ b/src/frontend-common/game_list.cpp @@ -1151,6 +1151,22 @@ std::string GameList::GetCoverImagePathForEntry(const GameListEntry* entry) cons PathString cover_path; for (const char* extension : extensions) { + // use the file title if it differs (e.g. modded games) + const std::string_view file_title = System::GetTitleForPath(entry->path.c_str()); + if (!file_title.empty() && entry->title != file_title) + { + cover_path.Clear(); + cover_path.AppendString(g_host_interface->GetUserDirectory().c_str()); + cover_path.AppendCharacter(FS_OSPATH_SEPERATOR_CHARACTER); + cover_path.AppendString("covers"); + cover_path.AppendCharacter(FS_OSPATH_SEPERATOR_CHARACTER); + cover_path.AppendString(file_title.data(), static_cast(file_title.size())); + cover_path.AppendCharacter('.'); + cover_path.AppendString(extension); + if (FileSystem::FileExists(cover_path)) + return std::string(cover_path.GetCharArray()); + } + // try the title if (!entry->title.empty()) { @@ -1168,22 +1184,6 @@ std::string GameList::GetCoverImagePathForEntry(const GameListEntry* entry) cons if (FileSystem::FileExists(cover_path)) return std::string(cover_path.GetCharArray()); } - - // and the file title if it differs - const std::string_view file_title = System::GetTitleForPath(entry->path.c_str()); - if (!file_title.empty() && entry->title != file_title) - { - cover_path.Clear(); - cover_path.AppendString(g_host_interface->GetUserDirectory().c_str()); - cover_path.AppendCharacter(FS_OSPATH_SEPERATOR_CHARACTER); - cover_path.AppendString("covers"); - cover_path.AppendCharacter(FS_OSPATH_SEPERATOR_CHARACTER); - cover_path.AppendString(file_title.data(), static_cast(file_title.size())); - cover_path.AppendCharacter('.'); - cover_path.AppendString(extension); - if (FileSystem::FileExists(cover_path)) - return std::string(cover_path.GetCharArray()); - } } return std::string();