mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-27 13:44:15 +01:00
- fixed GetTitle for plugins to get title in current language if available otherwise default to english.
- also cleaned up GameTDB.cpp
This commit is contained in:
parent
1dee2f3b32
commit
df81ad9f22
BIN
out/boot.dol
BIN
out/boot.dol
Binary file not shown.
Before Width: | Height: | Size: 3.6 MiB After Width: | Height: | Size: 3.6 MiB |
@ -56,12 +56,12 @@ static const ReplaceStruct Replacements[] =
|
||||
};
|
||||
|
||||
GameTDB::GameTDB()
|
||||
: isLoaded(false), isParsed(false), file(0), filepath(0), LangCode("EN"), GameNodeCache(NULL)
|
||||
: isLoaded(false), file(0), LangCode("EN"), GameNodeCache(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
GameTDB::GameTDB(const char *filepath)
|
||||
: isLoaded(false), isParsed(false), file(0), filepath(0), LangCode("EN"), GameNodeCache(NULL)
|
||||
: isLoaded(false), file(0), LangCode("EN"), GameNodeCache(NULL)
|
||||
{
|
||||
OpenFile(filepath);
|
||||
}
|
||||
@ -76,14 +76,9 @@ bool GameTDB::OpenFile(const char *filepath)
|
||||
if(!filepath)
|
||||
return false;
|
||||
|
||||
//gprintf("Trying to open '%s'...", filepath);
|
||||
file = fopen(filepath, "rb");
|
||||
if(file)
|
||||
{
|
||||
this->filepath = filepath;
|
||||
|
||||
//gprintf("success\n");
|
||||
|
||||
int pos;
|
||||
string OffsetsPath = filepath;
|
||||
if((pos = OffsetsPath.find_last_of('/')) != (int) string::npos)
|
||||
@ -91,15 +86,8 @@ bool GameTDB::OpenFile(const char *filepath)
|
||||
else
|
||||
OffsetsPath.clear(); //! Relative path
|
||||
|
||||
//gprintf("Checking game offsets\n");
|
||||
LoadGameOffsets(OffsetsPath.c_str());
|
||||
/*if (!isParsed)
|
||||
{
|
||||
gprintf("Checking titles.ini\n");
|
||||
CheckTitlesIni(OffsetsPath.c_str());
|
||||
}*/
|
||||
}
|
||||
//else gprintf("failed\n");
|
||||
|
||||
isLoaded = (file != NULL);
|
||||
return isLoaded;
|
||||
@ -119,17 +107,6 @@ void GameTDB::CloseFile()
|
||||
file = NULL;
|
||||
}
|
||||
|
||||
void GameTDB::Refresh()
|
||||
{
|
||||
gprintf("Refreshing file '%s'\n", filepath);
|
||||
CloseFile();
|
||||
|
||||
if(filepath == NULL)
|
||||
return;
|
||||
|
||||
OpenFile(filepath);
|
||||
}
|
||||
|
||||
bool GameTDB::LoadGameOffsets(const char *path)
|
||||
{
|
||||
if(!path)
|
||||
@ -459,36 +436,7 @@ bool GameTDB::ParseFile()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameTDB::FindTitle(char *data, const char * &title, const string &langCode)
|
||||
{
|
||||
// Coverflow.getHdr() will return NULL if coverflow list is empty or not made yet
|
||||
// because list generator hasn't made the game list yet.
|
||||
if(CoverFlow.getHdr() != NULL && CoverFlow.getHdr()->type == TYPE_PLUGIN)
|
||||
{
|
||||
title = GetNodeText(data, "<title>", "</title>");
|
||||
|
||||
if(title == NULL)
|
||||
return false;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
char *language = SeekLang(data, langCode.c_str());
|
||||
if(language == NULL)
|
||||
{
|
||||
language = SeekLang(data, "EN");
|
||||
if(language == NULL)
|
||||
return false;
|
||||
}
|
||||
|
||||
title = GetNodeText(language, "<title>", "</title>");
|
||||
|
||||
if(title == NULL)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameTDB::GetTitle(const char *id, const char * &title)
|
||||
bool GameTDB::GetTitle(const char *id, const char * &title, bool plugin)
|
||||
{
|
||||
title = NULL;
|
||||
if(id == NULL)
|
||||
@ -497,12 +445,41 @@ bool GameTDB::GetTitle(const char *id, const char * &title)
|
||||
char *data = GetGameNode(id);
|
||||
if(data == NULL)
|
||||
return false;
|
||||
bool retval = FindTitle(data, title, LangCode);
|
||||
MEM2_free(data);
|
||||
|
||||
return retval;
|
||||
char *language = SeekLang(data, LangCode.c_str());
|
||||
if(language == NULL)
|
||||
{
|
||||
language = SeekLang(data, "EN");
|
||||
if(language == NULL)
|
||||
{
|
||||
MEM2_free(data);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
title = GetNodeText(language, "<title>", "</title>");
|
||||
|
||||
if(title == NULL && plugin)// If current language doesn't have Title then try in English
|
||||
{
|
||||
language = SeekLang(data, "EN");
|
||||
if(language == NULL)
|
||||
{
|
||||
MEM2_free(data);
|
||||
return false;
|
||||
}
|
||||
|
||||
title = GetNodeText(language, "<title>", "</title>");
|
||||
}
|
||||
|
||||
MEM2_free(data);
|
||||
|
||||
if(title == NULL)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* used for plugins database files */
|
||||
/* gets no-intro filename used for snapshots and cart/disk images */
|
||||
bool GameTDB::GetName(const char *id, const char * &name)
|
||||
{
|
||||
name = NULL;
|
||||
@ -989,20 +966,6 @@ int GameTDB::GetAccessories(const char *id, vector<Accessory> & acc_list)
|
||||
return acc_list.size();
|
||||
}
|
||||
|
||||
u32 GameTDB::FindCaseColor(char *data)
|
||||
{
|
||||
u32 color = -1;// -1 = ffffffff
|
||||
|
||||
char *ColorNode = GetNodeText(data, "<case color=\"", "\"");
|
||||
if(!ColorNode || strlen(ColorNode) == 0)
|
||||
return color;
|
||||
|
||||
char format[8];
|
||||
sprintf(format, "0x%s", ColorNode);
|
||||
|
||||
return strtoul(format, NULL, 16);
|
||||
}
|
||||
|
||||
u32 GameTDB::GetCaseColor(const char *id)
|
||||
{
|
||||
u32 color = -1;// -1 = ffffffff
|
||||
@ -1013,10 +976,16 @@ u32 GameTDB::GetCaseColor(const char *id)
|
||||
if(!data)
|
||||
return color;
|
||||
|
||||
color = FindCaseColor(data);
|
||||
char *ColorNode = GetNodeText(data, "<case color=\"", "\"");
|
||||
if(!ColorNode)
|
||||
{
|
||||
MEM2_free(data);
|
||||
return color;
|
||||
}
|
||||
|
||||
if(color != 0xffffffff)
|
||||
gprintf("GameTDB: Found alternate color(%x) for: %s\n", color, id);
|
||||
color = strtoul(ColorNode, NULL, 16);
|
||||
//if(color != 0xffffffff)
|
||||
// gprintf("GameTDB: Found alternate color(%x) for: %s\n", color, id);
|
||||
|
||||
MEM2_free(data);
|
||||
return color;
|
||||
|
@ -65,15 +65,13 @@ public:
|
||||
bool OpenFile(const char * filepath);
|
||||
//! Closes the GameTDB xml file
|
||||
void CloseFile();
|
||||
//! Refresh the GameTDB xml file, in case the file has been updated
|
||||
void Refresh();
|
||||
//! Set the language code which should be use to find the appropriate language
|
||||
//! If the language code is not found, the language code defaults to EN
|
||||
void SetLanguageCode(const char * code) { if(code) LangCode = code; };
|
||||
//! Get the current set language code
|
||||
const char * GetLanguageCode() { return LangCode.c_str(); };
|
||||
//! Get the title of a specific game id in the language defined in LangCode
|
||||
bool GetTitle(const char *id, const char * &title);
|
||||
bool GetTitle(const char *id, const char * &title, bool plugin = false);
|
||||
//! Get the name of a specific game id
|
||||
bool GetName(const char *id, const char * &name);
|
||||
//! Get the synopsis of a specific game id in the language defined in LangCode
|
||||
@ -126,9 +124,6 @@ private:
|
||||
bool ParseFile();
|
||||
bool LoadGameOffsets(const char * path);
|
||||
bool SaveGameOffsets(const char * path);
|
||||
bool CheckTitlesIni(const char * path);
|
||||
bool FindTitle(char *data, const char * &title, const string &langCode);
|
||||
u32 FindCaseColor(char * data);
|
||||
inline int GetData(char * data, int offset, int size);
|
||||
inline char * LoadGameNode(const char * id);
|
||||
inline char * GetGameNode(const char * id);
|
||||
@ -137,10 +132,8 @@ private:
|
||||
inline char * GetNodeText(char *data, const char *nodestart, const char *nodeend);
|
||||
|
||||
bool isLoaded;
|
||||
bool isParsed;
|
||||
vector<GameOffsets> OffsetMap;
|
||||
FILE * file;
|
||||
const char *filepath;
|
||||
string LangCode;
|
||||
char *GameNodeCache;
|
||||
char GameIDCache[7];
|
||||
|
@ -284,7 +284,7 @@ static void Add_Plugin_Game(char *FullPath)
|
||||
|
||||
const char *gameTDB_Title = NULL;
|
||||
if(gameTDB.IsLoaded() && customTitle.empty())
|
||||
gameTDB.GetTitle(ListElement.id, gameTDB_Title);
|
||||
gameTDB.GetTitle(ListElement.id, gameTDB_Title, true);
|
||||
|
||||
/* set the roms title */
|
||||
if(!customTitle.empty())
|
||||
|
Loading…
Reference in New Issue
Block a user