mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-22 03:09:15 +01:00
*Cleanups to the Homebrew XML stuff
*Added HomebrewXML class
This commit is contained in:
parent
a02013f03f
commit
8fd2bbdb01
File diff suppressed because one or more lines are too long
@ -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);
|
||||
|
||||
@ -365,182 +362,173 @@ int MenuHomebrewBrowse()
|
||||
w.Append(&homo);
|
||||
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);
|
||||
MainButton1Txt.SetText(MainButtonText);
|
||||
snprintf(MainButtonText, sizeof(MainButtonText), "%s", HB0.shortdescription);
|
||||
MainButton1aTxt.SetText(MainButtonText);
|
||||
MainButton1aoverTxt.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);
|
||||
MainButton1Txt.SetText(MainButtonText);
|
||||
snprintf(MainButtonText, sizeof(MainButtonText), " ");
|
||||
MainButton1aTxt.SetText(MainButtonText);
|
||||
MainButton1aoverTxt.SetText(MainButtonText);
|
||||
}
|
||||
|
||||
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", 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));
|
||||
XMLInfo[0].SetName(MainButtonText);
|
||||
MainButton1Txt.SetText(MainButtonText);
|
||||
snprintf(MainButtonText, sizeof(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);
|
||||
MainButton2Txt.SetText(MainButtonText);
|
||||
snprintf(MainButtonText, sizeof(MainButtonText), "%s", HB1.shortdescription);
|
||||
MainButton2aTxt.SetText(MainButtonText);
|
||||
MainButton2aoverTxt.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);
|
||||
MainButton2Txt.SetText(MainButtonText);
|
||||
snprintf(MainButtonText, sizeof(MainButtonText), " ");
|
||||
MainButton2aoverTxt.SetText(MainButtonText);
|
||||
MainButton2aTxt.SetText(MainButtonText);
|
||||
}
|
||||
|
||||
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", 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));
|
||||
XMLInfo[1].SetName(MainButtonText);
|
||||
MainButton2Txt.SetText(MainButtonText);
|
||||
snprintf(MainButtonText, sizeof(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);
|
||||
MainButton3Txt.SetText(MainButtonText);
|
||||
snprintf(MainButtonText, sizeof(MainButtonText), "%s", HB2.shortdescription);
|
||||
MainButton3aTxt.SetText(MainButtonText);
|
||||
MainButton3aoverTxt.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);
|
||||
MainButton3Txt.SetText(MainButtonText);
|
||||
snprintf(MainButtonText, sizeof(MainButtonText), " ");
|
||||
MainButton3aoverTxt.SetText(MainButtonText);
|
||||
MainButton3aTxt.SetText(MainButtonText);
|
||||
}
|
||||
|
||||
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", 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));
|
||||
XMLInfo[2].SetName(MainButtonText);
|
||||
MainButton3Txt.SetText(MainButtonText);
|
||||
snprintf(MainButtonText, sizeof(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);
|
||||
MainButton4Txt.SetText(MainButtonText);
|
||||
snprintf(MainButtonText, sizeof(MainButtonText), "%s", HB3.shortdescription);
|
||||
MainButton4aTxt.SetText(MainButtonText);
|
||||
MainButton4aoverTxt.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);
|
||||
MainButton4Txt.SetText(MainButtonText);
|
||||
snprintf(MainButtonText, sizeof(MainButtonText), " ");
|
||||
MainButton4aTxt.SetText(MainButtonText);
|
||||
MainButton4aoverTxt.SetText(MainButtonText);
|
||||
}
|
||||
|
||||
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", 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));
|
||||
XMLInfo[3].SetName(MainButtonText);
|
||||
MainButton4Txt.SetText(MainButtonText);
|
||||
snprintf(MainButtonText, sizeof(MainButtonText), " ");
|
||||
MainButton4DescTxt.SetText(MainButtonText);
|
||||
MainButton4DescOverTxt.SetText(MainButtonText);
|
||||
}
|
||||
|
||||
w.Append(&MainButton4);
|
||||
}
|
||||
|
||||
@ -585,24 +573,24 @@ int MenuHomebrewBrowse()
|
||||
|
||||
if(MainButton1.GetState() == STATE_CLICKED) {
|
||||
char temp[200];
|
||||
char iconpath[200];
|
||||
char metapath[200];
|
||||
char * shortpath = NULL;
|
||||
|
||||
char iconpath[200];
|
||||
char metapath[200];
|
||||
char * shortpath = NULL;
|
||||
|
||||
//write iconpath
|
||||
snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset));
|
||||
|
||||
|
||||
//write iconpath
|
||||
snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset));
|
||||
|
||||
//get filesize
|
||||
u64 filesize = HomebrewFiles.GetFilesize(fileoffset);
|
||||
//write short filename
|
||||
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset)), "%s", HomebrewFiles.GetFilepath(fileoffset));
|
||||
snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset));
|
||||
|
||||
//get filesize
|
||||
u64 filesize = HomebrewFiles.GetFilesize(fileoffset);
|
||||
//write short filename
|
||||
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset)), "%s", HomebrewFiles.GetFilepath(fileoffset));
|
||||
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;
|
||||
@ -613,24 +601,24 @@ int MenuHomebrewBrowse()
|
||||
}
|
||||
else if(MainButton2.GetState() == STATE_CLICKED) {
|
||||
char temp[200];
|
||||
char iconpath[200];
|
||||
char metapath[200];
|
||||
char * shortpath = NULL;
|
||||
|
||||
char iconpath[200];
|
||||
char metapath[200];
|
||||
char * shortpath = NULL;
|
||||
|
||||
//write iconpath
|
||||
snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+1));
|
||||
|
||||
|
||||
//write iconpath
|
||||
snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset+1));
|
||||
|
||||
|
||||
//get filesize
|
||||
u64 filesize = HomebrewFiles.GetFilesize(fileoffset+1);
|
||||
u64 filesize = HomebrewFiles.GetFilesize(fileoffset+1);
|
||||
//write short filename
|
||||
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+1)), "%s", HomebrewFiles.GetFilepath(fileoffset+1));
|
||||
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+1)), "%s", HomebrewFiles.GetFilepath(fileoffset+1));
|
||||
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;
|
||||
@ -640,25 +628,25 @@ int MenuHomebrewBrowse()
|
||||
MainButton2.ResetState();
|
||||
}
|
||||
else if(MainButton3.GetState() == STATE_CLICKED) {
|
||||
char temp[200];
|
||||
char iconpath[200];
|
||||
char metapath[200];
|
||||
char * shortpath = NULL;
|
||||
|
||||
char temp[200];
|
||||
char iconpath[200];
|
||||
char metapath[200];
|
||||
char * shortpath = NULL;
|
||||
|
||||
//write iconpath
|
||||
snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+2));
|
||||
|
||||
|
||||
//write iconpath
|
||||
snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset+2));
|
||||
|
||||
|
||||
//get filesize
|
||||
u64 filesize = HomebrewFiles.GetFilesize(fileoffset+2);
|
||||
u64 filesize = HomebrewFiles.GetFilesize(fileoffset+2);
|
||||
//write short filename
|
||||
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+2)), "%s", HomebrewFiles.GetFilepath(fileoffset+2));
|
||||
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+2)), "%s", HomebrewFiles.GetFilepath(fileoffset+2));
|
||||
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;
|
||||
@ -668,25 +656,25 @@ int MenuHomebrewBrowse()
|
||||
MainButton3.ResetState();
|
||||
}
|
||||
else if(MainButton4.GetState() == STATE_CLICKED) {
|
||||
char temp[200];
|
||||
char iconpath[200];
|
||||
char metapath[200];
|
||||
char * shortpath = NULL;
|
||||
|
||||
char temp[200];
|
||||
char iconpath[200];
|
||||
char metapath[200];
|
||||
char * shortpath = NULL;
|
||||
|
||||
//write iconpath
|
||||
snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+3));
|
||||
|
||||
|
||||
//write iconpath
|
||||
snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset+3));
|
||||
|
||||
|
||||
//get filesize
|
||||
u64 filesize = HomebrewFiles.GetFilesize(fileoffset+3);
|
||||
u64 filesize = HomebrewFiles.GetFilesize(fileoffset+3);
|
||||
//write short filename
|
||||
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+3)), "%s", HomebrewFiles.GetFilepath(fileoffset+3));
|
||||
snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+3)), "%s", HomebrewFiles.GetFilepath(fileoffset+3));
|
||||
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;
|
||||
|
70
source/homebrewboot/HomebrewXML.cpp
Normal file
70
source/homebrewboot/HomebrewXML.cpp
Normal 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;
|
||||
}
|
41
source/homebrewboot/HomebrewXML.h
Normal file
41
source/homebrewboot/HomebrewXML.h
Normal 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
|
@ -2337,7 +2337,7 @@ int ProgressUpdateWindow()
|
||||
// get Wii's language setting
|
||||
char sysLanguage[3];
|
||||
GetLanguageToLangCode(sysLanguage);
|
||||
|
||||
|
||||
//make the URL to get XML based on our games
|
||||
char XMLurl[2040];
|
||||
char filename[10];
|
||||
@ -2597,7 +2597,7 @@ int ProgressUpdateWindow()
|
||||
// get Wii's language setting
|
||||
char sysLanguage[3];
|
||||
GetLanguageToLangCode(sysLanguage);
|
||||
|
||||
|
||||
//make the URL to get XML based on our games
|
||||
char XMLurl[2040];
|
||||
char filename[10];
|
||||
@ -2801,7 +2801,7 @@ int CodeDownload(const char *id)
|
||||
if (Settings.wsprompt == yes){
|
||||
dialogBoxImg.SetWidescreen(CFG.widescreen);}
|
||||
|
||||
|
||||
|
||||
|
||||
char title[50];
|
||||
sprintf(title, "%s", tr("Code Download"));
|
||||
@ -2869,13 +2869,13 @@ int CodeDownload(const char *id)
|
||||
}
|
||||
|
||||
if(IsNetworkInit() && ret >= 0) {
|
||||
|
||||
|
||||
char txtpath[150];
|
||||
snprintf(txtpath, sizeof(txtpath), "%s%s.txt", Settings.TxtCheatcodespath,id);
|
||||
|
||||
|
||||
char codeurl[150];
|
||||
snprintf(codeurl, sizeof(codeurl), "http://usbgecko.com/codes/codes/R/%s.txt",id);
|
||||
|
||||
|
||||
struct block file = downloadfile(codeurl);
|
||||
|
||||
if (file.size == 333)
|
||||
@ -2895,17 +2895,17 @@ int CodeDownload(const char *id)
|
||||
free(file.data);
|
||||
ret = 1;
|
||||
strcat(txtpath, " has been Saved. The text has not been verified. Some of the code may not work right with each other. If you experience trouble, open the text in a real text editor for more information.");
|
||||
|
||||
|
||||
WindowPrompt(0,txtpath,"Ok");
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
strcat(codeurl, " could not be downloaded.");
|
||||
|
||||
|
||||
WindowPrompt(tr("Error"),codeurl,"Ok");
|
||||
ret =-1;
|
||||
}
|
||||
|
||||
|
||||
CloseConnection();
|
||||
}
|
||||
exit:
|
||||
@ -2981,17 +2981,17 @@ void GetLanguageToLangCode(char *langcode) {
|
||||
<short_description>
|
||||
<long_description>
|
||||
SD:/APPS/FTPII/ICON.PNG*/
|
||||
|
||||
|
||||
int
|
||||
HBCWindowPrompt(const char *name, const char *coder, const char *version,
|
||||
const char *release_date, const char *long_description, const char *iconPath, u64 filesize)
|
||||
{
|
||||
int choice = -1;
|
||||
|
||||
|
||||
|
||||
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);
|
||||
@ -3001,7 +3001,7 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version,
|
||||
trigU.SetButtonOnlyTrigger(-1, WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP, PAD_BUTTON_UP);
|
||||
GuiTrigger trigD;
|
||||
trigD.SetButtonOnlyTrigger(-1, WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN, PAD_BUTTON_DOWN);
|
||||
|
||||
|
||||
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume);
|
||||
GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume);
|
||||
char imgPath[50];
|
||||
@ -3011,24 +3011,24 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version,
|
||||
GuiImageData dialogBox(imgPath, dialogue_box_png);
|
||||
snprintf(imgPath, sizeof(imgPath), "%sbg_options.png", CFG.theme_path);
|
||||
GuiImageData whiteBox(imgPath, bg_options_png);
|
||||
|
||||
|
||||
snprintf(imgPath, sizeof(imgPath), "%sscrollbar.png", CFG.theme_path);
|
||||
GuiImageData scrollbar(imgPath, scrollbar_png);
|
||||
GuiImage scrollbarImg(&scrollbar);
|
||||
scrollbarImg.SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
|
||||
scrollbarImg.SetPosition(-40, 114);
|
||||
scrollbarImg.SetSkew(0,0,0,0,0,-120,0,-120);
|
||||
|
||||
|
||||
snprintf(imgPath, sizeof(imgPath), "%sscrollbar_arrowdown.png", CFG.theme_path);
|
||||
GuiImageData arrowDown(imgPath, scrollbar_arrowdown_png);
|
||||
GuiImage arrowDownImg(&arrowDown);
|
||||
arrowDownImg.SetScale(.8);
|
||||
|
||||
|
||||
snprintf(imgPath, sizeof(imgPath), "%sscrollbar_arrowup.png", CFG.theme_path);
|
||||
GuiImageData arrowUp(imgPath, scrollbar_arrowup_png);
|
||||
GuiImage arrowUpImg (&arrowUp);
|
||||
arrowUpImg.SetScale(.8);
|
||||
|
||||
|
||||
GuiButton arrowUpBtn(arrowUpImg.GetWidth(), arrowUpImg.GetHeight());
|
||||
arrowUpBtn.SetImage(&arrowUpImg);
|
||||
arrowUpBtn.SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
|
||||
@ -3050,7 +3050,7 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version,
|
||||
GuiImageData *iconData =NULL;
|
||||
GuiImage *iconImg =NULL;
|
||||
snprintf(imgPath, sizeof(imgPath), "%s", iconPath);
|
||||
|
||||
|
||||
bool iconExist = checkfile(imgPath);
|
||||
if (iconExist){
|
||||
iconData = new GuiImageData (iconPath, dialogue_box_png);
|
||||
@ -3060,8 +3060,8 @@ 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);
|
||||
whiteBoxImg.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
||||
@ -3069,43 +3069,43 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version,
|
||||
/*if (Settings.wsprompt == yes){
|
||||
dialogBoxImg.SetWidescreen(CFG.widescreen);
|
||||
}*/
|
||||
|
||||
|
||||
char tmp[510];
|
||||
|
||||
|
||||
GuiText nameTxt(name,30 , (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||
nameTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
||||
nameTxt.SetPosition(0,-15);
|
||||
nameTxt.SetMaxWidth(430, GuiText::SCROLL);
|
||||
|
||||
|
||||
|
||||
|
||||
if (strcmp(coder,""))
|
||||
snprintf(tmp, sizeof(tmp), "Coded by: %s",coder);
|
||||
GuiText coderTxt(tmp, 16, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||
coderTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
||||
coderTxt.SetPosition(180,30);
|
||||
coderTxt.SetMaxWidth(280);
|
||||
|
||||
|
||||
if (strcmp(version,""))
|
||||
snprintf(tmp, sizeof(tmp), "Version: %s",version);
|
||||
GuiText versionTxt(tmp,16 , (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||
versionTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
||||
versionTxt.SetPosition(40,65);
|
||||
versionTxt.SetMaxWidth(430);
|
||||
|
||||
|
||||
//if (release_date)
|
||||
//snprintf(tmp, sizeof(tmp), "Released: %s",release_date);
|
||||
GuiText release_dateTxt(release_date,16 , (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||
release_dateTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
||||
release_dateTxt.SetPosition(40,85);
|
||||
release_dateTxt.SetMaxWidth(430);
|
||||
|
||||
|
||||
int pagesize = 6;
|
||||
GuiText long_descriptionTxt(long_description, 20, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||
long_descriptionTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
||||
long_descriptionTxt.SetPosition(46,117);
|
||||
long_descriptionTxt.SetMaxWidth(360);
|
||||
long_descriptionTxt.SetNumLines(pagesize);
|
||||
|
||||
|
||||
//convert filesize from u64 to char and put unit of measurement after it
|
||||
char temp2[7];
|
||||
char filesizeCH[15];
|
||||
@ -3113,28 +3113,28 @@ 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);
|
||||
|
||||
|
||||
}
|
||||
GuiText filesizeTxt(filesizeCH, 16, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||
filesizeTxt.SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
|
||||
filesizeTxt.SetPosition(-40,12);
|
||||
|
||||
|
||||
GuiText btn1Txt(tr("Load"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||
GuiImage btn1Img(&btnOutline);
|
||||
if (Settings.wsprompt == yes){
|
||||
@ -3156,18 +3156,18 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version,
|
||||
btn2.SetLabel(&btn2Txt);
|
||||
btn2.SetTrigger(&trigB);
|
||||
|
||||
|
||||
|
||||
btn1.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
|
||||
btn1.SetPosition(40, 2);
|
||||
btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
|
||||
btn2.SetPosition(-40, 2);
|
||||
|
||||
|
||||
promptWindow.Append(&dialogBoxImg);
|
||||
if (strcmp(long_description,""))promptWindow.Append(&whiteBoxImg);
|
||||
if (strcmp(long_description,""))promptWindow.Append(&scrollbarImg);
|
||||
if (strcmp(long_description,""))promptWindow.Append(&arrowDownBtn);
|
||||
if (strcmp(long_description,""))promptWindow.Append(&arrowUpBtn);
|
||||
|
||||
|
||||
if (strcmp(name,""))promptWindow.Append(&nameTxt);
|
||||
if (strcmp(version,""))promptWindow.Append(&versionTxt);
|
||||
if (strcmp(coder,""))promptWindow.Append(&coderTxt);
|
||||
@ -3210,13 +3210,13 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version,
|
||||
if (!((ButtonsHold() & WPAD_BUTTON_UP)||(ButtonsHold() & PAD_BUTTON_UP)))
|
||||
arrowUpBtn.ResetState();
|
||||
}
|
||||
else if ((arrowDownBtn.GetState()==STATE_CLICKED||arrowDownBtn.GetState()==STATE_HELD)
|
||||
else if ((arrowDownBtn.GetState()==STATE_CLICKED||arrowDownBtn.GetState()==STATE_HELD)
|
||||
&&long_descriptionTxt.GetTotalLines()>pagesize
|
||||
&&long_descriptionTxt.GetFirstLine()-1<long_descriptionTxt.GetTotalLines()-pagesize)
|
||||
{
|
||||
{
|
||||
int l=0;
|
||||
l=long_descriptionTxt.GetFirstLine()+1;
|
||||
|
||||
|
||||
long_descriptionTxt.SetFirstLine(l);
|
||||
usleep(60000);
|
||||
if (!((ButtonsHold() & WPAD_BUTTON_DOWN)||(ButtonsHold() & PAD_BUTTON_DOWN)))
|
||||
|
244
source/xml/xml.c
244
source/xml/xml.c
@ -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"},
|
||||
@ -89,7 +80,7 @@ bool OpenXMLDatabase(char* xmlfilepath, char* argdblang, bool argJPtoEN, bool op
|
||||
CloseXMLDatabase();
|
||||
return false;
|
||||
}
|
||||
if (loadtitles) LoadTitlesFromXML(argdblang, argJPtoEN);
|
||||
if (loadtitles) LoadTitlesFromXML(argdblang, argJPtoEN);
|
||||
if (!keepopen) CloseXMLDatabase();
|
||||
}
|
||||
return true;
|
||||
@ -98,15 +89,15 @@ bool OpenXMLDatabase(char* xmlfilepath, char* argdblang, bool argJPtoEN, bool op
|
||||
void CloseXMLDatabase()
|
||||
{
|
||||
/* free memory */
|
||||
if (xml_loaded) {
|
||||
if (xml_loaded) {
|
||||
mxmlDelete(nodedata);
|
||||
mxmlDelete(nodetree);
|
||||
xml_loaded = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GetTextFromNode(mxml_node_t *currentnode, mxml_node_t *topnode, char *nodename,
|
||||
|
||||
void GetTextFromNode(mxml_node_t *currentnode, mxml_node_t *topnode, char *nodename,
|
||||
char *attributename, char *value, int descend, char *dest, int destsize)
|
||||
{
|
||||
*element_text = 0;
|
||||
@ -121,16 +112,16 @@ void GetTextFromNode(mxml_node_t *currentnode, mxml_node_t *topnode, char *noden
|
||||
} else {
|
||||
strcpy(dest,"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool OpenXMLFile(char *filename)
|
||||
{
|
||||
//if (xmldebug) dbg_time1();
|
||||
|
||||
if (xml_loaded)
|
||||
|
||||
if (xml_loaded)
|
||||
return false;
|
||||
|
||||
|
||||
gameinfo = gameinfo_reset;
|
||||
nodedata=NULL;
|
||||
nodetree=NULL;
|
||||
@ -145,7 +136,7 @@ bool OpenXMLFile(char *filename)
|
||||
filexml = fopen(filename, "rb");
|
||||
if (!filexml)
|
||||
return false;
|
||||
|
||||
|
||||
nodetree = mxmlLoadFile(NULL, filexml, MXML_NO_CALLBACK);
|
||||
fclose(filexml);
|
||||
|
||||
@ -155,9 +146,9 @@ bool OpenXMLFile(char *filename)
|
||||
if (unzfile == NULL)
|
||||
return false;
|
||||
unzOpenCurrentFile(unzfile);
|
||||
|
||||
|
||||
unz_file_info zipfileinfo;
|
||||
unzGetCurrentFileInfo(unzfile, &zipfileinfo, NULL, 0, NULL, 0, NULL, 0);
|
||||
unzGetCurrentFileInfo(unzfile, &zipfileinfo, NULL, 0, NULL, 0, NULL, 0);
|
||||
int zipfilebuffersize = zipfileinfo.uncompressed_size;
|
||||
char * zipfilebuffer = malloc(zipfilebuffersize);
|
||||
memset(zipfilebuffer, 0, zipfilebuffersize);
|
||||
@ -166,18 +157,18 @@ bool OpenXMLFile(char *filename)
|
||||
unzClose(unzfile);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
unzReadCurrentFile(unzfile, zipfilebuffer, zipfilebuffersize);
|
||||
unzCloseCurrentFile(unzfile);
|
||||
unzClose(unzfile);
|
||||
|
||||
|
||||
nodetree = mxmlLoadString(NULL, zipfilebuffer, MXML_NO_CALLBACK);
|
||||
free(zipfilebuffer);
|
||||
}
|
||||
|
||||
if (nodetree == NULL)
|
||||
return false;
|
||||
|
||||
|
||||
nodedata = mxmlFindElement(nodetree, nodetree, "datafile", NULL, NULL, MXML_DESCEND);
|
||||
if (nodedata == NULL) {
|
||||
return false;
|
||||
@ -204,7 +195,7 @@ char *GetLangSettingFromGame(char *gameid)
|
||||
char *langtxt = langlist[langcode];
|
||||
return langtxt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* convert language text into ISO 639 two-letter language code */
|
||||
char *ConvertLangTextToCode(char *languagetxt)
|
||||
@ -243,7 +234,7 @@ void ConvertRating(char *ratingvalue, char *fromrating, char *torating, char *de
|
||||
desttype = ConvertRatingToIndex(torating);
|
||||
if (type == -1 || desttype == -1)
|
||||
return;
|
||||
|
||||
|
||||
/* rating conversion table */
|
||||
/* the list is ordered to pick the most likely value first: */
|
||||
/* EC and AO are less likely to be used so they are moved down to only be picked up when converting ESRB to PEGI or CERO */
|
||||
@ -263,7 +254,7 @@ void ConvertRating(char *ratingvalue, char *fromrating, char *torating, char *de
|
||||
{{"C"},{"T"},{"15"}},
|
||||
{{"Z"},{"AO"},{"18"}},
|
||||
};
|
||||
|
||||
|
||||
int i;
|
||||
for (i=0;i<=11;i++)
|
||||
{
|
||||
@ -281,34 +272,34 @@ void LoadTitlesFromXML(char *langtxt, bool forcejptoen)
|
||||
{
|
||||
if (nodedata == NULL)
|
||||
return;
|
||||
|
||||
|
||||
bool forcelang = false;
|
||||
if (strcmp(langtxt,""))
|
||||
forcelang = true;
|
||||
forcelang = true;
|
||||
|
||||
char langcode[10] = "";
|
||||
if (forcelang)
|
||||
strcpy(langcode,ConvertLangTextToCode(langtxt)); /* convert language text into ISO 639 two-letter language code */
|
||||
|
||||
|
||||
/* create index of <id> elements */
|
||||
nodeindex = mxmlIndexNew(nodedata,"id", NULL);
|
||||
nodeindex = mxmlIndexNew(nodedata,"id", NULL);
|
||||
nodeid = mxmlIndexReset(nodeindex);
|
||||
*element_text = 0;
|
||||
char id_text[10];
|
||||
char title_text[200] = "";
|
||||
char title_text_EN[200] = "";
|
||||
|
||||
|
||||
/* search index of id elements, load all id/titles text */
|
||||
while (nodeid != NULL)
|
||||
{
|
||||
nodeid = mxmlIndexFind(nodeindex,"id", NULL);
|
||||
if (nodeid != NULL) {
|
||||
if (nodeid != NULL) {
|
||||
strcpy(title_text,"");
|
||||
strcpy(title_text_EN,"");
|
||||
|
||||
|
||||
get_text(nodeid, element_text, sizeof(element_text));
|
||||
snprintf(id_text, 7, "%s",element_text);
|
||||
|
||||
|
||||
// if language is not forced, use game language setting from config
|
||||
if (!forcelang) {
|
||||
langtxt = GetLangSettingFromGame(id_text);
|
||||
@ -318,7 +309,7 @@ void LoadTitlesFromXML(char *langtxt, bool forcejptoen)
|
||||
/* if enabled, force English title for all games set to Japanese */
|
||||
if (forcejptoen && (!strcmp(langcode,"JA")))
|
||||
strcpy(langcode,"EN");
|
||||
|
||||
|
||||
/* load title from nodes */
|
||||
nodefound = mxmlFindElement(nodeid, nodedata, "locale", "lang", "EN", MXML_NO_DESCEND);
|
||||
if (nodefound != NULL) {
|
||||
@ -333,12 +324,12 @@ void LoadTitlesFromXML(char *langtxt, bool forcejptoen)
|
||||
if (!strcmp(title_text,"")) {
|
||||
strcpy(title_text,title_text_EN);
|
||||
}
|
||||
|
||||
|
||||
snprintf(id_text, 5, "%s",id_text);
|
||||
title_set(id_text, title_text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// free memory
|
||||
mxmlIndexDelete(nodeindex);
|
||||
|
||||
@ -346,7 +337,7 @@ void LoadTitlesFromXML(char *langtxt, bool forcejptoen)
|
||||
}
|
||||
|
||||
|
||||
void GetPublisherFromGameid(char *idtxt, char *dest, int destsize)
|
||||
void GetPublisherFromGameid(char *idtxt, char *dest, int destsize)
|
||||
{
|
||||
/* guess publisher from company list using last two characters from game id */
|
||||
nodeindextmp = mxmlIndexNew(nodedata,"company", NULL);
|
||||
@ -370,7 +361,7 @@ void GetPublisherFromGameid(char *idtxt, char *dest, int destsize)
|
||||
} else {
|
||||
strcpy(dest,"");
|
||||
}
|
||||
|
||||
|
||||
// free memory
|
||||
mxmlIndexDelete(nodeindextmp);
|
||||
}
|
||||
@ -380,9 +371,9 @@ void GetPublisherFromGameid(char *idtxt, char *dest, int destsize)
|
||||
bool LoadGameInfoFromXML(char* gameid, char* langtxt)
|
||||
/* gameid: full game id */
|
||||
/* langtxt: "English","French","German" */
|
||||
{
|
||||
{
|
||||
bool exist=false;
|
||||
if (!xml_loaded || nodedata == NULL)
|
||||
if (!xml_loaded || nodedata == NULL)
|
||||
return exist;
|
||||
|
||||
// load game info using forced language, or game individual setting, or main language setting
|
||||
@ -390,12 +381,12 @@ bool LoadGameInfoFromXML(char* gameid, char* langtxt)
|
||||
if (!strcmp(langtxt,""))
|
||||
langtxt = GetLangSettingFromGame(gameid);
|
||||
strcpy(langcode,ConvertLangTextToCode(langtxt));
|
||||
|
||||
|
||||
/* reset all game info */
|
||||
gameinfo = gameinfo_reset;
|
||||
|
||||
|
||||
/* index all IDs */
|
||||
nodeindex = mxmlIndexNew(nodedata,"id", NULL);
|
||||
nodeindex = mxmlIndexNew(nodedata,"id", NULL);
|
||||
nodeid = mxmlIndexReset(nodeindex);
|
||||
*element_text = 0;
|
||||
/* search for game matching gameid */
|
||||
@ -421,7 +412,7 @@ bool LoadGameInfoFromXML(char* gameid, char* langtxt)
|
||||
GetTextFromNode(nodeid, nodedata, "developer", NULL, NULL, MXML_NO_DESCEND, gameinfo.developer,sizeof(gameinfo.developer));
|
||||
GetTextFromNode(nodeid, nodedata, "publisher", NULL, NULL, MXML_NO_DESCEND, gameinfo.publisher,sizeof(gameinfo.publisher));
|
||||
GetPublisherFromGameid(gameid,gameinfo.publisherfromid,sizeof(gameinfo.publisherfromid));
|
||||
|
||||
|
||||
/* text from attributes */
|
||||
GetTextFromNode(nodeid, nodedata, "date", "year", NULL, MXML_NO_DESCEND, gameinfo.year,sizeof(gameinfo.year));
|
||||
GetTextFromNode(nodeid, nodedata, "date", "month", NULL,MXML_NO_DESCEND, gameinfo.month,sizeof(gameinfo.month));
|
||||
@ -431,7 +422,7 @@ bool LoadGameInfoFromXML(char* gameid, char* langtxt)
|
||||
GetTextFromNode(nodeid, nodedata, "rom", "crc", NULL, MXML_NO_DESCEND, gameinfo.iso_crc,sizeof(gameinfo.iso_crc));
|
||||
GetTextFromNode(nodeid, nodedata, "rom", "md5", NULL, MXML_NO_DESCEND, gameinfo.iso_md5,sizeof(gameinfo.iso_md5));
|
||||
GetTextFromNode(nodeid, nodedata, "rom", "sha1", NULL, MXML_NO_DESCEND, gameinfo.iso_sha1,sizeof(gameinfo.iso_sha1));
|
||||
|
||||
|
||||
/* text from child elements */
|
||||
nodefound = mxmlFindElement(nodeid, nodedata, "locale", "lang", "EN", MXML_NO_DESCEND);
|
||||
if (nodefound != NULL) {
|
||||
@ -563,9 +554,9 @@ bool LoadGameInfoFromXML(char* gameid, char* langtxt)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
exist=true;
|
||||
} else {
|
||||
/*game not found */
|
||||
@ -604,7 +595,7 @@ bool LoadGameInfoFromXML(char* gameid, char* langtxt)
|
||||
void PrintGameInfo(bool showfullinfo)
|
||||
{
|
||||
if (showfullinfo) {
|
||||
|
||||
|
||||
//Con_Clear();
|
||||
|
||||
//printf("id: %s version: %s region: %s",gameinfo.id, gameinfo.version, gameinfo.region);
|
||||
@ -651,11 +642,11 @@ void PrintGameInfo(bool showfullinfo)
|
||||
//printf("iso_crc: %s iso_md5: %s\n",gameinfo.iso_crc,gameinfo.iso_md5);
|
||||
//printf("iso_sha1: %s\n",gameinfo.iso_sha1);
|
||||
//printf("synopsis: %s\n",gameinfo.synopsis);
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
char linebuf[1000] = "";
|
||||
|
||||
|
||||
if (xmldebug) {
|
||||
//char xmltime[100];
|
||||
//sprintf(xmltime,"%d",xmlloadtime);
|
||||
@ -687,7 +678,7 @@ void PrintGameInfo(bool showfullinfo)
|
||||
}
|
||||
printf("%s\n",linebuf);
|
||||
strcpy(linebuf,"");
|
||||
|
||||
|
||||
if (strcmp(gameinfo.ratingvalue,"") != 0) {
|
||||
snprintf(linebuf, sizeof(linebuf), "rated %s", gameinfo.ratingvalue);
|
||||
if (!strcmp(gameinfo.ratingtype,"PEGI"))
|
||||
@ -729,9 +720,9 @@ char *MemInfo()
|
||||
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
/* get_text() - Get the text for a node, taken from mini-mxml example mxmldoc.c */
|
||||
static char * get_text(mxml_node_t *node, char *buffer, int buflen) /* O - Text in node, I - Node to get, I - Buffer, I - Size of buffer */
|
||||
static char * get_text(mxml_node_t *node, char *buffer, int buflen) /* O - Text in node, I - Node to get, I - Buffer, I - Size of buffer */
|
||||
{
|
||||
char *ptr, *end; /* Pointer into buffer, End of buffer */
|
||||
char *ptr, *end; /* Pointer into buffer, End of buffer */
|
||||
int len; /* Length of node */
|
||||
mxml_node_t *current; /* Current node */
|
||||
ptr = buffer;
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
#ifndef _XML_H_
|
||||
#define _XML_H_
|
||||
|
||||
#include <mxml.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
@ -13,68 +15,57 @@ bool OpenXMLDatabase(char* xmlfilepath, char* argdblang, bool argJPtoEN, bool op
|
||||
void CloseXMLDatabase();
|
||||
bool LoadGameInfoFromXML(char* gameid, char* langcode);
|
||||
|
||||
|
||||
#define XML_ELEMMAX 15
|
||||
|
||||
struct gameXMLinfo
|
||||
{
|
||||
char id[7];
|
||||
char version[50];
|
||||
char region[7];
|
||||
char title[200];
|
||||
char synopsis[3000];
|
||||
char title_EN[200];
|
||||
char synopsis_EN[3000];
|
||||
char locales[XML_ELEMMAX+1][3];
|
||||
int localeCnt;
|
||||
char developer[75];
|
||||
char publisher[75];
|
||||
char publisherfromid[75];
|
||||
char year[5];
|
||||
char month[3];
|
||||
char day[3];
|
||||
char genre[75];
|
||||
char genresplit[XML_ELEMMAX+1][20];
|
||||
int genreCnt;
|
||||
char ratingtype[5];
|
||||
char ratingvalue[5];
|
||||
char ratingdescriptors[XML_ELEMMAX+1][40];
|
||||
int descriptorCnt;
|
||||
char ratingvalueCERO[5];
|
||||
char ratingvalueESRB[5];
|
||||
char ratingvaluePEGI[5];
|
||||
char wifiplayers[4];
|
||||
char wififeatures[XML_ELEMMAX+1][20];
|
||||
int wifiCnt;
|
||||
char players[4];
|
||||
char accessories[XML_ELEMMAX+1][20];
|
||||
int accessoryCnt;
|
||||
char accessoriesReq[XML_ELEMMAX+1][20];
|
||||
int accessoryReqCnt;
|
||||
char iso_crc[9];
|
||||
char iso_md5[33];
|
||||
char iso_sha1[41];
|
||||
{
|
||||
char id[7];
|
||||
char version[50];
|
||||
char region[7];
|
||||
char title[200];
|
||||
char synopsis[3000];
|
||||
char title_EN[200];
|
||||
char synopsis_EN[3000];
|
||||
char locales[XML_ELEMMAX+1][3];
|
||||
int localeCnt;
|
||||
char developer[75];
|
||||
char publisher[75];
|
||||
char publisherfromid[75];
|
||||
char year[5];
|
||||
char month[3];
|
||||
char day[3];
|
||||
char genre[75];
|
||||
char genresplit[XML_ELEMMAX+1][20];
|
||||
int genreCnt;
|
||||
char ratingtype[5];
|
||||
char ratingvalue[5];
|
||||
char ratingdescriptors[XML_ELEMMAX+1][40];
|
||||
int descriptorCnt;
|
||||
char ratingvalueCERO[5];
|
||||
char ratingvalueESRB[5];
|
||||
char ratingvaluePEGI[5];
|
||||
char wifiplayers[4];
|
||||
char wififeatures[XML_ELEMMAX+1][20];
|
||||
int wifiCnt;
|
||||
char players[4];
|
||||
char accessories[XML_ELEMMAX+1][20];
|
||||
int accessoryCnt;
|
||||
char accessoriesReq[XML_ELEMMAX+1][20];
|
||||
int accessoryReqCnt;
|
||||
char iso_crc[9];
|
||||
char iso_md5[33];
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user