Ejemplo n.º 1
0
/****************************************************************************
 * CheatMenu
 ***************************************************************************/
int CheatMenu(const char * gameID) {
	int choice = 0;
	bool exit = false;
	int ret = 1;

	// because destroy GuiSound must wait while sound playing is finished, we use a global sound
	if(!btnClick2) btnClick2=new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
	//	GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);

	char imgPath[100];
	snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path);
	GuiImageData btnOutline(imgPath, button_dialogue_box_png);
	snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path);
	GuiImageData settingsbg(imgPath, settings_background_png);
	GuiImage settingsbackground(&settingsbg);

	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
	GuiTrigger trigB;
	trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);

	GuiText backBtnTxt(tr("Back") , 22, THEME.prompttext);
	backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
	GuiImage backBtnImg(&btnOutline);
	GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -140, 400, &trigA, NULL, btnClick2,1);
	backBtn.SetLabel(&backBtnTxt);
	backBtn.SetTrigger(&trigB);

	GuiText createBtnTxt(tr("Create") , 22, THEME.prompttext);
	createBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
	GuiImage createBtnImg(&btnOutline);
	GuiButton createBtn(&createBtnImg,&createBtnImg, 2, 3, 160, 400, &trigA, NULL, btnClick2,1);
	createBtn.SetLabel(&createBtnTxt);

	char txtfilename[55];
	snprintf(txtfilename,sizeof(txtfilename),"%s%s.txt",Settings.TxtCheatcodespath,gameID);

	GCTCheats c;
	int check = c.openTxtfile(txtfilename);

	int download =0;

	switch (check) {
	case -1:
		WindowPrompt(tr("Error"),tr("Cheatfile is blank"),tr("OK"));
		break;
	case 0:
		download = WindowPrompt(tr("Error"),tr("No Cheatfile found"),tr("Download Now"),tr("Cancel"));
		if (download==1)
		{
			download = CodeDownload(gameID);
			if(download < 0 || c.openTxtfile(txtfilename) != 1)
				break;
		}
		else
			break;
	case 1:
		int cntcheats = c.getCnt();
		customOptionList cheatslst(cntcheats);
		GuiCustomOptionBrowser chtBrowser(400, 280, &cheatslst, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, 1, 90);
		chtBrowser.SetPosition(0, 90);
		chtBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
		chtBrowser.SetClickable(true);

		GuiText titleTxt(c.getGameName().c_str(), 28, (GXColor) {0, 0, 0, 255});
		titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
		titleTxt.SetMaxWidth(350, GuiText::SCROLL);
		titleTxt.SetPosition(12,40);

		for (int i = 0; i <= cntcheats; i++) {
            cheatslst.SetValue(i, "%s",c.getCheatName(i).c_str());
            cheatslst.SetName(i, "OFF");
        }

		HaltGui();
		GuiWindow w(screenwidth, screenheight);
		w.Append(&settingsbackground);
		w.Append(&titleTxt);
		w.Append(&backBtn);
		w.Append(&createBtn);
		w.Append(&chtBrowser);
		mainWindow->SetState(STATE_DISABLED);
		mainWindow->ChangeFocus(&w);
		mainWindow->Append(&w);
		ResumeGui();

		while (!exit) {
			VIDEO_WaitVSync ();

			ret = chtBrowser.GetClickedOption();
			if (ret != -1) {
				const char *strCheck = cheatslst.GetName(ret);
				if (strncmp(strCheck,"ON",2) == 0) {
					cheatslst.SetName(ret,"%s","OFF");
				} else if (strncmp(strCheck,"OFF",3) == 0) {
					cheatslst.SetName(ret,"%s","ON");
				}
			}

			if (createBtn.GetState() == STATE_CLICKED) {
				createBtn.ResetState();
				if (cntcheats > 0) {
					int selectednrs[30];
					int x = 0;
					for (int i = 0; i <= cntcheats; i++) {
						const char *strCheck = cheatslst.GetName(i);
						if (strncmp(strCheck,"ON",2) == 0) {
							selectednrs[x] = i;
							x++;
						}
					}
					if (x == 0) {
						WindowPrompt(tr("Error"),tr("No cheats were selected"),tr("OK"));
					} else {
						subfoldercreate(Settings.Cheatcodespath);
						string chtpath = Settings.Cheatcodespath;
						string gctfname = chtpath + c.getGameID() + ".gct";
						c.createGCT(selectednrs,x,gctfname.c_str());
						WindowPrompt(tr("GCT File created"),NULL,tr("OK"));
						exit = true;
						break;
					}
				} else WindowPrompt(tr("Error"),tr("Could not create GCT file"),tr("OK"));
			}

			if (backBtn.GetState() == STATE_CLICKED) {
				backBtn.ResetState();
				exit = true;
				break;
			}
		}
		HaltGui();
		mainWindow->SetState(STATE_DEFAULT);
		mainWindow->Remove(&w);
		ResumeGui();
		break;
	}

	return choice;
}
Ejemplo n.º 2
0
/****************************************************************************
 * MenuHomebrewBrowse
 ***************************************************************************/
int MenuHomebrewBrowse() {
    int menu = MENU_NONE;
    int choice = 0;

    HomebrewFiles HomebrewFiles(Settings.homebrewapps_path);

    u32 filecount = HomebrewFiles.GetFilecount();

    if (!filecount) {
        WindowPrompt(tr("No .dol or .elf files found."),0, tr("OK"));
        return MENU_DISCLIST;
    }

    enum {
        FADE,
        LEFT,
        RIGHT
    };

    if (IsNetworkInit())
        ResumeNetworkWait();

    int slidedirection = FADE;

    /*** Sound Variables ***/
    GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
	// because destroy GuiSound must wait while sound playing is finished, we use a global sound
	if(!btnClick2) btnClick2=new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
	//	GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
    GuiSound btnClick1(button_click_pcm, button_click_pcm_size, Settings.sfxvolume);

    /*** Image Variables ***/
    char imgPath[150];
    snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path);
    GuiImageData btnOutline(imgPath, button_dialogue_box_png);

    snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path);
    GuiImageData bgData(imgPath, settings_background_png);

    snprintf(imgPath, sizeof(imgPath), "%ssettings_title.png", CFG.theme_path);
    GuiImageData MainButtonImgData(imgPath, settings_title_png);

    snprintf(imgPath, sizeof(imgPath), "%ssettings_title_over.png", CFG.theme_path);
    GuiImageData MainButtonImgOverData(imgPath, settings_title_over_png);

    snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_left.png", CFG.theme_path);
    GuiImageData arrow_left(imgPath, startgame_arrow_left_png);

    snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", CFG.theme_path);
    GuiImageData arrow_right(imgPath, startgame_arrow_right_png);

    snprintf(imgPath, sizeof(imgPath), "%sWifi_btn.png", CFG.theme_path);
    GuiImageData wifiImgData(imgPath, Wifi_btn_png);

    snprintf(imgPath, sizeof(imgPath), "%sChannel_btn.png", CFG.theme_path);
    GuiImageData channelImgData(imgPath, 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 == yes) {
        backBtnTxt.SetWidescreen(CFG.widescreen);
        backBtnImg.SetWidescreen(CFG.widescreen);
    }
    GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -180, 400, &trigA, &btnSoundOver, btnClick2,1);
    backBtn.SetLabel(&backBtnTxt);
    backBtn.SetTrigger(&trigB);

    GuiButton h**o(1,1);
    h**o.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(btnClick2);
    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(btnClick2);
    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, GuiText::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, GuiText::DOTTED);
    MainButton1DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    MainButton1DescTxt.SetPosition(148, 15);
    GuiText MainButton1DescOverTxt(MainButtonText, 18, (GXColor) { 0, 0, 0, 255});
    MainButton1DescOverTxt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::SCROLL);
    MainButton1DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    MainButton1DescOverTxt.SetPosition(148, 15);
    GuiButton MainButton1(MainButton1Img.GetWidth(), MainButton1Img.GetHeight());
    MainButton1.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    MainButton1.SetPosition(0, 90);
    MainButton1.SetImage(&MainButton1Img);
    MainButton1.SetImageOver(&MainButton1ImgOver);
    MainButton1.SetLabel(&MainButton1Txt);
    MainButton1.SetLabel(&MainButton1DescTxt,1);
    MainButton1.SetLabelOver(&MainButton1DescOverTxt,1);
    MainButton1.SetSoundOver(&btnSoundOver);
    MainButton1.SetSoundClick(&btnClick1);
    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, GuiText::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, GuiText::DOTTED);
    GuiText MainButton2DescOverTxt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
    MainButton2DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    MainButton2DescOverTxt.SetPosition(148, 15);
    MainButton2DescOverTxt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::SCROLL);
    GuiButton MainButton2(MainButton2Img.GetWidth(), MainButton2Img.GetHeight());
    MainButton2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    MainButton2.SetPosition(0, 160);
    MainButton2.SetImage(&MainButton2Img);
    MainButton2.SetImageOver(&MainButton2ImgOver);
    MainButton2.SetLabel(&MainButton2Txt);
    MainButton2.SetLabel(&MainButton2DescTxt,1);
    MainButton2.SetLabelOver(&MainButton2DescOverTxt,1);
    MainButton2.SetSoundOver(&btnSoundOver);
    MainButton2.SetSoundClick(&btnClick1);
    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, GuiText::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, GuiText::DOTTED);
    GuiText MainButton3DescOverTxt(MainButtonText, 18, (GXColor) {0, 0, 0, 255 });
    MainButton3DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    MainButton3DescOverTxt.SetPosition(148, 15);
    MainButton3DescOverTxt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::SCROLL);
    GuiButton MainButton3(MainButton3Img.GetWidth(), MainButton3Img.GetHeight());
    MainButton3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    MainButton3.SetPosition(0, 230);
    MainButton3.SetImage(&MainButton3Img);
    MainButton3.SetImageOver(&MainButton3ImgOver);
    MainButton3.SetLabel(&MainButton3Txt);
    MainButton3.SetLabel(&MainButton3DescTxt,1);
    MainButton3.SetLabelOver(&MainButton3DescOverTxt,1);
    MainButton3.SetSoundOver(&btnSoundOver);
    MainButton3.SetSoundClick(&btnClick1);
    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, GuiText::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, GuiText::DOTTED);
    GuiText MainButton4DescOverTxt(MainButtonText, 18, (GXColor) { 0, 0, 0, 255});
    MainButton4DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    MainButton4DescOverTxt.SetPosition(148, 15);
    MainButton4DescOverTxt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::SCROLL);
    GuiButton MainButton4(MainButton4Img.GetWidth(), MainButton4Img.GetHeight());
    MainButton4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    MainButton4.SetPosition(0, 300);
    MainButton4.SetImage(&MainButton4Img);
    MainButton4.SetImageOver(&MainButton4ImgOver);
    MainButton4.SetLabel(&MainButton4Txt);
    MainButton4.SetLabel(&MainButton4DescTxt,1);
    MainButton4.SetLabelOver(&MainButton4DescOverTxt,1);
    MainButton4.SetSoundOver(&btnSoundOver);
    MainButton4.SetSoundClick(&btnClick1);
    MainButton4.SetEffectGrow();
    MainButton4.SetTrigger(&trigA);

    GuiImage wifiImg(&wifiImgData);
    if (Settings.wsprompt == yes) {
        wifiImg.SetWidescreen(CFG.widescreen);
    }
    GuiButton wifiBtn(wifiImg.GetWidth(), wifiImg.GetHeight());
    wifiBtn.SetImage(&wifiImg);
    wifiBtn.SetPosition(500, 400);
    wifiBtn.SetSoundOver(&btnSoundOver);
    wifiBtn.SetSoundClick(&btnClick1);
    wifiBtn.SetEffectGrow();
    wifiBtn.SetAlpha(80);
    wifiBtn.SetTrigger(&trigA);

    GuiImage channelBtnImg(&channelImgData);
    channelBtnImg.SetWidescreen(CFG.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(btnClick2);
    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, 0);
                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(&h**o);
        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) {
                    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);
            }
            if (buttonsleft > 1) {
                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);
            }
            if (buttonsleft > 2) {
                snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+2));
                if (XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
                    snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetName());
                    MainButton3Txt.SetText(MainButtonText);
                    snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetShortDescription());
                    MainButton3DescTxt.SetText(MainButtonText);
                    MainButton3DescOverTxt.SetText(MainButtonText);
                } else {
                    snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+2)), "%s", HomebrewFiles.GetFilepath(fileoffset+2));
                    shortpath = strrchr(temp, '/');
                    snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+2));
                    XMLInfo[2].SetName(MainButtonText);
                    MainButton3Txt.SetText(MainButtonText);
                    snprintf(MainButtonText, sizeof(MainButtonText), " ");
                    MainButton3DescTxt.SetText(MainButtonText);
                    MainButton3DescOverTxt.SetText(MainButtonText);
                }
                w.Append(&MainButton3);
            }
            if (buttonsleft > 3) {
                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);
            }
        } 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[3].LoadHomebrewXMLData(temp) > 0) {
                snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetName());
                MainButton3Txt.SetText(MainButtonText);
                snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetShortDescription());
                MainButton3DescTxt.SetText(MainButtonText);
                MainButton3DescOverTxt.SetText(MainButtonText);
            } else {
                snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+2)), "%s", HomebrewFiles.GetFilepath(fileoffset+2));
                shortpath = strrchr(temp, '/');
                snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+2));
                XMLInfo[2].SetName(MainButtonText);
                MainButton3Txt.SetText(MainButtonText);
                snprintf(MainButtonText, sizeof(MainButtonText), " ");
                MainButton3DescTxt.SetText(MainButtonText);
                MainButton3DescOverTxt.SetText(MainButtonText);
            }
            w.Append(&MainButton3);

            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) {
                    boothomebrew = 1;
                    menu = MENU_EXIT;
                    snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s",  HomebrewFiles.GetFilepath(fileoffset), HomebrewFiles.GetFilename(fileoffset));
                    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) {
                    boothomebrew = 1;
                    menu = MENU_EXIT;
                    snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s",  HomebrewFiles.GetFilepath(fileoffset+1), HomebrewFiles.GetFilename(fileoffset+1));
                    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) {
                    boothomebrew = 1;
                    menu = MENU_EXIT;
                    snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s",  HomebrewFiles.GetFilepath(fileoffset+2), HomebrewFiles.GetFilename(fileoffset+2));
                    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) {
                    boothomebrew = 1;
                    menu = MENU_EXIT;
                    snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s",  HomebrewFiles.GetFilepath(fileoffset+3), HomebrewFiles.GetFilename(fileoffset+3));
                    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 (h**o.GetState() == STATE_CLICKED) {
                cfg_save_global();
                bgMusic->Pause();
                choice = WindowExitPrompt();
                bgMusic->Resume();

                if (choice == 3) {
                    Sys_LoadMenu(); // Back to System Menu
                } else if (choice == 2) {
                    Sys_BackToLoader();
                } else {
                    h**o.ResetState();
                }
            }

            else if (infilesize > 0) {
                char filesizetxt[50];
                char temp[50];

                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 == 1) {

                    int res = AllocHomebrewMemory(infilesize);

                    if (res < 0) {
                        CloseConnection();
                        WindowPrompt(tr("Not enough free memory."), 0, tr("OK"));
                    } else {
                        u32 read = 0;
                        u8 *temp = NULL;
                        int len = NETWORKBLOCKSIZE;
                        temp = (u8 *) malloc(infilesize);

						bool error = false;
						u8 *ptr = temp;
                        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(ptr, len);

                            if (result < 0) {
                                WindowPrompt(tr("Error while transfering data."), 0, tr("OK"));
								error = true;
                                break;
                            }
                            if (!result) {
                                break;
							}

							ptr += result;

                            read += result;
                        }
						
						char filename[101];
						if (!error) {
						
							network_read((u8*) &filename, 100);
							
							// Do we need to unzip this thing?
							if (wiiloadVersion[0] > 0 || wiiloadVersion[1] > 4) {

								// We need to unzip...
								if (temp[0] == 'P' && temp[1] == 'K' && temp[2] == 0x03 && temp[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 != NULL)
									{
										fwrite(temp, 1, infilesize, fp);
										fclose(fp);
										
										// Now unzip the zip file...
										unzFile uf = unzOpen(zippath);
										if (uf==NULL) {
											error = true;
										} else {
											extractZip(uf,0,1,0, Settings.homebrewapps_path);
											unzCloseCurrentFile(uf);
											
											remove(zippath);
											
											// Reload this menu here...
											menu = MENU_HOMEBREWBROWSE;
											break;
										}
									} else {
										error = true;
									}
								} 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, temp, infilesize) != Z_OK;
									uncfilesize = f;
									
									free(temp);
									temp = unc;
								}
							}
							
							if (!error && strstr(filename,".zip") == NULL) {
								innetbuffer = temp;
							}
						}
						
                        ProgressStop();

                        if (error || read != infilesize) {
                            WindowPrompt(tr("Error:"), tr("No data could be read."), tr("OK"));
                            FreeHomebrewBuffer();
                        } else {
                            if (strstr(filename,".dol") || strstr(filename,".DOL")
                                || strstr(filename,".elf") || strstr(filename,".ELF")) {
                                boothomebrew = 2;
                                menu = MENU_EXIT;
                                CloseConnection();
                                break;
                            } else if (strstr(filename,".zip")) {
                                WindowPrompt(tr("Success:"), tr("Uploaded ZIP file installed to homebrew directory."), tr("OK"));
								CloseConnection();
                            } else {
                                FreeHomebrewBuffer();
                                WindowPrompt(tr("ERROR:"), tr("Not a DOL/ELF file."), tr("OK"));
							}
                        }
                    }
                }
                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
                u32 num = 0x00010001;
                TitleBrowser(num);
                //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;
}
int MenuSettingsTheme()
{
	int menu = MENU_NONE;

	int ret = -1;
	int activated = -1;
	int i = 0;
	int focus = 0;

	OptionList options;

	sprintf(options.name[i], tr("STANDARD"));
	if(stricmp(Options.temp_theme.c_str(), tr("STANDARD")) == 0)
	{
		sprintf (options.value[i], tr("activated"));
		activated = i;
	}
	else
		sprintf (options.value[i], " ");

	i++;

	DIR *dirHandle;
	struct dirent * dirEntry;
	dirHandle = opendir(check_path(Settings.device_dat + ":/config/HBF/Themes").c_str());
	if (dirHandle) {
		while (0 != (dirEntry = readdir(dirHandle)))
		{
			if(stricmp(dirEntry->d_name, ".") != 0 && stricmp(dirEntry->d_name, "..") != 0)
			{
				sprintf(options.name[i], dirEntry->d_name);

				if(stricmp(Options.temp_theme.c_str(), dirEntry->d_name) == 0)
				{
					sprintf (options.value[i], tr("activated"));
					activated = i;
				}
				else
					sprintf (options.value[i], " ");

				i++;
			}
		}
		closedir(dirHandle);
	}

	options.length = i;

	GuiImageData bgImgData(Theme.background);
	GuiImageData btnOutline(Theme.button_small);
	GuiImageData btnOutlineOver(Theme.button_small_focus);

	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);

	GuiImage bgImg(&bgImgData);

	GuiText titleTxt(tr("Themes"), 28, (GXColor){Theme.title_1, Theme.title_2, Theme.title_3, 255});
	titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	titleTxt.SetPosition(50,50);

	GuiText downloadBtnTxt(tr("Download"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiImage downloadBtnImg(&btnOutline);
	GuiImage downloadBtnImgOver(&btnOutlineOver);
	GuiButton downloadBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
	downloadBtn.SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
	downloadBtn.SetPosition(-100, 38);
	downloadBtn.SetLabel(&downloadBtnTxt);
	downloadBtn.SetImage(&downloadBtnImg);
	downloadBtn.SetImageOver(&downloadBtnImgOver);
	downloadBtn.SetTrigger(&trigA);
	downloadBtn.SetEffectGrow();

	GuiText okBtnTxt(tr("OK"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiImage okBtnImg(&btnOutline);
	GuiImage okBtnImgOver(&btnOutlineOver);
	GuiButton okBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
	okBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
	okBtn.SetPosition(100, -35);
	okBtn.SetLabel(&okBtnTxt);
	okBtn.SetImage(&okBtnImg);
	okBtn.SetImageOver(&okBtnImgOver);
	okBtn.SetTrigger(&trigA);
	okBtn.SetEffectGrow();

	GuiText backBtnTxt(tr("Stop"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiImage backBtnImg(&btnOutline);
	GuiImage backBtnImgOver(&btnOutlineOver);
	GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
	backBtn.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
	backBtn.SetPosition(-100, -35);
	backBtn.SetLabel(&backBtnTxt);
	backBtn.SetImage(&backBtnImg);
	backBtn.SetImageOver(&backBtnImgOver);
	backBtn.SetTrigger(&trigA);
	backBtn.SetEffectGrow();

	GuiOptionBrowser optionBrowser(552, 248, &options);
	optionBrowser.SetPosition(0, 108);
	optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	optionBrowser.Col1Scroll(280);
	optionBrowser.SetCol2Position(340);

	HaltGui();
	GuiWindow w(screenwidth, screenheight);
	w.Append(&bgImg);
	w.Append(&titleTxt);
	w.Append(&downloadBtn);
	w.Append(&okBtn);
	w.Append(&backBtn);
	mainWindow->Append(&w);
	mainWindow->Append(&optionBrowser);

	mainWindow->ChangeFocus(&optionBrowser);
	ResumeGui();

	while(menu == MENU_NONE)
	{
		usleep(100);

		ret = optionBrowser.GetClickedOption();

		if(ret != -1)
		{
			for(i=0; i < options.length; i++)
			{
				if(i == ret)
				{
					sprintf (options.value[i], tr("activated"));
					activated = i;
				}
				else
					sprintf (options.value[i], " ");
			}
			optionBrowser.TriggerUpdate();
		}

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B) || PAD_ButtonsDown(0) & PAD_BUTTON_B
		   || WUPC_ButtonsDown(0) & WPAD_CLASSIC_BUTTON_B)
		{
			if(focus == 0)
			{
				focus = 1;
				mainWindow->ChangeFocus(&w);
				downloadBtn.ResetState();
				okBtn.SetState(STATE_SELECTED);
			}
			else
			{
				focus = 0;
				mainWindow->ChangeFocus(&optionBrowser);
			}
			HaltResumeGui();
		}

		if(downloadBtn.GetState() == STATE_CLICKED)
		{
			downloadBtn.ResetState();
			string themedownload = checkThemesPrompt();
			if(themedownload != "NULL")
			{
				if(theme_folder_exists(themedownload))
				{
					themeDownload(themedownload);
					menu = MENU_SETTINGS_THEME;
					theme_dl = true;
					break;
				}
			}
		}

		if(okBtn.GetState() == STATE_CLICKED)
		{
			Options.temp_last_setting = 1;
			Options.temp_theme = options.name[activated];
			menu = MENU_SETTINGS_FILE;
		}

		if(backBtn.GetState() == STATE_CLICKED)
		{
			Options.temp_last_setting = 1;
			menu = MENU_SETTINGS_FILE;
		}

		if(runaway == true)
		{
			Options.temp_last_setting = 1;
			menu = MENU_SETTINGS_FILE;
		}
	}
	HaltGui();
	mainWindow->Remove(&optionBrowser);
	mainWindow->Remove(&w);
	return menu;
}
Ejemplo n.º 4
0
/****************************************************************************
 * MenuLanguageSelect
 ***************************************************************************/
int MenuLanguageSelect() {
    int cnt = 0;
    int ret = 0, choice = 0;
    int scrollon;
    int returnhere = 0;

    GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
	// because destroy GuiSound must wait while sound playing is finished, we use a global sound
	if(!btnClick2) btnClick2=new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
	//	GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);

    char imgPath[100];

    snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path);
    GuiImageData btnOutline(imgPath, button_dialogue_box_png);
    snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path);
    GuiImageData settingsbg(imgPath, settings_background_png);

    GuiTrigger trigA;
    trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
    GuiTrigger trigB;
    trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);

    char fullpath[100];
    int countfiles = GetAllDirFiles(Settings.languagefiles_path);

    if (!strcmp("", Settings.languagefiles_path)) {
        sprintf(fullpath, "%s", tr("Standard"));
    } else {
        sprintf(fullpath, "%s", Settings.languagefiles_path);
    }

    GuiText titleTxt(fullpath, 24, (GXColor) {0, 0, 0, 255});
    titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
    titleTxt.SetPosition(0,0);
    GuiButton pathBtn(300, 50);
    pathBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    pathBtn.SetPosition(0,28);
    pathBtn.SetLabel(&titleTxt);
    pathBtn.SetSoundOver(&btnSoundOver);
    pathBtn.SetSoundClick(btnClick2);
    pathBtn.SetTrigger(&trigA);
    pathBtn.SetEffectGrow();

    GuiImage oggmenubackground(&settingsbg);
    oggmenubackground.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    oggmenubackground.SetPosition(0, 0);

    GuiText backBtnTxt(tr("Back") , 22, THEME.prompttext);
    backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
    GuiImage backBtnImg(&btnOutline);
    if (Settings.wsprompt == yes) {
        backBtnTxt.SetWidescreen(CFG.widescreen);
        backBtnImg.SetWidescreen(CFG.widescreen);
    }
    GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
    backBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    backBtn.SetPosition(-190, 400);
    backBtn.SetLabel(&backBtnTxt);
    backBtn.SetImage(&backBtnImg);
    backBtn.SetSoundOver(&btnSoundOver);
    backBtn.SetSoundClick(btnClick2);
    backBtn.SetTrigger(&trigA);
    backBtn.SetTrigger(&trigB);
    backBtn.SetEffectGrow();

    GuiText defaultBtnTxt(tr("Default") , 22, THEME.prompttext);
    defaultBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
    GuiImage defaultBtnImg(&btnOutline);
    if (Settings.wsprompt == yes) {
        defaultBtnTxt.SetWidescreen(CFG.widescreen);
        defaultBtnImg.SetWidescreen(CFG.widescreen);
    }
    GuiButton defaultBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
    defaultBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    defaultBtn.SetPosition(190, 400);
    defaultBtn.SetLabel(&defaultBtnTxt);
    defaultBtn.SetImage(&defaultBtnImg);
    defaultBtn.SetSoundOver(&btnSoundOver);
    defaultBtn.SetSoundClick(btnClick2);
    defaultBtn.SetTrigger(&trigA);
    defaultBtn.SetEffectGrow();

    GuiText updateBtnTxt(tr("Update Files") , 22, THEME.prompttext);
    updateBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
    GuiImage updateBtnImg(&btnOutline);
    if (Settings.wsprompt == yes) {
        updateBtnTxt.SetWidescreen(CFG.widescreen);
        updateBtnImg.SetWidescreen(CFG.widescreen);
    }
    GuiButton updateBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
    updateBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    updateBtn.SetPosition(0, 400);
    updateBtn.SetLabel(&updateBtnTxt);
    updateBtn.SetImage(&updateBtnImg);
    updateBtn.SetSoundOver(&btnSoundOver);
    updateBtn.SetSoundClick(btnClick2);
    updateBtn.SetTrigger(&trigA);
    updateBtn.SetEffectGrow();

    customOptionList options2(countfiles);

    for (cnt = 0; cnt < countfiles; cnt++) {
        char filename[64];
        strlcpy(filename, GetFileName(cnt), sizeof(filename));
        char *dot = strchr(filename, '.');
        if (dot) *dot='\0';
        options2.SetName(cnt, "%s", filename);
        options2.SetValue(cnt, NULL);

    }

    if (cnt < 9) {
        scrollon = 0;
    } else {
        scrollon = 1;
    }

    GuiCustomOptionBrowser optionBrowser4(396, 280, &options2, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, scrollon, 10);
    optionBrowser4.SetPosition(0, 90);
    optionBrowser4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);

    HaltGui();
    GuiWindow w(screenwidth, screenheight);
    w.Append(&oggmenubackground);
    w.Append(&pathBtn);
    w.Append(&backBtn);
    w.Append(&defaultBtn);
    w.Append(&updateBtn);
    w.Append(&optionBrowser4);
    mainWindow->Append(&w);

    w.SetEffect(EFFECT_FADE, 20);
    ResumeGui();

    while (w.GetEffect()>0) usleep(50);

    while (!returnhere) {

        if (shutdown == 1)
            Sys_Shutdown();
        else if (reset == 1)
            Sys_Reboot();

        else if (backBtn.GetState() == STATE_CLICKED) {

            backBtn.ResetState();
            break;
        }

        else if (defaultBtn.GetState() == STATE_CLICKED) {
            choice = WindowPrompt(tr("Loading standard language."),0,tr("OK"), tr("Cancel"));
            if (choice == 1) {
                sprintf(Settings.language_path, "notset");
                cfg_save_global();
                gettextCleanUp();
				HaltGui();
                CFG_Load();
				ResumeGui();
                returnhere = 2;
            }
            defaultBtn.ResetState();
			//optionBrowser4.SetFocus(1); // commented out to prevent crash
        }

        else if (updateBtn.GetState() == STATE_CLICKED) {
            choice = WindowPrompt(tr("Update all Language Files"),tr("Do you wish to update/download all language files?"),tr("OK"), tr("Cancel"));
            if (choice == 1) {

                bool network = true;
                if (!IsNetworkInit()) {
                    network = NetworkInitPrompt();
                }

                if (network) {
                    const char URL[60] = "http://usbloader-gui.googlecode.com/svn/trunk/Languages/";
                    char fullURL[300];
                    FILE *pfile;

                    URL_List LinkList(URL);
                    int listsize = LinkList.GetURLCount();

                    subfoldercreate(Settings.languagefiles_path);

                    for (int i = 0; i < listsize; i++) {

                        ShowProgress(tr("Updating Language Files:"), 0, LinkList.GetURL(i), i, listsize-1);

                        if (strcasecmp(".lang", strrchr(LinkList.GetURL(i), '.')) == 0) {

                            snprintf(fullURL, sizeof(fullURL), "%s%s", URL, LinkList.GetURL(i));

                            struct block file = downloadfile(fullURL);

                            if (file.data && file.size) {
                                char filepath[300];

                                snprintf(filepath, sizeof(filepath), "%s%s", Settings.languagefiles_path, LinkList.GetURL(i));
                                pfile = fopen(filepath, "wb");
                                fwrite(file.data, 1, file.size, pfile);
                                fclose(pfile);

                            }

                            free(file.data);
                        }
                    }
                    ProgressStop();
                    returnhere = 1;
                    break;
                }
            }
			updateBtn.ResetState();
			//optionBrowser4.SetFocus(1); // commented out to prevent crash
        }

        else if (pathBtn.GetState() == STATE_CLICKED) {
            w.Remove(&optionBrowser4);
            w.Remove(&backBtn);
            w.Remove(&pathBtn);
            w.Remove(&defaultBtn);
            char entered[43] = "";
            strlcpy(entered, Settings.languagefiles_path, sizeof(entered));
            int result = OnScreenKeyboard(entered,43,0);
            w.Append(&optionBrowser4);
            w.Append(&pathBtn);
            w.Append(&backBtn);
            w.Append(&defaultBtn);
            if ( result == 1 ) {
                int len = (strlen(entered)-1);
                if (entered[len] !='/')
                    strncat (entered, "/", 1);
                strlcpy(Settings.languagefiles_path, entered, sizeof(Settings.languagefiles_path));
                WindowPrompt(tr("Languagepath changed."),0,tr("OK"));
                if (isInserted(bootDevice)) {
                    cfg_save_global();
                    returnhere = 1;
                    break;
                } else {
                    WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK"));
                }
            }
            if (countfiles > 0) {
                optionBrowser4.SetFocus(1);
            }
            pathBtn.ResetState();
        }

        ret = optionBrowser4.GetClickedOption();

        if (ret>=0) {
            choice = WindowPrompt(tr("Do you want to change language?"), 0, tr("Yes"), tr("Cancel"));
            if (choice == 1) {
                if (isInserted(bootDevice)) {
                    snprintf(Settings.language_path, sizeof(Settings.language_path), "%s%s", Settings.languagefiles_path, GetFileName(ret));
                    cfg_save_global();
                    if (!checkfile(Settings.language_path)) {
                        sprintf(Settings.language_path, tr("not set"));
                        WindowPrompt(tr("File not found."),tr("Loading standard language."),tr("OK"));
                    }
                    gettextCleanUp();
					HaltGui();
					CFG_Load();
					ResumeGui();
                    returnhere = 2;
                    break;
                } else {
                    WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK"), 0,0,0,-1);
                }
            }
            optionBrowser4.SetFocus(1);
        }

    }

    w.SetEffect(EFFECT_FADE, -20);
    while (w.GetEffect()>0) usleep(50);

    HaltGui();
    mainWindow->Remove(&w);
    ResumeGui();

    return returnhere;
}
Ejemplo n.º 5
0
void ThemeMenu::MainButtonClicked(int button)
{
	//! TODO: Clean me
	const char * title = ThemeList[button].Title.c_str();
	const char * author = ThemeList[button].Team.c_str();
	const char * version = ThemeList[button].Version.c_str();
	GuiImageData *thumbimageData = ThemePreviews[button % 4];

	debughelper_printf("\nTheme_Prompt(%s ,%s)", title, author);
	bool leave = false;

	GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
	GuiImageData dialogBox(Resources::GetFile("theme_dialogue_box.png"), Resources::GetFileSize("theme_dialogue_box.png"));

	GuiImage dialogBoxImg(&dialogBox);

	GuiWindow promptWindow(dialogBox.GetWidth(), dialogBox.GetHeight());
	promptWindow.SetAlignment(ALIGN_CENTER, ALIGN_MIDDLE);
	promptWindow.SetPosition(0, -10);

	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
	GuiTrigger trigB;
	trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);

	int PositionY = 30;

	GuiText titleTxt(tr( "Theme Title:" ), 18, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
	titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	titleTxt.SetPosition(230, PositionY);
	PositionY += 20;

	GuiText titleTxt2(title, 18, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
	titleTxt2.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	titleTxt2.SetPosition(230, PositionY);
	titleTxt2.SetMaxWidth(dialogBox.GetWidth() - 220, WRAP);

	if(titleTxt2.GetTextWidth() >= dialogBox.GetWidth() - 220)
		PositionY += 50;
	else
		PositionY += 30;

	GuiText authorTxt(tr( "Author(s):" ), 18, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
	authorTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	authorTxt.SetPosition(230, PositionY);
	PositionY += 20;

	GuiText authorTxt2(author, 18, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
	authorTxt2.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	authorTxt2.SetPosition(230, PositionY);
	authorTxt2.SetMaxWidth(dialogBox.GetWidth() - 220, DOTTED);

	if(authorTxt2.GetTextWidth() >= dialogBox.GetWidth() - 220)
		PositionY += 50;
	else
		PositionY += 30;

	GuiText versionTxt(tr( "Version:" ), 18, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
	versionTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	versionTxt.SetPosition(230, PositionY);

	GuiText versionTxt2(version, 18, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
	versionTxt2.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	versionTxt2.SetPosition(235+versionTxt.GetTextWidth(), PositionY);
	versionTxt2.SetMaxWidth(dialogBox.GetWidth() - 220, DOTTED);

	GuiText applyBtnTxt(tr( "Apply" ), 22, thColor("r=0 g=0 b=0 a=255 - prompt windows button text color"));
	applyBtnTxt.SetMaxWidth(btnOutline.GetWidth() - 30);
	GuiImage applyBtnImg(&btnOutline);
	if (Settings.wsprompt)
	{
		applyBtnTxt.SetWidescreen(Settings.widescreen);
		applyBtnImg.SetWidescreen(Settings.widescreen);
	}
	GuiButton applyBtn(&applyBtnImg, &applyBtnImg, ALIGN_RIGHT, ALIGN_TOP, -5, 170, &trigA, btnSoundOver, btnSoundClick2, 1);
	applyBtn.SetLabel(&applyBtnTxt);
	applyBtn.SetScale(0.9);

	GuiText backBtnTxt(tr( "Back" ), 22, thColor("r=0 g=0 b=0 a=255 - prompt windows button text color"));
	backBtnTxt.SetMaxWidth(btnOutline.GetWidth() - 30);
	GuiImage backBtnImg(&btnOutline);
	if (Settings.wsprompt)
	{
		backBtnTxt.SetWidescreen(Settings.widescreen);
		backBtnImg.SetWidescreen(Settings.widescreen);
	}
	GuiButton backBtn(&backBtnImg, &backBtnImg, ALIGN_RIGHT, ALIGN_TOP, -5, 220, &trigA, btnSoundOver, btnSoundClick2, 1);
	backBtn.SetLabel(&backBtnTxt);
	backBtn.SetTrigger(&trigB);
	backBtn.SetScale(0.9);

	GuiImage ThemeImage(thumbimageData);
	ThemeImage.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	ThemeImage.SetPosition(20, 10);
	ThemeImage.SetScale(0.8);

	promptWindow.Append(&dialogBoxImg);
	promptWindow.Append(&ThemeImage);
	promptWindow.Append(&titleTxt);
	promptWindow.Append(&titleTxt2);
	promptWindow.Append(&authorTxt);
	promptWindow.Append(&authorTxt2);
	promptWindow.Append(&versionTxt);
	promptWindow.Append(&versionTxt2);
	promptWindow.Append(&applyBtn);
	promptWindow.Append(&backBtn);

	HaltGui();
	promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50);
	mainWindow->SetState(STATE_DISABLED);
	mainWindow->Append(&promptWindow);
	ResumeGui();

	while (!leave)
	{
		usleep(100);

		if (shutdown)
			Sys_Shutdown();
		else if (reset)
			Sys_Reboot();

		if (applyBtn.GetState() == STATE_CLICKED)
		{
			int choice = WindowPrompt(tr( "Do you want to apply this theme?" ), title, tr( "Yes" ), tr( "Cancel" ));
			if (choice)
			{
				if (Theme::Load(ThemeList[button].Filepath.c_str()))
				{
					snprintf(Settings.theme, sizeof(Settings.theme), ThemeList[button].Filepath.c_str());
					Theme::Reload();
					returnMenu = MENU_THEMEMENU;
					leave = true;
				}
			}
			mainWindow->SetState(STATE_DISABLED);
			promptWindow.SetState(STATE_DEFAULT);
			applyBtn.ResetState();
		}

		else if (backBtn.GetState() == STATE_CLICKED)
		{
			leave = true;
			backBtn.ResetState();
		}
	}

	promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
	while (promptWindow.GetEffect() > 0) usleep(100);
	HaltGui();
	mainWindow->Remove(&promptWindow);
	mainWindow->SetState(STATE_DEFAULT);
	ResumeGui();
}
Ejemplo n.º 6
0
/****************************************************************************
 * MenuSettings
 ***************************************************************************/
int MenuSettingsNetwork()
{
	int menu = MENU_NONE;

	int ret = -1;
	int i = 0;
	int focus = 0;

	int network = Options.temp_network;
	int wifigecko = Options.temp_wifigecko;
	int newrevtext = Options.temp_newrevtext;

	OptionList options;

	sprintf(options.name[i++], tr("Auto Connect"));
	sprintf(options.name[i++], tr("Enable Wifi Gecko"));
	sprintf(options.name[i++], tr("Update Info"));
	options.length = i;

	GuiImageData bgImgData(Theme.background);
	GuiImageData btnOutline(Theme.button_small);
	GuiImageData btnOutlineOver(Theme.button_small_focus);

	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);

	GuiImage bgImg(&bgImgData);

	GuiText titleTxt(tr("Network Settings"), 28, (GXColor){Theme.title_1, Theme.title_2, Theme.title_3, 255});
	titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	titleTxt.SetPosition(50,50);

	GuiText okBtnTxt(tr("OK"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiImage okBtnImg(&btnOutline);
	GuiImage okBtnImgOver(&btnOutlineOver);
	GuiButton okBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
	okBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
	okBtn.SetPosition(100, -35);
	okBtn.SetLabel(&okBtnTxt);
	okBtn.SetImage(&okBtnImg);
	okBtn.SetImageOver(&okBtnImgOver);
	okBtn.SetTrigger(&trigA);
	okBtn.SetEffectGrow();

	GuiText backBtnTxt(tr("Stop"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiImage backBtnImg(&btnOutline);
	GuiImage backBtnImgOver(&btnOutlineOver);
	GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
	backBtn.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
	backBtn.SetPosition(-100, -35);
	backBtn.SetLabel(&backBtnTxt);
	backBtn.SetImage(&backBtnImg);
	backBtn.SetImageOver(&backBtnImgOver);
	backBtn.SetTrigger(&trigA);
	backBtn.SetEffectGrow();

	GuiOptionBrowser optionBrowser(552, 248, &options);
	optionBrowser.SetPosition(0, 108);
	optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	optionBrowser.SetCol2Position(340);

	HaltGui();
	GuiWindow w(screenwidth, screenheight);
	w.Append(&bgImg);
	w.Append(&titleTxt);
	w.Append(&okBtn);
	w.Append(&backBtn);
	mainWindow->Append(&w);
	mainWindow->Append(&optionBrowser);

	mainWindow->ChangeFocus(&optionBrowser);
	ResumeGui();

	int change = 0;
	while(menu == MENU_NONE)
	{
		usleep(100);

		ret = optionBrowser.GetChangedOption();

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT) || PAD_ButtonsDown(0) & PAD_BUTTON_RIGHT)
		{
			change = 0;
			switch (ret)
			{
				case 0:
					change = network;
					change++;
					if(change > 1)
						change = 1;
					network = change;
					break;

				case 1:
					change = wifigecko;
					change++;
					if(change > 1)
						change = 1;
					wifigecko = change;
					break;

				case 2:
					change = newrevtext;
					change++;
					if(change > 1)
						change = 1;
					newrevtext = change;
					break;
			}
			HaltResumeGui();
		}

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT) || PAD_ButtonsDown(0) & PAD_BUTTON_LEFT)
		{
			change = 0;
			switch (ret)
			{
				case 0:
					change = network;
					change--;
					if(change < 0)
						change = 0;
					network = change;
					break;

				case 1:
					change = wifigecko;
					change--;
					if(change < 0)
						change = 0;
					wifigecko = change;
					break;

				case 2:
					change = newrevtext;
					change--;
					if(change < 0)
						change = 0;
					newrevtext = change;
					break;
			}
			HaltResumeGui();
		}

		if(change != -1)
		{
			change = -1;

			if(network == 0)
				sprintf (options.value[0], tr("No"));
			else
				sprintf (options.value[0], tr("Yes"));

			if(wifigecko == 0)
				sprintf (options.value[1], tr("No"));
			else
				sprintf (options.value[1], tr("Yes"));

			if(newrevtext == 0)
				sprintf (options.value[2], tr("No"));
			else
				sprintf (options.value[2], tr("Yes"));

			optionBrowser.TriggerUpdate();
		}

		if(optionBrowser.GetClickedOption() != -1)
			optionBrowser.TriggerUpdate();

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B) || PAD_ButtonsDown(0) & PAD_BUTTON_B)
		{
			if(focus == 0)
			{
				focus = 1;
				mainWindow->ChangeFocus(&w);
			}
			else
			{
				focus = 0;
				mainWindow->ChangeFocus(&optionBrowser);
			}
			HaltResumeGui();
		}

		if(okBtn.GetState() == STATE_CLICKED)
		{
			Options.temp_last_setting = 1;
			if (Options.temp_network != network)
			{
				if(network == 1)
				{
					ResumeNetworkThread();
				}
				else
				{
					HaltNetworkThread();
				}
			}
			Options.temp_network = network;
			Options.temp_wifigecko = wifigecko;
			Options.temp_newrevtext = newrevtext;
			menu = MENU_SETTINGS_FILE;
		}

		if(backBtn.GetState() == STATE_CLICKED)
		{
			Options.temp_last_setting = 1;
			menu = MENU_SETTINGS_FILE;
		}

		if(runaway == true)
		{
			Options.temp_last_setting = 1;
			menu = MENU_SETTINGS_FILE;
		}
	}
	HaltGui();
	mainWindow->Remove(&optionBrowser);
	mainWindow->Remove(&w);
	return menu;
}
Ejemplo n.º 7
0
static int MenuSettingsFile() {
    int menu = MENU_NONE;
    int ret;
    int i = 0;
    bool firstRun = true;
    OptionList options;
    sprintf(options.name[i++], "Load Device");
    sprintf(options.name[i++], "Save Device");
    sprintf(options.name[i++], "Folder 1");
    sprintf(options.name[i++], "Folder 2");
    sprintf(options.name[i++], "Folder 3");
    sprintf(options.name[i++], "Auto Load");
    sprintf(options.name[i++], "Auto Save");
    options.length = i;

    GuiText titleTxt("Settings - Saving & Loading", 28, ColorGrey);
    titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    titleTxt.SetPosition(50, 50);

    GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM);
    GuiImageData btnOutline(xenon_button_png);
    GuiImageData btnOutlineOver(xenon_button_over_png);

    GuiTrigger trigA;
    //	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
    trigA.SetSimpleTrigger(-1, 0, PAD_BUTTON_A);

    GuiText backBtnTxt("Go Back", 22, ColorGrey2);
    GuiImage backBtnImg(&btnOutline);
    GuiImage backBtnImgOver(&btnOutlineOver);
    GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
    backBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
    backBtn.SetPosition(100, -35);
    backBtn.SetLabel(&backBtnTxt);
    backBtn.SetImage(&backBtnImg);
    backBtn.SetImageOver(&backBtnImgOver);
    backBtn.SetSoundOver(&btnSoundOver);
    backBtn.SetTrigger(&trigA);
    backBtn.SetEffectGrow();

    GuiOptionBrowser optionBrowser(552, 248, &options);
    optionBrowser.SetPosition(0, 108);
    optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    optionBrowser.SetCol2Position(185);

    HaltGui();
    GuiWindow w(screenwidth, screenheight);
    w.Append(&backBtn);
    mainWindow->Append(&optionBrowser);
    mainWindow->Append(&w);
    mainWindow->Append(&titleTxt);
    ResumeGui();

    while (menu == MENU_NONE) {
        UGUI();
        usleep(THREAD_SLEEP);

        ret = optionBrowser.GetClickedOption();

        switch (ret) {
            case 0:
                Settings.LoadMethod++;
                break;

            case 1:
                Settings.SaveMethod++;
                break;

            case 2:
                OnScreenKeyboard(Settings.Folder1, 256);
                break;

            case 3:
                OnScreenKeyboard(Settings.Folder2, 256);
                break;

            case 4:
                OnScreenKeyboard(Settings.Folder3, 256);
                break;

            case 5:
                Settings.AutoLoad++;
                if (Settings.AutoLoad > 2)
                    Settings.AutoLoad = 0;
                break;

            case 6:
                Settings.AutoSave++;
                if (Settings.AutoSave > 3)
                    Settings.AutoSave = 0;
                break;
        }

        if (ret >= 0 || firstRun) {
            firstRun = false;

            // correct load/save methods out of bounds
            if (Settings.LoadMethod > 4)
                Settings.LoadMethod = 0;
            if (Settings.SaveMethod > 6)
                Settings.SaveMethod = 0;

            if (Settings.LoadMethod == METHOD_AUTO) sprintf(options.value[0], "Auto Detect");
            else if (Settings.LoadMethod == METHOD_SD) sprintf(options.value[0], "SD");
            else if (Settings.LoadMethod == METHOD_USB) sprintf(options.value[0], "USB");
            else if (Settings.LoadMethod == METHOD_DVD) sprintf(options.value[0], "DVD");
            else if (Settings.LoadMethod == METHOD_SMB) sprintf(options.value[0], "Network");

            if (Settings.SaveMethod == METHOD_AUTO) sprintf(options.value[1], "Auto Detect");
            else if (Settings.SaveMethod == METHOD_SD) sprintf(options.value[1], "SD");
            else if (Settings.SaveMethod == METHOD_USB) sprintf(options.value[1], "USB");
            else if (Settings.SaveMethod == METHOD_SMB) sprintf(options.value[1], "Network");
            else if (Settings.SaveMethod == METHOD_MC_SLOTA) sprintf(options.value[1], "MC Slot A");
            else if (Settings.SaveMethod == METHOD_MC_SLOTB) sprintf(options.value[1], "MC Slot B");

            snprintf(options.value[2], 256, "%s", Settings.Folder1);
            snprintf(options.value[3], 256, "%s", Settings.Folder2);
            snprintf(options.value[4], 256, "%s", Settings.Folder3);

            if (Settings.AutoLoad == 0) sprintf(options.value[5], "Off");
            else if (Settings.AutoLoad == 1) sprintf(options.value[5], "Some");
            else if (Settings.AutoLoad == 2) sprintf(options.value[5], "All");

            if (Settings.AutoSave == 0) sprintf(options.value[5], "Off");
            else if (Settings.AutoSave == 1) sprintf(options.value[6], "Some");
            else if (Settings.AutoSave == 2) sprintf(options.value[6], "All");

            optionBrowser.TriggerUpdate();
        }

        if (backBtn.GetState() == STATE_CLICKED) {
            menu = MENU_SETTINGS;
        }

    }
    HaltGui();
    mainWindow->Remove(&optionBrowser);
    mainWindow->Remove(&w);
    mainWindow->Remove(&titleTxt);
    return menu;
}
Ejemplo n.º 8
0
/****************************************************************************
 * MenuBrowseDevice
 ***************************************************************************/
static int MenuBrowseDevice() {
    char title[100];
    int i;

    ShutoffRumble();

    // populate initial directory listing
    if (BrowseDevice() <= 0) {
        int choice = WindowPrompt(
                "Error",
                "Unable to display files on selected load device.",
                "Retry",
                "Check Settings");

        if (choice)
            return MENU_BROWSE_DEVICE;
        else
            return MENU_SETTINGS;
    }

    int menu = MENU_NONE;

    sprintf(title, "Browse Files");

    GuiText titleTxt(title, 28, ColorGrey);
    titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    titleTxt.SetPosition(100, 50);

    GuiTrigger trigA;
    //	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
    trigA.SetSimpleTrigger(-1, 0, PAD_BUTTON_A);

    GuiFileBrowser fileBrowser(1080, 496);
    fileBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    fileBrowser.SetPosition(0, 100);

    GuiImageData btnOutline(xenon_button_png);
    GuiImageData btnOutlineOver(xenon_button_over_png);

    GuiText backBtnTxt("Go Back", 24, ColorGrey2);
    GuiImage backBtnImg(&btnOutline);
    GuiImage backBtnImgOver(&btnOutlineOver);
    GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
    backBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
    backBtn.SetPosition(30, -35);
    backBtn.SetLabel(&backBtnTxt);
    backBtn.SetImage(&backBtnImg);
    backBtn.SetImageOver(&backBtnImgOver);
    backBtn.SetTrigger(&trigA);
    backBtn.SetEffectGrow();

    GuiWindow xenon_buttonWindow(screenwidth, screenheight);
    xenon_buttonWindow.Append(&backBtn);

    HaltGui();
    mainWindow->Append(&titleTxt);
    mainWindow->Append(&fileBrowser);
    mainWindow->Append(&xenon_buttonWindow);
    ResumeGui();

    while (menu == MENU_NONE) {
        UGUI();
        usleep(THREAD_SLEEP);

        // update file browser based on arrow xenon_buttons
        // set MENU_EXIT if A xenon_button pressed on a file
        for (i = 0; i < FILE_PAGESIZE; i++) {
            if (fileBrowser.fileList[i]->GetState() == STATE_CLICKED) {
                fileBrowser.fileList[i]->ResetState();
                // check corresponding browser entry
                if (browserList[browser.selIndex].isdir) {
                    if (BrowserChangeFolder()) {
                        fileBrowser.ResetState();
                        fileBrowser.fileList[0]->SetState(STATE_SELECTED);
                        fileBrowser.TriggerUpdate();
                    } else {
                        menu = MENU_BROWSE_DEVICE;
                        break;
                    }
                } else {
                    ShutoffRumble();
                    mainWindow->SetState(STATE_DISABLED);
                    // load file
                    printf("Launch : %s\r\n",browserList[browser.selIndex].filename);
                    mainWindow->SetState(STATE_DEFAULT);
                }
            }
        }
        if (backBtn.GetState() == STATE_CLICKED)
            menu = MENU_SETTINGS;
    }
    HaltGui();
    mainWindow->Remove(&titleTxt);
    mainWindow->Remove(&xenon_buttonWindow);
    mainWindow->Remove(&fileBrowser);
    return menu;
}