Example #1
0
/****************************************************************************
 * OnScreenKeyboard
 *
 * Opens an on-screen keyboard window, with the data entered being stored
 * into the specified variable.
 ***************************************************************************/
static void OnScreenKeyboard(char * var, u16 maxlen) {
    int save = -1;

    GuiKeyboard keyboard(var, maxlen);

    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 okBtnTxt("OK", 22, (GXColor) {
        0, 0, 0, 255
    });
    GuiImage okBtnImg(&btnOutline);
    GuiImage okBtnImgOver(&btnOutlineOver);
    GuiButton okBtn(btnOutline.GetWidth(), btnOutline.GetHeight());

    okBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
    okBtn.SetPosition(25, -25);

    okBtn.SetLabel(&okBtnTxt);
    okBtn.SetImage(&okBtnImg);
    okBtn.SetImageOver(&okBtnImgOver);
    okBtn.SetSoundOver(&btnSoundOver);
    okBtn.SetTrigger(&trigA);
    okBtn.SetEffectGrow();

    GuiText cancelBtnTxt("Cancel", 22, (GXColor) {
        0, 0, 0, 255
    });
    GuiImage cancelBtnImg(&btnOutline);
    GuiImage cancelBtnImgOver(&btnOutlineOver);
    GuiButton cancelBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
    cancelBtn.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
    cancelBtn.SetPosition(-25, -25);
    cancelBtn.SetLabel(&cancelBtnTxt);
    cancelBtn.SetImage(&cancelBtnImg);
    cancelBtn.SetImageOver(&cancelBtnImgOver);
    cancelBtn.SetSoundOver(&btnSoundOver);
    cancelBtn.SetTrigger(&trigA);
    cancelBtn.SetEffectGrow();

    keyboard.Append(&okBtn);
    keyboard.Append(&cancelBtn);

    HaltGui();
    mainWindow->SetState(STATE_DISABLED);
    mainWindow->Append(&keyboard);
    mainWindow->ChangeFocus(&keyboard);
    ResumeGui();

    while (save == -1) {
        UGUI();
        usleep(THREAD_SLEEP);

        if (okBtn.GetState() == STATE_CLICKED)
            save = 1;
        else if (cancelBtn.GetState() == STATE_CLICKED)
            save = 0;
    }

    if (save) {
        snprintf(var, maxlen, "%s", keyboard.kbtextstr);
    }

    HaltGui();
    mainWindow->Remove(&keyboard);
    mainWindow->SetState(STATE_DEFAULT);
    ResumeGui();
}
Example #2
0
/****************************************************************************
 * WindowPrompt
 *
 * Displays a prompt window to user, with information, an error message, or
 * presenting a user with a choice
 ***************************************************************************/
void
revtext(const char *msg)
{
	bool stop = false;

	GuiWindow promptWindow(520,360);
	promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	promptWindow.SetPosition(0, -10);
	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);

	GuiImageData dialogBox(Theme.dialog_background);
	GuiImage dialogBoxImg(&dialogBox);

	TextLine revtext;
	revtext.text(msg, 18, 400);

    int i = 0;
    int y = 90;
	int place = 25;

	int number = 7;

	GuiText upTxt("c", 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	upTxt.SetFont(symbol_ttf, symbol_ttf_size);
	upTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	upTxt.SetPosition(0, y -20);

	GuiText downTxt("d", 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	downTxt.SetFont(symbol_ttf, symbol_ttf_size);
	downTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	downTxt.SetPosition(0, y + (place * (number-1)) + 15);

	GuiText * Entrie[number];

	for(i=0; i < number && i < (signed)revtext.line.size(); i++)
	{
		Entrie[i] = new GuiText(revtext.line[i].c_str(), 20, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
		Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
		Entrie[i]->SetPosition(50, y);
		y += place;
	}

	GuiText titleTxt(tr("Info"), 26, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	titleTxt.SetPosition(0,40);

	GuiText backTxt(tr("OK"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiImage backImg(&btnOutline);
	GuiImage backImgOver(&btnOutlineOver);
	GuiButton back(btnOutline.GetWidth(), btnOutline.GetHeight());

	back.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
	back.SetPosition(0, -25);

	back.SetLabel(&backTxt);
	back.SetImage(&backImg);
	back.SetImageOver(&backImgOver);
	back.SetTrigger(&trigA);
	back.SetState(STATE_SELECTED);

	promptWindow.Append(&dialogBoxImg);
	promptWindow.Append(&titleTxt);

	for(int x=0; x < i; x++)
		promptWindow.Append(Entrie[x]);

	if((signed)revtext.line.size() >= number)
	{
		promptWindow.Append(&upTxt);
		promptWindow.Append(&downTxt);
	}

	promptWindow.Append(&back);

	HaltGui();
	mainWindow->SetState(STATE_DISABLED);
	mainWindow->Append(&promptWindow);
	mainWindow->ChangeFocus(&promptWindow);
	ResumeGui();

	while(!stop)
	{
		usleep(100);

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP) || PAD_ButtonsDown(0) & PAD_BUTTON_UP)
		{
			int z = revtext.text_up();

			for(int x=0; x < i; x++)
				Entrie[x]->SetText(revtext.line[x + z].c_str());


			HaltResumeGui();
		}

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN) || PAD_ButtonsDown(0) & PAD_BUTTON_DOWN)
		{
			int z = revtext.text_down(number);

			for(int x=0; x < i; x++)
				Entrie[x]->SetText(revtext.line[x + z].c_str());


			HaltResumeGui();
		}

		if(back.GetState() == STATE_CLICKED)
			stop = true;
	}

	HaltGui();
	mainWindow->Remove(&promptWindow);
	mainWindow->SetState(STATE_DEFAULT);
	ResumeGui();
}
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;
}
/****************************************************************************
 * Kategorie entfernen
 ***************************************************************************/
string eraseCategory()
{
	bool stop = true;
	int kategorieInt = 1;
	string kategoriename = AvailableCategory.categories[kategorieInt];

	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);

	GuiWindow promptWindow(520,360);
	promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	promptWindow.SetPosition(0, -10);

	GuiImageData dialogBox(Theme.dialog_background);
	GuiImage dialogBoxImg(&dialogBox);
	GuiImageData btnOutline(Theme.button_small);
	GuiImageData btnOutlineOver(Theme.button_small_focus);

	GuiText zeile1Txt(tr("Remove Category"), 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	zeile1Txt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	zeile1Txt.SetPosition(0, -100);

	GuiText zeile2Txt(AvailableCategory.categories[1].c_str(), 24, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	zeile2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	zeile2Txt.SetPosition(0, -10);

	GuiText zeile4Txt(tr("Select Category   (-/+)"), 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	zeile4Txt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	zeile4Txt.SetPosition(0, 60);

	GuiText okTxt(tr("Yes"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiImage okImg(&btnOutline);
	GuiImage okImgOver(&btnOutlineOver);
	GuiButton ok(btnOutline.GetWidth(), btnOutline.GetHeight());
	ok.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
	ok.SetPosition(-120, -25);
	ok.SetLabel(&okTxt);
	ok.SetImage(&okImg);
	ok.SetImageOver(&okImgOver);
	ok.SetTrigger(&trigA);

	GuiText backTxt(tr("No"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiImage backImg(&btnOutline);
	GuiImage backImgOver(&btnOutlineOver);
	GuiButton back(btnOutline.GetWidth(), btnOutline.GetHeight());
	back.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
	back.SetPosition(120, -25);
	back.SetLabel(&backTxt);
	back.SetImage(&backImg);
	back.SetImageOver(&backImgOver);
	back.SetTrigger(&trigA);
	back.SetTrigger(&trigB);
	back.SetState(STATE_SELECTED);

	promptWindow.Append(&dialogBoxImg);
	promptWindow.Append(&zeile1Txt);
	promptWindow.Append(&zeile2Txt);
	promptWindow.Append(&zeile4Txt);
	promptWindow.Append(&ok);
	promptWindow.Append(&back);

	HaltGui();
	mainWindow->SetState(STATE_DISABLED);
	mainWindow->Append(&promptWindow);
	mainWindow->ChangeFocus(&promptWindow);
	ResumeGui();

	while(stop)
	{
		usleep(100);

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS) || PAD_ButtonsDown(0) & PAD_TRIGGER_R
		   || WUPC_ButtonsDown(0) & WPAD_CLASSIC_BUTTON_PLUS)
		{
			kategorieInt++;
			if ( kategorieInt >= (signed)AvailableCategory.categories.size() )
				kategorieInt = 1;

			kategoriename = AvailableCategory.categories[kategorieInt];
			zeile2Txt.SetText(kategoriename.c_str());
			HaltResumeGui();
		}

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS) || PAD_ButtonsDown(0) & PAD_TRIGGER_L
		   || WUPC_ButtonsDown(0) & WPAD_CLASSIC_BUTTON_MINUS)
		{
			kategorieInt--;
			if ( kategorieInt < 1 )
				kategorieInt = AvailableCategory.categories.size() -1;

			kategoriename = AvailableCategory.categories[kategorieInt];
			zeile2Txt.SetText(kategoriename.c_str());
			HaltResumeGui();
		}

		if(ok.GetState() == STATE_CLICKED)
			stop = false;

		if(back.GetState() == STATE_CLICKED)
		{
			kategoriename = "NULL";
			stop = false;
		}
	}

	HaltGui();
	mainWindow->Remove(&promptWindow);
	mainWindow->SetState(STATE_DEFAULT);
	ResumeGui();

	return kategoriename;
}
Example #5
0
s32 Wad_Uninstall(FILE *fp)
{
	//////start the gui shit
   GuiWindow promptWindow(472,320);
	promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	promptWindow.SetPosition(0, -10);

	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), "%sdialogue_box.png", CFG.theme_path);
	GuiImageData dialogBox(imgPath, dialogue_box_png);
	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);

	GuiImage dialogBoxImg(&dialogBox);
	if (Settings.wsprompt == yes){
	dialogBoxImg.SetWidescreen(CFG.widescreen);}

	GuiText btn1Txt(tr("OK"), 22, THEME.prompttext);
	GuiImage btn1Img(&btnOutline);
	if (Settings.wsprompt == yes){
	btn1Txt.SetWidescreen(CFG.widescreen);
	btn1Img.SetWidescreen(CFG.widescreen);}
	GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -55, &trigA, &btnSoundOver, btnClick2,1);
	btn1.SetLabel(&btn1Txt);
	btn1.SetState(STATE_SELECTED);

    char title[50];
   sprintf(title, "%s", tr("Uninstalling wad"));
	GuiText titleTxt(title, 26, THEME.prompttext);
	titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	titleTxt.SetPosition(0,40);

	GuiText msg1Txt(NULL, 18, THEME.prompttext);
	msg1Txt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	msg1Txt.SetPosition(50,75);

	GuiText msg2Txt(NULL, 18, THEME.prompttext);
	msg2Txt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	msg2Txt.SetPosition(50, 98);

	GuiText msg3Txt(NULL, 18, THEME.prompttext);
	msg3Txt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	msg3Txt.SetPosition(50, 121);

	GuiText msg4Txt(NULL, 18, THEME.prompttext);
	msg4Txt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	msg4Txt.SetPosition(50, 144);

	GuiText msg5Txt(NULL, 18, THEME.prompttext);
	msg5Txt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	msg5Txt.SetPosition(50, 167);



	if ((Settings.wsprompt == yes) && (CFG.widescreen)){/////////////adjust for widescreen

		msg1Txt.SetPosition(70,95);
		msg2Txt.SetPosition(70, 118);
		msg3Txt.SetPosition(70, 141);
		msg4Txt.SetPosition(70, 164);
		msg5Txt.SetPosition(70, 187);

	}
	promptWindow.Append(&dialogBoxImg);
	promptWindow.Append(&titleTxt);
	promptWindow.Append(&msg5Txt);
	promptWindow.Append(&msg4Txt);
	promptWindow.Append(&msg3Txt);
	promptWindow.Append(&msg1Txt);
	promptWindow.Append(&msg2Txt);

	HaltGui();
	mainWindow->SetState(STATE_DISABLED);
	mainWindow->Append(&promptWindow);
	mainWindow->ChangeFocus(&promptWindow);
	ResumeGui();
	//sleep(3);

	///start the wad shit
	wadHeader *header	= NULL;
	void	  *pvoid	= NULL;
	tikview   *viewData = NULL;

	u64 tid;
	u32 viewCnt;
	s32 ret;

	msg1Txt.SetText(tr(">> Reading WAD data..."));

	// WAD header
	ret = __Wad_ReadAlloc(fp, &pvoid, 0, sizeof(wadHeader));
	if (ret < 0) {
		char errTxt[50];
		sprintf(errTxt,"%sret = %d",tr(">> Reading WAD data...ERROR! "),ret);
		msg1Txt.SetText(errTxt);
		//printf(" ERROR! (ret = %d)\n", ret);
		goto out;
	}
	SetPointer(header, pvoid);

	// Get title ID
	ret =  __Wad_GetTitleID(fp, header, &tid);
	if (ret < 0) {
		//printf(" ERROR! (ret = %d)\n", ret);
		char errTxt[50];
		sprintf(errTxt,"%sret = %d",tr(">> Reading WAD data...ERROR! "),ret);
		msg1Txt.SetText(errTxt);
		goto out;
	}

	msg1Txt.SetText(tr(">> Reading WAD data...Ok!"));
	msg2Txt.SetText(tr(">> Deleting tickets..."));

	// Get ticket views
	ret = Title_GetTicketViews(tid, &viewData, &viewCnt);
	if (ret < 0){
		char errTxt[50];
		sprintf(errTxt,"%sret = %d",tr(">> Deleting tickets...ERROR! "),ret);
		msg2Txt.SetText(errTxt);
		//printf(" ERROR! (ret = %d)\n", ret);
		}
	// Delete tickets
	if (ret >= 0) {
		u32 cnt;

		// Delete all tickets
		for (cnt = 0; cnt < viewCnt; cnt++) {
			ret = ES_DeleteTicket(&viewData[cnt]);
			if (ret < 0)
				break;
		}

		if (ret < 0){
			char errTxt[50];
			sprintf(errTxt,"%sret = %d",tr(">> Deleting tickets...ERROR! "),ret);
			msg2Txt.SetText(errTxt);}
			//printf(" ERROR! (ret = %d\n", ret);
		else
			//printf(" OK!\n");
			msg2Txt.SetText(tr(">> Deleting tickets...Ok! "));

	}

	msg3Txt.SetText(tr(">> Deleting title contents..."));
	//WindowPrompt(">> Deleting title contents...",0,"Back",0,0);

	// Delete title contents
	ret = ES_DeleteTitleContent(tid);
	if (ret < 0){
		char errTxt[50];
		sprintf(errTxt,"%sret = %d",tr(">> Deleting title contents...ERROR! "),ret);
		msg3Txt.SetText(errTxt);}
		//printf(" ERROR! (ret = %d)\n", ret);
	else
		//printf(" OK!\n");
		msg3Txt.SetText(tr(">> Deleting title contents...Ok!"));

	msg4Txt.SetText(tr(">> Deleting title..."));
	// Delete title
	ret = ES_DeleteTitle(tid);
	if (ret < 0){
		char errTxt[50];
		sprintf(errTxt,"%sret = %d",tr(">> Deleting title ...ERROR! "),ret);
		msg4Txt.SetText(errTxt);}
		//printf(" ERROR! (ret = %d)\n", ret);
	else
		//printf(" OK!\n");
		msg4Txt.SetText(tr(">> Deleting title ...Ok!"));

out:
	// Free memory
	if (header)
		free(header);

	goto exit;


exit:
	msg5Txt.SetText(tr("Done!"));
	promptWindow.Append(&btn1);
	while(btn1.GetState() != STATE_CLICKED){
	}


	HaltGui();
	mainWindow->Remove(&promptWindow);
	mainWindow->SetState(STATE_DEFAULT);
	ResumeGui();

	return ret;
}
/****************************************************************************
 * MetaEdit
 *
 * meta bearbeiten
 ***************************************************************************/
bool
MetaEdit(string dir)
{
	int choice = -1;
	bool changed = false;

	dir += "meta.xml";
	string line, quelltext;

	ifstream in(dir.c_str());
	while(getline(in, line))
		quelltext += line + "\n";

	GuiWindow promptWindow(520,360);
	promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	promptWindow.SetPosition(0, -10);
	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);

	GuiImageData dialogBox(Theme.dialog_background);
	GuiImage dialogBoxImg(&dialogBox);

	TextLine meta;
	meta.text(quelltext, 18, 440);

    int i = 0;
    int y = 90;
	int place = 25;

	int number = 7;
	int startline = 0;

	GuiText upTxt("c", 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	upTxt.SetFont(symbol_ttf, symbol_ttf_size);
	upTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	upTxt.SetPosition(0, y -20);

	GuiText downTxt("d", 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	downTxt.SetFont(symbol_ttf, symbol_ttf_size);
	downTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	downTxt.SetPosition(0, y + (place * (number-1)) + 15);

	GuiButton * Entrie[number];
	GuiText * EntrieTxt[number];

	for(i=0; i < number && i < (signed)meta.line.size(); i++)
	{
		EntrieTxt[i] = new GuiText(meta.line[i].c_str(), 18, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
		EntrieTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
		Entrie[i] = new GuiButton(440, 18);
		Entrie[i]->SetLabel(EntrieTxt[i]);
		Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
		Entrie[i]->SetPosition(40, y);
		Entrie[i]->SetTrigger(&trigA);
		y += place;
	}

	GuiText titleTxt("meta.xml", 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	titleTxt.SetPosition(0,40);

	GuiText backTxt(tr("OK"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiImage backImg(&btnOutline);
	GuiImage backImgOver(&btnOutlineOver);
	GuiButton back(btnOutline.GetWidth(), btnOutline.GetHeight());

	back.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
	back.SetPosition(0, -25);

	back.SetLabel(&backTxt);
	back.SetImage(&backImg);
	back.SetImageOver(&backImgOver);
	back.SetTrigger(&trigA);
	back.SetState(STATE_SELECTED);

	promptWindow.Append(&dialogBoxImg);
	promptWindow.Append(&titleTxt);

	for(int x=0; x < i; x++)
		promptWindow.Append(Entrie[x]);

	if((signed)meta.line.size() >= number)
	{
		promptWindow.Append(&upTxt);
		promptWindow.Append(&downTxt);
	}

	promptWindow.Append(&back);

	HaltGui();
	mainWindow->SetState(STATE_DISABLED);
	mainWindow->Append(&promptWindow);
	mainWindow->ChangeFocus(&promptWindow);
	ResumeGui();

	while(choice == -1)
	{
		usleep(100);

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP) || PAD_ButtonsDown(0) & PAD_BUTTON_UP
		   || WUPC_ButtonsDown(0) & WPAD_CLASSIC_BUTTON_UP)
		{
			startline = meta.text_up();

			for(int x=0; x < i; x++)
				EntrieTxt[x]->SetText(meta.line[x + startline].c_str());

			HaltResumeGui();
		}

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN) || PAD_ButtonsDown(0) & PAD_BUTTON_DOWN
		   || WUPC_ButtonsDown(0) & WPAD_CLASSIC_BUTTON_DOWN)
		{
			startline = meta.text_down(number);

			for(int x=0; x < i; x++)
				EntrieTxt[x]->SetText(meta.line[x + startline].c_str());

			HaltResumeGui();
		}

		if(back.GetState() == STATE_CLICKED)
			choice = 0;

		for(int x=0; x < i; x++)
		{
			if(Entrie[x]->GetState() == STATE_CLICKED)
			{
				Entrie[x]->ResetState();

				string temp = meta.line[x + startline];
				while((signed)temp.find("\n") != -1)
					temp.replace(temp.find("\n"), 1, "¶");

				char new_text[256];
				sprintf (new_text, "%s", temp.c_str());
				OnScreenKeyboard(new_text, 256, true);

				mainWindow->SetState(STATE_DISABLED);
				promptWindow.SetState(STATE_DEFAULT);

				if(strcasecmp(new_text,"NULL") != 0 )
				{
					changed = true;
					meta.line[x + startline] = new_text;
					while((signed)meta.line[x + startline].find("¶") != -1)
						meta.line[x + startline].replace(meta.line[x + startline].find("¶"), 1, "\n");

					EntrieTxt[x]->SetText(meta.line[x + startline].c_str());

					quelltext.clear();
					for(int a = 0; a < (signed)meta.line.size(); a++)
						quelltext += meta.line[a];

					meta.text(quelltext, 18, 440);
					for(int x=0; x < i; x++)
						EntrieTxt[x]->SetText(meta.line[x + startline].c_str());
				}

				break;
			}
		}
	}

	if(changed)
	{
		ofstream datei(dir.c_str());
		datei << quelltext;
	//	for(int i = 0; i < (signed)meta.line.size(); i++)
	//		datei << meta.line[i];
	}

	HaltGui();
	mainWindow->Remove(&promptWindow);
	mainWindow->SetState(STATE_DEFAULT);
	ResumeGui();
	return choice;
}
Example #7
0
string checkUpdatePrompt()
{
	GuiWindow promptWindow(520,360);
	promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	promptWindow.SetPosition(0, -10);

	GuiImageData dialogBox(Theme.dialog_background);
	GuiImage dialogBoxImg(&dialogBox);

	GuiImageData btnOutline(Theme.button_small);
	GuiImage btn1Img(&btnOutline);

	GuiImageData btnOutlineOver(Theme.button_small_focus);
	GuiImage btn1ImgOver(&btnOutlineOver);

	// ok button
	GuiText backTxt(tr("OK"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiImage backImg(&btnOutline);
	GuiImage backImgOver(&btnOutlineOver);
	GuiButton back(btnOutline.GetWidth(), btnOutline.GetHeight());
	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);

	back.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
	back.SetPosition(0, -25);
	back.SetLabel(&backTxt);
	back.SetImage(&backImg);
	back.SetImageOver(&backImgOver);
	back.SetTrigger(&trigA);
	back.SetState(STATE_SELECTED);

	GuiText titleTxt(tr("Update"), 26, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	titleTxt.SetPosition(0, 40);
	GuiText msgTxt(tr("Initialise network..."), 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);

	promptWindow.Append(&dialogBoxImg);
	promptWindow.Append(&titleTxt);
	promptWindow.Append(&msgTxt);

	HaltGui();
	mainWindow->SetState(STATE_DISABLED);
	mainWindow->Append(&promptWindow);
	mainWindow->ChangeFocus(&promptWindow);
	ResumeGui();

	string rev = "NULL";
	// berprfen, ob netzwerk initialisiert wird
	Initialize_Network();
	if(!IsNetworkInit())
	{
		msgTxt.SetText(tr("No network connection"));
		bool stop = false;

		promptWindow.Append(&back);
		while(!stop)
		{
			usleep(100);

			if(back.GetState() == STATE_CLICKED)
				stop = true;
		}
		promptWindow.Remove(&back);
	}
	else
	{
		string revs = CheckNewVersions();
		if(revs == "error")
		{
			msgTxt.SetText(tr("Error while reading file"));
			bool stop = false;

			promptWindow.Append(&back);
			while(!stop)
			{
				usleep(100);

				if(back.GetState() == STATE_CLICKED)
					stop = true;
			}
			promptWindow.Remove(&back);
		}
		else
			rev = choiceRev(revs);
	}

	HaltGui();
	mainWindow->Remove(&promptWindow);
	mainWindow->SetState(STATE_DEFAULT);
	ResumeGui();

	return rev;
}
Example #8
0
/********************************************************************************
* TitleBrowser- opens a browser with a list of installed Titles
* relies on code from any title deleter.
*********************************************************************************/
int TitleBrowser(u32 type) {

	u32 num_titles;
	u32 titles[100] ATTRIBUTE_ALIGN(32);
	u32 num_sys_titles;
	u32 sys_titles[10] ATTRIBUTE_ALIGN(32);
	s32 ret = -1;
	int numtitle;//to get rid of a stupid compile wrning
	//open the database file
	FILE *f;
	char path[100];

	ISFS_Initialize();

	sprintf(path,"%s/config/database.txt",bootDevice);
	f = fopen(path, "r");

	// Get count of titles of our requested type
	ret = getTitles_TypeCount(type, &num_titles);
	if (ret < 0) {
		//printf("\tError! Can't get count of titles! (ret = %d)\n", ret);
		//exit(1);
	}

	// Get titles of our requested type
	ret = getTitles_Type(type, titles, num_titles);
	if (ret < 0) {
		//printf("\tError! Can't get list of titles! (ret = %d)\n", ret);
		//exit(1);
	}

	// Get count of system titles
	ret = getTitles_TypeCount(0x00010002, &num_sys_titles);
	if (ret < 0) {
		//printf("\tError! Can't get count of titles! (ret = %d)\n", ret);
		//exit(1);
	}

	// Get system titles
	ret = getTitles_Type(0x00010002, sys_titles, num_sys_titles);
	if (ret < 0) {
		//printf("\tError! Can't get list of titles! (ret = %d)\n", ret);
		//exit(1);
	}


	//this array will hold all the names for the titles so we only have to get them one time
	char name[num_titles+num_sys_titles][50];

	customOptionList options3(num_titles+num_sys_titles+1);
	//write the titles on the option browser
	u32 i = 0;



	//first add the good stuff
	while (i < num_titles) {
		//start from the beginning of the file each loop
		if (f)rewind(f);
		//char name[50];
		char text[15];
		strcpy(name[i],"");//make sure name is empty
		u8 found=0;
		//set the title's name, number, ID to text
		sprintf(text, "%s", titleText(type, titles[i]));

		//get name from database cause i dont like the ADT function
		char line[200];
		char tmp[50];
		snprintf(tmp,50," ");
		
		//check if the content.bin is on the SD card for that game
		//if there is content.bin,then the game is on the SDmenu and not the wii
		sprintf(line,"SD:/private/wii/title/%s/content.bin",text);
		if (!checkfile(line))
			{
				if (f) {
					while (fgets(line, sizeof(line), f)) {
						if (line[0]== text[0]&&
								line[1]== text[1]&&
								line[2]== text[2]) {
							int j=0;
							found=1;
							for (j=0;(line[j+4]!='\0' || j<51);j++)

								tmp[j]=line[j+4];
							snprintf(name[i],sizeof(name[i]),"%s",tmp);
							//break;
						}
					}
				}
				if (!found) {
					if (getName00(name[i], TITLE_ID(type, titles[i]),CONF_GetLanguage()*2)>=0)
						found=2;

					if (!found) {
						if (getNameBN(name[i], TITLE_ID(type, titles[i]))>=0)
							found=3;

						if (!found)
							snprintf(name[i],sizeof(name[i]),"Unknown Title (%08x)",titles[i]);
					}
				}

				//set the text to the option browser
				options3.SetName(i, "%s",text);
				options3.SetValue(i, "%s",name[i]);
				//options3.SetValue(i, " (%08x) %s",titles[i],name[i]);//use this line to show the number to call to launch the channel
				//move on to the next title
			}
        i++;
    }

    // now add the crappy system titles
    while (i < num_titles+num_sys_titles) {
        //start from the beginning of the file each loop
        if (f)rewind(f);
        //char name[50];
        char text[15];
        strcpy(name[i],"");//make sure name is empty
        u8 found=0;
        //set the title's name, number, ID to text
        sprintf(text, "%s", titleText(0x00010002, sys_titles[i-num_titles]));

        //get name from database cause i dont like the ADT function
        char line[200];
        char tmp[50];
        snprintf(tmp,50," ");
        //snprintf(name[i],sizeof(name[i]),"Unknown Title");
        if (f) {
            while (fgets(line, sizeof(line), f)) {
                if (line[0]== text[0]&&
                        line[1]== text[1]&&
                        line[2]== text[2]) {
                    int j=0;
                    found=1;
                    for (j=0;(line[j+4]!='\0' || j<51);j++)

                        tmp[j]=line[j+4];
                    snprintf(name[i],sizeof(name[i]),"%s",tmp);
                    break;
                }
            }
        }
        if (!found) {
            if (getName00(name[i], TITLE_ID(0x00010002, sys_titles[i-num_titles]))>=0)
                found=2;

            if (!found) {
                if (getNameBN(name[i], TITLE_ID(0x00010002, sys_titles[i-num_titles]))>=0)
                    found=3;

                if (!found)
                    snprintf(name[i],sizeof(name[i]),"Unknown Title (%08x)",sys_titles[i-num_titles]);
            }
        }

        //set the text to the option browser
        options3.SetName(i, "%s",text);
        options3.SetValue(i, "%s",name[i]);
        //options3.SetValue(i, " (%08x) %s",titles[i],name[i]);//use this line to show the number to call to launch the channel
        //move on to the next title
        i++;
    }
    if (i == num_titles+num_sys_titles) {
        options3.SetName(i, " ");
        options3.SetValue(i, "%s",tr("Wii Settings"));
    }
    //we have all the titles we need so close the database and stop poking around in the wii
    fclose(f);

    //get rid of our footprints in there
    Uninstall_FromTitle(TITLE_ID(1, 0));
    ISFS_Deinitialize();
    bool exit = false;

    if (IsNetworkInit())
        ResumeNetworkWait();

    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), "%sgamesettings_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 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);

    GuiText titleTxt(tr("Title Launcher"), 28, (GXColor) {0, 0, 0, 255});
    titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    titleTxt.SetPosition(12,40);
    titleTxt.SetMaxWidth(356, GuiText::SCROLL);

    GuiImage settingsbackground(&settingsbg);
    GuiButton settingsbackgroundbtn(settingsbackground.GetWidth(), settingsbackground.GetHeight());
    settingsbackgroundbtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    settingsbackgroundbtn.SetPosition(0, 0);
    settingsbackgroundbtn.SetImage(&settingsbackground);

    GuiText cancelBtnTxt(tr("Back"), 22, THEME.prompttext);
    cancelBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
    GuiImage cancelBtnImg(&btnOutline);
    if (Settings.wsprompt == yes) {
        cancelBtnTxt.SetWidescreen(CFG.widescreen);
        cancelBtnImg.SetWidescreen(CFG.widescreen);
    }
    GuiButton cancelBtn(&cancelBtnImg,&cancelBtnImg, 2, 3, 180, 400, &trigA, &btnSoundOver, btnClick2,1);
    cancelBtn.SetScale(0.9);
    cancelBtn.SetLabel(&cancelBtnTxt);
    cancelBtn.SetTrigger(&trigB);

    u8 scrollbaron = 0;
    if (num_titles > 9)
        scrollbaron = 1;

    GuiCustomOptionBrowser optionBrowser3(396, 280, &options3, CFG.theme_path, "bg_options_gamesettings.png", bg_options_settings_png, num_titles+num_sys_titles>9?1:0, 200);
    optionBrowser3.SetPosition(0, 90);
    optionBrowser3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);

    snprintf(imgPath, sizeof(imgPath), "%sWifi_btn.png", CFG.theme_path);
    GuiImageData wifiImgData(imgPath, Wifi_btn_png);
    GuiImage wifiImg(&wifiImgData);
    if (Settings.wsprompt == yes) {
        wifiImg.SetWidescreen(CFG.widescreen);
    }
    GuiButton wifiBtn(wifiImg.GetWidth(), wifiImg.GetHeight());
    wifiBtn.SetImage(&wifiImg);
    wifiBtn.SetPosition(100, 400);
    wifiBtn.SetEffectGrow();
    wifiBtn.SetAlpha(80);
    wifiBtn.SetTrigger(&trigA);

    GuiTrigger trigZ;
    trigZ.SetButtonOnlyTrigger(-1, WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL, PAD_TRIGGER_Z);

    GuiButton screenShotBtn(0,0);
    screenShotBtn.SetPosition(0,0);
    screenShotBtn.SetTrigger(&trigZ);

    HaltGui();
    GuiWindow w(screenwidth, screenheight);
    w.Append(&screenShotBtn);
    w.Append(&settingsbackgroundbtn);
    w.Append(&titleTxt);
    w.Append(&cancelBtn);
    w.Append(&wifiBtn);
    w.Append(&optionBrowser3);

    mainWindow->Append(&w);


    int tmp=num_titles+num_sys_titles;
    ResumeGui();
    numtitle=num_titles;
    while (!exit) {
        VIDEO_WaitVSync();

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

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

                ResumeNetworkWait();
                wifiBtn.ResetState();
        }

        if (IsNetworkInit()) {
                wifiBtn.SetAlpha(255);
        }

        ret = optionBrowser3.GetClickedOption();

        if (ret > -1) {//if a click happened

            //char name[50];
            char text[15];
            if (f)rewind(f);
            //strcpy(name,"");//make sure name is empty

            if (ret<numtitle) {
                //set the title's name, number, ID to text
                sprintf(text, "%s", titleText(type, titles[ret]));

                char temp[100];
                //prompt to boot selected title
                snprintf(temp, sizeof(temp), "%s : %s",text,name[ret]);
                int  choice = WindowPrompt(tr("Boot?"), temp, tr("OK"), tr("Cancel"));
                if (choice) {//if they say yes


                    //stop all this stuff before starting the channel

                    CloseXMLDatabase();
                    ExitGUIThreads();
                    ShutdownAudio();
                    StopGX();
                    WII_Initialize();
                    WII_LaunchTitle(TITLE_ID(type,titles[ret]));
                    //this really shouldn't be needed because the title will be booted
                    exit = true;
                    break;
                } else {
                    //if they said no to booting the title
                    ret = -1;
                    optionBrowser3.ResetState();
                }

            } else { //if they clicked a system title
                if (ret == tmp) {
                    CloseXMLDatabase();
                    ExitGUIThreads();
                    ShutdownAudio();
                    StopGX();
                    WII_Initialize();
                    WII_ReturnToSettings();

                } else {
                    //set the title's name, number, ID to text
                    sprintf(text, "%s", titleText(0x00010002, sys_titles[ret-num_titles]));

                    char temp[112];
                    //prompt to boot selected title
					snprintf(temp, sizeof(temp), tr("%s : %s May not boot correctly if your System Menu is not up to date."),text,name[ret]);
                    int  choice = WindowPrompt(tr("Boot?"), temp, tr("OK"), tr("Cancel"));
                    if (choice) {//if they say yes


                        //stop all this stuff before starting the channel

                        CloseXMLDatabase();
                        ExitGUIThreads();
                        ShutdownAudio();
                        StopGX();
                        WII_Initialize();
                        WII_LaunchTitle(TITLE_ID(0x00010002,sys_titles[ret-num_titles]));
                        //this really shouldn't be needed because the title will be booted
                        exit = true;
                        break;
                    } else {
                        //if they said no to booting the title
                        ret = -1;
                        optionBrowser3.ResetState();
                    }
                }
            }
        }

        if(infilesize > 0) {

                char filesizetxt[50];
                char temp[50];
                char filepath[100];
//				u32 read = 0;
				
				//make sure there is a folder for this to be saved in
				struct stat st;
                snprintf(filepath, sizeof(filepath), "%s/wad/", bootDevice);
				if (stat(filepath, &st) != 0) {
						if (subfoldercreate(filepath) != 1) {
							WindowPrompt(tr("Error !"),tr("Can't create directory"),tr("OK"));
						}
					}
				snprintf(filepath, sizeof(filepath), "%s/wad/tmp.tmp", bootDevice);
				

                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"));
		gprintf("\nchoice:%d",choice);

		if (choice == 1) {

			u32 read = 0;
			u8 *temp = NULL;
			int len = NETWORKBLOCKSIZE;
			temp = (u8 *) malloc(infilesize);

						bool error = false;
						u8 *ptr = temp;
						gprintf("\nrecieving shit");
			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) {
				gprintf("\n!RESULT");
				break;
							}
			    ptr += result;
			    read += result;
			}
			ProgressStop();

						char filename[101];
						char tmptxt[200];



						//bool installWad=0;
						if (!error) {
						    gprintf("\nno error yet");

							network_read((u8*) &filename, 100);
							gprintf("\nfilename: %s",filename);

							// Do we need to unzip this thing?
							if (wiiloadVersion[0] > 0 || wiiloadVersion[1] > 4) {
							    gprintf("\nusing newer wiiload version");

								if (uncfilesize != 0) { // if uncfilesize == 0, it's not compressed
								    gprintf("\ntrying to uncompress");
									// 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) {
								sprintf(tmptxt,"%s",filename);
								//if we got a wad
								if (strcasestr(tmptxt,".wad")) {
								    FILE *file = fopen(filepath, "wb");
								    fwrite(temp, 1, (uncfilesize>0?uncfilesize:infilesize), file);
								    fclose(file);

								    sprintf(tmptxt,"%s/wad/%s",bootDevice,filename);
								    if (checkfile(tmptxt))remove(tmptxt);
								    rename(filepath, tmptxt);

								    //check and make sure the wad we just saved is the correct size
								    u32 lSize;
								    file = fopen(tmptxt, "rb");

								    // obtain file size:
								    fseek (file , 0 , SEEK_END);
								    lSize = ftell (file);

								    rewind (file);
								    if (lSize==(uncfilesize>0?uncfilesize:infilesize)) {
									gprintf("\nsize is ok");
									int pick = WindowPrompt(tr(" Wad Saved as:"), tmptxt, tr("Install"),tr("Uninstall"),tr("Cancel"));
									//install or uninstall it
									if (pick==1)
										{
											HaltGui();
											w.Remove(&titleTxt);
											w.Remove(&cancelBtn);
											w.Remove(&wifiBtn);
											w.Remove(&optionBrowser3);
											ResumeGui();

											Wad_Install(file);

											HaltGui();
											w.Append(&titleTxt);
											w.Append(&cancelBtn);
											w.Append(&wifiBtn);
											w.Append(&optionBrowser3);
											ResumeGui();

										}
									if (pick==2)Wad_Uninstall(file);
								    }
								    else gprintf("\nBad size");
								    //close that beast, we're done with it
								    fclose (file);

								    //do we want to keep the file in the wad folder
								    if (WindowPrompt(tr("Delete ?"), tmptxt, tr("Delete"),tr("Keep"))!=0)
									remove(tmptxt);
								    }
								else {
								    WindowPrompt(tr("ERROR:"), tr("Not a WAD file."), tr("OK"));
								    }
							}
						}



			if (error || read != infilesize) {
			    WindowPrompt(tr("Error:"), tr("No data could be read."), tr("OK"));


			}
			if(temp)free(temp);
		}



		CloseConnection();
                ResumeNetworkWait();
        }

        if (cancelBtn.GetState() == STATE_CLICKED) {
            //break the loop and end the function
            exit = true;
            ret = -10;
        }
	else if (screenShotBtn.GetState() == STATE_CLICKED) {
			gprintf("\n\tscreenShotBtn clicked");
			screenShotBtn.ResetState();
			ScreenShot();
			gprintf("...It's easy, mmmmmmKay");
		    }
    }

    CloseConnection();
    if (IsNetworkInit())
        HaltNetworkThread();

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

    return ret;
}
/****************************************************************************
 * gameinfo
 ***************************************************************************/
static int InternalShowGameInfo(struct discHdr *header)
{
	mainWindow->SetState(STATE_DISABLED);

	char ID[7];
	strlcpy(ID, (char *) header->id, sizeof(ID));

	char xmlpath[300];
	snprintf(xmlpath, sizeof(xmlpath), "%swiitdb.xml", Settings.titlestxt_path);

	GameTDB XML_DB;

	if(!XML_DB.OpenFile(xmlpath))
	{
		ShowError(tr("Could not open wiitdb.xml."));
		return -1;
	}

	XML_DB.SetLanguageCode(Settings.db_language);

	GameXMLInfo GameInfo;

	if(!XML_DB.GetGameXMLInfo(ID, &GameInfo))
	{
		ShowError(tr("Could not find info for this game in the wiitdb.xml."));
		return -1;
	}

	XML_DB.CloseFile();

	int choice = -1;
	int titley = 10;
	int marginY = titley + 40;
	int indexy = marginY;
	int wifiY = 0;
	int intputX = 200, inputY = -30, txtXOffset = 90;
	u8 nunchuk = 0, classiccontroller = 0, balanceboard = 0, dancepad = 0, guitar = 0, gamecube = 0, wheel = 0,
			motionplus = 0, drums = 0, microphone = 0, zapper = 0, nintendods = 0,
			//vitalitysensor=0,
			wiispeak = 0;
	int newline = 1;
	u8 page = 1;

	BoxCover * boxCov = NULL;
	GuiImageData * playersImgData = NULL;
	GuiImage * playersImg = NULL;

	GuiImageData * wifiplayersImgData = NULL;
	GuiImage * wifiplayersImg = NULL;
	GuiImage * ratingImg = NULL;

	GuiImage * classiccontrollerImg = NULL;
	GuiImage * nunchukImg = NULL;
	GuiImage * guitarImg = NULL;
	GuiImage * drumsImg = NULL;
	GuiImage * dancepadImg = NULL;
	GuiImage * motionplusImg = NULL;
	GuiImage * wheelImg = NULL;
	GuiImage * balanceboardImg = NULL;
	GuiImage * microphoneImg = NULL;
	GuiImage * zapperImg = NULL;
	GuiImage * nintendodsImg = NULL;
	GuiImage * wiispeakImg = NULL;
	//GuiImage * vitalitysensorImg = NULL;
	GuiImage * gcImg = NULL;
	GuiImage * dialogBoxImg1 = NULL;
	GuiImage * dialogBoxImg2 = NULL;
	GuiImage * dialogBoxImg3 = NULL;
	GuiImage * dialogBoxImg4 = NULL;
	GuiImage * dialogBoxImg11 = NULL;
	GuiImage * dialogBoxImg22 = NULL;
	GuiImage * dialogBoxImg33 = NULL;
	GuiImage * dialogBoxImg44 = NULL;
	GuiImage * coverImg = NULL;

	GuiImageData * classiccontrollerImgData = NULL;
	GuiImageData * nunchukImgData = NULL;
	GuiImageData * guitarImgData = NULL;
	GuiImageData * drumsImgData = NULL;
	GuiImageData * motionplusImgData = NULL;
	GuiImageData * wheelImgData = NULL;
	GuiImageData * balanceboardImgData = NULL;
	GuiImageData * dancepadImgData = NULL;
	GuiImageData * microphoneImgData = NULL;
	GuiImageData * zapperImgData = NULL;
	GuiImageData * nintendodsImgData = NULL;
	GuiImageData * wiispeakImgData = NULL;
	//GuiImageData * vitalitysensorImgData = NULL;
	GuiImageData * gamecubeImgData = NULL;
	GuiImageData * ratingImgData = NULL;
	GuiImageData * cover = NULL;

	GuiText * releasedTxt = NULL;
	GuiText * publisherTxt = NULL;
	GuiText * developerTxt = NULL;
	GuiText * titleTxt = NULL;
	Text * synopsisTxt = NULL;
	GuiText * genreTitleTxt = NULL;
	GuiText ** genreTxt = NULL;
	GuiText ** wifiTxt = NULL;
	GuiText * gametdb1Txt = NULL;
	GuiText * memTxt = NULL;

	GuiWindow gameinfoWindow(600, 308);
	gameinfoWindow.SetAlignment(ALIGN_CENTER, ALIGN_MIDDLE);
	gameinfoWindow.SetPosition(0, -50);

	GuiWindow InfoWindow(600, 308);
	InfoWindow.SetAlignment(ALIGN_LEFT, ALIGN_TOP);

	GuiWindow txtWindow(350, 270);
	txtWindow.SetAlignment(ALIGN_CENTER, ALIGN_TOP);
	txtWindow.SetPosition(95, 40);

	GuiImageData dialogBox1(Resources::GetFile("gameinfo1.png"), Resources::GetFileSize("gameinfo1.png"));
	GuiImageData dialogBox2(Resources::GetFile("gameinfo1a.png"), Resources::GetFileSize("gameinfo1a.png"));
	GuiImageData dialogBox3(Resources::GetFile("gameinfo2.png"), Resources::GetFileSize("gameinfo2.png"));
	GuiImageData dialogBox4(Resources::GetFile("gameinfo2a.png"), Resources::GetFileSize("gameinfo2a.png"));

	GuiTrigger trig1;
	trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1 | WPAD_CLASSIC_BUTTON_X, 0);
	GuiTrigger trigA;
	trigA.SetButtonOnlyTrigger(-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);
	GuiTrigger trigU;
	trigU.SetButtonOnlyTrigger(-1, WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP, PAD_BUTTON_UP);
	GuiTrigger trigD;
	trigD.SetButtonOnlyTrigger(-1, WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN, PAD_BUTTON_DOWN);
	GuiTrigger trigH;
	trigH.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0);

	//buttons for changing between synopsis and other info
	GuiButton backBtn(0, 0);
	backBtn.SetPosition(-20, -20);
	backBtn.SetTrigger(&trigB);
	gameinfoWindow.Append(&backBtn);

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

	GuiTrigger trigLeft;
	trigLeft.SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT);

	GuiTrigger trigRight;
	trigRight.SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT);

	GuiButton LeftBtn(0, 0);
	LeftBtn.SetTrigger(&trigLeft);
	if(header->type != TYPE_GAME_WII_DISC && header->type != TYPE_GAME_GC_DISC)
		gameinfoWindow.Append(&LeftBtn);

	GuiButton RightBtn(0, 0);
	RightBtn.SetTrigger(&trigRight);
	if(header->type != TYPE_GAME_WII_DISC && header->type != TYPE_GAME_GC_DISC)
		gameinfoWindow.Append(&RightBtn);

	GuiButton coverBtn(180, 250);
	coverBtn.SetPosition(20, 20);
	coverBtn.SetTrigger(&trigA_Simple);
	gameinfoWindow.Append(&coverBtn);

	GuiButton nextBtn(400, 300);
	nextBtn.SetPosition(200, 20);
	nextBtn.SetTrigger(&trigA_Simple);
	gameinfoWindow.Append(&nextBtn);

	//buttons for scrolling the synopsis
	GuiButton upBtn(0, 0);
	upBtn.SetPosition(0, 0);
	upBtn.SetTrigger(&trigU);

	GuiButton dnBtn(0, 0);
	dnBtn.SetPosition(0, 0);
	dnBtn.SetTrigger(&trigD);

	GuiButton homeBtn(0, 0);
	homeBtn.SetPosition(0, 0);
	homeBtn.SetTrigger(&trigH);
	gameinfoWindow.Append(&homeBtn);

	char linebuf2[100] = "";

	// enable icons for required accessories
	for (u32 i = 0; i < GameInfo.AccessoirList.size(); ++i)
	{
		if(!GameInfo.AccessoirList[i].Required)
			continue;

		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "classiccontroller") == 0) classiccontroller = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "nunchuk") == 0) nunchuk = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "guitar") == 0) guitar = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "drums") == 0) drums = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "dancepad") == 0) dancepad = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "motionplus") == 0) motionplus = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "wheel") == 0) wheel = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "balanceboard") == 0) balanceboard = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "microphone") == 0) microphone = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "zapper") == 0) zapper = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "nintendods") == 0) nintendods = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "wiispeak") == 0) wiispeak = 1;
		//if (strcmp(GameInfo.AccessoirList[i].Name.c_str(),"vitalitysensor")==0)
		//   vitalitysensor=1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "gamecube") == 0) gamecube = 1;
	}

	// switch icons
	if (nunchuk)
		nunchukImgData = Resources::GetImageData("nunchukR.png");
	else nunchukImgData = Resources::GetImageData("nunchuk.png");

	if (classiccontroller)
		classiccontrollerImgData = Resources::GetImageData("classiccontrollerR.png");
	else classiccontrollerImgData = Resources::GetImageData("classiccontroller.png");

	if (guitar)
		guitarImgData = Resources::GetImageData("guitarR.png");
	else guitarImgData = Resources::GetImageData("guitar.png");

	if (gamecube)
		gamecubeImgData = Resources::GetImageData("gcncontrollerR.png");
	else gamecubeImgData = Resources::GetImageData("gcncontroller.png");

	if (wheel)
		wheelImgData = Resources::GetImageData("wheelR.png");
	else wheelImgData = Resources::GetImageData("wheel.png");

	if (motionplus)
		motionplusImgData = Resources::GetImageData("motionplusR.png");
	else motionplusImgData = Resources::GetImageData("motionplus.png");

	if (drums)
		drumsImgData = Resources::GetImageData("drumsR.png");
	else drumsImgData = Resources::GetImageData("drums.png");

	if (microphone)
		microphoneImgData = Resources::GetImageData("microphoneR.png");
	else microphoneImgData = Resources::GetImageData("microphone.png");

	if (zapper)
		zapperImgData = Resources::GetImageData("zapperR.png");
	else zapperImgData = Resources::GetImageData("zapper.png");

	if (wiispeak)
		wiispeakImgData = Resources::GetImageData("wiispeakR.png");
	else wiispeakImgData = Resources::GetImageData("wiispeak.png");

	if (nintendods)
		nintendodsImgData = Resources::GetImageData("nintendodsR.png");
	else nintendodsImgData = Resources::GetImageData("nintendods.png");

	if (balanceboard)
		balanceboardImgData = Resources::GetImageData("balanceboardR.png");
	else balanceboardImgData = Resources::GetImageData("balanceboard.png");

	if (dancepad)
		dancepadImgData = Resources::GetImageData("dancepadR.png");
	else dancepadImgData = Resources::GetImageData("dancepad.png");

	// look for optional accessories
	for (u32 i = 0; i < GameInfo.AccessoirList.size(); ++i)
	{
		if(GameInfo.AccessoirList[i].Required)
			continue;

		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "classiccontroller") == 0) classiccontroller = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "nunchuk") == 0) nunchuk = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "guitar") == 0) guitar = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "drums") == 0) drums = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "dancepad") == 0) dancepad = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "motionplus") == 0) motionplus = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "wheel") == 0) wheel = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "balanceboard") == 0) balanceboard = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "microphone") == 0) microphone = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "zapper") == 0) zapper = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "nintendods") == 0) nintendods = 1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "wiispeak") == 0) wiispeak = 1;
		//if (strcmp(GameInfo.AccessoirList[i].Name.c_str(),"vitalitysensor")==0)
		//	vitalitysensor=1;
		if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "gamecube") == 0) gamecube = 1;
	}

	dialogBoxImg1 = new GuiImage(&dialogBox1);
	dialogBoxImg1->SetAlignment(0, 3);
	dialogBoxImg1->SetPosition(-9, 0);

	dialogBoxImg2 = new GuiImage(&dialogBox2);
	dialogBoxImg2->SetAlignment(0, 3);
	dialogBoxImg2->SetPosition(145, 0);

	dialogBoxImg3 = new GuiImage(&dialogBox3);
	dialogBoxImg3->SetAlignment(0, 3);
	dialogBoxImg3->SetPosition(301, 0);

	dialogBoxImg4 = new GuiImage(&dialogBox4);
	dialogBoxImg4->SetAlignment(0, 3);
	dialogBoxImg4->SetPosition(457, 0);

	gameinfoWindow.Append(dialogBoxImg1);
	gameinfoWindow.Append(dialogBoxImg2);
	gameinfoWindow.Append(dialogBoxImg3);
	gameinfoWindow.Append(dialogBoxImg4);

	bool loadFlatCover = false;
	bool load3DCover = false;
	char imgPath[150];
	snprintf(imgPath, sizeof(imgPath), "%s/%s.png", Settings.coversFull_path, ID);
	if(!CheckFile(imgPath))
	{
		loadFlatCover = true;
		snprintf(imgPath, sizeof(imgPath), "%s/%s.png", Settings.covers2d_path, ID);
	}
	if(!CheckFile(imgPath))
	{
		loadFlatCover = false;
		load3DCover = true;
		snprintf(imgPath, sizeof(imgPath), "%s/%s.png", Settings.covers_path, ID);
	}
	cover = new GuiImageData(imgPath); //load full id image
	if (!cover->GetImage())
	{
		delete cover;
		cover = NULL;
	}

	if(load3DCover && cover) //! No cover is always 3D box
	{
		coverImg = new GuiImage(cover);
		coverImg->SetWidescreen(Settings.widescreen);
		coverImg->SetPosition(15, 30);
	}
	else
	{
		boxCov = new BoxCover(cover, loadFlatCover);
		boxCov->SetPosition(-1.6f, 0.4f, -27.0f);
		boxCov->SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 40);

		if(GameInfo.CaseColor == 0xFF0000)
		{
			boxCov->SetBoxColor((GXColor) { 198, 34, 4, 255 });
		}
		else if(GameInfo.CaseColor >= 0)
		{
			u8 * Color = (u8 *) &GameInfo.CaseColor;
			boxCov->SetBoxColor((GXColor) { Color[1], Color[2], Color[3], 255 });
		}

		gameinfoWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 100);
	}

	// # of players
	if (GameInfo.Players > 0)
	{
		if (GameInfo.Players == 1)
			playersImgData = Resources::GetImageData("wiimote1.png");

		else if (GameInfo.Players == 2)
			playersImgData = Resources::GetImageData("wiimote2.png");

		else if (GameInfo.Players == 3)
			playersImgData = Resources::GetImageData("wiimote3.png");

		else if (GameInfo.Players == 4)
			playersImgData = Resources::GetImageData("wiimote4.png");

		playersImg = new GuiImage(playersImgData);
		playersImg->SetWidescreen(Settings.widescreen);
		playersImg->SetPosition(intputX, inputY);
		playersImg->SetAlignment(0, 4);
		InfoWindow.Append(playersImg);
		intputX += (Settings.widescreen ? playersImg->GetWidth() * Settings.WSFactor : playersImg->GetWidth()) + 5;
	}

	//draw the input types for this game
	if (motionplus == 1)
	{
		motionplusImg = new GuiImage(motionplusImgData);
		motionplusImg->SetWidescreen(Settings.widescreen);
		motionplusImg->SetPosition(intputX, inputY);
		motionplusImg->SetAlignment(0, 4);
		InfoWindow.Append(motionplusImg);
		intputX += (Settings.widescreen ? motionplusImg->GetWidth() * Settings.WSFactor : motionplusImg->GetWidth()) + 5;
	}
	if (nunchuk == 1)
	{
		nunchukImg = new GuiImage(nunchukImgData);
		nunchukImg->SetWidescreen(Settings.widescreen);
		nunchukImg->SetPosition(intputX, inputY);
		nunchukImg->SetAlignment(0, 4);
		InfoWindow.Append(nunchukImg);
		intputX += (Settings.widescreen ? nunchukImg->GetWidth() * Settings.WSFactor : nunchukImg->GetWidth()) + 5;
	}
	if (classiccontroller == 1)
	{
		classiccontrollerImg = new GuiImage(classiccontrollerImgData);
		classiccontrollerImg->SetWidescreen(Settings.widescreen);
		classiccontrollerImg->SetPosition(intputX, inputY);
		classiccontrollerImg->SetAlignment(0, 4);
		InfoWindow.Append(classiccontrollerImg);
		intputX += (Settings.widescreen ? classiccontrollerImg->GetWidth() * Settings.WSFactor : classiccontrollerImg->GetWidth()) + 5;
	}
	if (gamecube == 1)
	{
		gcImg = new GuiImage(gamecubeImgData);
		gcImg->SetWidescreen(Settings.widescreen);
		gcImg->SetPosition(intputX, inputY);
		gcImg->SetAlignment(0, 4);
		InfoWindow.Append(gcImg);
		intputX += (Settings.widescreen ? gcImg->GetWidth() * Settings.WSFactor : gcImg->GetWidth()) + 5;
	}
	if (wheel == 1)
	{
		wheelImg = new GuiImage(wheelImgData);
		wheelImg->SetWidescreen(Settings.widescreen);
		wheelImg->SetPosition(intputX, inputY);
		wheelImg->SetAlignment(0, 4);
		InfoWindow.Append(wheelImg);
		intputX += (Settings.widescreen ? wheelImg->GetWidth() * Settings.WSFactor : wheelImg->GetWidth()) + 5;
	}
	if (guitar == 1)
	{
		guitarImg = new GuiImage(guitarImgData);
		guitarImg->SetWidescreen(Settings.widescreen);
		guitarImg->SetPosition(intputX, inputY);
		guitarImg->SetAlignment(0, 4);
		InfoWindow.Append(guitarImg);
		intputX += (Settings.widescreen ? guitarImg->GetWidth() * Settings.WSFactor : guitarImg->GetWidth()) + 5;
	}
	if (drums == 1)
	{
		drumsImg = new GuiImage(drumsImgData);
		drumsImg->SetWidescreen(Settings.widescreen);
		drumsImg->SetPosition(intputX, inputY);
		drumsImg->SetAlignment(0, 4);
		InfoWindow.Append(drumsImg);
		intputX += (Settings.widescreen ? drumsImg->GetWidth() * Settings.WSFactor : drumsImg->GetWidth()) + 5;
	}
	if (microphone == 1)
	{
		microphoneImg = new GuiImage(microphoneImgData);
		microphoneImg->SetWidescreen(Settings.widescreen);
		microphoneImg->SetPosition(intputX, inputY);
		microphoneImg->SetAlignment(0, 4);
		InfoWindow.Append(microphoneImg);
		intputX += (Settings.widescreen ? microphoneImg->GetWidth() * Settings.WSFactor : microphoneImg->GetWidth()) + 5;
	}
	if (zapper == 1)
	{
		zapperImg = new GuiImage(zapperImgData);
		zapperImg->SetWidescreen(Settings.widescreen);
		zapperImg->SetPosition(intputX, inputY);
		zapperImg->SetAlignment(0, 4);
		InfoWindow.Append(zapperImg);
		intputX += (Settings.widescreen ? zapperImg->GetWidth() * Settings.WSFactor : zapperImg->GetWidth()) + 5;
	}
	if (wiispeak == 1)
	{
		wiispeakImg = new GuiImage(wiispeakImgData);
		wiispeakImg->SetWidescreen(Settings.widescreen);
		wiispeakImg->SetPosition(intputX, inputY);
		wiispeakImg->SetAlignment(0, 4);
		InfoWindow.Append(wiispeakImg);
		intputX += (Settings.widescreen ? wiispeakImg->GetWidth() * Settings.WSFactor : wiispeakImg->GetWidth()) + 5;
	}
	if (nintendods == 1)
	{
		nintendodsImg = new GuiImage(nintendodsImgData);
		nintendodsImg->SetWidescreen(Settings.widescreen);
		nintendodsImg->SetPosition(intputX, inputY);
		nintendodsImg->SetAlignment(0, 4);
		InfoWindow.Append(nintendodsImg);
		intputX += (Settings.widescreen ? nintendodsImg->GetWidth() * Settings.WSFactor : nintendodsImg->GetWidth()) + 5;
	}
	if (dancepad == 1)
	{
		dancepadImg = new GuiImage(dancepadImgData);
		dancepadImg->SetWidescreen(Settings.widescreen);
		dancepadImg->SetPosition(intputX, inputY);
		dancepadImg->SetAlignment(0, 4);
		InfoWindow.Append(dancepadImg);
		intputX += (Settings.widescreen ? dancepadImg->GetWidth() * Settings.WSFactor : dancepadImg->GetWidth()) + 5;
	}
	if (balanceboard == 1)
	{
		balanceboardImg = new GuiImage(balanceboardImgData);
		balanceboardImg->SetWidescreen(Settings.widescreen);
		balanceboardImg->SetPosition(intputX, inputY);
		balanceboardImg->SetAlignment(0, 4);
		InfoWindow.Append(balanceboardImg);
		intputX += (Settings.widescreen ? balanceboardImg->GetWidth() * Settings.WSFactor : balanceboardImg->GetWidth()) + 5;
	}

	// # online players
	if (GameInfo.WifiPlayers > 0)
	{
		if(GameInfo.WifiPlayers == 1)
			wifiplayersImgData = Resources::GetImageData("wifi1.png");

		else if(GameInfo.WifiPlayers == 2)
			wifiplayersImgData = Resources::GetImageData("wifi2.png");

		else if(GameInfo.WifiPlayers == 4)
			wifiplayersImgData = Resources::GetImageData("wifi4.png");

		else if(GameInfo.WifiPlayers == 6)
			wifiplayersImgData = Resources::GetImageData("wifi6.png");

		else if(GameInfo.WifiPlayers == 10)
			wifiplayersImgData = Resources::GetImageData("wifi10.png");

		else if(GameInfo.WifiPlayers == 8)
			wifiplayersImgData =Resources::GetImageData("wifi8.png");

		else if(GameInfo.WifiPlayers == 12)
			wifiplayersImgData = Resources::GetImageData("wifi12.png");

		else if(GameInfo.WifiPlayers == 16)
			wifiplayersImgData = Resources::GetImageData("wifi16.png");

		else if(GameInfo.WifiPlayers == 32)
			wifiplayersImgData = Resources::GetImageData("wifi32.png");

		wifiplayersImg = new GuiImage(wifiplayersImgData);
		wifiplayersImg->SetWidescreen(Settings.widescreen);
		wifiplayersImg->SetPosition(intputX, inputY);
		wifiplayersImg->SetAlignment(0, 4);
		InfoWindow.Append(wifiplayersImg);
		intputX += (Settings.widescreen ? wifiplayersImg->GetWidth() * Settings.WSFactor : wifiplayersImg->GetWidth()) + 5;
	}

	// ratings
	if (GameInfo.RatingType >= 0)
	{
		if (GameInfo.RatingType == 1)
		{
			if (strcmp(GameInfo.RatingValue.c_str(), "EC") == 0)
				ratingImgData = Resources::GetImageData("esrb_ec.png");
			else if (strcmp(GameInfo.RatingValue.c_str(), "E") == 0)
				ratingImgData = Resources::GetImageData("esrb_e.png");
			else if (strcmp(GameInfo.RatingValue.c_str(), "E10+") == 0)
				ratingImgData = Resources::GetImageData("esrb_eten.png");
			else if (strcmp(GameInfo.RatingValue.c_str(), "T") == 0)
				ratingImgData = Resources::GetImageData("esrb_t.png");
			else if (strcmp(GameInfo.RatingValue.c_str(), "M") == 0)
				ratingImgData = Resources::GetImageData("esrb_m.png");
			else if (strcmp(GameInfo.RatingValue.c_str(), "AO") == 0)
				ratingImgData = Resources::GetImageData("esrb_ao.png");
			else
				ratingImgData = Resources::GetImageData("norating.png");
		} //there are 2 values here cause some countries are stupid and
		else if (GameInfo.RatingType == 2) //can't use the same as everybody else
		{
			if ((strcmp(GameInfo.RatingValue.c_str(), "3") == 0) || (strcmp(GameInfo.RatingValue.c_str(), "4") == 0))
				ratingImgData = Resources::GetImageData("pegi_3.png");
			else if ((strcmp(GameInfo.RatingValue.c_str(), "7") == 0) || (strcmp(GameInfo.RatingValue.c_str(), "7") == 0))
				ratingImgData = Resources::GetImageData("pegi_7.png");
			else if (strcmp(GameInfo.RatingValue.c_str(), "12") == 0)
				ratingImgData = Resources::GetImageData("pegi_12.png");
			else if ((strcmp(GameInfo.RatingValue.c_str(), "16") == 0) || (strcmp(GameInfo.RatingValue.c_str(), "15") == 0))
				ratingImgData = Resources::GetImageData("pegi_16.png");
			else if (strcmp(GameInfo.RatingValue.c_str(), "18") == 0)
				ratingImgData = Resources::GetImageData("pegi_18.png");
			else
			{
				ratingImgData = Resources::GetImageData("norating.png");
			}
		}
		else if (GameInfo.RatingType == 0)
		{
			if (strcmp(GameInfo.RatingValue.c_str(), "A") == 0)
				ratingImgData = Resources::GetImageData("cero_a.png");
			else if (strcmp(GameInfo.RatingValue.c_str(), "B") == 0)
				ratingImgData = Resources::GetImageData("cero_b.png");
			else if (strcmp(GameInfo.RatingValue.c_str(), "C") == 0)
				ratingImgData = Resources::GetImageData("cero_c.png");
			else if (strcmp(GameInfo.RatingValue.c_str(), "D") == 0)
				ratingImgData = Resources::GetImageData("cero_d.png");
			else if (strcmp(GameInfo.RatingValue.c_str(), "Z") == 0)
				ratingImgData = Resources::GetImageData("cero_z.png");
			else
			{
				ratingImgData = Resources::GetImageData("norating.png");
			}
		}

		else
		{
			ratingImgData = Resources::GetImageData("norating.png");
		}
		ratingImg = new GuiImage(ratingImgData);
		ratingImg->SetWidescreen(Settings.widescreen);
		ratingImg->SetPosition(-25, inputY);
		ratingImg->SetAlignment(1, 4);
		InfoWindow.Append(ratingImg);
		intputX += (Settings.widescreen ? ratingImg->GetWidth() * Settings.WSFactor : ratingImg->GetWidth()) + 5;
	}

	// title
	int titlefontsize = 25;
	if (GameInfo.Title.size() > 0)
	{
		titleTxt = new GuiText(GameInfo.Title.c_str(), titlefontsize, ( GXColor ) {0, 0, 0, 255});
		titleTxt->SetMaxWidth(350, SCROLL_HORIZONTAL);
		titleTxt->SetAlignment(ALIGN_CENTER, ALIGN_TOP);
		titleTxt->SetPosition(txtXOffset, 12 + titley);
		InfoWindow.Append(titleTxt);
	}

	//date
	snprintf(linebuf2, sizeof(linebuf2), " ");
	if (GameInfo.PublishDate != 0)
	{
		int year = GameInfo.PublishDate >> 16;
		int day = GameInfo.PublishDate & 0xFF;
		int month = (GameInfo.PublishDate >> 8) & 0xFF;
		snprintf(linebuf2, sizeof(linebuf2), "%02i ", day);

		switch (month)
		{
			case 1:
				snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr( "Jan" ));
				break;
			case 2:
				snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr( "Feb" ));
				break;
			case 3:
				snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr( "Mar" ));
				break;
			case 4:
				snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr( "Apr" ));
				break;
			case 5:
				snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr( "May" ));
				break;
			case 6:
				snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr( "June" ));
				break;
			case 7:
				snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr( "July" ));
				break;
			case 8:
				snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr( "Aug" ));
				break;
			case 9:
				snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr( "Sept" ));
				break;
			case 10:
				snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr( "Oct" ));
				break;
			case 11:
				snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr( "Nov" ));
				break;
			case 12:
				snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, tr( "Dec" ));
				break;
		}

		char linebuf[300];
		snprintf(linebuf, sizeof(linebuf), "%s : %s%i", tr( "Released" ), linebuf2, year);
		releasedTxt = new GuiText(linebuf, 16, ( GXColor ) {0, 0, 0, 255});
		if (releasedTxt->GetTextWidth() > 300) newline = 2;
		releasedTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
		releasedTxt->SetPosition(-17, 12 + indexy);
		indexy += (20 * newline);
		newline = 1;
		InfoWindow.Append(releasedTxt);
	}
Example #10
0
/****************************************************************************
 * MainMenu
 ***************************************************************************/
void MainMenu(int menu) {
    
    TR;
    int currentMenu = menu;

#ifdef HW_RVL
    pointer[0] = new GuiImageData(player1_point_png);
    pointer[1] = new GuiImageData(player2_point_png);
    pointer[2] = new GuiImageData(player3_point_png);
    pointer[3] = new GuiImageData(player4_point_png);
#endif

    GuiImageData * background = new GuiImageData(xenon_bg_png);

    mainWindow = new GuiWindow(screenwidth, screenheight);

    bgImg = new GuiImage(background);

    //    bgImg = new GuiImage(screenwidth, screenheight, (GXColor) {
    //        50, 50, 50, 255
    //    });
    //    bgImg->ColorStripe(30);
    mainWindow->Append(bgImg);

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

    ResumeGui();

    bgMusic = new GuiSound(bg_music_ogg, bg_music_ogg_size, SOUND_OGG);
    bgMusic->SetVolume(50);
    bgMusic->Play(); // startup music

    while (currentMenu != MENU_EXIT) {
        switch (currentMenu) {
            case MENU_SETTINGS:
                currentMenu = MenuSettings();
                break;
            case MENU_SETTINGS_FILE:
                currentMenu = MenuSettingsFile();
                break;
            case MENU_BROWSE_DEVICE:
                currentMenu = MenuBrowseDevice();
                break;
            default: // unrecognized menu
                currentMenu = MenuSettings();
                break;
        }
        //        currentMenu=MenuTest();
        //        currentMenu = MenuBrowseDevice();
    }
    ResumeGui();
    ExitRequested = 1;

    while (1) {
        UGUI();
        usleep(THREAD_SLEEP);
    }

    HaltGui();

    bgMusic->Stop();
    delete bgMusic;
    delete bgImg;
    delete mainWindow;

    delete pointer[0];
    delete pointer[1];
    delete pointer[2];
    delete pointer[3];

    mainWindow = NULL;
}
Example #11
0
/****************************************************************************
 * WindowPrompt
 *
 * Displays a prompt window to user, with information, an error message, or
 * presenting a user with a choice
 ***************************************************************************/
int
WindowPrompt(const char *title, const char *msg, const char *btn1Label, const char *btn2Label) {
    int choice = -1;

    //    GuiWindow promptWindow(448, 288);
    GuiWindow promptWindow(640, 360);
    promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
    promptWindow.SetPosition(0, -10);
    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);

    //    GuiImageData dialogBox(dialogue_box_png);
    GuiImageData dialogBox(xenon_popup_png);
    GuiImage dialogBoxImg(&dialogBox);

    GuiText titleTxt(title, 26, ColorGrey);
    titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    titleTxt.SetPosition(0, 40);

    GuiText msgTxt(msg, 22, ColorGrey);
    msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
    msgTxt.SetPosition(0, -20);
    msgTxt.SetWrap(true, 600);

    GuiText btn1Txt(btn1Label, 22, ColorGrey);
    GuiImage btn1Img(&btnOutline);
    GuiImage btn1ImgOver(&btnOutlineOver);
    GuiButton btn1(btnOutline.GetWidth(), btnOutline.GetHeight());

    if (btn2Label) {
        btn1.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
        btn1.SetPosition(20, -25);
    } else {
        btn1.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
        btn1.SetPosition(0, -25);
    }

    btn1.SetLabel(&btn1Txt);
    btn1.SetImage(&btn1Img);
    btn1.SetImageOver(&btn1ImgOver);
    btn1.SetSoundOver(&btnSoundOver);
    btn1.SetTrigger(&trigA);
    btn1.SetState(STATE_SELECTED);
    btn1.SetEffectGrow();

    GuiText btn2Txt(btn2Label, 22, ColorGrey);
    GuiImage btn2Img(&btnOutline);
    GuiImage btn2ImgOver(&btnOutlineOver);
    GuiButton btn2(btnOutline.GetWidth(), btnOutline.GetHeight());
    btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
    btn2.SetPosition(-20, -25);
    btn2.SetLabel(&btn2Txt);
    btn2.SetImage(&btn2Img);
    btn2.SetImageOver(&btn2ImgOver);
    btn2.SetSoundOver(&btnSoundOver);
    btn2.SetTrigger(&trigA);
    btn2.SetEffectGrow();

    promptWindow.Append(&dialogBoxImg);
    promptWindow.Append(&titleTxt);
    promptWindow.Append(&msgTxt);
    promptWindow.Append(&btn1);

    if (btn2Label)
        promptWindow.Append(&btn2);

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

    while (choice == -1) {
        UGUI();
        usleep(THREAD_SLEEP);

        if (btn1.GetState() == STATE_CLICKED)
            choice = 1;
        else if (btn2.GetState() == STATE_CLICKED)
            choice = 0;
    }

    promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
    while (promptWindow.GetEffect() > 0) {
        UGUI();
        usleep(THREAD_SLEEP);
    }
    HaltGui();
    mainWindow->Remove(&promptWindow);
    mainWindow->SetState(STATE_DEFAULT);
    ResumeGui();
    return choice;
}
Example #12
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;
}
Example #13
0
/****************************************************************************
 * MenuSettings
 ***************************************************************************/
static int MenuSettings() {
    int menu = MENU_NONE;

    GuiText titleTxt("Settings", 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);
    GuiImageData btnLargeOutline(xenon_button_large_png);
    GuiImageData btnLargeOutlineOver(xenon_button_large_over_png);

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

    GuiText fileBtnTxt("File Browser", 22, ColorGrey2);
    fileBtnTxt.SetWrap(true, btnLargeOutline.GetWidth() - 30);
    GuiImage fileBtnImg(&btnLargeOutline);
    GuiImage fileBtnImgOver(&btnLargeOutlineOver);
    GuiButton fileBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight());
    fileBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    fileBtn.SetPosition(50, 120);
    fileBtn.SetLabel(&fileBtnTxt);
    fileBtn.SetImage(&fileBtnImg);
    fileBtn.SetImageOver(&fileBtnImgOver);
    fileBtn.SetSoundOver(&btnSoundOver);
    fileBtn.SetTrigger(&trigA);
    fileBtn.SetEffectGrow();

    GuiText videoBtnTxt("Video", 22, ColorGrey2);
    videoBtnTxt.SetWrap(true, btnLargeOutline.GetWidth() - 30);
    GuiImage videoBtnImg(&btnLargeOutline);
    GuiImage videoBtnImgOver(&btnLargeOutlineOver);
    GuiButton videoBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight());
    videoBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    videoBtn.SetPosition(0, 120);
    videoBtn.SetLabel(&videoBtnTxt);
    videoBtn.SetImage(&videoBtnImg);
    videoBtn.SetImageOver(&videoBtnImgOver);
    videoBtn.SetSoundOver(&btnSoundOver);
    videoBtn.SetTrigger(&trigA);
    videoBtn.SetEffectGrow();

    GuiText savingBtnTxt1("Saving", 22, ColorGrey2);

    GuiText savingBtnTxt2("&", 18, ColorGrey2);

    GuiText savingBtnTxt3("Loading", 22, ColorGrey2);
    savingBtnTxt1.SetPosition(0, -20);
    savingBtnTxt3.SetPosition(0, +20);
    GuiImage savingBtnImg(&btnLargeOutline);
    GuiImage savingBtnImgOver(&btnLargeOutlineOver);
    GuiButton savingBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight());
    savingBtn.SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
    savingBtn.SetPosition(-50, 120);
    savingBtn.SetLabel(&savingBtnTxt1, 0);
    savingBtn.SetLabel(&savingBtnTxt2, 1);
    savingBtn.SetLabel(&savingBtnTxt3, 2);
    savingBtn.SetImage(&savingBtnImg);
    savingBtn.SetImageOver(&savingBtnImgOver);
    savingBtn.SetSoundOver(&btnSoundOver);
    savingBtn.SetTrigger(&trigA);
    savingBtn.SetEffectGrow();

    GuiText menuBtnTxt("Menu", 22, ColorGrey2);
    menuBtnTxt.SetWrap(true, btnLargeOutline.GetWidth() - 30);
    GuiImage menuBtnImg(&btnLargeOutline);
    GuiImage menuBtnImgOver(&btnLargeOutlineOver);
    GuiButton menuBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight());
    menuBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    menuBtn.SetPosition(-125, 250);
    menuBtn.SetLabel(&menuBtnTxt);
    menuBtn.SetImage(&menuBtnImg);
    menuBtn.SetImageOver(&menuBtnImgOver);
    menuBtn.SetSoundOver(&btnSoundOver);
    menuBtn.SetTrigger(&trigA);
    menuBtn.SetEffectGrow();

    GuiText networkBtnTxt("Network", 22, ColorGrey2);
    networkBtnTxt.SetWrap(true, btnLargeOutline.GetWidth() - 30);
    GuiImage networkBtnImg(&btnLargeOutline);
    GuiImage networkBtnImgOver(&btnLargeOutlineOver);
    GuiButton networkBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight());
    networkBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    networkBtn.SetPosition(125, 250);
    networkBtn.SetLabel(&networkBtnTxt);
    networkBtn.SetImage(&networkBtnImg);
    networkBtn.SetImageOver(&networkBtnImgOver);
    networkBtn.SetSoundOver(&btnSoundOver);
    networkBtn.SetTrigger(&trigA);
    networkBtn.SetEffectGrow();

    GuiText exitBtnTxt("Exit", 22, ColorGrey2);
    GuiImage exitBtnImg(&btnOutline);
    GuiImage exitBtnImgOver(&btnOutlineOver);
    GuiButton exitBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
    exitBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
    exitBtn.SetPosition(100, -35);
    exitBtn.SetLabel(&exitBtnTxt);
    exitBtn.SetImage(&exitBtnImg);
    exitBtn.SetImageOver(&exitBtnImgOver);
    exitBtn.SetSoundOver(&btnSoundOver);
    exitBtn.SetTrigger(&trigA);
    exitBtn.SetTrigger(&trigHome);
    exitBtn.SetEffectGrow();

    GuiText resetBtnTxt("Reset Settings", 22, ColorGrey2);
    GuiImage resetBtnImg(&btnOutline);
    GuiImage resetBtnImgOver(&btnOutlineOver);
    GuiButton resetBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
    resetBtn.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
    resetBtn.SetPosition(-100, -35);
    resetBtn.SetLabel(&resetBtnTxt);
    resetBtn.SetImage(&resetBtnImg);
    resetBtn.SetImageOver(&resetBtnImgOver);
    resetBtn.SetSoundOver(&btnSoundOver);
    resetBtn.SetTrigger(&trigA);
    resetBtn.SetEffectGrow();

    HaltGui();
    GuiWindow w(screenwidth, screenheight);
    w.Append(&titleTxt);
    w.Append(&fileBtn);
    w.Append(&videoBtn);
    w.Append(&savingBtn);
    w.Append(&menuBtn);

#ifdef HW_RVL
    w.Append(&networkBtn);
#endif

    w.Append(&exitBtn);
    w.Append(&resetBtn);

    mainWindow->Append(&w);

    ResumeGui();

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

        if (fileBtn.GetState() == STATE_CLICKED) {
            menu = MENU_BROWSE_DEVICE;
        } else if (videoBtn.GetState() == STATE_CLICKED) {
            menu = MENU_SETTINGS_FILE;
        } else if (savingBtn.GetState() == STATE_CLICKED) {
            menu = MENU_SETTINGS_FILE;
        } else if (menuBtn.GetState() == STATE_CLICKED) {
            menu = MENU_SETTINGS_FILE;
        } else if (networkBtn.GetState() == STATE_CLICKED) {
            menu = MENU_SETTINGS_FILE;
        } else if (exitBtn.GetState() == STATE_CLICKED) {
            menu = MENU_EXIT;
        } else if (resetBtn.GetState() == STATE_CLICKED) {
            resetBtn.ResetState();

            int choice = WindowPrompt(
                    "Reset Settings",
                    "Are you sure that you want to reset your settings?",
                    "Yes",
                    "No");
            if (choice == 1) {
                // reset settings
            }
        }
    }

    HaltGui();
    mainWindow->Remove(&w);
    return menu;
}
Example #14
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;
}
int TitleBrowser()
{
	u32 num_titles;
	u32 num_sys_titles;
	s32 ret = -1;
	u64 *titleList = NULL;

	// Get count of titles of the good titles
	num_titles = NandTitles.SetType(0x10001);
	u32 n = num_titles;
	for (u32 i = 0; i < n; i++)
	{
		u64 tid = NandTitles.Next();
		if (!tid)
		{
			break;
		}

		//remove ones not actually installed on the nand
		if (!NandTitles.Exists(tid))
		{
			num_titles--;
		}
	}

	// Get count of system titles
	num_sys_titles = NandTitles.SetType(0x10002);
	n = num_sys_titles;
	for (u32 i = 0; i < n; i++)
	{
		u64 tid = NandTitles.Next();
		if (!tid)
		{
			break;
		}
		//these can't be booted anyways
		if (TITLE_LOWER( tid ) == 0x48414741 || TITLE_LOWER( tid ) == 0x48414141 || TITLE_LOWER( tid ) == 0x48414641)
		{
			num_sys_titles--;
			continue;
		}

		//these aren't installed on the nand
		if (!NandTitles.Exists(tid))
		{
			num_sys_titles--;
		}
	}

	//make a list of just the tids we are adding to the titlebrowser
	titleList = (u64*) memalign(32, (num_titles + num_sys_titles) * sizeof(u64));
	if (!titleList)
	{
		gprintf("TitleBrowser(): out of memory!\n");
		return -1;
	}
	OptionList options3;
	//write the titles on the option browser

	std::string Filepath = Settings.titlestxt_path;
	Filepath += "wiitdb.xml";

	GameTDB *XML_DB = new GameTDB(Filepath.c_str());
	XML_DB->SetLanguageCode(Settings.db_language);

	u32 i = 0;
	NandTitles.SetType(0x10001);
	//first add the good stuff
	while (i < num_titles)
	{
		u64 tid = NandTitles.Next();
		if (!tid)
		{
			gprintf("shit happened3\n");
			break;
		}
		gprintf("[ %u ] tid: %016llx\t%s\n", i, tid, NandTitles.NameOf(tid));

		if (!NandTitles.Exists(tid))
		{
			continue;
		}

		char id[5];
		NandTitles.AsciiTID(tid, (char*) &id);

		const char* name = NULL;
		std::string TitleName;

		if(XML_DB->GetTitle(id, TitleName))
			name = TitleName.c_str();
		else
			name = NandTitles.NameOf(tid);

		options3.SetName(i, "%s", id);
		options3.SetValue(i, "%s", name ? name : tr( "Unknown" ));
		titleList[i] = tid;
		i++;
	}

	NandTitles.SetType(0x10002);
	while (i < num_sys_titles + num_titles)
	{
		u64 tid = NandTitles.Next();
		if (!tid)
		{
			break;
		}
		if (TITLE_LOWER( tid ) == 0x48414741 || TITLE_LOWER( tid ) == 0x48414141 || TITLE_LOWER( tid ) == 0x48414641) continue;

		if (!NandTitles.Exists(tid))
		{
			continue;
		}

		char id[5];
		NandTitles.AsciiTID(tid, (char*) &id);

		const char* name = NULL;
		std::string TitleName;

		if(XML_DB->GetTitle(id, TitleName))
			name = TitleName.c_str();
		else
			name = NandTitles.NameOf(tid);

		options3.SetName(i, "%s", id);
		options3.SetValue(i, "%s", name ? name : tr( "Unknown" ));
		titleList[i] = tid;
		i++;
	}

	delete XML_DB;
	XML_DB = NULL;

	if (i == num_titles + num_sys_titles)
	{
		options3.SetName(i, " ");
		options3.SetValue(i, "%s", tr( "Wii Settings" ));
	}

	bool exit = false;
	int total = num_titles + num_sys_titles;

	if (IsNetworkInit()) ResumeNetworkWait();

	GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
	GuiImageData settingsbg(Resources::GetFile("settings_background.png"), Resources::GetFileSize("settings_background.png"));

	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);

	GuiText titleTxt(tr( "Title Launcher" ), 28, ( GXColor )
	{   0, 0, 0, 255});
	titleTxt.SetAlignment(ALIGN_CENTER, ALIGN_TOP);
	titleTxt.SetPosition(12, 40);
	titleTxt.SetMaxWidth(356, SCROLL_HORIZONTAL);

	GuiImage settingsbackground(&settingsbg);
	GuiButton settingsbackgroundbtn(settingsbackground.GetWidth(), settingsbackground.GetHeight());
	settingsbackgroundbtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	settingsbackgroundbtn.SetPosition(0, 0);
	settingsbackgroundbtn.SetImage(&settingsbackground);

	GuiText cancelBtnTxt(tr( "Back" ), 22, thColor("r=0 g=0 b=0 a=255 - prompt windows button text color"));
	cancelBtnTxt.SetMaxWidth(btnOutline.GetWidth() - 30);
	GuiImage cancelBtnImg(&btnOutline);
	if (Settings.wsprompt)
	{
		cancelBtnTxt.SetWidescreen(Settings.widescreen);
		cancelBtnImg.SetWidescreen(Settings.widescreen);
	}
	GuiButton cancelBtn(&cancelBtnImg, &cancelBtnImg, 2, 3, 180, 400, &trigA, btnSoundOver, btnSoundClick2, 1);
	cancelBtn.SetScale(0.9);
	cancelBtn.SetLabel(&cancelBtnTxt);
	cancelBtn.SetTrigger(&trigB);

	GuiOptionBrowser optionBrowser3(396, 280, &options3, "bg_options_settings.png");
	optionBrowser3.SetPosition(0, 90);
	optionBrowser3.SetAlignment(ALIGN_CENTER, ALIGN_TOP);

	GuiImageData wifiImgData(Resources::GetFile("wifi_btn.png"), Resources::GetFileSize("wifi_btn.png"));
	GuiImage wifiImg(&wifiImgData);
	if (Settings.wsprompt)
	{
		wifiImg.SetWidescreen(Settings.widescreen);
	}
	GuiButton wifiBtn(wifiImg.GetWidth(), wifiImg.GetHeight());
	wifiBtn.SetImage(&wifiImg);
	wifiBtn.SetPosition(100, 400);
	wifiBtn.SetEffectGrow();
	wifiBtn.SetAlpha(80);
	wifiBtn.SetTrigger(&trigA);

	HaltGui();
	GuiWindow w(screenwidth, screenheight);
	w.Append(&settingsbackgroundbtn);
	w.Append(&titleTxt);
	w.Append(&cancelBtn);
	w.Append(&wifiBtn);
	w.Append(&optionBrowser3);
	mainWindow->Append(&w);

	ResumeGui();

	while (!exit)
	{
		VIDEO_WaitVSync();

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

		else if (wifiBtn.GetState() == STATE_CLICKED)
		{
			ResumeNetworkWait();
			wifiBtn.ResetState();
		}

		if (IsNetworkInit())
		{
			wifiBtn.SetAlpha(255);
		}

		ret = optionBrowser3.GetClickedOption();

		if (ret > -1)
		{ //if a click happened

			if (ret < total)
			{
				//set the title's name, number, ID to text
				char text[0x100];
				char id[5];
				NandTitles.AsciiTID(titleList[ret], (char*) &id);

				snprintf(text, sizeof(text), "%s : %s", id, NandTitles.NameOf(titleList[ret]));

				//prompt to boot selected title
				if (WindowPrompt(tr( "Boot?" ), text, tr( "OK" ), tr( "Cancel" )))
				{ //if they say yes
					ExitApp();
					WII_Initialize();
					WII_LaunchTitle(titleList[ret]);
					//this really shouldn't be needed because the title will be booted
					exit = true;
					break;
				}
				else
				{
					//if they said no to booting the title
					ret = -1;
					optionBrowser3.ResetState();
				}

			}
			else if (ret == total)
			{ //if they clicked to go to the wii settings
				ExitApp();
				WII_Initialize();
				WII_ReturnToSettings();
			}
		}
		if (cancelBtn.GetState() == STATE_CLICKED)
		{
			//break the loop and end the function
			exit = true;
			ret = -10;
		}
	}

	CloseConnection();
	if (IsNetworkInit()) HaltNetworkThread();

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

	return ret;
}
Example #16
0
bool GuiBrowser(GuiWindow *mainWindow, GuiWindow *parentWindow, char *path, const char *label)
{
    char temp[256];
    char title[100];
	int i;

	ShutoffRumble();

	// populate initial directory listing
	if(BrowseDevice() <= 0)
	{
		WindowPrompt(
		"Error",
		"Unable to display files on selected load device",
		"Ok",
		NULL);

        return false;
	}

	int menu = MENU_NONE;
	int dev = 0;
	char mount[2][5] = {"SD", "USB"};

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

    if(OpenDefaultFolder() <= 0)
    {
        BrowseDevice();
        bzero(temp, sizeof(temp));
    }
    else sprintf(temp, "%s/", Settings.UserFolder);

	sprintf(title, "Browse files");
	bzero(path, sizeof(path));

    GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM);
    GuiImageData Textbox(textbox_end_png);
    GuiImage TextboxImg(&Textbox);
    GuiButton InsertURL(TextboxImg.GetWidth(), TextboxImg.GetHeight());

    GuiImageData Device(textbox_begin_png);
    GuiImage DeviceImg(&Device);
    GuiButton InsertDEV(DeviceImg.GetWidth(), DeviceImg.GetHeight());

    GuiText URL(strchr(temp, '/'), 20, (GXColor){0, 0, 0, 255});
    GuiText DEV("SD", 20, (GXColor){0, 0, 0, 255});

    URL.SetMaxWidth(TextboxImg.GetWidth()-20);
    URL.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    URL.SetPosition(5,0);
    URL.SetScroll(SCROLL_HORIZONTAL);

    InsertURL.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    InsertURL.SetPosition(InsertDEV.GetWidth()/2,30);
    InsertURL.SetLabel(&URL);
    InsertURL.SetImage(&TextboxImg);
    InsertURL.SetSoundOver(&btnSoundOver);
    InsertURL.SetTrigger(&trigA);

    InsertDEV.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    InsertDEV.SetPosition(InsertURL.GetLeft()-InsertDEV.GetWidth()/2,30);
    InsertDEV.SetLabel(&DEV);
    InsertDEV.SetImage(&DeviceImg);
    InsertDEV.SetSoundOver(&btnSoundOver);
    InsertDEV.SetTrigger(&trigA);
    InsertDEV.SetEffectGrow();

    GuiText titleTxt(title, 28, (GXColor){0, 0, 0, 255});
    titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	titleTxt.SetPosition(50,50);

	GuiFileBrowser fileBrowser(552, 248);
	fileBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	fileBrowser.SetPosition(0, 108);
	fileBrowser.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_IN, 30);

	GuiImageData btnOutline(button_png);
	GuiImageData btnOutlineOver(button_over_png);

	GuiText okBtnTxt(label, 24, (GXColor){0, 0, 0, 255});
	GuiImage okBtnImg(&btnOutline);
	GuiImage okBtnImgOver(&btnOutlineOver);
	GuiButton okBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
	okBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
	okBtn.SetPosition(50, -35);
	okBtn.SetLabel(&okBtnTxt);
	okBtn.SetImage(&okBtnImg);
	okBtn.SetImageOver(&okBtnImgOver);
	okBtn.SetTrigger(&trigA);
	okBtn.SetEffectGrow();

    GuiText cancelBtnTxt("Cancel", 24, (GXColor){0, 0, 0, 255});
	GuiImage cancelBtnImg(&btnOutline);
	GuiImage cancelBtnImgOver(&btnOutlineOver);
	GuiButton cancelBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
	cancelBtn.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
	cancelBtn.SetPosition(-50, -35);
	cancelBtn.SetLabel(&cancelBtnTxt);
	cancelBtn.SetImage(&cancelBtnImg);
	cancelBtn.SetImageOver(&cancelBtnImgOver);
	cancelBtn.SetTrigger(&trigA);
	cancelBtn.SetEffectGrow();

	GuiWindow buttonWindow(screenwidth, screenheight);
	buttonWindow.Append(&okBtn);
	buttonWindow.Append(&cancelBtn);
	buttonWindow.Append(&InsertURL);
	buttonWindow.Append(&InsertDEV);
    buttonWindow.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_IN, 30);

    if (mainWindow)
    {
        mainWindow->SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
        while(mainWindow->GetEffect() > 0)
            usleep(100);
    }

    HaltGui();
    if (mainWindow)
        parentWindow->Remove(mainWindow);
    parentWindow->Append(&buttonWindow);
    parentWindow->Append(&fileBrowser);
    ResumeGui();

	while(menu == MENU_NONE)
	{
		usleep(100);
		if(!strlen(URL.GetText()) || URL.GetText()[0] != '/')
        {
            sprintf(temp, "%s", rootdir);
            URL.SetText(strchr(temp, '/'));
        }

        if(InsertURL.GetState() == STATE_CLICKED)
        {
            URL.SetScroll(SCROLL_NONE);
            OnScreenKeyboard(parentWindow, strchr(temp, '/'), 256);
            URL.SetText(strchr(temp, '/'));
            URL.SetScroll(SCROLL_HORIZONTAL);

            InsertURL.ResetState();
        }

        if(InsertDEV.GetState() == STATE_CLICKED)
        {
            InsertDEV.ResetState();
            dev ^= 1;

            if(BrowseDevice(dev) <= 0)
            {
                BrowseDevice();
                dev = 0;
            }

            DEV.SetText(mount[dev]);
            URL.SetText("");
        }

		// update file browser based on arrow buttons
		// set MENU_EXIT if A 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();

                        if(strlen(browser.dir) > 1)
                            sprintf(fullpath, "%s%s/", rootdir, browser.dir+1); // print current path
                        else sprintf(fullpath, "%s", rootdir); // print current path

                        sprintf(temp, fullpath);
                        URL.SetText(strchr(temp, '/'));
					}
					else
					{
						menu = MENU_HOME;
						break;
					}
				}
				else
				{
					ShutoffRumble();
					// load file
					if(strlen(browser.dir) > 1)
                        sprintf(fullpath, "%s%s/%s", rootdir, browser.dir+1, browserList[browser.selIndex].filename); // print current path
                    else sprintf(fullpath, "%s%s", rootdir, browserList[browser.selIndex].filename); // print current path

                    sprintf(temp, fullpath);
                    URL.SetText(strchr(temp, '/'));
				}
			}
		}

		if(okBtn.GetState() == STATE_CLICKED)
		{
		    sprintf(path, temp);
		    menu = MENU_HOME;
		}
        if(cancelBtn.GetState() == STATE_CLICKED)
		    menu = MENU_HOME;
	}

    fileBrowser.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50);
    buttonWindow.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50);
    while(buttonWindow.GetEffect() > 0)
        usleep(100);

    fileBrowser.SetVisible(false);
    buttonWindow.SetVisible(false);

    if(mainWindow)
    {
        mainWindow->SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 30);
        parentWindow->Append(mainWindow);
        while(mainWindow->GetEffect() > 0)
            usleep(100);
    }

    HaltGui();
    parentWindow->Remove(&buttonWindow);
    parentWindow->Remove(&fileBrowser);
    ResumeGui();

    if (isValidPath(path))
        return true;
    return false;
}
/********************************************************************************
 * TitleBrowser- opens a browser with a list of installed Titles
 *********************************************************************************/
bool TitleSelector(char output[])
{
	gprintf("TitleSelector()\n");

	s32 num_titles;
	s32 r = -1;
	bool ret = false;
	u64 *titleList = NULL;

	// Get count of titles of the good titles
	num_titles = NandTitles.SetType(0x10001);
	u32 n = num_titles;

	for (u32 i = 0; i < n; i++)
	{
		u64 tid = NandTitles.Next();
		if (!tid)
		{
			break;
		}

		//remove ones not actually installed on the nand
		if (!NandTitles.Exists(tid))
		{
			num_titles--;
		}
	}

	//make a list of just the tids we are adding to the titlebrowser
	titleList = (u64*) memalign(32, num_titles * sizeof(u64));
	if (!titleList)
	{
		gprintf("TitleLister(): out of memory!\n");
		return false;
	}
	OptionList options4;
	//write the titles on the option browser

	std::string Filepath = Settings.titlestxt_path;
	Filepath += "wiitdb.xml";

	GameTDB *XML_DB = new GameTDB(Filepath.c_str());
	XML_DB->SetLanguageCode(Settings.db_language);

	s32 i = 0;
	NandTitles.SetType(0x10001);
	while (i < num_titles)
	{
		u64 tid = NandTitles.Next();
		if (!tid)
		{
			gprintf("shit happened\n");
			break;
		}

		if (!NandTitles.Exists(tid))
			continue;

		char id[5];
		NandTitles.AsciiTID(tid, (char*) &id);

		const char* name = NULL;
		std::string TitleName;

		if(XML_DB->GetTitle(id, TitleName))
			name = TitleName.c_str();
		else
			name = NandTitles.NameOf(tid);
		//gprintf("%016llx: %s: %s\n%p\t%p\n", tid, id, name, &id, name );

		options4.SetName(i, "%s", id);
		options4.SetValue(i, "%s", name ? name : tr( "Unknown" ));
		titleList[i] = tid;
		i++;
	}

	delete XML_DB;
	XML_DB = NULL;

	options4.SetName(i, " ");
	options4.SetValue(i, "%s", tr( "Clear" ));

	bool exit = false;

	GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
	GuiImageData settingsbg(Resources::GetFile("settings_background.png"), Resources::GetFileSize("settings_background.png"));

	GuiImage settingsbackground(&settingsbg);
	GuiButton settingsbackgroundbtn(settingsbackground.GetWidth(), settingsbackground.GetHeight());
	settingsbackgroundbtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	settingsbackgroundbtn.SetPosition(0, 0);
	settingsbackgroundbtn.SetImage(&settingsbackground);

	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 cancelBtnTxt(tr( "Back" ), 22, thColor("r=0 g=0 b=0 a=255 - prompt windows button text color"));
	cancelBtnTxt.SetMaxWidth(btnOutline.GetWidth() - 30);
	GuiImage cancelBtnImg(&btnOutline);
	if (Settings.wsprompt)
	{
		cancelBtnTxt.SetWidescreen(Settings.widescreen);
		cancelBtnImg.SetWidescreen(Settings.widescreen);
	}
	GuiButton cancelBtn(&cancelBtnImg, &cancelBtnImg, 2, 3, 180, 400, &trigA, btnSoundOver, btnSoundClick2, 1);
	cancelBtn.SetLabel(&cancelBtnTxt);
	cancelBtn.SetTrigger(&trigB);

	GuiOptionBrowser optionBrowser4(396, 280, &options4, "bg_options_settings.png");
	optionBrowser4.SetPosition(0, 90);
	optionBrowser4.SetAlignment(ALIGN_CENTER, ALIGN_TOP);

	HaltGui();
	GuiWindow w(screenwidth, screenheight);
	w.Append(&settingsbackgroundbtn);
	w.Append(&cancelBtn);
	w.Append(&optionBrowser4);
	mainWindow->SetState(STATE_DISABLED);
	mainWindow->Append(&w);

	ResumeGui();

	while (!exit)
	{
		VIDEO_WaitVSync();

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

		r = optionBrowser4.GetClickedOption();

		if (r > -1)
		{ //if a click happened
			if (r < num_titles)
			{
				u64 tid = titleList[r];
				sprintf(output, "%08x", TITLE_LOWER( tid ));
			}
			else output[0] = 0;
			ret = true;
			exit = true;
		}

		else if (cancelBtn.GetState() == STATE_CLICKED)
		{
			//break the loop and end the function
			exit = true;
		}
	}

	HaltGui();
	mainWindow->SetState(STATE_DEFAULT);
	mainWindow->Remove(&w);
	free(titleList);
	ResumeGui();

	return ret;
}
/********************************************************************************
 *Disk Browser
 *********************************************************************************/
int DiscBrowse(const char * GameID, char * alternatedname, int alternatedname_size)
{
	gprintf("\nDiscBrowser() started");
	bool exit = false;
	int ret = -1, choice;

	HaltGui();

	gprintf("WBFS_OpenDisc\n");
	wbfs_disc_t *disc = WBFS_OpenDisc((u8 *) GameID);
	if (!disc)
	{
		ResumeGui();
		WindowPrompt(tr( "ERROR:" ), tr( "Could not open Disc" ), tr( "OK" ));
		return ret;
	}
	gprintf("wd_open_disc\n");
	wiidisc_t *wdisc = wd_open_disc((int(*)(void *, u32, u32, void *)) wbfs_disc_read, disc);
	if (!wdisc)
	{
		ResumeGui();
		WindowPrompt(tr( "ERROR:" ), tr( "Could not open Disc" ), tr( "OK" ));
		return ret;
	}

	gprintf("wd_get_fst\n");
	FST_ENTRY * fstbuffer = (FST_ENTRY *) wd_extract_file(wdisc, ONLY_GAME_PARTITION, (char *) "FST");
	if (!fstbuffer)
	{
		ResumeGui();
		WindowPrompt(tr( "ERROR:" ), tr( "Not enough free memory." ), tr( "OK" ));
		return -1;
	}

	gprintf("wd_close_disc\n");
	wd_close_disc(wdisc);
	gprintf("WBFS_CloseDisc\n");
	WBFS_CloseDisc(disc);

	gprintf("options\n");
	OptionList options;

	for (u32 i = 0, position = 0; i < fstbuffer[0].filelen; i++)
	{
		//don't add files that aren't .dol to the list
		const char * filename = fstfiles(fstbuffer, i);
		const char * fileext = NULL;

		if(filename)
			fileext = strrchr(filename, '.');

		if (fileext && strcasecmp(fileext, ".dol") == 0)
		{
			options.SetName(position, "%s %03i", tr("Offset"), i);
			options.SetValue(position, filename);
			position++;
		}
	}

	free(fstbuffer);

	gprintf("\n%i alt dols found", options.GetLength()+1);
	if (options.GetLength() <= 0)
	{
		WindowPrompt(tr( "ERROR" ), tr( "No DOL file found on disc." ), tr( "OK" ));
		return ret;
	}

	GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
	GuiImageData settingsbg(Resources::GetFile("settings_background.png"), Resources::GetFileSize("settings_background.png"));

	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);

	GuiText titleTxt(GameTitles.GetTitle(GameID), 28, ( GXColor ) {0, 0, 0, 255});
	titleTxt.SetAlignment(ALIGN_CENTER, ALIGN_TOP);
	titleTxt.SetPosition(12, 40);
	titleTxt.SetMaxWidth(356, SCROLL_HORIZONTAL);

	GuiImage settingsbackground(&settingsbg);
	GuiButton settingsbackgroundbtn(settingsbackground.GetWidth(), settingsbackground.GetHeight());
	settingsbackgroundbtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	settingsbackgroundbtn.SetPosition(0, 0);
	settingsbackgroundbtn.SetImage(&settingsbackground);

	GuiText cancelBtnTxt(tr( "Back" ), 22, thColor("r=0 g=0 b=0 a=255 - prompt windows button text color"));
	cancelBtnTxt.SetMaxWidth(btnOutline.GetWidth() - 30);
	GuiImage cancelBtnImg(&btnOutline);
	if (Settings.wsprompt == ON)
	{
		cancelBtnTxt.SetWidescreen(Settings.widescreen);
		cancelBtnImg.SetWidescreen(Settings.widescreen);
	}
	GuiButton cancelBtn(&cancelBtnImg, &cancelBtnImg, 2, 3, 180, 400, &trigA, btnSoundOver, btnSoundClick2, 1);
	cancelBtn.SetScale(0.9);
	cancelBtn.SetLabel(&cancelBtnTxt);
	cancelBtn.SetTrigger(&trigB);

	GuiOptionBrowser optionBrowser3(396, 280, &options, "bg_options_settings.png");
	optionBrowser3.SetPosition(0, 90);
	optionBrowser3.SetAlignment(ALIGN_CENTER, ALIGN_TOP);

	HaltGui();
	GuiWindow w(screenwidth, screenheight);
	w.Append(&settingsbackgroundbtn);
	w.Append(&titleTxt);
	w.Append(&cancelBtn);
	w.Append(&optionBrowser3);

	mainWindow->Append(&w);

	ResumeGui();
	while (!exit)
	{
		usleep(100);

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

		ret = optionBrowser3.GetClickedOption();

		if (ret >= 0)
		{
			choice = WindowPrompt(options.GetValue(ret), tr( "Load this DOL as alternate DOL?" ), tr( "OK" ), tr( "Cancel" ));
			if (choice)
			{
				snprintf(alternatedname, alternatedname_size, options.GetValue(ret));
				const char * offset = options.GetName(ret);
				if(offset)
					ret = atoi(offset+strlen("Offset ")); //doloffset
				else
					ret = -1; // weird problem
				exit = true;
			}
		}

		if (cancelBtn.GetState() == STATE_CLICKED)
		{
			exit = true;
		}
	}

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

	return ret;
}
Example #19
0
string choiceRev(string revs)
{
	bool stop = false;
	string rev = "NULL";

	TextLine versions;
	versions.list(revs);

	GuiText titleTxt(tr("Update"), 26, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	titleTxt.SetPosition(0, 40);

	GuiWindow promptWindow(520,360);
	promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	promptWindow.SetPosition(0, -10);
	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);

	GuiImageData dialogBox(Theme.dialog_background);
	GuiImage dialogBoxImg(&dialogBox);

	int place = 23;
	int y = 150;
	int i = 0;
	int number = 5;
	int selection = 0;
	int selctionPos = y;

	GuiText selectionTxt(">>                              <<", 20, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	selectionTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	selectionTxt.SetPosition(0, y);

	GuiText upTxt("c", 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	upTxt.SetFont(symbol_ttf, symbol_ttf_size);
	upTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	upTxt.SetPosition(0, y -20);

	GuiText downTxt("d", 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	downTxt.SetFont(symbol_ttf, symbol_ttf_size);
	downTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	downTxt.SetPosition(0, y + (place * (number-1)) + 15);

	GuiText * Entrie[number];

	for(i=0; i < number && i < (signed)versions.line.size(); i++)
	{
		Entrie[i] = new GuiText(versions.line[i].c_str(), 20, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
		Entrie[i]->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
		Entrie[i]->SetPosition(0, y);
		y += place;
	}

	promptWindow.Append(&dialogBoxImg);
	promptWindow.Append(&titleTxt);
	promptWindow.Append(&selectionTxt);

	for(int x=0; x < i; x++)
		promptWindow.Append(Entrie[x]);

	if((signed)versions.line.size() >= number)
	{
		promptWindow.Append(&upTxt);
		promptWindow.Append(&downTxt);
	}

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

	while(!stop)
	{
		usleep(100);

		if(WPAD_ButtonsHeld(0) & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP) || PAD_ButtonsDown(0) & PAD_BUTTON_UP)
		{

			selection--;
			if(selection < 0)
			{
				selection = 0;

				int z = versions.text_up();
				for(int x=0; x < i; x++)
					Entrie[x]->SetText(versions.line[x + z].c_str());
			}
			selectionTxt.SetPosition(0, selection * place + selctionPos);

			HaltResumeGui();
			usleep(100000);
		}

		if(WPAD_ButtonsHeld(0) & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN) || PAD_ButtonsDown(0) & PAD_BUTTON_DOWN)
		{

			selection++;
			if(selection > number -1)
			{
				selection = number -1;

				int z = versions.text_down(number);
				for(int x=0; x < i; x++)
					Entrie[x]->SetText(versions.line[x + z].c_str());
			}
			selectionTxt.SetPosition(0, selection * place + selctionPos);

			HaltResumeGui();
			usleep(100000);
		}

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A) || PAD_ButtonsDown(0) & PAD_BUTTON_A)
		{
			rev = versions.line[selection + versions.textScrollPos];
			stop = true;
		}

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B) || PAD_ButtonsDown(0) & PAD_BUTTON_B)
			stop = true;
	}

	promptWindow.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50);
	while(promptWindow.GetEffect() > 0) usleep(100);
	HaltGui();
	mainWindow->Remove(&promptWindow);
	mainWindow->SetState(STATE_DEFAULT);
	ResumeGui();
	return rev;
}
/****************************************************************************
 * 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;
}
Example #21
0
/****************************************************************************
 * WindowPrompt
 *
 * Displays a prompt window to user, with information, an error message, or
 * presenting a user with a choice
 ***************************************************************************/
void
updatePrompt(string rev)
{
//	bool stop = true;

	GuiWindow promptWindow(520,360);
	promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	promptWindow.SetPosition(0, -10);
	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);


	GuiImageData dialogBox(Theme.dialog_background);
	GuiImage dialogBoxImg(&dialogBox);

	GuiImageData btnOutline(Theme.button_small);
	GuiImage btn1Img(&btnOutline);
	GuiImage btn2Img(&btnOutline);

	GuiImageData btnOutlineOver(Theme.button_small_focus);
	GuiImage btn1ImgOver(&btnOutlineOver);
	GuiImage btn2ImgOver(&btnOutlineOver);

	GuiText titleTxt(tr("Update"), 26, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	titleTxt.SetPosition(0, 40);
	GuiText downloadTxt(tr("Downloading file..."), 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	downloadTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	downloadTxt.SetPosition(0, -20);

	GuiText msgTxt(tr("please wait"), 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	msgTxt.SetPosition(0, 20);

	GuiText btn1Txt(tr("Yes"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiButton btn1(btnOutline.GetWidth(), btnOutline.GetHeight());

	btn1.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
	btn1.SetPosition(20, -25);
	btn1.SetLabel(&btn1Txt);
	btn1.SetImage(&btn1Img);
	btn1.SetImageOver(&btn1ImgOver);
	btn1.SetTrigger(&trigA);
	btn1.SetState(STATE_SELECTED);
	btn1.SetEffectGrow();

	GuiText btn2Txt(tr("No"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiButton btn2(btnOutline.GetWidth(), btnOutline.GetHeight());

	btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
	btn2.SetPosition(-20, -25);
	btn2.SetLabel(&btn2Txt);
	btn2.SetImage(&btn2Img);
	btn2.SetImageOver(&btn2ImgOver);
	btn2.SetTrigger(&trigA);
	btn2.SetEffectGrow();

	promptWindow.Append(&dialogBoxImg);
	promptWindow.Append(&titleTxt);
	promptWindow.Append(&downloadTxt);
	promptWindow.Append(&msgTxt);

	HaltGui();
	mainWindow->SetState(STATE_DISABLED);
	mainWindow->Append(&promptWindow);
	mainWindow->ChangeFocus(&promptWindow);
	ResumeGui();

	char url[100];
#ifdef STBOOTVWII
	if(rev == "Beta")
		sprintf(url, "http://www.nanolx.org/hbf/DOL.st.vwii/Beta/boot.dol");
	else
		sprintf(url, "http://www.nanolx.org/hbf/DOL.st.vwii/rev%s/boot.dol", rev.c_str());

	// copy boot.dol to prev.dol
	std::ifstream infile((Settings.device_dat + ":/apps/HomebrewFilter.vWii.Standalone/boot.dol").c_str(), std::ios_base::binary);
	std::ofstream outfile((Settings.device_dat + ":/apps/HomebrewFilter.vWii.Standalone/prev.dol").c_str(), std::ios_base::binary);
#elif VWII
	if(rev == "Beta")
		sprintf(url, "http://www.nanolx.org/hbf/DOL.vwii/Beta/boot.dol");
	else
		sprintf(url, "http://www.nanolx.org/hbf/DOL.vwii/rev%s/boot.dol", rev.c_str());

	// copy boot.dol to prev.dol
	std::ifstream infile((Settings.device_dat + ":/apps/HomebrewFilter.vWii/boot.dol").c_str(), std::ios_base::binary);
	std::ofstream outfile((Settings.device_dat + ":/apps/HomebrewFilter.vWii/prev.dol").c_str(), std::ios_base::binary);
#elif STDBOOT
	if(rev == "Beta")
		sprintf(url, "http://www.nanolx.org/hbf/DOL.st/Beta/boot.dol");
	else
		sprintf(url, "http://www.nanolx.org/hbf/DOL.st/rev%s/boot.dol", rev.c_str());

	// copy boot.dol to prev.dol
	std::ifstream infile((Settings.device_dat + ":/apps/HomebrewFilter.Standalone/boot.dol").c_str(), std::ios_base::binary);
	std::ofstream outfile((Settings.device_dat + ":/apps/HomebrewFilter.Standalone/prev.dol").c_str(), std::ios_base::binary);
#else
	if(rev == "Beta")
		sprintf(url, "http://www.nanolx.org/hbf/DOL/Beta/boot.dol");
	else
		sprintf(url, "http://www.nanolx.org/hbf/DOL/rev%s/boot.dol", rev.c_str());

	// copy boot.dol to prev.dol
	std::ifstream infile((Settings.device_dat + ":/apps/HomebrewFilter/boot.dol").c_str(), std::ios_base::binary);
	std::ofstream outfile((Settings.device_dat + ":/apps/HomebrewFilter/prev.dol").c_str(), std::ios_base::binary);
#endif

	outfile << infile.rdbuf();

	struct block file = downloadfile(url);
	if (file.data && file.size > 0)
	{
		// write file
#ifdef STBOOTVWII
		if(opendir(check_path(Settings.device_dat + ":/apps/HomebrewFilter.vWii.Standalone").c_str()) == NULL)
				mkdir((Settings.device_dat + ":/apps/HomebrewFilter.vWii.Standalone").c_str(), 0777);

		FILE * data = fopen((Settings.device_dat + ":/apps/HomebrewFilter.vWii.Standalone/boot.dol").c_str(), "wb");
		if(data)
		{
			fwrite(file.data, 1, file.size, data);
			fclose(data);
		}
#elif VWII
		if(opendir(check_path(Settings.device_dat + ":/apps/HomebrewFilter.vWii").c_str()) == NULL)
				mkdir((Settings.device_dat + ":/apps/HomebrewFilter.vWii").c_str(), 0777);

		FILE * data = fopen((Settings.device_dat + ":/apps/HomebrewFilter.vWii/boot.dol").c_str(), "wb");
		if(data)
		{
			fwrite(file.data, 1, file.size, data);
			fclose(data);
		}
#elif STDBOOT
		if(opendir(check_path(Settings.device_dat + ":/apps/HomebrewFilter.Standalone").c_str()) == NULL)
				mkdir((Settings.device_dat + ":/apps/HomebrewFilter.Standalone").c_str(), 0777);

		FILE * data = fopen((Settings.device_dat + ":/apps/HomebrewFilter.Standalone/boot.dol").c_str(), "wb");
		if(data)
		{
			fwrite(file.data, 1, file.size, data);
			fclose(data);
		}
#else
		if(opendir(check_path(Settings.device_dat + ":/apps/HomebrewFilter").c_str()) == NULL)
				mkdir((Settings.device_dat + ":/apps/HomebrewFilter").c_str(), 0777);

		FILE * data = fopen((Settings.device_dat + ":/apps/HomebrewFilter/boot.dol").c_str(), "wb");
		if(data)
		{
			fwrite(file.data, 1, file.size, data);
			fclose(data);
		}
#endif
		if(file.data)
			free(file.data);

		boot_buffer = true;
		updatehbf = true;
	}
	else
	{
		if(file.data)
			free(file.data);
	}

	HaltGui();
	mainWindow->Remove(&promptWindow);
	mainWindow->SetState(STATE_DEFAULT);
	ResumeGui();
}
/****************************************************************************
 * WindowPrompt
 *
 * Displays a prompt window to user, with information, an error message, or
 * presenting a user with a choice
 ***************************************************************************/
int devicePrompt()
{
	bool stop = false;
	int device = -1;

#ifndef VWII
	GuiWindow promptWindow(328,64);
#else
	GuiWindow promptWindow(144,64);
#endif
	promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	promptWindow.SetPosition(-135, 280);
	GuiTrigger trigA;
	GuiTrigger trigB;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
	trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);

	// Hintergrund
#ifndef VWII
	GuiImageData dialogBox(Theme.choice_large);
#else
	GuiImageData dialogBox(Theme.choice);
#endif
	GuiImage dialogBoxImg(&dialogBox);

	// button data
	GuiImageData sd_BtnImgData(Theme.sd_inactive);
	GuiImageData sd_BtnImgDataOver(Theme.sd_active);
	GuiImageData usb_BtnImgData(Theme.usb_inactive);
	GuiImageData usb_BtnImgDataOver(Theme.usb_active);
	GuiImageData sd_usb_BtnImgData(Theme.sd_usb_inactive);
	GuiImageData sd_usb_BtnImgDataOver(Theme.sd_usb_active);
#ifndef VWII
	GuiImageData dvd_BtnImgData(Theme.dvd_inactive);
	GuiImageData dvd_BtnImgDataOver(Theme.dvd_active);
	GuiImageData gca_BtnImgData(Theme.gca_inactive);
	GuiImageData gca_BtnImgDataOver(Theme.gca_active);
	GuiImageData gcb_BtnImgData(Theme.gcb_inactive);
	GuiImageData gcb_BtnImgDataOver(Theme.gcb_active);
	GuiImageData all_BtnImgData(Theme.all_inactive);
	GuiImageData all_BtnImgDataOver(Theme.all_active);
#endif

	// button
	GuiImage sd_BtnImg(&sd_BtnImgData);
	GuiImage usb_BtnImg(&usb_BtnImgData);
	GuiImage sd_usb_BtnImg(&sd_usb_BtnImgData);
#ifndef VWII
	GuiImage dvd_BtnImg(&dvd_BtnImgData);
	GuiImage gca_BtnImg(&gca_BtnImgData);
	GuiImage gcb_BtnImg(&gca_BtnImgData);
	GuiImage all_BtnImg(&all_BtnImgData);
#endif

	// button over
	GuiImage sd_BtnImgOver(&sd_BtnImgDataOver);
	GuiImage usb_BtnImgOver(&usb_BtnImgDataOver);
	GuiImage sd_usb_BtnImgOver(&sd_usb_BtnImgDataOver);
#ifndef VWII
	GuiImage dvd_BtnImgOver(&dvd_BtnImgDataOver);
	GuiImage gca_BtnImgOver(&gca_BtnImgDataOver);
	GuiImage gcb_BtnImgOver(&gca_BtnImgDataOver);
	GuiImage all_BtnImgOver(&all_BtnImgDataOver);
#endif

	GuiButton sd_Btn(sd_BtnImgData.GetWidth(), sd_BtnImgData.GetHeight());
	sd_Btn.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
	sd_Btn.SetPosition(8, 0);
	sd_Btn.SetImage(&sd_BtnImg);
	sd_Btn.SetImageOver(&sd_BtnImgOver);
	sd_Btn.SetTrigger(&trigA);

	GuiButton usb_Btn(usb_BtnImgData.GetWidth(), usb_BtnImgData.GetHeight());
	usb_Btn.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
	usb_Btn.SetPosition(52, 0);
	usb_Btn.SetImage(&usb_BtnImg);
	usb_Btn.SetImageOver(&usb_BtnImgOver);
	usb_Btn.SetTrigger(&trigA);

	GuiButton sd_usb_Btn(sd_usb_BtnImgData.GetWidth(), sd_usb_BtnImgData.GetHeight());
	sd_usb_Btn.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
	sd_usb_Btn.SetPosition(96, 0);
	sd_usb_Btn.SetImage(&sd_usb_BtnImg);
	sd_usb_Btn.SetImageOver(&sd_usb_BtnImgOver);
	sd_usb_Btn.SetTrigger(&trigA);
#ifndef VWII
	GuiButton dvd_Btn(dvd_BtnImgData.GetWidth(), dvd_BtnImgData.GetHeight());
	dvd_Btn.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	dvd_Btn.SetPosition(0, 0);
	dvd_Btn.SetImage(&dvd_BtnImg);
	dvd_Btn.SetImageOver(&dvd_BtnImgOver);
	dvd_Btn.SetTrigger(&trigA);

	GuiButton gca_Btn(gca_BtnImgData.GetWidth(), gca_BtnImgData.GetHeight());
	gca_Btn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
	gca_Btn.SetPosition(-96, 0);
	gca_Btn.SetImage(&gca_BtnImg);
	gca_Btn.SetImageOver(&gca_BtnImgOver);
	gca_Btn.SetTrigger(&trigA);

	GuiButton gcb_Btn(gcb_BtnImgData.GetWidth(), gcb_BtnImgData.GetHeight());
	gcb_Btn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
	gcb_Btn.SetPosition(-52, 0);
	gcb_Btn.SetImage(&gcb_BtnImg);
	gcb_Btn.SetImageOver(&gcb_BtnImgOver);
	gcb_Btn.SetTrigger(&trigA);

	GuiButton all_Btn(all_BtnImgData.GetWidth(), all_BtnImgData.GetHeight());
	all_Btn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
	all_Btn.SetPosition(-8, 0);
	all_Btn.SetImage(&all_BtnImg);
	all_Btn.SetImageOver(&all_BtnImgOver);
	all_Btn.SetTrigger(&trigA);
#endif
	GuiButton back(0, 0);
	back.SetTrigger(&trigB);

	promptWindow.Append(&dialogBoxImg);
	promptWindow.Append(&sd_Btn);
	promptWindow.Append(&usb_Btn);
	promptWindow.Append(&sd_usb_Btn);
#ifndef VWII
	promptWindow.Append(&dvd_Btn);
	promptWindow.Append(&gca_Btn);
	promptWindow.Append(&gcb_Btn);
	promptWindow.Append(&all_Btn);
#endif
	promptWindow.Append(&back);

	HaltGui();
	mainWindow->SetState(STATE_DISABLED2);
	mainWindow->Append(&promptWindow);
	mainWindow->ChangeFocus(&promptWindow);
	ResumeGui();

	while(!stop)
	{
		usleep(100);

		if(sd_Btn.GetState() == STATE_CLICKED)
		{
			device = 1;
			stop = true;
		}

		if(usb_Btn.GetState() == STATE_CLICKED)
		{
			device = 2;
			stop = true;
		}

		if(sd_usb_Btn.GetState() == STATE_CLICKED)
		{
			device = 3;
			stop = true;
		}
#ifndef VWII
		if(dvd_Btn.GetState() == STATE_CLICKED)
		{
			device = 4;
			stop = true;
		}

		if(gca_Btn.GetState() == STATE_CLICKED)
		{
			device = 5;
			stop = true;
		}

		if(gcb_Btn.GetState() == STATE_CLICKED)
		{
			device = 6;
			stop = true;
		}

		if(all_Btn.GetState() == STATE_CLICKED)
		{
			device = 7;
			stop = true;
		}
#endif
		if(back.GetState() == STATE_CLICKED)
			stop = true;
	}

	HaltGui();
	mainWindow->Remove(&promptWindow);
	mainWindow->SetState(STATE_DEFAULT);
	ResumeGui();

	return device;
}
Example #23
0
s32 Wad_Install(FILE *fp)
{
	//////start the gui shit
	GuiWindow promptWindow(472,320);
	promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	promptWindow.SetPosition(0, -10);

	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), "%sdialogue_box.png", CFG.theme_path);
	GuiImageData dialogBox(imgPath, dialogue_box_png);
	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);

	GuiImage dialogBoxImg(&dialogBox);
	if (Settings.wsprompt == yes){
	dialogBoxImg.SetWidescreen(CFG.widescreen);}

	GuiText btn1Txt(tr("OK"), 22, THEME.prompttext);
	GuiImage btn1Img(&btnOutline);
	if (Settings.wsprompt == yes){
	btn1Txt.SetWidescreen(CFG.widescreen);
	btn1Img.SetWidescreen(CFG.widescreen);}
	GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -35, &trigA, &btnSoundOver, btnClick2,1);
	btn1.SetLabel(&btn1Txt);
	btn1.SetState(STATE_SELECTED);

	snprintf(imgPath, sizeof(imgPath), "%sprogressbar_outline.png", CFG.theme_path);
	GuiImageData progressbarOutline(imgPath, progressbar_outline_png);
	GuiImage progressbarOutlineImg(&progressbarOutline);
	if (Settings.wsprompt == yes){
	progressbarOutlineImg.SetWidescreen(CFG.widescreen);}
	progressbarOutlineImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
	progressbarOutlineImg.SetPosition(25, 50);

	snprintf(imgPath, sizeof(imgPath), "%sprogressbar_empty.png", CFG.theme_path);
	GuiImageData progressbarEmpty(imgPath, progressbar_empty_png);
	GuiImage progressbarEmptyImg(&progressbarEmpty);
	progressbarEmptyImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
	progressbarEmptyImg.SetPosition(25, 50);
	progressbarEmptyImg.SetTile(100);

	snprintf(imgPath, sizeof(imgPath), "%sprogressbar.png", CFG.theme_path);
	GuiImageData progressbar(imgPath, progressbar_png);
	GuiImage progressbarImg(&progressbar);
	progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
	progressbarImg.SetPosition(25, 50);

    char title[50];
   sprintf(title, "%s", tr("Installing wad"));
	GuiText titleTxt(title, 26, THEME.prompttext);
	titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	titleTxt.SetPosition(0,40);
    char msg[50];
    sprintf(msg, " ");
	// sprintf(msg, "%s", tr("Initializing Network"));
	GuiText msg1Txt(NULL, 20, THEME.prompttext);
	msg1Txt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	msg1Txt.SetPosition(50,75);
//	char msg2[50] = " ";
	GuiText msg2Txt(NULL, 20, THEME.prompttext);
	msg2Txt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	msg2Txt.SetPosition(50, 98);

	GuiText msg3Txt(NULL, 20, THEME.prompttext);
	msg3Txt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	msg3Txt.SetPosition(50, 121);

	GuiText msg4Txt(NULL, 20, THEME.prompttext);
	msg4Txt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	msg4Txt.SetPosition(50, 144);

	GuiText msg5Txt(NULL, 20, THEME.prompttext);
	msg5Txt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	msg5Txt.SetPosition(50, 167);

	GuiText prTxt(NULL, 26, THEME.prompttext);
	prTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	prTxt.SetPosition(0, 50);


	if ((Settings.wsprompt == yes) && (CFG.widescreen)){/////////////adjust for widescreen
		progressbarOutlineImg.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
		progressbarOutlineImg.SetPosition(0, 50);
		progressbarEmptyImg.SetPosition(80,50);
		progressbarEmptyImg.SetTile(78);
		progressbarImg.SetPosition(80, 50);

		msg1Txt.SetPosition(90,75);
		msg2Txt.SetPosition(90, 98);
		msg3Txt.SetPosition(90, 121);
		msg4Txt.SetPosition(90, 144);
		msg5Txt.SetPosition(90, 167);

	}
	promptWindow.Append(&dialogBoxImg);
	promptWindow.Append(&titleTxt);
	promptWindow.Append(&msg5Txt);
	promptWindow.Append(&msg4Txt);
	promptWindow.Append(&msg3Txt);
	promptWindow.Append(&msg1Txt);
	promptWindow.Append(&msg2Txt);

   //promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50);

	HaltGui();
	mainWindow->SetState(STATE_DISABLED);
	mainWindow->Append(&promptWindow);
	mainWindow->ChangeFocus(&promptWindow);
	//sleep(1);


	///start the wad shit
	bool fail = false;
	wadHeader   *header  = NULL;
	void		*pvoid;
	signed_blob *p_certs = NULL, *p_crl = NULL, *p_tik = NULL, *p_tmd = NULL;

	tmd *tmd_data  = NULL;

	u32 cnt, offset = 0;
	s32 ret = 666;


	ResumeGui();
	msg1Txt.SetText(tr(">> Reading WAD data..."));
	HaltGui();
#define SetPointer(a, p) a=(typeof(a))p
	// WAD header
	//ret = __Wad_ReadAlloc(fp, (void *)header, offset, sizeof(wadHeader));
	ret = __Wad_ReadAlloc(fp, &pvoid, offset, sizeof(wadHeader));

	if (ret < 0)
		goto err;
	SetPointer(header, pvoid);
	offset += round_up(header->header_len, 64);

	// WAD certificates
	//ret = __Wad_ReadAlloc(fp, (void *)&p_certs, offset, header->certs_len);
	ret = __Wad_ReadAlloc(fp, &pvoid, offset, header->certs_len);
	if (ret < 0)
		goto err;
	SetPointer(p_certs, pvoid);
	offset += round_up(header->certs_len, 64);

	// WAD crl

	if (header->crl_len) {
		//ret = __Wad_ReadAlloc(fp, (void *)&p_crl, offset, header->crl_len);
		ret = __Wad_ReadAlloc(fp, &pvoid, offset, header->crl_len);
		if (ret < 0)
			goto err;
		SetPointer(p_crl, pvoid);
		offset += round_up(header->crl_len, 64);
	}

	// WAD ticket
	//ret = __Wad_ReadAlloc(fp, (void *)&p_tik, offset, header->tik_len);
	ret = __Wad_ReadAlloc(fp, &pvoid, offset, header->tik_len);
	if (ret < 0)
		goto err;
	SetPointer(p_tik, pvoid);
	offset += round_up(header->tik_len, 64);

	// WAD TMD
	//ret = __Wad_ReadAlloc(fp, (void *)&p_tmd, offset, header->tmd_len);
	ret = __Wad_ReadAlloc(fp, &pvoid, offset, header->tmd_len);
	if (ret < 0)
		goto err;
	SetPointer(p_tmd, pvoid);
	offset += round_up(header->tmd_len, 64);

	ResumeGui();
	msg1Txt.SetText(tr("Reading WAD data... Ok!"));
	msg2Txt.SetText(tr(">> Installing ticket..."));
	HaltGui();
	// Install ticket
	ret = ES_AddTicket(p_tik, header->tik_len, p_certs, header->certs_len, p_crl, header->crl_len);
	if (ret < 0)
		goto err;

	ResumeGui();
	msg2Txt.SetText(tr("Installing ticket... Ok!"));
	msg3Txt.SetText(tr(">> Installing title..."));
	//WindowPrompt(">> Installing title...",0,0,0,0,0,200);
	HaltGui();
	// Install title
	ret = ES_AddTitleStart(p_tmd, header->tmd_len, p_certs, header->certs_len, p_crl, header->crl_len);
	if (ret < 0)
		goto err;

	// Get TMD info
	tmd_data = (tmd *)SIGNATURE_PAYLOAD(p_tmd);

	// Install contents
	//ResumeGui();
	//HaltGui();
	promptWindow.Append(&progressbarEmptyImg);
   promptWindow.Append(&progressbarImg);
   promptWindow.Append(&progressbarOutlineImg);
   promptWindow.Append(&prTxt);
	ResumeGui();
	msg3Txt.SetText(tr("Installing title... Ok!"));
	for (cnt = 0; cnt < tmd_data->num_contents; cnt++) {

		tmd_content *content = &tmd_data->contents[cnt];

		u32 idx = 0, len;
		s32 cfd;
		ResumeGui();

		//printf("\r\t\t>> Installing content #%02d...", content->cid);
		// Encrypted content size
		len = round_up(content->size, 64);

		// Install content
		cfd = ES_AddContentStart(tmd_data->title_id, content->cid);
		if (cfd < 0) {
			ret = cfd;
			goto err;
		}
		snprintf(imgPath, sizeof(imgPath), "%s%d...",tr(">> Installing content #"),content->cid);
		msg4Txt.SetText(imgPath);
		// Install content data
		while (idx < len) {

            //VIDEO_WaitVSync ();

			u32 size;

			// Data length
			size = (len - idx);
			if (size > BLOCK_SIZE)
				size = BLOCK_SIZE;

			// Read data
			ret = __Wad_ReadFile(fp, &wadBuffer, offset, size);
			if (ret < 0)
				goto err;

			// Install data
			ret = ES_AddContentData(cfd, wadBuffer, size);
			if (ret < 0)
				goto err;

			// Increase variables
			idx    += size;
			offset += size;
		
		//snprintf(imgPath, sizeof(imgPath), "%s%d (%d)...",tr(">> Installing content #"),content->cid,idx);

		//msg4Txt.SetText(imgPath);

		prTxt.SetTextf("%i%%", 100*(cnt*len+idx)/(tmd_data->num_contents*len));
      if ((Settings.wsprompt == yes) && (CFG.widescreen)) {
         progressbarImg.SetTile(78*(cnt*len+idx)/(tmd_data->num_contents*len));
      } else {
         progressbarImg.SetTile(100*(cnt*len+idx)/(tmd_data->num_contents*len));
      }

		}

		// Finish content installation
		ret = ES_AddContentFinish(cfd);
		if (ret < 0)
			goto err;
	}

	msg4Txt.SetText(tr("Installing content... Ok!"));
	msg5Txt.SetText(tr(">> Finishing installation..."));



	// Finish title install
	ret = ES_AddTitleFinish();
	if (ret >= 0) {
//		printf(" OK!\n");
		goto out;
	}

err:
	//char titties[100];
	ResumeGui();
	prTxt.SetTextf("%s%d", tr("Error..."),ret);
	promptWindow.Append(&prTxt);
	fail = true;
  	//snprintf(titties, sizeof(titties), "%d", ret);
	//printf(" ERROR! (ret = %d)\n", ret);
	//WindowPrompt("ERROR!",titties,"Back",0,0);
	// Cancel install
	ES_AddTitleCancel();
	goto exit;
	//return ret;

out:
	// Free memory
	if (header)
		free(header);
	if (p_certs)
		free(p_certs);
	if (p_crl)
		free(p_crl);
	if (p_tik)
		free(p_tik);
	if (p_tmd)
		free(p_tmd);
	goto exit;


exit:
	if (!fail)msg5Txt.SetText(tr("Finishing installation... Ok!"));
	promptWindow.Append(&btn1);
	while(btn1.GetState() != STATE_CLICKED){
	}


	HaltGui();
	mainWindow->Remove(&promptWindow);
	mainWindow->SetState(STATE_DEFAULT);
	ResumeGui();

	return ret;
}
Example #24
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();
}
/****************************************************************************
 * WindowPrompt
 *
 * Displays a prompt window to user, with information, an error message, or
 * presenting a user with a choice
 ***************************************************************************/
void
infoPrompt()
{
	bool stop = false;

	GuiWindow promptWindow(520,360);
	promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	promptWindow.SetPosition(0, -10);
	GuiImageData btnOutline(Theme.button_tiny);
	GuiImageData btnOutlineOver(Theme.button_tiny_focus);
	GuiTrigger trigA;
	GuiTrigger trigB;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
	trigB.SetSimpleTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);

	GuiImageData dialogBox(Theme.dialog_background);
	GuiImage dialogBoxImg(&dialogBox);

    int i = 0;
    int x = 30;
    int y = 40;
	GuiText * Entrie[20];

    Entrie[i] = new GuiText(tr("About HomebrewFilter"), 28, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
    Entrie[i]->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    Entrie[i]->SetPosition(0, y);
    i++;
    y += 50;

    Entrie[i] = new GuiText(tr("Developers:"), 24, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
    Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    Entrie[i]->SetPosition(x, y);
    i++;

//    Entrie[i] = new GuiText("hamachi-mp / Christopher Roy Bratusek / obcd", 22, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
    Entrie[i] = new GuiText("hamachi-mp   Nano   Obcd", 22, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
    Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    Entrie[i]->SetPosition(x+200, y);
    i++;
    y += 32;

    Entrie[i] = new GuiText(tr("Designer:"), 24, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
    Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    Entrie[i]->SetPosition(x, y);
    i++;

    Entrie[i] = new GuiText("Black.Pearl", 22, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
    Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    Entrie[i]->SetPosition(x+200, y);
    i++;
    y += 50;

    Entrie[i] = new GuiText(tr("Special thanks to:"), 22, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
    Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    Entrie[i]->SetPosition(x,y);
	i++;
	y += 32;

	Entrie[i] = new GuiText("- Dimok", 20, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
    Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    Entrie[i]->SetPosition(x+50,y);
    i++;
	y += 32;

	Entrie[i] = new GuiText("- ichfly ", 20, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
    Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    Entrie[i]->SetPosition(x+50,y);
    i++;
	y += 32;

	Entrie[i] = new GuiText("- all the translators", 20, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
    Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    Entrie[i]->SetPosition(x+50,y);
    i++;


    int CreditEntries = i;

	char Rev[50];
#ifdef STBOOTVWII
	sprintf(Rev, "Rev. %i (vWii ST)", SvnRev());
#elif VWII
	sprintf(Rev, "Rev. %i (vWii Full)", SvnRev());
#elif STBOOT
	sprintf(Rev, "Rev. %i (Wii ST)", SvnRev());
#else
	sprintf(Rev, "Rev. %i (Wii Full)", SvnRev());
#endif
	GuiText RevTxt(Rev, 20, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	RevTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	RevTxt.SetPosition(30,24);

	char RunsIos[50];
	if((*(volatile unsigned int*)HW_ARMIRQMASK)&&(*(volatile unsigned int*)HW_ARMIRQFLAG))
		sprintf(RunsIos, "IOS %i Rev. %i (HW_AHBPROT)", IOS_GetVersion(), IOS_GetRevision());
	else
		sprintf(RunsIos, "IOS %i Rev. %i", IOS_GetVersion(), IOS_GetRevision());

	GuiText RunsIosTxt(RunsIos, 14, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	RunsIosTxt.SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
	RunsIosTxt.SetPosition(-30,24);

	GuiText backTxt(tr("Back"), 24, (GXColor){Theme.button_tiny_text_1, Theme.button_tiny_text_2, Theme.button_tiny_text_3, 255});
	GuiImage backImg(&btnOutline);
	GuiImage backImgOver(&btnOutlineOver);
	GuiButton back(btnOutline.GetWidth(), btnOutline.GetHeight());
	back.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
	back.SetPosition(0, -15);
	back.SetLabel(&backTxt);
	back.SetImage(&backImg);
	back.SetImageOver(&backImgOver);
	back.SetTrigger(&trigA);
	back.SetTrigger(&trigB);

	promptWindow.Append(&dialogBoxImg);

	for(int i = 0; i < CreditEntries; i++)
        promptWindow.Append(Entrie[i]);

    promptWindow.Append(&RevTxt);
    promptWindow.Append(&RunsIosTxt);
	promptWindow.Append(&back);

	HaltGui();
	mainWindow->SetState(STATE_DISABLED);
	mainWindow->Append(&promptWindow);
	mainWindow->ChangeFocus(&promptWindow);
	ResumeGui();

	while(!stop)
	{
		usleep(100);

		if(back.GetState() == STATE_CLICKED)
			stop = true;
	}

	HaltGui();
	mainWindow->Remove(&promptWindow);
	mainWindow->SetState(STATE_DEFAULT);
	ResumeGui();
}
Example #26
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;
}
/****************************************************************************
 * OnScreenKeyboard
 *
 * Opens an on-screen keyboard window, with the data entered being stored
 * into the specified variable.
 ***************************************************************************/
void OnScreenKeyboard(char * var, u16 maxlen, bool br)
{
	int save = -1;

	GuiKeyboard keyboard(var, maxlen, br);

	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);

	GuiText okBtnTxt("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(25, -25);

	okBtn.SetLabel(&okBtnTxt);
	okBtn.SetImage(&okBtnImg);
	okBtn.SetImageOver(&okBtnImgOver);
	okBtn.SetTrigger(&trigA);
	okBtn.SetEffectGrow();

	GuiText cancelBtnTxt(tr("Stop"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiImage cancelBtnImg(&btnOutline);
	GuiImage cancelBtnImgOver(&btnOutlineOver);
	GuiButton cancelBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
	cancelBtn.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
	cancelBtn.SetPosition(-25, -25);
	cancelBtn.SetLabel(&cancelBtnTxt);
	cancelBtn.SetImage(&cancelBtnImg);
	cancelBtn.SetImageOver(&cancelBtnImgOver);
	cancelBtn.SetTrigger(&trigA);
	cancelBtn.SetEffectGrow();

	keyboard.Append(&okBtn);
	keyboard.Append(&cancelBtn);

	HaltGui();
	mainWindow->SetState(STATE_DISABLED);
	mainWindow->Append(&keyboard);
	mainWindow->ChangeFocus(&keyboard);
	ResumeGui();

	int textpointertime = 0;
	bool textpointerswitch = true;
	while(save == -1)
	{
		usleep(100);

		textpointertime++;
		if(textpointerswitch && textpointertime >= 5000)
		{
			textpointertime = 0;
			textpointerswitch = false;
		}
		else if(!textpointerswitch && textpointertime >= 5000)
		{
			textpointertime = 0;
			textpointerswitch = true;
		}
		keyboard.textpointerImg->SetVisible(textpointerswitch);

		if(okBtn.GetState() == STATE_CLICKED)
			save = 1;
		else if(cancelBtn.GetState() == STATE_CLICKED)
			save = 0;
	}

	if(save)
		snprintf(var, maxlen, "%s", keyboard.kbtextstr);
	else
		snprintf(var, maxlen, "%s", "NULL");


	HaltGui();
	mainWindow->Remove(&keyboard);
	mainWindow->SetState(STATE_DEFAULT);
	ResumeGui();
}
Example #28
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;
}
Example #29
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;
}
void fontDownload(string fontname)
{
	bool stop = true;

	GuiWindow promptWindow(520,360);
	promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	promptWindow.SetPosition(0, -10);
	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);


	GuiImageData dialogBox(Theme.dialog_background);
	GuiImage dialogBoxImg(&dialogBox);

	GuiImageData btnOutline(Theme.button_small);
	GuiImage btn1Img(&btnOutline);
	GuiImage btn2Img(&btnOutline);

	GuiImageData btnOutlineOver(Theme.button_small_focus);
	GuiImage btn1ImgOver(&btnOutlineOver);
	GuiImage btn2ImgOver(&btnOutlineOver);

	GuiText titleTxt(tr("Download"), 26, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	titleTxt.SetPosition(0, 40);
	GuiText downloadTxt(tr("Downloading file..."), 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	downloadTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	downloadTxt.SetPosition(0, -20);

	GuiText msgTxt(tr("please wait"), 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	msgTxt.SetPosition(0, 20);

	GuiText btn1Txt(tr("OK"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiButton btn1(btnOutline.GetWidth(), btnOutline.GetHeight());

	btn1.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
	btn1.SetPosition(0, -25);
	btn1.SetLabel(&btn1Txt);
	btn1.SetImage(&btn1Img);
	btn1.SetImageOver(&btn1ImgOver);
	btn1.SetTrigger(&trigA);
	btn1.SetState(STATE_SELECTED);
	btn1.SetEffectGrow();

	promptWindow.Append(&dialogBoxImg);
	promptWindow.Append(&titleTxt);
	promptWindow.Append(&downloadTxt);
	promptWindow.Append(&msgTxt);


	HaltGui();
	mainWindow->SetState(STATE_DISABLED);
	mainWindow->Append(&promptWindow);
	mainWindow->ChangeFocus(&promptWindow);
	ResumeGui();

	char buffer[100];
	msgTxt.SetText(fontname.c_str());
	sprintf(buffer, "http://www.nanolx.org/hbf/Fonts/%s", fontname.c_str());
	struct block file = downloadfile(buffer);
	if (file.data && file.size > 0 && folder_exists())
	{
		FILE * data = fopen((Settings.device_dat + ":/config/HBF/Fonts/"+ fontname).c_str(), "wb");
		if(data)
		{
			fwrite(file.data, 1, file.size, data);
			fclose(data);
		}
	}
	if(file.data)
		free(file.data);

	msgTxt.SetText("");
	downloadTxt.SetText(tr("finished"));

	promptWindow.Append(&btn1);


	while(stop)
	{
		usleep(100);

		if(btn1.GetState() == STATE_CLICKED)
			stop = false;
	}

	HaltGui();
	mainWindow->Remove(&promptWindow);
	mainWindow->SetState(STATE_DEFAULT);
	ResumeGui();
}