split Genre display on several lines on the Game Info page.

This commit is contained in:
lustar.mii 2009-06-14 09:33:55 +00:00
parent 6396c7099f
commit 9a4fd8e680
3 changed files with 168 additions and 99 deletions

View File

@ -239,7 +239,6 @@ showGameInfo(char *ID, u8 *headerID)
}
for (int i=1;strcmp(gameinfo.accessories[i],"") != 0;i++)
{
if (strcmp(gameinfo.accessories[i],"classiccontroller")==0)
classiccontroller=1;
@ -271,9 +270,6 @@ showGameInfo(char *ID, u8 *headerID)
gamecube=1;
}
dialogBoxImg1 = new GuiImage(&dialogBox1);
dialogBoxImg1->SetAlignment(0,3);
dialogBoxImg1->SetPosition(-9,0);
@ -553,30 +549,35 @@ showGameInfo(char *ID, u8 *headerID)
releasedTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); releasedTxt->SetPosition(-17,12+y); y+=(20 * newline);newline=1;
gameinfoWindow.Append(releasedTxt);}
//genre
if (strcmp(gameinfo.genre,"") != 0)
{snprintf(linebuf, sizeof(linebuf), "%s", gameinfo.genre);
if (strcmp(gameinfo.genresplit[1],"") != 0){
for (int i=1;strcmp(gameinfo.genresplit[i],"") !=0;i++)
{
snprintf(linebuf, sizeof(linebuf), "%s", gameinfo.genresplit[i]);
genreTxt = new GuiText(linebuf, 16, (GXColor){0,0,0, 255});
if (genreTxt->GetWidth()>300) newline=2;
genreTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); genreTxt->SetPosition(205,12+y1); y1+=(25 * newline);newline=1;
gameinfoWindow.Append(genreTxt);}
genreTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); genreTxt->SetPosition(205,12+y1); y1+=(20 * i);
gameinfoWindow.Append(genreTxt);
}
}
//developer
if (strcmp(gameinfo.developer,"") != 0 && strcmp(gameinfo.developer,gameinfo.publisher) != 0)
{snprintf(linebuf, sizeof(linebuf), "%s %s", LANGUAGE.developedby, gameinfo.developer);
if (strcmp(gameinfo.developer,"") != 0 && strcmp(gameinfo.developer,gameinfo.publisher) != 0) {
snprintf(linebuf, sizeof(linebuf), "%s %s", LANGUAGE.developedby, gameinfo.developer);
developerTxt = new GuiText(linebuf, 16, (GXColor){0,0,0, 255});
if (developerTxt->GetWidth()>250) newline=2;
developerTxt->SetMaxWidth(250,GuiText::WRAP);
developerTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); developerTxt->SetPosition(-17,12+y); y+=(40 * newline);newline=1;
gameinfoWindow.Append(developerTxt);}
gameinfoWindow.Append(developerTxt);
}
//publisher
if (strcmp(gameinfo.publisher,"") != 0)
{snprintf(linebuf, sizeof(linebuf), "%s %s", LANGUAGE.publishedby, gameinfo.publisher);
if (strcmp(gameinfo.publisher,"") != 0){
snprintf(linebuf, sizeof(linebuf), "%s %s", LANGUAGE.publishedby, gameinfo.publisher);
publisherTxt = new GuiText(linebuf, 16, (GXColor){0,0,0, 255});
if (publisherTxt->GetWidth()>250) newline=2;
publisherTxt->SetMaxWidth(250,GuiText::WRAP);
publisherTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); publisherTxt->SetPosition(-17,12+y); y+=(20 * newline);newline=1;
gameinfoWindow.Append(publisherTxt);}
gameinfoWindow.Append(publisherTxt);
}
//don't bother us txt
snprintf(linebuf, sizeof(linebuf), "Don't bother the USB Loader GX Team about errors in this file.");

View File

@ -391,7 +391,6 @@ bool LoadGameInfoFromXML(char* gameid, char* langtxt)
/* search for game matching gameid */
while (1)
{
nodeid = mxmlIndexFind(nodeindex,"id", NULL);
if (nodeid != NULL) {
get_text(nodeid, element_text, sizeof(element_text));
@ -525,6 +524,29 @@ bool LoadGameInfoFromXML(char* gameid, char* langtxt)
ConvertRating(gameinfo.ratingvalue, gameinfo.ratingtype, "ESRB",gameinfo.ratingvalueESRB);
ConvertRating(gameinfo.ratingvalue, gameinfo.ratingtype, "PEGI",gameinfo.ratingvaluePEGI);
/* provide genre as an array: gameinfo.genresplit */
if (strcmp(gameinfo.genre,"") != 0){
const char *delimgenre = ",;";
char genretxt[500];
strcpy(genretxt,gameinfo.genre);
char *splitresult;
splitresult = strtok(genretxt, delimgenre);
if (splitresult != NULL) {
trim_inplace(splitresult);
strcpy(gameinfo.genresplit[1],splitresult);
int incr = 1;
while (splitresult != NULL)
{
splitresult = strtok(NULL, delimgenre);
if (splitresult != NULL && strcmp(splitresult,"")!=0) {
++incr;
trim_inplace(splitresult);
strcpy(gameinfo.genresplit[incr],splitresult);
}
}
}
}
//PrintGameInfo();
exist=true;
@ -651,3 +673,46 @@ void PrintGameInfo(bool showfullinfo)
}
}
/* trim leading and trailing whitespace functions, by calv */
void trim_copy(char *input, char *output)
{
char *end = output;
char c;
while(*input && isspace(*input))
++input;
while(*input)
{
c = *(output++) = *(input++);
if( !isspace(c) )
end = output;
}
*end = 0;
}
void trim_inplace(char *s)
{
trim_copy(s, s);
}
char *trim_nocopy(char *s)
{
char *start = s;
while(*start && isspace(*start))
++start;
char *i = start;
char *end = start;
while(*i)
{
if( !isspace(*(i++)) )
end = i;
}
*end = 0;
return start;
}

View File

@ -27,6 +27,7 @@ struct gameXMLinfo
char month[10];
char day[10];
char genre[500];
char genresplit[100][500];
char ratingtype[10];
char ratingvalue[10];
char ratingdescriptors[100][500];
@ -62,7 +63,9 @@ void FreeXMLMemory();
void title_set(char *id, char *title);
void trim_copy(char *input, char *output);
void trim_inplace(char *s);
char *trim_nocopy(char *s);
#ifdef __cplusplus
}