From 9a77dbd9e628af58c94b4f3af5beb04462827b3c Mon Sep 17 00:00:00 2001 From: giantpune Date: Thu, 16 Jul 2009 08:29:01 +0000 Subject: [PATCH] fixed bug that caused the xml to not be downloaded on some wiis. Added option to download txtcode if none is found. The error checking for this is really weak so you might get a "file not found" page saved as a cheat text. But its bettor than nothing. --- Languages/danish.lang | 8 +- Languages/dutch.lang | 8 +- Languages/english.lang | 8 +- Languages/finnish.lang | 8 +- Languages/french.lang | 8 +- Languages/german.lang | 8 +- Languages/italian.lang | 8 +- Languages/japanese.lang | 8 +- Languages/korean.lang | 8 +- Languages/norwegian.lang | 8 +- Languages/portuguese_br.lang | 8 +- Languages/portuguese_pt.lang | 8 +- Languages/russian.lang | 8 +- Languages/schinese.lang | 8 +- Languages/spanish.lang | 8 +- Languages/swedish.lang | 8 +- Languages/tchinese.lang | 8 +- Languages/turkish.lang | 8 +- gui.pnps | 2 +- source/cheats/cheatmenu.cpp | 13 ++- source/prompts/PromptWindows.cpp | 152 ++++++++++++++++++++++++++++++- source/prompts/PromptWindows.h | 1 + 22 files changed, 289 insertions(+), 23 deletions(-) diff --git a/Languages/danish.lang b/Languages/danish.lang index 4980fbe2..15ad60e6 100644 --- a/Languages/danish.lang +++ b/Languages/danish.lang @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-15 23:05-0400\n" +"POT-Creation-Date: 2009-07-16 03:53-0400\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -138,6 +138,9 @@ msgstr "Klokke" msgid "Close" msgstr "" +msgid "Code Download" +msgstr "" + msgid "Console" msgstr "" @@ -276,6 +279,9 @@ msgstr "Downloade Boxart billede?" msgid "Download Discart image?" msgstr "" +msgid "Download Now" +msgstr "" + msgid "Download finished" msgstr "Download færdig" diff --git a/Languages/dutch.lang b/Languages/dutch.lang index c49d046b..ea8c6a35 100644 --- a/Languages/dutch.lang +++ b/Languages/dutch.lang @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-15 23:05-0400\n" +"POT-Creation-Date: 2009-07-16 03:53-0400\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -138,6 +138,9 @@ msgstr "Klok" msgid "Close" msgstr "Sluiten" +msgid "Code Download" +msgstr "" + msgid "Console" msgstr "Console" @@ -276,6 +279,9 @@ msgstr "Hoesjes downloaden?" msgid "Download Discart image?" msgstr "" +msgid "Download Now" +msgstr "" + msgid "Download finished" msgstr "Downloaden voltooid" diff --git a/Languages/english.lang b/Languages/english.lang index f9684cc5..1bc010de 100644 --- a/Languages/english.lang +++ b/Languages/english.lang @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-15 23:05-0400\n" +"POT-Creation-Date: 2009-07-16 03:53-0400\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -138,6 +138,9 @@ msgstr "" msgid "Close" msgstr "" +msgid "Code Download" +msgstr "" + msgid "Console" msgstr "" @@ -276,6 +279,9 @@ msgstr "" msgid "Download Discart image?" msgstr "" +msgid "Download Now" +msgstr "" + msgid "Download finished" msgstr "" diff --git a/Languages/finnish.lang b/Languages/finnish.lang index b6493290..2dec3183 100644 --- a/Languages/finnish.lang +++ b/Languages/finnish.lang @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-15 23:05-0400\n" +"POT-Creation-Date: 2009-07-16 03:53-0400\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -138,6 +138,9 @@ msgstr "Kello" msgid "Close" msgstr "" +msgid "Code Download" +msgstr "" + msgid "Console" msgstr "" @@ -276,6 +279,9 @@ msgstr "Lataa kansikuva?" msgid "Download Discart image?" msgstr "" +msgid "Download Now" +msgstr "" + msgid "Download finished" msgstr "Lataus valmistunut" diff --git a/Languages/french.lang b/Languages/french.lang index d9b53590..4c89c1af 100644 --- a/Languages/french.lang +++ b/Languages/french.lang @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-15 23:05-0400\n" +"POT-Creation-Date: 2009-07-16 03:53-0400\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -138,6 +138,9 @@ msgstr "Horloge" msgid "Close" msgstr "Fermer" +msgid "Code Download" +msgstr "" + msgid "Console" msgstr "Console" @@ -276,6 +279,9 @@ msgstr "Télécharger les jaquettes ?" msgid "Download Discart image?" msgstr "" +msgid "Download Now" +msgstr "" + msgid "Download finished" msgstr "Téléchargement terminé" diff --git a/Languages/german.lang b/Languages/german.lang index d8fa83bc..17491947 100644 --- a/Languages/german.lang +++ b/Languages/german.lang @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-15 23:05-0400\n" +"POT-Creation-Date: 2009-07-16 03:53-0400\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -138,6 +138,9 @@ msgstr "Uhr" msgid "Close" msgstr "Schließen" +msgid "Code Download" +msgstr "" + msgid "Console" msgstr "" @@ -276,6 +279,9 @@ msgstr "Download Boxart Bilder?" msgid "Download Discart image?" msgstr "" +msgid "Download Now" +msgstr "" + msgid "Download finished" msgstr "Download abgeschlossen" diff --git a/Languages/italian.lang b/Languages/italian.lang index 15fb50b3..a8f6f6f5 100644 --- a/Languages/italian.lang +++ b/Languages/italian.lang @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-15 23:05-0400\n" +"POT-Creation-Date: 2009-07-16 03:53-0400\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -138,6 +138,9 @@ msgstr "Orologio" msgid "Close" msgstr "" +msgid "Code Download" +msgstr "" + msgid "Console" msgstr "Console" @@ -276,6 +279,9 @@ msgstr "Scaricamento Immagine Boxart?" msgid "Download Discart image?" msgstr "" +msgid "Download Now" +msgstr "" + msgid "Download finished" msgstr "Scaricamento Completato" diff --git a/Languages/japanese.lang b/Languages/japanese.lang index c1bb95b4..5f810f8e 100644 --- a/Languages/japanese.lang +++ b/Languages/japanese.lang @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-15 23:05-0400\n" +"POT-Creation-Date: 2009-07-16 03:53-0400\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -138,6 +138,9 @@ msgstr "Clock" msgid "Close" msgstr "閉じる" +msgid "Code Download" +msgstr "" + msgid "Console" msgstr "" @@ -276,6 +279,9 @@ msgstr "Boxart イメージをダウンロードしますか?" msgid "Download Discart image?" msgstr "" +msgid "Download Now" +msgstr "" + msgid "Download finished" msgstr "ダウンロードを終了しました" diff --git a/Languages/korean.lang b/Languages/korean.lang index 3cac11c8..31ab9a91 100644 --- a/Languages/korean.lang +++ b/Languages/korean.lang @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-15 23:05-0400\n" +"POT-Creation-Date: 2009-07-16 03:53-0400\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -138,6 +138,9 @@ msgstr "시계" msgid "Close" msgstr "" +msgid "Code Download" +msgstr "" + msgid "Console" msgstr "" @@ -276,6 +279,9 @@ msgstr "박스 이미지를 다운로드 할까요?" msgid "Download Discart image?" msgstr "" +msgid "Download Now" +msgstr "" + msgid "Download finished" msgstr "다운로드 완료" diff --git a/Languages/norwegian.lang b/Languages/norwegian.lang index c626b01b..dde57d54 100644 --- a/Languages/norwegian.lang +++ b/Languages/norwegian.lang @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-15 23:05-0400\n" +"POT-Creation-Date: 2009-07-16 03:53-0400\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -138,6 +138,9 @@ msgstr "Klokke" msgid "Close" msgstr "Lukk" +msgid "Code Download" +msgstr "" + msgid "Console" msgstr "" @@ -276,6 +279,9 @@ msgstr "Last ned cover bilde?" msgid "Download Discart image?" msgstr "" +msgid "Download Now" +msgstr "" + msgid "Download finished" msgstr "Nedlasting ferdig" diff --git a/Languages/portuguese_br.lang b/Languages/portuguese_br.lang index 8e17c0e0..e77bc1d4 100644 --- a/Languages/portuguese_br.lang +++ b/Languages/portuguese_br.lang @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-15 23:05-0400\n" +"POT-Creation-Date: 2009-07-16 03:53-0400\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -138,6 +138,9 @@ msgstr "Relógio" msgid "Close" msgstr "Fechar" +msgid "Code Download" +msgstr "" + msgid "Console" msgstr "" @@ -276,6 +279,9 @@ msgstr "Baixar imagem da Caixa?" msgid "Download Discart image?" msgstr "" +msgid "Download Now" +msgstr "" + msgid "Download finished" msgstr "Pronto" diff --git a/Languages/portuguese_pt.lang b/Languages/portuguese_pt.lang index 308dc404..2f3e38cb 100644 --- a/Languages/portuguese_pt.lang +++ b/Languages/portuguese_pt.lang @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-15 23:05-0400\n" +"POT-Creation-Date: 2009-07-16 03:53-0400\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -138,6 +138,9 @@ msgstr "Relógio" msgid "Close" msgstr "Fechar" +msgid "Code Download" +msgstr "" + msgid "Console" msgstr "" @@ -276,6 +279,9 @@ msgstr "Descarregar imagem da Caixa?" msgid "Download Discart image?" msgstr "" +msgid "Download Now" +msgstr "" + msgid "Download finished" msgstr "Download Terminado" diff --git a/Languages/russian.lang b/Languages/russian.lang index 7fb478cd..68a88236 100644 --- a/Languages/russian.lang +++ b/Languages/russian.lang @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-15 23:05-0400\n" +"POT-Creation-Date: 2009-07-16 03:53-0400\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -138,6 +138,9 @@ msgstr "Часы" msgid "Close" msgstr "Закрыть" +msgid "Code Download" +msgstr "" + msgid "Console" msgstr "" @@ -276,6 +279,9 @@ msgstr "Скачать обложку диска?" msgid "Download Discart image?" msgstr "" +msgid "Download Now" +msgstr "" + msgid "Download finished" msgstr "Скачивание завершено" diff --git a/Languages/schinese.lang b/Languages/schinese.lang index 458fc19b..7b6546c2 100644 --- a/Languages/schinese.lang +++ b/Languages/schinese.lang @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-15 23:05-0400\n" +"POT-Creation-Date: 2009-07-16 03:53-0400\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -138,6 +138,9 @@ msgstr "时钟" msgid "Close" msgstr "" +msgid "Code Download" +msgstr "" + msgid "Console" msgstr "" @@ -276,6 +279,9 @@ msgstr "下载封面图片?" msgid "Download Discart image?" msgstr "" +msgid "Download Now" +msgstr "" + msgid "Download finished" msgstr "下载完成" diff --git a/Languages/spanish.lang b/Languages/spanish.lang index 440d1475..55e686ea 100644 --- a/Languages/spanish.lang +++ b/Languages/spanish.lang @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-15 23:05-0400\n" +"POT-Creation-Date: 2009-07-16 03:53-0400\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -138,6 +138,9 @@ msgstr "Reloj" msgid "Close" msgstr "Cerrar" +msgid "Code Download" +msgstr "" + msgid "Console" msgstr "Consola" @@ -276,6 +279,9 @@ msgstr "¿Descargar Imágenes?" msgid "Download Discart image?" msgstr "" +msgid "Download Now" +msgstr "" + msgid "Download finished" msgstr "Descarga completa" diff --git a/Languages/swedish.lang b/Languages/swedish.lang index 0f11c41d..c72e1a3f 100644 --- a/Languages/swedish.lang +++ b/Languages/swedish.lang @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-15 23:05-0400\n" +"POT-Creation-Date: 2009-07-16 03:53-0400\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -138,6 +138,9 @@ msgstr "Klocka" msgid "Close" msgstr "" +msgid "Code Download" +msgstr "" + msgid "Console" msgstr "" @@ -276,6 +279,9 @@ msgstr "Ladda ner omslagsbild?" msgid "Download Discart image?" msgstr "" +msgid "Download Now" +msgstr "" + msgid "Download finished" msgstr "Nedladdning klar" diff --git a/Languages/tchinese.lang b/Languages/tchinese.lang index 12466cf2..6cc66e05 100644 --- a/Languages/tchinese.lang +++ b/Languages/tchinese.lang @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-15 23:05-0400\n" +"POT-Creation-Date: 2009-07-16 03:53-0400\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -138,6 +138,9 @@ msgstr "時鐘" msgid "Close" msgstr "關閉" +msgid "Code Download" +msgstr "" + msgid "Console" msgstr "" @@ -276,6 +279,9 @@ msgstr "下載外盒封面圖片?" msgid "Download Discart image?" msgstr "" +msgid "Download Now" +msgstr "" + msgid "Download finished" msgstr "下載完成" diff --git a/Languages/turkish.lang b/Languages/turkish.lang index 7c75c876..7ebbf28d 100644 --- a/Languages/turkish.lang +++ b/Languages/turkish.lang @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-15 23:05-0400\n" +"POT-Creation-Date: 2009-07-16 03:53-0400\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -138,6 +138,9 @@ msgstr "Saat" msgid "Close" msgstr "" +msgid "Code Download" +msgstr "" + msgid "Console" msgstr "" @@ -276,6 +279,9 @@ msgstr "Kutu resmini indirmek ister misiniz?" msgid "Download Discart image?" msgstr "" +msgid "Download Now" +msgstr "" + msgid "Download finished" msgstr "Indirme tamamlandi" diff --git a/gui.pnps b/gui.pnps index 26ee1dec..42b4aa4c 100644 --- a/gui.pnps +++ b/gui.pnps @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/source/cheats/cheatmenu.cpp b/source/cheats/cheatmenu.cpp index 6349b872..8ac7b3de 100644 --- a/source/cheats/cheatmenu.cpp +++ b/source/cheats/cheatmenu.cpp @@ -62,12 +62,21 @@ int CheatMenu(const char * gameID) GCTCheats c; int check = c.openTxtfile(txtfilename); - + + int download =0; + //char tmp[10]; + + switch(check) { case -1: WindowPrompt(tr("Error"),tr("Cheatfile is blank"),tr("OK")); break; - case 0: WindowPrompt(tr("Error"),tr("No Cheatfile found"),tr("OK")); + case 0: download = WindowPrompt(tr("Error"),tr("No Cheatfile found"),tr("OK"),tr("Download Now")); + //snprintf(tmp, sizeof(tmp), "%i",download); + + //WindowPrompt(0,tmp,tr("OK"),tr("Download Now")); + if (download==0) + download = CodeDownload(gameID); break; case 1: int cntcheats = c.getCnt(); diff --git a/source/prompts/PromptWindows.cpp b/source/prompts/PromptWindows.cpp index 563ce9f9..3caed564 100644 --- a/source/prompts/PromptWindows.cpp +++ b/source/prompts/PromptWindows.cpp @@ -2368,7 +2368,8 @@ int ProgressUpdateWindow() //make the URL to get XML based on our games char XMLurl[2032]; char filename[10]; - strncat (XMLurl, "http://wiitdb.com/wiitdb.zip?ID=", 32); + //strncat (XMLurl, "http://wiitdb.com/wiitdb.zip?ID=", 32); + strcpy (XMLurl, "http://wiitdb.com/wiitdb.zip?ID="); unsigned int i; for (i = 0; i < gameCnt ; i++) { @@ -2508,6 +2509,9 @@ int ProgressUpdateWindow() return 1; } + + + #else ///////////////////this is only used if the dol is being compiled for a full channel int ProgressUpdateWindow() { @@ -2624,7 +2628,8 @@ int ProgressUpdateWindow() //make the URL to get XML based on our games char XMLurl[2032]; char filename[10]; - strncat (XMLurl, "http://wiitdb.com/wiitdb.zip?ID=", 32); + //strncat (XMLurl, "http://wiitdb.com/wiitdb.zip?ID=", 32); + strcpy (XMLurl, "http://wiitdb.com/wiitdb.zip?ID="); unsigned int i; for (i = 0; i < gameCnt ; i++) { @@ -2804,6 +2809,149 @@ int ProgressUpdateWindow() } #endif +int CodeDownload(const char *id) +{ + int ret = 0; + + GuiWindow promptWindow(472,320); + promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + promptWindow.SetPosition(0, -10); + + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume); + GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, 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);} + + + + char title[50]; + sprintf(title, "%s", tr("Code Download")); + GuiText titleTxt(title, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + titleTxt.SetPosition(0,50); + char msg[50]; + sprintf(msg, "%s", tr("Initializing Network")); + GuiText msgTxt(msg, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + msgTxt.SetPosition(0,140); + char msg2[50] = " "; + GuiText msg2Txt(msg2, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + msg2Txt.SetPosition(0, 50); + + GuiText btn1Txt(tr("Cancel"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + GuiImage btn1Img(&btnOutline); + if (Settings.wsprompt == yes){ + btn1Txt.SetWidescreen(CFG.widescreen); + btn1Img.SetWidescreen(CFG.widescreen);} + GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -40, &trigA, &btnSoundOver, &btnClick,1); + btn1.SetLabel(&btn1Txt); + btn1.SetState(STATE_SELECTED); + + promptWindow.Append(&dialogBoxImg); + promptWindow.Append(&titleTxt); + promptWindow.Append(&msgTxt); + promptWindow.Append(&msg2Txt); + promptWindow.Append(&btn1); + + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); + + HaltGui(); + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&promptWindow); + mainWindow->ChangeFocus(&promptWindow); + ResumeGui(); + + struct stat st; + if(stat(Settings.TxtCheatcodespath, &st) != 0) { + if(subfoldercreate(Settings.TxtCheatcodespath) != 1) { + WindowPrompt(tr("Error !"),tr("Can't create directory"),tr("OK")); + ret = -1; + goto exit; + } + } + + while (!IsNetworkInit()) { + + VIDEO_WaitVSync(); + + Initialize_Network(); + + if (IsNetworkInit()) { + msgTxt.SetText(GetNetworkIP()); + } else { + msgTxt.SetText(tr("Could not initialize network!")); + } + if(btn1.GetState() == STATE_CLICKED) { + ret = -1; + btn1.ResetState(); + goto exit; + } + } + + if(IsNetworkInit() && ret >= 0) { + FILE * pfile; + + char txtpath[150]; + snprintf(txtpath, sizeof(txtpath), "%s%s.txt", Settings.TxtCheatcodespath,id); + + char codeurl[150]; + snprintf(codeurl, sizeof(codeurl), "http://usbgecko.com/codes/codes/R/%s.txt",id); + + struct block file = downloadfile(codeurl); + + if (file.size == 333) + { + strcat(codeurl, " is not on the server."); + + WindowPrompt(tr("Error"),codeurl,"Ok"); + ret =-1; + goto exit; + } + + if(file.data != NULL){ + pfile = fopen(txtpath, "wb"); + fwrite(file.data,1,file.size,pfile); + fclose(pfile); + free(file.data); + ret = 1; + strcat(txtpath, " has been Saved. The text has not been verified. Some of the code may not work right with each other. If you experience trouble, open the text in a real text editor for more information."); + + WindowPrompt(0,txtpath,"Ok"); + } + else + { + strcat(codeurl, " could not be downloaded."); + + WindowPrompt(tr("Error"),codeurl,"Ok"); + ret =-1; + } + + + CloseConnection(); + } +exit: + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + while(promptWindow.GetEffect() > 0) usleep(50); + + HaltGui(); + mainWindow->Remove(&promptWindow); + mainWindow->SetState(STATE_DEFAULT); + ResumeGui(); + + return ret; +} + char * GetMissingFiles() { return (char *) missingFiles; diff --git a/source/prompts/PromptWindows.h b/source/prompts/PromptWindows.h index 256b280d..33663049 100644 --- a/source/prompts/PromptWindows.h +++ b/source/prompts/PromptWindows.h @@ -26,5 +26,6 @@ int ProgressDownloadWindow(int choice2); int ProgressUpdateWindow(); char * GetMissingFiles(); int WindowScreensaver(); +int CodeDownload(const char *id); #endif