mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2025-02-25 16:23:54 +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()
|
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)
|
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);
|
OpenFile(filepath);
|
||||||
}
|
}
|
||||||
@ -76,14 +76,9 @@ bool GameTDB::OpenFile(const char *filepath)
|
|||||||
if(!filepath)
|
if(!filepath)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//gprintf("Trying to open '%s'...", filepath);
|
|
||||||
file = fopen(filepath, "rb");
|
file = fopen(filepath, "rb");
|
||||||
if(file)
|
if(file)
|
||||||
{
|
{
|
||||||
this->filepath = filepath;
|
|
||||||
|
|
||||||
//gprintf("success\n");
|
|
||||||
|
|
||||||
int pos;
|
int pos;
|
||||||
string OffsetsPath = filepath;
|
string OffsetsPath = filepath;
|
||||||
if((pos = OffsetsPath.find_last_of('/')) != (int) string::npos)
|
if((pos = OffsetsPath.find_last_of('/')) != (int) string::npos)
|
||||||
@ -91,15 +86,8 @@ bool GameTDB::OpenFile(const char *filepath)
|
|||||||
else
|
else
|
||||||
OffsetsPath.clear(); //! Relative path
|
OffsetsPath.clear(); //! Relative path
|
||||||
|
|
||||||
//gprintf("Checking game offsets\n");
|
|
||||||
LoadGameOffsets(OffsetsPath.c_str());
|
LoadGameOffsets(OffsetsPath.c_str());
|
||||||
/*if (!isParsed)
|
|
||||||
{
|
|
||||||
gprintf("Checking titles.ini\n");
|
|
||||||
CheckTitlesIni(OffsetsPath.c_str());
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
//else gprintf("failed\n");
|
|
||||||
|
|
||||||
isLoaded = (file != NULL);
|
isLoaded = (file != NULL);
|
||||||
return isLoaded;
|
return isLoaded;
|
||||||
@ -119,17 +107,6 @@ void GameTDB::CloseFile()
|
|||||||
file = NULL;
|
file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameTDB::Refresh()
|
|
||||||
{
|
|
||||||
gprintf("Refreshing file '%s'\n", filepath);
|
|
||||||
CloseFile();
|
|
||||||
|
|
||||||
if(filepath == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
OpenFile(filepath);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GameTDB::LoadGameOffsets(const char *path)
|
bool GameTDB::LoadGameOffsets(const char *path)
|
||||||
{
|
{
|
||||||
if(!path)
|
if(!path)
|
||||||
@ -459,36 +436,7 @@ bool GameTDB::ParseFile()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameTDB::FindTitle(char *data, const char * &title, const string &langCode)
|
bool GameTDB::GetTitle(const char *id, const char * &title, bool plugin)
|
||||||
{
|
|
||||||
// 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)
|
|
||||||
{
|
{
|
||||||
title = NULL;
|
title = NULL;
|
||||||
if(id == NULL)
|
if(id == NULL)
|
||||||
@ -497,12 +445,41 @@ bool GameTDB::GetTitle(const char *id, const char * &title)
|
|||||||
char *data = GetGameNode(id);
|
char *data = GetGameNode(id);
|
||||||
if(data == NULL)
|
if(data == NULL)
|
||||||
return false;
|
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)
|
bool GameTDB::GetName(const char *id, const char * &name)
|
||||||
{
|
{
|
||||||
name = NULL;
|
name = NULL;
|
||||||
@ -989,20 +966,6 @@ int GameTDB::GetAccessories(const char *id, vector<Accessory> & acc_list)
|
|||||||
return acc_list.size();
|
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 GameTDB::GetCaseColor(const char *id)
|
||||||
{
|
{
|
||||||
u32 color = -1;// -1 = ffffffff
|
u32 color = -1;// -1 = ffffffff
|
||||||
@ -1013,10 +976,16 @@ u32 GameTDB::GetCaseColor(const char *id)
|
|||||||
if(!data)
|
if(!data)
|
||||||
return color;
|
return color;
|
||||||
|
|
||||||
color = FindCaseColor(data);
|
char *ColorNode = GetNodeText(data, "<case color=\"", "\"");
|
||||||
|
if(!ColorNode)
|
||||||
|
{
|
||||||
|
MEM2_free(data);
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
if(color != 0xffffffff)
|
color = strtoul(ColorNode, NULL, 16);
|
||||||
gprintf("GameTDB: Found alternate color(%x) for: %s\n", color, id);
|
//if(color != 0xffffffff)
|
||||||
|
// gprintf("GameTDB: Found alternate color(%x) for: %s\n", color, id);
|
||||||
|
|
||||||
MEM2_free(data);
|
MEM2_free(data);
|
||||||
return color;
|
return color;
|
||||||
|
@ -65,15 +65,13 @@ public:
|
|||||||
bool OpenFile(const char * filepath);
|
bool OpenFile(const char * filepath);
|
||||||
//! Closes the GameTDB xml file
|
//! Closes the GameTDB xml file
|
||||||
void CloseFile();
|
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
|
//! 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
|
//! If the language code is not found, the language code defaults to EN
|
||||||
void SetLanguageCode(const char * code) { if(code) LangCode = code; };
|
void SetLanguageCode(const char * code) { if(code) LangCode = code; };
|
||||||
//! Get the current set language code
|
//! Get the current set language code
|
||||||
const char * GetLanguageCode() { return LangCode.c_str(); };
|
const char * GetLanguageCode() { return LangCode.c_str(); };
|
||||||
//! Get the title of a specific game id in the language defined in LangCode
|
//! 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
|
//! Get the name of a specific game id
|
||||||
bool GetName(const char *id, const char * &name);
|
bool GetName(const char *id, const char * &name);
|
||||||
//! Get the synopsis of a specific game id in the language defined in LangCode
|
//! Get the synopsis of a specific game id in the language defined in LangCode
|
||||||
@ -126,9 +124,6 @@ private:
|
|||||||
bool ParseFile();
|
bool ParseFile();
|
||||||
bool LoadGameOffsets(const char * path);
|
bool LoadGameOffsets(const char * path);
|
||||||
bool SaveGameOffsets(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 int GetData(char * data, int offset, int size);
|
||||||
inline char * LoadGameNode(const char * id);
|
inline char * LoadGameNode(const char * id);
|
||||||
inline char * GetGameNode(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);
|
inline char * GetNodeText(char *data, const char *nodestart, const char *nodeend);
|
||||||
|
|
||||||
bool isLoaded;
|
bool isLoaded;
|
||||||
bool isParsed;
|
|
||||||
vector<GameOffsets> OffsetMap;
|
vector<GameOffsets> OffsetMap;
|
||||||
FILE * file;
|
FILE * file;
|
||||||
const char *filepath;
|
|
||||||
string LangCode;
|
string LangCode;
|
||||||
char *GameNodeCache;
|
char *GameNodeCache;
|
||||||
char GameIDCache[7];
|
char GameIDCache[7];
|
||||||
|
@ -284,7 +284,7 @@ static void Add_Plugin_Game(char *FullPath)
|
|||||||
|
|
||||||
const char *gameTDB_Title = NULL;
|
const char *gameTDB_Title = NULL;
|
||||||
if(gameTDB.IsLoaded() && customTitle.empty())
|
if(gameTDB.IsLoaded() && customTitle.empty())
|
||||||
gameTDB.GetTitle(ListElement.id, gameTDB_Title);
|
gameTDB.GetTitle(ListElement.id, gameTDB_Title, true);
|
||||||
|
|
||||||
/* set the roms title */
|
/* set the roms title */
|
||||||
if(!customTitle.empty())
|
if(!customTitle.empty())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user