mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-25 20:56:53 +01:00
*Changed Theme Download to parse XML now
*Removed punes headlessID because it doesnt allow a start of the loader over SendElf anymore
This commit is contained in:
parent
5c26c4082a
commit
063072a6c9
@ -2,8 +2,8 @@
|
||||
<app version="1">
|
||||
<name> USB Loader GX</name>
|
||||
<coder>USB Loader GX Team</coder>
|
||||
<version>1.0 r859</version>
|
||||
<release_date>200912120047</release_date>
|
||||
<version>1.0 r860</version>
|
||||
<release_date>200912121501</release_date>
|
||||
<short_description>Loads games from USB-devices</short_description>
|
||||
<long_description>USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times.
|
||||
The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller.
|
||||
|
File diff suppressed because one or more lines are too long
@ -10,6 +10,7 @@
|
||||
#ifndef _HOMEBREWBROWSE_H_
|
||||
#define _HOMEBREWBROWSE_H_
|
||||
|
||||
int roundup(float number);
|
||||
int MenuHomebrewBrowse();
|
||||
|
||||
#endif
|
||||
|
@ -145,8 +145,10 @@ int MenuCheck() {
|
||||
//Spieleliste laden
|
||||
__Menu_GetEntries(0);
|
||||
|
||||
if (strcmp(headlessID,"")!=0)
|
||||
menu = MENU_EXIT;
|
||||
//THIS SHIT MAKES THE LOADER NOT RUN FROM SENDELF
|
||||
//Think of something else pune.
|
||||
//if (strcmp(headlessID,"")!=0)
|
||||
//menu = MENU_EXIT;
|
||||
|
||||
if (menu == MENU_NONE)
|
||||
menu = MENU_DISCLIST;
|
||||
|
@ -253,7 +253,7 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
|
||||
int tmp;
|
||||
while (showProgress) {
|
||||
|
||||
VIDEO_WaitVSync ();
|
||||
usleep(20000);
|
||||
|
||||
GameInstallProgress();
|
||||
|
||||
@ -325,7 +325,8 @@ void ProgressStop() {
|
||||
* Callbackfunction for updating the progress values
|
||||
* Use this function as standard callback
|
||||
***************************************************************************/
|
||||
void ShowProgress(const char *title, const char *msg1, char *dynmsg2, f32 done, f32 total, bool swSize, bool swTime) {
|
||||
void ShowProgress(const char *title, const char *msg1, char *dynmsg2, f32 done, f32 total, bool swSize, bool swTime)
|
||||
{
|
||||
if (total <= 0)
|
||||
return;
|
||||
|
||||
@ -342,7 +343,6 @@ void ShowProgress(const char *title, const char *msg1, char *dynmsg2, f32 done,
|
||||
if (dynmsg2)
|
||||
dyn_message = dynmsg2;
|
||||
|
||||
if (swTime == true) {
|
||||
static u32 expected;
|
||||
|
||||
u32 elapsed, h, m, s, speed = 0;
|
||||
@ -350,6 +350,7 @@ void ShowProgress(const char *title, const char *msg1, char *dynmsg2, f32 done,
|
||||
if (!done) {
|
||||
start = time(0);
|
||||
expected = 300;
|
||||
LWP_ResumeThread(progressthread);
|
||||
}
|
||||
|
||||
//Elapsed time
|
||||
@ -373,6 +374,7 @@ void ShowProgress(const char *title, const char *msg1, char *dynmsg2, f32 done,
|
||||
m = (elapsed / 60) % 60;
|
||||
s = elapsed % 60;
|
||||
|
||||
if (swTime == true) {
|
||||
snprintf(progressTime, sizeof(progressTime), "%s %d:%02d:%02d",tr("Time left:"),h,m,s);
|
||||
}
|
||||
|
||||
@ -383,13 +385,13 @@ void ShowProgress(const char *title, const char *msg1, char *dynmsg2, f32 done,
|
||||
snprintf(progressSizeLeft, sizeof(progressSizeLeft), "%0.2fMB/%0.2fMB", done * done/total / MB_SIZE, total/MB_SIZE);
|
||||
else
|
||||
snprintf(progressSizeLeft, sizeof(progressSizeLeft), "%0.2fGB/%0.2fGB", done * done/total / GB_SIZE, total/GB_SIZE);
|
||||
|
||||
snprintf(progressSpeed, sizeof(progressSpeed), "%dKB/s", speed);
|
||||
}
|
||||
|
||||
showProgress = 1;
|
||||
progressDone = 100.0*done/total;
|
||||
changed = true;
|
||||
|
||||
LWP_ResumeThread(progressthread);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "libwiigui/gui.h"
|
||||
#include "prompts/PromptWindows.h"
|
||||
#include "prompts/ProgressWindow.h"
|
||||
#include "homebrewboot/HomebrewBrowse.h"
|
||||
#include "network/networkops.h"
|
||||
#include "themes/Theme_List.h"
|
||||
#include "menu.h"
|
||||
@ -68,9 +69,9 @@ bool DownloadTheme(const char *url, const char *title)
|
||||
|
||||
u32 done = 0;
|
||||
|
||||
int blocksize = 1024;
|
||||
int blocksize = 1024*5;
|
||||
|
||||
u8 *buffer = (u8*) malloc(blocksize);
|
||||
u8 *buffer = new u8[blocksize];
|
||||
|
||||
while(done < (u32) filesize)
|
||||
{
|
||||
@ -89,17 +90,26 @@ bool DownloadTheme(const char *url, const char *title)
|
||||
WindowPrompt(tr("Download failed."), tr("Transfer failed."), tr("OK"));
|
||||
return false;
|
||||
}
|
||||
else if (ret == 0)
|
||||
break;
|
||||
|
||||
fwrite(buffer, 1, blocksize, file);
|
||||
|
||||
done += ret;
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
delete [] buffer;
|
||||
fclose(file);
|
||||
|
||||
ProgressStop();
|
||||
|
||||
if(done != (u32) filesize)
|
||||
{
|
||||
remove(filepath);
|
||||
WindowPrompt(tr("Download failed."), tr("Connection lost..."), tr("OK"));
|
||||
return false;
|
||||
}
|
||||
|
||||
ZipFile zipfile(filepath);
|
||||
|
||||
bool result = zipfile.ExtractAll(path);
|
||||
@ -249,10 +259,10 @@ int Theme_Downloader()
|
||||
{
|
||||
int pagesize = 4;
|
||||
int menu = MENU_NONE;
|
||||
bool pagechanged = false;
|
||||
bool listchanged = false;
|
||||
|
||||
char THEME_LINK[30] = "http://wii.spiffy360.com/";
|
||||
const char THEME_LINK[70] = "http://wii.spiffy360.com/themes.php?xml=1&category=1&adult=0";
|
||||
//const char THEME_LINK_ADULT[70] = "http://wii.spiffy360.com/themes.php?xml=1&category=1&adult=1";
|
||||
|
||||
/*** Sound Variables ***/
|
||||
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
|
||||
@ -388,18 +398,6 @@ int Theme_Downloader()
|
||||
PageIndicatorBtn.SetTrigger(&trigA);
|
||||
PageIndicatorBtn.SetEffectGrow();
|
||||
|
||||
GuiImage Pageindicator2Img(&PageindicatorImgData);
|
||||
GuiText Pageindicator2Txt(NULL, 22, (GXColor) { 0, 0, 0, 255});
|
||||
GuiButton PageIndicator2Btn(Pageindicator2Img.GetWidth(), Pageindicator2Img.GetHeight());
|
||||
PageIndicator2Btn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
||||
PageIndicator2Btn.SetPosition(150, 400);
|
||||
PageIndicator2Btn.SetImage(&Pageindicator2Img);
|
||||
PageIndicator2Btn.SetLabel(&Pageindicator2Txt);
|
||||
PageIndicator2Btn.SetSoundOver(&btnSoundOver);
|
||||
PageIndicator2Btn.SetSoundClick(&btnClick1);
|
||||
PageIndicator2Btn.SetTrigger(&trigA);
|
||||
PageIndicator2Btn.SetEffectGrow();
|
||||
|
||||
GuiImage wifiImg(&wifiImgData);
|
||||
if (Settings.wsprompt == yes)
|
||||
{
|
||||
@ -426,7 +424,30 @@ int Theme_Downloader()
|
||||
char url[300];
|
||||
int currentpage = 1;
|
||||
int currenttheme = 0;
|
||||
int currentloaderpage = 1;
|
||||
|
||||
HaltGui();
|
||||
w.RemoveAll();
|
||||
w.Append(&background);
|
||||
w.Append(&titleTxt);
|
||||
w.Append(&backBtn);
|
||||
w.Append(&GoLeftBtn);
|
||||
w.Append(&GoRightBtn);
|
||||
w.Append(&PageIndicatorBtn);
|
||||
w.Append(&wifiBtn);
|
||||
w.Append(&HomeBtn);
|
||||
ResumeGui();
|
||||
|
||||
ShowProgress(tr("Downloading Page List:"), "", (char *) tr("Please wait..."), 0, pagesize);
|
||||
|
||||
Theme = new Theme_List(THEME_LINK);
|
||||
|
||||
int ThemesOnPage = Theme->GetThemeCount();
|
||||
|
||||
if(!ThemesOnPage)
|
||||
{
|
||||
WindowPrompt(tr("No themes found on the site."), 0, "OK");
|
||||
menu = MENU_SETTINGS;
|
||||
}
|
||||
|
||||
while(menu == MENU_NONE)
|
||||
{
|
||||
@ -438,55 +459,13 @@ int Theme_Downloader()
|
||||
w.Append(&GoLeftBtn);
|
||||
w.Append(&GoRightBtn);
|
||||
w.Append(&PageIndicatorBtn);
|
||||
w.Append(&PageIndicator2Btn);
|
||||
w.Append(&wifiBtn);
|
||||
w.Append(&HomeBtn);
|
||||
ResumeGui();
|
||||
|
||||
ShowProgress(tr("Downloading Page List:"), "", (char *) tr("Please wait..."), 0, pagesize);
|
||||
|
||||
snprintf(url, sizeof(url), "%sthemes.php?creator=&sort=1&page=%i", THEME_LINK, currentpage);
|
||||
|
||||
if(Theme)
|
||||
{
|
||||
delete Theme;
|
||||
Theme = NULL;
|
||||
}
|
||||
Theme = new Theme_List(url);
|
||||
|
||||
sprintf(url, "%i", currentpage);
|
||||
PageindicatorTxt.SetText(url);
|
||||
|
||||
int SitePageCount = Theme->GetSitepageCount();
|
||||
int ThemesOnPage = Theme->GetThemeCount();
|
||||
|
||||
pagechanged = false;
|
||||
|
||||
if(!ThemesOnPage)
|
||||
{
|
||||
WindowPrompt(tr("No themes found on the site."), 0, "OK");
|
||||
pagechanged = true;
|
||||
menu = MENU_SETTINGS;
|
||||
}
|
||||
|
||||
while(!pagechanged)
|
||||
{
|
||||
HaltGui();
|
||||
w.RemoveAll();
|
||||
w.Append(&background);
|
||||
w.Append(&titleTxt);
|
||||
w.Append(&backBtn);
|
||||
w.Append(&GoLeftBtn);
|
||||
w.Append(&GoRightBtn);
|
||||
w.Append(&PageIndicatorBtn);
|
||||
w.Append(&PageIndicator2Btn);
|
||||
w.Append(&wifiBtn);
|
||||
w.Append(&HomeBtn);
|
||||
ResumeGui();
|
||||
|
||||
sprintf(url, "%i", currentloaderpage);
|
||||
Pageindicator2Txt.SetText(url);
|
||||
|
||||
int n = 0;
|
||||
|
||||
for(int i = currenttheme; (i < (currenttheme+pagesize)); i++)
|
||||
@ -511,9 +490,6 @@ int Theme_Downloader()
|
||||
MainButtonTxt[n]->SetPosition(0, 10);
|
||||
MainButtonTxt[n]->SetMaxWidth(theme_box_Data.GetWidth()-10, GuiText::DOTTED);
|
||||
|
||||
if(!Theme->IsDirectImageLink(i))
|
||||
sprintf(url, "%s%s", THEME_LINK, Theme->GetImageLink(i));
|
||||
else
|
||||
sprintf(url, "%s", Theme->GetImageLink(i));
|
||||
|
||||
char filepath[300];
|
||||
@ -586,7 +562,6 @@ int Theme_Downloader()
|
||||
else if (backBtn.GetState() == STATE_CLICKED)
|
||||
{
|
||||
listchanged = true;
|
||||
pagechanged = true;
|
||||
menu = MENU_SETTINGS;
|
||||
backBtn.ResetState();
|
||||
break;
|
||||
@ -595,16 +570,11 @@ int Theme_Downloader()
|
||||
{
|
||||
listchanged = true;
|
||||
currenttheme += pagesize;
|
||||
currentloaderpage++;
|
||||
currentpage++;
|
||||
if(currenttheme >= ThemesOnPage)
|
||||
{
|
||||
pagechanged = true;
|
||||
currentpage++;
|
||||
if(currentpage > SitePageCount)
|
||||
currentpage = 1;
|
||||
|
||||
currenttheme = 0;
|
||||
currentloaderpage = 1;
|
||||
}
|
||||
GoRightBtn.ResetState();
|
||||
}
|
||||
@ -612,16 +582,11 @@ int Theme_Downloader()
|
||||
{
|
||||
listchanged = true;
|
||||
currenttheme -= pagesize;
|
||||
currentloaderpage--;
|
||||
currentpage--;
|
||||
if(currenttheme < 0)
|
||||
{
|
||||
pagechanged = true;
|
||||
currentpage--;
|
||||
if(currentpage < 1)
|
||||
currentpage = SitePageCount;
|
||||
|
||||
currenttheme = 0;
|
||||
currentloaderpage = 1;
|
||||
currentpage = roundup((ThemesOnPage+1.0f)/pagesize);
|
||||
currenttheme = currentpage*pagesize-pagesize;
|
||||
}
|
||||
GoLeftBtn.ResetState();
|
||||
}
|
||||
@ -630,14 +595,13 @@ int Theme_Downloader()
|
||||
{
|
||||
if(MainButton[i]->GetState() == STATE_CLICKED)
|
||||
{
|
||||
snprintf(url, sizeof(url), "%s%s", THEME_LINK, Theme->GetDownloadLink(currenttheme+i));
|
||||
snprintf(url, sizeof(url), "%s", Theme->GetDownloadLink(currenttheme+i));
|
||||
Theme_Prompt(Theme->GetThemeTitle(currenttheme+i), Theme->GetThemeAuthor(currenttheme+i), ImageData[i], url);
|
||||
MainButton[i]->ResetState();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
w.SetEffect(EFFECT_FADE, -20);
|
||||
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include <gctypes.h>
|
||||
|
||||
#include "Theme_List.h"
|
||||
#include "xml/xml.h"
|
||||
#include "prompts/PromptWindows.h"
|
||||
|
||||
#define stringcompare(text, cmp, pos) strncasecmp((const char*) &text[pos-strlen(cmp)], (const char*) cmp, strlen((const char*) cmp))
|
||||
|
||||
@ -52,7 +54,6 @@ Theme_List::Theme_List(const char * url)
|
||||
{
|
||||
Theme = NULL;
|
||||
themescount = 0;
|
||||
sitepages = 0;
|
||||
|
||||
if (!IsNetworkInit())
|
||||
{
|
||||
@ -68,97 +69,14 @@ Theme_List::Theme_List(const char * url)
|
||||
return;
|
||||
}
|
||||
|
||||
u32 cnt = 0;
|
||||
char temp[1024];
|
||||
|
||||
Theme = (Theme_Info *) malloc(sizeof(Theme_Info));
|
||||
if (!Theme) {
|
||||
themescount = CountThemes(file.data);
|
||||
if (themescount <= 0)
|
||||
{
|
||||
free(file.data);
|
||||
themescount = -3;
|
||||
return;
|
||||
}
|
||||
|
||||
memset(&Theme[themescount], 0, sizeof(Theme_Info));
|
||||
|
||||
while (cnt < file.size) {
|
||||
|
||||
if(stringcompare(file.data, "\"themetitle\">", cnt) == 0)
|
||||
{
|
||||
Theme = (Theme_Info *) realloc(Theme, (themescount+1)*sizeof(Theme_Info));
|
||||
|
||||
if (!Theme)
|
||||
{
|
||||
for (int i = 0; i < themescount; i++)
|
||||
{
|
||||
if(Theme[i].imagelink)
|
||||
delete [] Theme[i].imagelink;
|
||||
if(Theme[i].imagelink)
|
||||
delete [] Theme[i].downloadlink;
|
||||
Theme[i].imagelink = NULL;
|
||||
Theme[i].downloadlink = NULL;
|
||||
}
|
||||
free(Theme);
|
||||
Theme = NULL;
|
||||
free(file.data);
|
||||
themescount = -4;
|
||||
break;
|
||||
}
|
||||
|
||||
memset(&(Theme[themescount]), 0, sizeof(Theme_Info));
|
||||
|
||||
copyhtmlsting((const char *) file.data, temp, "</", cnt);
|
||||
|
||||
snprintf(Theme[themescount].themetitle, sizeof(Theme[themescount].themetitle), "%s", temp);
|
||||
|
||||
while (cnt < file.size && stringcompare(file.data, "\"themecreated\">By: ", cnt) != 0)
|
||||
cnt++;
|
||||
|
||||
copyhtmlsting((const char *) file.data, temp, " - <", cnt);
|
||||
|
||||
snprintf(Theme[themescount].author, sizeof(Theme[themescount].author), "%s", temp);
|
||||
|
||||
while(cnt < file.size && stringcompare(file.data, "class=\"image\" src=\"", cnt) != 0)
|
||||
cnt++;
|
||||
|
||||
copyhtmlsting((const char *) file.data, temp, "\" ", cnt);
|
||||
|
||||
Theme[themescount].imagelink = new char[strlen(temp)+1];
|
||||
|
||||
snprintf(Theme[themescount].imagelink, strlen(temp)+1, "%s", temp);
|
||||
|
||||
if (strncmp(Theme[themescount].imagelink, "http://", strlen("http://")) != 0)
|
||||
Theme[themescount].direct[0] = false;
|
||||
else
|
||||
Theme[themescount].direct[0] = true;
|
||||
|
||||
while(cnt < file.size && stringcompare(file.data, "href=\"getfile.php", cnt+strlen("getfile.php")) != 0)
|
||||
cnt++;
|
||||
|
||||
copyhtmlsting((const char *) file.data, temp, "\">", cnt);
|
||||
|
||||
Theme[themescount].downloadlink = new char[strlen(temp)+1];
|
||||
|
||||
snprintf(Theme[themescount].downloadlink, strlen(temp)+1, "%s", temp);
|
||||
|
||||
if (strncmp(Theme[themescount].downloadlink, "http://", strlen("http://")) != 0)
|
||||
Theme[themescount].direct[1] = false;
|
||||
else
|
||||
Theme[themescount].direct[1] = true;
|
||||
|
||||
themescount++;
|
||||
}
|
||||
|
||||
if(stringcompare(file.data, "/themes.php?creator=&sort=1&page=", cnt) == 0)
|
||||
{
|
||||
copyhtmlsting((const char *) file.data, temp, "class", cnt);
|
||||
int currentvalue = atoi(temp);
|
||||
|
||||
if(currentvalue > sitepages);
|
||||
sitepages = currentvalue;
|
||||
}
|
||||
|
||||
cnt++;
|
||||
}
|
||||
ParseXML(file.data);
|
||||
|
||||
free(file.data);
|
||||
}
|
||||
@ -167,19 +85,113 @@ Theme_List::~Theme_List()
|
||||
{
|
||||
for (int i = 0; i < themescount; i++)
|
||||
{
|
||||
if(Theme[i].themetitle)
|
||||
delete [] Theme[i].themetitle;
|
||||
if(Theme[i].author)
|
||||
delete [] Theme[i].author;
|
||||
if(Theme[i].imagelink)
|
||||
delete [] Theme[i].imagelink;
|
||||
if(Theme[i].imagelink)
|
||||
if(Theme[i].downloadlink)
|
||||
delete [] Theme[i].downloadlink;
|
||||
Theme[i].themetitle = NULL;
|
||||
Theme[i].author = NULL;
|
||||
Theme[i].imagelink = NULL;
|
||||
Theme[i].downloadlink = NULL;
|
||||
}
|
||||
|
||||
if(Theme)
|
||||
free(Theme);
|
||||
delete [] Theme;
|
||||
Theme = NULL;
|
||||
}
|
||||
|
||||
|
||||
int Theme_List::CountThemes(const u8 * xmlfile)
|
||||
{
|
||||
char tmp[200];
|
||||
u32 cnt = 0;
|
||||
u32 stringlength = strlen((const char *) xmlfile);
|
||||
memset(tmp, 0, sizeof(tmp));
|
||||
|
||||
while (cnt < stringlength)
|
||||
{
|
||||
if (stringcompare(xmlfile, "<totalthemes>", cnt) == 0)
|
||||
{
|
||||
copyhtmlsting((const char *) xmlfile, tmp, ">", cnt);
|
||||
break;
|
||||
}
|
||||
cnt++;
|
||||
}
|
||||
tmp[cnt+1] = 0;
|
||||
|
||||
return atoi(tmp);
|
||||
}
|
||||
|
||||
bool Theme_List::ParseXML(const u8 * xmlfile)
|
||||
{
|
||||
char element_text[1024];
|
||||
memset(element_text, 0, sizeof(element_text));
|
||||
mxml_node_t *nodetree=NULL;
|
||||
mxml_node_t *nodedata=NULL;
|
||||
mxml_node_t *nodeid=NULL;
|
||||
mxml_index_t *nodeindex=NULL;
|
||||
|
||||
nodetree = mxmlLoadString(NULL, (const char *) xmlfile, MXML_OPAQUE_CALLBACK);
|
||||
|
||||
if (nodetree == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
nodedata = mxmlFindElement(nodetree, nodetree, "themes", NULL, NULL, MXML_DESCEND);
|
||||
if (nodedata == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
nodeindex = mxmlIndexNew(nodedata,"name", NULL);
|
||||
nodeid = mxmlIndexReset(nodeindex);
|
||||
|
||||
Theme = new Theme_Info[themescount];
|
||||
memset(Theme, 0, sizeof(Theme));
|
||||
|
||||
for (int i = 0; i < themescount; i++)
|
||||
{
|
||||
nodeid = mxmlIndexFind(nodeindex,"name", NULL);
|
||||
if (nodeid != NULL)
|
||||
{
|
||||
get_nodetext(nodeid, element_text, sizeof(element_text));
|
||||
Theme[i].themetitle = new char[strlen(element_text)+2];
|
||||
snprintf(Theme[i].themetitle,strlen(element_text)+1, "%s", element_text);
|
||||
|
||||
GetTextFromNode(nodeid, nodedata, (char *) "creator", NULL, NULL, MXML_NO_DESCEND, element_text,sizeof(element_text));
|
||||
Theme[i].author = new char[strlen(element_text)+2];
|
||||
snprintf(Theme[i].author,strlen(element_text)+1, "%s", element_text);
|
||||
|
||||
GetTextFromNode(nodeid, nodedata, (char *) "thumbpath", NULL, NULL, MXML_NO_DESCEND, element_text,sizeof(element_text));
|
||||
Theme[i].imagelink = new char[strlen(element_text)+2];
|
||||
snprintf(Theme[i].imagelink,strlen(element_text)+1, "%s", element_text);
|
||||
|
||||
GetTextFromNode(nodeid, nodedata, (char *) "downloadpath", NULL, NULL, MXML_NO_DESCEND, element_text,sizeof(element_text));
|
||||
Theme[i].downloadlink = new char[strlen(element_text)+2];
|
||||
snprintf(Theme[i].downloadlink,strlen(element_text)+1, "%s", element_text);
|
||||
|
||||
GetTextFromNode(nodeid, nodedata, (char *) "averagerating", NULL, NULL, MXML_NO_DESCEND, element_text,sizeof(element_text));
|
||||
Theme[i].rating = atoi(element_text);
|
||||
}
|
||||
}
|
||||
|
||||
nodetree=NULL;
|
||||
nodedata=NULL;
|
||||
nodeid=NULL;
|
||||
nodeindex=NULL;
|
||||
mxmlIndexDelete(nodeindex);
|
||||
free(nodetree);
|
||||
free(nodedata);
|
||||
free(nodeid);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const char * Theme_List::GetThemeTitle(int ind)
|
||||
{
|
||||
if (ind > themescount || ind < 0 || !Theme || themescount <= 0)
|
||||
@ -217,27 +229,6 @@ int Theme_List::GetThemeCount()
|
||||
return themescount;
|
||||
}
|
||||
|
||||
int Theme_List::GetSitepageCount()
|
||||
{
|
||||
return sitepages;
|
||||
}
|
||||
|
||||
bool Theme_List::IsDirectImageLink(int ind)
|
||||
{
|
||||
if (ind > themescount || ind < 0 || !Theme || themescount <= 0)
|
||||
return false;
|
||||
else
|
||||
return Theme[ind].direct[0];
|
||||
}
|
||||
|
||||
bool Theme_List::IsDirectDownloadLink(int ind)
|
||||
{
|
||||
if (ind > themescount || ind < 0 || !Theme || themescount <= 0)
|
||||
return false;
|
||||
else
|
||||
return Theme[ind].direct[1];
|
||||
}
|
||||
|
||||
static int ListCompare(const void *a, const void *b)
|
||||
{
|
||||
Theme_Info *ab = (Theme_Info*) a;
|
||||
|
@ -11,11 +11,11 @@
|
||||
|
||||
typedef struct _theme_info
|
||||
{
|
||||
char themetitle[100];
|
||||
char author[50];
|
||||
char *themetitle;
|
||||
char *author;
|
||||
char *imagelink;
|
||||
char *downloadlink;
|
||||
bool direct[2];
|
||||
u8 rating;
|
||||
} Theme_Info;
|
||||
|
||||
|
||||
@ -27,6 +27,10 @@ class Theme_List
|
||||
Theme_List(const char *url);
|
||||
//!Destructor
|
||||
~Theme_List();
|
||||
//!Get Themes into a struct from the XML file amount
|
||||
bool ParseXML(const u8 * xmlfile);
|
||||
//!Get Theme amount
|
||||
int CountThemes(const u8 * xmlfile);
|
||||
//! Get the a theme title
|
||||
//!\param list index
|
||||
const char * GetThemeTitle(int index);
|
||||
@ -39,19 +43,12 @@ class Theme_List
|
||||
//! Get the download link of the theme
|
||||
//!\param list index
|
||||
const char * GetDownloadLink(int index);
|
||||
//! Is it a direct URL or just a file or path under the main url
|
||||
bool IsDirectImageLink(int index);
|
||||
//! Is it a direct URL or just a file or path under the main url
|
||||
bool IsDirectDownloadLink(int index);
|
||||
//! Get the number of links counted
|
||||
int GetThemeCount();
|
||||
//! Get the number of pages counted on which there are Themes
|
||||
int GetSitepageCount();
|
||||
//! Sort list
|
||||
void SortList();
|
||||
protected:
|
||||
int themescount;
|
||||
int sitepages;
|
||||
Theme_Info *Theme;
|
||||
};
|
||||
|
||||
|
@ -61,7 +61,7 @@ static mxml_node_t *nodefound=NULL;
|
||||
static mxml_index_t *nodeindex=NULL;
|
||||
static mxml_index_t *nodeindextmp=NULL;
|
||||
int xmlloadtime = 0;
|
||||
static char * get_text(mxml_node_t *node, char *buffer, int buflen);
|
||||
char * get_nodetext(mxml_node_t *node, char *buffer, int buflen);
|
||||
bool xml_loaded = false;
|
||||
|
||||
|
||||
@ -111,7 +111,7 @@ void GetTextFromNode(mxml_node_t *currentnode, mxml_node_t *topnode, char *noden
|
||||
if (attributename != NULL) {
|
||||
strlcpy(dest,mxmlElementGetAttr(nodefound, attributename),destsize);
|
||||
} else {
|
||||
get_text(nodefound, element_text, sizeof(element_text));
|
||||
get_nodetext(nodefound, element_text, sizeof(element_text));
|
||||
strlcpy(dest,element_text,destsize);
|
||||
}
|
||||
} else {
|
||||
@ -308,7 +308,7 @@ void LoadTitlesFromXML(char *langtxt, bool forcejptoen)
|
||||
strcpy(title_text,"");
|
||||
strcpy(title_text_EN,"");
|
||||
|
||||
get_text(nodeid, element_text, sizeof(element_text));
|
||||
get_nodetext(nodeid, element_text, sizeof(element_text));
|
||||
snprintf(id_text, 7, "%s",element_text);
|
||||
|
||||
// if language is not forced, use game language setting from config
|
||||
@ -402,7 +402,7 @@ bool LoadGameInfoFromXML(char* gameid, char* langtxt)
|
||||
while (1) {
|
||||
nodeid = mxmlIndexFind(nodeindex,"id", NULL);
|
||||
if (nodeid != NULL) {
|
||||
get_text(nodeid, element_text, sizeof(element_text));
|
||||
get_nodetext(nodeid, element_text, sizeof(element_text));
|
||||
if (!strcmp(element_text,gameid)) {
|
||||
break;
|
||||
}
|
||||
@ -718,8 +718,8 @@ 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 */
|
||||
/* get_nodetext() - Get the text for a node, taken from mini-mxml example mxmldoc.c */
|
||||
char * get_nodetext(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 */
|
||||
int len; /* Length of node */
|
||||
mxml_node_t *current; /* Current node */
|
||||
@ -760,7 +760,7 @@ int GetRatingForGame(char *gameid)
|
||||
while (1) {
|
||||
nodeid = mxmlIndexFind(nodeindex,"id", NULL);
|
||||
if (nodeid != NULL) {
|
||||
get_text(nodeid, element_text, sizeof(element_text));
|
||||
get_nodetext(nodeid, element_text, sizeof(element_text));
|
||||
if (!strcmp(element_text,gameid)) {
|
||||
break;
|
||||
}
|
||||
|
@ -66,6 +66,7 @@ extern "C" {
|
||||
void GetTextFromNode(mxml_node_t *currentnode, mxml_node_t *topnode, char *nodename,
|
||||
char *attributename, char *value, int descend, char *dest, int destsize);
|
||||
int GetRatingForGame(char *gameid);
|
||||
char * get_nodetext(mxml_node_t *node, char *buffer, int buflen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user