diff --git a/gui.pnproj b/gui.pnproj
index 621e2f15..4cd0f061 100644
--- a/gui.pnproj
+++ b/gui.pnproj
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/source/cheats/cheatmenu.cpp b/source/cheats/cheatmenu.cpp
index c4964e3e..ce8bed7e 100644
--- a/source/cheats/cheatmenu.cpp
+++ b/source/cheats/cheatmenu.cpp
@@ -76,7 +76,7 @@ int CheatMenu(const char * gameID)
case 1:
int cntcheats = c.getCnt();
OptionList cheatslst;
- GuiCustomOptionBrowser chtBrowser(400, 280, &cheatslst, "bg_options_settings.png", 1, 90);
+ GuiCustomOptionBrowser chtBrowser(400, 280, &cheatslst, "bg_options_settings.png");
chtBrowser.SetPosition(0, 90);
chtBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
chtBrowser.SetClickable(true);
diff --git a/source/homebrewboot/HomebrewBrowse.cpp b/source/homebrewboot/HomebrewBrowse.cpp
index 7d823952..f9bfb947 100644
--- a/source/homebrewboot/HomebrewBrowse.cpp
+++ b/source/homebrewboot/HomebrewBrowse.cpp
@@ -1,1045 +1,20 @@
-/****************************************************************************
- * HomebrewBrowse
- * USB Loader GX 2009
- *
- * Homebrew launcher for USB Loader GX
- *
- * homebrewbrowse.cpp
- ***************************************************************************/
-#include
-#include
-#include
-#include
-
-#include "language/gettext.h"
-#include "libwiigui/gui.h"
-#include "prompts/TitleBrowser.h"
-#include "prompts/PromptWindows.h"
-#include "prompts/ProgressWindow.h"
-#include "homebrewboot/HomebrewFiles.h"
-#include "homebrewboot/HomebrewXML.h"
-#include "homebrewboot/BootHomebrew.h"
-#include "network/networkops.h"
-#include "themes/CTheme.h"
-#include "menu.h"
-#include "menu/menus.h"
-#include "filelist.h"
-#include "sys.h"
-#include "network/http.h"
-#include "utils/minizip/miniunz.h"
-#include "usbloader/utils.h"
-
-/*** Extern functions ***/
-extern void ResumeGui();
-extern void HaltGui();
-
-/*** Extern variables ***/
-extern u32 infilesize;
-extern u32 uncfilesize;
-extern char wiiloadVersion[2];
-extern u8 shutdown;
-extern u8 reset;
-
-/****************************************************************************
- * roundup Function
- ***************************************************************************/
-int roundup(float number)
-{
- if (number == (int) number)
- return (int) number;
- else return (int) (number + 1);
-}
-
-static int ReceiveFile()
-{
- char filesizetxt[50];
- char temp[50];
- u32 filesize = 0;
-
- if (infilesize < MB_SIZE)
- snprintf(filesizetxt, sizeof(filesizetxt), tr( "Incoming file %0.2fKB" ), infilesize / KB_SIZE);
- else snprintf(filesizetxt, sizeof(filesizetxt), tr( "Incoming file %0.2fMB" ), infilesize / MB_SIZE);
-
- snprintf(temp, sizeof(temp), tr( "Load file from: %s ?" ), GetIncommingIP());
-
- int choice = WindowPrompt(filesizetxt, temp, tr( "OK" ), tr( "Cancel" ));
-
- if (choice == 0)
- return MENU_NONE;
-
- u32 read = 0;
- int len = NETWORKBLOCKSIZE;
- filesize = infilesize;
- u8 * buffer = (u8 *) malloc(infilesize);
- if(!buffer)
- {
- WindowPrompt(tr( "Not enough memory." ), 0, tr( "OK" ));
- return MENU_NONE;
- }
-
- bool error = false;
- while (read < infilesize)
- {
- ShowProgress(tr( "Receiving file from:" ), GetIncommingIP(), NULL, read, infilesize, true);
-
- if (infilesize - read < (u32) len)
- len = infilesize - read;
- else len = NETWORKBLOCKSIZE;
-
- int result = network_read(buffer+read, len);
-
- if (result < 0)
- {
- WindowPrompt(tr( "Error while transfering data." ), 0, tr( "OK" ));
- free(buffer);
- return MENU_NONE;
- }
- if (!result)
- {
- break;
- }
-
- read += result;
- }
-
- char filename[101];
- network_read((u8*) &filename, 100);
-
- // Do we need to unzip this thing?
- if (wiiloadVersion[0] > 0 || wiiloadVersion[1] > 4)
- {
- // We need to unzip...
- if (buffer[0] == 'P' && buffer[1] == 'K' && buffer[2] == 0x03 && buffer[3] == 0x04)
- {
- // It's a zip file, unzip to the apps directory
- // Zip archive, ask for permission to install the zip
- char zippath[255];
- sprintf((char *) &zippath, "%s%s", Settings.homebrewapps_path, filename);
-
- FILE *fp = fopen(zippath, "wb");
- if (!fp)
- {
- WindowPrompt(tr( "Error writing the data." ), 0, tr( "OK" ));
- return MENU_NONE;
- }
-
- fwrite(buffer, 1, infilesize, fp);
- fclose(fp);
-
- free(buffer);
- buffer = NULL;
-
- // Now unzip the zip file...
- unzFile uf = unzOpen(zippath);
- if (uf == NULL)
- {
- WindowPrompt(tr( "Error while opening the zip." ), 0, tr( "OK" ));
- return MENU_NONE;
- }
-
- extractZip(uf, 0, 1, 0, Settings.homebrewapps_path);
- unzCloseCurrentFile(uf);
-
- remove(zippath);
-
- WindowPrompt(tr( "Success:" ),
- tr( "Uploaded ZIP file installed to homebrew directory." ), tr( "OK" ));
-
- // Reload this menu here...
- return MENU_HOMEBREWBROWSE;
- }
- else if (uncfilesize != 0) // if uncfilesize == 0, it's not compressed
- {
- // It's compressed, uncompress
- u8 *unc = (u8 *) malloc(uncfilesize);
- uLongf f = uncfilesize;
- error = uncompress(unc, &f, buffer, infilesize) != Z_OK;
- uncfilesize = f;
- filesize = uncfilesize;
-
- free(buffer);
- buffer = unc;
- }
- }
-
- CopyHomebrewMemory(buffer, 0, filesize);
- free(buffer);
-
- ProgressStop();
-
- if (error || read != infilesize || strcasestr(filename, ".dol") || strcasestr(filename, ".elf"))
- {
- WindowPrompt(tr( "Error:" ), tr( "No data could be read." ), tr( "OK" ));
- FreeHomebrewBuffer();
- return MENU_NONE;
- }
-
- CloseConnection();
-
- AddBootArgument(filename);
-
- return BootHomebrewFromMem();
-}
+#include "HomebrewBrowser.hpp"
/****************************************************************************
* MenuHomebrewBrowse
***************************************************************************/
int MenuHomebrewBrowse()
{
- int menu = MENU_NONE;
- int choice = 0;
+ HomebrewBrowser * Menu = new HomebrewBrowser();
+ mainWindow->Append(Menu);
- HomebrewFiles HomebrewFiles(Settings.homebrewapps_path);
+ Menu->ShowMenu();
- u32 filecount = HomebrewFiles.GetFilecount();
+ int returnMenu = MENU_NONE;
- if (!filecount)
- {
- WindowPrompt(tr( "No .dol or .elf files found." ), 0, tr( "OK" ));
- return MENU_DISCLIST;
- }
+ while((returnMenu = Menu->MainLoop()) == MENU_NONE);
- enum
- {
- FADE, LEFT, RIGHT
- };
+ delete Menu;
- if (IsNetworkInit()) ResumeNetworkWait();
-
- int slidedirection = FADE;
-
- /*** Image Variables ***/
- GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
-
- GuiImageData bgData(Resources::GetFile("settings_background.png"), Resources::GetFileSize("settings_background.png"));
-
- GuiImageData MainButtonImgData(Resources::GetFile("settings_title.png"), Resources::GetFileSize("settings_title.png"));
-
- GuiImageData MainButtonImgOverData(Resources::GetFile("settings_title_over.png"), Resources::GetFileSize("settings_title_over.png"));
-
- GuiImageData arrow_left(Resources::GetFile("startgame_arrow_left.png"), Resources::GetFileSize("startgame_arrow_left.png"));
-
- GuiImageData arrow_right(Resources::GetFile("startgame_arrow_right.png"), Resources::GetFileSize("startgame_arrow_right.png"));
-
- GuiImageData wifiImgData(Resources::GetFile("Wifi_btn.png"), Resources::GetFileSize("Wifi_btn.png"));
-
- GuiImageData channelImgData(Resources::GetFile("Channel_btn.png"), Resources::GetFileSize("Channel_btn.png"));
-
- GuiImage background(&bgData);
-
- /*** Trigger Variables ***/
- GuiTrigger trigA;
- trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
- GuiTrigger trigHome;
- trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0);
- GuiTrigger trigB;
- trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
- GuiTrigger trigL;
- trigL.SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT);
- GuiTrigger trigR;
- trigR.SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT);
- GuiTrigger trigMinus;
- trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0);
- GuiTrigger trigPlus;
- trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0);
-
- GuiText titleTxt(tr( "Homebrew Launcher" ), 28, ( GXColor )
- { 0, 0, 0, 255});
- titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
- titleTxt.SetPosition(0, 40);
-
- GuiImageData *IconData[4];
- GuiImage *IconImg[4];
-
- for (int i = 0; i < 4; i++)
- {
- IconData[i] = NULL;
- IconImg[i] = NULL;
- }
- /*** Buttons ***/
-
- GuiText backBtnTxt(tr( "Back" ), 22, Theme.prompttext);
- backBtnTxt.SetMaxWidth(btnOutline.GetWidth() - 30);
- GuiImage backBtnImg(&btnOutline);
- if (Settings.wsprompt)
- {
- backBtnTxt.SetWidescreen(Settings.widescreen);
- backBtnImg.SetWidescreen(Settings.widescreen);
- }
- GuiButton backBtn(&backBtnImg, &backBtnImg, 2, 3, -180, 400, &trigA, btnSoundOver, btnSoundClick2, 1);
- backBtn.SetLabel(&backBtnTxt);
- backBtn.SetTrigger(&trigB);
-
- GuiButton homo(1, 1);
- homo.SetTrigger(&trigHome);
-
- GuiImage GoLeftImg(&arrow_left);
- GuiButton GoLeftBtn(GoLeftImg.GetWidth(), GoLeftImg.GetHeight());
- GoLeftBtn.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
- GoLeftBtn.SetPosition(25, -25);
- GoLeftBtn.SetImage(&GoLeftImg);
- GoLeftBtn.SetSoundOver(btnSoundOver);
- GoLeftBtn.SetSoundClick(btnSoundClick2);
- GoLeftBtn.SetEffectGrow();
- GoLeftBtn.SetTrigger(&trigA);
- GoLeftBtn.SetTrigger(&trigL);
- GoLeftBtn.SetTrigger(&trigMinus);
-
- GuiImage GoRightImg(&arrow_right);
- GuiButton GoRightBtn(GoRightImg.GetWidth(), GoRightImg.GetHeight());
- GoRightBtn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
- GoRightBtn.SetPosition(-25, -25);
- GoRightBtn.SetImage(&GoRightImg);
- GoRightBtn.SetSoundOver(btnSoundOver);
- GoRightBtn.SetSoundClick(btnSoundClick2);
- GoRightBtn.SetEffectGrow();
- GoRightBtn.SetTrigger(&trigA);
- GoRightBtn.SetTrigger(&trigR);
- GoRightBtn.SetTrigger(&trigPlus);
-
- char MainButtonText[50];
- snprintf(MainButtonText, sizeof(MainButtonText), "%s", " ");
-
- GuiImage MainButton1Img(&MainButtonImgData);
- GuiImage MainButton1ImgOver(&MainButtonImgOverData);
- GuiText MainButton1Txt(MainButtonText, 18, ( GXColor )
- { 0, 0, 0, 255});
- MainButton1Txt.SetMaxWidth(MainButton1Img.GetWidth() - 150, DOTTED);
- MainButton1Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
- MainButton1Txt.SetPosition(148, -12);
- GuiText MainButton1DescTxt(MainButtonText, 18, ( GXColor )
- { 0, 0, 0, 255});
- MainButton1DescTxt.SetMaxWidth(MainButton1Img.GetWidth() - 150, 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, SCROLL_HORIZONTAL);
- 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(&MainButton1DescTxt, 1);
- MainButton1.SetLabelOver(&MainButton1DescOverTxt, 1);
- MainButton1.SetSoundOver(btnSoundOver);
- MainButton1.SetSoundClick(btnSoundClick);
- MainButton1.SetEffectGrow();
- MainButton1.SetTrigger(&trigA);
-
- GuiImage MainButton2Img(&MainButtonImgData);
- GuiImage MainButton2ImgOver(&MainButtonImgOverData);
- GuiText MainButton2Txt(MainButtonText, 18, ( GXColor ) {0, 0, 0, 255});
- MainButton2Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
- MainButton2Txt.SetPosition(148, -12);
- MainButton2Txt.SetMaxWidth(MainButton2Img.GetWidth() - 150, DOTTED);
- GuiText MainButton2DescTxt(MainButtonText, 18, ( GXColor ) {0, 0, 0, 255});
- MainButton2DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
- MainButton2DescTxt.SetPosition(148, 15);
- MainButton2DescTxt.SetMaxWidth(MainButton2Img.GetWidth() - 150, 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, SCROLL_HORIZONTAL);
- 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(&MainButton2DescTxt, 1);
- MainButton2.SetLabelOver(&MainButton2DescOverTxt, 1);
- MainButton2.SetSoundOver(btnSoundOver);
- MainButton2.SetSoundClick(btnSoundClick);
- MainButton2.SetEffectGrow();
- MainButton2.SetTrigger(&trigA);
-
- GuiImage MainButton3Img(&MainButtonImgData);
- GuiImage MainButton3ImgOver(&MainButtonImgOverData);
- GuiText MainButton3Txt(MainButtonText, 18, ( GXColor ) {0, 0, 0, 255});
- MainButton3Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
- MainButton3Txt.SetPosition(148, -12);
- MainButton3Txt.SetMaxWidth(MainButton3Img.GetWidth() - 150, DOTTED);
- GuiText MainButton3DescTxt(MainButtonText, 18, ( GXColor ) {0, 0, 0, 255});
- MainButton3DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
- MainButton3DescTxt.SetPosition(148, 15);
- MainButton3DescTxt.SetMaxWidth(MainButton3Img.GetWidth() - 150, 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, SCROLL_HORIZONTAL);
- 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(&MainButton3DescTxt, 1);
- MainButton3.SetLabelOver(&MainButton3DescOverTxt, 1);
- MainButton3.SetSoundOver(btnSoundOver);
- MainButton3.SetSoundClick(btnSoundClick);
- MainButton3.SetEffectGrow();
- MainButton3.SetTrigger(&trigA);
-
- GuiImage MainButton4Img(&MainButtonImgData);
- GuiImage MainButton4ImgOver(&MainButtonImgOverData);
- GuiText MainButton4Txt(MainButtonText, 18, ( GXColor )
- { 0, 0, 0, 255});
- MainButton4Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
- MainButton4Txt.SetPosition(148, -12);
- MainButton4Txt.SetMaxWidth(MainButton4Img.GetWidth() - 150, DOTTED);
- GuiText MainButton4DescTxt(MainButtonText, 18, ( GXColor )
- { 0, 0, 0, 255});
- MainButton4DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
- MainButton4DescTxt.SetPosition(148, 15);
- MainButton4DescTxt.SetMaxWidth(MainButton4Img.GetWidth() - 150, 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, SCROLL_HORIZONTAL);
- 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(&MainButton4DescTxt, 1);
- MainButton4.SetLabelOver(&MainButton4DescOverTxt, 1);
- MainButton4.SetSoundOver(btnSoundOver);
- MainButton4.SetSoundClick(btnSoundClick);
- MainButton4.SetEffectGrow();
- MainButton4.SetTrigger(&trigA);
-
- GuiImage wifiImg(&wifiImgData);
- if (Settings.wsprompt)
- {
- wifiImg.SetWidescreen(Settings.widescreen);
- }
- GuiButton wifiBtn(wifiImg.GetWidth(), wifiImg.GetHeight());
- wifiBtn.SetImage(&wifiImg);
- wifiBtn.SetPosition(500, 400);
- wifiBtn.SetSoundOver(btnSoundOver);
- wifiBtn.SetSoundClick(btnSoundClick);
- wifiBtn.SetEffectGrow();
- wifiBtn.SetAlpha(80);
- wifiBtn.SetTrigger(&trigA);
-
- GuiImage channelBtnImg(&channelImgData);
- channelBtnImg.SetWidescreen(Settings.widescreen);
- GuiButton channelBtn(channelBtnImg.GetWidth(), channelBtnImg.GetHeight());
- channelBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
- channelBtn.SetPosition(440, 400);
- channelBtn.SetImage(&channelBtnImg);
- channelBtn.SetSoundOver(btnSoundOver);
- channelBtn.SetSoundClick(btnSoundClick2);
- channelBtn.SetEffectGrow();
- channelBtn.SetTrigger(&trigA);
-
- GuiTooltip * titleTT = NULL;
-
- GuiWindow w(screenwidth, screenheight);
-
- /*** XML Variables ***/
- HomebrewXML XMLInfo[4];
-
- int pageToDisplay = 1;
- const int pages = roundup(filecount / 4.0f);
- bool wifi_btn_loaded = false;
-
- while (menu == MENU_NONE) //set pageToDisplay to 0 to quit
- {
- VIDEO_WaitVSync();
-
- menu = MENU_NONE;
- bool changed = false;
- int fileoffset = pageToDisplay * 4 - 4;
-
- /** Standard procedure made in all pages **/
- MainButton1.StopEffect();
- MainButton2.StopEffect();
- MainButton3.StopEffect();
- MainButton4.StopEffect();
-
- if (slidedirection == RIGHT)
- {
- MainButton1.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 60);
- MainButton2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 60);
- MainButton3.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 60);
- MainButton4.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 60);
- while (MainButton1.GetEffect() > 0)
- usleep(50);
- }
- else if (slidedirection == LEFT)
- {
- MainButton1.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 60);
- MainButton2.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 60);
- MainButton3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 60);
- MainButton4.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 60);
- while (MainButton1.GetEffect() > 0)
- usleep(50);
- }
-
- HaltGui();
-
- mainWindow->RemoveAll();
-
- /** Set new icons **/
- for (int i = 0; i < 4; i++)
- {
- if (IconData[i] != NULL)
- {
- delete IconData[i];
- IconData[i] = NULL;
- }
- if (IconImg[i] != NULL)
- {
- delete IconImg[i];
- IconImg[i] = NULL;
- }
- if (fileoffset + i < (int) filecount)
- {
- char iconpath[200];
- snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset + i));
- IconData[i] = new GuiImageData(iconpath);
- if (IconData[i]->GetImage())
- {
- IconImg[i] = new GuiImage(IconData[i]);
- IconImg[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
- IconImg[i]->SetPosition(12, 0);
- IconImg[i]->SetScale(0.95);
- }
- }
- }
-
- if (IconImg[0] != 0)
- MainButton1.SetIcon(IconImg[0]);
- else MainButton1.SetIcon(NULL);
- if (IconImg[1] != 0)
- MainButton2.SetIcon(IconImg[1]);
- else MainButton2.SetIcon(NULL);
- if (IconImg[2] != 0)
- MainButton3.SetIcon(IconImg[2]);
- else MainButton3.SetIcon(NULL);
- if (IconImg[3] != 0)
- MainButton4.SetIcon(IconImg[3]);
- else MainButton4.SetIcon(NULL);
-
- mainWindow->Append(&w);
- w.RemoveAll();
- w.Append(&background);
- w.Append(&titleTxt);
- w.Append(&backBtn);
- w.Append(&homo);
- w.Append(&wifiBtn);
- w.Append(&channelBtn);
- w.Append(&GoRightBtn);
- w.Append(&GoLeftBtn);
-
- if (pageToDisplay == pages)
- {
- int buttonsleft = filecount - (pages - 1) * 4;
- char * shortpath = NULL;
- char temp[200];
-
- if (buttonsleft > 0)
- {
- snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset));
- if (XMLInfo[0].LoadHomebrewXMLData(temp) > 0)
- {
- MainButton1Txt.SetText(XMLInfo[0].GetName());
- MainButton1DescTxt.SetText(XMLInfo[0].GetShortDescription());
- MainButton1DescOverTxt.SetText(XMLInfo[0].GetShortDescription());
- }
- 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);
- }
- if (buttonsleft > 1)
- {
- snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset + 1));
- if (XMLInfo[1].LoadHomebrewXMLData(temp) > 0)
- {
- MainButton2Txt.SetText(XMLInfo[1].GetName());
- MainButton2DescTxt.SetText(XMLInfo[1].GetShortDescription());
- MainButton2DescOverTxt.SetText(XMLInfo[1].GetShortDescription());
- }
- 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);
- }
- if (buttonsleft > 2)
- {
- snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset + 2));
- if (XMLInfo[2].LoadHomebrewXMLData(temp) > 0)
- {
- MainButton3Txt.SetText(XMLInfo[2].GetName());
- MainButton3DescTxt.SetText(XMLInfo[2].GetShortDescription());
- MainButton3DescOverTxt.SetText(XMLInfo[2].GetShortDescription());
- }
- 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);
- }
- if (buttonsleft > 3)
- {
- snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset + 3));
- if (XMLInfo[3].LoadHomebrewXMLData(temp) > 0)
- {
- MainButton4Txt.SetText(XMLInfo[3].GetName());
- MainButton4DescTxt.SetText(XMLInfo[3].GetShortDescription());
- MainButton4DescOverTxt.SetText(XMLInfo[3].GetShortDescription());
- }
- 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);
- }
- }
- else
- {
- char temp[200];
- char *shortpath = NULL;
-
- 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);
-
- 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);
-
- snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset + 2));
- if (XMLInfo[2].LoadHomebrewXMLData(temp) > 0)
- {
- snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[2].GetName());
- MainButton3Txt.SetText(MainButtonText);
- snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[2].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);
-
- 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);
- }
-
- MainButton1.StopEffect();
- MainButton2.StopEffect();
- MainButton3.StopEffect();
- MainButton4.StopEffect();
-
- MainButton1.SetEffectGrow();
- MainButton2.SetEffectGrow();
- MainButton3.SetEffectGrow();
- MainButton4.SetEffectGrow();
-
- if (slidedirection == FADE)
- {
- MainButton1.SetEffect(EFFECT_FADE, 20);
- MainButton2.SetEffect(EFFECT_FADE, 20);
- MainButton3.SetEffect(EFFECT_FADE, 20);
- MainButton4.SetEffect(EFFECT_FADE, 20);
- }
- else if (slidedirection == LEFT)
- {
- MainButton1.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 60);
- MainButton2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 60);
- MainButton3.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 60);
- MainButton4.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 60);
- }
- else if (slidedirection == RIGHT)
- {
- MainButton1.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 60);
- MainButton2.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 60);
- MainButton3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 60);
- MainButton4.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 60);
- }
-
- mainWindow->Append(&w);
-
- ResumeGui();
-
- while (MainButton1.GetEffect() > 0)
- usleep(50);
-
- while (!changed)
- {
- VIDEO_WaitVSync();
-
- if (MainButton1.GetState() == STATE_CLICKED)
- {
- char temp[200];
- 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));
- shortpath = strrchr(temp, '/');
- snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset));
-
- int choice = HBCWindowPrompt(XMLInfo[0].GetName(), XMLInfo[0].GetCoder(), XMLInfo[0].GetVersion(),
- XMLInfo[0].GetReleasedate(), XMLInfo[0].GetLongDescription(), iconpath, filesize);
- if (choice == 1)
- {
- snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s",
- HomebrewFiles.GetFilepath(fileoffset), HomebrewFiles.GetFilename(fileoffset));
- BootHomebrew(Settings.selected_homebrew);
- break;
- }
- MainButton1.ResetState();
- }
- else if (MainButton2.GetState() == STATE_CLICKED)
- {
- char temp[200];
- 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);
- //write short filename
- 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(XMLInfo[1].GetName(), XMLInfo[1].GetCoder(), XMLInfo[1].GetVersion(),
- XMLInfo[1].GetReleasedate(), XMLInfo[1].GetLongDescription(), iconpath, filesize);
- if (choice == 1)
- {
- snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s",
- HomebrewFiles.GetFilepath(fileoffset + 1), HomebrewFiles.GetFilename(fileoffset + 1));
- BootHomebrew(Settings.selected_homebrew);
- break;
- }
- MainButton2.ResetState();
- }
- else if (MainButton3.GetState() == STATE_CLICKED)
- {
- 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);
- //write short filename
- 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(XMLInfo[2].GetName(), XMLInfo[2].GetCoder(), XMLInfo[2].GetVersion(),
- XMLInfo[2].GetReleasedate(), XMLInfo[2].GetLongDescription(), iconpath, filesize);
- if (choice == 1)
- {
- snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s",
- HomebrewFiles.GetFilepath(fileoffset + 2), HomebrewFiles.GetFilename(fileoffset + 2));
- BootHomebrew(Settings.selected_homebrew);
- break;
- }
- MainButton3.ResetState();
- }
- else if (MainButton4.GetState() == STATE_CLICKED)
- {
- 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);
- //write short filename
- 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(XMLInfo[3].GetName(), XMLInfo[3].GetCoder(), XMLInfo[3].GetVersion(),
- XMLInfo[3].GetReleasedate(), XMLInfo[3].GetLongDescription(), iconpath, filesize);
- if (choice == 1)
- {
- snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s",
- HomebrewFiles.GetFilepath(fileoffset + 3), HomebrewFiles.GetFilename(fileoffset + 3));
- BootHomebrew(Settings.selected_homebrew);
- break;
- }
- MainButton4.ResetState();
- }
-
- else if (shutdown == 1)
- Sys_Shutdown();
- else if (reset == 1)
- Sys_Reboot();
-
- else if (backBtn.GetState() == STATE_CLICKED)
- {
- menu = MENU_DISCLIST;
- changed = true;
- }
-
- else if (GoLeftBtn.GetState() == STATE_CLICKED)
- {
- pageToDisplay--;
- /** Change direction of the flying buttons **/
- if (pageToDisplay < 1) pageToDisplay = pages;
- slidedirection = LEFT;
- changed = true;
- GoLeftBtn.ResetState();
- }
-
- else if (GoRightBtn.GetState() == STATE_CLICKED)
- {
- pageToDisplay++;
- /** Change direction of the flying buttons **/
- if (pageToDisplay > pages) pageToDisplay = 1;
- slidedirection = RIGHT;
- changed = true;
- GoRightBtn.ResetState();
- }
-
- else if (wifiBtn.GetState() == STATE_CLICKED)
- {
-
- ResumeNetworkWait();
- wifiBtn.ResetState();
- }
-
- else if (homo.GetState() == STATE_CLICKED)
- {
- Settings.Save();
- bgMusic->Pause();
- choice = WindowExitPrompt();
- bgMusic->Resume();
-
- if (choice == 3)
- {
- Sys_LoadMenu(); // Back to System Menu
- }
- else if (choice == 2)
- {
- Sys_BackToLoader();
- }
- else
- {
- homo.ResetState();
- }
- }
-
- else if (infilesize > 0)
- {
- menu = ReceiveFile();
- CloseConnection();
- ResumeNetworkWait();
- }
-
- else if (channelBtn.GetState() == STATE_CLICKED)
- {
- w.SetState(STATE_DISABLED);
- //10001 are the channels that are installed as channels, not including shop channel/mii channel etc
- TitleBrowser();
- //if they didn't boot a channel reset this window
- w.SetState(STATE_DEFAULT);
- channelBtn.ResetState();
-
- }
-
- if (IsNetworkInit())
- {
- if (!wifi_btn_loaded)
- {
- wifiBtn.SetAlpha(255);
-
- titleTT = new GuiTooltip(GetNetworkIP());
- titleTT->SetAlpha(Theme.tooltipAlpha);
- wifiBtn.SetToolTip(titleTT, 0, -50, 0, 5);
- wifi_btn_loaded = true;
- }
- }
- }
- }
-
- w.SetEffect(EFFECT_FADE, -20);
- while (w.GetEffect() > 0)
- usleep(50);
-
- HaltGui();
-
- for (int i = 0; i < 4; i++)
- {
- if (IconData[i] != NULL)
- {
- delete IconData[i];
- IconData[i] = NULL;
- }
- if (IconImg[i] != NULL)
- {
- delete IconImg[i];
- IconImg[i] = NULL;
- }
- }
-
- delete titleTT;
- titleTT = NULL;
-
- if (IsNetworkInit()) HaltNetworkThread();
-
- mainWindow->RemoveAll();
- mainWindow->Append(bgImg);
-
- ResumeGui();
-
- return menu;
+ return returnMenu;
}
diff --git a/source/homebrewboot/HomebrewBrowser.cpp b/source/homebrewboot/HomebrewBrowser.cpp
new file mode 100644
index 00000000..807d14a5
--- /dev/null
+++ b/source/homebrewboot/HomebrewBrowser.cpp
@@ -0,0 +1,389 @@
+/****************************************************************************
+ * Copyright (C) 2010
+ * by Dimok
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty. In no event will the authors be held liable for any
+ * damages arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any
+ * purpose, including commercial applications, and to alter it and
+ * redistribute it freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you
+ * must not claim that you wrote the original software. If you use
+ * this software in a product, an acknowledgment in the product
+ * documentation would be appreciated but is not required.
+ *
+ * 2. Altered source versions must be plainly marked as such, and
+ * must not be misrepresented as being the original software.
+ *
+ * 3. This notice may not be removed or altered from any source
+ * distribution.
+ ***************************************************************************/
+#include "HomebrewBrowser.hpp"
+#include "themes/CTheme.h"
+#include "prompts/PromptWindows.h"
+#include "language/gettext.h"
+#include "network/networkops.h"
+#include "utils/minizip/miniunz.h"
+#include "usbloader/utils.h"
+#include "prompts/TitleBrowser.h"
+#include "homebrewboot/BootHomebrew.h"
+#include "prompts/ProgressWindow.h"
+#include "wstring.hpp"
+#include "HomebrewXML.h"
+
+extern u32 infilesize;
+extern u32 uncfilesize;
+extern char wiiloadVersion[2];
+
+HomebrewBrowser::HomebrewBrowser()
+ : FlyingButtonsMenu(tr( "Homebrew Launcher" ))
+{
+ HomebrewList = new HomebrewFiles(Settings.homebrewapps_path);
+
+ if (IsNetworkInit())
+ ResumeNetworkWait();
+
+ wifiNotSet = true;
+ wifiImgData = Resources::GetImageData("Wifi_btn.png");
+ wifiToolTip = new GuiTooltip(" ");
+ wifiImg = new GuiImage(wifiImgData);
+ wifiBtn = new GuiButton(wifiImgData->GetWidth(), wifiImgData->GetHeight());
+ wifiBtn->SetImage(wifiImg);
+ wifiBtn->SetPosition(300, 400);
+ wifiBtn->SetSoundOver(btnSoundOver);
+ wifiBtn->SetSoundClick(btnSoundClick);
+ wifiBtn->SetEffectGrow();
+ wifiBtn->SetAlpha(80);
+ wifiBtn->SetTrigger(trigA);
+ Append(wifiBtn);
+
+ channelImgData = Resources::GetImageData("Channel_btn.png");
+ channelBtnImg = new GuiImage(channelImgData);
+ channelBtnImg->SetWidescreen(Settings.widescreen);
+ channelBtn = new GuiButton(channelBtnImg->GetWidth(), channelBtnImg->GetHeight());
+ channelBtn->SetPosition(240, 400);
+ channelBtn->SetImage(channelBtnImg);
+ channelBtn->SetSoundOver(btnSoundOver);
+ channelBtn->SetSoundClick(btnSoundClick2);
+ channelBtn->SetEffectGrow();
+ channelBtn->SetTrigger(trigA);
+ Append(channelBtn);
+
+ MainButtonDesc.resize(HomebrewList->GetFilecount());
+ MainButtonDescOver.resize(HomebrewList->GetFilecount());
+
+ for(u32 i = 0; i < 4; ++i)
+ {
+ IconImgData[i] = NULL;
+ IconImg[i] = NULL;
+ }
+
+ for(int i = 0; i < HomebrewList->GetFilecount(); ++i)
+ {
+ MainButtonDesc[i] = new GuiText((char *) NULL, 18, (GXColor) {0, 0, 0, 255});
+ MainButtonDesc[i]->SetMaxWidth(MainButtonImgData->GetWidth() - 150, DOTTED);
+ MainButtonDesc[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
+ MainButtonDesc[i]->SetPosition(148, 15);
+
+ MainButtonDescOver[i] = new GuiText((char *) NULL, 18, (GXColor) {0, 0, 0, 255});
+ MainButtonDescOver[i]->SetMaxWidth(MainButtonImgData->GetWidth() - 150, SCROLL_HORIZONTAL);
+ MainButtonDescOver[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
+ MainButtonDescOver[i]->SetPosition(148, 15);
+ }
+
+ SetupMainButtons();
+}
+
+HomebrewBrowser::~HomebrewBrowser()
+{
+ HaltGui();
+ delete HomebrewList;
+
+ Remove(wifiBtn);
+ delete wifiImgData;
+ delete wifiImg;
+ delete wifiToolTip;
+ delete wifiBtn;
+
+ Remove(channelBtn);
+ delete channelImgData;
+ delete channelBtnImg;
+ delete channelBtn;
+
+ for(u32 i = 0; i < MainButtonDesc.size(); ++i)
+ {
+ delete MainButtonDesc[i];
+ delete MainButtonDescOver[i];
+ MainButton[i]->SetLabel(NULL, 1);
+ MainButton[i]->SetLabelOver(NULL, 1);
+ }
+
+ if (IsNetworkInit())
+ HaltNetworkThread();
+}
+
+void HomebrewBrowser::AddMainButtons()
+{
+ HaltGui();
+
+ for(u32 i = 0; i < 4; ++i)
+ {
+ if(IconImgData[i])
+ delete IconImgData[i];
+ if(IconImg[i])
+ delete IconImg[i];
+ IconImgData[i] = NULL;
+ IconImg[i] = NULL;
+ }
+
+ for(u32 i = 0; i < MainButton.size(); ++i)
+ MainButton[i]->SetIcon(NULL);
+
+ char iconpath[200];
+ int FirstItem = currentPage*DISPLAY_BUTTONS;
+
+ for(int i = FirstItem, n = 0; i < (int) MainButton.size() && i < FirstItem+DISPLAY_BUTTONS; ++i, ++n)
+ {
+ snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewList->GetFilepath(i));
+ IconImgData[n] = new GuiImageData(iconpath);
+ IconImg[n] = new GuiImage(IconImgData[n]);
+ IconImg[n]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
+ IconImg[n]->SetPosition(12, 0);
+ IconImg[n]->SetScale(0.95);
+ MainButton[i]->SetIcon(IconImg[n]);
+ }
+
+ FlyingButtonsMenu::AddMainButtons();
+}
+
+void HomebrewBrowser::SetupMainButtons()
+{
+ HomebrewXML MetaXML;
+ char metapath[200];
+
+ for(int i = 0; i < HomebrewList->GetFilecount(); ++i)
+ {
+ const char * HomebrewName = NULL;
+ snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewList->GetFilepath(i));
+
+ if (MetaXML.LoadHomebrewXMLData(metapath) > 0)
+ {
+ HomebrewName = MetaXML.GetName();
+ MainButtonDesc[i]->SetText(MetaXML.GetShortDescription());
+ MainButtonDescOver[i]->SetText(MetaXML.GetShortDescription());
+ }
+ else
+ {
+ const char * shortpath = strrchr(HomebrewList->GetFilename(i), '/');
+ if(shortpath)
+ {
+ snprintf(metapath, sizeof(metapath), "%s/%s", shortpath, HomebrewList->GetFilename(i));
+ HomebrewName = metapath;
+ }
+ else
+ HomebrewName = HomebrewList->GetFilename(i);
+ MainButtonDesc[i]->SetText(" ");
+ MainButtonDescOver[i]->SetText(" ");
+ }
+
+ SetMainButton(i, HomebrewName, MainButtonImgData, MainButtonImgOverData);
+
+ MainButtonTxt[i]->SetFontSize(18);
+ MainButtonTxt[i]->SetMaxWidth(MainButtonImgData->GetWidth() - 150, DOTTED);
+ MainButtonTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
+ MainButtonTxt[i]->SetPosition(148, -12);
+ MainButton[i]->SetLabel(MainButtonDesc[i], 1);
+ MainButton[i]->SetLabelOver(MainButtonDescOver[i], 1);
+ }
+}
+
+int HomebrewBrowser::MainLoop()
+{
+ if (IsNetworkInit() && wifiNotSet)
+ {
+ wifiToolTip->SetText(GetNetworkIP());
+ wifiBtn->SetAlpha(255);
+ wifiBtn->SetToolTip(wifiToolTip, 0, -50, 0, 5);
+ wifiNotSet = false;
+ }
+
+ if(wifiBtn->GetState() == STATE_CLICKED)
+ {
+ ResumeNetworkWait();
+ wifiBtn->ResetState();
+ }
+ else if(channelBtn->GetState() == STATE_CLICKED)
+ {
+ SetState(STATE_DISABLED);
+ TitleBrowser();
+ SetState(STATE_DEFAULT);
+ channelBtn->ResetState();
+ }
+ else if (infilesize > 0)
+ {
+ int menu = ReceiveFile();
+ if(menu != MENU_NONE)
+ return menu;
+ CloseConnection();
+ ResumeNetworkWait();
+ }
+
+ return FlyingButtonsMenu::MainLoop();
+}
+
+//! Callback for MainButton clicked
+void HomebrewBrowser::MainButtonClicked(int button)
+{
+ HomebrewXML MetaXML;
+ char metapath[200];
+ snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewList->GetFilepath(button));
+ MetaXML.LoadHomebrewXMLData(metapath);
+
+ u64 filesize = HomebrewList->GetFilesize(button);
+
+ wString HomebrewName(MainButtonTxt[button]->GetText());
+
+ int choice = HBCWindowPrompt(HomebrewName.toUTF8().c_str(), MetaXML.GetCoder(), MetaXML.GetVersion(),
+ MetaXML.GetReleasedate(), MetaXML.GetLongDescription(), IconImgData[button % 4], filesize);
+
+ if (choice == 1)
+ {
+ char homebrewpath[200];
+ snprintf(homebrewpath, sizeof(homebrewpath), "%s%s", HomebrewList->GetFilepath(button), HomebrewList->GetFilename(button));
+ BootHomebrew(homebrewpath);
+ }
+}
+
+int HomebrewBrowser::ReceiveFile()
+{
+ char filesizetxt[50];
+ char temp[50];
+ u32 filesize = 0;
+
+ if (infilesize < MB_SIZE)
+ snprintf(filesizetxt, sizeof(filesizetxt), tr( "Incoming file %0.2fKB" ), infilesize / KB_SIZE);
+ else snprintf(filesizetxt, sizeof(filesizetxt), tr( "Incoming file %0.2fMB" ), infilesize / MB_SIZE);
+
+ snprintf(temp, sizeof(temp), tr( "Load file from: %s ?" ), GetIncommingIP());
+
+ int choice = WindowPrompt(filesizetxt, temp, tr( "OK" ), tr( "Cancel" ));
+
+ if (choice == 0)
+ return MENU_NONE;
+
+ u32 read = 0;
+ int len = NETWORKBLOCKSIZE;
+ filesize = infilesize;
+ u8 * buffer = (u8 *) malloc(infilesize);
+ if(!buffer)
+ {
+ WindowPrompt(tr( "Not enough memory." ), 0, tr( "OK" ));
+ return MENU_NONE;
+ }
+
+ bool error = false;
+ while (read < infilesize)
+ {
+ ShowProgress(tr( "Receiving file from:" ), GetIncommingIP(), NULL, read, infilesize, true);
+
+ if (infilesize - read < (u32) len)
+ len = infilesize - read;
+ else len = NETWORKBLOCKSIZE;
+
+ int result = network_read(buffer+read, len);
+
+ if (result < 0)
+ {
+ WindowPrompt(tr( "Error while transfering data." ), 0, tr( "OK" ));
+ free(buffer);
+ return MENU_NONE;
+ }
+ if (!result)
+ {
+ break;
+ }
+
+ read += result;
+ }
+
+ char filename[101];
+ network_read((u8*) &filename, 100);
+
+ // Do we need to unzip this thing?
+ if (wiiloadVersion[0] > 0 || wiiloadVersion[1] > 4)
+ {
+ // We need to unzip...
+ if (buffer[0] == 'P' && buffer[1] == 'K' && buffer[2] == 0x03 && buffer[3] == 0x04)
+ {
+ // It's a zip file, unzip to the apps directory
+ // Zip archive, ask for permission to install the zip
+ char zippath[255];
+ sprintf((char *) &zippath, "%s%s", Settings.homebrewapps_path, filename);
+
+ FILE *fp = fopen(zippath, "wb");
+ if (!fp)
+ {
+ WindowPrompt(tr( "Error writing the data." ), 0, tr( "OK" ));
+ return MENU_NONE;
+ }
+
+ fwrite(buffer, 1, infilesize, fp);
+ fclose(fp);
+
+ free(buffer);
+ buffer = NULL;
+
+ // Now unzip the zip file...
+ unzFile uf = unzOpen(zippath);
+ if (uf == NULL)
+ {
+ WindowPrompt(tr( "Error while opening the zip." ), 0, tr( "OK" ));
+ return MENU_NONE;
+ }
+
+ extractZip(uf, 0, 1, 0, Settings.homebrewapps_path);
+ unzCloseCurrentFile(uf);
+
+ remove(zippath);
+
+ WindowPrompt(tr( "Success:" ),
+ tr( "Uploaded ZIP file installed to homebrew directory." ), tr( "OK" ));
+
+ // Reload this menu here...
+ return MENU_HOMEBREWBROWSE;
+ }
+ else if (uncfilesize != 0) // if uncfilesize == 0, it's not compressed
+ {
+ // It's compressed, uncompress
+ u8 *unc = (u8 *) malloc(uncfilesize);
+ uLongf f = uncfilesize;
+ error = uncompress(unc, &f, buffer, infilesize) != Z_OK;
+ uncfilesize = f;
+ filesize = uncfilesize;
+
+ free(buffer);
+ buffer = unc;
+ }
+ }
+
+ CopyHomebrewMemory(buffer, 0, filesize);
+ free(buffer);
+
+ ProgressStop();
+
+ if (error || read != infilesize || strcasestr(filename, ".dol") || strcasestr(filename, ".elf"))
+ {
+ WindowPrompt(tr( "Error:" ), tr( "No data could be read." ), tr( "OK" ));
+ FreeHomebrewBuffer();
+ return MENU_NONE;
+ }
+
+ CloseConnection();
+
+ AddBootArgument(filename);
+
+ return BootHomebrewFromMem();
+}
diff --git a/source/homebrewboot/HomebrewBrowser.hpp b/source/homebrewboot/HomebrewBrowser.hpp
new file mode 100644
index 00000000..7f622d0b
--- /dev/null
+++ b/source/homebrewboot/HomebrewBrowser.hpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+ * Copyright (C) 2010
+ * by Dimok
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty. In no event will the authors be held liable for any
+ * damages arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any
+ * purpose, including commercial applications, and to alter it and
+ * redistribute it freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you
+ * must not claim that you wrote the original software. If you use
+ * this software in a product, an acknowledgment in the product
+ * documentation would be appreciated but is not required.
+ *
+ * 2. Altered source versions must be plainly marked as such, and
+ * must not be misrepresented as being the original software.
+ *
+ * 3. This notice may not be removed or altered from any source
+ * distribution.
+ ***************************************************************************/
+#ifndef HOMEBREWBROWSER_HPP_
+#define HOMEBREWBROWSER_HPP_
+
+#include "settings/menus/FlyingButtonsMenu.hpp"
+#include "HomebrewFiles.h"
+
+#define DISPLAY_BUTTONS 4
+
+class HomebrewBrowser : public FlyingButtonsMenu
+{
+ public:
+ HomebrewBrowser();
+ ~HomebrewBrowser();
+ virtual int MainLoop();
+ protected:
+ void MainButtonClicked(int index);
+ int ReceiveFile();
+ virtual void CreateSettingsMenu(int index) { MainButtonClicked(index); };
+ virtual void DeleteSettingsMenu() { };
+ virtual void SetupMainButtons();
+ virtual void AddMainButtons();
+
+ HomebrewFiles * HomebrewList;
+ GuiImageData * IconImgData[DISPLAY_BUTTONS];
+ GuiImage * IconImg[DISPLAY_BUTTONS];
+ std::vector MainButtonDesc;
+ std::vector MainButtonDescOver;
+
+ bool wifiNotSet;
+ GuiTooltip * wifiToolTip;
+ GuiImageData * wifiImgData;
+ GuiImage * wifiImg;
+ GuiButton * wifiBtn;
+
+ GuiImageData * channelImgData;
+ GuiImage * channelBtnImg;
+ GuiButton * channelBtn;
+};
+
+#endif
diff --git a/source/homebrewboot/HomebrewFiles.cpp b/source/homebrewboot/HomebrewFiles.cpp
index cdf36bfd..4b6e46c1 100644
--- a/source/homebrewboot/HomebrewFiles.cpp
+++ b/source/homebrewboot/HomebrewFiles.cpp
@@ -115,11 +115,6 @@ unsigned int HomebrewFiles::GetFilesize(int ind)
else return FileInfo[ind].FileSize;
}
-int HomebrewFiles::GetFilecount()
-{
- return filecount;
-}
-
static int ListCompare(const void *a, const void *b)
{
FileInfos *ab = (FileInfos*) a;
diff --git a/source/homebrewboot/HomebrewFiles.h b/source/homebrewboot/HomebrewFiles.h
index dca244ff..d2bcb259 100644
--- a/source/homebrewboot/HomebrewFiles.h
+++ b/source/homebrewboot/HomebrewFiles.h
@@ -35,7 +35,7 @@ class HomebrewFiles
//!\param list index
unsigned int GetFilesize(int index);
//! Get the filecount of the whole list
- int GetFilecount();
+ int GetFilecount() { return filecount; };
//! Sort list by filepath
void SortList();
protected:
diff --git a/source/homebrewboot/HomebrewXML.cpp b/source/homebrewboot/HomebrewXML.cpp
index f5a2e25e..34b19cc3 100644
--- a/source/homebrewboot/HomebrewXML.cpp
+++ b/source/homebrewboot/HomebrewXML.cpp
@@ -13,16 +13,6 @@
#define ENTRIE_SIZE 8192
-/* Initializes a new instance of the HomebrewXML class. */
-HomebrewXML::HomebrewXML()
-{
-}
-
-/* Finalizes an instance of the HomebrewXML class. */
-HomebrewXML::~HomebrewXML()
-{
-}
-
/* qparam filename Filepath of the XML file */
int HomebrewXML::LoadHomebrewXMLData(const char* filename)
{
diff --git a/source/homebrewboot/HomebrewXML.h b/source/homebrewboot/HomebrewXML.h
index f890b2d5..6032fd02 100644
--- a/source/homebrewboot/HomebrewXML.h
+++ b/source/homebrewboot/HomebrewXML.h
@@ -10,8 +10,8 @@
class HomebrewXML
{
public:
- HomebrewXML();
- ~HomebrewXML();
+ HomebrewXML() { };
+ HomebrewXML(const char* filename) { LoadHomebrewXMLData(filename); };
int LoadHomebrewXMLData(const char* filename);
diff --git a/source/libwiigui/gui_customoptionbrowser.cpp b/source/libwiigui/gui_customoptionbrowser.cpp
index 0527717a..e228fa2b 100644
--- a/source/libwiigui/gui_customoptionbrowser.cpp
+++ b/source/libwiigui/gui_customoptionbrowser.cpp
@@ -22,17 +22,17 @@
/**
* Constructor for the GuiCustomOptionBrowser class.
*/
-GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, OptionList * l, const char * custombg, int scrollon, int col2)
+GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, OptionList * l, const char * custombg)
{
width = w;
height = h;
options = l;
- scrollbaron = scrollon;
selectable = true;
- listOffset = this->FindMenuItem(-1, 1);
selectedItem = 0;
focus = 1; // allow focus
- coL2 = col2;
+ coL2 = 50;
+ scrollbaron = false;
+ listOffset = 0;
trigA = new GuiTrigger;
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
@@ -105,17 +105,17 @@ GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, OptionList * l, con
for (int i = 0; i < PAGESIZE; i++)
{
- optionTxt[i] = new GuiText(options->GetName(i), 20, Theme.settingstext);
+ optionTxt[i] = new GuiText((wchar_t *) NULL, 20, Theme.settingstext);
optionTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
optionTxt[i]->SetPosition(24, 0);
optionTxt[i]->SetMaxWidth(bgOptionsImg->GetWidth() - (coL2 + 24), DOTTED);
optionBg[i] = new GuiImage(bgOptionsEntry);
- optionVal[i] = new GuiText((char *) NULL, 20, Theme.settingstext);
+ optionVal[i] = new GuiText((wchar_t *) NULL, 20, Theme.settingstext);
optionVal[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
- optionValOver[i] = new GuiText((char *) NULL, 20, Theme.settingstext);
+ optionValOver[i] = new GuiText((wchar_t *) NULL, 20, Theme.settingstext);
optionValOver[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
optionBtn[i] = new GuiButton(width - 28, GAMESELECTSIZE);
@@ -128,9 +128,7 @@ GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, OptionList * l, con
optionBtn[i]->SetRumble(false);
optionBtn[i]->SetTrigger(trigA);
optionBtn[i]->SetSoundClick(btnSoundClick);
-
}
- UpdateListEntries();
}
/**
@@ -199,31 +197,28 @@ void GuiCustomOptionBrowser::ResetState()
int GuiCustomOptionBrowser::GetClickedOption()
{
- int found = -1;
for (int i = 0; i < PAGESIZE; i++)
{
if (optionBtn[i]->GetState() == STATE_CLICKED)
{
optionBtn[i]->SetState(STATE_SELECTED);
- found = optionIndex[i];
- break;
+ return optionIndex[i];
}
}
- return found;
+
+ return -1;
}
int GuiCustomOptionBrowser::GetSelectedOption()
{
- int found = -1;
for (int i = 0; i < PAGESIZE; i++)
{
if (optionBtn[i]->GetState() == STATE_SELECTED)
{
- found = optionIndex[i];
- break;
+ return optionIndex[i];
}
}
- return found;
+ return -1;
}
void GuiCustomOptionBrowser::SetClickable(bool enable)
@@ -234,11 +229,6 @@ void GuiCustomOptionBrowser::SetClickable(bool enable)
}
}
-void GuiCustomOptionBrowser::SetScrollbar(int enable)
-{
- scrollbaron = enable;
-}
-
void GuiCustomOptionBrowser::SetOffset(int optionnumber)
{
listOffset = optionnumber;
@@ -259,7 +249,8 @@ int GuiCustomOptionBrowser::FindMenuItem(int currentItem, int direction)
if (strlen(options->GetName(nextItem)) > 0)
return nextItem;
- else return FindMenuItem(nextItem, direction);
+
+ return FindMenuItem(nextItem, direction);
}
/**
@@ -283,7 +274,7 @@ void GuiCustomOptionBrowser::Draw()
else break;
}
- if (scrollbaron == 1)
+ if (PAGESIZE < options->GetLength())
{
scrollbarImg->Draw();
arrowUpBtn->Draw();
@@ -295,6 +286,7 @@ void GuiCustomOptionBrowser::Draw()
void GuiCustomOptionBrowser::UpdateListEntries()
{
+ LOCK(this);
scrollbaron = options->GetLength() > PAGESIZE;
if (listOffset < 0) listOffset = this->FindMenuItem(-1, 1);
int next = listOffset;
@@ -324,7 +316,10 @@ void GuiCustomOptionBrowser::UpdateListEntries()
optionBtn[i]->SetState(STATE_DISABLED);
}
}
- if (coL2 < (24 + maxNameWidth + 16)) coL2 = 24 + maxNameWidth + 16;
+
+ if (coL2 < (24 + maxNameWidth + 16))
+ coL2 = 24 + maxNameWidth + 16;
+
for (int i = 0; i < PAGESIZE; i++)
{
if (optionBtn[i]->GetState() != STATE_DISABLED)
@@ -340,18 +335,12 @@ void GuiCustomOptionBrowser::UpdateListEntries()
void GuiCustomOptionBrowser::Update(GuiTrigger * t)
{
- int next, prev, lang = options->GetLength();
-
if (state == STATE_DISABLED || !t) return;
- if (options->IsChanged())
- {
- coL2 = 0;
- UpdateListEntries();
- }
+ int next, prev, length = options->GetLength();
int old_listOffset = listOffset;
- if (scrollbaron == 1)
+ if (length < PAGESIZE)
{
// update the location of the scroll box based on the position in the option list
arrowUpBtn->Update(t);
@@ -359,11 +348,14 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
scrollbarBoxBtn->Update(t);
}
+ if(options->IsChanged())
+ UpdateListEntries();
+
next = listOffset;
- u32 buttonshold = ButtonsHold();
-
- if (buttonshold != WPAD_BUTTON_UP && buttonshold != WPAD_BUTTON_DOWN)
+ if (!(t->wpad.btns_h & WPAD_BUTTON_UP || t->wpad.btns_h & WPAD_BUTTON_DOWN ||
+ t->wpad.btns_h & WPAD_CLASSIC_BUTTON_UP || t->wpad.btns_h & WPAD_CLASSIC_BUTTON_DOWN ||
+ t->pad.btns_h & PAD_BUTTON_UP || t->pad.btns_h & PAD_BUTTON_DOWN))
{
for (int i = 0; i < PAGESIZE; i++)
{
@@ -432,104 +424,106 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
}
}
- if (scrollbaron == 1)
+ if (!scrollbaron)
+ return;
+
+ if (arrowDownBtn->GetState() == STATE_CLICKED || arrowDownBtn->GetState() == STATE_HELD)
{
- if (arrowDownBtn->GetState() == STATE_CLICKED || arrowDownBtn->GetState() == STATE_HELD)
+ next = this->FindMenuItem(optionIndex[selectedItem], 1);
+
+ if (next >= 0)
{
-
- next = this->FindMenuItem(optionIndex[selectedItem], 1);
-
- if (next >= 0)
+ if (selectedItem == PAGESIZE - 1)
{
- if (selectedItem == PAGESIZE - 1)
- {
- // move list down by 1
- listOffset = this->FindMenuItem(listOffset, 1);
- }
- else if (optionBtn[selectedItem + 1]->IsVisible())
- {
- optionBtn[selectedItem]->ResetState();
- optionBtn[selectedItem + 1]->SetState(STATE_SELECTED, t->chan);
- selectedItem++;
- }
- scrollbarBoxBtn->Draw();
- usleep(35000);
+ // move list down by 1
+ listOffset = this->FindMenuItem(listOffset, 1);
}
- if (buttonshold != WPAD_BUTTON_A)
+ else if (optionBtn[selectedItem + 1]->IsVisible())
{
- arrowDownBtn->ResetState();
+ optionBtn[selectedItem]->ResetState();
+ optionBtn[selectedItem + 1]->SetState(STATE_SELECTED, t->chan);
+ selectedItem++;
}
+ scrollbarBoxBtn->Draw();
+ usleep(35000);
}
- else if (arrowUpBtn->GetState() == STATE_CLICKED || arrowUpBtn->GetState() == STATE_HELD)
+ if (!(t->wpad.btns_h & WPAD_BUTTON_A || t->wpad.btns_h & WPAD_CLASSIC_BUTTON_A ||
+ t->pad.btns_h & PAD_BUTTON_A))
{
- prev = this->FindMenuItem(optionIndex[selectedItem], -1);
-
- if (prev >= 0)
- {
- if (selectedItem == 0)
- {
- // move list up by 1
- listOffset = prev;
- }
- else
- {
- optionBtn[selectedItem]->ResetState();
- optionBtn[selectedItem - 1]->SetState(STATE_SELECTED, t->chan);
- selectedItem--;
- }
- scrollbarBoxBtn->Draw();
- usleep(35000);
- }
- if (buttonshold != WPAD_BUTTON_A)
- {
- arrowUpBtn->ResetState();
- }
+ arrowDownBtn->ResetState();
}
+ }
+ else if (arrowUpBtn->GetState() == STATE_CLICKED || arrowUpBtn->GetState() == STATE_HELD)
+ {
+ prev = this->FindMenuItem(optionIndex[selectedItem], -1);
- if (scrollbarBoxBtn->GetState() == STATE_HELD && scrollbarBoxBtn->GetStateChan() == t->chan && t->wpad.ir.valid
- && options->GetLength() > PAGESIZE)
+ if (prev >= 0)
{
- scrollbarBoxBtn->SetPosition(width / 2 - 18 + 7, 0);
-
- int position = t->wpad.ir.y - 50 - scrollbarBoxBtn->GetTop();
-
- listOffset = (position * lang) / 180 - selectedItem;
-
- if (listOffset <= 0)
+ if (selectedItem == 0)
{
- listOffset = 0;
- selectedItem = 0;
+ // move list up by 1
+ listOffset = prev;
}
- else if (listOffset + PAGESIZE >= lang)
+ else
{
- listOffset = lang - PAGESIZE;
- selectedItem = PAGESIZE - 1;
+ optionBtn[selectedItem]->ResetState();
+ optionBtn[selectedItem - 1]->SetState(STATE_SELECTED, t->chan);
+ selectedItem--;
}
+ scrollbarBoxBtn->Draw();
+ usleep(35000);
}
- int positionbar = 237 * (listOffset + selectedItem) / lang;
-
- if (positionbar > 216) positionbar = 216;
- scrollbarBoxBtn->SetPosition(width / 2 - 18 + 7, positionbar + 8);
-
- if (t->Right())
+ if (!(t->wpad.btns_h & WPAD_BUTTON_A || t->wpad.btns_h & WPAD_CLASSIC_BUTTON_A ||
+ t->pad.btns_h & PAD_BUTTON_A))
{
- if (listOffset < lang && lang > PAGESIZE)
- {
- listOffset = listOffset + PAGESIZE;
- if (listOffset + PAGESIZE >= lang) listOffset = lang - PAGESIZE;
- }
- }
- else if (t->Left())
- {
- if (listOffset > 0)
- {
- listOffset = listOffset - PAGESIZE;
- if (listOffset < 0) listOffset = 0;
- }
+ arrowUpBtn->ResetState();
}
}
- if (old_listOffset != listOffset) UpdateListEntries();
+ if (scrollbarBoxBtn->GetState() == STATE_HELD && scrollbarBoxBtn->GetStateChan() == t->chan && t->wpad.ir.valid
+ && options->GetLength() > PAGESIZE)
+ {
+ scrollbarBoxBtn->SetPosition(width / 2 - 18 + 7, 0);
+
+ int position = t->wpad.ir.y - 50 - scrollbarBoxBtn->GetTop();
+
+ listOffset = (position * length) / 180 - selectedItem;
+
+ if (listOffset <= 0)
+ {
+ listOffset = 0;
+ selectedItem = 0;
+ }
+ else if (listOffset + PAGESIZE >= length)
+ {
+ listOffset = length - PAGESIZE;
+ selectedItem = PAGESIZE - 1;
+ }
+ }
+ int positionbar = 237 * (listOffset + selectedItem) / length;
+
+ if (positionbar > 216) positionbar = 216;
+ scrollbarBoxBtn->SetPosition(width / 2 - 18 + 7, positionbar + 8);
+
+ if (t->Right())
+ {
+ if (listOffset < length && length > PAGESIZE)
+ {
+ listOffset = listOffset + PAGESIZE;
+ if (listOffset + PAGESIZE >= length) listOffset = length - PAGESIZE;
+ }
+ }
+ else if (t->Left())
+ {
+ if (listOffset > 0)
+ {
+ listOffset = listOffset - PAGESIZE;
+ if (listOffset < 0) listOffset = 0;
+ }
+ }
+
+ if (old_listOffset != listOffset)
+ UpdateListEntries();
if (updateCB) updateCB(this);
}
diff --git a/source/libwiigui/gui_customoptionbrowser.h b/source/libwiigui/gui_customoptionbrowser.h
index f6064d94..9291b2fa 100644
--- a/source/libwiigui/gui_customoptionbrowser.h
+++ b/source/libwiigui/gui_customoptionbrowser.h
@@ -8,13 +8,12 @@
class GuiCustomOptionBrowser: public GuiElement
{
public:
- GuiCustomOptionBrowser(int w, int h, OptionList * l, const char * background, int scrollbar, int col2);
+ GuiCustomOptionBrowser(int w, int h, OptionList * l, const char * background);
~GuiCustomOptionBrowser();
int FindMenuItem(int c, int d);
int GetClickedOption();
int GetSelectedOption();
void SetClickable(bool enable);
- void SetScrollbar(int enable);
void SetOffset(int optionnumber);
void ResetState();
void SetFocus(int f);
@@ -25,7 +24,7 @@ class GuiCustomOptionBrowser: public GuiElement
int selectedItem;
int listOffset;
int coL2;
- int scrollbaron;
+ bool scrollbaron;
OptionList * options;
int optionIndex[PAGESIZE];
diff --git a/source/menu.cpp b/source/menu.cpp
index c8b62721..1fb6398e 100644
--- a/source/menu.cpp
+++ b/source/menu.cpp
@@ -97,7 +97,7 @@ void HaltGui()
// wait for thread to finish
while (!LWP_ThreadIsSuspended(guithread))
- usleep(50);
+ usleep(100);
}
/****************************************************************************
diff --git a/source/menu/menu_partition_selection.cpp b/source/menu/menu_partition_selection.cpp
index 1728a606..dffb96b1 100644
--- a/source/menu/menu_partition_selection.cpp
+++ b/source/menu/menu_partition_selection.cpp
@@ -71,7 +71,7 @@ int SelectPartitionMenu()
1);
exitBtn.SetTrigger(&trigHome);
- GuiCustomOptionBrowser optionBrowser(396, 280, &options, "bg_options_settings.png", 0, 10);
+ GuiCustomOptionBrowser optionBrowser(396, 280, &options, "bg_options_settings.png");
optionBrowser.SetPosition(0, 40);
optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
diff --git a/source/prompts/DiscBrowser.cpp b/source/prompts/DiscBrowser.cpp
index b205de15..81d694f1 100644
--- a/source/prompts/DiscBrowser.cpp
+++ b/source/prompts/DiscBrowser.cpp
@@ -132,10 +132,7 @@ int DiscBrowse(const char * GameID, char * alternatedname, int alternatedname_si
cancelBtn.SetLabel(&cancelBtnTxt);
cancelBtn.SetTrigger(&trigB);
- u8 scrollbaron = 0;
- if (dolfilecount > 9) scrollbaron = 1;
-
- GuiCustomOptionBrowser optionBrowser3(396, 280, &options3, "bg_options_gamesettings.png", dolfilecount > 9 ? 1 : 0, 200);
+ GuiCustomOptionBrowser optionBrowser3(396, 280, &options3, "bg_options_gamesettings.png");
optionBrowser3.SetPosition(0, 90);
optionBrowser3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
diff --git a/source/prompts/PromptWindows.cpp b/source/prompts/PromptWindows.cpp
index 2424687e..0e7eb501 100644
--- a/source/prompts/PromptWindows.cpp
+++ b/source/prompts/PromptWindows.cpp
@@ -422,7 +422,7 @@ void WindowCredits()
creditsWindow.SetEffect(EFFECT_FADE, -30);
while (creditsWindow.GetEffect() > 0)
- usleep(50);
+ usleep(100);
HaltGui();
mainWindow->Remove(&creditsWindow);
mainWindow->SetState(STATE_DEFAULT);
@@ -766,7 +766,7 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label, cons
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0)
- usleep(50);
+ usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
mainWindow->SetState(STATE_DEFAULT);
@@ -1068,16 +1068,16 @@ int WindowExitPrompt()
}
homeout->Play();
while (btn1.GetEffect() > 0)
- usleep(50);
+ usleep(100);
while (promptWindow.GetEffect() > 0)
- usleep(50);
+ usleep(100);
HaltGui();
homein->Stop();
delete homein;
mainWindow->Remove(&promptWindow);
mainWindow->SetState(STATE_DEFAULT);
while (homeout->IsPlaying() > 0)
- usleep(50);
+ usleep(100);
homeout->Stop();
delete homeout;
ResumeGui();
@@ -1415,7 +1415,7 @@ int GameWindowPrompt()
nameTxt.SetEffect(EFFECT_FADE, -17);
ResumeGui();
while (nameTxt.GetEffect() > 0 || diskImg.GetBetaRotateEffect())
- usleep(50);
+ usleep(100);
HaltGui();
diskImg.SetImage(diskCover);
diskImg.SetBeta(90);
@@ -1439,7 +1439,7 @@ int GameWindowPrompt()
nameTxt.SetEffect(EFFECT_FADE, -17);
ResumeGui();
while (nameTxt.GetEffect() > 0 || diskImg.GetBetaRotateEffect())
- usleep(50);
+ usleep(100);
HaltGui();
diskImg.SetImage(diskCover);
diskImg.SetBeta(270);
@@ -1486,7 +1486,7 @@ int GameWindowPrompt()
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
mainWindow->SetState(STATE_DEFAULT);
while (promptWindow.GetEffect() > 0)
- usleep(50);
+ usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
ResumeGui();
@@ -1696,7 +1696,7 @@ int GameWindowPrompt()
}
while (promptWindow.GetEffect() > 0)
- usleep(50);
+ usleep(100);
HaltGui();
if (changed != 3 && changed != 4) // changed==3 or changed==4 --> only Halt the GUI
{
@@ -1853,7 +1853,7 @@ int DiscWait(const char *title, const char *msg, const char *btn1Label, const ch
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0)
- usleep(50);
+ usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
mainWindow->SetState(STATE_DEFAULT);
@@ -1927,7 +1927,7 @@ int FormatingPartition(const char *title, partitionEntry *entry)
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0)
- usleep(50);
+ usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
mainWindow->SetState(STATE_DEFAULT);
@@ -2035,7 +2035,7 @@ bool SearchMissingImages(int choice2)
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0)
- usleep(50);
+ usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
@@ -2148,7 +2148,7 @@ bool NetworkInitPrompt()
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0)
- usleep(50);
+ usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
@@ -3112,7 +3112,7 @@ int ProgressUpdateWindow()
}
// promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
- //while(promptWindow.GetEffect() > 0) usleep(50);
+ //while(promptWindow.GetEffect() > 0) usleep(100);
HaltGui();
//mainWindow->Remove(&promptWindow);
@@ -3503,7 +3503,7 @@ int ProgressUpdateWindow()
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0)
- usleep(50);
+ usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
@@ -3657,7 +3657,7 @@ int CodeDownload(const char *id)
}
exit: promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0)
- usleep(50);
+ usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
@@ -3679,16 +3679,8 @@ char * GetMissingFiles()
* presenting a user with a choice of up to 2 Buttons.
*
***************************************************************************/
-/*
-
-
-
-
-
- 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)
+ const char *long_description, GuiImageData * iconImgData, u64 filesize)
{
int choice = -1;
@@ -3741,21 +3733,9 @@ int HBCWindowPrompt(const char *name, const char *coder, const char *version, co
arrowDownBtn.SetEffectOnOver(EFFECT_SCALE, 50, 130);
arrowDownBtn.SetSoundClick(btnSoundClick2);
- GuiImageData *iconData = NULL;
- GuiImage *iconImg = NULL;
-
- char imgPath[150];
- snprintf(imgPath, sizeof(imgPath), "%s", iconPath);
-
- bool iconExist = CheckFile(imgPath);
- if (iconExist)
- {
- //! This does not crash even if there is no file
- iconData = new GuiImageData(imgPath);
- iconImg = new GuiImage(iconData);
- iconImg->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
- iconImg->SetPosition(45, 10);
- }
+ GuiImage *iconImg = new GuiImage(iconImgData);
+ iconImg->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
+ iconImg->SetPosition(45, 10);
GuiImage dialogBoxImg(&dialogBox);
dialogBoxImg.SetSkew(0, -80, 0, -80, 0, 50, 0, 50);
@@ -3910,11 +3890,14 @@ int HBCWindowPrompt(const char *name, const char *coder, const char *version, co
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0)
- usleep(50);
+ usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
mainWindow->SetState(STATE_DEFAULT);
ResumeGui();
+
+ delete iconImg;
+
return choice;
}
diff --git a/source/prompts/PromptWindows.h b/source/prompts/PromptWindows.h
index 0e8424c1..9067132e 100644
--- a/source/prompts/PromptWindows.h
+++ b/source/prompts/PromptWindows.h
@@ -8,6 +8,7 @@
#ifndef _PROMPTWINDOWS_H_
#define _PROMPTWINDOWS_H_
+#include "libwiigui/gui.h"
#include "usbloader/partition_usbloader.h"
int WindowPrompt(const char *title, const char *msg = NULL, const char * btn1Label = NULL, const char * btn2Label =
@@ -28,6 +29,6 @@ char * GetMissingFiles();
int WindowScreensaver();
int CodeDownload(const char *id);
int HBCWindowPrompt(const char *name, const char *coder, const char *version, const char *release_date,
- const char *long_description, const char *iconPath, u64 filesize);
+ const char *long_description, GuiImageData * iconImgData, u64 filesize);
#endif
diff --git a/source/prompts/TitleBrowser.cpp b/source/prompts/TitleBrowser.cpp
index 4d4a24c8..a02e70bb 100644
--- a/source/prompts/TitleBrowser.cpp
+++ b/source/prompts/TitleBrowser.cpp
@@ -150,10 +150,7 @@ bool TitleSelector(char output[])
cancelBtn.SetLabel(&cancelBtnTxt);
cancelBtn.SetTrigger(&trigB);
- u8 scrollbaron = 0;
- if (num_titles + 1 > 9) scrollbaron = 1;
-
- GuiCustomOptionBrowser optionBrowser4(396, 280, &options4, "bg_options_settings.png", scrollbaron, 200);
+ GuiCustomOptionBrowser optionBrowser4(396, 280, &options4, "bg_options_settings.png");
optionBrowser4.SetPosition(0, 90);
optionBrowser4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
@@ -381,10 +378,7 @@ int TitleBrowser()
cancelBtn.SetLabel(&cancelBtnTxt);
cancelBtn.SetTrigger(&trigB);
- u8 scrollbaron = 0;
- if (total + 1 > 9) scrollbaron = 1;
-
- GuiCustomOptionBrowser optionBrowser3(396, 280, &options3, "bg_options_gamesettings.png", scrollbaron, 200);
+ GuiCustomOptionBrowser optionBrowser3(396, 280, &options3, "bg_options_settings.png");
optionBrowser3.SetPosition(0, 90);
optionBrowser3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
diff --git a/source/prompts/gameinfo.cpp b/source/prompts/gameinfo.cpp
index 559138cf..06bcb3a3 100644
--- a/source/prompts/gameinfo.cpp
+++ b/source/prompts/gameinfo.cpp
@@ -963,7 +963,7 @@ int showGameInfo(char *ID)
{
gameinfoWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 100);
while (gameinfoWindow.GetEffect() > 0)
- usleep(50);
+ usleep(100);
HaltGui();
mainWindow->Remove(&gameinfoWindow);
mainWindow->SetState(STATE_DEFAULT);
@@ -1045,7 +1045,7 @@ int showGameInfo(char *ID)
{
gameinfoWindow2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 100);
while (gameinfoWindow2.GetEffect() > 0)
- usleep(50);
+ usleep(100);
HaltGui();
mainWindow->Remove(&gameinfoWindow2);
mainWindow->SetState(STATE_DEFAULT);
diff --git a/source/settings/CSettings.h b/source/settings/CSettings.h
index ab72a3b8..c41c9073 100644
--- a/source/settings/CSettings.h
+++ b/source/settings/CSettings.h
@@ -91,7 +91,6 @@ class CSettings
char dolpath[150];
char update_path[150];
char homebrewapps_path[150];
- char selected_homebrew[200];
char Cheatcodespath[100];
char TxtCheatcodespath[100];
char BcaCodepath[100];
diff --git a/source/settings/SettingsPrompts.cpp b/source/settings/SettingsPrompts.cpp
index 43874f90..49f7e569 100644
--- a/source/settings/SettingsPrompts.cpp
+++ b/source/settings/SettingsPrompts.cpp
@@ -204,7 +204,7 @@ int MenuLanguageSelect()
scrollon = 1;
}
- GuiCustomOptionBrowser optionBrowser4( 396, 280, &options2, "bg_options_settings.png", scrollon, 10 );
+ GuiCustomOptionBrowser optionBrowser4( 396, 280, &options2, "bg_options_settings.png");
optionBrowser4.SetPosition( 0, 90 );
optionBrowser4.SetAlignment( ALIGN_CENTRE, ALIGN_TOP );
diff --git a/source/settings/menus/FlyingButtonsMenu.cpp b/source/settings/menus/FlyingButtonsMenu.cpp
index 6db2031a..b11b47cd 100644
--- a/source/settings/menus/FlyingButtonsMenu.cpp
+++ b/source/settings/menus/FlyingButtonsMenu.cpp
@@ -265,6 +265,7 @@ void FlyingButtonsMenu::ShowMenu()
titleTxt = new GuiText(MenuTitle.c_str(), 28, ( GXColor ) {0, 0, 0, 255});
titleTxt->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt->SetPosition(0, 40);
+ titleTxt->SetMaxWidth(310, SCROLL_HORIZONTAL);
Append(titleTxt);
GoLeftImg = new GuiImage(arrow_left);
diff --git a/source/settings/menus/FlyingButtonsMenu.hpp b/source/settings/menus/FlyingButtonsMenu.hpp
index e5d18783..369c681a 100644
--- a/source/settings/menus/FlyingButtonsMenu.hpp
+++ b/source/settings/menus/FlyingButtonsMenu.hpp
@@ -35,18 +35,18 @@ class FlyingButtonsMenu : public GuiWindow
public:
FlyingButtonsMenu(const char * menu_title);
~FlyingButtonsMenu();
- int MainLoop();
- void HideMenu();
- void ShowMenu();
+ virtual int MainLoop();
+ virtual void HideMenu();
+ virtual void ShowMenu();
protected:
virtual void CreateSettingsMenu(int index) { };
virtual void DeleteSettingsMenu() { };
virtual void SetupMainButtons() { };
- void AddMainButtons();
- void ShowButtonsEffects(int effect, int effect_speed);
- void SlideButtons(int slide_direction);
- void SetPageIndicators();
- void SetMainButton(int position, const char * ButtonText, GuiImageData * imageData, GuiImageData * imageOver);
+ virtual void AddMainButtons();
+ virtual void ShowButtonsEffects(int effect, int effect_speed);
+ virtual void SlideButtons(int slide_direction);
+ virtual void SetPageIndicators();
+ virtual void SetMainButton(int position, const char * ButtonText, GuiImageData * imageData, GuiImageData * imageOver);
int currentPage;
int returnMenu;
diff --git a/source/settings/menus/SettingsMenu.cpp b/source/settings/menus/SettingsMenu.cpp
index f2fdf4b0..3297654e 100644
--- a/source/settings/menus/SettingsMenu.cpp
+++ b/source/settings/menus/SettingsMenu.cpp
@@ -58,13 +58,14 @@ SettingsMenu::SettingsMenu(const char * title, OptionList * opts, int returnTo)
Append(backBtn);
}
- optionBrowser = new GuiCustomOptionBrowser(396, 280, Options, "bg_options_settings.png", 0, 150);
+ optionBrowser = new GuiCustomOptionBrowser(396, 280, Options, "bg_options_settings.png");
optionBrowser->SetPosition(0, 90);
optionBrowser->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt = new GuiText(title, 28, (GXColor) {0, 0, 0, 255});
titleTxt->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt->SetPosition(0, 40);
+ titleTxt->SetMaxWidth(310, SCROLL_HORIZONTAL);
Append(optionBrowser);
Append(titleTxt);
diff --git a/source/themes/Resources.cpp b/source/themes/Resources.cpp
index 8c1063a7..3a39af68 100644
--- a/source/themes/Resources.cpp
+++ b/source/themes/Resources.cpp
@@ -171,6 +171,7 @@ RecourceFile Resources::RecourceFiles[] =
{"lock_gray.png", lock_gray_png, lock_gray_png_size, NULL, 0},
{"unlock.png", unlock_png, unlock_png_size, NULL, 0},
{"unlock_gray.png", unlock_gray_png, unlock_gray_png_size, NULL, 0},
+ {"Channel_btn.png", Channel_btn_png, Channel_btn_png_size, NULL, 0},
{NULL, NULL, 0, NULL, 0}
};
diff --git a/source/themes/Theme_Downloader.cpp b/source/themes/Theme_Downloader.cpp
index 0b7145ec..11d02c44 100644
--- a/source/themes/Theme_Downloader.cpp
+++ b/source/themes/Theme_Downloader.cpp
@@ -253,7 +253,7 @@ static int Theme_Prompt(const char *title, const char *author, GuiImageData *thu
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0)
- usleep(50);
+ usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
mainWindow->SetState(STATE_DEFAULT);
@@ -576,7 +576,7 @@ int Theme_Downloader()
currentpage--;
if (currenttheme < 0)
{
- currentpage = roundup((ThemesOnPage + 1.0f) / pagesize);
+ currentpage = ceil((ThemesOnPage + 1.0f) / pagesize);
currenttheme = currentpage * pagesize - pagesize;
}
GoLeftBtn.ResetState();