mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-01 00:55:06 +01:00
-cleaned up gametdb code
-fixed gametdb memory management, now you can reload cache as often as you want, read synopsis as often as you want without wiiflow codedumping or freezing anymore after a few
This commit is contained in:
parent
9665ea5dc7
commit
c08a0710ce
@ -31,7 +31,7 @@
|
||||
#include "text.hpp"
|
||||
#include "config/config.hpp"
|
||||
#include "gecko/gecko.h"
|
||||
|
||||
#include "memory/mem2.hpp"
|
||||
#define NAME_OFFSET_DB "gametdb_offsets.bin"
|
||||
#define MAXREADSIZE 1024*1024 //Cache size only for parsing the offsets: 1MB
|
||||
|
||||
@ -54,12 +54,12 @@ static const ReplaceStruct Replacements[] =
|
||||
};
|
||||
|
||||
GameTDB::GameTDB()
|
||||
: isLoaded(false), isParsed(false), file(0), filepath(0), LangCode("EN"), GameNodeCache(0)
|
||||
: isLoaded(false), isParsed(false), file(0), filepath(0), LangCode("EN"), GameNodeCache(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
GameTDB::GameTDB(const char *filepath)
|
||||
: isLoaded(false), isParsed(false), file(0), filepath(0), LangCode("EN"), GameNodeCache(0)
|
||||
: isLoaded(false), isParsed(false), file(0), filepath(0), LangCode("EN"), GameNodeCache(NULL)
|
||||
{
|
||||
OpenFile(filepath);
|
||||
}
|
||||
@ -108,7 +108,7 @@ void GameTDB::CloseFile()
|
||||
OffsetMap.clear();
|
||||
|
||||
if(GameNodeCache)
|
||||
delete [] GameNodeCache;
|
||||
MEM2_free(GameNodeCache);
|
||||
GameNodeCache = NULL;
|
||||
|
||||
if(file)
|
||||
@ -143,24 +143,22 @@ bool GameTDB::LoadGameOffsets(const char *path)
|
||||
bool result = ParseFile();
|
||||
if(result)
|
||||
SaveGameOffsets(OffsetDBPath.c_str());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
u64 ExistingVersion = GetGameTDBVersion();
|
||||
u64 Version = 0;
|
||||
u32 NodeCount = 0;
|
||||
u64 ExistingVersion = GetGameTDBVersion();
|
||||
u64 Version = 0;
|
||||
u32 NodeCount = 0;
|
||||
|
||||
fread(&Version, 1, sizeof(Version), fp);
|
||||
|
||||
if(ExistingVersion != Version)
|
||||
{
|
||||
fclose(fp);
|
||||
bool result = ParseFile();
|
||||
if(result)
|
||||
SaveGameOffsets(OffsetDBPath.c_str());
|
||||
|
||||
return result;
|
||||
fclose(fp);
|
||||
bool result = ParseFile();
|
||||
if(result)
|
||||
SaveGameOffsets(OffsetDBPath.c_str());
|
||||
return result;
|
||||
}
|
||||
|
||||
fread(&NodeCount, 1, sizeof(NodeCount), fp);
|
||||
@ -171,7 +169,6 @@ bool GameTDB::LoadGameOffsets(const char *path)
|
||||
bool result = ParseFile();
|
||||
if(result)
|
||||
SaveGameOffsets(OffsetDBPath.c_str());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -183,7 +180,6 @@ bool GameTDB::LoadGameOffsets(const char *path)
|
||||
bool result = ParseFile();
|
||||
if(result)
|
||||
SaveGameOffsets(OffsetDBPath.c_str());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -262,13 +258,13 @@ char *GameTDB::LoadGameNode(const char *id)
|
||||
if(!offset)
|
||||
return NULL;
|
||||
|
||||
char *data = new (std::nothrow) char[offset->nodesize+1];
|
||||
char *data = (char*)MEM2_alloc(offset->nodesize+1);
|
||||
if(!data)
|
||||
return NULL;
|
||||
|
||||
if((read = GetData(data, offset->gamenode, offset->nodesize)) != offset->nodesize)
|
||||
{
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -281,23 +277,21 @@ char *GameTDB::GetGameNode(const char *id)
|
||||
{
|
||||
char *data = NULL;
|
||||
|
||||
if(GameNodeCache != 0 && strncmp(id, GameIDCache, strlen(GameIDCache)) == 0)
|
||||
if(GameNodeCache != NULL && strncmp(id, GameIDCache, strlen(GameIDCache)) == 0)
|
||||
{
|
||||
data = new (std::nothrow) char[strlen(GameNodeCache)+1];
|
||||
data = (char*)MEM2_alloc(strlen(GameNodeCache)+1);
|
||||
if(data)
|
||||
strcpy(data, GameNodeCache);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(GameNodeCache)
|
||||
delete [] GameNodeCache;
|
||||
|
||||
MEM2_free(GameNodeCache);
|
||||
GameNodeCache = LoadGameNode(id);
|
||||
|
||||
if(GameNodeCache)
|
||||
{
|
||||
snprintf(GameIDCache, sizeof(GameIDCache), id);
|
||||
data = new (std::nothrow) char[strlen(GameNodeCache)+1];
|
||||
data = (char*)MEM2_alloc(strlen(GameNodeCache)+1);
|
||||
if(data)
|
||||
strcpy(data, GameNodeCache);
|
||||
}
|
||||
@ -317,7 +311,7 @@ GameOffsets *GameTDB::GetGameOffset(const char *gameID)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline char *CleanText(char *in_text)
|
||||
static inline char *CleanText(char * &in_text)
|
||||
{
|
||||
if(!in_text)
|
||||
return NULL;
|
||||
@ -409,7 +403,7 @@ bool GameTDB::ParseFile()
|
||||
if(!file)
|
||||
return false;
|
||||
|
||||
char *Line = new (std::nothrow) char[MAXREADSIZE+1];
|
||||
char *Line = (char*)MEM2_alloc(MAXREADSIZE+1);
|
||||
if(!Line)
|
||||
return false;
|
||||
|
||||
@ -454,59 +448,48 @@ bool GameTDB::ParseFile()
|
||||
OffsetMap[size].nodesize = (gameEndNode-gameNode);
|
||||
gameNode = gameEndNode;
|
||||
}
|
||||
|
||||
if(readnew)
|
||||
continue;
|
||||
|
||||
currentPos += read;
|
||||
}
|
||||
|
||||
delete [] Line;
|
||||
|
||||
MEM2_free(Line);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameTDB::FindTitle(char *data, string & title, string langCode)
|
||||
bool GameTDB::FindTitle(char *data, const char * &title, const string &langCode)
|
||||
{
|
||||
char *language = SeekLang(data, langCode.c_str());
|
||||
if(!language)
|
||||
if(language == NULL)
|
||||
{
|
||||
language = SeekLang(data, "EN");
|
||||
if(!language)
|
||||
if(language == NULL)
|
||||
return false;
|
||||
}
|
||||
title = GetNodeText(language, "<title>", "</title>");
|
||||
|
||||
char *the_title = GetNodeText(language, "<title>", "</title>");
|
||||
if(!the_title)
|
||||
if(title == NULL)
|
||||
return false;
|
||||
|
||||
char tmp[64];
|
||||
strncpy(tmp, the_title, sizeof(tmp) - 1);
|
||||
tmp[sizeof(tmp) - 1] = '\0';
|
||||
title=tmp;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameTDB::GetTitle(const char *id, string & title)
|
||||
bool GameTDB::GetTitle(const char *id, const char * &title)
|
||||
{
|
||||
title = "";
|
||||
if(!id)
|
||||
title = NULL;
|
||||
if(id == NULL)
|
||||
return false;
|
||||
|
||||
char *data = GetGameNode(id);
|
||||
if(!data)
|
||||
if(data == NULL)
|
||||
return false;
|
||||
|
||||
bool retval = FindTitle(data, title, LangCode);
|
||||
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool GameTDB::GetSynopsis(const char *id, string & synopsis)
|
||||
bool GameTDB::GetSynopsis(const char *id, const char * &synopsis)
|
||||
{
|
||||
synopsis = "";
|
||||
synopsis = NULL;
|
||||
if(!id)
|
||||
return false;
|
||||
|
||||
@ -515,99 +498,73 @@ bool GameTDB::GetSynopsis(const char *id, string & synopsis)
|
||||
return false;
|
||||
|
||||
char *language = SeekLang(data, LangCode.c_str());
|
||||
if(!language)
|
||||
if(language == NULL)
|
||||
{
|
||||
language = SeekLang(data, "EN");
|
||||
if(!language)
|
||||
if(language == NULL)
|
||||
{
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
synopsis = GetNodeText(language, "<synopsis>", "</synopsis>");
|
||||
MEM2_free(data);
|
||||
|
||||
char *the_synopsis = GetNodeText(language, "<synopsis>", "</synopsis>");
|
||||
if(!the_synopsis)
|
||||
{
|
||||
delete [] data;
|
||||
if(synopsis == NULL)
|
||||
return false;
|
||||
}
|
||||
|
||||
synopsis = the_synopsis;
|
||||
|
||||
delete [] data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameTDB::GetRegion(const char *id, string & region)
|
||||
bool GameTDB::GetRegion(const char *id, const char * ®ion)
|
||||
{
|
||||
region = "";
|
||||
region = NULL;
|
||||
if(!id)
|
||||
return false;
|
||||
|
||||
char *data = GetGameNode(id);
|
||||
if(!data)
|
||||
return false;
|
||||
region = GetNodeText(data, "<region>", "</region>");
|
||||
MEM2_free(data);
|
||||
|
||||
char *the_region = GetNodeText(data, "<region>", "</region>");
|
||||
if(!the_region)
|
||||
{
|
||||
delete [] data;
|
||||
if(region == NULL)
|
||||
return false;
|
||||
}
|
||||
|
||||
region = the_region;
|
||||
|
||||
delete [] data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameTDB::GetDeveloper(const char *id, string & dev)
|
||||
bool GameTDB::GetDeveloper(const char *id, const char * &dev)
|
||||
{
|
||||
dev = "";
|
||||
dev = NULL;
|
||||
if(id == NULL)
|
||||
return false;
|
||||
|
||||
char *data = GetGameNode(id);
|
||||
if(data == NULL)
|
||||
return false;
|
||||
|
||||
dev = GetNodeText(data, "<developer>", "</developer>");
|
||||
MEM2_free(data);
|
||||
|
||||
if(dev == NULL)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameTDB::GetPublisher(const char *id, const char * &pub)
|
||||
{
|
||||
pub = NULL;
|
||||
if(!id)
|
||||
return false;
|
||||
|
||||
char *data = GetGameNode(id);
|
||||
if(!data)
|
||||
if(data == NULL)
|
||||
return false;
|
||||
|
||||
char *the_dev = GetNodeText(data, "<developer>", "</developer>");
|
||||
if(!the_dev)
|
||||
{
|
||||
delete [] data;
|
||||
pub = GetNodeText(data, "<publisher>", "</publisher>");
|
||||
MEM2_free(data);
|
||||
|
||||
if(pub == NULL)
|
||||
return false;
|
||||
}
|
||||
|
||||
dev = the_dev;
|
||||
|
||||
delete [] data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameTDB::GetPublisher(const char *id, string & pub)
|
||||
{
|
||||
pub = "";
|
||||
if(!id)
|
||||
return false;
|
||||
|
||||
char *data = GetGameNode(id);
|
||||
if(!data)
|
||||
return false;
|
||||
|
||||
char *the_pub = GetNodeText(data, "<publisher>", "</publisher>");
|
||||
if(!the_pub)
|
||||
{
|
||||
delete [] data;
|
||||
return false;
|
||||
}
|
||||
|
||||
pub = the_pub;
|
||||
|
||||
delete [] data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -623,7 +580,7 @@ u32 GameTDB::GetPublishDate(const char *id)
|
||||
char *year_string = GetNodeText(data, "<date year=\"", "/>");
|
||||
if(!year_string)
|
||||
{
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -634,7 +591,7 @@ u32 GameTDB::GetPublishDate(const char *id)
|
||||
char *month_string = strstr(year_string, "month=\"");
|
||||
if(!month_string)
|
||||
{
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -645,7 +602,7 @@ u32 GameTDB::GetPublishDate(const char *id)
|
||||
char *day_string = strstr(month_string, "day=\"");
|
||||
if(!day_string)
|
||||
{
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -653,60 +610,27 @@ u32 GameTDB::GetPublishDate(const char *id)
|
||||
|
||||
day = atoi(day_string);
|
||||
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
|
||||
return ((year & 0xFFFF) << 16 | (month & 0xFF) << 8 | (day & 0xFF));
|
||||
}
|
||||
|
||||
bool GameTDB::GetGenres(const char *id, string & gen)
|
||||
bool GameTDB::GetGenres(const char *id, const char * &gen)
|
||||
{
|
||||
vector<string> genre;
|
||||
gen = NULL;
|
||||
|
||||
gen = "";
|
||||
if(!id)
|
||||
if(id == NULL)
|
||||
return false;
|
||||
|
||||
char *data = GetGameNode(id);
|
||||
if(!data)
|
||||
if(data == NULL)
|
||||
return false;
|
||||
|
||||
char *the_genre = GetNodeText(data, "<genre>", "</genre>");
|
||||
if(!the_genre)
|
||||
{
|
||||
delete [] data;
|
||||
gen = GetNodeText(data, "<genre>", "</genre>");
|
||||
MEM2_free(data);
|
||||
|
||||
if(gen == NULL)
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 genre_num = 0;
|
||||
const char *ptr = the_genre;
|
||||
|
||||
while(*ptr != '\0')
|
||||
{
|
||||
if(genre_num >= genre.size())
|
||||
genre.resize(genre_num+1);
|
||||
|
||||
if(*ptr == ',' || *ptr == '/' || *ptr == ';')
|
||||
{
|
||||
ptr++;
|
||||
while(*ptr == ' ')
|
||||
ptr++;
|
||||
genre_num++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(genre[genre_num].size() == 0)
|
||||
genre[genre_num].push_back(toupper((int)*ptr));
|
||||
else
|
||||
genre[genre_num].push_back(*ptr);
|
||||
|
||||
++ptr;
|
||||
}
|
||||
genre[genre_num].push_back('\0');
|
||||
|
||||
delete [] data;
|
||||
|
||||
gen = vectorToString(genre, ", ");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -743,7 +667,7 @@ int GameTDB::GetRating(const char *id)
|
||||
char *rating_text = GetNodeText(data, "<rating type=\"", "/>");
|
||||
if(!rating_text)
|
||||
{
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
return rating;
|
||||
}
|
||||
|
||||
@ -756,14 +680,14 @@ int GameTDB::GetRating(const char *id)
|
||||
else if(strncmp(rating_text, "GRB", 4) == 0)
|
||||
rating = GAMETDB_RATING_TYPE_GRB;
|
||||
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
|
||||
return rating;
|
||||
}
|
||||
|
||||
bool GameTDB::GetRatingValue(const char *id, string & rating_value)
|
||||
bool GameTDB::GetRatingValue(const char *id, const char * &rating_value)
|
||||
{
|
||||
rating_value = "";
|
||||
rating_value = NULL;
|
||||
if(!id)
|
||||
return false;
|
||||
|
||||
@ -774,21 +698,15 @@ bool GameTDB::GetRatingValue(const char *id, string & rating_value)
|
||||
char *rating_text = GetNodeText(data, "<rating type=\"", "/>");
|
||||
if(!rating_text)
|
||||
{
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
return false;
|
||||
}
|
||||
|
||||
char *value_text = GetNodeText(rating_text, "value=\"", "\"");
|
||||
if(!value_text)
|
||||
{
|
||||
delete [] data;
|
||||
rating_value = GetNodeText(rating_text, "value=\"", "\"");
|
||||
MEM2_free(data);
|
||||
|
||||
if(rating_value == NULL)
|
||||
return false;
|
||||
}
|
||||
|
||||
rating_value = value_text;
|
||||
|
||||
delete [] data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -805,7 +723,7 @@ int GameTDB::GetRatingDescriptors(const char *id, vector<string> & desc_list)
|
||||
char *descriptor_text = GetNodeText(data, "<descriptor>", "</rating>");
|
||||
if(!descriptor_text)
|
||||
{
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -831,7 +749,7 @@ int GameTDB::GetRatingDescriptors(const char *id, vector<string> & desc_list)
|
||||
++descriptor_text;
|
||||
}
|
||||
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
|
||||
return desc_list.size();
|
||||
}
|
||||
@ -850,7 +768,7 @@ int GameTDB::GetWifiPlayers(const char *id)
|
||||
char *PlayersNode = GetNodeText(data, "<wi-fi players=\"", "\">");
|
||||
if(!PlayersNode)
|
||||
{
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
return players;
|
||||
}
|
||||
|
||||
@ -872,7 +790,7 @@ int GameTDB::GetWifiFeatures(const char *id, vector<string> & feat_list)
|
||||
char *feature_text = GetNodeText(data, "<feature>", "</wi-fi>");
|
||||
if(!feature_text)
|
||||
{
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -902,7 +820,7 @@ int GameTDB::GetWifiFeatures(const char *id, vector<string> & feat_list)
|
||||
++feature_text;
|
||||
}
|
||||
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
|
||||
return feat_list.size();
|
||||
}
|
||||
@ -921,7 +839,7 @@ int GameTDB::GetPlayers(const char *id)
|
||||
char *PlayersNode = GetNodeText(data, "<input players=\"", "\">");
|
||||
if(!PlayersNode)
|
||||
{
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
return players;
|
||||
}
|
||||
|
||||
@ -943,7 +861,7 @@ int GameTDB::GetAccessories(const char *id, vector<Accessory> & acc_list)
|
||||
char *ControlsNode = GetNodeText(data, "<control type=\"", "</input>");
|
||||
if(!ControlsNode)
|
||||
{
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -961,7 +879,7 @@ int GameTDB::GetAccessories(const char *id, vector<Accessory> & acc_list)
|
||||
char *requiredField = strstr(ControlsNode, "required=\"");
|
||||
if(!requiredField)
|
||||
{
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -976,7 +894,7 @@ int GameTDB::GetAccessories(const char *id, vector<Accessory> & acc_list)
|
||||
list_num++;
|
||||
}
|
||||
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
|
||||
return acc_list.size();
|
||||
}
|
||||
@ -1010,7 +928,7 @@ u32 GameTDB::GetCaseColor(const char *id)
|
||||
if(color != 0xffffffff)
|
||||
gprintf("GameTDB: Found alternate color(%x) for: %s\n", color, id);
|
||||
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
return color;
|
||||
}
|
||||
|
||||
@ -1031,7 +949,7 @@ int GameTDB::GetCaseVersions(const char *id)
|
||||
char *PlayersNode = GetNodeText(data, "case versions=\"", "\"");
|
||||
if(!PlayersNode)
|
||||
{
|
||||
delete [] data;
|
||||
MEM2_free(data);
|
||||
return altcase;
|
||||
}
|
||||
|
||||
@ -1040,32 +958,6 @@ int GameTDB::GetCaseVersions(const char *id)
|
||||
return altcase;
|
||||
}
|
||||
|
||||
bool GameTDB::GetGameXMLInfo(const char *id, GameXMLInfo *gameInfo)
|
||||
{
|
||||
if(!id || !gameInfo)
|
||||
return false;
|
||||
|
||||
gameInfo->GameID = id;
|
||||
|
||||
GetTitle(id, gameInfo->Title);
|
||||
GetSynopsis(id, gameInfo->Synopsis);
|
||||
GetRegion(id, gameInfo->Region);
|
||||
GetDeveloper(id, gameInfo->Developer);
|
||||
GetPublisher(id, gameInfo->Publisher);
|
||||
gameInfo->PublishDate = GetPublishDate(id);
|
||||
GetGenres(id, gameInfo->Genres);
|
||||
gameInfo->RatingType = GetRating(id);
|
||||
GetRatingValue(id, gameInfo->RatingValue);
|
||||
GetRatingDescriptors(id, gameInfo->RatingDescriptors);
|
||||
gameInfo->WifiPlayers = GetWifiPlayers(id);
|
||||
GetWifiFeatures(id, gameInfo->WifiFeatures);
|
||||
gameInfo->Players = GetPlayers(id);
|
||||
GetAccessories(id, gameInfo->Accessories);
|
||||
gameInfo->CaseColor = GetCaseColor(id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameTDB::IsLoaded()
|
||||
{
|
||||
return isLoaded;
|
||||
|
@ -43,27 +43,6 @@ typedef struct _Accessory
|
||||
bool Required;
|
||||
} Accessory;
|
||||
|
||||
typedef struct _GameXMLInfo
|
||||
{
|
||||
string GameID;
|
||||
string Region;
|
||||
string Title;
|
||||
string Synopsis;
|
||||
string Developer;
|
||||
string Publisher;
|
||||
unsigned int PublishDate;
|
||||
string Genres;
|
||||
int RatingType;
|
||||
string RatingValue;
|
||||
vector<string> RatingDescriptors;
|
||||
int WifiPlayers;
|
||||
vector<string> WifiFeatures;
|
||||
int Players;
|
||||
vector<Accessory> Accessories;
|
||||
int CaseColor;
|
||||
|
||||
} GameXMLInfo;
|
||||
|
||||
typedef struct _GameOffsets
|
||||
{
|
||||
char gameID[7];
|
||||
@ -73,97 +52,95 @@ typedef struct _GameOffsets
|
||||
|
||||
class GameTDB
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
GameTDB();
|
||||
//! Constructor
|
||||
//! If filepath is passed the xml file is opened and the node offsets are loaded
|
||||
GameTDB(const char * filepath);
|
||||
//! Destructor
|
||||
~GameTDB();
|
||||
//! If filepath is passed the xml file is opened and the node offsets are loaded
|
||||
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, string & title);
|
||||
//! Get the synopsis of a specific game id in the language defined in LangCode
|
||||
bool GetSynopsis(const char * id, string & synopsis);
|
||||
//! Get the region of a game for a specific game id
|
||||
bool GetRegion(const char * id, string & region);
|
||||
//! Get the developer of a game for a specific game id
|
||||
bool GetDeveloper(const char * id, string & dev);
|
||||
//! Get the publisher of a game for a specific game id
|
||||
bool GetPublisher(const char * id, string & pub);
|
||||
//! Get the publish date of a game for a specific game id
|
||||
//! First 1 byte is the day, than 1 byte month and last 2 bytes is the year
|
||||
//! year = (return >> 16), month = (return >> 8) & 0xFF, day = return & 0xFF
|
||||
unsigned int GetPublishDate(const char * id);
|
||||
//! Get the genre list of a game for a specific game id
|
||||
bool GetGenres(const char * id, string & gen);
|
||||
//! Get the rating type for a specific game id
|
||||
//! The rating type can be converted to a string with GameTDB::RatingToString(rating)
|
||||
int GetRating(const char * id);
|
||||
//! Get the rating value for a specific game id
|
||||
bool GetRatingValue(const char * id, string & rating_value);
|
||||
//! Get the rating descriptor list inside a vector for a specific game id
|
||||
//! Returns the amount of descriptors found or -1 if failed
|
||||
int GetRatingDescriptors(const char * id, vector<string> & desc_list);
|
||||
//! Get the wifi player count for a specific game id
|
||||
//! Returns the amount of wifi players or -1 if failed
|
||||
int GetWifiPlayers(const char * id);
|
||||
//! Get the wifi feature list inside a vector for a specific game id
|
||||
//! Returns the amount of wifi features found or -1 if failed
|
||||
int GetWifiFeatures(const char * id, vector<string> & feat_list);
|
||||
//! Get the player count for a specific game id
|
||||
//! Returns the amount of players or -1 if failed
|
||||
int GetPlayers(const char * id);
|
||||
//! Returns the amount of accessoires found or -1 if failed
|
||||
//! Get the accessoire (inputs) list inside a vector for a specific game id
|
||||
int GetAccessories(const char * id, vector<Accessory> & acc_list);
|
||||
//! Get the box (case) color for a specific game id
|
||||
//! Returns the color in RGB (first 3 bytes)
|
||||
unsigned int GetCaseColor(const char * id);
|
||||
int GetCaseVersions(const char * id);
|
||||
//! Get the complete game info in the GameXMLInfo struct
|
||||
bool GetGameXMLInfo(const char * id, GameXMLInfo * gameInfo);
|
||||
//! Convert a specific game rating to a string
|
||||
static const char * RatingToString(int rating);
|
||||
//! Get the version of the gametdb xml database
|
||||
unsigned long long GetGameTDBVersion();
|
||||
//! Get the entry count in the xml database
|
||||
inline size_t GetEntryCount() { return OffsetMap.size(); };
|
||||
//! Is a database loaded
|
||||
bool IsLoaded();
|
||||
private:
|
||||
bool ParseFile();
|
||||
bool LoadGameOffsets(const char * path);
|
||||
bool SaveGameOffsets(const char * path);
|
||||
bool CheckTitlesIni(const char * path);
|
||||
bool FindTitle(char * data, string & title, string langCode);
|
||||
unsigned int FindCaseColor(char * data);
|
||||
inline int GetData(char * data, int offset, int size);
|
||||
inline char * LoadGameNode(const char * id);
|
||||
inline char * GetGameNode(const char * id);
|
||||
inline GameOffsets * GetGameOffset(const char * id);
|
||||
inline char * SeekLang(char * text, const char * langcode);
|
||||
inline char * GetNodeText(char * data, const char * nodestart, const char * nodeend);
|
||||
public:
|
||||
//! Constructor
|
||||
GameTDB();
|
||||
//! Constructor
|
||||
//! If filepath is passed the xml file is opened and the node offsets are loaded
|
||||
GameTDB(const char * filepath);
|
||||
//! Destructor
|
||||
~GameTDB();
|
||||
//! If filepath is passed the xml file is opened and the node offsets are loaded
|
||||
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);
|
||||
//! Get the synopsis of a specific game id in the language defined in LangCode
|
||||
bool GetSynopsis(const char *id, const char * &synopsis);
|
||||
//! Get the region of a game for a specific game id
|
||||
bool GetRegion(const char *id, const char * ®ion);
|
||||
//! Get the developer of a game for a specific game id
|
||||
bool GetDeveloper(const char *id, const char * &dev);
|
||||
//! Get the publisher of a game for a specific game id
|
||||
bool GetPublisher(const char *id, const char * &pub);
|
||||
//! Get the publish date of a game for a specific game id
|
||||
//! First 1 byte is the day, than 1 byte month and last 2 bytes is the year
|
||||
//! year = (return >> 16), month = (return >> 8) & 0xFF, day = return & 0xFF
|
||||
unsigned int GetPublishDate(const char *id);
|
||||
//! Get the genre list of a game for a specific game id
|
||||
bool GetGenres(const char * id, const char * &gen);
|
||||
//! Get the rating type for a specific game id
|
||||
//! The rating type can be converted to a string with GameTDB::RatingToString(rating)
|
||||
int GetRating(const char * id);
|
||||
//! Get the rating value for a specific game id
|
||||
bool GetRatingValue(const char * id, const char * &rating_value);
|
||||
//! Get the rating descriptor list inside a vector for a specific game id
|
||||
//! Returns the amount of descriptors found or -1 if failed
|
||||
int GetRatingDescriptors(const char * id, vector<string> & desc_list);
|
||||
//! Get the wifi player count for a specific game id
|
||||
//! Returns the amount of wifi players or -1 if failed
|
||||
int GetWifiPlayers(const char * id);
|
||||
//! Get the wifi feature list inside a vector for a specific game id
|
||||
//! Returns the amount of wifi features found or -1 if failed
|
||||
int GetWifiFeatures(const char * id, vector<string> & feat_list);
|
||||
//! Get the player count for a specific game id
|
||||
//! Returns the amount of players or -1 if failed
|
||||
int GetPlayers(const char * id);
|
||||
//! Returns the amount of accessoires found or -1 if failed
|
||||
//! Get the accessoire (inputs) list inside a vector for a specific game id
|
||||
int GetAccessories(const char * id, vector<Accessory> & acc_list);
|
||||
//! Get the box (case) color for a specific game id
|
||||
//! Returns the color in RGB (first 3 bytes)
|
||||
unsigned int GetCaseColor(const char * id);
|
||||
int GetCaseVersions(const char * id);
|
||||
//! Convert a specific game rating to a string
|
||||
static const char * RatingToString(int rating);
|
||||
//! Get the version of the gametdb xml database
|
||||
unsigned long long GetGameTDBVersion();
|
||||
//! Get the entry count in the xml database
|
||||
inline size_t GetEntryCount() { return OffsetMap.size(); };
|
||||
//! Is a database loaded
|
||||
bool IsLoaded();
|
||||
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);
|
||||
unsigned int FindCaseColor(char * data);
|
||||
inline int GetData(char * data, int offset, int size);
|
||||
inline char * LoadGameNode(const char * id);
|
||||
inline char * GetGameNode(const char * id);
|
||||
inline GameOffsets * GetGameOffset(const char * id);
|
||||
inline char * SeekLang(char * text, const char * langcode);
|
||||
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];
|
||||
bool isLoaded;
|
||||
bool isParsed;
|
||||
vector<GameOffsets> OffsetMap;
|
||||
FILE * file;
|
||||
const char *filepath;
|
||||
string LangCode;
|
||||
char *GameNodeCache;
|
||||
char GameIDCache[7];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -70,18 +70,18 @@ static void AddISO(const char *GameID, const char *GameTitle, const char *GamePa
|
||||
if(GameID != NULL) strncpy(ListElement.id, GameID, 6);
|
||||
if(GamePath != NULL) strncpy(ListElement.path, GamePath, sizeof(ListElement.path) - 1);
|
||||
ListElement.casecolor = CustomTitles.getColor("COVERS", ListElement.id, GameColor).intVal();
|
||||
string CustomTitle = CustomTitles.getString("TITLES", ListElement.id);
|
||||
const char *CustomTitle = CustomTitles.getString("TITLES", ListElement.id).c_str();
|
||||
if(gameTDB.IsLoaded())
|
||||
{
|
||||
if(ListElement.casecolor == GameColor)
|
||||
ListElement.casecolor = gameTDB.GetCaseColor(ListElement.id);
|
||||
if(CustomTitle.size() == 0)
|
||||
gameTDB.GetTitle(ListElement.id, CustomTitle);
|
||||
ListElement.wifi = gameTDB.GetWifiPlayers(ListElement.id);
|
||||
ListElement.players = gameTDB.GetPlayers(ListElement.id);
|
||||
if(CustomTitle == NULL || CustomTitle[0] == '\0')
|
||||
gameTDB.GetTitle(ListElement.id, CustomTitle);
|
||||
}
|
||||
if(CustomTitle.size() > 0)
|
||||
mbstowcs(ListElement.title, CustomTitle.c_str(), 63);
|
||||
if(CustomTitle != NULL && CustomTitle[0] != '\0')
|
||||
mbstowcs(ListElement.title, CustomTitle, 63);
|
||||
else if(GameTitle != NULL)
|
||||
mbstowcs(ListElement.title, GameTitle, 63);
|
||||
Asciify(ListElement.title);
|
||||
@ -201,18 +201,18 @@ static void Create_Channel_List()
|
||||
ListElement.settings[1] = TITLE_LOWER(chan->title);
|
||||
strncpy(ListElement.id, chan->id, 4);
|
||||
ListElement.casecolor = CustomTitles.getColor("COVERS", ListElement.id, 1).intVal();
|
||||
string CustomTitle = CustomTitles.getString("TITLES", ListElement.id);
|
||||
const char *CustomTitle = CustomTitles.getString("TITLES", ListElement.id).c_str();
|
||||
if(gameTDB.IsLoaded())
|
||||
{
|
||||
if(ListElement.casecolor == 1)
|
||||
ListElement.casecolor = gameTDB.GetCaseColor(ListElement.id);
|
||||
if(CustomTitle.size() == 0)
|
||||
gameTDB.GetTitle(ListElement.id, CustomTitle);
|
||||
ListElement.wifi = gameTDB.GetWifiPlayers(ListElement.id);
|
||||
ListElement.players = gameTDB.GetPlayers(ListElement.id);
|
||||
if(CustomTitle == NULL || CustomTitle[0] == '\0')
|
||||
gameTDB.GetTitle(ListElement.id, CustomTitle);
|
||||
}
|
||||
if(CustomTitle.size() > 0)
|
||||
mbstowcs(ListElement.title, CustomTitle.c_str(), 63);
|
||||
if(CustomTitle != NULL && CustomTitle[0] != '\0')
|
||||
mbstowcs(ListElement.title, CustomTitle, 63);
|
||||
else
|
||||
wcsncpy(ListElement.title, chan->name, 64);
|
||||
ListElement.type = TYPE_CHANNEL;
|
||||
|
@ -1668,60 +1668,59 @@ void CMenu::_initCF(void)
|
||||
if (ageLock < 19)
|
||||
{
|
||||
int ageRated = min(max(gameAgeList.getInt(domain, id), 0), 19);
|
||||
|
||||
if(ageRated == 0 && (element->type == TYPE_WII_GAME || element->type == TYPE_CHANNEL))
|
||||
if(ageRated == 0 && gametdb.IsLoaded() && (element->type == TYPE_WII_GAME || element->type == TYPE_CHANNEL))
|
||||
{
|
||||
GameXMLInfo gameinfo;
|
||||
if(gametdb.IsLoaded() && gametdb.GetGameXMLInfo(id.c_str(), &gameinfo))
|
||||
const char *RatingValue = NULL;
|
||||
if(gametdb.GetRatingValue(id.c_str(), RatingValue))
|
||||
{
|
||||
switch(gameinfo.RatingType)
|
||||
switch(gametdb.GetRating(id.c_str()))
|
||||
{
|
||||
case GAMETDB_RATING_TYPE_CERO:
|
||||
if (gameinfo.RatingValue == "A")
|
||||
if(RatingValue[0] == 'A')
|
||||
ageRated = 3;
|
||||
else if (gameinfo.RatingValue == "B")
|
||||
else if(RatingValue[0] == 'B')
|
||||
ageRated = 12;
|
||||
else if (gameinfo.RatingValue == "D")
|
||||
else if(RatingValue[0] == 'D')
|
||||
ageRated = 15;
|
||||
else if (gameinfo.RatingValue == "C")
|
||||
else if(RatingValue[0] == 'C')
|
||||
ageRated = 17;
|
||||
else if (gameinfo.RatingValue == "Z")
|
||||
else if(RatingValue[0] == 'Z')
|
||||
ageRated = 18;
|
||||
break;
|
||||
case GAMETDB_RATING_TYPE_ESRB:
|
||||
if (gameinfo.RatingValue == "E")
|
||||
if(RatingValue[0] == 'E')
|
||||
ageRated = 6;
|
||||
else if (gameinfo.RatingValue == "EC")
|
||||
else if(memcmp(RatingValue, "EC", 2) == 0)
|
||||
ageRated = 3;
|
||||
else if (gameinfo.RatingValue == "E10+")
|
||||
else if(memcmp(RatingValue, "E10+", 4) == 0)
|
||||
ageRated = 10;
|
||||
else if (gameinfo.RatingValue == "T")
|
||||
else if(RatingValue[0] == 'T')
|
||||
ageRated = 13;
|
||||
else if (gameinfo.RatingValue == "M")
|
||||
else if(RatingValue[0] == 'M')
|
||||
ageRated = 17;
|
||||
else if (gameinfo.RatingValue == "AO")
|
||||
else if(memcmp(RatingValue, "AO", 2) == 0)
|
||||
ageRated = 18;
|
||||
break;
|
||||
case GAMETDB_RATING_TYPE_PEGI:
|
||||
if (gameinfo.RatingValue == "3")
|
||||
if(RatingValue[0] == '3')
|
||||
ageRated = 3;
|
||||
else if (gameinfo.RatingValue == "7")
|
||||
else if(RatingValue[0] == '7')
|
||||
ageRated = 7;
|
||||
else if (gameinfo.RatingValue == "12")
|
||||
else if(memcmp(RatingValue, "12", 2) == 0)
|
||||
ageRated = 12;
|
||||
else if (gameinfo.RatingValue == "16")
|
||||
else if(memcmp(RatingValue, "16", 2) == 0)
|
||||
ageRated = 16;
|
||||
else if (gameinfo.RatingValue == "18")
|
||||
else if(memcmp(RatingValue, "18", 2) == 0)
|
||||
ageRated = 18;
|
||||
break;
|
||||
case GAMETDB_RATING_TYPE_GRB:
|
||||
if (gameinfo.RatingValue == "A")
|
||||
if(RatingValue[0] == 'A')
|
||||
ageRated = 3;
|
||||
else if (gameinfo.RatingValue == "12")
|
||||
else if(memcmp(RatingValue, "12", 2) == 0)
|
||||
ageRated = 12;
|
||||
else if (gameinfo.RatingValue == "15")
|
||||
else if(memcmp(RatingValue, "15", 2) == 0)
|
||||
ageRated = 15;
|
||||
else if (gameinfo.RatingValue == "18")
|
||||
else if(memcmp(RatingValue, "18", 2) == 0)
|
||||
ageRated = 18;
|
||||
break;
|
||||
default:
|
||||
|
@ -77,11 +77,10 @@ extern const u8 pegi_12_png[];
|
||||
extern const u8 pegi_16_png[];
|
||||
extern const u8 pegi_18_png[];
|
||||
|
||||
GameXMLInfo gameinfo;
|
||||
wstringEx gameinfo_Synopsis_w;
|
||||
wstringEx gameinfo_Title_w;
|
||||
|
||||
static bool titlecheck = false;
|
||||
bool titlecheck = false;
|
||||
u8 cnt_controlsreq = 0, cnt_controls = 0;
|
||||
const int pixels_to_skip = 10;
|
||||
|
||||
@ -130,7 +129,7 @@ void CMenu::_gameinfo(void)
|
||||
amount_of_skips--;
|
||||
}
|
||||
}
|
||||
else if (BTN_RIGHT_PRESSED && !(m_thrdWorking && m_thrdStop) && page == 0 && gameinfo.Synopsis.size() > 0)
|
||||
else if (BTN_RIGHT_PRESSED && !(m_thrdWorking && m_thrdStop) && page == 0 && !gameinfo_Synopsis_w.empty())
|
||||
{
|
||||
page = 1;
|
||||
amount_of_skips = 0;
|
||||
@ -313,24 +312,37 @@ void CMenu::_textGameInfo(void)
|
||||
GameTDB gametdb;
|
||||
gametdb.OpenFile(fmt("%s/wiitdb.xml", m_settingsDir.c_str()));
|
||||
gametdb.SetLanguageCode(m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str());
|
||||
|
||||
titlecheck = gametdb.IsLoaded() && gametdb.GetGameXMLInfo(m_cf.getId().c_str(), &gameinfo);
|
||||
const char *TMP_Char = NULL;
|
||||
titlecheck = gametdb.IsLoaded();
|
||||
if(titlecheck)
|
||||
{
|
||||
gameinfo_Title_w.fromUTF8(gameinfo.Title);
|
||||
m_btnMgr.setText(m_gameinfoLblTitle, gameinfo_Title_w, true);
|
||||
gameinfo_Synopsis_w.fromUTF8(gameinfo.Synopsis);
|
||||
m_btnMgr.setText(m_gameinfoLblSynopsis, gameinfo_Synopsis_w);
|
||||
char GameID[7];
|
||||
GameID[6] = '\0';
|
||||
strncpy(GameID, m_cf.getId().c_str(), 6);
|
||||
if(gametdb.GetTitle(GameID, TMP_Char))
|
||||
{
|
||||
gameinfo_Title_w.fromUTF8(TMP_Char);
|
||||
m_btnMgr.setText(m_gameinfoLblTitle, gameinfo_Title_w, true);
|
||||
}
|
||||
if(gametdb.GetSynopsis(GameID, TMP_Char))
|
||||
{
|
||||
gameinfo_Synopsis_w.fromUTF8(TMP_Char);
|
||||
m_btnMgr.setText(m_gameinfoLblSynopsis, gameinfo_Synopsis_w);
|
||||
}
|
||||
m_btnMgr.setText(m_gameinfoLblID, wfmt(L"GameID: %s", GameID), true);
|
||||
if(gametdb.GetDeveloper(GameID, TMP_Char))
|
||||
m_btnMgr.setText(m_gameinfoLblDev, wfmt(_fmt("gameinfo1",L"Developer: %s"), TMP_Char), true);
|
||||
if(gametdb.GetPublisher(GameID, TMP_Char))
|
||||
m_btnMgr.setText(m_gameinfoLblPublisher, wfmt(_fmt("gameinfo2",L"Publisher: %s"), TMP_Char), true);
|
||||
if(gametdb.GetRegion(GameID, TMP_Char))
|
||||
m_btnMgr.setText(m_gameinfoLblRegion, wfmt(_fmt("gameinfo3",L"Region: %s"), TMP_Char), true);
|
||||
if(gametdb.GetGenres(GameID, TMP_Char))
|
||||
m_btnMgr.setText(m_gameinfoLblGenre, wfmt(_fmt("gameinfo5",L"Genre: %s"), TMP_Char), true);
|
||||
|
||||
m_btnMgr.setText(m_gameinfoLblID, wfmt(L"GameID: %s", gameinfo.GameID.c_str()), true);
|
||||
m_btnMgr.setText(m_gameinfoLblDev, wfmt(_fmt("gameinfo1",L"Developer: %s"), gameinfo.Developer.c_str()), true);
|
||||
m_btnMgr.setText(m_gameinfoLblPublisher, wfmt(_fmt("gameinfo2",L"Publisher: %s"), gameinfo.Publisher.c_str()), true);
|
||||
m_btnMgr.setText(m_gameinfoLblRegion, wfmt(_fmt("gameinfo3",L"Region: %s"), gameinfo.Region.c_str()), true);
|
||||
m_btnMgr.setText(m_gameinfoLblGenre, wfmt(_fmt("gameinfo5",L"Genre: %s"), gameinfo.Genres.c_str()), true);
|
||||
|
||||
int year = gameinfo.PublishDate >> 16;
|
||||
int day = gameinfo.PublishDate & 0xFF;
|
||||
int month = (gameinfo.PublishDate >> 8) & 0xFF;
|
||||
int PublishDate = gametdb.GetPublishDate(GameID);
|
||||
int year = PublishDate >> 16;
|
||||
int day = PublishDate & 0xFF;
|
||||
int month = (PublishDate >> 8) & 0xFF;
|
||||
switch(CONF_GetRegion())
|
||||
{
|
||||
case 0:
|
||||
@ -345,151 +357,153 @@ void CMenu::_textGameInfo(void)
|
||||
m_btnMgr.setText(m_gameinfoLblRlsdate, wfmt(_fmt("gameinfo4",L"Release Date: %i-%i-%i"), day, month, year), true);
|
||||
break;
|
||||
}
|
||||
|
||||
//Ratings
|
||||
m_rating.fromJPG(norating_jpg, norating_jpg_size);
|
||||
switch(gameinfo.RatingType)
|
||||
const char *RatingValue = NULL;
|
||||
if(gametdb.GetRatingValue(GameID, RatingValue))
|
||||
{
|
||||
case GAMETDB_RATING_TYPE_CERO:
|
||||
if (gameinfo.RatingValue == "A")
|
||||
m_rating.fromPNG(cero_a_png);
|
||||
else if (gameinfo.RatingValue == "B")
|
||||
m_rating.fromPNG(cero_b_png);
|
||||
else if (gameinfo.RatingValue == "D")
|
||||
m_rating.fromPNG(cero_d_png);
|
||||
else if (gameinfo.RatingValue == "C")
|
||||
m_rating.fromPNG(cero_c_png);
|
||||
else if (gameinfo.RatingValue == "Z")
|
||||
m_rating.fromPNG(cero_z_png);
|
||||
break;
|
||||
case GAMETDB_RATING_TYPE_ESRB:
|
||||
if (gameinfo.RatingValue == "E")
|
||||
m_rating.fromJPG(esrb_e_jpg, esrb_e_jpg_size);
|
||||
else if (gameinfo.RatingValue == "EC")
|
||||
m_rating.fromJPG(esrb_ec_jpg, esrb_ec_jpg_size);
|
||||
else if (gameinfo.RatingValue == "E10+")
|
||||
m_rating.fromJPG(esrb_eten_jpg, esrb_eten_jpg_size);
|
||||
else if (gameinfo.RatingValue == "T")
|
||||
m_rating.fromJPG(esrb_t_jpg, esrb_t_jpg_size);
|
||||
else if (gameinfo.RatingValue == "M")
|
||||
m_rating.fromJPG(esrb_m_jpg, esrb_m_jpg_size);
|
||||
else if (gameinfo.RatingValue == "AO")
|
||||
m_rating.fromJPG(esrb_ao_jpg, esrb_ao_jpg_size);
|
||||
break;
|
||||
case GAMETDB_RATING_TYPE_PEGI:
|
||||
if (gameinfo.RatingValue == "3")
|
||||
m_rating.fromPNG(pegi_3_png);
|
||||
else if (gameinfo.RatingValue == "7")
|
||||
m_rating.fromPNG(pegi_7_png);
|
||||
else if (gameinfo.RatingValue == "12")
|
||||
m_rating.fromPNG(pegi_12_png);
|
||||
else if (gameinfo.RatingValue == "16")
|
||||
m_rating.fromPNG(pegi_16_png);
|
||||
else if (gameinfo.RatingValue == "18")
|
||||
m_rating.fromPNG(pegi_18_png);
|
||||
break;
|
||||
case GAMETDB_RATING_TYPE_GRB:
|
||||
if (gameinfo.RatingValue == "A")
|
||||
m_rating.fromPNG(grb_a_png);
|
||||
else if (gameinfo.RatingValue == "12")
|
||||
m_rating.fromPNG(grb_12_png);
|
||||
else if (gameinfo.RatingValue == "15")
|
||||
m_rating.fromPNG(grb_15_png);
|
||||
else if (gameinfo.RatingValue == "18")
|
||||
m_rating.fromPNG(grb_18_png);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch(gametdb.GetRating(GameID))
|
||||
{
|
||||
case GAMETDB_RATING_TYPE_CERO:
|
||||
if(RatingValue[0] == 'A')
|
||||
m_rating.fromPNG(cero_a_png);
|
||||
else if(RatingValue[0] == 'B')
|
||||
m_rating.fromPNG(cero_b_png);
|
||||
else if(RatingValue[0] == 'D')
|
||||
m_rating.fromPNG(cero_d_png);
|
||||
else if(RatingValue[0] == 'C')
|
||||
m_rating.fromPNG(cero_c_png);
|
||||
else if(RatingValue[0] == 'Z')
|
||||
m_rating.fromPNG(cero_z_png);
|
||||
break;
|
||||
case GAMETDB_RATING_TYPE_ESRB:
|
||||
if(RatingValue[0] == 'E')
|
||||
m_rating.fromJPG(esrb_e_jpg, esrb_e_jpg_size);
|
||||
else if(memcmp(RatingValue, "EC", 2) == 0)
|
||||
m_rating.fromJPG(esrb_ec_jpg, esrb_ec_jpg_size);
|
||||
else if(memcmp(RatingValue, "E10+", 4) == 0)
|
||||
m_rating.fromJPG(esrb_eten_jpg, esrb_eten_jpg_size);
|
||||
else if(RatingValue[0] == 'T')
|
||||
m_rating.fromJPG(esrb_t_jpg, esrb_t_jpg_size);
|
||||
else if(RatingValue[0] == 'M')
|
||||
m_rating.fromJPG(esrb_m_jpg, esrb_m_jpg_size);
|
||||
else if(memcmp(RatingValue, "AO", 2) == 0)
|
||||
m_rating.fromJPG(esrb_ao_jpg, esrb_ao_jpg_size);
|
||||
break;
|
||||
case GAMETDB_RATING_TYPE_PEGI:
|
||||
if(RatingValue[0] == '3')
|
||||
m_rating.fromPNG(pegi_3_png);
|
||||
else if(RatingValue[0] == '7')
|
||||
m_rating.fromPNG(pegi_7_png);
|
||||
else if(memcmp(RatingValue, "12", 2) == 0)
|
||||
m_rating.fromPNG(pegi_12_png);
|
||||
else if(memcmp(RatingValue, "16", 2) == 0)
|
||||
m_rating.fromPNG(pegi_16_png);
|
||||
else if(memcmp(RatingValue, "18", 2) == 0)
|
||||
m_rating.fromPNG(pegi_18_png);
|
||||
break;
|
||||
case GAMETDB_RATING_TYPE_GRB:
|
||||
if(RatingValue[0] == 'A')
|
||||
m_rating.fromPNG(grb_a_png);
|
||||
else if(memcmp(RatingValue, "12", 2) == 0)
|
||||
m_rating.fromPNG(grb_12_png);
|
||||
else if(memcmp(RatingValue, "15", 2) == 0)
|
||||
m_rating.fromPNG(grb_15_png);
|
||||
else if(memcmp(RatingValue, "18", 2) == 0)
|
||||
m_rating.fromPNG(grb_18_png);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_btnMgr.setTexture(m_gameinfoLblRating, m_rating);
|
||||
|
||||
//Wifi players
|
||||
int WifiPlayers = gametdb.GetWifiPlayers(GameID);
|
||||
STexture emptyTex;
|
||||
if (gameinfo.WifiPlayers == 1)
|
||||
if(WifiPlayers == 1)
|
||||
m_wifi.fromPNG(wifi1_png);
|
||||
else if (gameinfo.WifiPlayers == 2)
|
||||
else if(WifiPlayers == 2)
|
||||
m_wifi.fromPNG(wifi2_png);
|
||||
else if (gameinfo.WifiPlayers == 4)
|
||||
else if(WifiPlayers == 4)
|
||||
m_wifi.fromPNG(wifi4_png);
|
||||
else if (gameinfo.WifiPlayers == 8)
|
||||
else if(WifiPlayers == 8)
|
||||
m_wifi.fromPNG(wifi8_png);
|
||||
else if (gameinfo.WifiPlayers == 10)
|
||||
else if(WifiPlayers == 10)
|
||||
m_wifi.fromPNG(wifi10_png);
|
||||
else if (gameinfo.WifiPlayers == 12)
|
||||
else if(WifiPlayers == 12)
|
||||
m_wifi.fromPNG(wifi12_png);
|
||||
else if (gameinfo.WifiPlayers == 16)
|
||||
else if(WifiPlayers == 16)
|
||||
m_wifi.fromPNG(wifi16_png);
|
||||
else if (gameinfo.WifiPlayers == 18)
|
||||
else if(WifiPlayers == 18)
|
||||
m_wifi.fromPNG(wifi18_png);
|
||||
else if (gameinfo.WifiPlayers == 32)
|
||||
else if(WifiPlayers == 32)
|
||||
m_wifi.fromPNG(wifi32_png);
|
||||
|
||||
if(gameinfo.WifiPlayers > 0)
|
||||
if(WifiPlayers > 0)
|
||||
m_btnMgr.setTexture(m_gameinfoLblWifiplayers, m_wifi);
|
||||
else
|
||||
m_btnMgr.setTexture(m_gameinfoLblWifiplayers, emptyTex);
|
||||
|
||||
u8 wiimote=0,
|
||||
nunchuk=0,
|
||||
classiccontroller=0,
|
||||
balanceboard=0,
|
||||
dancepad=0,
|
||||
guitar=0,
|
||||
gamecube=0,
|
||||
motionplus=0,
|
||||
drums=0,
|
||||
microphone=0,
|
||||
wheel=0,
|
||||
keyboard=0,
|
||||
udraw = 0,
|
||||
zapper=0;
|
||||
|
||||
//check required controlls
|
||||
for (vector<Accessory>::iterator acc_itr = gameinfo.Accessories.begin(); acc_itr != gameinfo.Accessories.end(); acc_itr++)
|
||||
{
|
||||
if (!acc_itr->Required) continue;
|
||||
|
||||
if (strcmp((acc_itr->Name).c_str(), "wiimote") == 0)
|
||||
wiimote=1;
|
||||
else if (strcmp((acc_itr->Name).c_str(), "nunchuk") == 0)
|
||||
nunchuk=1;
|
||||
else if (strcmp((acc_itr->Name).c_str(), "guitar") == 0)
|
||||
guitar=1;
|
||||
else if (strcmp((acc_itr->Name).c_str(), "drums") == 0)
|
||||
drums=1;
|
||||
else if (strcmp((acc_itr->Name).c_str(), "dancepad") == 0)
|
||||
dancepad=1;
|
||||
else if (strcmp((acc_itr->Name).c_str(), "motionplus") == 0)
|
||||
motionplus=1;
|
||||
else if (strcmp((acc_itr->Name).c_str(), "microphone") == 0)
|
||||
microphone=1;
|
||||
else if (strcmp((acc_itr->Name).c_str(), "balanceboard") == 0)
|
||||
balanceboard=1;
|
||||
else if (strcmp((acc_itr->Name).c_str(), "udraw") == 0)
|
||||
udraw = 1;
|
||||
}
|
||||
bool wiimote = false;
|
||||
bool nunchuk = false;
|
||||
bool classiccontroller = false;
|
||||
bool balanceboard = false;
|
||||
bool dancepad = false;
|
||||
bool guitar = false;
|
||||
bool gamecube = false;
|
||||
bool motionplus = false;
|
||||
bool drums = false;
|
||||
bool microphone = false;
|
||||
bool wheel = false;
|
||||
bool keyboard = false;
|
||||
bool udraw = false;
|
||||
bool zapper = false;
|
||||
|
||||
vector<Accessory> Accessories;
|
||||
gametdb.GetAccessories(GameID, Accessories);
|
||||
for(vector<Accessory>::iterator acc_itr = Accessories.begin(); acc_itr != Accessories.end(); acc_itr++)
|
||||
{
|
||||
if(!acc_itr->Required)
|
||||
continue;
|
||||
if(strcmp((acc_itr->Name).c_str(), "wiimote") == 0)
|
||||
wiimote = true;
|
||||
else if(strcmp((acc_itr->Name).c_str(), "nunchuk") == 0)
|
||||
nunchuk = true;
|
||||
else if(strcmp((acc_itr->Name).c_str(), "guitar") == 0)
|
||||
guitar = true;
|
||||
else if(strcmp((acc_itr->Name).c_str(), "drums") == 0)
|
||||
drums = true;
|
||||
else if(strcmp((acc_itr->Name).c_str(), "dancepad") == 0)
|
||||
dancepad = true;
|
||||
else if(strcmp((acc_itr->Name).c_str(), "motionplus") == 0)
|
||||
motionplus = true;
|
||||
else if(strcmp((acc_itr->Name).c_str(), "microphone") == 0)
|
||||
microphone = true;
|
||||
else if(strcmp((acc_itr->Name).c_str(), "balanceboard") == 0)
|
||||
balanceboard = true;
|
||||
else if(strcmp((acc_itr->Name).c_str(), "udraw") == 0)
|
||||
udraw = true;
|
||||
}
|
||||
u8 x = 0;
|
||||
u8 max_controlsReq = ARRAY_SIZE(m_gameinfoLblControlsReq);
|
||||
|
||||
if(wiimote && x < max_controlsReq)
|
||||
{
|
||||
u8 players = gameinfo.Players;
|
||||
if (gameinfo.Players >= 10)
|
||||
players = players/10;
|
||||
u8 players = gametdb.GetPlayers(GameID);
|
||||
if(players >= 10)
|
||||
players /= 10;
|
||||
|
||||
if (players == 1)
|
||||
if(players == 1)
|
||||
m_controlsreq[x].fromPNG(wiimote1_png);
|
||||
else if (players == 2)
|
||||
else if(players == 2)
|
||||
m_controlsreq[x].fromPNG(wiimote2_png);
|
||||
else if (players == 3)
|
||||
else if(players == 3)
|
||||
m_controlsreq[x].fromPNG(wiimote3_png);
|
||||
else if (players == 4)
|
||||
else if(players == 4)
|
||||
m_controlsreq[x].fromPNG(wiimote4_png);
|
||||
else if (players == 6)
|
||||
else if(players == 6)
|
||||
m_controlsreq[x].fromPNG(wiimote6_png);
|
||||
else if (players == 8)
|
||||
else if(players == 8)
|
||||
m_controlsreq[x].fromPNG(wiimote8_png);
|
||||
|
||||
m_btnMgr.setTexture(m_gameinfoLblControlsReq[x] ,m_controlsreq[x], 20, 60);
|
||||
@ -543,60 +557,56 @@ void CMenu::_textGameInfo(void)
|
||||
m_btnMgr.setTexture(m_gameinfoLblControlsReq[x] ,m_controlsreq[x], 52, 60);
|
||||
x++;
|
||||
}
|
||||
|
||||
cnt_controlsreq = x;
|
||||
|
||||
//check optional controlls
|
||||
wiimote=0,
|
||||
nunchuk=0,
|
||||
classiccontroller=0,
|
||||
balanceboard=0,
|
||||
dancepad=0,
|
||||
guitar=0,
|
||||
gamecube=0,
|
||||
motionplus=0,
|
||||
drums=0,
|
||||
microphone=0,
|
||||
wheel=0,
|
||||
keyboard=0,
|
||||
udraw = 0,
|
||||
zapper=0;
|
||||
|
||||
for (vector<Accessory>::iterator acc_itr = gameinfo.Accessories.begin(); acc_itr != gameinfo.Accessories.end(); acc_itr++)
|
||||
wiimote = false;
|
||||
nunchuk = false;
|
||||
classiccontroller = false;
|
||||
balanceboard = false;
|
||||
dancepad = false;
|
||||
guitar = false;
|
||||
gamecube = false;
|
||||
motionplus = false;
|
||||
drums = false;
|
||||
microphone = false;
|
||||
wheel = false;
|
||||
keyboard = false;
|
||||
udraw = false;
|
||||
zapper = false;
|
||||
for(vector<Accessory>::iterator acc_itr = Accessories.begin(); acc_itr != Accessories.end(); acc_itr++)
|
||||
{
|
||||
if (acc_itr->Required) continue;
|
||||
|
||||
if (strcmp((acc_itr->Name).c_str(), "classiccontroller") == 0)
|
||||
classiccontroller=1;
|
||||
else if (strcmp((acc_itr->Name).c_str(), "nunchuk") == 0)
|
||||
nunchuk=1;
|
||||
else if (strcmp((acc_itr->Name).c_str(), "guitar") == 0)
|
||||
guitar=1;
|
||||
else if (strcmp((acc_itr->Name).c_str(), "drums") == 0)
|
||||
drums=1;
|
||||
else if (strcmp((acc_itr->Name).c_str(), "dancepad") == 0)
|
||||
dancepad=1;
|
||||
else if (strcmp((acc_itr->Name).c_str(), "motionplus") == 0)
|
||||
motionplus=1;
|
||||
else if (strcmp((acc_itr->Name).c_str(), "balanceboard") == 0)
|
||||
balanceboard=1;
|
||||
else if (strcmp((acc_itr->Name).c_str(), "microphone") == 0)
|
||||
microphone=1;
|
||||
else if (strcmp((acc_itr->Name).c_str(), "gamecube") == 0)
|
||||
gamecube=1;
|
||||
else if (strcmp((acc_itr->Name).c_str(), "keyboard") == 0)
|
||||
keyboard=1;
|
||||
else if (strcmp((acc_itr->Name).c_str(), "zapper") == 0)
|
||||
zapper=1;
|
||||
else if (strcmp((acc_itr->Name).c_str(), "wheel") == 0)
|
||||
wheel=1;
|
||||
else if (strcmp((acc_itr->Name).c_str(), "udraw") == 0)
|
||||
udraw = 1;
|
||||
}
|
||||
|
||||
if(acc_itr->Required)
|
||||
continue;
|
||||
if(strcmp((acc_itr->Name).c_str(), "classiccontroller") == 0)
|
||||
classiccontroller = true;
|
||||
else if(strcmp((acc_itr->Name).c_str(), "nunchuk") == 0)
|
||||
nunchuk = true;
|
||||
else if(strcmp((acc_itr->Name).c_str(), "guitar") == 0)
|
||||
guitar = true;
|
||||
else if(strcmp((acc_itr->Name).c_str(), "drums") == 0)
|
||||
drums = true;
|
||||
else if(strcmp((acc_itr->Name).c_str(), "dancepad") == 0)
|
||||
dancepad = true;
|
||||
else if(strcmp((acc_itr->Name).c_str(), "motionplus") == 0)
|
||||
motionplus = true;
|
||||
else if(strcmp((acc_itr->Name).c_str(), "balanceboard") == 0)
|
||||
balanceboard = true;
|
||||
else if(strcmp((acc_itr->Name).c_str(), "microphone") == 0)
|
||||
microphone = true;
|
||||
else if(strcmp((acc_itr->Name).c_str(), "gamecube") == 0)
|
||||
gamecube = true;
|
||||
else if(strcmp((acc_itr->Name).c_str(), "keyboard") == 0)
|
||||
keyboard = true;
|
||||
else if(strcmp((acc_itr->Name).c_str(), "zapper") == 0)
|
||||
zapper = true;
|
||||
else if(strcmp((acc_itr->Name).c_str(), "wheel") == 0)
|
||||
wheel = true;
|
||||
else if(strcmp((acc_itr->Name).c_str(), "udraw") == 0)
|
||||
udraw = true;
|
||||
}
|
||||
x = 0;
|
||||
u8 max_controls = ARRAY_SIZE(m_gameinfoLblControls);
|
||||
|
||||
if(classiccontroller && x < max_controls)
|
||||
{
|
||||
m_controls[x].fromPNG(classiccontroller_png);
|
||||
@ -675,12 +685,10 @@ void CMenu::_textGameInfo(void)
|
||||
m_btnMgr.setTexture(m_gameinfoLblControls[x] ,m_controls[x], 52, 60);
|
||||
x++;
|
||||
}
|
||||
|
||||
cnt_controls = x;
|
||||
}
|
||||
else
|
||||
m_btnMgr.setText(m_gameinfoLblTitle, wfmt(_fmt("gameinfo6",L"No Gameinfo"), true));
|
||||
|
||||
gametdb.CloseFile();
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user