Separate banner and volume name getting functions. Game properties now shows the correct "banner" name in more cases.

This commit is contained in:
Jordan Woyak 2013-03-03 18:29:56 -06:00
parent a30636cb88
commit 6026b29844
4 changed files with 54 additions and 31 deletions

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -22,7 +22,6 @@
#include "NetPlay.h"
#include "NetWindow.h"
#include "Frame.h"
#include "ConfigManager.h"
#include <sstream>
#include <string>
@ -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)