From b7071bc7b357ae4d2f9403a99c86ae46fb49f127 Mon Sep 17 00:00:00 2001 From: dimok321 <15055714+dimok789@users.noreply.github.com> Date: Fri, 17 Sep 2010 16:15:18 +0000 Subject: [PATCH] *Fixed scrolling of Text *Fixed HomebrewXML - Long Description not being loaded completely but only a part. --- HBC/META.XML | 4 +- source/homebrewboot/HomebrewXML.cpp | 61 ++++++++++---------- source/homebrewboot/HomebrewXML.h | 77 +++++++++++-------------- source/prompts/PromptWindows.cpp | 52 +++++++++-------- source/prompts/gameinfo.cpp | 88 ++++++++++++++++------------- 5 files changed, 145 insertions(+), 137 deletions(-) diff --git a/HBC/META.XML b/HBC/META.XML index 085e09cc..aafff896 100644 --- a/HBC/META.XML +++ b/HBC/META.XML @@ -2,8 +2,8 @@ USB Loader GX USB Loader GX Team - 1.0 r945 - 201009171347 + 1.0 r946 + 201009171539 Loads games from USB-devices 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. diff --git a/source/homebrewboot/HomebrewXML.cpp b/source/homebrewboot/HomebrewXML.cpp index c2310302..4225bab1 100644 --- a/source/homebrewboot/HomebrewXML.cpp +++ b/source/homebrewboot/HomebrewXML.cpp @@ -9,59 +9,62 @@ #include "HomebrewXML.h" -HomebrewXML::HomebrewXML() { - strcpy(name,""); - strcpy(coder,""); - strcpy(version,""); - strcpy(releasedate,""); - strcpy(shortdescription,""); - strcpy(longdescription,""); -} +#define ENTRIE_SIZE 8192 -HomebrewXML::~HomebrewXML() { -} - -int HomebrewXML::LoadHomebrewXMLData(const char* filename) { +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) { + if (!filexml) return -1; - } nodetreeHB = mxmlLoadFile(NULL, filexml, MXML_OPAQUE_CALLBACK); fclose(filexml); - if (nodetreeHB == NULL) { + if (nodetreeHB == NULL) return -2; - } nodedataHB = mxmlFindElement(nodetreeHB, nodetreeHB, "app", NULL, NULL, MXML_DESCEND); - if (nodedataHB == NULL) { + 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)); + char * Entrie = new char[ENTRIE_SIZE]; - int len = (strlen(tmp1)-6); //length of the date string without the 200000 at the end + GetTextFromNode(nodedataHB, nodedataHB, (char*) "name", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE); + Name = Entrie; + GetTextFromNode(nodedataHB, nodedataHB, (char*) "coder", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE); + Coder = Entrie; + + GetTextFromNode(nodedataHB, nodedataHB, (char*) "version", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE); + Version = Entrie; + + GetTextFromNode(nodedataHB, nodedataHB, (char*) "short_description", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE); + ShortDescription = Entrie; + + GetTextFromNode(nodedataHB, nodedataHB, (char*) "long_description", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE); + LongDescription = Entrie; + + GetTextFromNode(nodedataHB, nodedataHB, (char*) "release_date", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE); + + int len = (strlen(Entrie)-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]); + snprintf(Entrie, ENTRIE_SIZE, "%c%c/%c%c/%c%c%c%c", Entrie[4],Entrie[5],Entrie[6],Entrie[7],Entrie[0],Entrie[1],Entrie[2],Entrie[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); + snprintf(Entrie, ENTRIE_SIZE, "%c%c/%c%c%c%c", Entrie[4],Entrie[5],Entrie[0],Entrie[1],Entrie[2],Entrie[3]); + else + snprintf(Entrie, ENTRIE_SIZE, "%s", Entrie); + + Releasedate = Entrie; free(nodedataHB); free(nodetreeHB); + delete [] Entrie; + return 1; } diff --git a/source/homebrewboot/HomebrewXML.h b/source/homebrewboot/HomebrewXML.h index ef7c7ea7..3255ddf3 100644 --- a/source/homebrewboot/HomebrewXML.h +++ b/source/homebrewboot/HomebrewXML.h @@ -5,50 +5,39 @@ #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) { - strlcpy(name, path, sizeof(name)); - } -protected: - char name[50]; - char coder[100]; - char version[30]; - char releasedate[30]; - char shortdescription[150]; - char longdescription[500]; +#include + +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 + const char * GetName() { return Name.c_str(); }; + //! Get coder + const char * GetCoder() { return Coder.c_str(); }; + //! Get version + const char * GetVersion() { return Version.c_str(); }; + //! Get releasedate + const char * GetReleasedate() { return Releasedate.c_str(); }; + //! Get shortdescription + const char * GetShortDescription() { return ShortDescription.c_str(); }; + //! Get longdescription + const char * GetLongDescription() { return LongDescription.c_str(); }; + //! Set Name + void SetName(char * newName) { Name = newName; }; + protected: + std::string Name; + std::string Coder; + std::string Version; + std::string Releasedate; + std::string ShortDescription; + std::string LongDescription; }; #endif diff --git a/source/prompts/PromptWindows.cpp b/source/prompts/PromptWindows.cpp index 4d1c8c69..68ecba30 100644 --- a/source/prompts/PromptWindows.cpp +++ b/source/prompts/PromptWindows.cpp @@ -3518,6 +3518,7 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version, long_descriptionTxt.SetPosition(46,117); long_descriptionTxt.SetMaxWidth(360); long_descriptionTxt.SetLinesToDraw(pagesize); + long_descriptionTxt.Refresh(); //convert filesize from u64 to char and put unit of measurement after it char temp2[7]; @@ -3604,42 +3605,49 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version, mainWindow->ChangeFocus(&promptWindow); ResumeGui(); - while (choice == -1) { + while (choice == -1) + { VIDEO_WaitVSync(); - if (shutdown == 1) { + + if (shutdown == 1) + { wiilight(0); Sys_Shutdown(); } - if (reset == 1) + else if (reset == 1) + { + wiilight(0); Sys_Reboot(); - if (btn1.GetState() == STATE_CLICKED) { + } + + if (btn1.GetState() == STATE_CLICKED) choice = 1; - } else if (btn2.GetState() == STATE_CLICKED) { + else if (btn2.GetState() == STATE_CLICKED) choice = 0; - } - else if (screenShotBtn.GetState() == STATE_CLICKED) { - gprintf("\n\tscreenShotBtn clicked"); - screenShotBtn.ResetState(); - ScreenShot(); - gprintf("...It's easy, mmmmmmKay"); - } - else if ((arrowUpBtn.GetState()==STATE_CLICKED||arrowUpBtn.GetState()==STATE_HELD) ) { - long_descriptionTxt.SetTextLine(long_descriptionTxt.GetCurrPos()-1); - usleep(60000); + + else if (screenShotBtn.GetState() == STATE_CLICKED) + { + gprintf("\n\tscreenShotBtn clicked"); + screenShotBtn.ResetState(); + ScreenShot(); + gprintf("...It's easy, mmmmmmKay"); + } + else if (arrowUpBtn.GetState() == STATE_CLICKED || arrowUpBtn.GetState() == STATE_HELD) + { + long_descriptionTxt.PreviousLine(); + + usleep(6000); if (!((ButtonsHold() & WPAD_BUTTON_UP)||(ButtonsHold() & PAD_BUTTON_UP))) arrowUpBtn.ResetState(); - } else if ((arrowDownBtn.GetState()==STATE_CLICKED||arrowDownBtn.GetState()==STATE_HELD) - &&long_descriptionTxt.GetTotalLinesCount()>pagesize - &&long_descriptionTxt.GetCurrPos()-1SetAlignment(ALIGN_LEFT, ALIGN_TOP); wifiTxt[0]->SetPosition(205,200+wifiY); @@ -729,7 +729,7 @@ int showGameInfo(char *ID) { synopsisTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); synopsisTxt->SetPosition(0,0); synopsisTxt->SetLinesToDraw(pagesize); - //synopsisTxt->SetFirstLine(12); + synopsisTxt->Refresh(); dialogBoxImg11 = new GuiImage(&dialogBox1); dialogBoxImg11->SetAlignment(0,3); @@ -809,84 +809,92 @@ int showGameInfo(char *ID) { backBtn.ResetState(); if (page==1) { choice=1; + if(synopsisTxt) + delete synopsisTxt; synopsisTxt = NULL; break; } else if (page==2) { HaltGui(); gameinfoWindow2.Remove(&nextBtn); gameinfoWindow2.Remove(&backBtn); - gameinfoWindow2.Remove(&homeBtn); - gameinfoWindow2.Remove(&screenShotBtn); - gameinfoWindow2.SetVisible(false); + gameinfoWindow2.Remove(&homeBtn); + gameinfoWindow2.Remove(&screenShotBtn); + gameinfoWindow2.SetVisible(false); gameinfoWindow.SetVisible(true); gameinfoWindow.Append(&backBtn); gameinfoWindow.Append(&nextBtn); - gameinfoWindow.Append(&homeBtn); - gameinfoWindow.Append(&screenShotBtn); - mainWindow->Remove(&gameinfoWindow2); + gameinfoWindow.Append(&homeBtn); + gameinfoWindow.Append(&screenShotBtn); + mainWindow->Remove(&gameinfoWindow2); ResumeGui(); page=1; } - } else if (((nextBtn.GetState()==STATE_CLICKED)||(nextBtn.GetState()==STATE_HELD))&& - (strcmp(gameinfo.synopsis,"") != 0)) { + } + else if (((nextBtn.GetState()==STATE_CLICKED)||(nextBtn.GetState()==STATE_HELD))&& + (strcmp(gameinfo.synopsis,"") != 0)) + { nextBtn.ResetState(); - if (page==1) { + + if (page==1) + { HaltGui(); gameinfoWindow.Remove(&nextBtn); gameinfoWindow.Remove(&backBtn); - gameinfoWindow.Remove(&homeBtn); - gameinfoWindow.Remove(&screenShotBtn); - gameinfoWindow.SetVisible(false); + gameinfoWindow.Remove(&homeBtn); + gameinfoWindow.Remove(&screenShotBtn); + gameinfoWindow.SetVisible(false); gameinfoWindow2.SetVisible(true); coverImg->SetPosition(15,30); gameinfoWindow2.Append(&nextBtn); gameinfoWindow2.Append(&backBtn); - gameinfoWindow2.Append(&homeBtn); - gameinfoWindow2.Append(&screenShotBtn); - mainWindow->Append(&gameinfoWindow2); + gameinfoWindow2.Append(&homeBtn); + gameinfoWindow2.Append(&screenShotBtn); + mainWindow->Append(&gameinfoWindow2); ResumeGui(); page=2; - } else { + } + else + { HaltGui(); gameinfoWindow2.Remove(&nextBtn); gameinfoWindow2.Remove(&backBtn); - gameinfoWindow2.Remove(&homeBtn); - gameinfoWindow2.Remove(&screenShotBtn); - gameinfoWindow2.SetVisible(false); + gameinfoWindow2.Remove(&homeBtn); + gameinfoWindow2.Remove(&screenShotBtn); + gameinfoWindow2.SetVisible(false); gameinfoWindow.SetVisible(true); gameinfoWindow.Append(&backBtn); gameinfoWindow.Append(&nextBtn); - gameinfoWindow.Append(&homeBtn); - gameinfoWindow.Append(&screenShotBtn); - mainWindow->Remove(&gameinfoWindow2); + gameinfoWindow.Append(&homeBtn); + gameinfoWindow.Append(&screenShotBtn); + mainWindow->Remove(&gameinfoWindow2); ResumeGui(); page=1; } - } else if ((upBtn.GetState()==STATE_CLICKED||upBtn.GetState()==STATE_HELD) && page==2) { - //int l=synopsisTxt->GetFirstLine()-1; - if (synopsisTxt->GetCurrPos()>1) - synopsisTxt->SetTextLine(synopsisTxt->GetCurrPos()-1); + } + else if ((upBtn.GetState() == STATE_CLICKED || upBtn.GetState() == STATE_HELD) && page == 2) + { + synopsisTxt->PreviousLine(); + usleep(60000); if (!((ButtonsHold() & WPAD_BUTTON_UP)||(ButtonsHold() & PAD_BUTTON_UP))) upBtn.ResetState(); - } else if ((dnBtn.GetState()==STATE_CLICKED||dnBtn.GetState()==STATE_HELD) && page==2 - &&synopsisTxt->GetTotalLinesCount()>pagesize - &&synopsisTxt->GetCurrPos()-1GetTotalLinesCount()-pagesize) { - int l=0; - //if(synopsisTxt->GetTotalLines()>pagesize) - l=synopsisTxt->GetCurrPos()+1; - //if (l>(synopsisTxt->GetTotalLines()+1)-pagesize) - //l=(synopsisTxt->GetTotalLines()+1)-pagesize; + } + else if ((dnBtn.GetState() == STATE_CLICKED || dnBtn.GetState() == STATE_HELD) && page==2) + { + synopsisTxt->NextLine(); - synopsisTxt->SetTextLine(l); usleep(60000); if (!((ButtonsHold() & WPAD_BUTTON_DOWN)||(ButtonsHold() & PAD_BUTTON_DOWN))) dnBtn.ResetState(); - } else if (homeBtn.GetState()==STATE_CLICKED) { + } + else if (homeBtn.GetState()==STATE_CLICKED) + { if (page==1) { choice=2; + if(synopsisTxt) + delete synopsisTxt; synopsisTxt = NULL; break; } else if (page==2) { @@ -1103,10 +1111,10 @@ bool save_XML_URL() { // save xml url as as txt file for people without wifi sleep(1); return false; } - + char XMLurl[3540]; build_XML_URL(XMLurl,sizeof(XMLurl)); - + fprintf(f, "# USB Loader Has Saved this file\n"); fprintf(f, "# This URL was created based on your list of games and language settings.\n"); fclose(f);