Qt: Readability and prevents false matches regions

Code readability is easier if you check out this page and also prevents false matches like PAL-FI which is a Finnish game would trigger PAL-F which gives a French flag.
This commit is contained in:
RedDevilus 2022-06-01 16:49:09 +02:00 committed by refractionpcsx2
parent 815c0a394d
commit 5063961748
3 changed files with 30 additions and 23 deletions

View File

@ -281,8 +281,9 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
return m_type_exe_pixmap;
}
}
case Column_Region:
{
{
return m_region_pixmaps[static_cast<int>(ge->region)];
}
@ -459,9 +460,9 @@ void GameListModel::loadCommonImages()
for (u32 i = 0; i < static_cast<u32>(GameList::Region::Count); i++)
{
m_region_pixmaps[i] = QIcon(
QStringLiteral(":/icons/flags/%1.png").arg(GameList::RegionToString(static_cast<GameList::Region>(i))))
.pixmap(QSize(42, 30));
}
QStringLiteral(":/icons/flags/%1.png").arg(GameList::RegionToString(static_cast<GameList::Region>(i))))
.pixmap(QSize(42, 30));
}
for (u32 i = 1; i < GameList::CompatibilityRatingCount; i++)
m_compatibility_pixmaps[i].load(QStringLiteral(":/icons/star-%1.png").arg(i - 1));

View File

@ -89,7 +89,9 @@ const char* GameList::EntryTypeToString(EntryType type)
const char* GameList::RegionToString(Region region)
{
static std::array<const char*, static_cast<int>(Region::Count)> names = {
{"NTSC-B", "NTSC-C", "NTSC-HK", "NTSC-J", "NTSC-K", "NTSC-T", "NTSC-U", "Other", "PAL-A", "PAL-AF", "PAL-AU", "PAL-BE", "PAL-E", "PAL-F", "PAL-FI", "PAL-G", "PAL-GR", "PAL-I", "PAL-IN", "PAL-M", "PAL-NL", "PAL-NO", "PAL-P", "PAL-R", "PAL-S", "PAL-SC", "PAL-SW", "PAL-SWI", "PAL-UK"}};
{"NTSC-B", "NTSC-C", "NTSC-HK", "NTSC-J", "NTSC-K", "NTSC-T", "NTSC-U",
"Other",
"PAL-A", "PAL-AF", "PAL-AU", "PAL-BE", "PAL-E", "PAL-F", "PAL-FI", "PAL-G", "PAL-GR", "PAL-I", "PAL-IN", "PAL-M", "PAL-NL", "PAL-NO", "PAL-P", "PAL-R", "PAL-S", "PAL-SC", "PAL-SW", "PAL-SWI", "PAL-UK"}};
return names[static_cast<int>(region)];
}
@ -225,6 +227,8 @@ bool GameList::GetIsoListEntry(const std::string& path, GameList::Entry* entry)
{
entry->title = std::move(db_entry->name);
entry->compatibility_rating = db_entry->compat;
////// NTSC //////
//////////////////
if (StringUtil::StartsWith(db_entry->region, "NTSC-B"))
entry->region = Region::NTSC_B;
else if (StringUtil::StartsWith(db_entry->region, "NTSC-C"))
@ -239,28 +243,30 @@ bool GameList::GetIsoListEntry(const std::string& path, GameList::Entry* entry)
entry->region = Region::NTSC_T;
else if (StringUtil::StartsWith(db_entry->region, "NTSC-U"))
entry->region = Region::NTSC_U;
else if (StringUtil::StartsWith(db_entry->region, "PAL-A"))
entry->region = Region::PAL_A;
////// PAL //////
//////////////////
else if (StringUtil::StartsWith(db_entry->region, "PAL-AF"))
entry->region = Region::PAL_AF;
else if (StringUtil::StartsWith(db_entry->region, "PAL-AU"))
entry->region = Region::PAL_AU;
else if (StringUtil::StartsWith(db_entry->region, "PAL-A"))
entry->region = Region::PAL_A;
else if (StringUtil::StartsWith(db_entry->region, "PAL-BE"))
entry->region = Region::PAL_BE;
else if (StringUtil::StartsWith(db_entry->region, "PAL-E"))
entry->region = Region::PAL_E;
else if (StringUtil::StartsWith(db_entry->region, "PAL-F"))
entry->region = Region::PAL_F;
else if (StringUtil::StartsWith(db_entry->region, "PAL-FI"))
entry->region = Region::PAL_FI;
else if (StringUtil::StartsWith(db_entry->region, "PAL-G"))
entry->region = Region::PAL_G;
else if (StringUtil::StartsWith(db_entry->region, "PAL-F"))
entry->region = Region::PAL_F;
else if (StringUtil::StartsWith(db_entry->region, "PAL-GR"))
entry->region = Region::PAL_GR;
else if (StringUtil::StartsWith(db_entry->region, "PAL-I"))
entry->region = Region::PAL_I;
else if (StringUtil::StartsWith(db_entry->region, "PAL-G"))
entry->region = Region::PAL_G;
else if (StringUtil::StartsWith(db_entry->region, "PAL-IN"))
entry->region = Region::PAL_IN;
else if (StringUtil::StartsWith(db_entry->region, "PAL-I"))
entry->region = Region::PAL_I;
else if (StringUtil::StartsWith(db_entry->region, "PAL-M"))
entry->region = Region::PAL_M;
else if (StringUtil::StartsWith(db_entry->region, "PAL-NL"))
@ -271,14 +277,14 @@ bool GameList::GetIsoListEntry(const std::string& path, GameList::Entry* entry)
entry->region = Region::PAL_P;
else if (StringUtil::StartsWith(db_entry->region, "PAL-R"))
entry->region = Region::PAL_R;
else if (StringUtil::StartsWith(db_entry->region, "PAL-S"))
entry->region = Region::PAL_S;
else if (StringUtil::StartsWith(db_entry->region, "PAL-SC"))
entry->region = Region::PAL_SC;
else if (StringUtil::StartsWith(db_entry->region, "PAL-SW"))
entry->region = Region::PAL_SW;
else if (StringUtil::StartsWith(db_entry->region, "PAL-SWI"))
entry->region = Region::PAL_SWI;
else if (StringUtil::StartsWith(db_entry->region, "PAL-SW"))
entry->region = Region::PAL_SW;
else if (StringUtil::StartsWith(db_entry->region, "PAL-S"))
entry->region = Region::PAL_S;
else if (StringUtil::StartsWith(db_entry->region, "PAL-UK"))
entry->region = Region::PAL_UK;
else

View File

@ -50,26 +50,26 @@ namespace GameList
NTSC_T,
NTSC_U,
Other,
PAL_A,
PAL_AF,
PAL_AU,
PAL_A,
PAL_BE,
PAL_E,
PAL_F,
PAL_FI,
PAL_G,
PAL_F,
PAL_GR,
PAL_I,
PAL_G,
PAL_IN,
PAL_I,
PAL_M,
PAL_NL,
PAL_NO,
PAL_P,
PAL_R,
PAL_S,
PAL_SC,
PAL_SW,
PAL_SWI,
PAL_SW,
PAL_S,
PAL_UK,
Count
};