/**************************************************************************** * 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(); }
/**************************************************************************** * 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(); }
/**************************************************************************** * 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; }
/**************************************************************************** * 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(); }
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; }
/**************************************************************************** * 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(); }
/**************************************************************************** * 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; }
/**************************************************************************** * 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(); }
/**************************************************************************** * 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; }
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; }
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; }
/**************************************************************************** * 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; }
/**************************************************************************** * 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 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; }
/**************************************************************************** * 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; }
/**************************************************************************** * ManageAllProgress * * Opens a window, which displays progress to the user. ***************************************************************************/ void ManageAllProgress() { if(!showManageAllProgress) return; GuiSound btnSoundOver(button_over_wav, button_over_wav_size, cfg.SFXVolume); GuiSound btnClick(button_click_wav, button_click_wav_size, cfg.SFXVolume); GuiWindow promptWindow(400,230); promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); promptWindow.SetPosition(0, -10); SimpleGuiTrigger trigA(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); ManageThrobber Throbber(0); Throbber.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); Throbber.SetPosition(45, 0); GuiText nameTxt(NULL, 30, (GXColor){255, 255, 255, 255}); nameTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); nameTxt.SetMaxWidth(430, 1); GuiText subnameTxt(NULL, 24, (GXColor){255, 255, 255, 255}); subnameTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); subnameTxt.SetPosition(0, 35); subnameTxt.SetMaxWidth(430, 1); GuiText errorTxt(NULL, 24, (GXColor){255, 255, 255, 255}); errorTxt.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); errorTxt.SetPosition(0, -50); errorTxt.SetMaxWidth(430); snprintf(progressTxt, sizeof(progressTxt), "%i/%i", progressDone, progressTotal); GuiText stateTxt(progressTxt, 22, (GXColor){255, 255, 255, 255}); stateTxt.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); stateTxt.SetPosition(-10, -8); // Get The banner // ManageAllProgressBanner bannerList(bannerToDisplay); bannerList.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); bannerList.SetPosition(-80, -40); GuiImageData btnOutline(save_manage_button_png, save_manage_button_png_size); GuiImageData btnOutlineOver(save_manage_button_over_png, save_manage_button_over_png_size); GuiImage buttonImg(&btnOutline); GuiImage buttonOverImg(&btnOutlineOver); GuiText AbortTxt(tr("Cancel"), 22, (GXColor){0, 0, 0, 255}); GuiButton AbortBtn(buttonImg.GetWidth(), buttonImg.GetHeight()); AbortBtn.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); AbortBtn.SetLabel(&AbortTxt); AbortBtn.SetImage(&buttonImg); AbortBtn.SetImageOver(&buttonOverImg); AbortBtn.SetSoundOver(&btnSoundOver); AbortBtn.SetSoundClick(&btnClick); AbortBtn.SetTrigger(&trigA); AbortBtn.SetEffectGrow(); promptWindow.Append(&stateTxt); promptWindow.Append(&nameTxt); promptWindow.Append(&subnameTxt); promptWindow.Append(&errorTxt); promptWindow.Append(&bannerList); promptWindow.Append(&AbortBtn); promptWindow.Append(&Throbber); MainWindow::Instance()->HaltGui(); promptWindow.SetEffect(EFFECT_FADE, 20); MainWindow::Instance()->Append(&promptWindow); MainWindow::Instance()->ChangeFocus(&promptWindow); MainWindow::Instance()->ResumeGui(); while(promptWindow.GetEffect() > 0) usleep(100); while(showManageAllProgress != 0) { usleep(80000); throbberCount++; if(throbberCount > 8) throbberCount = 1; Throbber.SetThrobberCount(throbberCount); if(changed) { nameTxt.SetText(progressName); subnameTxt.SetText(progressSubname); snprintf(progressTxt, sizeof(progressTxt), "%i/%i", progressDone, progressTotal); stateTxt.SetText(progressTxt); bannerList.SetBannerToDisplay(bannerToDisplay); changed = false; } else if(AbortBtn.GetState() == STATE_CLICKED) { progresscanceled = true; AbortBtn.ResetState(); } if(showError == true) { AbortBtn.SetVisible(false); AbortBtn.SetState(STATE_DISABLED); errorTxt.SetText(progressError); errorTxt.SetVisible(true); usleep(5000000); errorTxt.SetVisible(false); AbortBtn.SetVisible(true); AbortBtn.SetState(STATE_DEFAULT); showError = false; } } promptWindow.SetEffect(EFFECT_FADE, -20); while(promptWindow.GetEffect() > 0) usleep(100); MainWindow::Instance()->HaltGui(); MainWindow::Instance()->Remove(&promptWindow); MainWindow::Instance()->ResumeGui(); progresscanceled = false; }
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(); }