mirror of https://github.com/PCSX2/pcsx2.git
- Added game compatibility info to database and added about ~50 more games (same info as pcsx2.net's compatibility list)
- Games now display their compatibility status on the console title-bar ^^ - Modifications to DataBase_Loader to write to the database and save changes Note to pcsx2 team: The compatibility info is numerically based. 000 ~ 099 = Unknown Compatibility status 100 ~ 199 = Nothing 200 ~ 299 = Intro 300 ~ 399 = Menu 400 ~ 499 = In-game 500 ~ 599 = Playable 600+ = Perfect (Currently no game has the perfect status since the pcsx2.net compatibility list didn't have that as an option) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2992 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
5e228774db
commit
46e08b6b8a
2700
bin/DataBase.dbf
2700
bin/DataBase.dbf
File diff suppressed because it is too large
Load Diff
|
@ -48,6 +48,13 @@ public:
|
|||
|
||||
class DataBase_Loader {
|
||||
private:
|
||||
template<class T> string toString(T value) {
|
||||
stringstream ss(ios_base::in | ios_base::out);
|
||||
string tString;
|
||||
ss << value;
|
||||
ss >> tString;
|
||||
return tString;
|
||||
}
|
||||
bool isComment(string& s) {
|
||||
string sub = s.substr(0, 2);
|
||||
return (sub.compare("--") == 0) || (sub.compare("//") == 0);
|
||||
|
@ -80,7 +87,6 @@ private:
|
|||
return;
|
||||
}
|
||||
keyPair.value = t;
|
||||
int temp = 0;
|
||||
while (!ss.eof() && !ss.fail()) {
|
||||
ss >> t;
|
||||
if (isComment(t)) break;
|
||||
|
@ -93,11 +99,14 @@ private:
|
|||
}
|
||||
}
|
||||
public:
|
||||
deque<Game_Data*> gList;
|
||||
Game_Data* curGame;
|
||||
deque<Game_Data*> gList; // List of all game data
|
||||
Game_Data* curGame; // Current game data
|
||||
String_Stream header; // Header of the database
|
||||
string baseKey; // Key to separate games by ("Serial")
|
||||
|
||||
DataBase_Loader(string file, string key, string value = "") {
|
||||
curGame = NULL;
|
||||
baseKey = key;
|
||||
if (!fileExists(file)) {
|
||||
Console.Error("DataBase_Loader: DataBase Not Found! [%s]", file.c_str());
|
||||
}
|
||||
|
@ -110,6 +119,8 @@ public:
|
|||
s0 = reader.getLine();
|
||||
extract(s0, keyPair);
|
||||
if (keyPair.key.compare(key) == 0) break;
|
||||
header.write(s0);
|
||||
header.write("\n");
|
||||
}
|
||||
Game_Data* game = new Game_Data(keyPair.value);
|
||||
game->kList.push_back(keyPair);
|
||||
|
@ -148,9 +159,41 @@ public:
|
|||
return true;
|
||||
}
|
||||
}
|
||||
curGame = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Saves changes to the database
|
||||
void saveToFile(string file = "DataBase.dbf") {
|
||||
File_Writer writer(file);
|
||||
writer.write(header.toString());
|
||||
deque<Game_Data*>::iterator it = gList.begin();
|
||||
for ( ; it != gList.end(); ++it) {
|
||||
deque<key_pair>::iterator i = it[0]->kList.begin();
|
||||
for ( ; i != it[0]->kList.end(); ++i) {
|
||||
writer.write(i[0].key);
|
||||
for (int a = 6 - i[0].key.length(); a > 0; a--) {
|
||||
writer.write(" "); // Padding for nice formatting on small key-names
|
||||
}
|
||||
writer.write(" = ");
|
||||
writer.write(i[0].value);
|
||||
writer.write("\n");
|
||||
}
|
||||
writer.write("---------------------------------------------\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Adds new game data to the database, and sets curGame to the new game...
|
||||
// If searchDB is true, it searches the database to see if game already exists.
|
||||
void addGame(string id, bool searchDB = true) {
|
||||
if (searchDB && setGame(id)) return;
|
||||
Game_Data* game = new Game_Data(id);
|
||||
key_pair kp(baseKey, id);
|
||||
game->kList.push_back(kp);
|
||||
gList.push_back(game);
|
||||
curGame = game;
|
||||
}
|
||||
|
||||
// Gets a string representation of the 'value' for the given key
|
||||
string getString(string key) {
|
||||
if (curGame) {
|
||||
|
@ -200,6 +243,52 @@ public:
|
|||
string v = getString(key);
|
||||
return !!atoi(v.c_str());
|
||||
}
|
||||
|
||||
// Write a string value to the specified key
|
||||
void writeString(string key, string value) {
|
||||
if (curGame) {
|
||||
deque<key_pair>::iterator it = curGame->kList.begin();
|
||||
for ( ; it != curGame->kList.end(); ++it) {
|
||||
if (!it[0].key.compare(key)) {
|
||||
it[0].value = value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
key_pair tKey(key, value);
|
||||
curGame->kList.push_back(tKey);
|
||||
}
|
||||
else Console.Error("DataBase_Loader: Game not set!");
|
||||
}
|
||||
|
||||
// Write a wxString value to the specified key
|
||||
void writeStringWX(string key, wxString value) {
|
||||
writeString(key, string(value.ToUTF8().data()));
|
||||
}
|
||||
|
||||
// Write a double value to the specified key
|
||||
void writeDouble(string key, double value) {
|
||||
writeString(key, toString(value));
|
||||
}
|
||||
|
||||
// Write a float value to the specified key
|
||||
void writeFloat(string key, float value) {
|
||||
writeString(key, toString(value));
|
||||
}
|
||||
|
||||
// Write an integer value to the specified key
|
||||
void writeInt(string key, int value) {
|
||||
writeString(key, toString(value));
|
||||
}
|
||||
|
||||
// Write a u8 value to the specified key
|
||||
void writeU8(string key, u8 value) {
|
||||
writeString(key, toString(value));
|
||||
}
|
||||
|
||||
// Write a bool value to the specified key
|
||||
void writeBool(string key, bool value) {
|
||||
writeString(key, toString(value?1:0));
|
||||
}
|
||||
};
|
||||
|
||||
extern ScopedPtr<DataBase_Loader> GameDB;
|
||||
|
|
|
@ -94,6 +94,26 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class String_Stream {
|
||||
public:
|
||||
stringstream* ss;
|
||||
String_Stream() {
|
||||
ss = new stringstream(stringstream::in | stringstream::out);
|
||||
}
|
||||
~String_Stream() {
|
||||
delete ss;
|
||||
}
|
||||
template<class T> void write(T t) {
|
||||
(*ss) << t;
|
||||
}
|
||||
template<class T> void read(T &t) {
|
||||
(*ss) >> t;
|
||||
}
|
||||
string toString() {
|
||||
return ss->str();
|
||||
}
|
||||
};
|
||||
|
||||
static bool fileExists(string file) {
|
||||
FILE *f = fopen(file.c_str(), "r");
|
||||
if (!f) return false;
|
||||
|
|
|
@ -579,13 +579,25 @@ void __fastcall eeGameStarting()
|
|||
if (!g_GameStarted && ElfCRC) {
|
||||
wxString gameCRC( wxsFormat( L"%8.8x", ElfCRC ) );
|
||||
wxString gameName;
|
||||
if( GameDB )
|
||||
{
|
||||
if (GameDB) {
|
||||
gameName = GameDB->getStringWX("Name");
|
||||
gameName += L" (" + GameDB->getStringWX("Region") + L")";
|
||||
}
|
||||
gameName += L" [" + DiscID + L"]";
|
||||
gameName += L" [" + gameCRC + L"]";
|
||||
int compat = GameDB->getInt("Compat");
|
||||
if (compat >= 600) gameName += L" [Compatibility = Perfect]";
|
||||
else if (compat >= 500) gameName += L" [Compatibility = Playable]";
|
||||
else if (compat >= 400) gameName += L" [Compatibility = In-Game]";
|
||||
else if (compat >= 300) gameName += L" [Compatibility = Menu]";
|
||||
else if (compat >= 200) gameName += L" [Compatibility = Intro]";
|
||||
else if (compat >= 100) gameName += L" [Compatibility = Nothing]";
|
||||
else gameName += L" [Compatibility = Unknown]";
|
||||
}
|
||||
else {
|
||||
gameName += L" [" + DiscID + L"]";
|
||||
gameName += L" [" + gameCRC + L"]";
|
||||
gameName += L" [Compatibility = Unknown]";
|
||||
}
|
||||
|
||||
// if patches found the following title will be overwritten
|
||||
Console.SetTitle(gameName);
|
||||
|
|
Loading…
Reference in New Issue