From c217b3ee3231d5b7e2eed21896f72e9de05f5ea1 Mon Sep 17 00:00:00 2001 From: MythicalPlayz <57963367+MythicalPlayz@users.noreply.github.com> Date: Fri, 21 Oct 2022 00:17:11 +0200 Subject: [PATCH] GameList: Use title name based on console language (#388) --- src/Cafe/CafeSystem.cpp | 8 +++++++- src/Cafe/TitleList/TitleInfo.cpp | 10 +++++++++- src/gui/MainWindow.cpp | 2 ++ src/gui/components/wxGameList.cpp | 5 +++++ src/gui/components/wxGameList.h | 1 + 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Cafe/CafeSystem.cpp b/src/Cafe/CafeSystem.cpp index acfd1d2f..68484830 100644 --- a/src/Cafe/CafeSystem.cpp +++ b/src/Cafe/CafeSystem.cpp @@ -705,7 +705,13 @@ namespace CafeSystem { if (sLaunchModeIsStandalone) return "Unknown Game"; - return sGameInfo_ForegroundTitle.GetBase().GetMetaInfo()->GetShortName(GetConfig().console_language); + std::string applicationName; + applicationName = sGameInfo_ForegroundTitle.GetBase().GetMetaInfo()->GetShortName(GetConfig().console_language); + if (applicationName.empty()) //Try to get the English Title + applicationName = sGameInfo_ForegroundTitle.GetBase().GetMetaInfo()->GetShortName(CafeConsoleLanguage::EN); + if (applicationName.empty()) //Unknown Game + applicationName = "Unknown Game"; + return applicationName; } std::string GetForegroundTitleArgStr() diff --git a/src/Cafe/TitleList/TitleInfo.cpp b/src/Cafe/TitleList/TitleInfo.cpp index 10710c43..36814ab8 100644 --- a/src/Cafe/TitleList/TitleInfo.cpp +++ b/src/Cafe/TitleList/TitleInfo.cpp @@ -589,7 +589,15 @@ std::string TitleInfo::GetTitleName() const { cemu_assert_debug(m_isValid); if (m_parsedMetaXml) - return m_parsedMetaXml->GetShortName(CafeConsoleLanguage::EN); + { + std::string titleNameCfgLanguage; + titleNameCfgLanguage = m_parsedMetaXml->GetShortName(GetConfig().console_language); + if (titleNameCfgLanguage.empty()) //Get English Title + titleNameCfgLanguage = m_parsedMetaXml->GetShortName(CafeConsoleLanguage::EN); + if (titleNameCfgLanguage.empty()) //Unknown Title + titleNameCfgLanguage = "Unknown Title"; + return titleNameCfgLanguage; + } if (m_cachedInfo) return m_cachedInfo->titleName; cemu_assert_suspicious(); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index fb18a7de..e8d1c920 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -931,6 +931,8 @@ void MainWindow::OnConsoleLanguage(wxCommandEvent& event) default: cemu_assert_debug(false); } + m_game_list->DeleteCachedStrings(); + m_game_list->ReloadGameEntries(false); g_config.Save(); } diff --git a/src/gui/components/wxGameList.cpp b/src/gui/components/wxGameList.cpp index 904fd5b7..50a6254a 100644 --- a/src/gui/components/wxGameList.cpp +++ b/src/gui/components/wxGameList.cpp @@ -1139,3 +1139,8 @@ bool wxGameList::QueryIconForTitle(TitleId titleId, int& icon, int& iconSmall) m_icon_cache_mtx.unlock(); return true; } + +void wxGameList::DeleteCachedStrings() +{ + m_name_cache.clear(); +} \ No newline at end of file diff --git a/src/gui/components/wxGameList.h b/src/gui/components/wxGameList.h index 2cf9f6b7..f8efd5d2 100644 --- a/src/gui/components/wxGameList.h +++ b/src/gui/components/wxGameList.h @@ -50,6 +50,7 @@ public: bool IsVisible(long item) const; // only available in wxwidgets 3.1.3 void ReloadGameEntries(bool cached = false); + void DeleteCachedStrings(); long FindListItemByTitleId(uint64 title_id) const; void OnClose(wxCloseEvent& event);