Merge pull request #4878 from B3n30/citra_qt_all_regions_game_list
Citra_qt: Display all valid regions in game_list
This commit is contained in:
commit
2f0ea48da4
@ -75,30 +75,31 @@ static QString GetQStringShortTitleFromSMDH(const Loader::SMDH& smdh,
|
|||||||
* @return QString region
|
* @return QString region
|
||||||
*/
|
*/
|
||||||
static QString GetRegionFromSMDH(const Loader::SMDH& smdh) {
|
static QString GetRegionFromSMDH(const Loader::SMDH& smdh) {
|
||||||
const Loader::SMDH::GameRegion region = smdh.GetRegion();
|
using GameRegion = Loader::SMDH::GameRegion;
|
||||||
|
static const std::map<GameRegion, const char*> regions_map = {
|
||||||
|
{GameRegion::Japan, QT_TR_NOOP("Japan")},
|
||||||
|
{GameRegion::NorthAmerica, QT_TR_NOOP("North America")},
|
||||||
|
{GameRegion::Europe, QT_TR_NOOP("Europe")},
|
||||||
|
{GameRegion::Australia, QT_TR_NOOP("Australia")},
|
||||||
|
{GameRegion::China, QT_TR_NOOP("China")},
|
||||||
|
{GameRegion::Korea, QT_TR_NOOP("Korea")},
|
||||||
|
{GameRegion::Taiwan, QT_TR_NOOP("Taiwan")}};
|
||||||
|
|
||||||
switch (region) {
|
std::vector<GameRegion> regions = smdh.GetRegions();
|
||||||
case Loader::SMDH::GameRegion::Invalid:
|
|
||||||
|
if (regions.empty()) {
|
||||||
return QObject::tr("Invalid region");
|
return QObject::tr("Invalid region");
|
||||||
case Loader::SMDH::GameRegion::Japan:
|
|
||||||
return QObject::tr("Japan");
|
|
||||||
case Loader::SMDH::GameRegion::NorthAmerica:
|
|
||||||
return QObject::tr("North America");
|
|
||||||
case Loader::SMDH::GameRegion::Europe:
|
|
||||||
return QObject::tr("Europe");
|
|
||||||
case Loader::SMDH::GameRegion::Australia:
|
|
||||||
return QObject::tr("Australia");
|
|
||||||
case Loader::SMDH::GameRegion::China:
|
|
||||||
return QObject::tr("China");
|
|
||||||
case Loader::SMDH::GameRegion::Korea:
|
|
||||||
return QObject::tr("Korea");
|
|
||||||
case Loader::SMDH::GameRegion::Taiwan:
|
|
||||||
return QObject::tr("Taiwan");
|
|
||||||
case Loader::SMDH::GameRegion::RegionFree:
|
|
||||||
return QObject::tr("Region free");
|
|
||||||
default:
|
|
||||||
return QObject::tr("Invalid Region");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (std::find(regions.begin(), regions.end(), GameRegion::RegionFree) != regions.end()) {
|
||||||
|
return QObject::tr("Region free");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString result = QObject::tr(regions_map.at(regions.front()));
|
||||||
|
for (auto region = ++regions.begin(); region != regions.end(); ++region) {
|
||||||
|
result += QStringLiteral("\n") + QObject::tr(regions_map.at(*region));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
class GameListItem : public QStandardItem {
|
class GameListItem : public QStandardItem {
|
||||||
|
@ -48,20 +48,20 @@ std::array<u16, 0x40> SMDH::GetShortTitle(Loader::SMDH::TitleLanguage language)
|
|||||||
return titles[static_cast<int>(language)].short_title;
|
return titles[static_cast<int>(language)].short_title;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMDH::GameRegion SMDH::GetRegion() const {
|
std::vector<SMDH::GameRegion> SMDH::GetRegions() const {
|
||||||
if (region_lockout == 0x7fffffff) {
|
if (region_lockout == 0x7fffffff) {
|
||||||
return GameRegion::RegionFree;
|
return std::vector<GameRegion>{GameRegion::RegionFree};
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr u32 REGION_COUNT = 7;
|
constexpr u32 REGION_COUNT = 7;
|
||||||
u32 region = 0;
|
std::vector<GameRegion> result;
|
||||||
for (; region < REGION_COUNT; ++region) {
|
for (u32 region = 0; region < REGION_COUNT; ++region) {
|
||||||
if (region_lockout & (1 << region)) {
|
if (region_lockout & (1 << region)) {
|
||||||
return static_cast<GameRegion>(region);
|
result.push_back(static_cast<GameRegion>(region));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return GameRegion::Invalid;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Loader
|
} // namespace Loader
|
||||||
|
@ -63,7 +63,6 @@ struct SMDH {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum class GameRegion {
|
enum class GameRegion {
|
||||||
Invalid = -1,
|
|
||||||
Japan = 0,
|
Japan = 0,
|
||||||
NorthAmerica = 1,
|
NorthAmerica = 1,
|
||||||
Europe = 2,
|
Europe = 2,
|
||||||
@ -88,7 +87,7 @@ struct SMDH {
|
|||||||
*/
|
*/
|
||||||
std::array<u16, 0x40> GetShortTitle(Loader::SMDH::TitleLanguage language) const;
|
std::array<u16, 0x40> GetShortTitle(Loader::SMDH::TitleLanguage language) const;
|
||||||
|
|
||||||
GameRegion GetRegion() const;
|
std::vector<GameRegion> GetRegions() const;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(SMDH) == 0x36C0, "SMDH structure size is wrong");
|
static_assert(sizeof(SMDH) == 0x36C0, "SMDH structure size is wrong");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user