From 6026b298449f480ea96285242c4ed9253c854a22 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Sun, 3 Mar 2013 18:29:56 -0600 Subject: [PATCH] Separate banner and volume name getting functions. Game properties now shows the correct "banner" name in more cases. --- Source/Core/DolphinWX/Src/ISOFile.cpp | 50 +++++++++++++++------ Source/Core/DolphinWX/Src/ISOFile.h | 2 + Source/Core/DolphinWX/Src/ISOProperties.cpp | 21 ++++----- Source/Core/DolphinWX/Src/NetWindow.cpp | 12 ++--- 4 files changed, 54 insertions(+), 31 deletions(-) diff --git a/Source/Core/DolphinWX/Src/ISOFile.cpp b/Source/Core/DolphinWX/Src/ISOFile.cpp index ec8280a726..797780c32e 100644 --- a/Source/Core/DolphinWX/Src/ISOFile.cpp +++ b/Source/Core/DolphinWX/Src/ISOFile.cpp @@ -226,28 +226,50 @@ std::string GameListItem::GetDescription(int _index) const } // (-1 = Japanese, 0 = English, etc) -std::string GameListItem::GetName(int _index) const +std::string GameListItem::GetVolumeName(int _index) const { u32 const index = _index + 1; - // banner name - if (index < m_names.size() && !m_names[index].empty()) - return m_names[index]; - - if (!m_names.empty() && !m_names[0].empty()) - return m_names[0]; - - // volume name if (index < m_volume_names.size() && !m_volume_names[index].empty()) return m_volume_names[index]; - if (!m_volume_names.empty() && !m_volume_names[0].empty()) + if (!m_volume_names.empty()) return m_volume_names[0]; + + return ""; +} - // No usable name, return filename (better than nothing) - std::string FileName; - SplitPath(m_FileName, NULL, &FileName, NULL); - return FileName; +// (-1 = Japanese, 0 = English, etc) +std::string GameListItem::GetBannerName(int _index) const +{ + u32 const index = _index + 1; + + if (index < m_names.size() && !m_names[index].empty()) + return m_names[index]; + + if (!m_names.empty()) + return m_names[0]; + + return ""; +} + +// (-1 = Japanese, 0 = English, etc) +std::string GameListItem::GetName(int _index) const +{ + // Prefer name from banner, fallback to name from volume, fallback to filename + + std::string name = GetBannerName(_index); + + if (name.empty()) + name = GetVolumeName(_index); + + if (name.empty()) + { + // No usable name, return filename (better than nothing) + SplitPath(GetFileName(), NULL, &name, NULL); + } + + return name; } const std::string GameListItem::GetWiiFSPath() const diff --git a/Source/Core/DolphinWX/Src/ISOFile.h b/Source/Core/DolphinWX/Src/ISOFile.h index ded392f56a..354a2f7fad 100644 --- a/Source/Core/DolphinWX/Src/ISOFile.h +++ b/Source/Core/DolphinWX/Src/ISOFile.h @@ -37,6 +37,8 @@ public: bool IsValid() const {return m_Valid;} const std::string& GetFileName() const {return m_FileName;} + std::string GetBannerName(int index) const; + std::string GetVolumeName(int index) const; std::string GetName(int index) const; std::string GetCompany() const; std::string GetDescription(int index = 0) const; diff --git a/Source/Core/DolphinWX/Src/ISOProperties.cpp b/Source/Core/DolphinWX/Src/ISOProperties.cpp index 43657300cb..f6ca1cb851 100644 --- a/Source/Core/DolphinWX/Src/ISOProperties.cpp +++ b/Source/Core/DolphinWX/Src/ISOProperties.cpp @@ -1301,28 +1301,25 @@ void CISOProperties::OnChangeBannerLang(wxCommandEvent& event) void CISOProperties::ChangeBannerDetails(int lang) { - std::string name; - wxString shortName, - comment, - maker; - + // why? switch (OpenGameListItem->GetCountry()) { case DiscIO::IVolume::COUNTRY_TAIWAN: case DiscIO::IVolume::COUNTRY_JAPAN: - shortName = StrToWxStr(OpenGameListItem->GetName(-1)); - comment = StrToWxStr(OpenGameListItem->GetDescription()); + lang = -1; break; + case DiscIO::IVolume::COUNTRY_USA: - // why? lang = 0; + break; + default: - shortName = StrToWxStr(OpenGameListItem->GetName(lang)); - comment = StrToWxStr(OpenGameListItem->GetDescription(lang)); break; } - - maker = StrToWxStr(OpenGameListItem->GetCompany()); + + wxString const shortName = StrToWxStr(OpenGameListItem->GetBannerName(lang)); + wxString const comment = StrToWxStr(OpenGameListItem->GetDescription(lang)); + wxString const maker = StrToWxStr(OpenGameListItem->GetCompany()); // Updates the informations shown in the window m_ShortName->SetValue(shortName); diff --git a/Source/Core/DolphinWX/Src/NetWindow.cpp b/Source/Core/DolphinWX/Src/NetWindow.cpp index 28c7f930d7..76bb76881b 100644 --- a/Source/Core/DolphinWX/Src/NetWindow.cpp +++ b/Source/Core/DolphinWX/Src/NetWindow.cpp @@ -22,7 +22,6 @@ #include "NetPlay.h" #include "NetWindow.h" #include "Frame.h" -#include "ConfigManager.h" #include #include @@ -39,11 +38,14 @@ NetPlayDiag *NetPlayDiag::npd = NULL; std::string BuildGameName(const GameListItem& game) { - auto const selected_lang = SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage; + // Lang needs to be consistent + auto const lang = 0; - // TODO: this should use the name from the volume not the banner - // (I seems banner name can sometimes depend on save contents) - return game.GetName(selected_lang) + " (" + game.GetUniqueID() + ")"; + std::string name(game.GetBannerName(lang)); + if (name.empty()) + name = game.GetVolumeName(lang); + + return name + " (" + game.GetUniqueID() + ")"; } void FillWithGameNames(wxListBox* game_lbox, const CGameListCtrl& game_list)