citra_qt: Add a game region column

This commit is contained in:
FearlessTobi 2018-05-01 19:57:01 +02:00
parent 9c65a45358
commit 36c4765054
5 changed files with 81 additions and 0 deletions

View file

@ -231,6 +231,7 @@ GameList::GameList(GMainWindow* parent) : QWidget{parent} {
item_model->insertColumns(0, COLUMN_COUNT);
item_model->setHeaderData(COLUMN_NAME, Qt::Horizontal, "Name");
item_model->setHeaderData(COLUMN_COMPATIBILITY, Qt::Horizontal, "Compatibility");
item_model->setHeaderData(COLUMN_REGION, Qt::Horizontal, "Region");
item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, "File type");
item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, "Size");
@ -492,6 +493,7 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign
emit EntryReady({
new GameListItemPath(QString::fromStdString(physical_name), smdh, program_id),
new GameListItemCompat(compatibility),
new GameListItemRegion(smdh),
new GameListItem(
QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))),
new GameListItemSize(FileUtil::GetSize(physical_name)),

View file

@ -31,6 +31,7 @@ public:
enum {
COLUMN_NAME,
COLUMN_COMPATIBILITY,
COLUMN_REGION,
COLUMN_FILE_TYPE,
COLUMN_SIZE,
COLUMN_COUNT, // Number of columns

View file

@ -73,6 +73,38 @@ static QString GetQStringShortTitleFromSMDH(const Loader::SMDH& smdh,
return QString::fromUtf16(smdh.GetShortTitle(language).data());
}
/**
* Gets the game region from SMDH data.
* @param smdh SMDH data
* @return QString region
*/
static QString GetRegionFromSMDH(const Loader::SMDH& smdh) {
const Loader::SMDH::GameRegion region = smdh.GetRegion();
switch (region) {
case Loader::SMDH::GameRegion::Invalid:
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");
}
}
struct CompatStatus {
QString color;
const char* text;
@ -168,6 +200,22 @@ public:
}
};
class GameListItemRegion : public GameListItem {
public:
GameListItemRegion() = default;
explicit GameListItemRegion(const std::vector<u8>& smdh_data) {
if (!Loader::IsValidSMDH(smdh_data)) {
setText(QObject::tr("Invalid region"));
return;
}
Loader::SMDH smdh;
memcpy(&smdh, smdh_data.data(), sizeof(Loader::SMDH));
setText(GetRegionFromSMDH(smdh));
}
};
/**
* A specialization of GameListItem for size values.
* This class ensures that for every numerical size value it holds (in bytes), a correct