mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-04 03:33:44 +01:00
Guess game region from game ID, display on game screen
This commit is contained in:
1 parent
d4eee74b54
commit
fedf7edc2b
4 files changed
+68
-23
No files matched your search
+41
-21
@@ -162,6 +162,44 @@ bool GameInfo::DeleteAllSaveData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void GameInfo::ParseParamSFO() {
|
||||
title = paramSFO.GetValueString("TITLE");
|
||||
id = paramSFO.GetValueString("DISC_ID");
|
||||
id_version = paramSFO.GetValueString("DISC_ID") + "_" + paramSFO.GetValueString("DISC_VERSION");
|
||||
disc_total = paramSFO.GetValueInt("DISC_TOTAL");
|
||||
disc_number = paramSFO.GetValueInt("DISC_NUMBER");
|
||||
// region = paramSFO.GetValueInt("REGION"); // Always seems to be 32768?
|
||||
|
||||
region = GAMEREGION_OTHER;
|
||||
if (id_version.size() >= 4) {
|
||||
std::string regStr = id_version.substr(0, 4);
|
||||
|
||||
// Guesswork
|
||||
switch (regStr[2]) {
|
||||
case 'E': region = GAMEREGION_EUROPE; break;
|
||||
case 'U': region = GAMEREGION_USA; break;
|
||||
case 'J': region = GAMEREGION_JAPAN; break;
|
||||
case 'H': region = GAMEREGION_HONGKONG; break;
|
||||
case 'A': region = GAMEREGION_ASIA; break;
|
||||
}
|
||||
/*
|
||||
if (regStr == "NPEZ" || regStr == "NPEG" || regStr == "ULES" || regStr == "UCES" ||
|
||||
regStr == "NPEX") {
|
||||
region = GAMEREGION_EUROPE;
|
||||
} else if (regStr == "NPUG" || regStr == "NPUZ" || regStr == "ULUS" || regStr == "UCUS") {
|
||||
region = GAMEREGION_USA;
|
||||
} else if (regStr == "NPJH" || regStr == "NPJG" || regStr == "ULJM"|| regStr == "ULJS") {
|
||||
region = GAMEREGION_JAPAN;
|
||||
} else if (regStr == "NPHG") {
|
||||
region = GAMEREGION_HONGKONG;
|
||||
} else if (regStr == "UCAS") {
|
||||
region = GAMEREGION_CHINA;
|
||||
}*/
|
||||
}
|
||||
|
||||
paramSFOLoaded = true;
|
||||
}
|
||||
|
||||
static bool ReadFileToString(IFileSystem *fs, const char *filename, std::string *contents, recursive_mutex *mtx) {
|
||||
PSPFileInfo info = fs->GetFileInfo(filename);
|
||||
if (!info.exists) {
|
||||
@@ -218,13 +256,7 @@ public:
|
||||
{
|
||||
lock_guard lock(info_->lock);
|
||||
info_->paramSFO.ReadSFO(sfoData, sfoSize);
|
||||
info_->title = info_->paramSFO.GetValueString("TITLE");
|
||||
info_->id = info_->paramSFO.GetValueString("DISC_ID");
|
||||
info_->id_version = info_->paramSFO.GetValueString("DISC_ID") + "_" + info_->paramSFO.GetValueString("DISC_VERSION");
|
||||
info_->disc_total = info_->paramSFO.GetValueInt("DISC_TOTAL");
|
||||
info_->disc_number = info_->paramSFO.GetValueInt("DISC_NUMBER");
|
||||
|
||||
info_->paramSFOLoaded = true;
|
||||
info_->ParseParamSFO();
|
||||
}
|
||||
delete [] sfoData;
|
||||
|
||||
@@ -287,13 +319,7 @@ public:
|
||||
if (ReadFileToString(&umd, "/PSP_GAME/PARAM.SFO", ¶mSFOcontents, 0)) {
|
||||
lock_guard lock(info_->lock);
|
||||
info_->paramSFO.ReadSFO((const u8 *)paramSFOcontents.data(), paramSFOcontents.size());
|
||||
info_->title = info_->paramSFO.GetValueString("TITLE");
|
||||
info_->id = info_->paramSFO.GetValueString("DISC_ID");
|
||||
info_->id_version = info_->paramSFO.GetValueString("DISC_ID") + "_" + info_->paramSFO.GetValueString("DISC_VERSION");
|
||||
info_->disc_total = info_->paramSFO.GetValueInt("DISC_TOTAL");
|
||||
info_->disc_number = info_->paramSFO.GetValueInt("DISC_NUMBER");
|
||||
|
||||
info_->paramSFOLoaded = true;
|
||||
info_->ParseParamSFO();
|
||||
}
|
||||
|
||||
ReadFileToString(&umd, "/PSP_GAME/ICON0.PNG", &info_->iconTextureData, &info_->lock);
|
||||
@@ -321,13 +347,7 @@ public:
|
||||
if (ReadFileToString(&umd, "/PSP_GAME/PARAM.SFO", ¶mSFOcontents, 0)) {
|
||||
lock_guard lock(info_->lock);
|
||||
info_->paramSFO.ReadSFO((const u8 *)paramSFOcontents.data(), paramSFOcontents.size());
|
||||
info_->title = info_->paramSFO.GetValueString("TITLE");
|
||||
info_->id = info_->paramSFO.GetValueString("DISC_ID");
|
||||
info_->id_version = info_->paramSFO.GetValueString("DISC_ID") + "_" + info_->paramSFO.GetValueString("DISC_VERSION");
|
||||
info_->disc_total = info_->paramSFO.GetValueInt("DISC_TOTAL");
|
||||
info_->disc_number = info_->paramSFO.GetValueInt("DISC_NUMBER");
|
||||
|
||||
info_->paramSFOLoaded = true;
|
||||
info_->ParseParamSFO();
|
||||
} else {
|
||||
// Fall back to the filename for title if ISO is broken
|
||||
info_->title = gamePath_;
|
||||
|
||||
+14
-2
@@ -31,11 +31,22 @@
|
||||
// does on the PSP, namely checking for and deleting savedata, and similar things.
|
||||
// Only cares about games that are installed on the current device.
|
||||
|
||||
// Guessed from GameID, not necessarily accurate
|
||||
enum GameRegion {
|
||||
GAMEREGION_JAPAN,
|
||||
GAMEREGION_USA,
|
||||
GAMEREGION_EUROPE,
|
||||
GAMEREGION_HONGKONG,
|
||||
GAMEREGION_ASIA,
|
||||
GAMEREGION_OTHER,
|
||||
GAMEREGION_MAX,
|
||||
};
|
||||
|
||||
class GameInfo {
|
||||
public:
|
||||
GameInfo()
|
||||
: fileType(FILETYPE_UNKNOWN), paramSFOLoaded(false), iconTexture(NULL), pic0Texture(NULL), pic1Texture(NULL),
|
||||
wantBG(false), gameSize(0), saveDataSize(0), installDataSize(0), disc_total(0), disc_number(0) {}
|
||||
wantBG(false), gameSize(0), saveDataSize(0), installDataSize(0), disc_total(0), disc_number(0), region(-1) {}
|
||||
|
||||
bool DeleteGame(); // Better be sure what you're doing when calling this.
|
||||
bool DeleteAllSaveData();
|
||||
@@ -44,7 +55,7 @@ public:
|
||||
u64 GetSaveDataSizeInBytes();
|
||||
u64 GetInstallDataSizeInBytes();
|
||||
|
||||
void LoadParamSFO();
|
||||
void ParseParamSFO();
|
||||
|
||||
std::vector<std::string> GetSaveDataDirectories();
|
||||
|
||||
@@ -61,6 +72,7 @@ public:
|
||||
std::string id_version;
|
||||
int disc_total;
|
||||
int disc_number;
|
||||
int region;
|
||||
IdentifiedFileType fileType;
|
||||
ParamSFOData paramSFO;
|
||||
bool paramSFOLoaded;
|
||||
|
||||
@@ -57,6 +57,7 @@ void GameScreen::CreateViews() {
|
||||
tvGameSize_ = leftColumn->Add(new TextView("...", ALIGN_LEFT, 1.0f, new AnchorLayoutParams(10, 250, NONE, NONE)));
|
||||
tvSaveDataSize_ = leftColumn->Add(new TextView("...", ALIGN_LEFT, 1.0f, new AnchorLayoutParams(10, 290, NONE, NONE)));
|
||||
tvInstallDataSize_ = leftColumn->Add(new TextView("", ALIGN_LEFT, 1.0f, new AnchorLayoutParams(10, 330, NONE, NONE)));
|
||||
tvRegion_ = leftColumn->Add(new TextView("", ALIGN_LEFT, 1.0f, new AnchorLayoutParams(10, 370, NONE, NONE)));
|
||||
}
|
||||
|
||||
ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins));
|
||||
@@ -135,6 +136,17 @@ void GameScreen::update(InputState &input) {
|
||||
tvInstallDataSize_->SetText(temp);
|
||||
}
|
||||
}
|
||||
|
||||
if (info->region >= 0 && info->region < GAMEREGION_MAX && info->region != GAMEREGION_OTHER) {
|
||||
static const char *regionNames[GAMEREGION_MAX] = {
|
||||
"Japan",
|
||||
"USA",
|
||||
"Europe",
|
||||
"Hong Kong",
|
||||
"Asia"
|
||||
};
|
||||
tvRegion_->SetText(ga->T(regionNames[info->region]));
|
||||
}
|
||||
}
|
||||
|
||||
UI::EventReturn GameScreen::OnSwitchBack(UI::EventParams &e) {
|
||||
|
||||
@@ -57,4 +57,5 @@ private:
|
||||
UI::TextView *tvGameSize_;
|
||||
UI::TextView *tvSaveDataSize_;
|
||||
UI::TextView *tvInstallDataSize_;
|
||||
UI::TextView *tvRegion_;
|
||||
};
|
||||
Reference in new issue
Block a user