*Cleanups to the Homebrew XML stuff

*Added HomebrewXML class
This commit is contained in:
dimok321 2009-07-20 18:53:28 +00:00
parent a02013f03f
commit 8fd2bbdb01
7 changed files with 455 additions and 515 deletions

File diff suppressed because one or more lines are too long

View File

@ -13,11 +13,10 @@
#include "libwiigui/gui.h"
#include "prompts/PromptWindows.h"
#include "homebrewboot/HomebrewFiles.h"
#include "homebrewboot/HomebrewXML.h"
#include "menu.h"
#include "filelist.h"
#include "sys.h"
#include "listfiles.h"
#include "../xml/xml.h"
/*** Extern functions ***/
extern void ResumeGui();
@ -32,12 +31,6 @@ extern u8 reset;
bool boothomebrew = false;
struct homebrewXMLinfo HB0;
struct homebrewXMLinfo HB1;
struct homebrewXMLinfo HB2;
struct homebrewXMLinfo HB3;
/****************************************************************************
* roundup Function
***************************************************************************/
@ -177,22 +170,22 @@ int MenuHomebrewBrowse()
MainButton1Txt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::DOTTED);
MainButton1Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton1Txt.SetPosition(148, -12);
GuiText MainButton1aTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
MainButton1aTxt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::DOTTED);
MainButton1aTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton1aTxt.SetPosition(148, 15);
GuiText MainButton1aoverTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
MainButton1aoverTxt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::SCROLL);
MainButton1aoverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton1aoverTxt.SetPosition(148, 15);
GuiText MainButton1DescTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
MainButton1DescTxt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::DOTTED);
MainButton1DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton1DescTxt.SetPosition(148, 15);
GuiText MainButton1DescOverTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
MainButton1DescOverTxt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::SCROLL);
MainButton1DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton1DescOverTxt.SetPosition(148, 15);
GuiButton MainButton1(MainButton1Img.GetWidth(), MainButton1Img.GetHeight());
MainButton1.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
MainButton1.SetPosition(0, 90);
MainButton1.SetImage(&MainButton1Img);
MainButton1.SetImageOver(&MainButton1ImgOver);
MainButton1.SetLabel(&MainButton1Txt);
MainButton1.SetLabel(&MainButton1aTxt,1);
MainButton1.SetLabelOver(&MainButton1aoverTxt,1);
MainButton1.SetLabel(&MainButton1DescTxt,1);
MainButton1.SetLabelOver(&MainButton1DescOverTxt,1);
MainButton1.SetSoundOver(&btnSoundOver);
MainButton1.SetSoundClick(&btnClick1);
MainButton1.SetEffectGrow();
@ -204,22 +197,22 @@ int MenuHomebrewBrowse()
MainButton2Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton2Txt.SetPosition(148, -12);
MainButton2Txt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton2aTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
MainButton2aTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton2aTxt.SetPosition(148, 15);
MainButton2aTxt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton2aoverTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
MainButton2aoverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton2aoverTxt.SetPosition(148, 15);
MainButton2aoverTxt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::SCROLL);
GuiText MainButton2DescTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
MainButton2DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton2DescTxt.SetPosition(148, 15);
MainButton2DescTxt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton2DescOverTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
MainButton2DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton2DescOverTxt.SetPosition(148, 15);
MainButton2DescOverTxt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::SCROLL);
GuiButton MainButton2(MainButton2Img.GetWidth(), MainButton2Img.GetHeight());
MainButton2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
MainButton2.SetPosition(0, 160);
MainButton2.SetImage(&MainButton2Img);
MainButton2.SetImageOver(&MainButton2ImgOver);
MainButton2.SetLabel(&MainButton2Txt);
MainButton2.SetLabel(&MainButton2aTxt,1);
MainButton2.SetLabelOver(&MainButton2aoverTxt,1);
MainButton2.SetLabel(&MainButton2DescTxt,1);
MainButton2.SetLabelOver(&MainButton2DescOverTxt,1);
MainButton2.SetSoundOver(&btnSoundOver);
MainButton2.SetSoundClick(&btnClick1);
MainButton2.SetEffectGrow();
@ -231,22 +224,22 @@ int MenuHomebrewBrowse()
MainButton3Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton3Txt.SetPosition(148, -12);
MainButton3Txt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton3aTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
MainButton3aTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton3aTxt.SetPosition(148, 15);
MainButton3aTxt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton3aoverTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
MainButton3aoverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton3aoverTxt.SetPosition(148, 15);
MainButton3aoverTxt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::SCROLL);
GuiText MainButton3DescTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
MainButton3DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton3DescTxt.SetPosition(148, 15);
MainButton3DescTxt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton3DescOverTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
MainButton3DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton3DescOverTxt.SetPosition(148, 15);
MainButton3DescOverTxt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::SCROLL);
GuiButton MainButton3(MainButton3Img.GetWidth(), MainButton3Img.GetHeight());
MainButton3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
MainButton3.SetPosition(0, 230);
MainButton3.SetImage(&MainButton3Img);
MainButton3.SetImageOver(&MainButton3ImgOver);
MainButton3.SetLabel(&MainButton3Txt);
MainButton3.SetLabel(&MainButton3aTxt,1);
MainButton3.SetLabelOver(&MainButton3aoverTxt,1);
MainButton3.SetLabel(&MainButton3DescTxt,1);
MainButton3.SetLabelOver(&MainButton3DescOverTxt,1);
MainButton3.SetSoundOver(&btnSoundOver);
MainButton3.SetSoundClick(&btnClick1);
MainButton3.SetEffectGrow();
@ -258,22 +251,22 @@ int MenuHomebrewBrowse()
MainButton4Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton4Txt.SetPosition(148, -12);
MainButton4Txt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton4aTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
MainButton4aTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton4aTxt.SetPosition(148, 15);
MainButton4aTxt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton4aoverTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
MainButton4aoverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton4aoverTxt.SetPosition(148, 15);
MainButton4aoverTxt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::SCROLL);
GuiText MainButton4DescTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
MainButton4DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton4DescTxt.SetPosition(148, 15);
MainButton4DescTxt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::DOTTED);
GuiText MainButton4DescOverTxt(MainButtonText, 18, (GXColor){0, 0, 0, 255});
MainButton4DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton4DescOverTxt.SetPosition(148, 15);
MainButton4DescOverTxt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::SCROLL);
GuiButton MainButton4(MainButton4Img.GetWidth(), MainButton4Img.GetHeight());
MainButton4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
MainButton4.SetPosition(0, 300);
MainButton4.SetImage(&MainButton4Img);
MainButton4.SetImageOver(&MainButton4ImgOver);
MainButton4.SetLabel(&MainButton4Txt);
MainButton4.SetLabel(&MainButton4aTxt,1);
MainButton4.SetLabelOver(&MainButton4aoverTxt,1);
MainButton4.SetLabel(&MainButton4DescTxt,1);
MainButton4.SetLabelOver(&MainButton4DescOverTxt,1);
MainButton4.SetSoundOver(&btnSoundOver);
MainButton4.SetSoundClick(&btnClick1);
MainButton4.SetEffectGrow();
@ -281,6 +274,10 @@ int MenuHomebrewBrowse()
GuiWindow w(screenwidth, screenheight);
/*** XML Variables ***/
HomebrewXML XMLInfo[4];
int pageToDisplay = 1;
const int pages = roundup(filecount/4.0f);
@ -366,181 +363,172 @@ int MenuHomebrewBrowse()
w.Append(&GoRightBtn);
w.Append(&GoLeftBtn);
char metapath[200];
if(pageToDisplay == pages) {
int buttonsleft = filecount-(pages-1)*4;
char * shortpath = NULL;
char temp[200];
if(buttonsleft > 0) {
if(LoadHomebrewXMLData(metapath,0)>0){
snprintf(MainButtonText, sizeof(MainButtonText), "%s", HB0.name);
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset));
if(XMLInfo[0].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[0].GetName());
MainButton1Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", HB0.shortdescription);
MainButton1aTxt.SetText(MainButtonText);
MainButton1aoverTxt.SetText(MainButtonText);
}
else{
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[0].GetShortDescription());
MainButton1DescTxt.SetText(MainButtonText);
MainButton1DescOverTxt.SetText(MainButtonText);
} else {
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset)), "%s", HomebrewFiles.GetFilepath(fileoffset));
shortpath = strrchr(temp, '/');
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset));
snprintf(HB0.name, sizeof(HB0.name), "%s", MainButtonText);
XMLInfo[0].SetName(MainButtonText);
MainButton1Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), " ");
MainButton1aTxt.SetText(MainButtonText);
MainButton1aoverTxt.SetText(MainButtonText);
MainButton1DescTxt.SetText(MainButtonText);
MainButton1DescOverTxt.SetText(MainButtonText);
}
w.Append(&MainButton1);
}
if(buttonsleft > 1) {
snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+1));
if(LoadHomebrewXMLData(metapath,1)>0){
snprintf(MainButtonText, sizeof(MainButtonText), "%s", HB1.name);
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+1));
if(XMLInfo[1].LoadHomebrewXMLData(temp) > 0){
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[1].GetName());
MainButton2Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", HB1.shortdescription);
MainButton2aTxt.SetText(MainButtonText);
MainButton2aoverTxt.SetText(MainButtonText);
}
else{
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[1].GetShortDescription());
MainButton2DescTxt.SetText(MainButtonText);
MainButton2DescOverTxt.SetText(MainButtonText);
} else {
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+1)), "%s", HomebrewFiles.GetFilepath(fileoffset+1));
shortpath = strrchr(temp, '/');
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+1));
snprintf(HB1.name, sizeof(HB1.name), "%s", MainButtonText);
XMLInfo[1].SetName(MainButtonText);
MainButton2Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), " ");
MainButton2aoverTxt.SetText(MainButtonText);
MainButton2aTxt.SetText(MainButtonText);
MainButton2DescTxt.SetText(MainButtonText);
MainButton2DescOverTxt.SetText(MainButtonText);
}
w.Append(&MainButton2);
}
if(buttonsleft > 2) {
snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+2));
if(LoadHomebrewXMLData(metapath,2)>0){
snprintf(MainButtonText, sizeof(MainButtonText), "%s", HB2.name);
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+2));
if(XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetName());
MainButton3Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", HB2.shortdescription);
MainButton3aTxt.SetText(MainButtonText);
MainButton3aoverTxt.SetText(MainButtonText);
}
else{
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetShortDescription());
MainButton3DescTxt.SetText(MainButtonText);
MainButton3DescOverTxt.SetText(MainButtonText);
} else {
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+2)), "%s", HomebrewFiles.GetFilepath(fileoffset+2));
shortpath = strrchr(temp, '/');
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+2));
snprintf(HB2.name, sizeof(HB2.name), "%s", MainButtonText);
XMLInfo[2].SetName(MainButtonText);
MainButton3Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), " ");
MainButton3aoverTxt.SetText(MainButtonText);
MainButton3aTxt.SetText(MainButtonText);
MainButton3DescTxt.SetText(MainButtonText);
MainButton3DescOverTxt.SetText(MainButtonText);
}
w.Append(&MainButton3);
}
if(buttonsleft > 3) {
snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+3));
if(LoadHomebrewXMLData(metapath,3)>0){
snprintf(MainButtonText, sizeof(MainButtonText), "%s", HB3.name);
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+3));
if(XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetName());
MainButton4Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", HB3.shortdescription);
MainButton4aTxt.SetText(MainButtonText);
MainButton4aoverTxt.SetText(MainButtonText);
}
else{
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetShortDescription());
MainButton4DescTxt.SetText(MainButtonText);
MainButton4DescOverTxt.SetText(MainButtonText);
} else {
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+3)), "%s", HomebrewFiles.GetFilepath(fileoffset+3));
shortpath = strrchr(temp, '/');
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+3));
snprintf(HB3.name, sizeof(HB3.name), "%s", MainButtonText);
XMLInfo[3].SetName(MainButtonText);
MainButton4Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), " ");
MainButton4aTxt.SetText(MainButtonText);
MainButton4aoverTxt.SetText(MainButtonText);
MainButton4DescTxt.SetText(MainButtonText);
MainButton4DescOverTxt.SetText(MainButtonText);
}
w.Append(&MainButton4);
}
} else {
char temp[200];
char *shortpath = NULL;
//btn1
snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset));
if(LoadHomebrewXMLData(metapath,0)>0){
snprintf(MainButtonText, sizeof(MainButtonText), "%s", HB0.name);
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset));
if(XMLInfo[0].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[0].GetName());
MainButton1Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", HB0.shortdescription);
MainButton1aTxt.SetText(MainButtonText);
MainButton1aoverTxt.SetText(MainButtonText);
}
else{
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[0].GetShortDescription());
MainButton1DescTxt.SetText(MainButtonText);
MainButton1DescOverTxt.SetText(MainButtonText);
} else {
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset)), "%s", HomebrewFiles.GetFilepath(fileoffset));
shortpath = strrchr(temp, '/');
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset));
snprintf(HB0.name, sizeof(HB0.name), "%s", MainButtonText);
XMLInfo[0].SetName(MainButtonText);
MainButton1Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), " ");
MainButton1aTxt.SetText(MainButtonText);
MainButton1aoverTxt.SetText(MainButtonText);
MainButton1DescTxt.SetText(MainButtonText);
MainButton1DescOverTxt.SetText(MainButtonText);
}
w.Append(&MainButton1);
//btn2
snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+1));
if(LoadHomebrewXMLData(metapath,1)>0){
snprintf(MainButtonText, sizeof(MainButtonText), "%s", HB1.name);
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+1));
if(XMLInfo[1].LoadHomebrewXMLData(temp) > 0){
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[1].GetName());
MainButton2Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", HB1.shortdescription);
MainButton2aTxt.SetText(MainButtonText);
MainButton2aoverTxt.SetText(MainButtonText);
}
else{
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[1].GetShortDescription());
MainButton2DescTxt.SetText(MainButtonText);
MainButton2DescOverTxt.SetText(MainButtonText);
} else {
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+1)), "%s", HomebrewFiles.GetFilepath(fileoffset+1));
shortpath = strrchr(temp, '/');
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+1));
snprintf(HB1.name, sizeof(HB1.name), "%s", MainButtonText);
XMLInfo[1].SetName(MainButtonText);
MainButton2Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), " ");
MainButton2aoverTxt.SetText(MainButtonText);
MainButton2aTxt.SetText(MainButtonText);
MainButton2DescTxt.SetText(MainButtonText);
MainButton2DescOverTxt.SetText(MainButtonText);
}
w.Append(&MainButton2);
//btn3
snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+2));
if(LoadHomebrewXMLData(metapath,2)>0){
snprintf(MainButtonText, sizeof(MainButtonText), "%s", HB2.name);
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+2));
if(XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetName());
MainButton3Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", HB2.shortdescription);
MainButton3aTxt.SetText(MainButtonText);
MainButton3aoverTxt.SetText(MainButtonText);
}
else{
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetShortDescription());
MainButton3DescTxt.SetText(MainButtonText);
MainButton3DescOverTxt.SetText(MainButtonText);
} else {
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+2)), "%s", HomebrewFiles.GetFilepath(fileoffset+2));
shortpath = strrchr(temp, '/');
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+2));
snprintf(HB2.name, sizeof(HB2.name), "%s", MainButtonText);
XMLInfo[2].SetName(MainButtonText);
MainButton3Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), " ");
MainButton3aoverTxt.SetText(MainButtonText);
MainButton3aTxt.SetText(MainButtonText);
MainButton3DescTxt.SetText(MainButtonText);
MainButton3DescOverTxt.SetText(MainButtonText);
}
w.Append(&MainButton3);
//btn4
snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+3));
if(LoadHomebrewXMLData(metapath,3)>0){
snprintf(MainButtonText, sizeof(MainButtonText), "%s", HB3.name);
snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+3));
if(XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetName());
MainButton4Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", HB3.shortdescription);
MainButton4aTxt.SetText(MainButtonText);
MainButton4aoverTxt.SetText(MainButtonText);
}
else{
snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetShortDescription());
MainButton4DescTxt.SetText(MainButtonText);
MainButton4DescOverTxt.SetText(MainButtonText);
} else {
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+3)), "%s", HomebrewFiles.GetFilepath(fileoffset+3));
shortpath = strrchr(temp, '/');
snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+3));
snprintf(HB3.name, sizeof(HB3.name), "%s", MainButtonText);
XMLInfo[3].SetName(MainButtonText);
MainButton4Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), " ");
MainButton4aTxt.SetText(MainButtonText);
MainButton4aoverTxt.SetText(MainButtonText);
MainButton4DescTxt.SetText(MainButtonText);
MainButton4DescOverTxt.SetText(MainButtonText);
}
w.Append(&MainButton4);
}
@ -602,7 +590,7 @@ int MenuHomebrewBrowse()
shortpath = strrchr(temp, '/');
snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset));
int choice = HBCWindowPrompt(HB0.name, HB0.coder, HB0.version, HB0.releasedate, HB0.longdescription, iconpath, filesize);
int choice = HBCWindowPrompt(XMLInfo[0].GetName(), XMLInfo[0].GetCoder(), XMLInfo[0].GetVersion(), XMLInfo[0].GetReleasedate(), XMLInfo[0].GetLongDescription(), iconpath, filesize);
if(choice == 1) {
boothomebrew = true;
menu = MENU_EXIT;
@ -630,7 +618,7 @@ int MenuHomebrewBrowse()
shortpath = strrchr(temp, '/');
snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+1));
int choice = HBCWindowPrompt(HB1.name, HB1.coder, HB1.version, HB1.releasedate, HB1.longdescription, iconpath, filesize);
int choice = HBCWindowPrompt(XMLInfo[1].GetName(), XMLInfo[1].GetCoder(), XMLInfo[1].GetVersion(), XMLInfo[1].GetReleasedate(), XMLInfo[1].GetLongDescription(), iconpath, filesize);
if(choice == 1) {
boothomebrew = true;
menu = MENU_EXIT;
@ -658,7 +646,7 @@ int MenuHomebrewBrowse()
shortpath = strrchr(temp, '/');
snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+2));
int choice = HBCWindowPrompt(HB2.name, HB2.coder, HB2.version, HB2.releasedate, HB2.longdescription, iconpath, filesize);
int choice = HBCWindowPrompt(XMLInfo[2].GetName(), XMLInfo[2].GetCoder(), XMLInfo[2].GetVersion(), XMLInfo[2].GetReleasedate(), XMLInfo[2].GetLongDescription(), iconpath, filesize);
if(choice == 1) {
boothomebrew = true;
menu = MENU_EXIT;
@ -686,7 +674,7 @@ int MenuHomebrewBrowse()
shortpath = strrchr(temp, '/');
snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+3));
int choice = HBCWindowPrompt(HB3.name, HB3.coder, HB3.version, HB3.releasedate, HB3.longdescription, iconpath, filesize);
int choice = HBCWindowPrompt(XMLInfo[3].GetName(), XMLInfo[3].GetCoder(), XMLInfo[3].GetVersion(), XMLInfo[3].GetReleasedate(), XMLInfo[3].GetLongDescription(), iconpath, filesize);
if(choice == 1) {
boothomebrew = true;
menu = MENU_EXIT;

View File

@ -0,0 +1,70 @@
/****************************************************************************
* HomebrewXML Class
* for USB Loader GX
***************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "xml/xml.h"
#include "HomebrewXML.h"
HomebrewXML::HomebrewXML()
{
strcpy(name,"");
strcpy(coder,"");
strcpy(version,"");
strcpy(releasedate,"");
strcpy(shortdescription,"");
strcpy(longdescription,"");
}
HomebrewXML::~HomebrewXML()
{
}
int HomebrewXML::LoadHomebrewXMLData(const char* filename)
{
mxml_node_t *nodedataHB = NULL;
mxml_node_t *nodetreeHB = NULL;
char tmp1[40];
/* Load XML file */
FILE *filexml;
filexml = fopen(filename, "rb");
if (!filexml) {
return -1;
}
nodetreeHB = mxmlLoadFile(NULL, filexml, MXML_NO_CALLBACK);
fclose(filexml);
if (nodetreeHB == NULL) {
return -2;
}
nodedataHB = mxmlFindElement(nodetreeHB, nodetreeHB, "app", NULL, NULL, MXML_DESCEND);
if (nodedataHB == NULL) {
return -5;
}
GetTextFromNode(nodedataHB, nodedataHB, (char*) "name", NULL, NULL, MXML_DESCEND, name,sizeof(name));
GetTextFromNode(nodedataHB, nodedataHB, (char*) "coder", NULL, NULL, MXML_DESCEND, coder,sizeof(coder));
GetTextFromNode(nodedataHB, nodedataHB, (char*) "version", NULL, NULL, MXML_DESCEND, version,sizeof(version));
GetTextFromNode(nodedataHB, nodedataHB, (char*) "release_date", NULL, NULL, MXML_DESCEND, tmp1,sizeof(tmp1));
GetTextFromNode(nodedataHB, nodedataHB, (char*) "short_description", NULL, NULL, MXML_DESCEND, shortdescription,sizeof(shortdescription));
GetTextFromNode(nodedataHB, nodedataHB, (char*) "long_description", NULL, NULL, MXML_DESCEND, longdescription,sizeof(longdescription));
int len = (strlen(tmp1)-6); //length of the date string without the 200000 at the end
if (len == 8)
snprintf(releasedate, sizeof(releasedate), "%c%c/%c%c/%c%c%c%c", tmp1[4],tmp1[5],tmp1[6],tmp1[7],tmp1[0],tmp1[1],tmp1[2],tmp1[3]);
else if (len == 6)
snprintf(releasedate, sizeof(releasedate), "%c%c/%c%c%c%c", tmp1[4],tmp1[5],tmp1[0],tmp1[1],tmp1[2],tmp1[3]);
else snprintf(releasedate, sizeof(releasedate), "%s", tmp1);
free(nodedataHB);
free(nodetreeHB);
return 1;
}

View File

@ -0,0 +1,41 @@
/****************************************************************************
* HomebrewXML Class
* for USB Loader GX
***************************************************************************/
#ifndef ___HOMEBREWXML_H_
#define ___HOMEBREWXML_H_
class HomebrewXML
{
public:
//!Constructor
//!\param path Path for the xml file
HomebrewXML();
//!Destructor
~HomebrewXML();
//!\param filename Filepath of the XML file
int LoadHomebrewXMLData(const char* filename);
//! Get name
char * GetName() { return name; }
//! Get coder
char * GetCoder() { return coder; }
//! Get version
char * GetVersion() { return version; }
//! Get releasedate
char * GetReleasedate() { return releasedate; }
//! Get shortdescription
char * GetShortDescription() { return shortdescription; }
//! Get longdescription
char * GetLongDescription() { return longdescription; }
//! Set Name
void SetName(char * path) { strncpy(name, path, sizeof(name)); }
protected:
char name[50];
char coder[50];
char version[30];
char releasedate[30];
char shortdescription[150];
char longdescription[500];
};
#endif

View File

@ -2991,7 +2991,7 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version,
GuiWindow promptWindow(472,320);
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
promptWindow.SetPosition(0, -10);
promptWindow.SetPosition(0, 6);
GuiTrigger trigA;
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
@ -3060,7 +3060,7 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version,
}
GuiImage dialogBoxImg(&dialogBox);
dialogBoxImg.SetSkew(0,-50,0,-50,0,50,0,50);
dialogBoxImg.SetSkew(0,-80,0,-80,0,50,0,50);
GuiImage whiteBoxImg(&whiteBox);
whiteBoxImg.SetPosition(0,110);
@ -3113,21 +3113,21 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version,
if(filesize<=1024.0)
{
sizeAdjusted = filesize;
snprintf(temp2, sizeof(temp2), "%f",sizeAdjusted);
snprintf(temp2, sizeof(temp2), "%.2f",sizeAdjusted);
snprintf(filesizeCH, sizeof(filesizeCH), "%s B",temp2);
}
if(filesize>1024.0)
{
sizeAdjusted = filesize/1024.0;
snprintf(temp2, sizeof(temp2), "%f",sizeAdjusted);
snprintf(temp2, sizeof(temp2), "%.2f",sizeAdjusted);
snprintf(filesizeCH, sizeof(filesizeCH), "%s KB",temp2);
}
if(filesize>1048576.0)
{
sizeAdjusted = filesize/1048576.0;
snprintf(temp2, sizeof(temp2), "%f",sizeAdjusted);
snprintf(temp2, sizeof(temp2), "%.2f",sizeAdjusted);
snprintf(filesizeCH, sizeof(filesizeCH), "%s MB",temp2);
}

View File

@ -5,7 +5,6 @@ Load game information from XML - Lustar
*/
#include <malloc.h>
#include <mxml.h>
#include "unzip/unzip.h"
#include "settings/cfg.h"
#include "xml/xml.h"
@ -24,14 +23,6 @@ extern struct SSettings Settings; // for loader GX
struct gameXMLinfo gameinfo;
struct gameXMLinfo gameinfo_reset;
extern struct homebrewXMLinfo HB0;
extern struct homebrewXMLinfo HB1;
extern struct homebrewXMLinfo HB2;
extern struct homebrewXMLinfo HB3;
static char langlist[11][22] =
{{"Console Default"},
{"Japanese"},
@ -758,145 +749,4 @@ static char * get_text(mxml_node_t *node, char *buffer, int buflen) /* O - Text
return (buffer);
}
int LoadHomebrewXMLData(char* filename,int i)
{
int ret;
if (i>3){
ret= -20;
goto noXML;}
mxml_node_t *nodedataHB=NULL;
mxml_node_t *nodetreeHB=NULL;
char tmp1[40];
/* Load XML file */
FILE *filexml;
filexml = fopen(filename, "rb");
if (!filexml)
{ret= -1;
goto noXML;}
nodetreeHB = mxmlLoadFile(NULL, filexml, MXML_NO_CALLBACK);
fclose(filexml);
if (nodetreeHB == NULL)
{ret= -2;
goto noXML;}
nodedataHB = mxmlFindElement(nodetreeHB, nodetreeHB, "app", NULL, NULL, MXML_DESCEND);
if (nodedataHB == NULL) {
ret= -5;
goto noXML;
}
//int len = (strlen(entered)-1);
//if(entered[len] !='/')
/* text from elements */
if (i==0){
GetTextFromNode(nodedataHB, nodedataHB, "name", NULL, NULL, MXML_DESCEND, HB0.name,sizeof(HB0.name));
GetTextFromNode(nodedataHB, nodedataHB, "coder", NULL, NULL, MXML_DESCEND, HB0.coder,sizeof(HB0.coder));
GetTextFromNode(nodedataHB, nodedataHB, "version", NULL, NULL, MXML_DESCEND, HB0.version,sizeof(HB0.version));
GetTextFromNode(nodedataHB, nodedataHB, "release_date", NULL, NULL, MXML_DESCEND, tmp1,sizeof(tmp1));
GetTextFromNode(nodedataHB, nodedataHB, "short_description", NULL, NULL, MXML_DESCEND, HB0.shortdescription,sizeof(HB0.shortdescription));
GetTextFromNode(nodedataHB, nodedataHB, "long_description", NULL, NULL, MXML_DESCEND, HB0.longdescription,sizeof(HB0.longdescription));
int len = (strlen(tmp1)-6);//length of the date string without the 200000 at the end
if (len==8)
snprintf(HB0.releasedate, sizeof(HB0.releasedate), "%c%c/%c%c/%c%c%c%c", tmp1[4],tmp1[5],tmp1[6],tmp1[7],tmp1[0],tmp1[1],tmp1[2],tmp1[3]);
else if (len==6)
snprintf(HB0.releasedate, sizeof(HB0.releasedate), "%c%c/%c%c%c%c", tmp1[4],tmp1[5],tmp1[0],tmp1[1],tmp1[2],tmp1[3]);
else snprintf(HB0.releasedate, sizeof(HB0.releasedate), "%s", tmp1);
}
else if (i==1){
GetTextFromNode(nodedataHB, nodedataHB, "name", NULL, NULL, MXML_DESCEND, HB1.name,sizeof(HB1.name));
GetTextFromNode(nodedataHB, nodedataHB, "coder", NULL, NULL, MXML_DESCEND, HB1.coder,sizeof(HB1.coder));
GetTextFromNode(nodedataHB, nodedataHB, "version", NULL, NULL, MXML_DESCEND, HB1.version,sizeof(HB1.version));
GetTextFromNode(nodedataHB, nodedataHB, "release_date", NULL, NULL, MXML_DESCEND, tmp1,sizeof(tmp1));
GetTextFromNode(nodedataHB, nodedataHB, "short_description", NULL, NULL, MXML_DESCEND, HB1.shortdescription,sizeof(HB1.shortdescription));
GetTextFromNode(nodedataHB, nodedataHB, "long_description", NULL, NULL, MXML_DESCEND, HB1.longdescription,sizeof(HB1.longdescription));
int len = (strlen(tmp1)-6);//length of the date string without the 200000 at the end
if (len==8)
snprintf(HB1.releasedate, sizeof(HB1.releasedate), "%c%c/%c%c/%c%c%c%c", tmp1[4],tmp1[5],tmp1[6],tmp1[7],tmp1[0],tmp1[1],tmp1[2],tmp1[3]);
else if (len==6)
snprintf(HB1.releasedate, sizeof(HB1.releasedate), "%c%c/%c%c%c%c", tmp1[4],tmp1[5],tmp1[0],tmp1[1],tmp1[2],tmp1[3]);
else snprintf(HB1.releasedate, sizeof(HB1.releasedate), "%s", tmp1);
}
else if (i==2){
GetTextFromNode(nodedataHB, nodedataHB, "name", NULL, NULL, MXML_DESCEND, HB2.name,sizeof(HB2.name));
GetTextFromNode(nodedataHB, nodedataHB, "coder", NULL, NULL, MXML_DESCEND, HB2.coder,sizeof(HB2.coder));
GetTextFromNode(nodedataHB, nodedataHB, "version", NULL, NULL, MXML_DESCEND, HB2.version,sizeof(HB2.version));
GetTextFromNode(nodedataHB, nodedataHB, "release_date", NULL, NULL, MXML_DESCEND, tmp1,sizeof(tmp1));
GetTextFromNode(nodedataHB, nodedataHB, "short_description", NULL, NULL, MXML_DESCEND, HB2.shortdescription,sizeof(HB2.shortdescription));
GetTextFromNode(nodedataHB, nodedataHB, "long_description", NULL, NULL, MXML_DESCEND, HB2.longdescription,sizeof(HB2.longdescription));
int len = (strlen(tmp1)-6);//length of the date string without the 200000 at the end
if (len==8)
snprintf(HB2.releasedate, sizeof(HB2.releasedate), "%c%c/%c%c/%c%c%c%c", tmp1[4],tmp1[5],tmp1[6],tmp1[7],tmp1[0],tmp1[1],tmp1[2],tmp1[3]);
else if (len==6)
snprintf(HB2.releasedate, sizeof(HB2.releasedate), "%c%c/%c%c%c%c", tmp1[4],tmp1[5],tmp1[0],tmp1[1],tmp1[2],tmp1[3]);
else snprintf(HB2.releasedate, sizeof(HB2.releasedate), "%s", tmp1);
}
else if (i==3){
GetTextFromNode(nodedataHB, nodedataHB, "name", NULL, NULL, MXML_DESCEND, HB3.name,sizeof(HB3.name));
GetTextFromNode(nodedataHB, nodedataHB, "coder", NULL, NULL, MXML_DESCEND, HB3.coder,sizeof(HB3.coder));
GetTextFromNode(nodedataHB, nodedataHB, "version", NULL, NULL, MXML_DESCEND, HB3.version,sizeof(HB3.version));
GetTextFromNode(nodedataHB, nodedataHB, "release_date", NULL, NULL, MXML_DESCEND, tmp1,sizeof(tmp1));
GetTextFromNode(nodedataHB, nodedataHB, "short_description", NULL, NULL, MXML_DESCEND, HB3.shortdescription,sizeof(HB3.shortdescription));
GetTextFromNode(nodedataHB, nodedataHB, "long_description", NULL, NULL, MXML_DESCEND, HB3.longdescription,sizeof(HB3.longdescription));
int len = (strlen(tmp1)-6);//length of the date string without the 200000 at the end
if (len==8)
snprintf(HB3.releasedate, sizeof(HB3.releasedate), "%c%c/%c%c/%c%c%c%c", tmp1[4],tmp1[5],tmp1[6],tmp1[7],tmp1[0],tmp1[1],tmp1[2],tmp1[3]);
else if (len==6)
snprintf(HB3.releasedate, sizeof(HB3.releasedate), "%c%c/%c%c%c%c", tmp1[4],tmp1[5],tmp1[0],tmp1[1],tmp1[2],tmp1[3]);
else snprintf(HB3.releasedate, sizeof(HB3.releasedate), "%s", tmp1);
}
ret =1;
free(nodedataHB);
free(nodetreeHB);
goto end;
noXML:
if (i==0){
strcpy(HB0.name,"");
strcpy(HB0.coder,"");
strcpy(HB0.version,"");
strcpy(HB0.releasedate,"");
strcpy(HB0.shortdescription,"");
strcpy(HB0.longdescription,"");
}
else if (i==1){
strcpy(HB1.name,"");
strcpy(HB1.coder,"");
strcpy(HB1.version,"");
strcpy(HB1.releasedate,"");
strcpy(HB1.shortdescription,"");
strcpy(HB1.longdescription,"");
}
else if (i==2){
strcpy(HB2.name,"");
strcpy(HB2.coder,"");
strcpy(HB2.version,"");
strcpy(HB2.releasedate,"");
strcpy(HB2.shortdescription,"");
strcpy(HB2.longdescription,"");
}
else if (i==3){
strcpy(HB3.name,"");
strcpy(HB3.coder,"");
strcpy(HB3.version,"");
strcpy(HB3.releasedate,"");
strcpy(HB3.shortdescription,"");
strcpy(HB3.longdescription,"");
}
end:
return ret;
}

View File

@ -2,6 +2,8 @@
#ifndef _XML_H_
#define _XML_H_
#include <mxml.h>
#ifdef __cplusplus
extern "C"
@ -13,7 +15,6 @@ bool OpenXMLDatabase(char* xmlfilepath, char* argdblang, bool argJPtoEN, bool op
void CloseXMLDatabase();
bool LoadGameInfoFromXML(char* gameid, char* langcode);
#define XML_ELEMMAX 15
struct gameXMLinfo
@ -56,25 +57,15 @@ struct gameXMLinfo
char iso_sha1[41];
} ;
struct homebrewXMLinfo
{
char name[50];
char coder[50];
char version[30];
char releasedate[30];
char shortdescription[150];
char longdescription[500];
} ;
bool OpenXMLFile(char* filename);
int LoadHomebrewXMLData(char* filename,int i);
void LoadTitlesFromXML(char *langcode, bool forcejptoen);
void GetPublisherFromGameid(char *idtxt, char *dest, int destsize);
char *ConvertLangTextToCode(char *langtext);
void ConvertRating(char *ratingvalue, char *fromrating, char *torating, char *destvalue, int destsize);
void PrintGameInfo(bool showfullinfo);
char *MemInfo();
void GetTextFromNode(mxml_node_t *currentnode, mxml_node_t *topnode, char *nodename,
char *attributename, char *value, int descend, char *dest, int destsize);
void title_set(char *id, char *title);
char* trimcopy(char *dest, char *src, int size);