/**************************************************************************** * 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; }
/**************************************************************************** * 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(); }
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(); }