diff --git a/src/citra_qt/game_list_p.h b/src/citra_qt/game_list_p.h index 0309ed083..def99a161 100644 --- a/src/citra_qt/game_list_p.h +++ b/src/citra_qt/game_list_p.h @@ -75,30 +75,32 @@ static QString GetQStringShortTitleFromSMDH(const Loader::SMDH& smdh, * @return QString region */ static QString GetRegionFromSMDH(const Loader::SMDH& smdh) { - const Loader::SMDH::GameRegion region = smdh.GetRegion(); + using GameRegion = Loader::SMDH::GameRegion; + static const std::map regions_map = { + {GameRegion::Japan, QObject::tr("Japan")}, + {GameRegion::NorthAmerica, QObject::tr("North America")}, + {GameRegion::Europe, QObject::tr("Europe")}, + {GameRegion::Australia,QObject::tr("Australia")}, + {GameRegion::China, QObject::tr("China")}, + {GameRegion::Korea, QObject::tr("Korea")}, + {GameRegion::Taiwan, QObject::tr("Taiwan")} + }; - switch (region) { - case Loader::SMDH::GameRegion::Invalid: + std::vector regions = smdh.GetRegions(); + + if (regions.empty()) { 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 = regions_map.at(regions.front()); + for (auto region = ++regions.begin(); region != regions.end(); ++region) { + result += "\n" + regions_map.at(*region); + } + return result; } class GameListItem : public QStandardItem { diff --git a/src/core/loader/smdh.cpp b/src/core/loader/smdh.cpp index ebb35675c..417f8d074 100644 --- a/src/core/loader/smdh.cpp +++ b/src/core/loader/smdh.cpp @@ -48,26 +48,20 @@ std::array SMDH::GetShortTitle(Loader::SMDH::TitleLanguage language) return titles[static_cast(language)].short_title; } -SMDH::GameRegion SMDH::GetRegion() const { +std::vector SMDH::GetRegions() const { if (region_lockout == 0x7fffffff) { - return GameRegion::RegionFree; + return std::vector{GameRegion::RegionFree}; } - constexpr u32 taiwan_and_china = - (1 << static_cast(GameRegion::Taiwan)) | (1 << static_cast(GameRegion::China)); - if (region_lockout == taiwan_and_china) { - return GameRegion::Taiwan; - } // hack to fix TWN games that support CHN consoles - constexpr u32 REGION_COUNT = 7; - u32 region = 0; - for (; region < REGION_COUNT; ++region) { + std::vector result; + for (u32 region = 0; region < REGION_COUNT; ++region) { if (region_lockout & (1 << region)) { - return static_cast(region); + result.push_back(static_cast(region)); } } - return GameRegion::Invalid; + return result; } } // namespace Loader diff --git a/src/core/loader/smdh.h b/src/core/loader/smdh.h index 0da1cf855..adeea05a9 100644 --- a/src/core/loader/smdh.h +++ b/src/core/loader/smdh.h @@ -63,7 +63,6 @@ struct SMDH { }; enum class GameRegion { - Invalid = -1, Japan = 0, NorthAmerica = 1, Europe = 2, @@ -88,7 +87,7 @@ struct SMDH { */ std::array GetShortTitle(Loader::SMDH::TitleLanguage language) const; - GameRegion GetRegion() const; + std::vector GetRegions() const; }; static_assert(sizeof(SMDH) == 0x36C0, "SMDH structure size is wrong");