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++) for (int i=1;strcmp(gameinfo.accessories[i],"") != 0;i++)
{ {
if (strcmp(gameinfo.accessories[i],"classiccontroller")==0) if (strcmp(gameinfo.accessories[i],"classiccontroller")==0)
classiccontroller=1; classiccontroller=1;
@ -271,9 +270,6 @@ showGameInfo(char *ID, u8 *headerID)
gamecube=1; gamecube=1;
} }
dialogBoxImg1 = new GuiImage(&dialogBox1); dialogBoxImg1 = new GuiImage(&dialogBox1);
dialogBoxImg1->SetAlignment(0,3); dialogBoxImg1->SetAlignment(0,3);
dialogBoxImg1->SetPosition(-9,0); 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; releasedTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); releasedTxt->SetPosition(-17,12+y); y+=(20 * newline);newline=1;
gameinfoWindow.Append(releasedTxt);} gameinfoWindow.Append(releasedTxt);}
//genre //genre
if (strcmp(gameinfo.genre,"") != 0) if (strcmp(gameinfo.genresplit[1],"") != 0){
{snprintf(linebuf, sizeof(linebuf), "%s", gameinfo.genre); 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}); 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+=(20 * i);
genreTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); genreTxt->SetPosition(205,12+y1); y1+=(25 * newline);newline=1; gameinfoWindow.Append(genreTxt);
gameinfoWindow.Append(genreTxt);} }
}
//developer //developer
if (strcmp(gameinfo.developer,"") != 0 && strcmp(gameinfo.developer,gameinfo.publisher) != 0) if (strcmp(gameinfo.developer,"") != 0 && strcmp(gameinfo.developer,gameinfo.publisher) != 0) {
{snprintf(linebuf, sizeof(linebuf), "%s %s", LANGUAGE.developedby, gameinfo.developer); snprintf(linebuf, sizeof(linebuf), "%s %s", LANGUAGE.developedby, gameinfo.developer);
developerTxt = new GuiText(linebuf, 16, (GXColor){0,0,0, 255}); developerTxt = new GuiText(linebuf, 16, (GXColor){0,0,0, 255});
if (developerTxt->GetWidth()>250) newline=2; if (developerTxt->GetWidth()>250) newline=2;
developerTxt->SetMaxWidth(250,GuiText::WRAP); developerTxt->SetMaxWidth(250,GuiText::WRAP);
developerTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); developerTxt->SetPosition(-17,12+y); y+=(40 * newline);newline=1; developerTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); developerTxt->SetPosition(-17,12+y); y+=(40 * newline);newline=1;
gameinfoWindow.Append(developerTxt);} gameinfoWindow.Append(developerTxt);
}
//publisher //publisher
if (strcmp(gameinfo.publisher,"") != 0) if (strcmp(gameinfo.publisher,"") != 0){
{snprintf(linebuf, sizeof(linebuf), "%s %s", LANGUAGE.publishedby, gameinfo.publisher); snprintf(linebuf, sizeof(linebuf), "%s %s", LANGUAGE.publishedby, gameinfo.publisher);
publisherTxt = new GuiText(linebuf, 16, (GXColor){0,0,0, 255}); publisherTxt = new GuiText(linebuf, 16, (GXColor){0,0,0, 255});
if (publisherTxt->GetWidth()>250) newline=2; if (publisherTxt->GetWidth()>250) newline=2;
publisherTxt->SetMaxWidth(250,GuiText::WRAP); publisherTxt->SetMaxWidth(250,GuiText::WRAP);
publisherTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); publisherTxt->SetPosition(-17,12+y); y+=(20 * newline);newline=1; 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 //don't bother us txt
snprintf(linebuf, sizeof(linebuf), "Don't bother the USB Loader GX Team about errors in this file."); 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 */ /* search for game matching gameid */
while (1) while (1)
{ {
nodeid = mxmlIndexFind(nodeindex,"id", NULL); nodeid = mxmlIndexFind(nodeindex,"id", NULL);
if (nodeid != NULL) { if (nodeid != NULL) {
get_text(nodeid, element_text, sizeof(element_text)); 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, "ESRB",gameinfo.ratingvalueESRB);
ConvertRating(gameinfo.ratingvalue, gameinfo.ratingtype, "PEGI",gameinfo.ratingvaluePEGI); 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(); //PrintGameInfo();
exist=true; 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 month[10];
char day[10]; char day[10];
char genre[500]; char genre[500];
char genresplit[100][500];
char ratingtype[10]; char ratingtype[10];
char ratingvalue[10]; char ratingvalue[10];
char ratingdescriptors[100][500]; char ratingdescriptors[100][500];
@ -62,7 +63,9 @@ void FreeXMLMemory();
void title_set(char *id, char *title); 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 #ifdef __cplusplus
} }