Skip to content

Commit

Permalink
DolphinQt: Use short GC game titles in grid view
Browse files Browse the repository at this point in the history
Short titles fit better than long titles.
  • Loading branch information
JosJuice committed May 15, 2015
1 parent 3d5a316 commit 638b51a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
26 changes: 16 additions & 10 deletions Source/Core/DolphinQt/GameList/GameFile.cpp
Expand Up @@ -25,7 +25,7 @@
#include "DolphinQt/Utils/Resources.h"
#include "DolphinQt/Utils/Utils.h"

static const u32 CACHE_REVISION = 0x007;
static const u32 CACHE_REVISION = 0x008;
static const u32 DATASTREAM_REVISION = 15; // Introduced in Qt 5.2

static QMap<DiscIO::IVolume::ELanguage, QString> ConvertLocalizedStrings(std::map<DiscIO::IVolume::ELanguage, std::string> strings)
Expand Down Expand Up @@ -90,7 +90,8 @@ GameFile::GameFile(const QString& fileName)
else
m_platform = WII_WAD;

m_names = ConvertLocalizedStrings(volume->GetNames(true));
m_short_names = ConvertLocalizedStrings(volume->GetNames(false));
m_long_names = ConvertLocalizedStrings(volume->GetNames(true));
m_descriptions = ConvertLocalizedStrings(volume->GetDescriptions());
m_company = QString::fromStdString(volume->GetCompany());

Expand Down Expand Up @@ -164,10 +165,12 @@ bool GameFile::LoadFromCache()
return false;

u32 country;
QMap<u8, QString> names;
QMap<u8, QString> short_names;
QMap<u8, QString> long_names;
QMap<u8, QString> descriptions;
stream >> m_folder_name
>> names
>> short_names
>> long_names
>> descriptions
>> m_company
>> m_unique_id
Expand All @@ -180,7 +183,8 @@ bool GameFile::LoadFromCache()
>> m_is_disc_two
>> m_revision;
m_country = (DiscIO::IVolume::ECountry)country;
m_names = CastLocalizedStrings<DiscIO::IVolume::ELanguage>(names);
m_short_names = CastLocalizedStrings<DiscIO::IVolume::ELanguage>(short_names);
m_long_names = CastLocalizedStrings<DiscIO::IVolume::ELanguage>(long_names);
m_descriptions = CastLocalizedStrings<DiscIO::IVolume::ELanguage>(descriptions);
file.close();
return true;
Expand All @@ -207,7 +211,8 @@ void GameFile::SaveToCache()
stream << CACHE_REVISION;

stream << m_folder_name
<< CastLocalizedStrings<u8>(m_names)
<< CastLocalizedStrings<u8>(m_short_names)
<< CastLocalizedStrings<u8>(m_long_names)
<< CastLocalizedStrings<u8>(m_descriptions)
<< m_company
<< m_unique_id
Expand Down Expand Up @@ -255,14 +260,15 @@ QString GameFile::GetDescription() const
return GetDescription(SConfig::GetInstance().m_LocalCoreStartupParameter.GetCurrentLanguage(m_platform != GAMECUBE_DISC));
}

QString GameFile::GetName(DiscIO::IVolume::ELanguage language) const
QString GameFile::GetName(bool prefer_long, DiscIO::IVolume::ELanguage language) const
{
return GetLanguageString(language, m_names);
return GetLanguageString(language, prefer_long ? m_long_names : m_short_names);
}

QString GameFile::GetName() const
QString GameFile::GetName(bool prefer_long) const
{
QString name = GetName(SConfig::GetInstance().m_LocalCoreStartupParameter.GetCurrentLanguage(m_platform != GAMECUBE_DISC));
bool wii = m_platform != GAMECUBE_DISC;
QString name = GetName(prefer_long, SConfig::GetInstance().m_LocalCoreStartupParameter.GetCurrentLanguage(wii));
if (name.isEmpty())
{
// No usable name, return filename (better than nothing)
Expand Down
7 changes: 4 additions & 3 deletions Source/Core/DolphinQt/GameList/GameFile.h
Expand Up @@ -22,8 +22,8 @@ class GameFile final
bool IsValid() const { return m_valid; }
QString GetFileName() { return m_file_name; }
QString GetFolderName() { return m_folder_name; }
QString GetName(DiscIO::IVolume::ELanguage language) const;
QString GetName() const;
QString GetName(bool prefer_long, DiscIO::IVolume::ELanguage language) const;
QString GetName(bool prefer_long) const;
QString GetDescription(DiscIO::IVolume::ELanguage language) const;
QString GetDescription() const;
QString GetCompany() const;
Expand Down Expand Up @@ -52,7 +52,8 @@ class GameFile final
QString m_file_name;
QString m_folder_name;

QMap<DiscIO::IVolume::ELanguage, QString> m_names;
QMap<DiscIO::IVolume::ELanguage, QString> m_short_names;
QMap<DiscIO::IVolume::ELanguage, QString> m_long_names;
QMap<DiscIO::IVolume::ELanguage, QString> m_descriptions;
QString m_company;

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinQt/GameList/GameGrid.cpp
Expand Up @@ -76,7 +76,7 @@ void DGameGrid::AddGame(GameFile* gameItem)
QListWidgetItem* i = new QListWidgetItem;
i->setIcon(QIcon(gameItem->GetBitmap()
.scaled(GRID_BANNER_WIDTH, GRID_BANNER_HEIGHT, Qt::KeepAspectRatio, Qt::SmoothTransformation)));
i->setText(gameItem->GetName());
i->setText(gameItem->GetName(false));
if (gameItem->IsCompressed())
i->setTextColor(QColor("#00F"));

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinQt/GameList/GameTree.cpp
Expand Up @@ -110,7 +110,7 @@ void DGameTree::AddGame(GameFile* item)
QTreeWidgetItem* i = new QTreeWidgetItem;
i->setIcon(COL_TYPE, QIcon(Resources::GetPlatformPixmap(item->GetPlatform())));
i->setIcon(COL_BANNER, QIcon(item->GetBitmap()));
i->setText(COL_TITLE, item->GetName());
i->setText(COL_TITLE, item->GetName(true));
i->setText(COL_DESCRIPTION, item->GetDescription());
i->setIcon(COL_REGION, QIcon(Resources::GetRegionPixmap(item->GetCountry())));
i->setText(COL_SIZE, NiceSizeFormat(item->GetFileSize()));
Expand Down

0 comments on commit 638b51a

Please sign in to comment.