diff --git a/Makefile b/Makefile index e366e261..bca0acc0 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ include $(DEVKITPPC)/wii_rules #--------------------------------------------------------------------------------- TARGET := boot BUILD := build -SOURCES := source source/libwiigui source/images source/fonts source/sounds source/libwbfs +SOURCES := source source/libwiigui source/images source/fonts source/sounds source/libwbfs source/unzip source/mxml INCLUDES := source SVNDEV := -D'SVN_REV="$(shell svnversion -n ..)"' @@ -32,7 +32,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x80a00 #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project #--------------------------------------------------------------------------------- -LIBS := -lfat -lpngu -lpng -lmetaphrasis -lm -lz -lwiiuse -lmad -lbte -lasnd -logc -ltremor -lfreetype +LIBS := -lfat -lpngu -lpng -lmetaphrasis -lm -lz -lwiiuse -lmad -lbte -lasnd -logc -ltremor -lfreetype -lmxml #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing # include and lib diff --git a/gui.pnproj b/gui.pnproj index 4bb8b13c..c3ed6c5c 100644 --- a/gui.pnproj +++ b/gui.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/gui.pnps b/gui.pnps index 4d76a3fe..4988660c 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/Settings.cpp b/source/Settings.cpp index 5ccb6eca..1c2e6e04 100644 --- a/source/Settings.cpp +++ b/source/Settings.cpp @@ -229,6 +229,58 @@ int MenuSettings() GuiCustomOptionBrowser optionBrowser2(396, 280, &options2, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, 0, 150); optionBrowser2.SetPosition(0, 90); optionBrowser2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + + //////////////////////// + customOptionList options4(8); + options4.SetName(0,"%s", LANGUAGE.VideoMode); + options4.SetName(1,"%s", LANGUAGE.VIDTVPatch); + options4.SetName(2,"%s", LANGUAGE.Language); + options4.SetName(3, "Ocarina"); + options4.SetName(4, "IOS"); + options4.SetName(5,"%s", LANGUAGE.Parentalcontrol); + options4.SetName(6,"%s", "Error 002 fix"); + options4.SetName(7,"%s", LANGUAGE.Defaultgamesettings); + + GuiButton settingsbackgroundbtn(settingsbackground.GetWidth(), settingsbackground.GetHeight()); + settingsbackgroundbtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); + settingsbackgroundbtn.SetPosition(0, 0); + settingsbackgroundbtn.SetImage(&settingsbackground); + + GuiText saveBtnTxt(LANGUAGE.Save, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + saveBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); + GuiImage saveBtnImg(&btnOutline); + if (Settings.wsprompt == yes){ + saveBtnTxt.SetWidescreen(CFG.widescreen); + saveBtnImg.SetWidescreen(CFG.widescreen);} + GuiButton saveBtn(&saveBtnImg,&saveBtnImg, 2, 3, -180, 400, &trigA, &btnSoundOver, &btnClick,1); + saveBtn.SetScale(0.9); + saveBtn.SetLabel(&saveBtnTxt); + + GuiText cancelBtnTxt(LANGUAGE.Back, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + cancelBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); + GuiImage cancelBtnImg(&btnOutline); + if (Settings.wsprompt == yes){ + cancelBtnTxt.SetWidescreen(CFG.widescreen); + cancelBtnImg.SetWidescreen(CFG.widescreen);} + GuiButton cancelBtn(&cancelBtnImg,&cancelBtnImg, 2, 3, 180, 400, &trigA, &btnSoundOver, &btnClick,1); + cancelBtn.SetScale(0.9); + cancelBtn.SetLabel(&cancelBtnTxt); + cancelBtn.SetTrigger(&trigB); + + GuiText deleteBtnTxt(LANGUAGE.Uninstall, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + deleteBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); + GuiImage deleteBtnImg(&btnOutline); + if (Settings.wsprompt == yes){ + deleteBtnTxt.SetWidescreen(CFG.widescreen); + deleteBtnImg.SetWidescreen(CFG.widescreen);} + GuiButton deleteBtn(&deleteBtnImg,&deleteBtnImg, 2, 3, 0, 400, &trigA, &btnSoundOver, &btnClick,1); + deleteBtn.SetScale(0.9); + deleteBtn.SetLabel(&deleteBtnTxt); + + GuiCustomOptionBrowser optionBrowser4(396, 280, &options4, CFG.theme_path, "bg_options_gamesettings.png", bg_options_settings_png, 0, 200); + optionBrowser4.SetPosition(0, 90); + optionBrowser4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + ///////////////////////////////////// GuiWindow w(screenwidth, screenheight); @@ -274,7 +326,7 @@ int MenuSettings() MainButton4Txt.SetText(MainButtonText); mainWindow->RemoveAll(); - mainWindow->Append(&w); + //mainWindow->Append(&w); w.RemoveAll(); w.Append(&settingsbackground); w.Append(&PageIndicatorBtn1); @@ -288,6 +340,7 @@ int MenuSettings() w.Append(&MainButton2); w.Append(&MainButton3); w.Append(&MainButton4); + mainWindow->Append(&w); PageIndicatorBtn1.SetAlpha(255); PageIndicatorBtn2.SetAlpha(50); @@ -1586,6 +1639,1397 @@ int MenuSettings() *********************************************************************************/ int GameSettings(struct discHdr * header) { + + int menu = MENU_NONE; + int ret; + int choice = 0; + bool exit = false; + + enum { + FADE, + LEFT, + RIGHT + }; + + int slidedirection = FADE; + + 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); + GuiSound btnClick1(button_click_pcm, button_click_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), "%ssettings_background.png", CFG.theme_path); + GuiImageData settingsbg(imgPath, settings_background_png); + + snprintf(imgPath, sizeof(imgPath), "%ssettings_title.png", CFG.theme_path); + GuiImageData MainButtonImgData(imgPath, settings_title_png); + + snprintf(imgPath, sizeof(imgPath), "%ssettings_title_over.png", CFG.theme_path); + GuiImageData MainButtonImgOverData(imgPath, settings_title_over_png); + + snprintf(imgPath, sizeof(imgPath), "%spageindicator.png", CFG.theme_path); + GuiImageData PageindicatorImgData(imgPath, pageindicator_png); + + snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_left.png", CFG.theme_path); + GuiImageData arrow_left(imgPath, startgame_arrow_left_png); + + snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", CFG.theme_path); + GuiImageData arrow_right(imgPath, startgame_arrow_right_png); + + snprintf(imgPath, sizeof(imgPath), "%scredits_button.png", CFG.theme_path); + GuiImageData creditsImgData(imgPath, credits_button_png); + + snprintf(imgPath, sizeof(imgPath), "%scredits_button_over.png", CFG.theme_path); + GuiImageData creditsOver(imgPath, credits_button_over_png); + + GuiImage creditsImg(&creditsImgData); + GuiImage creditsImgOver(&creditsOver); + + GuiTrigger trigA; + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + GuiTrigger trigHome; + trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); + GuiTrigger trigB; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); + GuiTrigger trigL; + trigL.SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT); + GuiTrigger trigR; + trigR.SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT); + GuiTrigger trigMinus; + trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0); + GuiTrigger trigPlus; + trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0); + + GuiText titleTxt(LANGUAGE.settings, 28, (GXColor){0, 0, 0, 255}); + titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + titleTxt.SetPosition(0,40); + + GuiImage settingsbackground(&settingsbg); + + GuiText backBtnTxt(LANGUAGE.Back , 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); + backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); + GuiImage backBtnImg(&btnOutline); + if (Settings.wsprompt == yes){ + backBtnTxt.SetWidescreen(CFG.widescreen); + backBtnImg.SetWidescreen(CFG.widescreen); + } + GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -180, 400, &trigA, &btnSoundOver, &btnClick,1); + backBtn.SetLabel(&backBtnTxt); + backBtn.SetTrigger(&trigB); + + GuiButton homo(1,1); + homo.SetTrigger(&trigHome); + + GuiImage PageindicatorImg1(&PageindicatorImgData); + GuiText PageindicatorTxt1("1", 22, (GXColor){0, 0, 0, 255}); + GuiButton PageIndicatorBtn1(PageindicatorImg1.GetWidth(), PageindicatorImg1.GetHeight()); + PageIndicatorBtn1.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + PageIndicatorBtn1.SetPosition(200, 400); + PageIndicatorBtn1.SetImage(&PageindicatorImg1); + PageIndicatorBtn1.SetLabel(&PageindicatorTxt1); + PageIndicatorBtn1.SetSoundOver(&btnSoundOver); + PageIndicatorBtn1.SetSoundClick(&btnClick1); + PageIndicatorBtn1.SetTrigger(&trigA); + PageIndicatorBtn1.SetEffectGrow(); + + GuiImage PageindicatorImg2(&PageindicatorImgData); + GuiText PageindicatorTxt2("2", 22, (GXColor){0, 0, 0, 255}); + GuiButton PageIndicatorBtn2(PageindicatorImg2.GetWidth(), PageindicatorImg2.GetHeight()); + PageIndicatorBtn2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + PageIndicatorBtn2.SetPosition(235, 400); + PageIndicatorBtn2.SetImage(&PageindicatorImg2); + PageIndicatorBtn2.SetLabel(&PageindicatorTxt2); + PageIndicatorBtn2.SetSoundOver(&btnSoundOver); + PageIndicatorBtn2.SetSoundClick(&btnClick1); + PageIndicatorBtn2.SetTrigger(&trigA); + PageIndicatorBtn2.SetEffectGrow(); + + GuiImage GoLeftImg(&arrow_left); + GuiButton GoLeftBtn(GoLeftImg.GetWidth(), GoLeftImg.GetHeight()); + GoLeftBtn.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + GoLeftBtn.SetPosition(25, -25); + GoLeftBtn.SetImage(&GoLeftImg); + GoLeftBtn.SetSoundOver(&btnSoundOver); + GoLeftBtn.SetSoundClick(&btnClick); + GoLeftBtn.SetEffectGrow(); + GoLeftBtn.SetTrigger(&trigA); + GoLeftBtn.SetTrigger(&trigL); + GoLeftBtn.SetTrigger(&trigMinus); + + GuiImage GoRightImg(&arrow_right); + GuiButton GoRightBtn(GoRightImg.GetWidth(), GoRightImg.GetHeight()); + GoRightBtn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE); + GoRightBtn.SetPosition(-25, -25); + GoRightBtn.SetImage(&GoRightImg); + GoRightBtn.SetSoundOver(&btnSoundOver); + GoRightBtn.SetSoundClick(&btnClick); + GoRightBtn.SetEffectGrow(); + GoRightBtn.SetTrigger(&trigA); + GoRightBtn.SetTrigger(&trigR); + GoRightBtn.SetTrigger(&trigPlus); + + char MainButtonText[50]; + snprintf(MainButtonText, sizeof(MainButtonText), "%s", " "); + + GuiImage MainButton1Img(&MainButtonImgData); + GuiImage MainButton1ImgOver(&MainButtonImgOverData); + GuiText MainButton1Txt(MainButtonText, 22, (GXColor){0, 0, 0, 255}); + MainButton1Txt.SetMaxWidth(MainButton1Img.GetWidth()); + GuiButton MainButton1(MainButton1Img.GetWidth(), MainButton1Img.GetHeight()); + MainButton1.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + MainButton1.SetPosition(0, 90); + MainButton1.SetImage(&MainButton1Img); + MainButton1.SetImageOver(&MainButton1ImgOver); + MainButton1.SetLabel(&MainButton1Txt); + MainButton1.SetSoundOver(&btnSoundOver); + MainButton1.SetSoundClick(&btnClick1); + MainButton1.SetEffectGrow(); + MainButton1.SetTrigger(&trigA); + + GuiImage MainButton2Img(&MainButtonImgData); + GuiImage MainButton2ImgOver(&MainButtonImgOverData); + GuiText MainButton2Txt(MainButtonText, 22, (GXColor){0, 0, 0, 255}); + MainButton2Txt.SetMaxWidth(MainButton2Img.GetWidth()); + GuiButton MainButton2(MainButton2Img.GetWidth(), MainButton2Img.GetHeight()); + MainButton2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + MainButton2.SetPosition(0, 160); + MainButton2.SetImage(&MainButton2Img); + MainButton2.SetImageOver(&MainButton2ImgOver); + MainButton2.SetLabel(&MainButton2Txt); + MainButton2.SetSoundOver(&btnSoundOver); + MainButton2.SetSoundClick(&btnClick1); + MainButton2.SetEffectGrow(); + MainButton2.SetTrigger(&trigA); + + GuiImage MainButton3Img(&MainButtonImgData); + GuiImage MainButton3ImgOver(&MainButtonImgOverData); + GuiText MainButton3Txt(MainButtonText, 22, (GXColor){0, 0, 0, 255}); + MainButton3Txt.SetMaxWidth(MainButton3Img.GetWidth()); + GuiButton MainButton3(MainButton3Img.GetWidth(), MainButton3Img.GetHeight()); + MainButton3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + MainButton3.SetPosition(0, 230); + MainButton3.SetImage(&MainButton3Img); + MainButton3.SetImageOver(&MainButton3ImgOver); + MainButton3.SetLabel(&MainButton3Txt); + MainButton3.SetSoundOver(&btnSoundOver); + MainButton3.SetSoundClick(&btnClick1); + MainButton3.SetEffectGrow(); + MainButton3.SetTrigger(&trigA); + + GuiImage MainButton4Img(&MainButtonImgData); + GuiImage MainButton4ImgOver(&MainButtonImgOverData); + GuiText MainButton4Txt(MainButtonText, 22, (GXColor){0, 0, 0, 255}); + MainButton4Txt.SetMaxWidth(MainButton4Img.GetWidth()); + GuiButton MainButton4(MainButton4Img.GetWidth(), MainButton4Img.GetHeight()); + MainButton4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + MainButton4.SetPosition(0, 300); + MainButton4.SetImage(&MainButton4Img); + MainButton4.SetImageOver(&MainButton4ImgOver); + MainButton4.SetLabel(&MainButton4Txt); + MainButton4.SetSoundOver(&btnSoundOver); + MainButton4.SetSoundClick(&btnClick1); + MainButton4.SetEffectGrow(); + MainButton4.SetTrigger(&trigA); + + customOptionList options2(9); + GuiCustomOptionBrowser optionBrowser2(396, 280, &options2, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, 0, 150); + optionBrowser2.SetPosition(0, 90); + optionBrowser2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + + GuiWindow w(screenwidth, screenheight); + + int pageToDisplay = 1; + while ( pageToDisplay > 0) //set pageToDisplay to 0 to quit + { + VIDEO_WaitVSync (); + + menu = MENU_NONE; + + if ( pageToDisplay == 1) + { + /** Standard procedure made in all pages **/ + MainButton1.StopEffect(); + MainButton2.StopEffect(); + MainButton3.StopEffect(); + MainButton4.StopEffect(); + + if(slidedirection == RIGHT) { + MainButton1.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 35); + MainButton2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 35); + MainButton3.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 35); + MainButton4.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 35); + while (MainButton1.GetEffect()>0) usleep(50); + } + else if(slidedirection == LEFT) { + MainButton1.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35); + MainButton2.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35); + MainButton3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35); + MainButton4.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35); + while (MainButton1.GetEffect()>0) usleep(50); + } + + HaltGui(); + + snprintf(MainButtonText, sizeof(MainButtonText), "%s", LANGUAGE.GUISettings); + MainButton1Txt.SetText(MainButtonText); + snprintf(MainButtonText, sizeof(MainButtonText), "%s", LANGUAGE.Gameload); + MainButton2Txt.SetText(MainButtonText); + snprintf(MainButtonText, sizeof(MainButtonText), "%s", LANGUAGE.Parentalcontrol); + MainButton3Txt.SetText(MainButtonText); + snprintf(MainButtonText, sizeof(MainButtonText), "%s", LANGUAGE.Sound); + MainButton4Txt.SetText(MainButtonText); + + mainWindow->RemoveAll(); + mainWindow->Append(&w); + w.RemoveAll(); + w.Append(&settingsbackground); + w.Append(&PageIndicatorBtn1); + w.Append(&PageIndicatorBtn2); + w.Append(&titleTxt); + w.Append(&backBtn); + w.Append(&homo); + w.Append(&GoRightBtn); + w.Append(&GoLeftBtn); + w.Append(&MainButton1); + w.Append(&MainButton2); + w.Append(&MainButton3); + w.Append(&MainButton4); + + PageIndicatorBtn1.SetAlpha(255); + PageIndicatorBtn2.SetAlpha(50); + + /** Creditsbutton change **/ + MainButton4.SetImage(&MainButton4Img); + MainButton4.SetImageOver(&MainButton4ImgOver); + + /** Disable ability to click through MainButtons */ + optionBrowser2.SetClickable(false); + + MainButton1.StopEffect(); + MainButton2.StopEffect(); + MainButton3.StopEffect(); + MainButton4.StopEffect(); + + MainButton1.SetEffectGrow(); + MainButton2.SetEffectGrow(); + MainButton3.SetEffectGrow(); + MainButton4.SetEffectGrow(); + + if(slidedirection == FADE) { + MainButton1.SetEffect(EFFECT_FADE, 20); + MainButton2.SetEffect(EFFECT_FADE, 20); + MainButton3.SetEffect(EFFECT_FADE, 20); + MainButton4.SetEffect(EFFECT_FADE, 20); + } + else if(slidedirection == LEFT) { + MainButton1.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 35); + MainButton2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 35); + MainButton3.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 35); + MainButton4.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 35); + } + else if(slidedirection == RIGHT) { + MainButton1.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35); + MainButton2.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35); + MainButton3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35); + MainButton4.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35); + } + + mainWindow->Append(&w); + + ResumeGui(); + + while(MainButton1.GetEffect() > 0) usleep(50); + + } + else if ( pageToDisplay == 2 ) + { + /** Standard procedure made in all pages **/ + MainButton1.StopEffect(); + MainButton2.StopEffect(); + MainButton3.StopEffect(); + MainButton4.StopEffect(); + + if(slidedirection == RIGHT) { + MainButton1.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 35); + MainButton2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 35); + MainButton3.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 35); + MainButton4.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 35); + while (MainButton1.GetEffect()>0) usleep(50); + } + else if(slidedirection == LEFT) { + MainButton1.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35); + MainButton2.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35); + MainButton3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35); + MainButton4.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 35); + while (MainButton1.GetEffect()>0) usleep(50); + } + + HaltGui(); + + snprintf(MainButtonText, sizeof(MainButtonText), "%s", LANGUAGE.Custompaths); + MainButton1Txt.SetText(MainButtonText); + snprintf(MainButtonText, sizeof(MainButtonText), "%s", LANGUAGE.Update); + MainButton2Txt.SetText(MainButtonText); + snprintf(MainButtonText, sizeof(MainButtonText), "%s", LANGUAGE.Defaultsettings); + MainButton3Txt.SetText(MainButtonText); + snprintf(MainButtonText, sizeof(MainButtonText), "%s", LANGUAGE.Credits); + MainButton4Txt.SetText(MainButtonText); + + mainWindow->RemoveAll(); + mainWindow->Append(&w); + w.RemoveAll(); + w.Append(&settingsbackground); + w.Append(&PageIndicatorBtn1); + w.Append(&PageIndicatorBtn2); + w.Append(&titleTxt); + w.Append(&backBtn); + w.Append(&homo); + w.Append(&GoRightBtn); + w.Append(&GoLeftBtn); + w.Append(&MainButton1); + w.Append(&MainButton2); + w.Append(&MainButton3); + w.Append(&MainButton4); + + PageIndicatorBtn1.SetAlpha(50); + PageIndicatorBtn2.SetAlpha(255); + + /** Creditsbutton change **/ + MainButton4.SetImage(&creditsImg); + MainButton4.SetImageOver(&creditsImgOver); + + /** Disable ability to click through MainButtons */ + optionBrowser2.SetClickable(false); + + MainButton1.StopEffect(); + MainButton2.StopEffect(); + MainButton3.StopEffect(); + MainButton4.StopEffect(); + + MainButton1.SetEffectGrow(); + MainButton2.SetEffectGrow(); + MainButton3.SetEffectGrow(); + MainButton4.SetEffectGrow(); + + if(slidedirection == FADE) { + MainButton1.SetEffect(EFFECT_FADE, 20); + MainButton2.SetEffect(EFFECT_FADE, 20); + MainButton3.SetEffect(EFFECT_FADE, 20); + MainButton4.SetEffect(EFFECT_FADE, 20); + } + else if(slidedirection == LEFT) { + MainButton1.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 35); + MainButton2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 35); + MainButton3.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 35); + MainButton4.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 35); + } + else if(slidedirection == RIGHT) { + MainButton1.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35); + MainButton2.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35); + MainButton3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35); + MainButton4.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 35); + } + + mainWindow->Append(&w); + + ResumeGui(); + + while(MainButton1.GetEffect() > 0) usleep(50); + + } + + while(menu == MENU_NONE) + { + VIDEO_WaitVSync (); + + if ( pageToDisplay == 1 ) + { + if(MainButton1.GetState() == STATE_CLICKED) { + MainButton1.SetEffect(EFFECT_FADE, -20); + MainButton2.SetEffect(EFFECT_FADE, -20); + MainButton3.SetEffect(EFFECT_FADE, -20); + MainButton4.SetEffect(EFFECT_FADE, -20); + while(MainButton1.GetEffect() > 0) usleep(50); + HaltGui(); + w.Remove(&PageIndicatorBtn1); + w.Remove(&PageIndicatorBtn2); + w.Remove(&GoRightBtn); + w.Remove(&GoLeftBtn); + w.Remove(&MainButton1); + w.Remove(&MainButton2); + w.Remove(&MainButton3); + w.Remove(&MainButton4); + titleTxt.SetText(LANGUAGE.GUISettings); + exit = false; + options2.SetName(0, "%s",LANGUAGE.AppLanguage); + options2.SetName(1, "%s",LANGUAGE.Display); + options2.SetName(2, "%s",LANGUAGE.Clock); + options2.SetName(3, "%s",LANGUAGE.Tooltips); + options2.SetName(4, "%s",LANGUAGE.FlipX); + options2.SetName(5, "%s",LANGUAGE.PromptsButtons); + options2.SetName(6, "%s",LANGUAGE.keyboard); + options2.SetName(7, "%s",LANGUAGE.Wiilight); + options2.SetName(8, "%s", LANGUAGE.Rumble); + for(int i = 0; i < 9; i++) options2.SetValue(i, NULL); + w.Append(&optionBrowser2); + optionBrowser2.SetClickable(true); + ResumeGui(); + + VIDEO_WaitVSync (); + optionBrowser2.SetEffect(EFFECT_FADE, 20); + while(optionBrowser2.GetEffect() > 0) usleep(50); + + int returnhere = 1; + char * languagefile; + languagefile = strrchr(Settings.language_path, '/')+1; + + while(!exit) + { + VIDEO_WaitVSync (); + + returnhere = 1; + + if(Settings.sinfo >= settings_sinfo_max) + Settings.sinfo = 0; + if(Settings.hddinfo >= settings_clock_max) + Settings.hddinfo = 0; //CLOCK + if (Settings.tooltips >= settings_tooltips_max) + Settings.tooltips = 0; + if ( Settings.xflip >= settings_xflip_max) + Settings.xflip = 0; + if ( Settings.wsprompt > 1 ) + Settings.wsprompt = 0; + if ( Settings.keyset >= settings_keyset_max) + Settings.keyset = 0; + if ( Settings.wiilight > 2 ) + Settings.wiilight = 0; + if(Settings.rumble >= settings_rumble_max) + Settings.rumble = 0; //RUMBLE + + if(!strcmp("notset", Settings.language_path)) + options2.SetValue(0, "%s", LANGUAGE.Default); + else + options2.SetValue(0, "%s", languagefile); + + if (Settings.sinfo == GameID) options2.SetValue(1,"%s",LANGUAGE.GameID); + else if (Settings.sinfo == GameRegion) options2.SetValue(1,"%s",LANGUAGE.GameRegion); + else if (Settings.sinfo == Both) options2.SetValue(1,"%s",LANGUAGE.Both); + else if (Settings.sinfo == Neither) options2.SetValue(1,"%s",LANGUAGE.Neither); + + if (Settings.hddinfo == hr12) options2.SetValue(2,"12 %s",LANGUAGE.hour); + else if (Settings.hddinfo == hr24) options2.SetValue(2,"24 %s",LANGUAGE.hour); + else if (Settings.hddinfo == Off) options2.SetValue(2,"%s",LANGUAGE.OFF); + + if (Settings.tooltips == TooltipsOn) options2.SetValue(3,"%s",LANGUAGE.ON); + else if (Settings.tooltips == TooltipsOff) options2.SetValue(3,"%s",LANGUAGE.OFF); + + if (Settings.xflip == no) options2.SetValue(4,"%s/%s",LANGUAGE.Right,LANGUAGE.Next); + else if (Settings.xflip == yes) options2.SetValue(4,"%s/%s",LANGUAGE.Left,LANGUAGE.Prev); + else if (Settings.xflip == sysmenu) options2.SetValue(4,"%s", LANGUAGE.LikeSysMenu); + else if (Settings.xflip == wtf) options2.SetValue(4,"%s/%s",LANGUAGE.Right,LANGUAGE.Prev); + else if (Settings.xflip == disk3d) options2.SetValue(4,"DiskFlip"); + + if (Settings.wsprompt == no) options2.SetValue(5,"%s",LANGUAGE.Normal); + else if (Settings.wsprompt == yes) options2.SetValue(5,"%s",LANGUAGE.WidescreenFix); + + if (Settings.keyset == us) options2.SetValue(6,"QWERTY"); + else if (Settings.keyset == dvorak) options2.SetValue(6,"DVORAK"); + else if (Settings.keyset == euro) options2.SetValue(6,"QWERTZ"); + else if (Settings.keyset == azerty) options2.SetValue(6,"AZERTY"); + + if (Settings.wiilight == 0) options2.SetValue(7,"%s",LANGUAGE.OFF); + else if (Settings.wiilight == 1) options2.SetValue(7,"%s",LANGUAGE.ON); + else if (Settings.wiilight == 2) options2.SetValue(7,"%s",LANGUAGE.OnlyInstall); + + if (Settings.rumble == RumbleOn) options2.SetValue(8,"%s",LANGUAGE.ON); + else if (Settings.rumble == RumbleOff) options2.SetValue(8,"%s",LANGUAGE.OFF); + + if(backBtn.GetState() == STATE_CLICKED) + { + backBtn.ResetState(); + exit = true; + break; + } + + if(shutdown == 1) + Sys_Shutdown(); + else if(reset == 1) + Sys_Reboot(); + + else if(menu == MENU_DISCLIST) { + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + WindowCredits(); + w.Append(&optionBrowser2); + w.Append(&backBtn); + } + else if(homo.GetState() == STATE_CLICKED) + { + cfg_save_global(); + optionBrowser2.SetState(STATE_DISABLED); + s32 thetimeofbg = bgMusic->GetPlayTime(); + bgMusic->Stop(); + choice = WindowExitPrompt(LANGUAGE.ExitUSBISOLoader,0, LANGUAGE.BacktoLoader,LANGUAGE.WiiMenu,LANGUAGE.Back,0); + if(!strcmp("", Settings.oggload_path) || !strcmp("notset", Settings.ogg_path)) + { + bgMusic->Play(); + } else { + bgMusic->PlayOggFile(Settings.ogg_path); + } + bgMusic->SetPlayTime(thetimeofbg); + SetVolumeOgg(255*(Settings.volume/100.0)); + if(choice == 3) { + Sys_LoadMenu(); // Back to System Menu + } else if (choice == 2) { + Sys_BackToLoader(); + } else { + homo.ResetState(); + } + optionBrowser2.SetState(STATE_DEFAULT); + } + + ret = optionBrowser2.GetClickedOption(); + + switch (ret) + { + case 0: + if(isSdInserted()) { + if ( Settings.godmode == 1) + { + w.SetEffect(EFFECT_FADE, -20); + while(w.GetEffect()>0) usleep(50); + mainWindow->Remove(&w); + while(returnhere == 1) + returnhere = MenuLanguageSelect(); + if(returnhere == 2) { + menu = MENU_SETTINGS; + pageToDisplay = 0; + exit = true; + mainWindow->Append(&w); + break; + } else { + HaltGui(); + mainWindow->Append(&w); + w.SetEffect(EFFECT_FADE, 20); + ResumeGui(); + while(w.GetEffect()>0) usleep(50); + } + } else { + WindowPrompt(LANGUAGE.Langchange,LANGUAGE.Consoleshouldbeunlockedtomodifyit,LANGUAGE.ok,0,0,0); + } + } else { + WindowPrompt(LANGUAGE.NoSDcardinserted, LANGUAGE.InsertaSDCardtousethatoption, LANGUAGE.ok, 0,0,0); + } + break; + case 1: + Settings.sinfo++; + break; + case 2: + Settings.hddinfo++; + break; + case 3: + Settings.tooltips++; + break; + case 4: + Settings.xflip++; + break; + case 5: + Settings.wsprompt++; + break; + case 6: + Settings.keyset++; + break; + case 7: + Settings.wiilight++; + break; + case 8: + Settings.rumble++; + break; + } + } + optionBrowser2.SetEffect(EFFECT_FADE, -20); + while(optionBrowser2.GetEffect() > 0) usleep(50); + titleTxt.SetText(LANGUAGE.settings); + slidedirection = FADE; + if(returnhere != 2) + pageToDisplay = 1; + MainButton1.ResetState(); + break; + } + + if(MainButton2.GetState() == STATE_CLICKED) { + MainButton1.SetEffect(EFFECT_FADE, -20); + MainButton2.SetEffect(EFFECT_FADE, -20); + MainButton3.SetEffect(EFFECT_FADE, -20); + MainButton4.SetEffect(EFFECT_FADE, -20); + while(MainButton2.GetEffect() > 0) usleep(50); + HaltGui(); + w.Remove(&PageIndicatorBtn1); + w.Remove(&PageIndicatorBtn2); + w.Remove(&GoRightBtn); + w.Remove(&GoLeftBtn); + w.Remove(&MainButton1); + w.Remove(&MainButton2); + w.Remove(&MainButton3); + w.Remove(&MainButton4); + titleTxt.SetText(LANGUAGE.Gameload); + exit = false; + options2.SetName(0, "%s",LANGUAGE.VideoMode); + options2.SetName(1, "%s",LANGUAGE.VIDTVPatch); + options2.SetName(2, "%s",LANGUAGE.Patchcountrystrings); + options2.SetName(3, "Ocarina"); + options2.SetName(4,"%s", LANGUAGE.BootStandard); + options2.SetName(5, "%s",LANGUAGE.QuickBoot); + options2.SetName(6, NULL); + options2.SetName(7, NULL); + options2.SetName(8, NULL); + for(int i = 0; i < 9; i++) options2.SetValue(i, NULL); + w.Append(&optionBrowser2); + optionBrowser2.SetClickable(true); + ResumeGui(); + + VIDEO_WaitVSync (); + optionBrowser2.SetEffect(EFFECT_FADE, 20); + while(optionBrowser2.GetEffect() > 0) usleep(50); + + while(!exit) + { + VIDEO_WaitVSync (); + if(Settings.video >= settings_video_max) + Settings.video = 0; + if(Settings.vpatch >= settings_off_on_max) + Settings.vpatch = 0; + if ( Settings.patchcountrystrings > 1) + Settings.patchcountrystrings = 0; + if(Settings.ocarina >= settings_off_on_max) + Settings.ocarina = 0; + if ( Settings.qboot > 1 ) + Settings.qboot = 0; + if ( Settings.cios >= settings_cios_max) + Settings.cios = 0; + + if (Settings.video == discdefault) options2.SetValue(0,"%s",LANGUAGE.DiscDefault); + else if (Settings.video == systemdefault) options2.SetValue(0,"%s",LANGUAGE.SystemDefault); + else if (Settings.video == patch) options2.SetValue(0,"%s",LANGUAGE.AutoPatch); + else if (Settings.video == pal50) options2.SetValue(0,"%s PAL50",LANGUAGE.Force); + else if (Settings.video == pal60) options2.SetValue(0,"%s PAL60",LANGUAGE.Force); + else if (Settings.video == ntsc) options2.SetValue(0,"%s NTSC",LANGUAGE.Force); + + if (Settings.vpatch == on) options2.SetValue(1,"%s",LANGUAGE.ON); + else if (Settings.vpatch == off) options2.SetValue(1,"%s",LANGUAGE.OFF); + + if (Settings.patchcountrystrings == 0) options2.SetValue(2,"%s",LANGUAGE.OFF); + else if (Settings.patchcountrystrings == 1) options2.SetValue(2,"%s",LANGUAGE.ON); + + if (Settings.ocarina == on) options2.SetValue(3,"%s",LANGUAGE.ON); + else if (Settings.ocarina == off) options2.SetValue(3,"%s",LANGUAGE.OFF); + + if (Settings.godmode != 1) options2.SetValue(4, "********"); + else if (Settings.cios == ios249) options2.SetValue(4,"cIOS 249"); + else if (Settings.cios == ios222) options2.SetValue(4,"cIOS 222"); + + if (Settings.qboot == no) options2.SetValue(5,"%s",LANGUAGE.No); + else if (Settings.qboot == yes) options2.SetValue(5,"%s",LANGUAGE.Yes); + + if(backBtn.GetState() == STATE_CLICKED) + { + backBtn.ResetState(); + exit = true; + break; + } + + if(shutdown == 1) + Sys_Shutdown(); + else if(reset == 1) + Sys_Reboot(); + + else if(homo.GetState() == STATE_CLICKED) + { + cfg_save_global(); + optionBrowser2.SetState(STATE_DISABLED); + s32 thetimeofbg = bgMusic->GetPlayTime(); + bgMusic->Stop(); + choice = WindowExitPrompt(LANGUAGE.ExitUSBISOLoader,0, LANGUAGE.BacktoLoader,LANGUAGE.WiiMenu,LANGUAGE.Back,0); + if(!strcmp("", Settings.oggload_path) || !strcmp("notset", Settings.ogg_path)) + { + bgMusic->Play(); + } else { + bgMusic->PlayOggFile(Settings.ogg_path); + } + bgMusic->SetPlayTime(thetimeofbg); + SetVolumeOgg(255*(Settings.volume/100.0)); + if(choice == 3) { + Sys_LoadMenu(); // Back to System Menu + } else if (choice == 2) { + Sys_BackToLoader(); + } else { + homo.ResetState(); + } + optionBrowser2.SetState(STATE_DEFAULT); + } + + ret = optionBrowser2.GetClickedOption(); + + switch (ret) + { + case 0: + Settings.video++; + break; + case 1: + Settings.vpatch++; + break; + case 2: + Settings.patchcountrystrings++; + break; + case 3: + Settings.ocarina++; + break; + case 4: + if(Settings.godmode) + Settings.cios++; + break; + case 5: + Settings.qboot++; + break; + } + } + optionBrowser2.SetEffect(EFFECT_FADE, -20); + while(optionBrowser2.GetEffect() > 0) usleep(50); + titleTxt.SetText(LANGUAGE.settings); + slidedirection = FADE; + pageToDisplay = 1; + MainButton2.ResetState(); + break; + } + + if(MainButton3.GetState() == STATE_CLICKED) { + MainButton1.SetEffect(EFFECT_FADE, -20); + MainButton2.SetEffect(EFFECT_FADE, -20); + MainButton3.SetEffect(EFFECT_FADE, -20); + MainButton4.SetEffect(EFFECT_FADE, -20); + while(MainButton3.GetEffect() > 0) usleep(50); + HaltGui(); + w.Remove(&PageIndicatorBtn1); + w.Remove(&PageIndicatorBtn2); + w.Remove(&GoRightBtn); + w.Remove(&GoLeftBtn); + w.Remove(&MainButton1); + w.Remove(&MainButton2); + w.Remove(&MainButton3); + w.Remove(&MainButton4); + titleTxt.SetText(LANGUAGE.Parentalcontrol); + exit = false; + options2.SetName(0, "Console"); + options2.SetName(1, "%s", LANGUAGE.Password); + options2.SetName(2, "%s",LANGUAGE.Controllevel); + options2.SetName(3, NULL); + options2.SetName(4, NULL); + options2.SetName(5, NULL); + options2.SetName(6, NULL); + options2.SetName(7, NULL); + options2.SetName(8, NULL); + for(int i = 0; i < 9; i++) options2.SetValue(i, NULL); + w.Append(&optionBrowser2); + optionBrowser2.SetClickable(true); + ResumeGui(); + + VIDEO_WaitVSync (); + optionBrowser2.SetEffect(EFFECT_FADE, 20); + while(optionBrowser2.GetEffect() > 0) usleep(50); + + while(!exit) + { + VIDEO_WaitVSync (); + + if (Settings.parentalcontrol > 3 ) + Settings.parentalcontrol = 0; + + if( Settings.godmode == 1 ) options2.SetValue(0, "Unlocked"); + else if( Settings.godmode == 0 ) options2.SetValue(0, "Locked"); + + if ( Settings.godmode != 1) options2.SetValue(1, "********"); + else if (!strcmp("", Settings.unlockCode)) options2.SetValue(1, "%s",LANGUAGE.notset); + else options2.SetValue(1, Settings.unlockCode); + + if (Settings.godmode != 1) options2.SetValue(2, "********"); + else if(Settings.parentalcontrol == 0) options2.SetValue(2, "%s", LANGUAGE.OFF); + else if(Settings.parentalcontrol == 1) options2.SetValue(2, "1"); + else if(Settings.parentalcontrol == 2) options2.SetValue(2, "2"); + else if(Settings.parentalcontrol == 3) options2.SetValue(2, "3"); + + if(backBtn.GetState() == STATE_CLICKED) + { + backBtn.ResetState(); + exit = true; + break; + } + + if(shutdown == 1) + Sys_Shutdown(); + else if(reset == 1) + Sys_Reboot(); + + else if(homo.GetState() == STATE_CLICKED) + { + cfg_save_global(); + optionBrowser2.SetState(STATE_DISABLED); + s32 thetimeofbg = bgMusic->GetPlayTime(); + bgMusic->Stop(); + choice = WindowExitPrompt(LANGUAGE.ExitUSBISOLoader,0, LANGUAGE.BacktoLoader,LANGUAGE.WiiMenu,LANGUAGE.Back,0); + if(!strcmp("", Settings.oggload_path) || !strcmp("notset", Settings.ogg_path)) + { + bgMusic->Play(); + } else { + bgMusic->PlayOggFile(Settings.ogg_path); + } + bgMusic->SetPlayTime(thetimeofbg); + SetVolumeOgg(255*(Settings.volume/100.0)); + if(choice == 3) { + Sys_LoadMenu(); // Back to System Menu + } else if (choice == 2) { + Sys_BackToLoader(); + } else { + homo.ResetState(); + } + optionBrowser2.SetState(STATE_DEFAULT); + } + + ret = optionBrowser2.GetClickedOption(); + + switch (ret) + { + case 0: + if (!strcmp("", Settings.unlockCode)) + { + Settings.godmode = !Settings.godmode; + break; + } + else if ( Settings.godmode == 0 ) { + //password check to unlock Install,Delete and Format + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + char entered[20] = ""; + int result = OnScreenKeyboard(entered, 20,0); + w.Append(&optionBrowser2); + w.Append(&backBtn); + if ( result == 1 ) { + if (!strcmp(entered, Settings.unlockCode)) //if password correct + { + if (Settings.godmode == 0) { + WindowPrompt(LANGUAGE.CorrectPassword,LANGUAGE.InstallRenameandDeleteareunlocked,LANGUAGE.ok,0,0,0); + Settings.godmode = 1; + __Menu_GetEntries(); + menu = MENU_DISCLIST; + } + } else { + WindowPrompt(LANGUAGE.WrongPassword,LANGUAGE.USBLoaderisprotected,LANGUAGE.ok,0,0,0); + } + } + } else { + int choice = WindowPrompt (LANGUAGE.LockConsole,LANGUAGE.Areyousure,LANGUAGE.Yes,LANGUAGE.No,0,0); + if(choice == 1) { + WindowPrompt(LANGUAGE.ConsoleLocked,LANGUAGE.USBLoaderisprotected,LANGUAGE.ok,0,0,0); + Settings.godmode = 0; + __Menu_GetEntries(); + menu = MENU_DISCLIST; + } + } + break; + case 1:// Modify Password + if ( Settings.godmode == 1) + { + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + char entered[20] = ""; + strncpy(entered, Settings.unlockCode, sizeof(entered)); + int result = OnScreenKeyboard(entered, 20,0); + w.Append(&optionBrowser2); + w.Append(&backBtn); + if ( result == 1 ) { + strncpy(Settings.unlockCode, entered, sizeof(Settings.unlockCode)); + WindowPrompt(LANGUAGE.PasswordChanged,LANGUAGE.Passwordhasbeenchanged,LANGUAGE.ok,0,0,0); + } + } else { + WindowPrompt(LANGUAGE.Passwordchange,LANGUAGE.Consoleshouldbeunlockedtomodifyit,LANGUAGE.ok,0,0,0); + } + break; + case 2: + if(Settings.godmode) + Settings.parentalcontrol++; + break; + } + } + optionBrowser2.SetEffect(EFFECT_FADE, -20); + while(optionBrowser2.GetEffect() > 0) usleep(50); + titleTxt.SetText(LANGUAGE.settings); + slidedirection = FADE; + pageToDisplay = 1; + MainButton3.ResetState(); + break; + } + + if(MainButton4.GetState() == STATE_CLICKED) { + MainButton1.SetEffect(EFFECT_FADE, -20); + MainButton2.SetEffect(EFFECT_FADE, -20); + MainButton3.SetEffect(EFFECT_FADE, -20); + MainButton4.SetEffect(EFFECT_FADE, -20); + while(MainButton4.GetEffect() > 0) usleep(50); + HaltGui(); + w.Remove(&PageIndicatorBtn1); + w.Remove(&PageIndicatorBtn2); + w.Remove(&GoRightBtn); + w.Remove(&GoLeftBtn); + w.Remove(&MainButton1); + w.Remove(&MainButton2); + w.Remove(&MainButton3); + w.Remove(&MainButton4); + titleTxt.SetText(LANGUAGE.Sound); + exit = false; + options2.SetName(0, "%s",LANGUAGE.Backgroundmusic); + options2.SetName(1, "%s",LANGUAGE.Volume); + options2.SetName(2, "%s",LANGUAGE.SFXVolume); + options2.SetName(3, NULL); + options2.SetName(4, NULL); + options2.SetName(5, NULL); + options2.SetName(6, NULL); + options2.SetName(7, NULL); + options2.SetName(8, NULL); + for(int i = 0; i < 9; i++) options2.SetValue(i, NULL); + w.Append(&optionBrowser2); + optionBrowser2.SetClickable(true); + ResumeGui(); + + VIDEO_WaitVSync (); + optionBrowser2.SetEffect(EFFECT_FADE, 20); + while(optionBrowser2.GetEffect() > 0) usleep(50); + + + char * oggfile; + + while(!exit) + { + VIDEO_WaitVSync (); + + bool returnhere = true; + + if(!strcmp("notset", Settings.ogg_path)) + options2.SetValue(0, "%s", LANGUAGE.Standard); + else { + oggfile = strrchr(Settings.ogg_path, '/')+1; + options2.SetValue(0, "%s", oggfile); + } + + if(Settings.volume > 0) + options2.SetValue(1,"%i", Settings.volume); + else + options2.SetValue(1,"%s", LANGUAGE.OFF); + if(Settings.sfxvolume > 0) + options2.SetValue(2,"%i", Settings.sfxvolume); + else + options2.SetValue(2,"%s", LANGUAGE.OFF); + + if(backBtn.GetState() == STATE_CLICKED) + { + backBtn.ResetState(); + exit = true; + break; + } + + if(shutdown == 1) + Sys_Shutdown(); + else if(reset == 1) + Sys_Reboot(); + + else if(homo.GetState() == STATE_CLICKED) + { + cfg_save_global(); + optionBrowser2.SetState(STATE_DISABLED); + s32 thetimeofbg = bgMusic->GetPlayTime(); + bgMusic->Stop(); + choice = WindowExitPrompt(LANGUAGE.ExitUSBISOLoader,0, LANGUAGE.BacktoLoader,LANGUAGE.WiiMenu,LANGUAGE.Back,0); + if(!strcmp("", Settings.oggload_path) || !strcmp("notset", Settings.ogg_path)) + { + bgMusic->Play(); + } else { + bgMusic->PlayOggFile(Settings.ogg_path); + } + bgMusic->SetPlayTime(thetimeofbg); + SetVolumeOgg(255*(Settings.volume/100.0)); + if(choice == 3) { + Sys_LoadMenu(); // Back to System Menu + } else if (choice == 2) { + Sys_BackToLoader(); + } else { + homo.ResetState(); + } + optionBrowser2.SetState(STATE_DEFAULT); + } + + ret = optionBrowser2.GetClickedOption(); + + switch (ret) + { + case 0: + if(isSdInserted()) + { + w.SetEffect(EFFECT_FADE, -20); + while(w.GetEffect()>0) usleep(50); + mainWindow->Remove(&w); + while(returnhere) + returnhere = MenuOGG(); + HaltGui(); + mainWindow->Append(&w); + w.SetEffect(EFFECT_FADE, 20); + ResumeGui(); + while(w.GetEffect()>0) usleep(50); + } + else + WindowPrompt(LANGUAGE.NoSDcardinserted, LANGUAGE.InsertaSDCardtousethatoption, LANGUAGE.ok, 0,0,0); + break; + case 1: + Settings.volume += 10; + if(Settings.volume > 100) + Settings.volume = 0; + SetVolumeOgg(255*(Settings.volume/100.0)); + break; + case 2: + Settings.sfxvolume += 10; + if(Settings.sfxvolume > 100) + Settings.sfxvolume = 0; + btnSoundOver.SetVolume(Settings.sfxvolume); + btnClick.SetVolume(Settings.sfxvolume); + btnClick1.SetVolume(Settings.sfxvolume); + break; + } + } + optionBrowser2.SetEffect(EFFECT_FADE, -20); + while(optionBrowser2.GetEffect() > 0) usleep(50); + titleTxt.SetText(LANGUAGE.settings); + slidedirection = FADE; + pageToDisplay = 1; + MainButton4.ResetState(); + break; + } + } + + if ( pageToDisplay == 2) + { + if(MainButton1.GetState() == STATE_CLICKED) { + MainButton1.SetEffect(EFFECT_FADE, -20); + MainButton2.SetEffect(EFFECT_FADE, -20); + MainButton3.SetEffect(EFFECT_FADE, -20); + MainButton4.SetEffect(EFFECT_FADE, -20); + while(MainButton1.GetEffect() > 0) usleep(50); + HaltGui(); + w.Remove(&PageIndicatorBtn1); + w.Remove(&PageIndicatorBtn2); + w.Remove(&GoRightBtn); + w.Remove(&GoLeftBtn); + w.Remove(&MainButton1); + w.Remove(&MainButton2); + w.Remove(&MainButton3); + w.Remove(&MainButton4); + titleTxt.SetText(LANGUAGE.Custompaths); + exit = false; + if(Settings.godmode) + options2.SetName(0, "%s", LANGUAGE.CoverPath); + options2.SetName(1, "%s", LANGUAGE.DiscimagePath); + options2.SetName(2, "%s", LANGUAGE.ThemePath); + options2.SetName(3, "%s", LANGUAGE.Titlestxtpath); + options2.SetName(4, "%s", LANGUAGE.Updatepath); + options2.SetName(5, NULL); + options2.SetName(6, NULL); + options2.SetName(7, NULL); + options2.SetName(8, NULL); + for(int i = 0; i < 9; i++) options2.SetValue(i, NULL); + w.Append(&optionBrowser2); + optionBrowser2.SetClickable(true); + ResumeGui(); + + VIDEO_WaitVSync (); + optionBrowser2.SetEffect(EFFECT_FADE, 20); + while(optionBrowser2.GetEffect() > 0) usleep(50); + + if(Settings.godmode) { + + while(!exit) + { + VIDEO_WaitVSync (); + + options2.SetValue(0, "%s", Settings.covers_path); + options2.SetValue(1, "%s", Settings.disc_path); + options2.SetValue(2, "%s", CFG.theme_path); + options2.SetValue(3, "%s", Settings.titlestxt_path); + options2.SetValue(4, "%s", Settings.update_path); + + if(backBtn.GetState() == STATE_CLICKED) + { + backBtn.ResetState(); + exit = true; + break; + } + + if(shutdown == 1) + Sys_Shutdown(); + else if(reset == 1) + Sys_Reboot(); + + else if(homo.GetState() == STATE_CLICKED) + { + cfg_save_global(); + optionBrowser2.SetState(STATE_DISABLED); + s32 thetimeofbg = bgMusic->GetPlayTime(); + bgMusic->Stop(); + choice = WindowExitPrompt(LANGUAGE.ExitUSBISOLoader,0, LANGUAGE.BacktoLoader,LANGUAGE.WiiMenu,LANGUAGE.Back,0); + if(!strcmp("", Settings.oggload_path) || !strcmp("notset", Settings.ogg_path)) + { + bgMusic->Play(); + } else { + bgMusic->PlayOggFile(Settings.ogg_path); + } + bgMusic->SetPlayTime(thetimeofbg); + SetVolumeOgg(255*(Settings.volume/100.0)); + if(choice == 3) { + Sys_LoadMenu(); // Back to System Menu + } else if (choice == 2) { + Sys_BackToLoader(); + } else { + homo.ResetState(); + } + optionBrowser2.SetState(STATE_DEFAULT); + } + + ret = optionBrowser2.GetClickedOption(); + + switch (ret) + { + case 0: + if ( Settings.godmode == 1) + { + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + char entered[43] = ""; + strncpy(entered, Settings.covers_path, sizeof(entered)); + int result = OnScreenKeyboard(entered,43,4); + w.Append(&optionBrowser2); + w.Append(&backBtn); + if ( result == 1 ) + { + int len = (strlen(entered)-1); + if(entered[len] !='/') + strncat (entered, "/", 1); + strncpy(Settings.covers_path, entered, sizeof(Settings.covers_path)); + WindowPrompt(LANGUAGE.CoverpathChanged,0,LANGUAGE.ok,0,0,0); + if(!isSdInserted()) { + WindowPrompt(LANGUAGE.NoSDcardinserted, LANGUAGE.InsertaSDCardtosave, LANGUAGE.ok, 0,0,0); + } + } + } else { + WindowPrompt(LANGUAGE.Coverpathchange,LANGUAGE.Consoleshouldbeunlockedtomodifyit,LANGUAGE.ok,0,0,0); + } + break; + case 1: + if ( Settings.godmode == 1) + { + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + char entered[43] = ""; + strncpy(entered, Settings.disc_path, sizeof(entered)); + int result = OnScreenKeyboard(entered, 43,4); + w.Append(&optionBrowser2); + w.Append(&backBtn); + if ( result == 1 ) + { + int len = (strlen(entered)-1); + if(entered[len] !='/') + strncat (entered, "/", 1); + strncpy(Settings.disc_path, entered, sizeof(Settings.disc_path)); + WindowPrompt(LANGUAGE.DiscpathChanged,0,LANGUAGE.ok,0,0,0); + if(!isSdInserted()) { + WindowPrompt(LANGUAGE.NoSDcardinserted, LANGUAGE.InsertaSDCardtosave, LANGUAGE.ok, 0,0,0); + } + } + } else { + WindowPrompt(LANGUAGE.Discpathchange,LANGUAGE.Consoleshouldbeunlockedtomodifyit,LANGUAGE.ok,0,0,0); + } + break; + case 2: + if ( Settings.godmode == 1) + { + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + char entered[43] = ""; + strncpy(entered, CFG.theme_path, sizeof(entered)); + int result = OnScreenKeyboard(entered, 43,4); + HaltGui(); + w.RemoveAll(); + if ( result == 1 ) + { + int len = (strlen(entered)-1); + if(entered[len] !='/') + strncat (entered, "/", 1); + strncpy(CFG.theme_path, entered, sizeof(CFG.theme_path)); + WindowPrompt(LANGUAGE.ThemepathChanged,0,LANGUAGE.ok,0,0,0); + if(!isSdInserted()) { + WindowPrompt(LANGUAGE.NoSDcardinserted, LANGUAGE.InsertaSDCardtosave, LANGUAGE.ok, 0,0,0); + } else { + cfg_save_global(); + } + mainWindow->Remove(bgImg); + CFG_Load(); + CFG_LoadGlobal(); + menu = MENU_SETTINGS; + #ifdef HW_RVL + snprintf(imgPath, sizeof(imgPath), "%splayer1_point.png", CFG.theme_path); + pointer[0] = new GuiImageData(imgPath, player1_point_png); + snprintf(imgPath, sizeof(imgPath), "%splayer2_point.png", CFG.theme_path); + pointer[1] = new GuiImageData(imgPath, player2_point_png); + snprintf(imgPath, sizeof(imgPath), "%splayer3_point.png", CFG.theme_path); + pointer[2] = new GuiImageData(imgPath, player3_point_png); + snprintf(imgPath, sizeof(imgPath), "%splayer4_point.png", CFG.theme_path); + pointer[3] = new GuiImageData(imgPath, player4_point_png); + #endif + if (CFG.widescreen) + snprintf(imgPath, sizeof(imgPath), "%swbackground.png", CFG.theme_path); + else + snprintf(imgPath, sizeof(imgPath), "%sbackground.png", CFG.theme_path); + + background = new GuiImageData(imgPath, CFG.widescreen? wbackground_png : background_png); + + bgImg = new GuiImage(background); + mainWindow->Append(bgImg); + mainWindow->Append(&w); + } + w.Append(&settingsbackground); + w.Append(&titleTxt); + w.Append(&backBtn); + w.Append(&optionBrowser2); + ResumeGui(); + } else { + WindowPrompt(LANGUAGE.Themepathchange,LANGUAGE.Consoleshouldbeunlockedtomodifyit,LANGUAGE.ok,0,0,0); + } + break; + } + } + /** If not godmode don't let him inside **/ + } else { + WindowPrompt(LANGUAGE.ConsoleLocked, LANGUAGE.UnlockConsoletousethisOption, LANGUAGE.ok, 0, 0, 0); + } + optionBrowser2.SetEffect(EFFECT_FADE, -20); + while(optionBrowser2.GetEffect() > 0) usleep(50); + titleTxt.SetText(LANGUAGE.settings); + slidedirection = FADE; + pageToDisplay = 2; + MainButton1.ResetState(); + break; + } + + if(MainButton2.GetState() == STATE_CLICKED) { + MainButton1.SetEffect(EFFECT_FADE, -20); + MainButton2.SetEffect(EFFECT_FADE, -20); + MainButton3.SetEffect(EFFECT_FADE, -20); + MainButton4.SetEffect(EFFECT_FADE, -20); + while(MainButton2.GetEffect() > 0) usleep(50); + w.Remove(&PageIndicatorBtn1); + w.Remove(&PageIndicatorBtn2); + w.Remove(&GoRightBtn); + w.Remove(&GoLeftBtn); + w.Remove(&MainButton1); + w.Remove(&MainButton2); + w.Remove(&MainButton3); + w.Remove(&MainButton4); + if(isSdInserted() && Settings.godmode) { + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + int ret = ProgressUpdateWindow(); + if(ret < 0) { + WindowPrompt(LANGUAGE.Updatefailed,0,LANGUAGE.ok,0,0,0); + } + w.Append(&optionBrowser2); + w.Append(&backBtn); + } else { + WindowPrompt(LANGUAGE.ConsoleLocked, LANGUAGE.UnlockConsoletousethisOption, LANGUAGE.ok, 0,0,0); + } + slidedirection = FADE; + pageToDisplay = 2; + MainButton2.ResetState(); + break; + } + + if(MainButton3.GetState() == STATE_CLICKED) { + MainButton1.SetEffect(EFFECT_FADE, -20); + MainButton2.SetEffect(EFFECT_FADE, -20); + MainButton3.SetEffect(EFFECT_FADE, -20); + MainButton4.SetEffect(EFFECT_FADE, -20); + while(MainButton3.GetEffect() > 0) usleep(50); + w.Remove(&PageIndicatorBtn1); + w.Remove(&PageIndicatorBtn2); + w.Remove(&GoRightBtn); + w.Remove(&GoLeftBtn); + w.Remove(&MainButton1); + w.Remove(&MainButton2); + w.Remove(&MainButton3); + w.Remove(&MainButton4); + w.Remove(&backBtn); + w.Remove(&optionBrowser2); + if(Settings.godmode) { + int choice = WindowPrompt(LANGUAGE.Areyousure, 0, LANGUAGE.Yes, LANGUAGE.Cancel, 0, 0); + if(choice == 1) { + if(isSdInserted()) + remove("SD:/config/GXGlobal.cfg"); + lang_default(); + CFG_Load(); + menu = MENU_SETTINGS; + pageToDisplay = 0; + } + } else { + WindowPrompt(LANGUAGE.ConsoleLocked, LANGUAGE.UnlockConsoletousethisOption, LANGUAGE.ok, 0, 0, 0); + } + w.Append(&backBtn); + w.Append(&optionBrowser2); + slidedirection = FADE; + pageToDisplay = 2; + MainButton3.ResetState(); + break; + } + + if(MainButton4.GetState() == STATE_CLICKED) { + MainButton1.SetEffect(EFFECT_FADE, -20); + MainButton2.SetEffect(EFFECT_FADE, -20); + MainButton3.SetEffect(EFFECT_FADE, -20); + MainButton4.SetEffect(EFFECT_FADE, -20); + while(MainButton4.GetEffect() > 0) usleep(50); + w.Remove(&PageIndicatorBtn1); + w.Remove(&PageIndicatorBtn2); + w.Remove(&GoRightBtn); + w.Remove(&GoLeftBtn); + w.Remove(&MainButton1); + w.Remove(&MainButton2); + w.Remove(&MainButton3); + w.Remove(&MainButton4); + WindowCredits(); + slidedirection = FADE; + pageToDisplay = 2; + MainButton4.ResetState(); + break; + } + } + + if(shutdown == 1) + Sys_Shutdown(); + if(reset == 1) + Sys_Reboot(); + + + + + } + } + + /* bool exit = false; int ret; int retVal = 0; @@ -1601,16 +3045,16 @@ int GameSettings(struct discHdr * header) strncat(gameName, "...", 3); } - customOptionList options3(8); - options3.SetName(0,"%s", LANGUAGE.VideoMode); - options3.SetName(1,"%s", LANGUAGE.VIDTVPatch); - options3.SetName(2,"%s", LANGUAGE.Language); - options3.SetName(3, "Ocarina"); - options3.SetName(4, "IOS"); - options3.SetName(5,"%s", LANGUAGE.Parentalcontrol); - options3.SetName(6,"%s", "Error 002 fix"); - options3.SetName(7,"%s", LANGUAGE.Defaultgamesettings); - + customOptionList options4(8); + options4.SetName(0,"%s", LANGUAGE.VideoMode); + options4.SetName(1,"%s", LANGUAGE.VIDTVPatch); + options4.SetName(2,"%s", LANGUAGE.Language); + options4.SetName(3, "Ocarina"); + options4.SetName(4, "IOS"); + options4.SetName(5,"%s", LANGUAGE.Parentalcontrol); + options4.SetName(6,"%s", "Error 002 fix"); + options4.SetName(7,"%s", LANGUAGE.Defaultgamesettings); + 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); @@ -1670,9 +3114,9 @@ int GameSettings(struct discHdr * header) deleteBtn.SetScale(0.9); deleteBtn.SetLabel(&deleteBtnTxt); - GuiCustomOptionBrowser optionBrowser3(396, 280, &options3, CFG.theme_path, "bg_options_gamesettings.png", bg_options_settings_png, 0, 200); - optionBrowser3.SetPosition(0, 90); - optionBrowser3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + GuiCustomOptionBrowser optionBrowser4(396, 280, &options4, CFG.theme_path, "bg_options_gamesettings.png", bg_options_settings_png, 0, 200); + optionBrowser4.SetPosition(0, 90); + optionBrowser4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); HaltGui(); GuiWindow w(screenwidth, screenheight); @@ -1681,7 +3125,7 @@ int GameSettings(struct discHdr * header) w.Append(&deleteBtn); w.Append(&saveBtn); w.Append(&cancelBtn); - w.Append(&optionBrowser3); + w.Append(&optionBrowser4); mainWindow->Append(&w); @@ -1718,41 +3162,46 @@ int GameSettings(struct discHdr * header) { VIDEO_WaitVSync(); - if (videoChoice == discdefault) options3.SetValue(0,"%s",LANGUAGE.DiscDefault); - else if (videoChoice == systemdefault) options3.SetValue(0,"%s",LANGUAGE.SystemDefault); - else if (videoChoice == patch) options3.SetValue(0,"%s",LANGUAGE.AutoPatch); - else if (videoChoice == pal50) options3.SetValue(0,"%s PAL50",LANGUAGE.Force); - else if (videoChoice == pal60) options3.SetValue(0,"%s PAL60",LANGUAGE.Force); - else if (videoChoice == ntsc) options3.SetValue(0,"%s NTSC",LANGUAGE.Force); - if (viChoice == on) options3.SetValue(1,"%s",LANGUAGE.ON); - else if (viChoice == off) options3.SetValue(1,"%s",LANGUAGE.OFF); - if (languageChoice == ConsoleLangDefault) options3.SetValue(2,"%s",LANGUAGE.ConsoleDefault); - else if (languageChoice == jap) options3.SetValue(2,"%s",LANGUAGE.Japanese); - else if (languageChoice == ger) options3.SetValue(2,"%s",LANGUAGE.German); - else if (languageChoice == eng) options3.SetValue(2,"%s",LANGUAGE.English); - else if (languageChoice == fren) options3.SetValue(2,"%s",LANGUAGE.French); - else if (languageChoice == esp) options3.SetValue(2,"%s",LANGUAGE.Spanish); - else if (languageChoice == it) options3.SetValue(2,"%s",LANGUAGE.Italian); - else if (languageChoice == dut) options3.SetValue(2,"%s",LANGUAGE.Dutch); - else if (languageChoice == schin) options3.SetValue(2,"%s",LANGUAGE.SChinese); - else if (languageChoice == tchin) options3.SetValue(2,"%s",LANGUAGE.TChinese); - else if (languageChoice == kor) options3.SetValue(2,"%s",LANGUAGE.Korean); - if (ocarinaChoice == on) options3.SetValue(3,"%s",LANGUAGE.ON); - else if (ocarinaChoice == off) options3.SetValue(3,"%s",LANGUAGE.OFF); + if (videoChoice == discdefault) options4.SetValue(0,"%s",LANGUAGE.DiscDefault); + else if (videoChoice == systemdefault) options4.SetValue(0,"%s",LANGUAGE.SystemDefault); + else if (videoChoice == patch) options4.SetValue(0,"%s",LANGUAGE.AutoPatch); + else if (videoChoice == pal50) options4.SetValue(0,"%s PAL50",LANGUAGE.Force); + else if (videoChoice == pal60) options4.SetValue(0,"%s PAL60",LANGUAGE.Force); + else if (videoChoice == ntsc) options4.SetValue(0,"%s NTSC",LANGUAGE.Force); + + if (viChoice == on) options4.SetValue(1,"%s",LANGUAGE.ON); + else if (viChoice == off) options4.SetValue(1,"%s",LANGUAGE.OFF); + + if (languageChoice == ConsoleLangDefault) options4.SetValue(2,"%s",LANGUAGE.ConsoleDefault); + else if (languageChoice == jap) options4.SetValue(2,"%s",LANGUAGE.Japanese); + else if (languageChoice == ger) options4.SetValue(2,"%s",LANGUAGE.German); + else if (languageChoice == eng) options4.SetValue(2,"%s",LANGUAGE.English); + else if (languageChoice == fren) options4.SetValue(2,"%s",LANGUAGE.French); + else if (languageChoice == esp) options4.SetValue(2,"%s",LANGUAGE.Spanish); + else if (languageChoice == it) options4.SetValue(2,"%s",LANGUAGE.Italian); + else if (languageChoice == dut) options4.SetValue(2,"%s",LANGUAGE.Dutch); + else if (languageChoice == schin) options4.SetValue(2,"%s",LANGUAGE.SChinese); + else if (languageChoice == tchin) options4.SetValue(2,"%s",LANGUAGE.TChinese); + else if (languageChoice == kor) options4.SetValue(2,"%s",LANGUAGE.Korean); + + if (ocarinaChoice == on) options4.SetValue(3,"%s",LANGUAGE.ON); + else if (ocarinaChoice == off) options4.SetValue(3,"%s",LANGUAGE.OFF); + + if (iosChoice == i249) options4.SetValue(4,"249"); + else if (iosChoice == i222) options4.SetValue(4,"222"); - if (iosChoice == i249) options3.SetValue(4,"249"); - else if (iosChoice == i222) options3.SetValue(4,"222"); if (parentalcontrolChoice == 0) options3.SetValue(5, LANGUAGE.Always); else if (parentalcontrolChoice == 1) options3.SetValue(5,"1"); else if (parentalcontrolChoice == 2) options3.SetValue(5,"2"); else if (parentalcontrolChoice == 3) options3.SetValue(5, LANGUAGE.Mature); - if (fix002 == on) options3.SetValue(6,LANGUAGE.ON); - else if (fix002 == off) options3.SetValue(6,LANGUAGE.OFF); + + if (fix002 == on) options4.SetValue(6,LANGUAGE.ON); + else if (fix002 == off) options4.SetValue(6,LANGUAGE.OFF); options3.SetValue(7, NULL); @@ -1761,7 +3210,6 @@ int GameSettings(struct discHdr * header) if(reset == 1) Sys_Reboot(); - ret = optionBrowser3.GetClickedOption(); switch (ret) { @@ -1822,7 +3270,7 @@ int GameSettings(struct discHdr * header) } saveBtn.ResetState(); - optionBrowser3.SetFocus(1); + optionBrowser4.SetFocus(1); } if (cancelBtn.GetState() == STATE_CLICKED) @@ -1861,7 +3309,7 @@ int GameSettings(struct discHdr * header) else if (choice == 0) { deleteBtn.ResetState(); - optionBrowser3.SetFocus(1); + optionBrowser4.SetFocus(1); } } @@ -1871,5 +3319,10 @@ int GameSettings(struct discHdr * header) mainWindow->Remove(&w); ResumeGui(); - return retVal; + return retVal;*/ + HaltGui(); + mainWindow->RemoveAll(); + mainWindow->Append(bgImg); + ResumeGui(); + return menu; } diff --git a/source/cfg.c b/source/cfg.c index 3a20037f..42e93b24 100644 --- a/source/cfg.c +++ b/source/cfg.c @@ -7,6 +7,8 @@ #include #include "cfg.h" #include "language.h" +#include "xml.h" /* XML - Lustar*/ +#include "mxml/mxml.h" struct SSettings Settings; @@ -1555,6 +1557,11 @@ void CFG_Load(void) cfg_load_games(); cfg_load_game_num(); + /* load renamed titles from proper names and game info XML, needs to be after cfg_load_games - Lustar */ + //snprintf(pathname, sizeof(pathname), "%s%s", Settings.titlestxt_path, "wiitdb.zip"); + //OpenXMLFile(pathname); + //LoadTitlesFromXML("English", false); // options can be added to set force title language to any language and force Japanese title to English + Global_Default(); //global default depends on theme information CFG_LoadGlobal(); diff --git a/source/filelist.h b/source/filelist.h index b3351505..f9b62331 100644 --- a/source/filelist.h +++ b/source/filelist.h @@ -32,6 +32,18 @@ extern const u32 bg_music_ogg_size; extern const u8 credits_music_ogg[]; extern const u32 credits_music_ogg_size; +extern const u8 gameinfo1_png[]; +extern const u32 gameinfo1_png_size; + +extern const u8 gameinfo2_png[]; +extern const u32 gameinfo2_png_size; + +extern const u8 gameinfo1a_png[]; +extern const u32 gameinfo1a_png_size; + +extern const u8 gameinfo2a_png[]; +extern const u32 gameinfo2a_png_size; + extern const u8 menuin_ogg[]; extern const u32 menuin_ogg_size; @@ -290,4 +302,141 @@ extern const u32 settings_title_over_png_size; extern const u8 pageindicator_png[]; extern const u32 pageindicator_png_size; +extern const u8 Wiimote1_png[]; +extern const u32 Wiimote1_png_size; + +extern const u8 Wiimote2_png[]; +extern const u32 Wiimote2_png_size; + +extern const u8 wifi1_png[]; +extern const u32 wifi1_png_size; + +extern const u8 wifi2_png[]; +extern const u32 wifi2png_size; + +extern const u8 wifi3_png[]; +extern const u32 wifi3_png_size; + +extern const u8 wifi4_png[]; +extern const u32 wifi4_png_size; + +extern const u8 wifi8_png[]; +extern const u32 wifi8_png_size; + +extern const u8 Wiimote4_png[]; +extern const u32 Wiimote4_png_size; + +extern const u8 norating_png[]; +extern const u32 norating_png_size; + +extern const u8 guitar_png[]; +extern const u32 guitar_png_size; + +extern const u8 microphone_png[]; +extern const u32 microphone_png_size; + +extern const u8 gcncontroller_png[]; +extern const u32 gcncontroller_png_size; + +extern const u8 classiccontroller_png[]; +extern const u32 classiccontroller_png_size; + +extern const u8 nunchuck_png[]; +extern const u32 nunchuck_png_size; + +extern const u8 guitarR_png[]; +extern const u32 guitarR_png_size; + +extern const u8 microphoneR_png[]; +extern const u32 microphoneR_png_size; + +extern const u8 gcncontrollerR_png[]; +extern const u32 gcncontrollerR_png_size; + +extern const u8 classiccontrollerR_png[]; +extern const u32 classiccontrollerR_png_size; + +extern const u8 nunchuckR_png[]; +extern const u32 nunchuckR_png_size; + +extern const u8 dancepadR_png[]; +extern const u32 dancepadR_size; + +extern const u8 balanceboard_png[]; +extern const u32 balanceboard_png_size; + +extern const u8 balanceboardR_png[]; +extern const u32 balanceboardR_png_size; + +extern const u8 dancepad_png[]; +extern const u32 dancepad_png_size; + +extern const u8 drumsR_png[]; +extern const u32 drumsR_png_size; + +extern const u8 drums_png[]; +extern const u32 drums_png_size; + +extern const u8 motionplusR_png[]; +extern const u32 motionplusR_png_size; + +extern const u8 motionplus_png[]; +extern const u32 motionplus_png_size; + +extern const u8 wheelR_png[]; +extern const u32 wheelR_png_size; + +extern const u8 wheel_png[]; +extern const u32 wheel_png_size; + +extern const u8 esrb_ec_png[]; +extern const u32 esrb_ec_png_size; + +extern const u8 esrb_e_png[]; +extern const u32 esrb_e_png_size; + +extern const u8 esrb_eten_png[]; +extern const u32 esrb_eten_png_size; + +extern const u8 esrb_t_png[]; +extern const u32 esrb_t_png_size; + +extern const u8 esrb_m_png[]; +extern const u32 esrb_m_png_size; + +extern const u8 esrb_ao_png[]; +extern const u32 esrb_ao_png_size; + +extern const u8 cero_a_png[]; +extern const u32 cero_a_png_size; + +extern const u8 cero_b_png[]; +extern const u32 cero_b_png_size; + +extern const u8 cero_c_png[]; +extern const u32 cero_c_png_size; + +extern const u8 cero_d_png[]; +extern const u32 cero_d_png_size; + +extern const u8 cero_z_png[]; +extern const u32 cero_z_png_size; + +extern const u8 pegi_3_png[]; +extern const u32 pegi_3_png_size; + +extern const u8 pegi_7_png[]; +extern const u32 pegi_7_png_size; + +extern const u8 pegi_12_png[]; +extern const u32 pegi_12_png_size; + +extern const u8 pegi_16_png[]; +extern const u32 pegi_16_png_size; + +extern const u8 pegi_18_png[]; +extern const u32 pegi_18_png_size; + + + #endif diff --git a/source/gameinfo.cpp b/source/gameinfo.cpp new file mode 100644 index 00000000..43f43af8 --- /dev/null +++ b/source/gameinfo.cpp @@ -0,0 +1,781 @@ +#include +#include +#include +#include +#include +#include + + +#include "gameinfo.h" + +#include "menu.h" +#include "filelist.h" +#include "sys.h" +#include "wpad.h" +#include "wbfs.h" +#include "language.h" +#include "libwiigui/gui.h" +#include "fatmounter.h" +#include "listfiles.h" + +#include "xml.h" + +GuiText * debugTxt = NULL; + +int cnt; +GuiImageData * playersImgData = NULL; +GuiImage * playersImg = NULL; + +GuiImageData * wifiplayersImgData = NULL; +GuiImage * wifiplayersImg = NULL; +GuiImage * ratingImg = NULL; + +GuiImage * classiccontrollerImg; +GuiImage * nunchuckImg; +GuiImage * guitarImg; +GuiImage * drumsImg; +GuiImage * dancepadImg; +GuiImage * motionplusImg; +GuiImage * wheelImg; +GuiImage * balanceboardImg; +GuiImage * microphoneImg; +GuiImage * gcImg; +GuiImage * dialogBoxImg1; +GuiImage * dialogBoxImg2; +GuiImage * dialogBoxImg3; +GuiImage * dialogBoxImg4; +GuiImage * dialogBoxImg11; +GuiImage * dialogBoxImg22; +GuiImage * dialogBoxImg33; +GuiImage * dialogBoxImg44; +GuiImage * coverImg; +GuiImage * coverImg2; + +GuiImageData * classiccontrollerImgData = NULL; +GuiImageData * nunchuckImgData = NULL; +GuiImageData * guitarImgData = NULL; +GuiImageData * drumsImgData = NULL; +GuiImageData * motionplusImgData = NULL; +GuiImageData * wheelImgData = NULL; +GuiImageData * balanceboardImgData = NULL; +GuiImageData * dancepadImgData = NULL; +GuiImageData * microphoneImgData = NULL; +GuiImageData * gamecubeImgData = NULL; +GuiImageData * ratingImgData = NULL; +GuiImageData * cover = NULL; + +GuiText * releasedTxt = NULL; +GuiText * publisherTxt = NULL; +GuiText * developerTxt = NULL; +GuiText * titleTxt = NULL; +GuiText * synopsisTxt = NULL; +GuiText * genreTxt = NULL; +GuiText * betaTxt = NULL; +GuiText * beta1Txt = NULL; +GuiText ** wifiTxt = NULL; + + +/*** Extern variables ***/ +extern GuiWindow * mainWindow; +extern GuiSound * bgMusic; +extern u8 shutdown; +extern u8 reset; + +/*** Extern functions ***/ +extern void ResumeGui(); +extern void HaltGui(); + +void eatADick() +{ +// use this to display variables on the window GuiText * debugTxt = NULL; + +playersImgData = NULL; +playersImg = NULL; + +wifiplayersImgData = NULL; +wifiplayersImg = NULL; +ratingImg = NULL; + +classiccontrollerImg = NULL; +nunchuckImg = NULL; +guitarImg = NULL; +drumsImg = NULL; +dancepadImg = NULL; +motionplusImg = NULL; +wheelImg = NULL; +balanceboardImg = NULL; +microphoneImg = NULL; +gcImg = NULL; +dialogBoxImg1 = NULL; +dialogBoxImg2 = NULL; +dialogBoxImg3 = NULL; +dialogBoxImg4 = NULL; +dialogBoxImg11 = NULL; +dialogBoxImg22 = NULL; +dialogBoxImg33 = NULL; +dialogBoxImg44 = NULL; +coverImg = NULL; +coverImg2 = NULL; + +classiccontrollerImgData = NULL; +nunchuckImgData = NULL; +guitarImgData = NULL; +drumsImgData = NULL; +motionplusImgData = NULL; +wheelImgData = NULL; +balanceboardImgData = NULL; +dancepadImgData = NULL; +microphoneImgData = NULL; +gamecubeImgData = NULL; +ratingImgData = NULL; +cover = NULL; + +releasedTxt = NULL; +publisherTxt = NULL; +developerTxt = NULL; +titleTxt = NULL; +synopsisTxt = NULL; +genreTxt = NULL; +betaTxt = NULL; +beta1Txt = NULL; +} + + +/**************************************************************************** +* gameinfo +***************************************************************************/ +int +showGameInfo(char *ID, u8 *headerID) +{ + int choice = -1; + //int i = 0; + int y = 0, y1 = 32; + int intputX =200, inputY=-30, txtXOffset = 90; + u8 nunchuk=0, + classiccontroller=0, + balanceboard=0, + dancepad=0, + guitar=0, + gamecube=0, + wheel=0, + motionplus=0, + drums=0, + microphone=0; + int newline=1; + u8 page =1; + + GuiWindow gameinfoWindow(600,308); + gameinfoWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + gameinfoWindow.SetPosition(0, -50); + + GuiWindow gameinfoWindow2(600,308); + gameinfoWindow2.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + gameinfoWindow2.SetPosition(0, -50); + + GuiWindow txtWindow(350,270); + txtWindow.SetAlignment(ALIGN_CENTRE, ALIGN_RIGHT); + txtWindow.SetPosition(85, 50); + + + 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[50]; + snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); + GuiImageData btnOutline(imgPath, button_dialogue_box_png); + snprintf(imgPath, sizeof(imgPath), "%sgameinfo1_png.png", CFG.theme_path); + GuiImageData dialogBox1(imgPath, gameinfo1_png); + snprintf(imgPath, sizeof(imgPath), "%sgameinfo1a_png.png", CFG.theme_path); + GuiImageData dialogBox2(imgPath, gameinfo1a_png); + snprintf(imgPath, sizeof(imgPath), "%sgameinfo2_png.png", CFG.theme_path); + GuiImageData dialogBox3(imgPath, gameinfo2_png); + snprintf(imgPath, sizeof(imgPath), "%sgameinfo2a_png.png", CFG.theme_path); + GuiImageData dialogBox4(imgPath, gameinfo2a_png); + + GuiTrigger trigA; + trigA.SetButtonOnlyTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + GuiTrigger trigB; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); + + + GuiButton backBtn(0,0); + backBtn.SetPosition(-20,-20); + backBtn.SetTrigger(&trigB); + gameinfoWindow.Append(&backBtn); + + GuiButton nextBtn(0,0); + nextBtn.SetPosition(20,20); + nextBtn.SetTrigger(&trigA); + gameinfoWindow.Append(&nextBtn); + + //load the xml shit + char pathname[100]; + snprintf(pathname, sizeof(pathname), "%s%s", Settings.titlestxt_path, "wiitdb.zip"); + OpenXMLFile(pathname); + snprintf(pathname, sizeof(pathname), "English"); + LoadTitlesFromXML(pathname, false); // options can be added to set force title language to any language and force Japanese title to English + + + /*struct Game_CFG *game_cfg = NULL; + int opt_lang; + char langtexttmp[11][22] = + {{"Console Default"}, + {"Japanese"}, + {"English"}, + {"German"}, + {"French"}, + {"Spanish"}, + {"Italian"}, + {"Dutch"}, + {"S. Chinese"}, + {"T. Chinese"}, + {"Korean"}}; + game_cfg = CFG_get_game_opt(headerID); + if (game_cfg) { + opt_lang = game_cfg->language; + } else { + opt_lang = Settings.language; + }*/ + LoadGameInfoFromXML(ID,pathname); + //LoadGameInfoFromXML(ID,langtexttmp[opt_lang]); + char linebuf[1000] = ""; + char linebuf2[100] = ""; + + // set images for required input + for (int i=0;strcmp(gameinfo.accessories_required[i+1],"") != 0;i++) + { + if (strcmp(gameinfo.accessories_required[i+1],"nunchuk")==0) + {nunchuckImgData = new GuiImageData(nunchuckR_png);nunchuk=1;} + else + nunchuckImgData = new GuiImageData(nunchuck_png); + + if (strcmp(gameinfo.accessories_required[i+1],"classiccontroller")==0) + {classiccontrollerImgData = new GuiImageData(classiccontrollerR_png);classiccontroller=1;} + else + classiccontrollerImgData = new GuiImageData(classiccontroller_png); + + if (strcmp(gameinfo.accessories_required[i+1],"guitar")==0) + {guitarImgData = new GuiImageData(guitarR_png);guitar=1;} + else + guitarImgData = new GuiImageData(guitar_png); + + if (strcmp(gameinfo.accessories_required[i+1],"gamecube")==0) + {gamecubeImgData = new GuiImageData(gcncontrollerR_png);gamecube=1;} + else + gamecubeImgData = new GuiImageData(gcncontroller_png); + + if (strcmp(gameinfo.accessories_required[i+1],"wheel")==0) + {wheelImgData = new GuiImageData(wheelR_png);wheel=1;} + else + wheelImgData = new GuiImageData(wheel_png); + + if (strcmp(gameinfo.accessories_required[i+1],"motionplus")==0) + {motionplusImgData = new GuiImageData(motionplusR_png);motionplus=1;} + else + motionplusImgData = new GuiImageData(motionplus_png); + + if (strcmp(gameinfo.accessories_required[i+1],"drums")==0) + {drumsImgData = new GuiImageData(drumsR_png);drums=1;} + else + drumsImgData = new GuiImageData(drums_png); + + if (strcmp(gameinfo.accessories_required[i+1],"microphone")==0) + {microphoneImgData = new GuiImageData(microphoneR_png);microphone=1;} + else + microphoneImgData = new GuiImageData(microphone_png); + + if (strcmp(gameinfo.accessories_required[i+1],"balanceboard")==0) + {balanceboardImgData = new GuiImageData(balanceboardR_png);balanceboard=1;} + else + balanceboardImgData = new GuiImageData(balanceboard_png); + + if (strcmp(gameinfo.accessories_required[i+1],"dancepad")==0) + {dancepadImgData = new GuiImageData(dancepadR_png);dancepad=1;} + else + dancepadImgData = new GuiImageData(dancepad_png); + + } + for (int i=0;strcmp(gameinfo.accessories[i+1],"") != 0;i++) + { + + if (strcmp(gameinfo.accessories_required[i],"classiccontroller")==0) + classiccontroller=1; + + if (strcmp(gameinfo.accessories[i+1],"nunchuk")==0) + {nunchuk=1;} + + if (strcmp(gameinfo.accessories[i+1],"guitar")==0) + guitar=1; + + if (strcmp(gameinfo.accessories_required[i],"drums")==0) + drums=1; + + if (strcmp(gameinfo.accessories_required[i],"dancepad")==0) + dancepad=1; + + if (strcmp(gameinfo.accessories_required[i],"motionplus")==0) + motionplus=1; + + if (strcmp(gameinfo.accessories_required[i],"wheel")==0) + wheel=1; + + if (strcmp(gameinfo.accessories_required[i],"balanceboard")==0) + balanceboard=1; + + if (strcmp(gameinfo.accessories_required[i],"microphone")==0) + microphone=1; + + if (strcmp(gameinfo.accessories_required[i],"gamecube")==0) + gamecube=1; + } + + + + + dialogBoxImg1 = new GuiImage(&dialogBox1); + dialogBoxImg1->SetAlignment(0,3); + dialogBoxImg1->SetPosition(0,0); + + dialogBoxImg2 = new GuiImage(&dialogBox2); + dialogBoxImg2->SetAlignment(0,3); + dialogBoxImg2->SetPosition(150,0); + + dialogBoxImg3 = new GuiImage(&dialogBox3); + dialogBoxImg3->SetAlignment(0,3); + dialogBoxImg3->SetPosition(300,0); + + dialogBoxImg4 = new GuiImage(&dialogBox4); + dialogBoxImg4->SetAlignment(0,3); + dialogBoxImg4->SetPosition(450,0); + + + gameinfoWindow.Append(dialogBoxImg1); + gameinfoWindow.Append(dialogBoxImg2); + gameinfoWindow.Append(dialogBoxImg3); + gameinfoWindow.Append(dialogBoxImg4); +// gameinfoWindow.Append(&titleTxt); + + //coverart + //snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, IDfull); + // cover = new GuiImageData(imgPath,0); //load short id + // if (!cover->GetImage()) //if could not load the short id image + // { + // delete cover; + snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, ID); + cover = new GuiImageData(imgPath, 0); //load full id image + if (!cover->GetImage()) + { + delete cover; + snprintf(imgPath, sizeof(imgPath), "%snoimage.png", Settings.covers_path); + cover = new GuiImageData(imgPath, nocover_png); //load no image + } + // } + + // if (coverImg) + // { + delete coverImg; + coverImg = NULL; + // } + coverImg = new GuiImage(cover); + coverImg->SetWidescreen(CFG.widescreen); + coverImg->SetPosition(15,30); + gameinfoWindow.Append(coverImg); + + // # of players + if (strcmp(gameinfo.players,"") != 0) { + playersImgData = new GuiImageData(Wiimote1_png); + if (atoi(gameinfo.players)>1){ + playersImgData= new GuiImageData(Wiimote2_png);} + if (atoi(gameinfo.players)>2){ + playersImgData= new GuiImageData(Wiimote4_png);} + + playersImg = new GuiImage(playersImgData); + playersImg->SetWidescreen(CFG.widescreen); + playersImg->SetPosition(intputX , inputY); + playersImg->SetAlignment(0,4); + gameinfoWindow.Append(playersImg); + intputX += (CFG.widescreen ? playersImg->GetWidth() * .8 : playersImg->GetWidth()); + } + + //draw the inupt types for this game + if (nunchuk==1){ + nunchuckImg = new GuiImage(nunchuckImgData); + nunchuckImg->SetWidescreen(CFG.widescreen); + nunchuckImg->SetPosition(intputX , inputY); + nunchuckImg->SetAlignment(0,4); + gameinfoWindow.Append(nunchuckImg); + intputX += (CFG.widescreen ? nunchuckImg->GetWidth() * .8 : nunchuckImg->GetWidth());} + + if (classiccontroller==1){ + classiccontrollerImg = new GuiImage(classiccontrollerImgData); + classiccontrollerImg->SetWidescreen(CFG.widescreen); + classiccontrollerImg->SetPosition(intputX , inputY); + classiccontrollerImg->SetAlignment(0,4); + gameinfoWindow.Append(classiccontrollerImg); + intputX += (CFG.widescreen ? classiccontrollerImg->GetWidth() * .8 : classiccontrollerImg->GetWidth());} + + if (gamecube==1){ + gcImg = new GuiImage(gamecubeImgData); + gcImg->SetWidescreen(CFG.widescreen); + gcImg->SetPosition(intputX , inputY); + gcImg->SetAlignment(0,4); + gameinfoWindow.Append(gcImg); + intputX += (CFG.widescreen ? gcImg->GetWidth() * .8 : gcImg->GetWidth());} + + if (wheel==1){ + wheelImg = new GuiImage(wheelImgData); + wheelImg->SetWidescreen(CFG.widescreen); + wheelImg->SetPosition(intputX , inputY); + wheelImg->SetAlignment(0,4); + gameinfoWindow.Append(wheelImg); + intputX += (CFG.widescreen ? wheelImg->GetWidth() * .8 : wheelImg->GetWidth());} + + if (guitar==1){ + guitarImg = new GuiImage(guitarImgData); + guitarImg->SetWidescreen(CFG.widescreen); + guitarImg->SetPosition(intputX , inputY); + guitarImg->SetAlignment(0,4); + gameinfoWindow.Append(guitarImg); + intputX += (CFG.widescreen ? guitarImg->GetWidth() * .8 : guitarImg->GetWidth());} + + if (drums==1){ + drumsImg = new GuiImage(drumsImgData); + drumsImg->SetWidescreen(CFG.widescreen); + drumsImg->SetPosition(intputX , inputY); + drumsImg->SetAlignment(0,4); + gameinfoWindow.Append(drumsImg); + intputX += (CFG.widescreen ? drumsImg->GetWidth() * .8 : drumsImg->GetWidth());} + + if (microphone==1){ + microphoneImg = new GuiImage(microphoneImgData); + microphoneImg->SetWidescreen(CFG.widescreen); + microphoneImg->SetPosition(intputX , inputY); + microphoneImg->SetAlignment(0,4); + gameinfoWindow.Append(microphoneImg); + intputX += (CFG.widescreen ? microphoneImg->GetWidth() * .8 : microphoneImg->GetWidth());} + + if (dancepad==1){ + dancepadImg = new GuiImage(dancepadImgData); + dancepadImg->SetWidescreen(CFG.widescreen); + dancepadImg->SetPosition(intputX , inputY); + dancepadImg->SetAlignment(0,4); + gameinfoWindow.Append(dancepadImg); + intputX += (CFG.widescreen ? dancepadImg->GetWidth() * .8 : dancepadImg->GetWidth());} + + if (motionplus==1){ + motionplusImg = new GuiImage(motionplusImgData); + motionplusImg->SetWidescreen(CFG.widescreen); + motionplusImg->SetPosition(intputX , inputY); + motionplusImg->SetAlignment(0,4); + gameinfoWindow.Append(motionplusImg); + intputX += (CFG.widescreen ? motionplusImg->GetWidth() * .8 : motionplusImg->GetWidth());} + + + + + // # online players + if (strcmp(gameinfo.wifiplayers,"") != 0) { + wifiplayersImgData = new GuiImageData(wifi1_png); + if (atoi(gameinfo.wifiplayers)>1){ + wifiplayersImgData= new GuiImageData(wifi2_png);} + if (atoi(gameinfo.wifiplayers)>2){ + wifiplayersImgData= new GuiImageData(wifi4_png);} + + if (atoi(gameinfo.wifiplayers)>4){ + wifiplayersImgData= new GuiImageData(wifi8_png);} + + wifiplayersImg = new GuiImage(wifiplayersImgData); + wifiplayersImg->SetWidescreen(CFG.widescreen); + wifiplayersImg->SetPosition(intputX , inputY); + wifiplayersImg->SetAlignment(0,4); + gameinfoWindow.Append(wifiplayersImg); + intputX += (CFG.widescreen ? wifiplayersImg->GetWidth() * .8 : wifiplayersImg->GetWidth()); + } + + // ratings + if (strcmp(gameinfo.ratingtype,"") !=0){ + if (strcmp(gameinfo.ratingtype,"ESRB")==0) { + if (strcmp(gameinfo.ratingvalueESRB,"EC")==0) + ratingImgData = new GuiImageData(esrb_ec_png); + else if (strcmp(gameinfo.ratingvalueESRB,"E")==0) + ratingImgData = new GuiImageData(esrb_e_png); + else if (strcmp(gameinfo.ratingvalueESRB,"E10+")==0) + ratingImgData = new GuiImageData(esrb_eten_png); + else if (strcmp(gameinfo.ratingvalueESRB,"T")==0) + ratingImgData = new GuiImageData(esrb_t_png); + else if (strcmp(gameinfo.ratingvalueESRB,"M")==0) + ratingImgData = new GuiImageData(esrb_m_png); + else if (strcmp(gameinfo.ratingvalueESRB,"AO")==0) + ratingImgData = new GuiImageData(esrb_ao_png); + else {ratingImgData = new GuiImageData(norating_png);} + } //there are 2 values here cause some countries are stupid and + else if (strcmp(gameinfo.ratingtype,"PEGI")==0) {//can't use the same as everybody else + if ((strcmp(gameinfo.ratingvaluePEGI,"3")==0)||(strcmp(gameinfo.ratingvaluePEGI,"4")==0)) + ratingImgData = new GuiImageData(pegi_3_png); + else if ((strcmp(gameinfo.ratingvaluePEGI,"7")==0)||(strcmp(gameinfo.ratingvaluePEGI,"7")==0)) + ratingImgData = new GuiImageData(pegi_7_png); + else if (strcmp(gameinfo.ratingvaluePEGI,"12")==0) + ratingImgData = new GuiImageData(pegi_12_png); + else if ((strcmp(gameinfo.ratingvaluePEGI,"16")==0)||(strcmp(gameinfo.ratingvaluePEGI,"15")==0)) + ratingImgData = new GuiImageData(pegi_16_png); + else if (strcmp(gameinfo.ratingvaluePEGI,"18")==0) + ratingImgData = new GuiImageData(pegi_18_png); + else {ratingImgData = new GuiImageData(norating_png);} + } + + else if (strcmp(gameinfo.ratingtype,"CERO")==0) { + if (strcmp(gameinfo.ratingvalueCERO,"A")==0) + ratingImgData = new GuiImageData(cero_a_png); + //ratingImgData = new GuiImageData(cero_b_png); + else if (strcmp(gameinfo.ratingvalueCERO,"B")==0) + ratingImgData = new GuiImageData(cero_b_png); + else if (strcmp(gameinfo.ratingvalueCERO,"C")==0) + ratingImgData = new GuiImageData(cero_c_png); + else if (strcmp(gameinfo.ratingvalueCERO,"D")==0) + ratingImgData = new GuiImageData(cero_d_png); + else if (strcmp(gameinfo.ratingvalueCERO,"Z")==0) + ratingImgData = new GuiImageData(cero_z_png); + else {ratingImgData = new GuiImageData(norating_png);} + } + + else {ratingImgData = new GuiImageData(norating_png);} + ratingImg = new GuiImage(ratingImgData); + ratingImg->SetWidescreen(CFG.widescreen); + ratingImg->SetPosition(-25 , inputY); + ratingImg->SetAlignment(1,4); + gameinfoWindow.Append(ratingImg); + intputX += (CFG.widescreen ? ratingImg->GetWidth() * .8 : ratingImg->GetWidth()); + + } + +//////////debugging line +/* snprintf(linebuf, sizeof(linebuf), "%s %s %s %s %i %s",gameinfo.ratingtype ,gameinfo.ratingvalueESRB,gameinfo.ratingvaluePEGI,gameinfo.ratingvalueCERO, ass,LANGUAGE.released); + + for (int i=0;strcmp(gameinfo.accessories_required[i+1],"") != 0;i++) + { + snprintf(linebuf, sizeof(linebuf), "%s %s",linebuf, gameinfo.accessories_required[i+1]); + } + +debugTxt = new GuiText(linebuf, 18, (GXColor){0,0,0, 255}); + debugTxt->SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); debugTxt->SetPosition(0,0); + gameinfoWindow.Append(debugTxt);*/ + + if (strcmp(gameinfo.title,"") != 0) + {snprintf(linebuf, sizeof(linebuf), "%s",gameinfo.title); + titleTxt = new GuiText(linebuf, 22, (GXColor){0,0,0, 255}); + if (titleTxt->GetWidth()>300)titleTxt->SetFontSize(18); + titleTxt->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); titleTxt->SetPosition(txtXOffset,12+y); y+=24; + gameinfoWindow.Append(titleTxt);} + + + + //date + snprintf(linebuf2, sizeof(linebuf2), " "); + if (strcmp(gameinfo.day,"") != 0) + {snprintf(linebuf2, sizeof(linebuf2), "%s ", gameinfo.day);} + if (strcmp(gameinfo.month,"") != 0){ + switch (atoi(gameinfo.month)) + { + case 1: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, LANGUAGE.january); + break; + case 2: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, LANGUAGE.february); + break; + case 3: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, LANGUAGE.march); + break; + case 4: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, LANGUAGE.april); + break; + case 5: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, LANGUAGE.may); + break; + case 6: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, LANGUAGE.june); + break; + case 7: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, LANGUAGE.july); + break; + case 8: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, LANGUAGE.august); + break; + case 9: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, LANGUAGE.september); + break; + case 10: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, LANGUAGE.october); + break; + case 11: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, LANGUAGE.november); + break; + case 12: + snprintf(linebuf2, sizeof(linebuf2), "%s%s ", linebuf2, LANGUAGE.december); + break; + } + } + if (strcmp(gameinfo.year,"") != 0)newline=1; + {snprintf(linebuf, sizeof(linebuf), "%s : %s%s", LANGUAGE.released, linebuf2, gameinfo.year); + releasedTxt = new GuiText(linebuf, 16, (GXColor){0,0,0, 255}); + if (releasedTxt->GetWidth()>300) newline=2; + releasedTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); releasedTxt->SetPosition(-17,12+y); y+=(20 * newline);newline=1; + gameinfoWindow.Append(releasedTxt);} + //genre + if (strcmp(gameinfo.genre,"") != 0) + {snprintf(linebuf, sizeof(linebuf), "%s", gameinfo.genre); + genreTxt = new GuiText(linebuf, 16, (GXColor){0,0,0, 255}); + if (genreTxt->GetWidth()>300) newline=2; + genreTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); genreTxt->SetPosition(205,12+y1); y1+=(25 * newline);newline=1; + gameinfoWindow.Append(genreTxt);} + + //developer + if (strcmp(gameinfo.developer,"") != 0 && strcmp(gameinfo.developer,gameinfo.publisher) != 0) + {snprintf(linebuf, sizeof(linebuf), "%s %s", LANGUAGE.developedby, gameinfo.developer); + developerTxt = new GuiText(linebuf, 16, (GXColor){0,0,0, 255}); + if (developerTxt->GetWidth()>250) newline=2; + developerTxt->SetMaxWidth(250,GuiText::WRAP); + developerTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); developerTxt->SetPosition(-17,12+y); y+=(40 * newline);newline=1; + gameinfoWindow.Append(developerTxt);} + + //publisher + if (strcmp(gameinfo.publisher,"") != 0) + {snprintf(linebuf, sizeof(linebuf), "%s %s", LANGUAGE.publishedby, gameinfo.publisher); + publisherTxt = new GuiText(linebuf, 16, (GXColor){0,0,0, 255}); + if (publisherTxt->GetWidth()>250) newline=2; + publisherTxt->SetMaxWidth(250,GuiText::WRAP); + publisherTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); publisherTxt->SetPosition(-17,12+y); y+=(20 * newline);newline=1; + gameinfoWindow.Append(publisherTxt);} + + //don't bother us txt + snprintf(linebuf, sizeof(linebuf), "Don't bother the USB Loader QX Team about errors in this file."); + betaTxt = new GuiText(linebuf, 14, (GXColor){0,0,0, 255}); + betaTxt->SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); betaTxt->SetPosition(-17,-20);// + gameinfoWindow.Append(betaTxt); + snprintf(linebuf, sizeof(linebuf), "A site will be available in the near nuture to submit changes."); + beta1Txt = new GuiText(linebuf, 14, (GXColor){0,0,0, 255}); + beta1Txt->SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); beta1Txt->SetPosition(-17,-10); + gameinfoWindow.Append(beta1Txt); + + // WiFi Shit commented out cause it has a code dump in it still + /*if (strcmp(gameinfo.wififeatures[0],"") != 0){ + snprintf(linebuf, sizeof(linebuf), "%s:",LANGUAGE.wififeatures); + wifiTxt[0] = new GuiText(linebuf, 16, (GXColor){0,0,0, 255}); + wifiTxt[0]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); wifiTxt[0]->SetPosition(205,12+y); y+=(20 * newline); + gameinfoWindow.Append(wifiTxt[0]);} + for (int i=1;strcmp(gameinfo.wififeatures[i],"") != 0;i++) + { + snprintf(linebuf, sizeof(linebuf), "%s",gameinfo.wififeatures[i]); + wifiTxt[i] = new GuiText(linebuf, 16, (GXColor){0,0,0, 255}); + wifiTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); wifiTxt[i]->SetPosition(210,12+y); y+=(20 * newline); + gameinfoWindow.Append(wifiTxt[i]);}*/ + + //synopsis + if (strcmp(gameinfo.synopsis,"") != 0) + {snprintf(linebuf, sizeof(linebuf), "%s", gameinfo.synopsis); + synopsisTxt = new GuiText(linebuf, 16, (GXColor){0,0,0, 255}); + synopsisTxt->SetMaxWidth(350,GuiText::WRAP); + synopsisTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); synopsisTxt->SetPosition(0,0); + dialogBoxImg11 = new GuiImage(&dialogBox1); + dialogBoxImg11->SetAlignment(0,3); + dialogBoxImg11->SetPosition(0,0); + + dialogBoxImg22 = new GuiImage(&dialogBox2); + dialogBoxImg22->SetAlignment(0,3); + dialogBoxImg22->SetPosition(150,0); + + dialogBoxImg33 = new GuiImage(&dialogBox3); + dialogBoxImg33->SetAlignment(0,3); + dialogBoxImg33->SetPosition(300,0); + + dialogBoxImg44 = new GuiImage(&dialogBox4); + dialogBoxImg44->SetAlignment(0,3); + dialogBoxImg44->SetPosition(450,0); + + + gameinfoWindow2.Append(dialogBoxImg11); + gameinfoWindow2.Append(dialogBoxImg22); + gameinfoWindow2.Append(dialogBoxImg33); + gameinfoWindow2.Append(dialogBoxImg44); + + txtWindow.Append(synopsisTxt); + coverImg2 = new GuiImage(cover); + coverImg2->SetWidescreen(CFG.widescreen); + coverImg2->SetPosition(15,30); + gameinfoWindow2.Append(coverImg2); + gameinfoWindow2.Append(&txtWindow); + } + + + + gameinfoWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); + HaltGui(); + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&gameinfoWindow); + mainWindow->ChangeFocus(&gameinfoWindow); + ResumeGui(); + + while(choice == -1) + { + VIDEO_WaitVSync(); + if(shutdown == 1) + { + wiilight(0); + Sys_Shutdown(); + } + if(reset == 1) + Sys_Reboot(); + + + if ((backBtn.GetState()==STATE_CLICKED)||(backBtn.GetState()==STATE_HELD)){ + choice=1; + eatADick(); + synopsisTxt = NULL; + break;} + + else if (((nextBtn.GetState()==STATE_CLICKED)||(nextBtn.GetState()==STATE_HELD))&& + (strcmp(gameinfo.synopsis,"") != 0)){ + + if (page==1){ + nextBtn.ResetState(); + HaltGui(); + gameinfoWindow.SetVisible(false); + gameinfoWindow2.SetVisible(true); + coverImg->SetPosition(15,30); + + backBtn.SetClickable(false); + gameinfoWindow2.Append(&nextBtn); + mainWindow->Append(&gameinfoWindow2); + ResumeGui(); + page=2; + } + else { + nextBtn.ResetState(); + HaltGui(); + backBtn.SetClickable(true); + gameinfoWindow2.SetVisible(false); + gameinfoWindow.SetVisible(true); + gameinfoWindow.Append(&backBtn); + gameinfoWindow.Append(&nextBtn); + mainWindow->Remove(&gameinfoWindow2); + ResumeGui(); + page=1; + } + nextBtn.ResetState(); + } + } + if (page==1){ + gameinfoWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + while(gameinfoWindow.GetEffect() > 0) usleep(50); + HaltGui(); + mainWindow->Remove(&gameinfoWindow); + mainWindow->SetState(STATE_DEFAULT); + ResumeGui();} + else { + gameinfoWindow2.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); + while(gameinfoWindow2.GetEffect() > 0) usleep(50); + HaltGui(); + mainWindow->Remove(&gameinfoWindow2); + mainWindow->SetState(STATE_DEFAULT); + ResumeGui();} + return choice; +} + diff --git a/source/gameinfo.h b/source/gameinfo.h new file mode 100644 index 00000000..cbdda2f7 --- /dev/null +++ b/source/gameinfo.h @@ -0,0 +1,14 @@ +/**************************************************************************** + * PromptWindows + * USB Loader GX 2009 + * + * PromptWindows.h + ***************************************************************************/ + +#ifndef _GAMEINFO_H_ +#define _GAMEINFO_H_ + + +int showGameInfo(char *ID, u8 *headerID); +void eatADick(); +#endif diff --git a/source/images/Wiimote1.png b/source/images/Wiimote1.png new file mode 100644 index 00000000..de55d53f Binary files /dev/null and b/source/images/Wiimote1.png differ diff --git a/source/images/Wiimote2.png b/source/images/Wiimote2.png new file mode 100644 index 00000000..3eee743d Binary files /dev/null and b/source/images/Wiimote2.png differ diff --git a/source/images/Wiimote3.png b/source/images/Wiimote3.png new file mode 100644 index 00000000..bb71db4d Binary files /dev/null and b/source/images/Wiimote3.png differ diff --git a/source/images/Wiimote4.png b/source/images/Wiimote4.png new file mode 100644 index 00000000..be402077 Binary files /dev/null and b/source/images/Wiimote4.png differ diff --git a/source/images/balanceboard.png b/source/images/balanceboard.png new file mode 100644 index 00000000..df79282d Binary files /dev/null and b/source/images/balanceboard.png differ diff --git a/source/images/balanceboardR.png b/source/images/balanceboardR.png new file mode 100644 index 00000000..63d7db80 Binary files /dev/null and b/source/images/balanceboardR.png differ diff --git a/source/images/cero_a.png b/source/images/cero_a.png new file mode 100644 index 00000000..a99dbd90 Binary files /dev/null and b/source/images/cero_a.png differ diff --git a/source/images/cero_b.png b/source/images/cero_b.png new file mode 100644 index 00000000..c6354326 Binary files /dev/null and b/source/images/cero_b.png differ diff --git a/source/images/cero_c.png b/source/images/cero_c.png new file mode 100644 index 00000000..905175ac Binary files /dev/null and b/source/images/cero_c.png differ diff --git a/source/images/cero_d.png b/source/images/cero_d.png new file mode 100644 index 00000000..21b509f2 Binary files /dev/null and b/source/images/cero_d.png differ diff --git a/source/images/cero_z.png b/source/images/cero_z.png new file mode 100644 index 00000000..d981c1ca Binary files /dev/null and b/source/images/cero_z.png differ diff --git a/source/images/classiccontroller.png b/source/images/classiccontroller.png new file mode 100644 index 00000000..0efcf798 Binary files /dev/null and b/source/images/classiccontroller.png differ diff --git a/source/images/classiccontrollerR.png b/source/images/classiccontrollerR.png new file mode 100644 index 00000000..af388223 Binary files /dev/null and b/source/images/classiccontrollerR.png differ diff --git a/source/images/dancepad.png b/source/images/dancepad.png new file mode 100644 index 00000000..c8e815a4 Binary files /dev/null and b/source/images/dancepad.png differ diff --git a/source/images/dancepadR.png b/source/images/dancepadR.png new file mode 100644 index 00000000..40b19732 Binary files /dev/null and b/source/images/dancepadR.png differ diff --git a/source/images/drums.png b/source/images/drums.png new file mode 100644 index 00000000..b675fbc9 Binary files /dev/null and b/source/images/drums.png differ diff --git a/source/images/drumsR.png b/source/images/drumsR.png new file mode 100644 index 00000000..a0da1045 Binary files /dev/null and b/source/images/drumsR.png differ diff --git a/source/images/esrb_ao.png b/source/images/esrb_ao.png new file mode 100644 index 00000000..8c31f2ac Binary files /dev/null and b/source/images/esrb_ao.png differ diff --git a/source/images/esrb_e.png b/source/images/esrb_e.png new file mode 100644 index 00000000..f8df3d6d Binary files /dev/null and b/source/images/esrb_e.png differ diff --git a/source/images/esrb_ec.png b/source/images/esrb_ec.png new file mode 100644 index 00000000..42bdd4f5 Binary files /dev/null and b/source/images/esrb_ec.png differ diff --git a/source/images/esrb_eten.png b/source/images/esrb_eten.png new file mode 100644 index 00000000..e1cc30d0 Binary files /dev/null and b/source/images/esrb_eten.png differ diff --git a/source/images/esrb_m.png b/source/images/esrb_m.png new file mode 100644 index 00000000..1bf2bf5d Binary files /dev/null and b/source/images/esrb_m.png differ diff --git a/source/images/esrb_t.png b/source/images/esrb_t.png new file mode 100644 index 00000000..f316e863 Binary files /dev/null and b/source/images/esrb_t.png differ diff --git a/source/images/gameinfo1.png b/source/images/gameinfo1.png new file mode 100644 index 00000000..97aac84a Binary files /dev/null and b/source/images/gameinfo1.png differ diff --git a/source/images/gameinfo1a.png b/source/images/gameinfo1a.png new file mode 100644 index 00000000..11d02f65 Binary files /dev/null and b/source/images/gameinfo1a.png differ diff --git a/source/images/gameinfo2.png b/source/images/gameinfo2.png new file mode 100644 index 00000000..5bf5add2 Binary files /dev/null and b/source/images/gameinfo2.png differ diff --git a/source/images/gameinfo2a.png b/source/images/gameinfo2a.png new file mode 100644 index 00000000..dd574ab2 Binary files /dev/null and b/source/images/gameinfo2a.png differ diff --git a/source/images/gcncontroller.png b/source/images/gcncontroller.png new file mode 100644 index 00000000..e4a64a10 Binary files /dev/null and b/source/images/gcncontroller.png differ diff --git a/source/images/gcncontrollerR.png b/source/images/gcncontrollerR.png new file mode 100644 index 00000000..772cdf8f Binary files /dev/null and b/source/images/gcncontrollerR.png differ diff --git a/source/images/guitar.png b/source/images/guitar.png new file mode 100644 index 00000000..00072694 Binary files /dev/null and b/source/images/guitar.png differ diff --git a/source/images/guitarR.png b/source/images/guitarR.png new file mode 100644 index 00000000..80df5234 Binary files /dev/null and b/source/images/guitarR.png differ diff --git a/source/images/microphone.png b/source/images/microphone.png new file mode 100644 index 00000000..f399d8cb Binary files /dev/null and b/source/images/microphone.png differ diff --git a/source/images/microphoneR.png b/source/images/microphoneR.png new file mode 100644 index 00000000..b92a7c92 Binary files /dev/null and b/source/images/microphoneR.png differ diff --git a/source/images/motionplus.png b/source/images/motionplus.png new file mode 100644 index 00000000..4ab1e32e Binary files /dev/null and b/source/images/motionplus.png differ diff --git a/source/images/motionplusR.png b/source/images/motionplusR.png new file mode 100644 index 00000000..fbf23b4d Binary files /dev/null and b/source/images/motionplusR.png differ diff --git a/source/images/norating.png b/source/images/norating.png new file mode 100644 index 00000000..2b5248ee Binary files /dev/null and b/source/images/norating.png differ diff --git a/source/images/nunchuck.png b/source/images/nunchuck.png new file mode 100644 index 00000000..aa056b8c Binary files /dev/null and b/source/images/nunchuck.png differ diff --git a/source/images/nunchuckR.png b/source/images/nunchuckR.png new file mode 100644 index 00000000..fbbf9b9b Binary files /dev/null and b/source/images/nunchuckR.png differ diff --git a/source/images/pegi_12.png b/source/images/pegi_12.png new file mode 100644 index 00000000..1f20221f Binary files /dev/null and b/source/images/pegi_12.png differ diff --git a/source/images/pegi_16.png b/source/images/pegi_16.png new file mode 100644 index 00000000..c44be3a3 Binary files /dev/null and b/source/images/pegi_16.png differ diff --git a/source/images/pegi_18.png b/source/images/pegi_18.png new file mode 100644 index 00000000..da086b3a Binary files /dev/null and b/source/images/pegi_18.png differ diff --git a/source/images/pegi_3.png b/source/images/pegi_3.png new file mode 100644 index 00000000..ce22c69e Binary files /dev/null and b/source/images/pegi_3.png differ diff --git a/source/images/pegi_7.png b/source/images/pegi_7.png new file mode 100644 index 00000000..402aaee3 Binary files /dev/null and b/source/images/pegi_7.png differ diff --git a/source/images/wheel.png b/source/images/wheel.png new file mode 100644 index 00000000..ba5597e9 Binary files /dev/null and b/source/images/wheel.png differ diff --git a/source/images/wheelR.png b/source/images/wheelR.png new file mode 100644 index 00000000..041bcf14 Binary files /dev/null and b/source/images/wheelR.png differ diff --git a/source/images/wifi1.png b/source/images/wifi1.png new file mode 100644 index 00000000..ea53e701 Binary files /dev/null and b/source/images/wifi1.png differ diff --git a/source/images/wifi2.png b/source/images/wifi2.png new file mode 100644 index 00000000..f0cd1580 Binary files /dev/null and b/source/images/wifi2.png differ diff --git a/source/images/wifi3.png b/source/images/wifi3.png new file mode 100644 index 00000000..1c9b1f57 Binary files /dev/null and b/source/images/wifi3.png differ diff --git a/source/images/wifi4.png b/source/images/wifi4.png new file mode 100644 index 00000000..bb3bbb44 Binary files /dev/null and b/source/images/wifi4.png differ diff --git a/source/images/wifi8.png b/source/images/wifi8.png new file mode 100644 index 00000000..10129f9e Binary files /dev/null and b/source/images/wifi8.png differ diff --git a/source/language.c b/source/language.c index 8d6913fe..138b22ea 100644 --- a/source/language.c +++ b/source/language.c @@ -185,6 +185,7 @@ snprintf(LANGUAGE.RenameGameonWBFS, sizeof(LANGUAGE.RenameGameonWBFS), "Rename G snprintf(LANGUAGE.Restart, sizeof(LANGUAGE.Restart), "Restart"); snprintf(LANGUAGE.Restarting, sizeof(LANGUAGE.Restarting), "Restarting..."); snprintf(LANGUAGE.Return, sizeof(LANGUAGE.Return), "Return"); +snprintf(LANGUAGE.released, sizeof(LANGUAGE.released), "Released"); snprintf(LANGUAGE.ReturntoWiiMenu, sizeof(LANGUAGE.ReturntoWiiMenu), "Return to Wii Menu"); snprintf(LANGUAGE.Right, sizeof(LANGUAGE.Right), "Right"); snprintf(LANGUAGE.Rumble, sizeof(LANGUAGE.Rumble), "Rumble"); @@ -255,6 +256,21 @@ snprintf(LANGUAGE.Dutch, sizeof(LANGUAGE.Dutch), "Dutch"); snprintf(LANGUAGE.SChinese, sizeof(LANGUAGE.SChinese), "SChinese"); snprintf(LANGUAGE.TChinese, sizeof(LANGUAGE.TChinese), "TChinese"); snprintf(LANGUAGE.Korean, sizeof(LANGUAGE.Korean), "Korean"); +snprintf(LANGUAGE.january, sizeof(LANGUAGE.january), "Jan"); +snprintf(LANGUAGE.february, sizeof(LANGUAGE.february), "Feb"); +snprintf(LANGUAGE.march, sizeof(LANGUAGE.march), "Mar"); +snprintf(LANGUAGE.april, sizeof(LANGUAGE.april), "Apr"); +snprintf(LANGUAGE.may, sizeof(LANGUAGE.may), "May"); +snprintf(LANGUAGE.june, sizeof(LANGUAGE.june), "June"); +snprintf(LANGUAGE.july, sizeof(LANGUAGE.july), "July"); +snprintf(LANGUAGE.august, sizeof(LANGUAGE.august), "Aug"); +snprintf(LANGUAGE.september, sizeof(LANGUAGE.september), "Sept"); +snprintf(LANGUAGE.october, sizeof(LANGUAGE.october), "Oct"); +snprintf(LANGUAGE.november, sizeof(LANGUAGE.november), "Nov"); +snprintf(LANGUAGE.december, sizeof(LANGUAGE.december), "Dec"); +snprintf(LANGUAGE.developedby, sizeof(LANGUAGE.developedby), "Developed by"); +snprintf(LANGUAGE.publishedby, sizeof(LANGUAGE.publishedby), "Published by"); +snprintf(LANGUAGE.wififeatures, sizeof(LANGUAGE.wififeatures), "WiFi Features"); }; diff --git a/source/language.h b/source/language.h index 5053cf7b..3076afa6 100644 --- a/source/language.h +++ b/source/language.h @@ -10,7 +10,25 @@ extern "C" #endif struct LANGUAGE -{ +{ + char released[15]; + char publishedby[25]; + char developedby[25]; + char january[15]; + char february[15]; + char march[15]; + char april[15]; + char may[15]; + char june[15]; + char july[15]; + char august[15]; + char september[15]; + char october[15]; + char november[15]; + char december[15]; + char wififeatures[20]; + + char t3Covers[50]; char addToFavorite[50]; char all[30]; diff --git a/source/menu.cpp b/source/menu.cpp index 418e8d91..77544a0e 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -31,6 +31,9 @@ #include "getentries.h" #include "PromptWindows.h" #include "Settings.h" +#include "gameinfo.h" + +//#include "xml.h" /* XML - Lustar*/ #define MAX_CHARACTERS 38 #define GB_SIZE 1073741824.0 @@ -165,6 +168,7 @@ void ExitGUIThreads() LWP_JoinThread(guithread, NULL); } + /**************************************************************************** * MenuDiscList ***************************************************************************/ @@ -178,437 +182,452 @@ static int MenuDiscList() int datagB =0; int dataed = -1; int cosa=0,sina=0; + int selectImg1 = 0; + char ID[4]; + char IDfull[7]; + + + datagB=0; + int menu = MENU_NONE, dataef=0; + char imgPath[100]; + __Menu_GetEntries(); - datagB=0; - int menu = MENU_NONE, dataef=0; - char imgPath[100]; - __Menu_GetEntries(); + f32 freespace, used, size = 0.0; + u32 nolist; + char text[MAX_CHARACTERS + 4]; + int choice = 0, selectedold = 100; + s32 ret; - f32 freespace, used, size = 0.0; - u32 nolist; - char text[MAX_CHARACTERS + 4]; - int choice = 0, selectedold = 100; - s32 ret; + //CLOCK + struct tm * timeinfo; + char theTime[80]=""; + time_t lastrawtime=0; - //CLOCK - struct tm * timeinfo; - char theTime[80]=""; - time_t lastrawtime=0; - - WBFS_DiskSpace(&used, &freespace); + WBFS_DiskSpace(&used, &freespace); if (!gameCnt) { //if there is no list of games to display nolist = 1; } - 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); - snprintf(imgPath, sizeof(imgPath), "%sbutton_install.png", CFG.theme_path); - GuiImageData btnInstall(imgPath, button_install_png); - snprintf(imgPath, sizeof(imgPath), "%sbutton_install_over.png", CFG.theme_path); - GuiImageData btnInstallOver(imgPath, button_install_over_png); + 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); - snprintf(imgPath, sizeof(imgPath), "%ssettings_button.png", CFG.theme_path); - GuiImageData btnSettings(imgPath, settings_button_png); - snprintf(imgPath, sizeof(imgPath), "%ssettings_button_over.png", CFG.theme_path); - GuiImageData btnSettingsOver(imgPath, settings_button_over_png); - GuiImageData dataID(&data1); + snprintf(imgPath, sizeof(imgPath), "%sbutton_install.png", CFG.theme_path); + GuiImageData btnInstall(imgPath, button_install_png); + snprintf(imgPath, sizeof(imgPath), "%sbutton_install_over.png", CFG.theme_path); + GuiImageData btnInstallOver(imgPath, button_install_over_png); - snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff.png", CFG.theme_path); - GuiImageData btnpwroff(imgPath, wiimote_poweroff_png); - snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff_over.png", CFG.theme_path); - GuiImageData btnpwroffOver(imgPath, wiimote_poweroff_over_png); - snprintf(imgPath, sizeof(imgPath), "%smenu_button.png", CFG.theme_path); - GuiImageData btnhome(imgPath, menu_button_png); - snprintf(imgPath, sizeof(imgPath), "%smenu_button_over.png", CFG.theme_path); - GuiImageData btnhomeOver(imgPath, menu_button_over_png); - snprintf(imgPath, sizeof(imgPath), "%sSDcard.png", CFG.theme_path); - GuiImageData btnsdcard(imgPath, sdcard_png); + snprintf(imgPath, sizeof(imgPath), "%ssettings_button.png", CFG.theme_path); + GuiImageData btnSettings(imgPath, settings_button_png); + snprintf(imgPath, sizeof(imgPath), "%ssettings_button_over.png", CFG.theme_path); + GuiImageData btnSettingsOver(imgPath, settings_button_over_png); + GuiImageData dataID(&data1); - snprintf(imgPath, sizeof(imgPath), "%sbattery.png", CFG.theme_path); - GuiImageData battery(imgPath, battery_png); - snprintf(imgPath, sizeof(imgPath), "%sbattery_red.png", CFG.theme_path); - GuiImageData batteryRed(imgPath, battery_red_png); - snprintf(imgPath, sizeof(imgPath), "%sbattery_bar.png", CFG.theme_path); - GuiImageData batteryBar(imgPath, battery_bar_png); + snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff.png", CFG.theme_path); + GuiImageData btnpwroff(imgPath, wiimote_poweroff_png); + snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff_over.png", CFG.theme_path); + GuiImageData btnpwroffOver(imgPath, wiimote_poweroff_over_png); + snprintf(imgPath, sizeof(imgPath), "%smenu_button.png", CFG.theme_path); + GuiImageData btnhome(imgPath, menu_button_png); + snprintf(imgPath, sizeof(imgPath), "%smenu_button_over.png", CFG.theme_path); + GuiImageData btnhomeOver(imgPath, menu_button_over_png); + snprintf(imgPath, sizeof(imgPath), "%sSDcard.png", CFG.theme_path); + GuiImageData btnsdcard(imgPath, sdcard_png); + + snprintf(imgPath, sizeof(imgPath), "%sbattery.png", CFG.theme_path); + GuiImageData battery(imgPath, battery_png); + snprintf(imgPath, sizeof(imgPath), "%sbattery_red.png", CFG.theme_path); + GuiImageData batteryRed(imgPath, battery_red_png); + snprintf(imgPath, sizeof(imgPath), "%sbattery_bar.png", CFG.theme_path); + GuiImageData batteryBar(imgPath, battery_bar_png); snprintf(imgPath, sizeof(imgPath), "%sfavIcon.png", CFG.theme_path); - GuiImageData imgfavIcon(imgPath, favIcon_png); + GuiImageData imgfavIcon(imgPath, favIcon_png); snprintf(imgPath, sizeof(imgPath), "%sfavIcon_gray.png", CFG.theme_path); - GuiImageData imgfavIcon_gray(imgPath, favIcon_gray_png); + GuiImageData imgfavIcon_gray(imgPath, favIcon_gray_png); snprintf(imgPath, sizeof(imgPath), "%sabcIcon.png", CFG.theme_path); - GuiImageData imgabcIcon(imgPath, abcIcon_png); + GuiImageData imgabcIcon(imgPath, abcIcon_png); snprintf(imgPath, sizeof(imgPath), "%sabcIcon_gray.png", CFG.theme_path); - GuiImageData imgabcIcon_gray(imgPath, abcIcon_gray_png); - snprintf(imgPath, sizeof(imgPath), "%splayCountIcon.png", CFG.theme_path); - GuiImageData imgplayCountIcon(imgPath, playCountIcon_png); - snprintf(imgPath, sizeof(imgPath), "%splayCountIcon_gray.png", CFG.theme_path); - GuiImageData imgplayCountIcon_gray(imgPath, playCountIcon_gray_png); - snprintf(imgPath, sizeof(imgPath), "%sarrangeGrid.png", CFG.theme_path); - GuiImageData imgarrangeGrid(imgPath, arrangeGrid_png); - snprintf(imgPath, sizeof(imgPath), "%sarrangeGrid_gray.png", CFG.theme_path); - GuiImageData imgarrangeGrid_gray(imgPath, arrangeGrid_gray_png); - snprintf(imgPath, sizeof(imgPath), "%sarrangeList.png", CFG.theme_path); - GuiImageData imgarrangeList(imgPath, arrangeList_png); - snprintf(imgPath, sizeof(imgPath), "%sarrangeList_gray.png", CFG.theme_path); - GuiImageData imgarrangeList_gray(imgPath, arrangeList_gray_png); - snprintf(imgPath, sizeof(imgPath), "%sarrangeCarousel.png", CFG.theme_path); - GuiImageData imgarrangeCarousel(imgPath, arrangeCarousel_png); - snprintf(imgPath, sizeof(imgPath), "%sarrangeCarousel_gray.png", CFG.theme_path); - GuiImageData imgarrangeCarousel_gray(imgPath, arrangeCarousel_gray_png); + GuiImageData imgabcIcon_gray(imgPath, abcIcon_gray_png); + snprintf(imgPath, sizeof(imgPath), "%splayCountIcon.png", CFG.theme_path); + GuiImageData imgplayCountIcon(imgPath, playCountIcon_png); + snprintf(imgPath, sizeof(imgPath), "%splayCountIcon_gray.png", CFG.theme_path); + GuiImageData imgplayCountIcon_gray(imgPath, playCountIcon_gray_png); + snprintf(imgPath, sizeof(imgPath), "%sarrangeGrid.png", CFG.theme_path); + GuiImageData imgarrangeGrid(imgPath, arrangeGrid_png); + snprintf(imgPath, sizeof(imgPath), "%sarrangeGrid_gray.png", CFG.theme_path); + GuiImageData imgarrangeGrid_gray(imgPath, arrangeGrid_gray_png); + snprintf(imgPath, sizeof(imgPath), "%sarrangeList.png", CFG.theme_path); + GuiImageData imgarrangeList(imgPath, arrangeList_png); + snprintf(imgPath, sizeof(imgPath), "%sarrangeList_gray.png", CFG.theme_path); + GuiImageData imgarrangeList_gray(imgPath, arrangeList_gray_png); + snprintf(imgPath, sizeof(imgPath), "%sarrangeCarousel.png", CFG.theme_path); + GuiImageData imgarrangeCarousel(imgPath, arrangeCarousel_png); + snprintf(imgPath, sizeof(imgPath), "%sarrangeCarousel_gray.png", CFG.theme_path); + GuiImageData imgarrangeCarousel_gray(imgPath, arrangeCarousel_gray_png); GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); GuiTrigger trigHome; - trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); + trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); + GuiTrigger trig2; + trig2.SetButtonOnlyTrigger(-1, WPAD_BUTTON_2 | WPAD_CLASSIC_BUTTON_X, 0); + char spaceinfo[30]; - sprintf(spaceinfo,"%.2fGB %s %.2fGB %s",freespace,LANGUAGE.of,(freespace+used),LANGUAGE.free); - GuiText usedSpaceTxt(spaceinfo, 18, (GXColor){THEME.info_r, THEME.info_g, THEME.info_b, 255}); - usedSpaceTxt.SetAlignment(THEME.hddInfoAlign, ALIGN_TOP); - usedSpaceTxt.SetPosition(THEME.hddInfo_x, THEME.hddInfo_y); + sprintf(spaceinfo,"%.2fGB %s %.2fGB %s",freespace,LANGUAGE.of,(freespace+used),LANGUAGE.free); + GuiText usedSpaceTxt(spaceinfo, 18, (GXColor){THEME.info_r, THEME.info_g, THEME.info_b, 255}); + usedSpaceTxt.SetAlignment(THEME.hddInfoAlign, ALIGN_TOP); + usedSpaceTxt.SetPosition(THEME.hddInfo_x, THEME.hddInfo_y); - char GamesCnt[15]; - sprintf(GamesCnt,"%s: %i",LANGUAGE.Games, gameCnt); - GuiText gamecntTxt(GamesCnt, 18, (GXColor){THEME.info_r, THEME.info_g, THEME.info_b, 255}); - gamecntTxt.SetAlignment(THEME.gameCntAlign, ALIGN_TOP); - gamecntTxt.SetPosition(THEME.gameCnt_x,THEME.gameCnt_y); + char GamesCnt[15]; + sprintf(GamesCnt,"%s: %i",LANGUAGE.Games, gameCnt); + GuiText gamecntTxt(GamesCnt, 18, (GXColor){THEME.info_r, THEME.info_g, THEME.info_b, 255}); + gamecntTxt.SetAlignment(THEME.gameCntAlign, ALIGN_TOP); + gamecntTxt.SetPosition(THEME.gameCnt_x,THEME.gameCnt_y); - GuiTooltip installBtnTT(LANGUAGE.Installagame); - if (Settings.wsprompt == yes) - installBtnTT.SetWidescreen(CFG.widescreen); - GuiImage installBtnImg(&btnInstall); - GuiImage installBtnImgOver(&btnInstallOver); - installBtnImg.SetWidescreen(CFG.widescreen); - installBtnImgOver.SetWidescreen(CFG.widescreen); + GuiTooltip installBtnTT(LANGUAGE.Installagame); + if (Settings.wsprompt == yes) + installBtnTT.SetWidescreen(CFG.widescreen); + GuiImage installBtnImg(&btnInstall); + GuiImage installBtnImgOver(&btnInstallOver); + installBtnImg.SetWidescreen(CFG.widescreen); + installBtnImgOver.SetWidescreen(CFG.widescreen); - GuiButton installBtn(&installBtnImg, &installBtnImgOver, ALIGN_LEFT, ALIGN_TOP, THEME.install_x, THEME.install_y, &trigA, &btnSoundOver, &btnClick, 1, &installBtnTT,24,-30, 0,5); + GuiButton installBtn(&installBtnImg, &installBtnImgOver, ALIGN_LEFT, ALIGN_TOP, THEME.install_x, THEME.install_y, &trigA, &btnSoundOver, &btnClick, 1, &installBtnTT,24,-30, 0,5); - GuiTooltip settingsBtnTT(LANGUAGE.settings); - if (Settings.wsprompt == yes) - settingsBtnTT.SetWidescreen(CFG.widescreen); + GuiTooltip settingsBtnTT(LANGUAGE.settings); + if (Settings.wsprompt == yes) + settingsBtnTT.SetWidescreen(CFG.widescreen); - GuiImage settingsBtnImg(&btnSettings); - settingsBtnImg.SetWidescreen(CFG.widescreen); - GuiImage settingsBtnImgOver(&btnSettingsOver); - settingsBtnImgOver.SetWidescreen(CFG.widescreen); - GuiButton settingsBtn(&settingsBtnImg,&settingsBtnImgOver, 0, 3, THEME.setting_x, THEME.setting_y, &trigA, &btnSoundOver, &btnClick,1,&settingsBtnTT,65,-30,0,5); - GuiTooltip homeBtnTT(LANGUAGE.BacktoHBCorWiiMenu); - if (Settings.wsprompt == yes) - homeBtnTT.SetWidescreen(CFG.widescreen); + GuiImage settingsBtnImg(&btnSettings); + settingsBtnImg.SetWidescreen(CFG.widescreen); + GuiImage settingsBtnImgOver(&btnSettingsOver); + settingsBtnImgOver.SetWidescreen(CFG.widescreen); + GuiButton settingsBtn(&settingsBtnImg,&settingsBtnImgOver, 0, 3, THEME.setting_x, THEME.setting_y, &trigA, &btnSoundOver, &btnClick,1,&settingsBtnTT,65,-30,0,5); + GuiTooltip homeBtnTT(LANGUAGE.BacktoHBCorWiiMenu); + if (Settings.wsprompt == yes) + homeBtnTT.SetWidescreen(CFG.widescreen); - GuiImage homeBtnImg(&btnhome); - homeBtnImg.SetWidescreen(CFG.widescreen); - GuiImage homeBtnImgOver(&btnhomeOver); - homeBtnImgOver.SetWidescreen(CFG.widescreen); - GuiButton homeBtn(&homeBtnImg,&homeBtnImgOver, 0, 3, THEME.home_x, THEME.home_y, &trigA, &btnSoundOver, &btnClick,1,&homeBtnTT,15,-30,1,5); - homeBtn.RemoveSoundClick(); - homeBtn.SetTrigger(&trigHome); + GuiImage homeBtnImg(&btnhome); + homeBtnImg.SetWidescreen(CFG.widescreen); + GuiImage homeBtnImgOver(&btnhomeOver); + homeBtnImgOver.SetWidescreen(CFG.widescreen); + GuiButton homeBtn(&homeBtnImg,&homeBtnImgOver, 0, 3, THEME.home_x, THEME.home_y, &trigA, &btnSoundOver, &btnClick,1,&homeBtnTT,15,-30,1,5); + homeBtn.RemoveSoundClick(); + homeBtn.SetTrigger(&trigHome); - GuiTooltip poweroffBtnTT(LANGUAGE.PowerofftheWii); - if (Settings.wsprompt == yes) - poweroffBtnTT.SetWidescreen(CFG.widescreen); + GuiTooltip poweroffBtnTT(LANGUAGE.PowerofftheWii); + if (Settings.wsprompt == yes) + poweroffBtnTT.SetWidescreen(CFG.widescreen); GuiImage poweroffBtnImg(&btnpwroff); - GuiImage poweroffBtnImgOver(&btnpwroffOver); - poweroffBtnImg.SetWidescreen(CFG.widescreen); - poweroffBtnImgOver.SetWidescreen(CFG.widescreen); - GuiButton poweroffBtn(&poweroffBtnImg,&poweroffBtnImgOver, 0, 3, THEME.power_x, THEME.power_y, &trigA, &btnSoundOver, &btnClick,1,&poweroffBtnTT,-10,-30,1,5); + GuiImage poweroffBtnImgOver(&btnpwroffOver); + poweroffBtnImg.SetWidescreen(CFG.widescreen); + poweroffBtnImgOver.SetWidescreen(CFG.widescreen); + GuiButton poweroffBtn(&poweroffBtnImg,&poweroffBtnImgOver, 0, 3, THEME.power_x, THEME.power_y, &trigA, &btnSoundOver, &btnClick,1,&poweroffBtnTT,-10,-30,1,5); - GuiTooltip sdcardBtnTT(LANGUAGE.ReloadSD); - if (Settings.wsprompt == yes) - sdcardBtnTT.SetWidescreen(CFG.widescreen); + GuiTooltip sdcardBtnTT(LANGUAGE.ReloadSD); + if (Settings.wsprompt == yes) + sdcardBtnTT.SetWidescreen(CFG.widescreen); - GuiImage sdcardImg(&btnsdcard); - sdcardImg.SetWidescreen(CFG.widescreen); - GuiButton sdcardBtn(&sdcardImg,&sdcardImg, 0, 3, THEME.sdcard_x, THEME.sdcard_y, &trigA, &btnSoundOver, &btnClick,1,&sdcardBtnTT,15,-30,0,5); + GuiImage sdcardImg(&btnsdcard); + sdcardImg.SetWidescreen(CFG.widescreen); + GuiButton sdcardBtn(&sdcardImg,&sdcardImg, 0, 3, THEME.sdcard_x, THEME.sdcard_y, &trigA, &btnSoundOver, &btnClick,1,&sdcardBtnTT,15,-30,0,5); - GuiImage wiiBtnImg(&dataID); - wiiBtnImg.SetWidescreen(CFG.widescreen); - GuiButton wiiBtn(&wiiBtnImg,&wiiBtnImg, 0, 4, 0, -10, &trigA, &btnSoundOver, &btnClick,0); + GuiButton gameInfo(0,0); + gameInfo.SetTrigger(&trig2); + gameInfo.SetSoundClick(&btnClick); + + + GuiImage wiiBtnImg(&dataID); + wiiBtnImg.SetWidescreen(CFG.widescreen); + GuiButton wiiBtn(&wiiBtnImg,&wiiBtnImg, 0, 4, 0, -10, &trigA, &btnSoundOver, &btnClick,0); - GuiImage favoriteBtnImg(&imgfavIcon); - GuiImage favoriteBtnImg_g(&imgfavIcon_gray); - favoriteBtnImg.SetWidescreen(CFG.widescreen); - favoriteBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton favoriteBtn(&favoriteBtnImg_g,&favoriteBtnImg_g, 2, 3, THEME.favorite_x, THEME.favorite_y, &trigA, &btnSoundOver, &btnClick,1); - favoriteBtn.SetAlpha(180); + GuiImage favoriteBtnImg(&imgfavIcon); + GuiImage favoriteBtnImg_g(&imgfavIcon_gray); + favoriteBtnImg.SetWidescreen(CFG.widescreen); + favoriteBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton favoriteBtn(&favoriteBtnImg_g,&favoriteBtnImg_g, 2, 3, THEME.favorite_x, THEME.favorite_y, &trigA, &btnSoundOver, &btnClick,1); + favoriteBtn.SetAlpha(180); - GuiImage abcBtnImg(&imgabcIcon); - abcBtnImg.SetWidescreen(CFG.widescreen); - GuiImage abcBtnImg_g(&imgabcIcon_gray); - abcBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton abcBtn(&abcBtnImg_g,&abcBtnImg_g, 2, 3, THEME.abc_x, THEME.abc_y, &trigA, &btnSoundOver, &btnClick,1); - abcBtn.SetAlpha(180); + GuiImage abcBtnImg(&imgabcIcon); + abcBtnImg.SetWidescreen(CFG.widescreen); + GuiImage abcBtnImg_g(&imgabcIcon_gray); + abcBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton abcBtn(&abcBtnImg_g,&abcBtnImg_g, 2, 3, THEME.abc_x, THEME.abc_y, &trigA, &btnSoundOver, &btnClick,1); + abcBtn.SetAlpha(180); - GuiImage countBtnImg(&imgplayCountIcon); - countBtnImg.SetWidescreen(CFG.widescreen); - GuiImage countBtnImg_g(&imgplayCountIcon_gray); - countBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton countBtn(&countBtnImg_g,&countBtnImg_g, 2, 3, THEME.count_x, THEME.count_y, &trigA, &btnSoundOver, &btnClick,1); - countBtn.SetAlpha(180); + GuiImage countBtnImg(&imgplayCountIcon); + countBtnImg.SetWidescreen(CFG.widescreen); + GuiImage countBtnImg_g(&imgplayCountIcon_gray); + countBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton countBtn(&countBtnImg_g,&countBtnImg_g, 2, 3, THEME.count_x, THEME.count_y, &trigA, &btnSoundOver, &btnClick,1); + countBtn.SetAlpha(180); - GuiImage listBtnImg(&imgarrangeList); - listBtnImg.SetWidescreen(CFG.widescreen); - GuiImage listBtnImg_g(&imgarrangeList_gray); - listBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton listBtn(&listBtnImg_g,&listBtnImg_g, 2, 3, THEME.list_x, THEME.list_y, &trigA, &btnSoundOver, &btnClick,1); - listBtn.SetAlpha(180); + GuiImage listBtnImg(&imgarrangeList); + listBtnImg.SetWidescreen(CFG.widescreen); + GuiImage listBtnImg_g(&imgarrangeList_gray); + listBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton listBtn(&listBtnImg_g,&listBtnImg_g, 2, 3, THEME.list_x, THEME.list_y, &trigA, &btnSoundOver, &btnClick,1); + listBtn.SetAlpha(180); - GuiImage gridBtnImg(&imgarrangeGrid); - gridBtnImg.SetWidescreen(CFG.widescreen); - GuiImage gridBtnImg_g(&imgarrangeGrid_gray); - gridBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton gridBtn(&gridBtnImg_g,&gridBtnImg_g, 2, 3, THEME.grid_x, THEME.grid_y, &trigA, &btnSoundOver, &btnClick,1); - gridBtn.SetAlpha(180); + GuiImage gridBtnImg(&imgarrangeGrid); + gridBtnImg.SetWidescreen(CFG.widescreen); + GuiImage gridBtnImg_g(&imgarrangeGrid_gray); + gridBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton gridBtn(&gridBtnImg_g,&gridBtnImg_g, 2, 3, THEME.grid_x, THEME.grid_y, &trigA, &btnSoundOver, &btnClick,1); + gridBtn.SetAlpha(180); - GuiImage carouselBtnImg(&imgarrangeCarousel); - carouselBtnImg.SetWidescreen(CFG.widescreen); - GuiImage carouselBtnImg_g(&imgarrangeCarousel_gray); - carouselBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton carouselBtn(&carouselBtnImg_g,&carouselBtnImg_g, 2, 3, THEME.carousel_x, THEME.carousel_y, &trigA, &btnSoundOver, &btnClick,1); - carouselBtn.SetAlpha(180); + GuiImage carouselBtnImg(&imgarrangeCarousel); + carouselBtnImg.SetWidescreen(CFG.widescreen); + GuiImage carouselBtnImg_g(&imgarrangeCarousel_gray); + carouselBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton carouselBtn(&carouselBtnImg_g,&carouselBtnImg_g, 2, 3, THEME.carousel_x, THEME.carousel_y, &trigA, &btnSoundOver, &btnClick,1); + carouselBtn.SetAlpha(180); - if (Settings.fave) - { - favoriteBtn.SetImage(&favoriteBtnImg); - favoriteBtn.SetImageOver(&favoriteBtnImg); - favoriteBtn.SetAlpha(255); - } - if (Settings.sort==all) - { - abcBtn.SetImage(&abcBtnImg); - abcBtn.SetImageOver(&abcBtnImg); - abcBtn.SetAlpha(255); - } - else if (Settings.sort==pcount) - { - countBtn.SetImage(&countBtnImg); - countBtn.SetImageOver(&countBtnImg); - countBtn.SetAlpha(255); - } - if (Settings.gameDisplay==list) - { - listBtn.SetImage(&listBtnImg); - listBtn.SetImageOver(&listBtnImg); - listBtn.SetAlpha(255); - } - else if (Settings.gameDisplay==grid) - { - gridBtn.SetImage(&gridBtnImg); - gridBtn.SetImageOver(&gridBtnImg); - gridBtn.SetAlpha(255); - } - else if (Settings.gameDisplay==carousel) - { - carouselBtn.SetImage(&carouselBtnImg); - carouselBtn.SetImageOver(&carouselBtnImg); - carouselBtn.SetAlpha(255); - } - if (Settings.gameDisplay==list) - { - if(CFG.widescreen) - { - favoriteBtn.SetPosition(THEME.favorite_x, THEME.favorite_y); - abcBtn.SetPosition(THEME.abc_x, THEME.abc_y); - countBtn.SetPosition(THEME.count_x, THEME.count_y); - listBtn.SetPosition(THEME.list_x, THEME.list_y); - gridBtn.SetPosition(THEME.grid_x, THEME.grid_y); - carouselBtn.SetPosition(THEME.carousel_x, THEME.carousel_y); - } - else - { - favoriteBtn.SetPosition(THEME.favorite_x-20, THEME.favorite_y); - abcBtn.SetPosition(THEME.abc_x-12, THEME.abc_y); - countBtn.SetPosition(THEME.count_x-4, THEME.count_y); - listBtn.SetPosition(THEME.list_x+4, THEME.list_y); - gridBtn.SetPosition(THEME.grid_x+12, THEME.grid_y); - carouselBtn.SetPosition(THEME.carousel_x+20, THEME.carousel_y); - } - } - else - { - if(CFG.widescreen) - { - favoriteBtn.SetPosition(THEME.favorite_x-THEME.sortBarOffset, THEME.favorite_y); - abcBtn.SetPosition(THEME.abc_x-THEME.sortBarOffset, THEME.abc_y); - countBtn.SetPosition(THEME.count_x-THEME.sortBarOffset, THEME.count_y); - listBtn.SetPosition(THEME.list_x-THEME.sortBarOffset, THEME.list_y); - gridBtn.SetPosition(THEME.grid_x-THEME.sortBarOffset, THEME.grid_y); - carouselBtn.SetPosition(THEME.carousel_x-THEME.sortBarOffset, THEME.carousel_y); - } - else - { - favoriteBtn.SetPosition(THEME.favorite_x-20-THEME.sortBarOffset, THEME.favorite_y); - abcBtn.SetPosition(THEME.abc_x-12-THEME.sortBarOffset, THEME.abc_y); - countBtn.SetPosition(THEME.count_x-4-THEME.sortBarOffset, THEME.count_y); - listBtn.SetPosition(THEME.list_x+4-THEME.sortBarOffset, THEME.list_y); - gridBtn.SetPosition(THEME.grid_x+12-THEME.sortBarOffset, THEME.grid_y); - carouselBtn.SetPosition(THEME.carousel_x+20-THEME.sortBarOffset, THEME.carousel_y); - } - } + if (Settings.fave) + { + favoriteBtn.SetImage(&favoriteBtnImg); + favoriteBtn.SetImageOver(&favoriteBtnImg); + favoriteBtn.SetAlpha(255); + } + if (Settings.sort==all) + { + abcBtn.SetImage(&abcBtnImg); + abcBtn.SetImageOver(&abcBtnImg); + abcBtn.SetAlpha(255); + } + else if (Settings.sort==pcount) + { + countBtn.SetImage(&countBtnImg); + countBtn.SetImageOver(&countBtnImg); + countBtn.SetAlpha(255); + } + if (Settings.gameDisplay==list) + { + listBtn.SetImage(&listBtnImg); + listBtn.SetImageOver(&listBtnImg); + listBtn.SetAlpha(255); + } + else if (Settings.gameDisplay==grid) + { + gridBtn.SetImage(&gridBtnImg); + gridBtn.SetImageOver(&gridBtnImg); + gridBtn.SetAlpha(255); + } + else if (Settings.gameDisplay==carousel) + { + carouselBtn.SetImage(&carouselBtnImg); + carouselBtn.SetImageOver(&carouselBtnImg); + carouselBtn.SetAlpha(255); + } + if (Settings.gameDisplay==list) + { + if(CFG.widescreen) + { + favoriteBtn.SetPosition(THEME.favorite_x, THEME.favorite_y); + abcBtn.SetPosition(THEME.abc_x, THEME.abc_y); + countBtn.SetPosition(THEME.count_x, THEME.count_y); + listBtn.SetPosition(THEME.list_x, THEME.list_y); + gridBtn.SetPosition(THEME.grid_x, THEME.grid_y); + carouselBtn.SetPosition(THEME.carousel_x, THEME.carousel_y); + } + else + { + favoriteBtn.SetPosition(THEME.favorite_x-20, THEME.favorite_y); + abcBtn.SetPosition(THEME.abc_x-12, THEME.abc_y); + countBtn.SetPosition(THEME.count_x-4, THEME.count_y); + listBtn.SetPosition(THEME.list_x+4, THEME.list_y); + gridBtn.SetPosition(THEME.grid_x+12, THEME.grid_y); + carouselBtn.SetPosition(THEME.carousel_x+20, THEME.carousel_y); + } + } + else + { + if(CFG.widescreen) + { + favoriteBtn.SetPosition(THEME.favorite_x-THEME.sortBarOffset, THEME.favorite_y); + abcBtn.SetPosition(THEME.abc_x-THEME.sortBarOffset, THEME.abc_y); + countBtn.SetPosition(THEME.count_x-THEME.sortBarOffset, THEME.count_y); + listBtn.SetPosition(THEME.list_x-THEME.sortBarOffset, THEME.list_y); + gridBtn.SetPosition(THEME.grid_x-THEME.sortBarOffset, THEME.grid_y); + carouselBtn.SetPosition(THEME.carousel_x-THEME.sortBarOffset, THEME.carousel_y); + } + else + { + favoriteBtn.SetPosition(THEME.favorite_x-20-THEME.sortBarOffset, THEME.favorite_y); + abcBtn.SetPosition(THEME.abc_x-12-THEME.sortBarOffset, THEME.abc_y); + countBtn.SetPosition(THEME.count_x-4-THEME.sortBarOffset, THEME.count_y); + listBtn.SetPosition(THEME.list_x+4-THEME.sortBarOffset, THEME.list_y); + gridBtn.SetPosition(THEME.grid_x+12-THEME.sortBarOffset, THEME.grid_y); + carouselBtn.SetPosition(THEME.carousel_x+20-THEME.sortBarOffset, THEME.carousel_y); + } + } - //Downloading Covers - GuiTooltip DownloadBtnTT(LANGUAGE.ClicktoDownloadCovers); - if (Settings.wsprompt == yes) - DownloadBtnTT.SetWidescreen(CFG.widescreen); - GuiButton DownloadBtn(160,224); - DownloadBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); - DownloadBtn.SetPosition(THEME.cover_x,THEME.cover_y); + //Downloading Covers + GuiTooltip DownloadBtnTT(LANGUAGE.ClicktoDownloadCovers); + if (Settings.wsprompt == yes) + DownloadBtnTT.SetWidescreen(CFG.widescreen); - if (Settings.godmode == 1) - {//only make the button have trigger & tooltip if in godmode - DownloadBtn.SetSoundOver(&btnSoundOver); - DownloadBtn.SetTrigger(&trigA); - DownloadBtn.SetToolTip(&DownloadBtnTT,205,-30); + GuiButton DownloadBtn(160,224); + DownloadBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); + DownloadBtn.SetPosition(THEME.cover_x,THEME.cover_y); + + if (Settings.godmode == 1) + {//only make the button have trigger & tooltip if in godmode + DownloadBtn.SetSoundOver(&btnSoundOver); + DownloadBtn.SetTrigger(&trigA); + DownloadBtn.SetToolTip(&DownloadBtnTT,205,-30); } - else - DownloadBtn.SetRumble(false); + else + DownloadBtn.SetRumble(false); GuiGameBrowser * gameBrowser = NULL; GuiGameGrid * gameGrid = NULL; GuiGameCarousel * gameCarousel = NULL; if (Settings.gameDisplay==list) { gameBrowser = new GuiGameBrowser(THEME.selection_w, THEME.selection_h, gameList, gameCnt, CFG.theme_path, bg_options_png, startat, offset); - gameBrowser->SetPosition(THEME.selection_x, THEME.selection_y); - gameBrowser->SetAlignment(ALIGN_LEFT, ALIGN_CENTRE); + gameBrowser->SetPosition(THEME.selection_x, THEME.selection_y); + gameBrowser->SetAlignment(ALIGN_LEFT, ALIGN_CENTRE); } else if (Settings.gameDisplay==grid) { - gameGrid = new GuiGameGrid(THEME.gamegrid_w,THEME.gamegrid_h, gameList, gameCnt, CFG.theme_path, bg_options_png, 0, 0); - gameGrid->SetPosition(THEME.gamegrid_x,THEME.gamegrid_y); - gameGrid->SetAlignment(ALIGN_LEFT, ALIGN_CENTRE); + gameGrid = new GuiGameGrid(THEME.gamegrid_w,THEME.gamegrid_h, gameList, gameCnt, CFG.theme_path, bg_options_png, 0, 0); + gameGrid->SetPosition(THEME.gamegrid_x,THEME.gamegrid_y); + gameGrid->SetAlignment(ALIGN_LEFT, ALIGN_CENTRE); } else if (Settings.gameDisplay==carousel) { - //GuiGameCarousel gameCarousel(THEME.gamecarousel_w, THEME.gamecarousel_h, gameList, gameCnt, CFG.theme_path, bg_options_png, startat, offset); - gameCarousel = new GuiGameCarousel(640, 400, gameList, gameCnt, CFG.theme_path, bg_options_png, startat, offset); - gameCarousel->SetPosition(THEME.gamecarousel_x,THEME.gamecarousel_y); - gameCarousel->SetAlignment(ALIGN_LEFT, ALIGN_CENTRE); + //GuiGameCarousel gameCarousel(THEME.gamecarousel_w, THEME.gamecarousel_h, gameList, gameCnt, CFG.theme_path, bg_options_png, startat, offset); + gameCarousel = new GuiGameCarousel(640, 400, gameList, gameCnt, CFG.theme_path, bg_options_png, startat, offset); + gameCarousel->SetPosition(THEME.gamecarousel_x,THEME.gamecarousel_y); + gameCarousel->SetAlignment(ALIGN_LEFT, ALIGN_CENTRE); } - GuiText clockTimeBack("88:88", 40, (GXColor){THEME.clock_r, THEME.clock_g, THEME.clock_b, 40}); - clockTimeBack.SetAlignment(THEME.clockAlign, ALIGN_TOP); - clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y); - clockTimeBack.SetFont(fontClock); - if (Settings.gameDisplay==grid || Settings.gameDisplay==carousel) { - clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y+3); - } - GuiText clockTime(theTime, 40, (GXColor){THEME.clock_r, THEME.clock_g, THEME.clock_b, 240}); - clockTime.SetAlignment(THEME.clockAlign, ALIGN_TOP); - clockTime.SetPosition(THEME.clock_x, THEME.clock_y); - clockTime.SetFont(fontClock); - if (Settings.gameDisplay==grid || Settings.gameDisplay==carousel) { - clockTime.SetPosition(THEME.clock_x, THEME.clock_y+3); - } + GuiText clockTimeBack("88:88", 40, (GXColor){THEME.clock_r, THEME.clock_g, THEME.clock_b, 40}); + clockTimeBack.SetAlignment(THEME.clockAlign, ALIGN_TOP); + clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y); + clockTimeBack.SetFont(fontClock); + if (Settings.gameDisplay==grid || Settings.gameDisplay==carousel) { + clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y+3); + } + GuiText clockTime(theTime, 40, (GXColor){THEME.clock_r, THEME.clock_g, THEME.clock_b, 240}); + clockTime.SetAlignment(THEME.clockAlign, ALIGN_TOP); + clockTime.SetPosition(THEME.clock_x, THEME.clock_y); + clockTime.SetFont(fontClock); + if (Settings.gameDisplay==grid || Settings.gameDisplay==carousel) { + clockTime.SetPosition(THEME.clock_x, THEME.clock_y+3); + } - HaltGui(); - GuiWindow w(screenwidth, screenheight); + HaltGui(); + GuiWindow w(screenwidth, screenheight); - if(THEME.showHDD == -1 || THEME.showHDD == 1) //force show hdd info - { - w.Append(&usedSpaceTxt); - } - if(THEME.showGameCnt == -1 || THEME.showGameCnt == 1) //force show game cnt info - { - w.Append(&gamecntTxt); - } + if(THEME.showHDD == -1 || THEME.showHDD == 1) //force show hdd info + { + w.Append(&usedSpaceTxt); + } + if(THEME.showGameCnt == -1 || THEME.showGameCnt == 1) //force show game cnt info + { + w.Append(&gamecntTxt); + } - w.Append(&sdcardBtn); - w.Append(&poweroffBtn); - if (Settings.godmode) - w.Append(&installBtn); - w.Append(&homeBtn); - w.Append(&settingsBtn); - if (Settings.gameDisplay==list){ - w.Append(&DownloadBtn); - } - w.Append(&favoriteBtn); - w.Append(&abcBtn); - w.Append(&countBtn); - w.Append(&listBtn); - w.Append(&gridBtn); - w.Append(&carouselBtn); + w.Append(&sdcardBtn); + w.Append(&poweroffBtn); + w.Append(&gameInfo); + if (Settings.godmode) + w.Append(&installBtn); + w.Append(&homeBtn); + w.Append(&settingsBtn); + if (Settings.gameDisplay==list){ + w.Append(&DownloadBtn); + } + w.Append(&favoriteBtn); + w.Append(&abcBtn); + w.Append(&countBtn); + w.Append(&listBtn); + w.Append(&gridBtn); + w.Append(&carouselBtn); - if((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) - { - w.Append(&clockTimeBack); - w.Append(&clockTime); - } + if((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) + { + w.Append(&clockTimeBack); + w.Append(&clockTime); + } - if (Settings.gameDisplay==list){mainWindow->Append(gameBrowser);} - if (Settings.gameDisplay==grid){mainWindow->Append(gameGrid);} - if (Settings.gameDisplay==carousel){mainWindow->Append(gameCarousel);} - mainWindow->Append(&w); + if (Settings.gameDisplay==list){mainWindow->Append(gameBrowser);} + if (Settings.gameDisplay==grid){mainWindow->Append(gameGrid);} + if (Settings.gameDisplay==carousel){mainWindow->Append(gameCarousel);} + mainWindow->Append(&w); - ResumeGui(); + ResumeGui(); - while(menu == MENU_NONE) - { + while(menu == MENU_NONE) + { - VIDEO_WaitVSync (); + VIDEO_WaitVSync (); - //CLOCK - time_t rawtime = time(0); //this fixes code dump caused by the clock - if (((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) && rawtime != lastrawtime) { - lastrawtime = rawtime; - timeinfo = localtime (&rawtime); - if (dataed < 1){ - if(Settings.hddinfo == hr12){ - if(rawtime & 1) - strftime(theTime, sizeof(theTime), "%I:%M", timeinfo); - else - strftime(theTime, sizeof(theTime), "%I %M", timeinfo); - } - if(Settings.hddinfo == hr24){ - if(rawtime & 1) - strftime(theTime, sizeof(theTime), "%H:%M", timeinfo); - else - strftime(theTime, sizeof(theTime), "%H %M", timeinfo); - } - clockTime.SetText(theTime); + //CLOCK + time_t rawtime = time(0); //this fixes code dump caused by the clock + if (((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) && rawtime != lastrawtime) { + lastrawtime = rawtime; + timeinfo = localtime (&rawtime); + if (dataed < 1){ + if(Settings.hddinfo == hr12){ + if(rawtime & 1) + strftime(theTime, sizeof(theTime), "%I:%M", timeinfo); + else + strftime(theTime, sizeof(theTime), "%I %M", timeinfo); + } + if(Settings.hddinfo == hr24){ + if(rawtime & 1) + strftime(theTime, sizeof(theTime), "%H:%M", timeinfo); + else + strftime(theTime, sizeof(theTime), "%H %M", timeinfo); + } + clockTime.SetText(theTime); - } - else if (dataed > 0){ + } + else if (dataed > 0){ - clockTime.SetTextf("%i", (dataed-1)); - } + clockTime.SetTextf("%i", (dataed-1)); + } - } + } if ((datagB<1)&&(Settings.cios==1)&&(Settings.video == ntsc)&&(Settings.hddinfo == hr12)&&(Settings.qboot==1)&&(Settings.wsprompt==0)&&(Settings.language==ger)&&(Settings.tooltips==0)){dataed=1;dataef=1;}if (dataef==1){if (cosa>7){cosa=1;}datag++;if (sina==3){wiiBtn.SetAlignment(ALIGN_LEFT,ALIGN_BOTTOM);wiiBtnImg.SetAngle(0);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((cosa)*70),(-2*(datag)+120));}else if(62<=datag){wiiBtn.SetPosition(((cosa)*70),((datag*2)-130));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==2){wiiBtn.SetAlignment(ALIGN_RIGHT,ALIGN_TOP);wiiBtnImg.SetAngle(270);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((-2*(datag)+130)),((cosa)*50));}else if(62<=datag){wiiBtn.SetPosition((2*(datag)-120),((cosa)*50));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==1){wiiBtn.SetAlignment(ALIGN_TOP,ALIGN_LEFT);wiiBtnImg.SetAngle(180);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((cosa)*70),(2*(datag)-120));}else if(62<=datag){wiiBtn.SetPosition(((cosa)*70),(-2*(datag)+130));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==0){wiiBtn.SetAlignment(ALIGN_TOP,ALIGN_LEFT);wiiBtnImg.SetAngle(90);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((2*(datag)-130)),((cosa)*50));}else if(62<=datag){wiiBtn.SetPosition((-2*(datag)+120),((cosa)*50));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}} - // respond to button presses - if(shutdown == 1) - { - Sys_Shutdown(); - } - if(reset == 1) - Sys_Reboot(); + // respond to button presses + if(shutdown == 1) + { + Sys_Shutdown(); + } + if(reset == 1) + Sys_Reboot(); - if(poweroffBtn.GetState() == STATE_CLICKED) - { + if(poweroffBtn.GetState() == STATE_CLICKED) + { - choice = WindowPrompt(LANGUAGE.HowtoShutdown,0,LANGUAGE.FullShutdown, LANGUAGE.ShutdowntoIdle, LANGUAGE.Cancel,0); - if(choice == 2) - { - Sys_ShutdownToIdel(); - } else if(choice == 1) { - Sys_ShutdownToStandby(); - } else { - poweroffBtn.ResetState(); - if (Settings.gameDisplay==list){gameBrowser->SetFocus(1);} - else if (Settings.gameDisplay==grid){gameGrid->SetFocus(1);} - else if (Settings.gameDisplay==carousel){gameCarousel->SetFocus(1);} - } + choice = WindowPrompt(LANGUAGE.HowtoShutdown,0,LANGUAGE.FullShutdown, LANGUAGE.ShutdowntoIdle, LANGUAGE.Cancel,0); + if(choice == 2) + { + Sys_ShutdownToIdel(); + } else if(choice == 1) { + Sys_ShutdownToStandby(); + } else { + poweroffBtn.ResetState(); + if (Settings.gameDisplay==list){gameBrowser->SetFocus(1);} + else if (Settings.gameDisplay==grid){gameGrid->SetFocus(1);} + else if (Settings.gameDisplay==carousel){gameCarousel->SetFocus(1);} + } - } - else if(homeBtn.GetState() == STATE_CLICKED) - { - s32 thetimeofbg = bgMusic->GetPlayTime(); + } + else if(homeBtn.GetState() == STATE_CLICKED) + { + s32 thetimeofbg = bgMusic->GetPlayTime(); bgMusic->Stop(); - choice = WindowExitPrompt(LANGUAGE.ExitUSBISOLoader,0, LANGUAGE.BacktoLoader,LANGUAGE.WiiMenu,LANGUAGE.Back,0); - if(!strcmp("", Settings.oggload_path) || !strcmp("notset", Settings.ogg_path)) { + choice = WindowExitPrompt(LANGUAGE.ExitUSBISOLoader,0, LANGUAGE.BacktoLoader,LANGUAGE.WiiMenu,LANGUAGE.Back,0); + if(!strcmp("", Settings.oggload_path) || !strcmp("notset", Settings.ogg_path)) { bgMusic->Play(); } else { bgMusic->PlayOggFile(Settings.ogg_path); @@ -616,593 +635,607 @@ static int MenuDiscList() bgMusic->SetPlayTime(thetimeofbg); SetVolumeOgg(255*(Settings.volume/100.0)); - if(choice == 3) - { - Sys_LoadMenu(); // Back to System Menu - } - else if (choice == 2) - { - Sys_BackToLoader(); - } else { - homeBtn.ResetState(); - if (Settings.gameDisplay==list){gameBrowser->SetFocus(1);} - else if (Settings.gameDisplay==grid){gameGrid->SetFocus(1);} - else if (Settings.gameDisplay==carousel){gameCarousel->SetFocus(1);} - } + if(choice == 3) + { + Sys_LoadMenu(); // Back to System Menu + } + else if (choice == 2) + { + Sys_BackToLoader(); + } else { + homeBtn.ResetState(); + if (Settings.gameDisplay==list){gameBrowser->SetFocus(1);} + else if (Settings.gameDisplay==grid){gameGrid->SetFocus(1);} + else if (Settings.gameDisplay==carousel){gameCarousel->SetFocus(1);} + } } - else if(wiiBtn.GetState() == STATE_CLICKED) - { dataed++; - wiiBtn.ResetState(); - if (Settings.gameDisplay==list){gameBrowser->SetFocus(1);} - else if (Settings.gameDisplay==grid){gameGrid->SetFocus(1);} - else if (Settings.gameDisplay==carousel){gameCarousel->SetFocus(1);} - } - else if(installBtn.GetState() == STATE_CLICKED) - { - choice = WindowPrompt(LANGUAGE.Installagame,0,LANGUAGE.Yes,LANGUAGE.No,0,0); - if (choice == 1) - { - menu = MENU_INSTALL; - break; - } - else - { - installBtn.ResetState(); - if (Settings.gameDisplay==list){gameBrowser->SetFocus(1);} - else if (Settings.gameDisplay==grid){gameGrid->SetFocus(1);} - else if (Settings.gameDisplay==carousel){gameCarousel->SetFocus(1);} - } - } + else if(wiiBtn.GetState() == STATE_CLICKED) + { dataed++; + wiiBtn.ResetState(); + if (Settings.gameDisplay==list){gameBrowser->SetFocus(1);} + else if (Settings.gameDisplay==grid){gameGrid->SetFocus(1);} + else if (Settings.gameDisplay==carousel){gameCarousel->SetFocus(1);} + } + else if(installBtn.GetState() == STATE_CLICKED) + { + choice = WindowPrompt(LANGUAGE.Installagame,0,LANGUAGE.Yes,LANGUAGE.No,0,0); + if (choice == 1) + { + menu = MENU_INSTALL; + break; + } + else + { + installBtn.ResetState(); + if (Settings.gameDisplay==list){gameBrowser->SetFocus(1);} + else if (Settings.gameDisplay==grid){gameGrid->SetFocus(1);} + else if (Settings.gameDisplay==carousel){gameCarousel->SetFocus(1);} + } + } - else if(sdcardBtn.GetState() == STATE_CLICKED) - { - SDCard_deInit(); - SDCard_Init(); - if (Settings.gameDisplay==list){ - startat = gameBrowser->GetSelectedOption(); - offset = gameBrowser->GetOffset();} - else if (Settings.gameDisplay==grid){ - startat = gameGrid->GetSelectedOption(); - offset = gameGrid->GetOffset();} - else if (Settings.gameDisplay==carousel){ - startat = gameCarousel->GetSelectedOption(); - offset = gameCarousel->GetOffset();} - if(isSdInserted()) { + + else if(sdcardBtn.GetState() == STATE_CLICKED) + { + SDCard_deInit(); + SDCard_Init(); + if (Settings.gameDisplay==list){ + startat = gameBrowser->GetSelectedOption(); + offset = gameBrowser->GetOffset();} + else if (Settings.gameDisplay==grid){ + startat = gameGrid->GetSelectedOption(); + offset = gameGrid->GetOffset();} + else if (Settings.gameDisplay==carousel){ + startat = gameCarousel->GetSelectedOption(); + offset = gameCarousel->GetOffset();} + if(isSdInserted()) { CFG_Load(); } - sdcardBtn.ResetState(); - menu = MENU_DISCLIST; - break; - } + sdcardBtn.ResetState(); + menu = MENU_DISCLIST; + break; + } - else if(DownloadBtn.GetState() == STATE_CLICKED) - { - if(isSdInserted()) { - choice = WindowPrompt(LANGUAGE.CoverDownload, 0, LANGUAGE.NormalCovers, LANGUAGE.t3Covers, LANGUAGE.DiscImages, LANGUAGE.Back); // ask for download choice + else if(DownloadBtn.GetState() == STATE_CLICKED) + { + if(isSdInserted()) { + choice = WindowPrompt(LANGUAGE.CoverDownload, 0, LANGUAGE.NormalCovers, LANGUAGE.t3Covers, LANGUAGE.DiscImages, LANGUAGE.Back); // ask for download choice - if (choice != 0) - { - int netset; - int choice2 = choice; + if (choice != 0) + { + int netset; + int choice2 = choice; - netset = NetworkInitPromp(choice2); + netset = NetworkInitPromp(choice2); - if(netset < 0) - { - WindowPrompt(LANGUAGE.Networkiniterror, 0, LANGUAGE.ok,0,0,0); - netcheck = false; + if(netset < 0) + { + WindowPrompt(LANGUAGE.Networkiniterror, 0, LANGUAGE.ok,0,0,0); + netcheck = false; - } else { + } else { netcheck = true; - } + } - if (netcheck) - { + if (netcheck) + { - if (GetMissingFiles() != NULL && cntMissFiles > 0) + if (GetMissingFiles() != NULL && cntMissFiles > 0) - { - char tempCnt[40]; + { + char tempCnt[40]; - sprintf(tempCnt,"%i %s",cntMissFiles,LANGUAGE.Missingfiles); - choice = WindowPrompt(LANGUAGE.DownloadBoxartimage,tempCnt,LANGUAGE.Yes,LANGUAGE.No,0,0); - if (choice == 1) - { - ret = ProgressDownloadWindow(choice2); - if (ret == 0) { - WindowPrompt(LANGUAGE.Downloadfinished,0,LANGUAGE.ok,0,0,0); - } else { + sprintf(tempCnt,"%i %s",cntMissFiles,LANGUAGE.Missingfiles); + choice = WindowPrompt(LANGUAGE.DownloadBoxartimage,tempCnt,LANGUAGE.Yes,LANGUAGE.No,0,0); + if (choice == 1) + { + ret = ProgressDownloadWindow(choice2); + if (ret == 0) { + WindowPrompt(LANGUAGE.Downloadfinished,0,LANGUAGE.ok,0,0,0); + } else { sprintf(tempCnt,"%i %s",ret,LANGUAGE.filesnotfoundontheserver); WindowPrompt(LANGUAGE.Downloadfinished,tempCnt,LANGUAGE.ok,0,0,0); - } - } - } - else - { - WindowPrompt(LANGUAGE.Nofilemissing,0,LANGUAGE.ok,0,0,0); - } - } - } + } + } + } + else + { + WindowPrompt(LANGUAGE.Nofilemissing,0,LANGUAGE.ok,0,0,0); + } + } + } } else { - WindowPrompt(LANGUAGE.NoSDcardinserted, LANGUAGE.InsertaSDCardtodownloadimages, LANGUAGE.ok, 0,0,0); + WindowPrompt(LANGUAGE.NoSDcardinserted, LANGUAGE.InsertaSDCardtodownloadimages, LANGUAGE.ok, 0,0,0); } DownloadBtn.ResetState(); - if (Settings.gameDisplay==list){gameBrowser->SetFocus(1);} - else if (Settings.gameDisplay==grid){gameGrid->SetFocus(1);} - else if (Settings.gameDisplay==carousel){gameCarousel->SetFocus(1);} - }//end download + if (Settings.gameDisplay==list){gameBrowser->SetFocus(1);} + else if (Settings.gameDisplay==grid){gameGrid->SetFocus(1);} + else if (Settings.gameDisplay==carousel){gameCarousel->SetFocus(1);} + }//end download - else if(settingsBtn.GetState() == STATE_CLICKED) - { if (Settings.gameDisplay==list){ - startat = gameBrowser->GetSelectedOption(); - offset = gameBrowser->GetOffset();} - else if (Settings.gameDisplay==grid){ - startat = gameGrid->GetSelectedOption(); - offset = gameGrid->GetOffset();} - else if (Settings.gameDisplay==carousel){ - startat = gameCarousel->GetSelectedOption(); - offset = gameCarousel->GetOffset();} - menu = MENU_SETTINGS; - break; + else if(settingsBtn.GetState() == STATE_CLICKED) + { if (Settings.gameDisplay==list){ + startat = gameBrowser->GetSelectedOption(); + offset = gameBrowser->GetOffset();} + else if (Settings.gameDisplay==grid){ + startat = gameGrid->GetSelectedOption(); + offset = gameGrid->GetOffset();} + else if (Settings.gameDisplay==carousel){ + startat = gameCarousel->GetSelectedOption(); + offset = gameCarousel->GetOffset();} + menu = MENU_SETTINGS; + break; - } + } - else if(favoriteBtn.GetState() == STATE_CLICKED) - { - Settings.fave=!Settings.fave; - if(isSdInserted()) { - cfg_save_global(); - } - __Menu_GetEntries(); - menu = MENU_DISCLIST; - break; - /* - if (Settings.gameDisplay==list){ - gameBrowser.Reload(gameList, gameCnt);} - else if (Settings.gameDisplay==grid){ - gameGrid.Reload(gameList, gameCnt);} - else if (Settings.gameDisplay==carousel){ - gameCarousel.Reload(gameList, gameCnt);} - gamecntTxt.SetTextf("%s: %i",LANGUAGE.Games, gameCnt); - selectedold = 1; - favoriteBtn.ResetState(); - Settings.fave ? (favoriteBtn.SetImage(&favoriteBtnImg),favoriteBtn.SetImageOver(&favoriteBtnImg), - favoriteBtn.SetAlpha(255)) : (favoriteBtn.SetImage(&favoriteBtnImg_g), - favoriteBtn.SetImageOver(&favoriteBtnImg_g), favoriteBtn.SetAlpha(180)); - */ - } + else if(favoriteBtn.GetState() == STATE_CLICKED) + { + Settings.fave=!Settings.fave; + if(isSdInserted()) { + cfg_save_global(); + } + __Menu_GetEntries(); + menu = MENU_DISCLIST; + break; + /* + if (Settings.gameDisplay==list){ + gameBrowser.Reload(gameList, gameCnt);} + else if (Settings.gameDisplay==grid){ + gameGrid.Reload(gameList, gameCnt);} + else if (Settings.gameDisplay==carousel){ + gameCarousel.Reload(gameList, gameCnt);} + gamecntTxt.SetTextf("%s: %i",LANGUAGE.Games, gameCnt); + selectedold = 1; + favoriteBtn.ResetState(); + Settings.fave ? (favoriteBtn.SetImage(&favoriteBtnImg),favoriteBtn.SetImageOver(&favoriteBtnImg), + favoriteBtn.SetAlpha(255)) : (favoriteBtn.SetImage(&favoriteBtnImg_g), + favoriteBtn.SetImageOver(&favoriteBtnImg_g), favoriteBtn.SetAlpha(180)); + */ + } - else if(abcBtn.GetState() == STATE_CLICKED) - { - if(Settings.sort != all) { - Settings.sort=all; - if(isSdInserted()) { - cfg_save_global(); - } - __Menu_GetEntries(); - /* - if (Settings.gameDisplay==list){ - gameBrowser.Reload(gameList, gameCnt);} - else if (Settings.gameDisplay==grid){ - gameGrid.Reload(gameList, gameCnt);} - else if (Settings.gameDisplay==carousel){ - gameCarousel.Reload(gameList, gameCnt);} - selectedold = 1; - abcBtn.SetImage(&abcBtnImg); - abcBtn.SetImageOver(&abcBtnImg); - abcBtn.SetAlpha(255); - countBtn.SetImage(&countBtnImg_g); - countBtn.SetImageOver(&countBtnImg_g); - countBtn.SetAlpha(180); - */ - menu = MENU_DISCLIST; - break; - } - abcBtn.ResetState(); - } + else if(abcBtn.GetState() == STATE_CLICKED) + { + if(Settings.sort != all) { + Settings.sort=all; + if(isSdInserted()) { + cfg_save_global(); + } + __Menu_GetEntries(); + /* + if (Settings.gameDisplay==list){ + gameBrowser.Reload(gameList, gameCnt);} + else if (Settings.gameDisplay==grid){ + gameGrid.Reload(gameList, gameCnt);} + else if (Settings.gameDisplay==carousel){ + gameCarousel.Reload(gameList, gameCnt);} + selectedold = 1; + abcBtn.SetImage(&abcBtnImg); + abcBtn.SetImageOver(&abcBtnImg); + abcBtn.SetAlpha(255); + countBtn.SetImage(&countBtnImg_g); + countBtn.SetImageOver(&countBtnImg_g); + countBtn.SetAlpha(180); + */ + menu = MENU_DISCLIST; + break; + } + abcBtn.ResetState(); + } - else if(countBtn.GetState() == STATE_CLICKED) - { - if(Settings.sort != pcount) { - Settings.sort=pcount; - if(isSdInserted()) { - cfg_save_global(); - } - __Menu_GetEntries(); - /* - if (Settings.gameDisplay==list){ - gameBrowser.Reload(gameList, gameCnt);} - else if (Settings.gameDisplay==grid){ - gameGrid.Reload(gameList, gameCnt);} - else if (Settings.gameDisplay==carousel){ - gameCarousel.Reload(gameList, gameCnt);} - selectedold = 1; - abcBtn.SetImage(&abcBtnImg_g); - abcBtn.SetImageOver(&abcBtnImg_g); - abcBtn.SetAlpha(180); - countBtn.SetImage(&countBtnImg); - countBtn.SetImageOver(&countBtnImg); - countBtn.SetAlpha(255); - */ - menu = MENU_DISCLIST; - break; - } - countBtn.ResetState(); + else if(countBtn.GetState() == STATE_CLICKED) + { + if(Settings.sort != pcount) { + Settings.sort=pcount; + if(isSdInserted()) { + cfg_save_global(); + } + __Menu_GetEntries(); + /* + if (Settings.gameDisplay==list){ + gameBrowser.Reload(gameList, gameCnt);} + else if (Settings.gameDisplay==grid){ + gameGrid.Reload(gameList, gameCnt);} + else if (Settings.gameDisplay==carousel){ + gameCarousel.Reload(gameList, gameCnt);} + selectedold = 1; + abcBtn.SetImage(&abcBtnImg_g); + abcBtn.SetImageOver(&abcBtnImg_g); + abcBtn.SetAlpha(180); + countBtn.SetImage(&countBtnImg); + countBtn.SetImageOver(&countBtnImg); + countBtn.SetAlpha(255); + */ + menu = MENU_DISCLIST; + break; + } + countBtn.ResetState(); - } + } - else if(listBtn.GetState() == STATE_CLICKED) { - if (Settings.gameDisplay!=list){/* - if (Settings.gameDisplay==grid) { - mainWindow->Remove(&gameGrid); - gridBtn.SetImage(&gridBtnImg_g); - gridBtn.SetImageOver(&gridBtnImg_g); - gridBtn.SetAlpha(180); - } - if (Settings.gameDisplay==carousel) { - mainWindow->Remove(&gameCarousel); - carouselBtn.SetImage(&carouselBtnImg_g); - carouselBtn.SetImageOver(&carouselBtnImg_g); - carouselBtn.SetAlpha(180); - } - HaltGui(); - mainWindow->Remove(&w); - */ - Settings.gameDisplay=list; - menu = MENU_DISCLIST; + else if(listBtn.GetState() == STATE_CLICKED) { + if (Settings.gameDisplay!=list){/* + if (Settings.gameDisplay==grid) { + mainWindow->Remove(&gameGrid); + gridBtn.SetImage(&gridBtnImg_g); + gridBtn.SetImageOver(&gridBtnImg_g); + gridBtn.SetAlpha(180); + } + if (Settings.gameDisplay==carousel) { + mainWindow->Remove(&gameCarousel); + carouselBtn.SetImage(&carouselBtnImg_g); + carouselBtn.SetImageOver(&carouselBtnImg_g); + carouselBtn.SetAlpha(180); + } + HaltGui(); + mainWindow->Remove(&w); + */ + Settings.gameDisplay=list; + menu = MENU_DISCLIST; listBtn.ResetState(); - break; + break; } else { - /*gameBrowser.Reload(gameList, gameCnt); // initialize before append - mainWindow->Append(&gameBrowser); - mainWindow->Append(&w); - ResumeGui(); - listBtn.SetImage(&listBtnImg); - listBtn.SetImageOver(&listBtnImg); - listBtn.SetAlpha(255); - if(CFG.widescreen) - { - favoriteBtn.SetPosition(THEME.favorite_x, THEME.favorite_y); - abcBtn.SetPosition(THEME.abc_x, THEME.abc_y); - countBtn.SetPosition(THEME.count_x, THEME.count_y); - listBtn.SetPosition(THEME.list_x, THEME.list_y); - gridBtn.SetPosition(THEME.grid_x, THEME.grid_y); - carouselBtn.SetPosition(THEME.carousel_x, THEME.carousel_y); - } else { - favoriteBtn.SetPosition(THEME.favorite_x-20, THEME.favorite_y); - abcBtn.SetPosition(THEME.abc_x-12, THEME.abc_y); - countBtn.SetPosition(THEME.count_x-4, THEME.count_y); - listBtn.SetPosition(THEME.list_x+4, THEME.list_y); - gridBtn.SetPosition(THEME.grid_x+12, THEME.grid_y); - carouselBtn.SetPosition(THEME.carousel_x+20, THEME.carousel_y); - } - if((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) { - clockTime.SetPosition(THEME.clock_x, THEME.clock_y); - clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y); - w.Append(&clockTime); - w.Append(&clockTimeBack); - } - w.Append(&favoriteBtn); - w.Append(&abcBtn); - w.Append(&countBtn); - w.Append(&listBtn); - w.Append(&gridBtn); - w.Append(&carouselBtn); - w.Append(&DownloadBtn); - if(isSdInserted()) { - cfg_save_global(); - } - } - */ - listBtn.ResetState(); + /*gameBrowser.Reload(gameList, gameCnt); // initialize before append + mainWindow->Append(&gameBrowser); + mainWindow->Append(&w); + ResumeGui(); + listBtn.SetImage(&listBtnImg); + listBtn.SetImageOver(&listBtnImg); + listBtn.SetAlpha(255); + if(CFG.widescreen) + { + favoriteBtn.SetPosition(THEME.favorite_x, THEME.favorite_y); + abcBtn.SetPosition(THEME.abc_x, THEME.abc_y); + countBtn.SetPosition(THEME.count_x, THEME.count_y); + listBtn.SetPosition(THEME.list_x, THEME.list_y); + gridBtn.SetPosition(THEME.grid_x, THEME.grid_y); + carouselBtn.SetPosition(THEME.carousel_x, THEME.carousel_y); + } else { + favoriteBtn.SetPosition(THEME.favorite_x-20, THEME.favorite_y); + abcBtn.SetPosition(THEME.abc_x-12, THEME.abc_y); + countBtn.SetPosition(THEME.count_x-4, THEME.count_y); + listBtn.SetPosition(THEME.list_x+4, THEME.list_y); + gridBtn.SetPosition(THEME.grid_x+12, THEME.grid_y); + carouselBtn.SetPosition(THEME.carousel_x+20, THEME.carousel_y); + } + if((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) { + clockTime.SetPosition(THEME.clock_x, THEME.clock_y); + clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y); + w.Append(&clockTime); + w.Append(&clockTimeBack); + } + w.Append(&favoriteBtn); + w.Append(&abcBtn); + w.Append(&countBtn); + w.Append(&listBtn); + w.Append(&gridBtn); + w.Append(&carouselBtn); + w.Append(&DownloadBtn); + if(isSdInserted()) { + cfg_save_global(); + } + } + */ + listBtn.ResetState(); } - } + } - else if (gridBtn.GetState() == STATE_CLICKED) { - if (Settings.gameDisplay!=grid){ - /* - if (Settings.gameDisplay==list) { - mainWindow->Remove(&gameBrowser); - if (GameIDTxt) w.Remove(GameIDTxt); - if (GameRegionTxt) w.Remove(GameRegionTxt); - w.Remove(&DownloadBtn); - listBtn.SetImage(&listBtnImg_g); - listBtn.SetImageOver(&listBtnImg_g); - listBtn.SetAlpha(180); - } - if (Settings.gameDisplay==carousel) { - mainWindow->Remove(&gameCarousel); - carouselBtn.SetImage(&carouselBtnImg_g); - carouselBtn.SetImageOver(&carouselBtnImg_g); - carouselBtn.SetAlpha(180); - } - HaltGui(); - mainWindow->Remove(&w); - */ - Settings.gameDisplay=grid; - menu = MENU_DISCLIST; + + else if (gridBtn.GetState() == STATE_CLICKED) { + if (Settings.gameDisplay!=grid){ + /* + if (Settings.gameDisplay==list) { + mainWindow->Remove(&gameBrowser); + if (GameIDTxt) w.Remove(GameIDTxt); + if (GameRegionTxt) w.Remove(GameRegionTxt); + w.Remove(&DownloadBtn); + listBtn.SetImage(&listBtnImg_g); + listBtn.SetImageOver(&listBtnImg_g); + listBtn.SetAlpha(180); + } + if (Settings.gameDisplay==carousel) { + mainWindow->Remove(&gameCarousel); + carouselBtn.SetImage(&carouselBtnImg_g); + carouselBtn.SetImageOver(&carouselBtnImg_g); + carouselBtn.SetAlpha(180); + } + HaltGui(); + mainWindow->Remove(&w); + */ + Settings.gameDisplay=grid; + menu = MENU_DISCLIST; gridBtn.ResetState(); - break; - } else { - /* - gameGrid.Reload(gameList, gameCnt); // initialize before append - mainWindow->Append(&gameGrid); - mainWindow->Append(&w); - ResumeGui(); - gridBtn.SetImage(&gridBtnImg); - gridBtn.SetImageOver(&gridBtnImg); - gridBtn.SetAlpha(255); - if(CFG.widescreen) - { - favoriteBtn.SetPosition(THEME.favorite_x-THEME.sortBarOffset, THEME.favorite_y); - abcBtn.SetPosition(THEME.abc_x-THEME.sortBarOffset, THEME.abc_y); - countBtn.SetPosition(THEME.count_x-THEME.sortBarOffset, THEME.count_y); - listBtn.SetPosition(THEME.list_x-THEME.sortBarOffset, THEME.list_y); - gridBtn.SetPosition(THEME.grid_x-THEME.sortBarOffset, THEME.grid_y); - carouselBtn.SetPosition(THEME.carousel_x-THEME.sortBarOffset, THEME.carousel_y); - } else { - favoriteBtn.SetPosition(THEME.favorite_x-20-THEME.sortBarOffset, THEME.favorite_y); - abcBtn.SetPosition(THEME.abc_x-12-THEME.sortBarOffset, THEME.abc_y); - countBtn.SetPosition(THEME.count_x-4-THEME.sortBarOffset, THEME.count_y); - listBtn.SetPosition(THEME.list_x+4-THEME.sortBarOffset, THEME.list_y); - gridBtn.SetPosition(THEME.grid_x+12-THEME.sortBarOffset, THEME.grid_y); - carouselBtn.SetPosition(THEME.carousel_x+20-THEME.sortBarOffset, THEME.carousel_y); - } - if((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) { - clockTime.SetPosition(THEME.clock_x, THEME.clock_y+3); - clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y+3); - w.Append(&clockTime); - w.Append(&clockTimeBack); - } - w.Append(&favoriteBtn); - w.Append(&abcBtn); - w.Append(&countBtn); - w.Append(&listBtn); - w.Append(&gridBtn); - w.Append(&carouselBtn); - if(isSdInserted()) { - cfg_save_global(); - } - }*/ - gridBtn.ResetState(); - } - } + break; + } else { + /* + gameGrid.Reload(gameList, gameCnt); // initialize before append + mainWindow->Append(&gameGrid); + mainWindow->Append(&w); + ResumeGui(); + gridBtn.SetImage(&gridBtnImg); + gridBtn.SetImageOver(&gridBtnImg); + gridBtn.SetAlpha(255); + if(CFG.widescreen) + { + favoriteBtn.SetPosition(THEME.favorite_x-THEME.sortBarOffset, THEME.favorite_y); + abcBtn.SetPosition(THEME.abc_x-THEME.sortBarOffset, THEME.abc_y); + countBtn.SetPosition(THEME.count_x-THEME.sortBarOffset, THEME.count_y); + listBtn.SetPosition(THEME.list_x-THEME.sortBarOffset, THEME.list_y); + gridBtn.SetPosition(THEME.grid_x-THEME.sortBarOffset, THEME.grid_y); + carouselBtn.SetPosition(THEME.carousel_x-THEME.sortBarOffset, THEME.carousel_y); + } else { + favoriteBtn.SetPosition(THEME.favorite_x-20-THEME.sortBarOffset, THEME.favorite_y); + abcBtn.SetPosition(THEME.abc_x-12-THEME.sortBarOffset, THEME.abc_y); + countBtn.SetPosition(THEME.count_x-4-THEME.sortBarOffset, THEME.count_y); + listBtn.SetPosition(THEME.list_x+4-THEME.sortBarOffset, THEME.list_y); + gridBtn.SetPosition(THEME.grid_x+12-THEME.sortBarOffset, THEME.grid_y); + carouselBtn.SetPosition(THEME.carousel_x+20-THEME.sortBarOffset, THEME.carousel_y); + } + if((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) { + clockTime.SetPosition(THEME.clock_x, THEME.clock_y+3); + clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y+3); + w.Append(&clockTime); + w.Append(&clockTimeBack); + } + w.Append(&favoriteBtn); + w.Append(&abcBtn); + w.Append(&countBtn); + w.Append(&listBtn); + w.Append(&gridBtn); + w.Append(&carouselBtn); + if(isSdInserted()) { + cfg_save_global(); + } + }*/ + gridBtn.ResetState(); + } + } - else if (carouselBtn.GetState() == STATE_CLICKED) { - if (Settings.gameDisplay!=carousel) { - /* - if (Settings.gameDisplay==list) - mainWindow->Remove(&gameBrowser); - if (GameIDTxt) w.Remove(GameIDTxt); - if (GameRegionTxt) w.Remove(GameRegionTxt); - w.Remove(&DownloadBtn); - listBtn.SetImage(&listBtnImg_g); - listBtn.SetImageOver(&listBtnImg_g); - listBtn.SetAlpha(180); - if (Settings.gameDisplay==grid) - mainWindow->Remove(&gameGrid); - gridBtn.SetImage(&gridBtnImg_g); - gridBtn.SetImageOver(&gridBtnImg_g); - gridBtn.SetAlpha(180); - HaltGui(); - mainWindow->Remove(&w); - */ - Settings.gameDisplay=carousel; - menu = MENU_DISCLIST; + else if (carouselBtn.GetState() == STATE_CLICKED) { + if (Settings.gameDisplay!=carousel) { + /* + if (Settings.gameDisplay==list) + mainWindow->Remove(&gameBrowser); + if (GameIDTxt) w.Remove(GameIDTxt); + if (GameRegionTxt) w.Remove(GameRegionTxt); + w.Remove(&DownloadBtn); + listBtn.SetImage(&listBtnImg_g); + listBtn.SetImageOver(&listBtnImg_g); + listBtn.SetAlpha(180); + if (Settings.gameDisplay==grid) + mainWindow->Remove(&gameGrid); + gridBtn.SetImage(&gridBtnImg_g); + gridBtn.SetImageOver(&gridBtnImg_g); + gridBtn.SetAlpha(180); + HaltGui(); + mainWindow->Remove(&w); + */ + Settings.gameDisplay=carousel; + menu = MENU_DISCLIST; carouselBtn.ResetState(); - break; + break; } else { - /* - gameCarousel.Reload(gameList, gameCnt); // initialize before append - mainWindow->Append(&gameCarousel); - mainWindow->Append(&w); - ResumeGui(); - carouselBtn.SetImage(&carouselBtnImg); - carouselBtn.SetImageOver(&carouselBtnImg); - carouselBtn.SetAlpha(255); - if(CFG.widescreen) - { - favoriteBtn.SetPosition(THEME.favorite_x-THEME.sortBarOffset, THEME.favorite_y); - abcBtn.SetPosition(THEME.abc_x-THEME.sortBarOffset, THEME.abc_y); - countBtn.SetPosition(THEME.count_x-THEME.sortBarOffset, THEME.count_y); - listBtn.SetPosition(THEME.list_x-THEME.sortBarOffset, THEME.list_y); - gridBtn.SetPosition(THEME.grid_x-THEME.sortBarOffset, THEME.grid_y); - carouselBtn.SetPosition(THEME.carousel_x-THEME.sortBarOffset, THEME.carousel_y); - } else { - favoriteBtn.SetPosition(THEME.favorite_x-20-THEME.sortBarOffset, THEME.favorite_y); - abcBtn.SetPosition(THEME.abc_x-12-THEME.sortBarOffset, THEME.abc_y); - countBtn.SetPosition(THEME.count_x-4-THEME.sortBarOffset, THEME.count_y); - listBtn.SetPosition(THEME.list_x+4-THEME.sortBarOffset, THEME.list_y); - gridBtn.SetPosition(THEME.grid_x+12-THEME.sortBarOffset, THEME.grid_y); - carouselBtn.SetPosition(THEME.carousel_x+20-THEME.sortBarOffset, THEME.carousel_y); - } - if((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) { - clockTime.SetPosition(THEME.clock_x, THEME.clock_y+3); - clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y+3); - w.Append(&clockTime); - w.Append(&clockTimeBack); - } - w.Append(&favoriteBtn); - w.Append(&abcBtn); - w.Append(&countBtn); - w.Append(&listBtn); - w.Append(&gridBtn); - w.Append(&carouselBtn); - if(isSdInserted()) { - cfg_save_global(); - } - } - */ - carouselBtn.ResetState(); + /* + gameCarousel.Reload(gameList, gameCnt); // initialize before append + mainWindow->Append(&gameCarousel); + mainWindow->Append(&w); + ResumeGui(); + carouselBtn.SetImage(&carouselBtnImg); + carouselBtn.SetImageOver(&carouselBtnImg); + carouselBtn.SetAlpha(255); + if(CFG.widescreen) + { + favoriteBtn.SetPosition(THEME.favorite_x-THEME.sortBarOffset, THEME.favorite_y); + abcBtn.SetPosition(THEME.abc_x-THEME.sortBarOffset, THEME.abc_y); + countBtn.SetPosition(THEME.count_x-THEME.sortBarOffset, THEME.count_y); + listBtn.SetPosition(THEME.list_x-THEME.sortBarOffset, THEME.list_y); + gridBtn.SetPosition(THEME.grid_x-THEME.sortBarOffset, THEME.grid_y); + carouselBtn.SetPosition(THEME.carousel_x-THEME.sortBarOffset, THEME.carousel_y); + } else { + favoriteBtn.SetPosition(THEME.favorite_x-20-THEME.sortBarOffset, THEME.favorite_y); + abcBtn.SetPosition(THEME.abc_x-12-THEME.sortBarOffset, THEME.abc_y); + countBtn.SetPosition(THEME.count_x-4-THEME.sortBarOffset, THEME.count_y); + listBtn.SetPosition(THEME.list_x+4-THEME.sortBarOffset, THEME.list_y); + gridBtn.SetPosition(THEME.grid_x+12-THEME.sortBarOffset, THEME.grid_y); + carouselBtn.SetPosition(THEME.carousel_x+20-THEME.sortBarOffset, THEME.carousel_y); + } + if((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) { + clockTime.SetPosition(THEME.clock_x, THEME.clock_y+3); + clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y+3); + w.Append(&clockTime); + w.Append(&clockTimeBack); + } + w.Append(&favoriteBtn); + w.Append(&abcBtn); + w.Append(&countBtn); + w.Append(&listBtn); + w.Append(&gridBtn); + w.Append(&carouselBtn); + if(isSdInserted()) { + cfg_save_global(); + } + } + */ + carouselBtn.ResetState(); } - } - - if (Settings.gameDisplay==grid){ - int selectimg; - selectimg = gameGrid->GetSelectedOption(); - gameSelected = gameGrid->GetClickedOption(); - } - - if (Settings.gameDisplay==carousel){ - int selectimg; - selectimg = gameCarousel->GetSelectedOption(); - gameSelected = gameCarousel->GetClickedOption(); - } - - if (Settings.gameDisplay==list) { - //Get selected game under cursor - int selectimg;//, promptnumber; - char ID[4]; - char IDfull[7]; - selectimg = gameBrowser->GetSelectedOption(); - gameSelected = gameBrowser->GetClickedOption(); - - - if (gameSelected > 0) //if click occured - selectimg = gameSelected; - - if ((selectimg >= 0) && (selectimg < (s32) gameCnt)) - { - if (selectimg != selectedold) - { - selectedold = selectimg;//update displayed cover, game ID, and region if the selected game changes - struct discHdr *header = &gameList[selectimg]; + } + else if (gameInfo.GetState() == STATE_CLICKED) { + struct discHdr *header = &gameList[selectImg1]; snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]); snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); - w.Remove(&DownloadBtn); - - if (GameIDTxt) - { - w.Remove(GameIDTxt); - delete GameIDTxt; - GameIDTxt = NULL; - } - if(GameRegionTxt) - { - w.Remove(GameRegionTxt); - delete GameRegionTxt; - GameRegionTxt = NULL; - } - - switch(header->id[3]) - { - case 'E': - sprintf(gameregion,"NTSC U"); - break; - - case 'J': - sprintf(gameregion,"NTSC J"); - break; - - case 'K': - sprintf(gameregion,"NTSC K"); - break; - - case 'P': - case 'D': - case 'F': - case 'X': - case 'S': - case 'Y': - sprintf(gameregion," PAL "); - break; - } - - //load game cover - if (cover) - { - delete cover; - cover = NULL; - } - - snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, IDfull); - cover = new GuiImageData(imgPath,0); //load short id - if (!cover->GetImage()) //if could not load the short id image - { - delete cover; - snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, ID); - cover = new GuiImageData(imgPath, 0); //load full id image - if (!cover->GetImage()) - { - delete cover; - snprintf(imgPath, sizeof(imgPath), "%snoimage.png", Settings.covers_path); - cover = new GuiImageData(imgPath, nocover_png); //load no image - } - } - - if (coverImg) - { - delete coverImg; - coverImg = NULL; - } - coverImg = new GuiImage(cover); - coverImg->SetWidescreen(CFG.widescreen); - - DownloadBtn.SetImage(coverImg);// put the new image on the download button - w.Append(&DownloadBtn); - - if ((Settings.sinfo == GameID) || (Settings.sinfo == Both)){ - GameIDTxt = new GuiText(IDfull, 22, (GXColor){THEME.info_r, THEME.info_g, THEME.info_b, 255}); - GameIDTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); - GameIDTxt->SetPosition(THEME.id_x,THEME.id_y); - GameIDTxt->SetEffect(EFFECT_FADE, 20); - w.Append(GameIDTxt); - } - - if ((Settings.sinfo == GameRegion) || (Settings.sinfo == Both)){ - GameRegionTxt = new GuiText(gameregion, 22, (GXColor){THEME.info_r, THEME.info_g, THEME.info_b, 255}); - GameRegionTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); - GameRegionTxt->SetPosition(THEME.region_x, THEME.region_y); - GameRegionTxt->SetEffect(EFFECT_FADE, 20); - w.Append(GameRegionTxt); - } - } + + choice = showGameInfo(IDfull, header->id); + if (choice>0){ + gameInfo.ResetState(); + //break; } } - if ((gameSelected >= 0) && (gameSelected < (s32)gameCnt)) - { - struct discHdr *header = &gameList[gameSelected]; - WBFS_GameSize(header->id, &size); - if (strlen(get_title(header)) < (MAX_CHARACTERS + 3)) { - sprintf(text, "%s", get_title(header)); - } - else { - strncpy(text, get_title(header), MAX_CHARACTERS); - text[MAX_CHARACTERS] = '\0'; - strncat(text, "...", 3); - } + if (Settings.gameDisplay==grid){ + int selectimg; + selectimg = gameGrid->GetSelectedOption(); + gameSelected = gameGrid->GetClickedOption(); + selectImg1=selectimg; + } - if (Settings.qboot == yes)//quickboot game - { - - wiilight(0); - //////////save game play count//////////////// - extern u8 favorite; - extern u16 count; - struct Game_NUM* game_num = CFG_get_game_num(header->id); - - if (game_num) - { - favorite = game_num->favorite; - count = game_num->count; - - }count+=1; - - if(isSdInserted()) { - if (CFG_save_game_num(header->id)) - { - //WindowPrompt(LANGUAGE.SuccessfullySaved, 0, LANGUAGE.ok, 0,0,0); + if (Settings.gameDisplay==carousel){ + int selectimg; + selectimg = gameCarousel->GetSelectedOption(); + gameSelected = gameCarousel->GetClickedOption(); + selectImg1=selectimg; } - else - { - WindowPrompt(LANGUAGE.SaveFailed, 0, LANGUAGE.ok, 0,0,0); - } - } - ////////////end save play count////////////// + if (Settings.gameDisplay==list) { + //Get selected game under cursor + int selectimg;//, promptnumber; + + selectimg = gameBrowser->GetSelectedOption(); + gameSelected = gameBrowser->GetClickedOption(); + selectImg1=selectimg; - struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); + if (gameSelected > 0) //if click occured + selectimg = gameSelected; + + if ((selectimg >= 0) && (selectimg < (s32) gameCnt)) + { + if (selectimg != selectedold) + { + selectedold = selectimg;//update displayed cover, game ID, and region if the selected game changes + struct discHdr *header = &gameList[selectimg]; + snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]); + snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); + w.Remove(&DownloadBtn); + + if (GameIDTxt) + { + w.Remove(GameIDTxt); + delete GameIDTxt; + GameIDTxt = NULL; + } + if(GameRegionTxt) + { + w.Remove(GameRegionTxt); + delete GameRegionTxt; + GameRegionTxt = NULL; + } + + switch(header->id[3]) + { + case 'E': + sprintf(gameregion,"NTSC U"); + break; + + case 'J': + sprintf(gameregion,"NTSC J"); + break; + + case 'K': + sprintf(gameregion,"NTSC K"); + break; + + + case 'P': + case 'D': + case 'F': + case 'X': + case 'S': + case 'Y': + sprintf(gameregion," PAL "); + break; + } + + //load game cover + if (cover) + { + delete cover; + cover = NULL; + } + + snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, IDfull); + cover = new GuiImageData(imgPath,0); //load short id + if (!cover->GetImage()) //if could not load the short id image + { + delete cover; + snprintf(imgPath, sizeof(imgPath), "%s%s.png", Settings.covers_path, ID); + cover = new GuiImageData(imgPath, 0); //load full id image + if (!cover->GetImage()) + { + delete cover; + snprintf(imgPath, sizeof(imgPath), "%snoimage.png", Settings.covers_path); + cover = new GuiImageData(imgPath, nocover_png); //load no image + } + } + + if (coverImg) + { + delete coverImg; + coverImg = NULL; + } + coverImg = new GuiImage(cover); + coverImg->SetWidescreen(CFG.widescreen); + + DownloadBtn.SetImage(coverImg);// put the new image on the download button + w.Append(&DownloadBtn); + + if ((Settings.sinfo == GameID) || (Settings.sinfo == Both)){ + GameIDTxt = new GuiText(IDfull, 22, (GXColor){THEME.info_r, THEME.info_g, THEME.info_b, 255}); + GameIDTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + GameIDTxt->SetPosition(THEME.id_x,THEME.id_y); + GameIDTxt->SetEffect(EFFECT_FADE, 20); + w.Append(GameIDTxt); + } + + if ((Settings.sinfo == GameRegion) || (Settings.sinfo == Both)){ + GameRegionTxt = new GuiText(gameregion, 22, (GXColor){THEME.info_r, THEME.info_g, THEME.info_b, 255}); + GameRegionTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + GameRegionTxt->SetPosition(THEME.region_x, THEME.region_y); + GameRegionTxt->SetEffect(EFFECT_FADE, 20); + w.Append(GameRegionTxt); + } + } + } + } + + if ((gameSelected >= 0) && (gameSelected < (s32)gameCnt)) + { + struct discHdr *header = &gameList[gameSelected]; + WBFS_GameSize(header->id, &size); + if (strlen(get_title(header)) < (MAX_CHARACTERS + 3)) { + sprintf(text, "%s", get_title(header)); + } + else { + strncpy(text, get_title(header), MAX_CHARACTERS); + text[MAX_CHARACTERS] = '\0'; + strncat(text, "...", 3); + } + + if (Settings.qboot == yes)//quickboot game + { + + wiilight(0); + //////////save game play count//////////////// + extern u8 favorite; + extern u16 count; + struct Game_NUM* game_num = CFG_get_game_num(header->id); + + if (game_num) + { + favorite = game_num->favorite; + count = game_num->count; + + }count+=1; + + if(isSdInserted()) { + if (CFG_save_game_num(header->id)) + { + //WindowPrompt(LANGUAGE.SuccessfullySaved, 0, LANGUAGE.ok, 0,0,0); + } + else + { + WindowPrompt(LANGUAGE.SaveFailed, 0, LANGUAGE.ok, 0,0,0); + } + } + ////////////end save play count////////////// + + struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); if (game_cfg)//if there are saved settings for this game use them { @@ -1235,64 +1268,64 @@ static int MenuDiscList() // if we have used the network or cios222 we need to reload the disklist if(networkisinitialized == 1 || ios2 == 1 || Settings.cios == ios222) - { - if(ios2 == 1) - { - ret = Sys_IosReload(222); + { + if(ios2 == 1) + { + ret = Sys_IosReload(222); - if(ret < 0) - { - WindowPrompt(LANGUAGE.YoudonthavecIOS,LANGUAGE.LoadingincIOS,LANGUAGE.ok, 0,0,0); - Sys_IosReload(249); - ios2 = 0; - } - } - else - { - ret = Sys_IosReload(249); - } - } + if(ret < 0) + { + WindowPrompt(LANGUAGE.YoudonthavecIOS,LANGUAGE.LoadingincIOS,LANGUAGE.ok, 0,0,0); + Sys_IosReload(249); + ios2 = 0; + } + } + else + { + ret = Sys_IosReload(249); + } + } - /* Set USB mode */ - ret = Disc_SetUSB(header->id, ios2); - if (ret < 0) { - sprintf(text, "%s %i", LANGUAGE.Error,ret); - WindowPrompt( - LANGUAGE.FailedtosetUSB, - text, - LANGUAGE.ok,0,0,0); - } - else { - /* Open disc */ - ret = Disc_Open(); - if (ret < 0) { - sprintf(text, "%s %i",LANGUAGE.Error, ret); - WindowPrompt( - LANGUAGE.Failedtoboot, - text, - LANGUAGE.ok,0,0,0); - } - else { - menu = MENU_EXIT; - } - } - break; - } - bool returnHere = true;// prompt to start game - while (returnHere) - { + /* Set USB mode */ + ret = Disc_SetUSB(header->id, ios2); + if (ret < 0) { + sprintf(text, "%s %i", LANGUAGE.Error,ret); + WindowPrompt( + LANGUAGE.FailedtosetUSB, + text, + LANGUAGE.ok,0,0,0); + } + else { + /* Open disc */ + ret = Disc_Open(); + if (ret < 0) { + sprintf(text, "%s %i",LANGUAGE.Error, ret); + WindowPrompt( + LANGUAGE.Failedtoboot, + text, + LANGUAGE.ok,0,0,0); + } + else { + menu = MENU_EXIT; + } + } + break; + } + bool returnHere = true;// prompt to start game + while (returnHere) + { - returnHere = false; - if(Settings.wiilight != 2) wiilight(1); - choice = GameWindowPrompt(); - header = &gameList[gameSelected]; //reset header + returnHere = false; + if(Settings.wiilight != 2) wiilight(1); + choice = GameWindowPrompt(); + header = &gameList[gameSelected]; //reset header - if(choice == 1) - { + if(choice == 1) + { - wiilight(0); - struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); - if (game_cfg)//if there are saved settings for this game use them + wiilight(0); + struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); + if (game_cfg)//if there are saved settings for this game use them { iosChoice = game_cfg->ios; } @@ -1305,6 +1338,7 @@ static int MenuDiscList() } } + int ios2; switch(iosChoice) { @@ -1322,112 +1356,113 @@ static int MenuDiscList() } // if we have used the network or cios222 we need to reload the disklist - if(networkisinitialized == 1 || ios2 == 1 || Settings.cios == ios222) - { - if(ios2 == 1) - { - ret = Sys_IosReload(222); - if(ret < 0) - { - WindowPrompt(LANGUAGE.YoudonthavecIOS,LANGUAGE.LoadingincIOS,LANGUAGE.ok, 0,0,0); - Sys_IosReload(249); - ios2 = 0; - } - } - else - { - ret = Sys_IosReload(249); - } - } + if(networkisinitialized == 1 || ios2 == 1 || Settings.cios == ios222) + { + if(ios2 == 1) + { + ret = Sys_IosReload(222); + if(ret < 0) + { + WindowPrompt(LANGUAGE.YoudonthavecIOS,LANGUAGE.LoadingincIOS,LANGUAGE.ok, 0,0,0); + Sys_IosReload(249); + ios2 = 0; + } + } + else + { + ret = Sys_IosReload(249); + } + } - /* Set USB mode */ - ret = Disc_SetUSB(header->id, ios2); - if (ret < 0) { - sprintf(text, "%s %i", LANGUAGE.Error, ret); - WindowPrompt( - LANGUAGE.FailedtosetUSB, - text, - LANGUAGE.ok,0,0,0); - } - else { - /* Open disc */ - ret = Disc_Open(); - if (ret < 0) { - sprintf(text, "%s %i",LANGUAGE.Error, ret); - WindowPrompt( - LANGUAGE.Failedtoboot, - text, - LANGUAGE.ok,0,0,0); + /* Set USB mode */ + ret = Disc_SetUSB(header->id, ios2); + if (ret < 0) { + sprintf(text, "%s %i", LANGUAGE.Error, ret); + WindowPrompt( + LANGUAGE.FailedtosetUSB, + text, + LANGUAGE.ok,0,0,0); + } + else { + /* Open disc */ + ret = Disc_Open(); + if (ret < 0) { + sprintf(text, "%s %i",LANGUAGE.Error, ret); + WindowPrompt( + LANGUAGE.Failedtoboot, + text, + LANGUAGE.ok,0,0,0); - } - else { - menu = MENU_EXIT; - } - } - } - else if (choice == 2) - { - wiilight(0); - HaltGui(); + } + else { + menu = MENU_EXIT; + } + } + } + else if (choice == 2) + { + wiilight(0); + HaltGui(); if (Settings.gameDisplay==list) mainWindow->Remove(gameBrowser); else if (Settings.gameDisplay==grid) mainWindow->Remove(gameGrid); else if (Settings.gameDisplay==carousel) mainWindow->Remove(gameCarousel); mainWindow->Remove(&w); ResumeGui(); - int settret = GameSettings(header); - HaltGui(); + int settret = GameSettings(header); + HaltGui(); if (Settings.gameDisplay==list) mainWindow->Append(gameBrowser); else if (Settings.gameDisplay==grid) mainWindow->Append(gameGrid); else if (Settings.gameDisplay==carousel) mainWindow->Append(gameCarousel); mainWindow->Append(&w); ResumeGui(); - if (settret == 1) //if deleted - { - menu = MENU_DISCLIST; - break; - } - returnHere = true; - } + if (settret == 1) //if deleted + { + menu = MENU_DISCLIST; + break; + } + returnHere = true; + } - else if (choice == 3) //WBFS renaming - { - wiilight(0); - //enter new game title - char entered[60]; - snprintf(entered, sizeof(entered), "%s", get_title(header)); - entered[59] = '\0'; - int result = OnScreenKeyboard(entered, 60,0); - if (result == 1) { - WBFS_RenameGame(header->id, entered); - __Menu_GetEntries(); - menu = MENU_DISCLIST; - } - } + else if (choice == 3) //WBFS renaming + { + wiilight(0); + //enter new game title + char entered[60]; + snprintf(entered, sizeof(entered), "%s", get_title(header)); + entered[59] = '\0'; + int result = OnScreenKeyboard(entered, 60,0); + if (result == 1) { + WBFS_RenameGame(header->id, entered); + __Menu_GetEntries(); + menu = MENU_DISCLIST; + } + } - else if(choice == 0) - if (Settings.gameDisplay==list){gameBrowser->SetFocus(1);} - else if (Settings.gameDisplay==grid){gameGrid->SetFocus(1);} - else if (Settings.gameDisplay==carousel){gameCarousel->SetFocus(1);} - } - } - } + else if(choice == 0) + if (Settings.gameDisplay==list){gameBrowser->SetFocus(1);} + else if (Settings.gameDisplay==grid){gameGrid->SetFocus(1);} + else if (Settings.gameDisplay==carousel){gameCarousel->SetFocus(1);} + } + } + } HaltGui(); - mainWindow->RemoveAll(); - mainWindow->Append(bgImg); - delete gameBrowser; - gameBrowser = NULL; - delete gameGrid; - gameGrid = NULL; - delete gameCarousel; - gameCarousel = NULL; - ResumeGui(); - return menu; + mainWindow->RemoveAll(); + mainWindow->Append(bgImg); + delete gameBrowser; + gameBrowser = NULL; + delete gameGrid; + gameGrid = NULL; + delete gameCarousel; + gameCarousel = NULL; + ResumeGui(); + return menu; } + /**************************************************************************** * MenuInstall ***************************************************************************/ diff --git a/source/mxml/mxml.h b/source/mxml/mxml.h new file mode 100644 index 00000000..8c47e75e --- /dev/null +++ b/source/mxml/mxml.h @@ -0,0 +1,305 @@ +/* + * "$Id: mxml.h 307 2007-09-15 20:03:15Z mike $" + * + * Header file for Mini-XML, a small XML-like file parsing library. + * + * Copyright 2003-2007 by Michael Sweet. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +/* + * Prevent multiple inclusion... + */ + +#ifndef _mxml_h_ +# define _mxml_h_ + +/* + * Include necessary headers... + */ + +# include +# include +# include +# include +# include + + +/* + * Constants... + */ + +# define MXML_TAB 8 /* Tabs every N columns */ + +# define MXML_NO_CALLBACK 0 /* Don't use a type callback */ +# define MXML_INTEGER_CALLBACK mxml_integer_cb + /* Treat all data as integers */ +# define MXML_OPAQUE_CALLBACK mxml_opaque_cb + /* Treat all data as opaque */ +# define MXML_REAL_CALLBACK mxml_real_cb + /* Treat all data as real numbers */ +# define MXML_TEXT_CALLBACK 0 /* Treat all data as text */ +# define MXML_IGNORE_CALLBACK mxml_ignore_cb + /* Ignore all non-element content */ + +# define MXML_NO_PARENT 0 /* No parent for the node */ + +# define MXML_DESCEND 1 /* Descend when finding/walking */ +# define MXML_NO_DESCEND 0 /* Don't descend when finding/walking */ +# define MXML_DESCEND_FIRST -1 /* Descend for first find */ + +# define MXML_WS_BEFORE_OPEN 0 /* Callback for before open tag */ +# define MXML_WS_AFTER_OPEN 1 /* Callback for after open tag */ +# define MXML_WS_BEFORE_CLOSE 2 /* Callback for before close tag */ +# define MXML_WS_AFTER_CLOSE 3 /* Callback for after close tag */ + +# define MXML_ADD_BEFORE 0 /* Add node before specified node */ +# define MXML_ADD_AFTER 1 /* Add node after specified node */ +# define MXML_ADD_TO_PARENT NULL /* Add node relative to parent */ + + +/* + * Data types... + */ + +typedef enum mxml_sax_event_e /**** SAX event type. ****/ +{ + MXML_SAX_CDATA, /* CDATA node */ + MXML_SAX_COMMENT, /* Comment node */ + MXML_SAX_DATA, /* Data node */ + MXML_SAX_DIRECTIVE, /* Processing directive node */ + MXML_SAX_ELEMENT_CLOSE, /* Element closed */ + MXML_SAX_ELEMENT_OPEN /* Element opened */ +} mxml_sax_event_t; + +typedef enum mxml_type_e /**** The XML node type. ****/ +{ + MXML_IGNORE = -1, /* Ignore/throw away node @since Mini-XML 2.3@ */ + MXML_ELEMENT, /* XML element with attributes */ + MXML_INTEGER, /* Integer value */ + MXML_OPAQUE, /* Opaque string */ + MXML_REAL, /* Real value */ + MXML_TEXT, /* Text fragment */ + MXML_CUSTOM /* Custom data @since Mini-XML 2.1@ */ +} mxml_type_t; + +typedef void (*mxml_custom_destroy_cb_t)(void *); + /**** Custom data destructor ****/ + +typedef void (*mxml_error_cb_t)(const char *); + /**** Error callback function ****/ + +typedef struct mxml_attr_s /**** An XML element attribute value. ****/ +{ + char *name; /* Attribute name */ + char *value; /* Attribute value */ +} mxml_attr_t; + +typedef struct mxml_element_s /**** An XML element value. ****/ +{ + char *name; /* Name of element */ + int num_attrs; /* Number of attributes */ + mxml_attr_t *attrs; /* Attributes */ +} mxml_element_t; + +typedef struct mxml_text_s /**** An XML text value. ****/ +{ + int whitespace; /* Leading whitespace? */ + char *string; /* Fragment string */ +} mxml_text_t; + +typedef struct mxml_custom_s /**** An XML custom value. @since Mini-XML 2.1@ ****/ +{ + void *data; /* Pointer to (allocated) custom data */ + mxml_custom_destroy_cb_t destroy; /* Pointer to destructor function */ +} mxml_custom_t; + +typedef union mxml_value_u /**** An XML node value. ****/ +{ + mxml_element_t element; /* Element */ + int integer; /* Integer number */ + char *opaque; /* Opaque string */ + double real; /* Real number */ + mxml_text_t text; /* Text fragment */ + mxml_custom_t custom; /* Custom data @since Mini-XML 2.1@ */ +} mxml_value_t; + +typedef struct mxml_node_s /**** An XML node. ****/ +{ + mxml_type_t type; /* Node type */ + struct mxml_node_s *next; /* Next node under same parent */ + struct mxml_node_s *prev; /* Previous node under same parent */ + struct mxml_node_s *parent; /* Parent node */ + struct mxml_node_s *child; /* First child node */ + struct mxml_node_s *last_child; /* Last child node */ + mxml_value_t value; /* Node value */ + int ref_count; /* Use count */ + void *user_data; /* User data */ +} mxml_node_t; + +typedef struct mxml_index_s /**** An XML node index. ****/ +{ + char *attr; /* Attribute used for indexing or NULL */ + int num_nodes; /* Number of nodes in index */ + int alloc_nodes; /* Allocated nodes in index */ + int cur_node; /* Current node */ + mxml_node_t **nodes; /* Node array */ +} mxml_index_t; + +typedef int (*mxml_custom_load_cb_t)(mxml_node_t *, const char *); + /**** Custom data load callback function ****/ + +typedef char *(*mxml_custom_save_cb_t)(mxml_node_t *); + /**** Custom data save callback function ****/ + +typedef mxml_type_t (*mxml_load_cb_t)(mxml_node_t *); + /**** Load callback function ****/ + +typedef const char *(*mxml_save_cb_t)(mxml_node_t *, int); + /**** Save callback function ****/ + +typedef void (*mxml_sax_cb_t)(mxml_node_t *, mxml_sax_event_t, void *); + /**** SAX callback function ****/ + + +/* + * C++ support... + */ + +# ifdef __cplusplus +extern "C" { +# endif /* __cplusplus */ + +/* + * Prototypes... + */ + +extern void mxmlAdd(mxml_node_t *parent, int where, + mxml_node_t *child, mxml_node_t *node); +extern void mxmlDelete(mxml_node_t *node); +extern void mxmlElementDeleteAttr(mxml_node_t *node, + const char *name); +extern const char *mxmlElementGetAttr(mxml_node_t *node, const char *name); +extern void mxmlElementSetAttr(mxml_node_t *node, const char *name, + const char *value); +extern void mxmlElementSetAttrf(mxml_node_t *node, const char *name, + const char *format, ...) +# ifdef __GNUC__ +__attribute__ ((__format__ (__printf__, 3, 4))) +# endif /* __GNUC__ */ +; +extern int mxmlEntityAddCallback(int (*cb)(const char *name)); +extern const char *mxmlEntityGetName(int val); +extern int mxmlEntityGetValue(const char *name); +extern void mxmlEntityRemoveCallback(int (*cb)(const char *name)); +extern mxml_node_t *mxmlFindElement(mxml_node_t *node, mxml_node_t *top, + const char *name, const char *attr, + const char *value, int descend); +extern void mxmlIndexDelete(mxml_index_t *ind); +extern mxml_node_t *mxmlIndexEnum(mxml_index_t *ind); +extern mxml_node_t *mxmlIndexFind(mxml_index_t *ind, + const char *element, + const char *value); +extern mxml_index_t *mxmlIndexNew(mxml_node_t *node, const char *element, + const char *attr); +extern mxml_node_t *mxmlIndexReset(mxml_index_t *ind); +extern mxml_node_t *mxmlLoadFd(mxml_node_t *top, int fd, + mxml_type_t (*cb)(mxml_node_t *)); +extern mxml_node_t *mxmlLoadFile(mxml_node_t *top, FILE *fp, + mxml_type_t (*cb)(mxml_node_t *)); +extern mxml_node_t *mxmlLoadString(mxml_node_t *top, const char *s, + mxml_type_t (*cb)(mxml_node_t *)); +extern mxml_node_t *mxmlNewCDATA(mxml_node_t *parent, const char *string); +extern mxml_node_t *mxmlNewCustom(mxml_node_t *parent, void *data, + mxml_custom_destroy_cb_t destroy); +extern mxml_node_t *mxmlNewElement(mxml_node_t *parent, const char *name); +extern mxml_node_t *mxmlNewInteger(mxml_node_t *parent, int integer); +extern mxml_node_t *mxmlNewOpaque(mxml_node_t *parent, const char *opaque); +extern mxml_node_t *mxmlNewReal(mxml_node_t *parent, double real); +extern mxml_node_t *mxmlNewText(mxml_node_t *parent, int whitespace, + const char *string); +extern mxml_node_t *mxmlNewTextf(mxml_node_t *parent, int whitespace, + const char *format, ...) +# ifdef __GNUC__ +__attribute__ ((__format__ (__printf__, 3, 4))) +# endif /* __GNUC__ */ +; +extern mxml_node_t *mxmlNewXML(const char *version); +extern int mxmlRelease(mxml_node_t *node); +extern void mxmlRemove(mxml_node_t *node); +extern int mxmlRetain(mxml_node_t *node); +extern char *mxmlSaveAllocString(mxml_node_t *node, + mxml_save_cb_t cb); +extern int mxmlSaveFd(mxml_node_t *node, int fd, + mxml_save_cb_t cb); +extern int mxmlSaveFile(mxml_node_t *node, FILE *fp, + mxml_save_cb_t cb); +extern int mxmlSaveString(mxml_node_t *node, char *buffer, + int bufsize, mxml_save_cb_t cb); +extern mxml_node_t *mxmlSAXLoadFd(mxml_node_t *top, int fd, + mxml_type_t (*cb)(mxml_node_t *), + mxml_sax_cb_t sax, void *sax_data); +extern mxml_node_t *mxmlSAXLoadFile(mxml_node_t *top, FILE *fp, + mxml_type_t (*cb)(mxml_node_t *), + mxml_sax_cb_t sax, void *sax_data); +extern mxml_node_t *mxmlSAXLoadString(mxml_node_t *top, const char *s, + mxml_type_t (*cb)(mxml_node_t *), + mxml_sax_cb_t sax, void *sax_data); +extern int mxmlSetCDATA(mxml_node_t *node, const char *data); +extern int mxmlSetCustom(mxml_node_t *node, void *data, + mxml_custom_destroy_cb_t destroy); +extern void mxmlSetCustomHandlers(mxml_custom_load_cb_t load, + mxml_custom_save_cb_t save); +extern int mxmlSetElement(mxml_node_t *node, const char *name); +extern void mxmlSetErrorCallback(mxml_error_cb_t cb); +extern int mxmlSetInteger(mxml_node_t *node, int integer); +extern int mxmlSetOpaque(mxml_node_t *node, const char *opaque); +extern int mxmlSetReal(mxml_node_t *node, double real); +extern int mxmlSetText(mxml_node_t *node, int whitespace, + const char *string); +extern int mxmlSetTextf(mxml_node_t *node, int whitespace, + const char *format, ...) +# ifdef __GNUC__ +__attribute__ ((__format__ (__printf__, 3, 4))) +# endif /* __GNUC__ */ +; +extern void mxmlSetWrapMargin(int column); +extern mxml_node_t *mxmlWalkNext(mxml_node_t *node, mxml_node_t *top, + int descend); +extern mxml_node_t *mxmlWalkPrev(mxml_node_t *node, mxml_node_t *top, + int descend); + + +/* + * Semi-private functions... + */ + +extern void mxml_error(const char *format, ...); +extern mxml_type_t mxml_ignore_cb(mxml_node_t *node); +extern mxml_type_t mxml_integer_cb(mxml_node_t *node); +extern mxml_type_t mxml_opaque_cb(mxml_node_t *node); +extern mxml_type_t mxml_real_cb(mxml_node_t *node); + + +/* + * C++ support... + */ + +# ifdef __cplusplus +} +# endif /* __cplusplus */ +#endif /* !_mxml_h_ */ + + +/* + * End of "$Id: mxml.h 307 2007-09-15 20:03:15Z mike $". + */ diff --git a/source/unzip/crypt.h b/source/unzip/crypt.h new file mode 100644 index 00000000..f14a628b --- /dev/null +++ b/source/unzip/crypt.h @@ -0,0 +1,132 @@ +/* crypt.h -- base code for crypt/uncrypt ZIPfile + + + Version 1.01e, February 12th, 2005 + + Copyright (C) 1998-2005 Gilles Vollant + + This code is a modified version of crypting code in Infozip distribution + + The encryption/decryption parts of this source code (as opposed to the + non-echoing password parts) were originally written in Europe. The + whole source package can be freely distributed, including from the USA. + (Prior to January 2000, re-export from the US was a violation of US law.) + + This encryption code is a direct transcription of the algorithm from + Roger Schlafly, described by Phil Katz in the file appnote.txt. This + file (appnote.txt) is distributed with the PKZIP program (even in the + version without encryption capabilities). + + If you don't need crypting in your application, just define symbols + NOCRYPT and NOUNCRYPT. + + This code support the "Traditional PKWARE Encryption". + + The new AES encryption added on Zip format by Winzip (see the page + http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong + Encryption is not supported. +*/ + +#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) + +/*********************************************************************** + * Return the next byte in the pseudo-random sequence + */ +static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) +{ + unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an + * unpredictable manner on 16-bit systems; not a problem + * with any known compiler so far, though */ + + temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; + return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); +} + +/*********************************************************************** + * Update the encryption keys with the next byte of plain text + */ +static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c) +{ + (*(pkeys+0)) = CRC32((*(pkeys+0)), c); + (*(pkeys+1)) += (*(pkeys+0)) & 0xff; + (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; + { + register int keyshift = (int)((*(pkeys+1)) >> 24); + (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); + } + return c; +} + + +/*********************************************************************** + * Initialize the encryption keys and the random header according to + * the given password. + */ +static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab) +{ + *(pkeys+0) = 305419896L; + *(pkeys+1) = 591751049L; + *(pkeys+2) = 878082192L; + while (*passwd != '\0') { + update_keys(pkeys,pcrc_32_tab,(int)*passwd); + passwd++; + } +} + +#define zdecode(pkeys,pcrc_32_tab,c) \ + (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab))) + +#define zencode(pkeys,pcrc_32_tab,c,t) \ + (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c)) + +#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED + +#define RAND_HEAD_LEN 12 + /* "last resort" source for second part of crypt seed pattern */ +# ifndef ZCR_SEED2 +# define ZCR_SEED2 3141592654UL /* use PI as default pattern */ +# endif + +static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting) + const char *passwd; /* password string */ + unsigned char *buf; /* where to write header */ + int bufSize; + unsigned long* pkeys; + const unsigned long* pcrc_32_tab; + unsigned long crcForCrypting; +{ + int n; /* index in random header */ + int t; /* temporary */ + int c; /* random byte */ + unsigned char header[RAND_HEAD_LEN-2]; /* random header */ + static unsigned calls = 0; /* ensure different random header each time */ + + if (bufSize> 7) & 0xff; + header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t); + } + /* Encrypt random header (last two bytes is high word of crc) */ + init_keys(passwd, pkeys, pcrc_32_tab); + for (n = 0; n < RAND_HEAD_LEN-2; n++) + { + buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t); + } + buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t); + buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t); + return n; +} + +#endif diff --git a/source/unzip/ioapi.c b/source/unzip/ioapi.c new file mode 100644 index 00000000..7f20c182 --- /dev/null +++ b/source/unzip/ioapi.c @@ -0,0 +1,177 @@ +/* ioapi.c -- IO base function header for compress/uncompress .zip + files using zlib + zip or unzip API + + Version 1.01e, February 12th, 2005 + + Copyright (C) 1998-2005 Gilles Vollant +*/ + +#include +#include +#include + +#include "zlib.h" +#include "ioapi.h" + + + +/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ + +#ifndef SEEK_CUR +#define SEEK_CUR 1 +#endif + +#ifndef SEEK_END +#define SEEK_END 2 +#endif + +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif + +voidpf ZCALLBACK fopen_file_func OF(( + voidpf opaque, + const char* filename, + int mode)); + +uLong ZCALLBACK fread_file_func OF(( + voidpf opaque, + voidpf stream, + void* buf, + uLong size)); + +uLong ZCALLBACK fwrite_file_func OF(( + voidpf opaque, + voidpf stream, + const void* buf, + uLong size)); + +long ZCALLBACK ftell_file_func OF(( + voidpf opaque, + voidpf stream)); + +long ZCALLBACK fseek_file_func OF(( + voidpf opaque, + voidpf stream, + uLong offset, + int origin)); + +int ZCALLBACK fclose_file_func OF(( + voidpf opaque, + voidpf stream)); + +int ZCALLBACK ferror_file_func OF(( + voidpf opaque, + voidpf stream)); + + +voidpf ZCALLBACK fopen_file_func (opaque, filename, mode) + voidpf opaque; + const char* filename; + int mode; +{ + FILE* file = NULL; + const char* mode_fopen = NULL; + if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) + mode_fopen = "rb"; + else + if (mode & ZLIB_FILEFUNC_MODE_EXISTING) + mode_fopen = "r+b"; + else + if (mode & ZLIB_FILEFUNC_MODE_CREATE) + mode_fopen = "wb"; + + if ((filename!=NULL) && (mode_fopen != NULL)) + file = fopen(filename, mode_fopen); + return file; +} + + +uLong ZCALLBACK fread_file_func (opaque, stream, buf, size) + voidpf opaque; + voidpf stream; + void* buf; + uLong size; +{ + uLong ret; + ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); + return ret; +} + + +uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size) + voidpf opaque; + voidpf stream; + const void* buf; + uLong size; +{ + uLong ret; + ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); + return ret; +} + +long ZCALLBACK ftell_file_func (opaque, stream) + voidpf opaque; + voidpf stream; +{ + long ret; + ret = ftell((FILE *)stream); + return ret; +} + +long ZCALLBACK fseek_file_func (opaque, stream, offset, origin) + voidpf opaque; + voidpf stream; + uLong offset; + int origin; +{ + int fseek_origin=0; + long ret; + switch (origin) + { + case ZLIB_FILEFUNC_SEEK_CUR : + fseek_origin = SEEK_CUR; + break; + case ZLIB_FILEFUNC_SEEK_END : + fseek_origin = SEEK_END; + break; + case ZLIB_FILEFUNC_SEEK_SET : + fseek_origin = SEEK_SET; + break; + default: return -1; + } + ret = 0; + fseek((FILE *)stream, offset, fseek_origin); + return ret; +} + +int ZCALLBACK fclose_file_func (opaque, stream) + voidpf opaque; + voidpf stream; +{ + int ret; + ret = fclose((FILE *)stream); + return ret; +} + +int ZCALLBACK ferror_file_func (opaque, stream) + voidpf opaque; + voidpf stream; +{ + int ret; + ret = ferror((FILE *)stream); + return ret; +} + +void fill_fopen_filefunc (pzlib_filefunc_def) + zlib_filefunc_def* pzlib_filefunc_def; +{ + pzlib_filefunc_def->zopen_file = fopen_file_func; + pzlib_filefunc_def->zread_file = fread_file_func; + pzlib_filefunc_def->zwrite_file = fwrite_file_func; + pzlib_filefunc_def->ztell_file = ftell_file_func; + pzlib_filefunc_def->zseek_file = fseek_file_func; + pzlib_filefunc_def->zclose_file = fclose_file_func; + pzlib_filefunc_def->zerror_file = ferror_file_func; + pzlib_filefunc_def->opaque = NULL; +} diff --git a/source/unzip/ioapi.h b/source/unzip/ioapi.h new file mode 100644 index 00000000..e73a3b2b --- /dev/null +++ b/source/unzip/ioapi.h @@ -0,0 +1,75 @@ +/* ioapi.h -- IO base function header for compress/uncompress .zip + files using zlib + zip or unzip API + + Version 1.01e, February 12th, 2005 + + Copyright (C) 1998-2005 Gilles Vollant +*/ + +#ifndef _ZLIBIOAPI_H +#define _ZLIBIOAPI_H + + +#define ZLIB_FILEFUNC_SEEK_CUR (1) +#define ZLIB_FILEFUNC_SEEK_END (2) +#define ZLIB_FILEFUNC_SEEK_SET (0) + +#define ZLIB_FILEFUNC_MODE_READ (1) +#define ZLIB_FILEFUNC_MODE_WRITE (2) +#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) + +#define ZLIB_FILEFUNC_MODE_EXISTING (4) +#define ZLIB_FILEFUNC_MODE_CREATE (8) + + +#ifndef ZCALLBACK + +#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) +#define ZCALLBACK CALLBACK +#else +#define ZCALLBACK +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); +typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); +typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); +typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); +typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); +typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); +typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); + +typedef struct zlib_filefunc_def_s +{ + open_file_func zopen_file; + read_file_func zread_file; + write_file_func zwrite_file; + tell_file_func ztell_file; + seek_file_func zseek_file; + close_file_func zclose_file; + testerror_file_func zerror_file; + voidpf opaque; +} zlib_filefunc_def; + + + +void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); + +#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) +#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) +#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) +#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) +#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) +#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/source/unzip/miniunz.c b/source/unzip/miniunz.c new file mode 100644 index 00000000..0874e4de --- /dev/null +++ b/source/unzip/miniunz.c @@ -0,0 +1,276 @@ +/* + miniunz.c + Version 1.01e, February 12th, 2005 + + Copyright (C) 1998-2005 Gilles Vollant +*/ + + +#include +#include +#include +#include +#include +#include +# include +# include + +#include "unzip.h" + +#define CASESENSITIVITY (0) +#define WRITEBUFFERSIZE (8192) +#define MAXFILENAME (256) + +static int mymkdir(const char* dirname) +{ + int ret=0; + ret = mkdir (dirname,0775); + return ret; +} + +int makedir (char *newdir) +{ + char *buffer ; + char *p; + int len = (int)strlen(newdir); + + if (len <= 0) + return 0; + + buffer = (char*)malloc(len+1); + strcpy(buffer,newdir); + + if (buffer[len-1] == '/') { + buffer[len-1] = '\0'; + } + if (mymkdir(buffer) == 0) + { + free(buffer); + return 1; + } + + p = buffer+1; + while (1) + { + char hold; + + while(*p && *p != '\\' && *p != '/') + p++; + hold = *p; + *p = 0; + if ((mymkdir(buffer) == -1) && (errno == ENOENT)) + { + printf("couldn't create directory %s\n",buffer); + free(buffer); + return 0; + } + if (hold == 0) + break; + *p++ = hold; + } + free(buffer); + return 1; +} + +static int do_extract_currentfile(unzFile uf,const int* popt_extract_without_path,int* popt_overwrite,const char* password) +{ + char filename_inzip[256]; + char* filename_withoutpath; + char* p; + int err=UNZ_OK; + FILE *fout=NULL; + void* buf; + uInt size_buf; + + unz_file_info file_info; + err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); + + if (err!=UNZ_OK) + { + printf("error %d with zipfile in unzGetCurrentFileInfo\n",err); + return err; + } + + size_buf = WRITEBUFFERSIZE; + buf = (void*)malloc(size_buf); + if (buf==NULL) + { + printf("Error allocating memory\n"); + return UNZ_INTERNALERROR; + } + + p = filename_withoutpath = filename_inzip; + while ((*p) != '\0') + { + if (((*p)=='/') || ((*p)=='\\')) + filename_withoutpath = p+1; + p++; + } + + if ((*filename_withoutpath)=='\0') + { + if ((*popt_extract_without_path)==0) + { + printf("creating directory: %s\n",filename_inzip); + mymkdir(filename_inzip); + } + } + else + { + char* write_filename; + int skip=0; + + if ((*popt_extract_without_path)==0) + write_filename = filename_inzip; + else + write_filename = filename_withoutpath; + + err = unzOpenCurrentFilePassword(uf,password); + if (err!=UNZ_OK) + { + printf("error %d with zipfile in unzOpenCurrentFilePassword\n",err); + } + + if (((*popt_overwrite)==0) && (err==UNZ_OK)) + { + char rep=0; + FILE* ftestexist; + ftestexist = fopen(write_filename,"rb"); + if (ftestexist!=NULL) + { + fclose(ftestexist); + do + { + char answer[128]; + int ret; + + printf("The file %s exists. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename); + ret = scanf("%1s",answer); + if (ret != 1) + { + exit(EXIT_FAILURE); + } + rep = answer[0] ; + if ((rep>='a') && (rep<='z')) + rep -= 0x20; + } + while ((rep!='Y') && (rep!='N') && (rep!='A')); + } + + if (rep == 'N') + skip = 1; + + if (rep == 'A') + *popt_overwrite=1; + } + + if ((skip==0) && (err==UNZ_OK)) + { + fout=fopen(write_filename,"wb"); + + /* some zipfile don't contain directory alone before file */ + if ((fout==NULL) && ((*popt_extract_without_path)==0) && + (filename_withoutpath!=(char*)filename_inzip)) + { + char c=*(filename_withoutpath-1); + *(filename_withoutpath-1)='\0'; + makedir(write_filename); + *(filename_withoutpath-1)=c; + fout=fopen(write_filename,"wb"); + } + + if (fout==NULL) + { + printf("error opening %s\n",write_filename); + } + } + + if (fout!=NULL) + { + printf(" extracting: %s\n",write_filename); + + do + { + err = unzReadCurrentFile(uf,buf,size_buf); + if (err<0) + { + printf("error %d with zipfile in unzReadCurrentFile\n",err); + break; + } + if (err>0) + if (fwrite(buf,err,1,fout)!=1) + { + printf("error in writing extracted file\n"); + err=UNZ_ERRNO; + break; + } + } + while (err>0); + if (fout) + fclose(fout); + + } + + if (err==UNZ_OK) + { + err = unzCloseCurrentFile (uf); + if (err!=UNZ_OK) + { + printf("error %d with zipfile in unzCloseCurrentFile\n",err); + } + } + else + unzCloseCurrentFile(uf); /* don't lose the error */ + } + + free(buf); + return err; +} + + +int extractZip(unzFile uf,int opt_extract_without_path,int opt_overwrite,const char* password) +{ + uLong i; + unz_global_info gi; + int err; + + err = unzGetGlobalInfo (uf,&gi); + if (err!=UNZ_OK) + printf("error %d with zipfile in unzGetGlobalInfo \n",err); + + for (i=0;i +#include +#include +#include "zlib.h" +#include "unzip.h" + +#define READ_8(adr) ((unsigned char)*(adr)) +#define READ_16(adr) ( READ_8(adr) | (READ_8(adr+1) << 8) ) +#define READ_32(adr) ( READ_16(adr) | (READ_16((adr)+2) << 16) ) + +#define WRITE_8(buff, n) do { \ + *((unsigned char*)(buff)) = (unsigned char) ((n) & 0xff); \ +} while(0) +#define WRITE_16(buff, n) do { \ + WRITE_8((unsigned char*)(buff), n); \ + WRITE_8(((unsigned char*)(buff)) + 1, (n) >> 8); \ +} while(0) +#define WRITE_32(buff, n) do { \ + WRITE_16((unsigned char*)(buff), (n) & 0xffff); \ + WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \ +} while(0) + +extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered) +const char* file; +const char* fileOut; +const char* fileOutTmp; +uLong* nRecovered; +uLong* bytesRecovered; +{ + int err = Z_OK; + FILE* fpZip = fopen(file, "rb"); + FILE* fpOut = fopen(fileOut, "wb"); + FILE* fpOutCD = fopen(fileOutTmp, "wb"); + if (fpZip != NULL && fpOut != NULL) { + int entries = 0; + uLong totalBytes = 0; + char header[30]; + char filename[256]; + char extra[1024]; + int offset = 0; + int offsetCD = 0; + while ( fread(header, 1, 30, fpZip) == 30 ) { + int currentOffset = offset; + + /* File entry */ + if (READ_32(header) == 0x04034b50) { + unsigned int version = READ_16(header + 4); + unsigned int gpflag = READ_16(header + 6); + unsigned int method = READ_16(header + 8); + unsigned int filetime = READ_16(header + 10); + unsigned int filedate = READ_16(header + 12); + unsigned int crc = READ_32(header + 14); /* crc */ + unsigned int cpsize = READ_32(header + 18); /* compressed size */ + unsigned int uncpsize = READ_32(header + 22); /* uncompressed sz */ + unsigned int fnsize = READ_16(header + 26); /* file name length */ + unsigned int extsize = READ_16(header + 28); /* extra field length */ + filename[0] = extra[0] = '\0'; + + /* Header */ + if (fwrite(header, 1, 30, fpOut) == 30) { + offset += 30; + } else { + err = Z_ERRNO; + break; + } + + /* Filename */ + if (fnsize > 0) { + if (fread(filename, 1, fnsize, fpZip) == fnsize) { + if (fwrite(filename, 1, fnsize, fpOut) == fnsize) { + offset += fnsize; + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_STREAM_ERROR; + break; + } + + /* Extra field */ + if (extsize > 0) { + if (fread(extra, 1, extsize, fpZip) == extsize) { + if (fwrite(extra, 1, extsize, fpOut) == extsize) { + offset += extsize; + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_ERRNO; + break; + } + } + + /* Data */ + { + int dataSize = cpsize; + if (dataSize == 0) { + dataSize = uncpsize; + } + if (dataSize > 0) { + char* data = malloc(dataSize); + if (data != NULL) { + if ((int)fread(data, 1, dataSize, fpZip) == dataSize) { + if ((int)fwrite(data, 1, dataSize, fpOut) == dataSize) { + offset += dataSize; + totalBytes += dataSize; + } else { + err = Z_ERRNO; + } + } else { + err = Z_ERRNO; + } + free(data); + if (err != Z_OK) { + break; + } + } else { + err = Z_MEM_ERROR; + break; + } + } + } + + /* Central directory entry */ + { + char header[46]; + char* comment = ""; + int comsize = (int) strlen(comment); + WRITE_32(header, 0x02014b50); + WRITE_16(header + 4, version); + WRITE_16(header + 6, version); + WRITE_16(header + 8, gpflag); + WRITE_16(header + 10, method); + WRITE_16(header + 12, filetime); + WRITE_16(header + 14, filedate); + WRITE_32(header + 16, crc); + WRITE_32(header + 20, cpsize); + WRITE_32(header + 24, uncpsize); + WRITE_16(header + 28, fnsize); + WRITE_16(header + 30, extsize); + WRITE_16(header + 32, comsize); + WRITE_16(header + 34, 0); /* disk # */ + WRITE_16(header + 36, 0); /* int attrb */ + WRITE_32(header + 38, 0); /* ext attrb */ + WRITE_32(header + 42, currentOffset); + /* Header */ + if (fwrite(header, 1, 46, fpOutCD) == 46) { + offsetCD += 46; + + /* Filename */ + if (fnsize > 0) { + if (fwrite(filename, 1, fnsize, fpOutCD) == fnsize) { + offsetCD += fnsize; + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_STREAM_ERROR; + break; + } + + /* Extra field */ + if (extsize > 0) { + if (fwrite(extra, 1, extsize, fpOutCD) == extsize) { + offsetCD += extsize; + } else { + err = Z_ERRNO; + break; + } + } + + /* Comment field */ + if (comsize > 0) { + if ((int)fwrite(comment, 1, comsize, fpOutCD) == comsize) { + offsetCD += comsize; + } else { + err = Z_ERRNO; + break; + } + } + + + } else { + err = Z_ERRNO; + break; + } + } + + /* Success */ + entries++; + + } else { + break; + } + } + + /* Final central directory */ + { + int entriesZip = entries; + char header[22]; + char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools"; + int comsize = (int) strlen(comment); + if (entriesZip > 0xffff) { + entriesZip = 0xffff; + } + WRITE_32(header, 0x06054b50); + WRITE_16(header + 4, 0); /* disk # */ + WRITE_16(header + 6, 0); /* disk # */ + WRITE_16(header + 8, entriesZip); /* hack */ + WRITE_16(header + 10, entriesZip); /* hack */ + WRITE_32(header + 12, offsetCD); /* size of CD */ + WRITE_32(header + 16, offset); /* offset to CD */ + WRITE_16(header + 20, comsize); /* comment */ + + /* Header */ + if (fwrite(header, 1, 22, fpOutCD) == 22) { + + /* Comment field */ + if (comsize > 0) { + if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) { + err = Z_ERRNO; + } + } + + } else { + err = Z_ERRNO; + } + } + + /* Final merge (file + central directory) */ + fclose(fpOutCD); + if (err == Z_OK) { + fpOutCD = fopen(fileOutTmp, "rb"); + if (fpOutCD != NULL) { + int nRead; + char buffer[8192]; + while ( (nRead = (int)fread(buffer, 1, sizeof(buffer), fpOutCD)) > 0) { + if ((int)fwrite(buffer, 1, nRead, fpOut) != nRead) { + err = Z_ERRNO; + break; + } + } + fclose(fpOutCD); + } + } + + /* Close */ + fclose(fpZip); + fclose(fpOut); + + /* Wipe temporary file */ + (void)remove(fileOutTmp); + + /* Number of recovered entries */ + if (err == Z_OK) { + if (nRecovered != NULL) { + *nRecovered = entries; + } + if (bytesRecovered != NULL) { + *bytesRecovered = totalBytes; + } + } + } else { + err = Z_STREAM_ERROR; + } + return err; +} diff --git a/source/unzip/mztools.h b/source/unzip/mztools.h new file mode 100644 index 00000000..82d1597a --- /dev/null +++ b/source/unzip/mztools.h @@ -0,0 +1,31 @@ +/* + Additional tools for Minizip + Code: Xavier Roche '2004 + License: Same as ZLIB (www.gzip.org) +*/ + +#ifndef _zip_tools_H +#define _zip_tools_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ZLIB_H +#include "zlib.h" +#endif + +#include "unzip.h" + +/* Repair a ZIP file (missing central directory) + file: file to recover + fileOut: output file after recovery + fileOutTmp: temporary file name used for recovery +*/ +extern int ZEXPORT unzRepair(const char* file, + const char* fileOut, + const char* fileOutTmp, + uLong* nRecovered, + uLong* bytesRecovered); + +#endif diff --git a/source/unzip/unzip.c b/source/unzip/unzip.c new file mode 100644 index 00000000..c24ff76f --- /dev/null +++ b/source/unzip/unzip.c @@ -0,0 +1,1607 @@ +/* unzip.c -- IO for uncompress .zip files using zlib + Version 1.01e, February 12th, 2005 + + Copyright (C) 1998-2005 Gilles Vollant + + Read unzip.h for more info +*/ + +/* Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of +compatibility with older software. The following is from the original crypt.c. Code +woven in by Terry Thorsen 1/2003. +*/ +/* + Copyright (c) 1990-2000 Info-ZIP. All rights reserved. + + See the accompanying file LICENSE, version 2000-Apr-09 or later + (the contents of which are also included in zip.h) for terms of use. + If, for some reason, all these files are missing, the Info-ZIP license + also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html +*/ +/* + crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h] + + The encryption/decryption parts of this source code (as opposed to the + non-echoing password parts) were originally written in Europe. The + whole source package can be freely distributed, including from the USA. + (Prior to January 2000, re-export from the US was a violation of US law.) + */ + +/* + This encryption code is a direct transcription of the algorithm from + Roger Schlafly, described by Phil Katz in the file appnote.txt. This + file (appnote.txt) is distributed with the PKZIP program (even in the + version without encryption capabilities). + */ + + +#include +#include +#include +#include "zlib.h" +#include "unzip.h" + +#ifdef STDC +# include +# include +# include +#endif +#ifdef NO_ERRNO_H + extern int errno; +#else +# include +#endif + + +#ifndef local +# define local static +#endif +/* compile with -Dlocal if your debugger can't find static symbols */ + + +#ifndef CASESENSITIVITYDEFAULT_NO +# if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) +# define CASESENSITIVITYDEFAULT_NO +# endif +#endif + + +#ifndef UNZ_BUFSIZE +#define UNZ_BUFSIZE (16384) +#endif + +#ifndef UNZ_MAXFILENAMEINZIP +#define UNZ_MAXFILENAMEINZIP (256) +#endif + +#ifndef ALLOC +# define ALLOC(size) (malloc(size)) +#endif +#ifndef TRYFREE +# define TRYFREE(p) {if (p) free(p);} +#endif + +#define SIZECENTRALDIRITEM (0x2e) +#define SIZEZIPLOCALHEADER (0x1e) + + + + +const char unz_copyright[] = + " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll"; + +/* unz_file_info_interntal contain internal info about a file in zipfile*/ +typedef struct unz_file_info_internal_s +{ + uLong offset_curfile;/* relative offset of local header 4 bytes */ +} unz_file_info_internal; + + +/* file_in_zip_read_info_s contain internal information about a file in zipfile, + when reading and decompress it */ +typedef struct +{ + char *read_buffer; /* internal buffer for compressed data */ + z_stream stream; /* zLib stream structure for inflate */ + + uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ + uLong stream_initialised; /* flag set if stream structure is initialised*/ + + uLong offset_local_extrafield;/* offset of the local extra field */ + uInt size_local_extrafield;/* size of the local extra field */ + uLong pos_local_extrafield; /* position in the local extra field in read*/ + + uLong crc32; /* crc32 of all data uncompressed */ + uLong crc32_wait; /* crc32 we must obtain after decompress all */ + uLong rest_read_compressed; /* number of byte to be decompressed */ + uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ + zlib_filefunc_def z_filefunc; + voidpf filestream; /* io structore of the zipfile */ + uLong compression_method; /* compression method (0==store) */ + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + int raw; +} file_in_zip_read_info_s; + + +/* unz_s contain internal information about the zipfile +*/ +typedef struct +{ + zlib_filefunc_def z_filefunc; + voidpf filestream; /* io structore of the zipfile */ + unz_global_info gi; /* public global information */ + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + uLong num_file; /* number of the current file in the zipfile*/ + uLong pos_in_central_dir; /* pos of the current file in the central dir*/ + uLong current_file_ok; /* flag about the usability of the current file*/ + uLong central_pos; /* position of the beginning of the central dir*/ + + uLong size_central_dir; /* size of the central directory */ + uLong offset_central_dir; /* offset of start of central directory with + respect to the starting disk number */ + + unz_file_info cur_file_info; /* public info about the current file in zip*/ + unz_file_info_internal cur_file_info_internal; /* private info about it*/ + file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current + file if we are decompressing it */ + int encrypted; +# ifndef NOUNCRYPT + unsigned long keys[3]; /* keys defining the pseudo-random sequence */ + const unsigned long* pcrc_32_tab; +# endif +} unz_s; + + +#ifndef NOUNCRYPT +#include "crypt.h" +#endif + +/* =========================================================================== + Read a byte from a gz_stream; update next_in and avail_in. Return EOF + for end of file. + IN assertion: the stream s has been sucessfully opened for reading. +*/ + + +local int unzlocal_getByte OF(( + const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream, + int *pi)); + +local int unzlocal_getByte(pzlib_filefunc_def,filestream,pi) + const zlib_filefunc_def* pzlib_filefunc_def; + voidpf filestream; + int *pi; +{ + unsigned char c; + int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1); + if (err==1) + { + *pi = (int)c; + return UNZ_OK; + } + else + { + if (ZERROR(*pzlib_filefunc_def,filestream)) + return UNZ_ERRNO; + else + return UNZ_EOF; + } +} + + +/* =========================================================================== + Reads a long in LSB order from the given gz_stream. Sets +*/ +local int unzlocal_getShort OF(( + const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream, + uLong *pX)); + +local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX) + const zlib_filefunc_def* pzlib_filefunc_def; + voidpf filestream; + uLong *pX; +{ + uLong x ; + int i; + int err; + + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + x = (uLong)i; + + if (err==UNZ_OK) + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<8; + + if (err==UNZ_OK) + *pX = x; + else + *pX = 0; + return err; +} + +local int unzlocal_getLong OF(( + const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream, + uLong *pX)); + +local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX) + const zlib_filefunc_def* pzlib_filefunc_def; + voidpf filestream; + uLong *pX; +{ + uLong x ; + int i; + int err; + + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + x = (uLong)i; + + if (err==UNZ_OK) + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<8; + + if (err==UNZ_OK) + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<16; + + if (err==UNZ_OK) + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<24; + + if (err==UNZ_OK) + *pX = x; + else + *pX = 0; + return err; +} + + +/* My own strcmpi / strcasecmp */ +local int strcmpcasenosensitive_internal (fileName1,fileName2) + const char* fileName1; + const char* fileName2; +{ + for (;;) + { + char c1=*(fileName1++); + char c2=*(fileName2++); + if ((c1>='a') && (c1<='z')) + c1 -= 0x20; + if ((c2>='a') && (c2<='z')) + c2 -= 0x20; + if (c1=='\0') + return ((c2=='\0') ? 0 : -1); + if (c2=='\0') + return 1; + if (c1c2) + return 1; + } +} + + +#ifdef CASESENSITIVITYDEFAULT_NO +#define CASESENSITIVITYDEFAULTVALUE 2 +#else +#define CASESENSITIVITYDEFAULTVALUE 1 +#endif + +#ifndef STRCMPCASENOSENTIVEFUNCTION +#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal +#endif + +/* + Compare two filename (fileName1,fileName2). + If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) + If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi + or strcasecmp) + If iCaseSenisivity = 0, case sensitivity is defaut of your operating system + (like 1 on Unix, 2 on Windows) + +*/ +extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity) + const char* fileName1; + const char* fileName2; + int iCaseSensitivity; +{ + if (iCaseSensitivity==0) + iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; + + if (iCaseSensitivity==1) + return strcmp(fileName1,fileName2); + + return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); +} + +#ifndef BUFREADCOMMENT +#define BUFREADCOMMENT (0x400) +#endif + +/* + Locate the Central directory of a zipfile (at the end, just before + the global comment) +*/ +local uLong unzlocal_SearchCentralDir OF(( + const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream)); + +local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream) + const zlib_filefunc_def* pzlib_filefunc_def; + voidpf filestream; +{ + unsigned char* buf; + uLong uSizeFile; + uLong uBackRead; + uLong uMaxBack=0xffff; /* maximum size of global comment */ + uLong uPosFound=0; + + if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) + return 0; + + + uSizeFile = ZTELL(*pzlib_filefunc_def,filestream); + + if (uMaxBack>uSizeFile) + uMaxBack = uSizeFile; + + buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); + if (buf==NULL) + return 0; + + uBackRead = 4; + while (uBackReaduMaxBack) + uBackRead = uMaxBack; + else + uBackRead+=BUFREADCOMMENT; + uReadPos = uSizeFile-uBackRead ; + + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? + (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); + if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) + break; + + if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) + break; + + for (i=(int)uReadSize-3; (i--)>0;) + if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && + ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) + { + uPosFound = uReadPos+i; + break; + } + + if (uPosFound!=0) + break; + } + TRYFREE(buf); + return uPosFound; +} + +/* + Open a Zip file. path contain the full pathname (by example, + on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer + "zlib/zlib114.zip". + If the zipfile cannot be opened (file doesn't exist or in not valid), the + return value is NULL. + Else, the return value is a unzFile Handle, usable with other function + of this unzip package. +*/ +extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def) + const char *path; + zlib_filefunc_def* pzlib_filefunc_def; +{ + unz_s us; + unz_s *s; + uLong central_pos,uL; + + uLong number_disk; /* number of the current dist, used for + spaning ZIP, unsupported, always 0*/ + uLong number_disk_with_CD; /* number the the disk with central dir, used + for spaning ZIP, unsupported, always 0*/ + uLong number_entry_CD; /* total number of entries in + the central dir + (same than number_entry on nospan) */ + + int err=UNZ_OK; + + if (unz_copyright[0]!=' ') + return NULL; + + if (pzlib_filefunc_def==NULL) + fill_fopen_filefunc(&us.z_filefunc); + else + us.z_filefunc = *pzlib_filefunc_def; + + us.filestream= (*(us.z_filefunc.zopen_file))(us.z_filefunc.opaque, + path, + ZLIB_FILEFUNC_MODE_READ | + ZLIB_FILEFUNC_MODE_EXISTING); + if (us.filestream==NULL) + return NULL; + + central_pos = unzlocal_SearchCentralDir(&us.z_filefunc,us.filestream); + if (central_pos==0) + err=UNZ_ERRNO; + + if (ZSEEK(us.z_filefunc, us.filestream, + central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) + err=UNZ_ERRNO; + + /* the signature, already checked */ + if (unzlocal_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) + err=UNZ_ERRNO; + + /* number of this disk */ + if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK) + err=UNZ_ERRNO; + + /* number of the disk with the start of the central directory */ + if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK) + err=UNZ_ERRNO; + + /* total number of entries in the central dir on this disk */ + if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK) + err=UNZ_ERRNO; + + /* total number of entries in the central dir */ + if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK) + err=UNZ_ERRNO; + + if ((number_entry_CD!=us.gi.number_entry) || + (number_disk_with_CD!=0) || + (number_disk!=0)) + err=UNZ_BADZIPFILE; + + /* size of the central directory */ + if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK) + err=UNZ_ERRNO; + + /* offset of start of central directory with respect to the + starting disk number */ + if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK) + err=UNZ_ERRNO; + + /* zipfile comment length */ + if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK) + err=UNZ_ERRNO; + + if ((central_pospfile_in_zip_read!=NULL) + unzCloseCurrentFile(file); + + ZCLOSE(s->z_filefunc, s->filestream); + TRYFREE(s); + return UNZ_OK; +} + + +/* + Write info about the ZipFile in the *pglobal_info structure. + No preparation of the structure is needed + return UNZ_OK if there is no problem. */ +extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info) + unzFile file; + unz_global_info *pglobal_info; +{ + unz_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + *pglobal_info=s->gi; + return UNZ_OK; +} + + +/* + Translate date/time from Dos format to tm_unz (readable more easilty) +*/ +local void unzlocal_DosDateToTmuDate (ulDosDate, ptm) + uLong ulDosDate; + tm_unz* ptm; +{ + uLong uDate; + uDate = (uLong)(ulDosDate>>16); + ptm->tm_mday = (uInt)(uDate&0x1f) ; + ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; + ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; + + ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); + ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; + ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; +} + +/* + Get Info about the current file in the zipfile, with internal only info +*/ +local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, + unz_file_info *pfile_info, + unz_file_info_internal + *pfile_info_internal, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize)); + +local int unzlocal_GetCurrentFileInfoInternal (file, + pfile_info, + pfile_info_internal, + szFileName, fileNameBufferSize, + extraField, extraFieldBufferSize, + szComment, commentBufferSize) + unzFile file; + unz_file_info *pfile_info; + unz_file_info_internal *pfile_info_internal; + char *szFileName; + uLong fileNameBufferSize; + void *extraField; + uLong extraFieldBufferSize; + char *szComment; + uLong commentBufferSize; +{ + unz_s* s; + unz_file_info file_info; + unz_file_info_internal file_info_internal; + int err=UNZ_OK; + uLong uMagic; + long lSeek=0; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (ZSEEK(s->z_filefunc, s->filestream, + s->pos_in_central_dir+s->byte_before_the_zipfile, + ZLIB_FILEFUNC_SEEK_SET)!=0) + err=UNZ_ERRNO; + + + /* we check the magic */ + if (err==UNZ_OK) + { + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) + err=UNZ_ERRNO; + else if (uMagic!=0x02014b50) + err=UNZ_BADZIPFILE; + } + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK) + err=UNZ_ERRNO; + + unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) + err=UNZ_ERRNO; + + lSeek+=file_info.size_filename; + if ((err==UNZ_OK) && (szFileName!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_filename0) && (fileNameBufferSize>0)) + if (ZREAD(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead) + err=UNZ_ERRNO; + lSeek -= uSizeRead; + } + + + if ((err==UNZ_OK) && (extraField!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_file_extraz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + } + + if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) + if (ZREAD(s->z_filefunc, s->filestream,extraField,uSizeRead)!=uSizeRead) + err=UNZ_ERRNO; + lSeek += file_info.size_file_extra - uSizeRead; + } + else + lSeek+=file_info.size_file_extra; + + + if ((err==UNZ_OK) && (szComment!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_file_commentz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + } + + if ((file_info.size_file_comment>0) && (commentBufferSize>0)) + if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead) + err=UNZ_ERRNO; + lSeek+=file_info.size_file_comment - uSizeRead; + } + else + lSeek+=file_info.size_file_comment; + + if ((err==UNZ_OK) && (pfile_info!=NULL)) + *pfile_info=file_info; + + if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) + *pfile_info_internal=file_info_internal; + + return err; +} + + + +/* + Write info about the ZipFile in the *pglobal_info structure. + No preparation of the structure is needed + return UNZ_OK if there is no problem. +*/ +extern int ZEXPORT unzGetCurrentFileInfo (file, + pfile_info, + szFileName, fileNameBufferSize, + extraField, extraFieldBufferSize, + szComment, commentBufferSize) + unzFile file; + unz_file_info *pfile_info; + char *szFileName; + uLong fileNameBufferSize; + void *extraField; + uLong extraFieldBufferSize; + char *szComment; + uLong commentBufferSize; +{ + return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, + szFileName,fileNameBufferSize, + extraField,extraFieldBufferSize, + szComment,commentBufferSize); +} + +/* + Set the current file of the zipfile to the first file. + return UNZ_OK if there is no problem +*/ +extern int ZEXPORT unzGoToFirstFile (file) + unzFile file; +{ + int err=UNZ_OK; + unz_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + s->pos_in_central_dir=s->offset_central_dir; + s->num_file=0; + err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; +} + +/* + Set the current file of the zipfile to the next file. + return UNZ_OK if there is no problem + return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. +*/ +extern int ZEXPORT unzGoToNextFile (file) + unzFile file; +{ + unz_s* s; + int err; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + if (s->gi.number_entry != 0xffff) /* 2^16 files overflow hack */ + if (s->num_file+1==s->gi.number_entry) + return UNZ_END_OF_LIST_OF_FILE; + + s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + + s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; + s->num_file++; + err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; +} + + +/* + Try locate the file szFileName in the zipfile. + For the iCaseSensitivity signification, see unzipStringFileNameCompare + + return value : + UNZ_OK if the file is found. It becomes the current file. + UNZ_END_OF_LIST_OF_FILE if the file is not found +*/ +extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) + unzFile file; + const char *szFileName; + int iCaseSensitivity; +{ + unz_s* s; + int err; + + /* We remember the 'current' position in the file so that we can jump + * back there if we fail. + */ + unz_file_info cur_file_infoSaved; + unz_file_info_internal cur_file_info_internalSaved; + uLong num_fileSaved; + uLong pos_in_central_dirSaved; + + + if (file==NULL) + return UNZ_PARAMERROR; + + if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) + return UNZ_PARAMERROR; + + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + + /* Save the current state */ + num_fileSaved = s->num_file; + pos_in_central_dirSaved = s->pos_in_central_dir; + cur_file_infoSaved = s->cur_file_info; + cur_file_info_internalSaved = s->cur_file_info_internal; + + err = unzGoToFirstFile(file); + + while (err == UNZ_OK) + { + char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; + err = unzGetCurrentFileInfo(file,NULL, + szCurrentFileName,sizeof(szCurrentFileName)-1, + NULL,0,NULL,0); + if (err == UNZ_OK) + { + if (unzStringFileNameCompare(szCurrentFileName, + szFileName,iCaseSensitivity)==0) + return UNZ_OK; + err = unzGoToNextFile(file); + } + } + + /* We failed, so restore the state of the 'current file' to where we + * were. + */ + s->num_file = num_fileSaved ; + s->pos_in_central_dir = pos_in_central_dirSaved ; + s->cur_file_info = cur_file_infoSaved; + s->cur_file_info_internal = cur_file_info_internalSaved; + return err; +} + + +/* +/////////////////////////////////////////// +// Contributed by Ryan Haksi (mailto://cryogen@infoserve.net) +// I need random access +// +// Further optimization could be realized by adding an ability +// to cache the directory in memory. The goal being a single +// comprehensive file read to put the file I need in a memory. +*/ + +/* +typedef struct unz_file_pos_s +{ + uLong pos_in_zip_directory; // offset in file + uLong num_of_file; // # of file +} unz_file_pos; +*/ + +extern int ZEXPORT unzGetFilePos(file, file_pos) + unzFile file; + unz_file_pos* file_pos; +{ + unz_s* s; + + if (file==NULL || file_pos==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + + file_pos->pos_in_zip_directory = s->pos_in_central_dir; + file_pos->num_of_file = s->num_file; + + return UNZ_OK; +} + +extern int ZEXPORT unzGoToFilePos(file, file_pos) + unzFile file; + unz_file_pos* file_pos; +{ + unz_s* s; + int err; + + if (file==NULL || file_pos==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + + /* jump to the right spot */ + s->pos_in_central_dir = file_pos->pos_in_zip_directory; + s->num_file = file_pos->num_of_file; + + /* set the current file */ + err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + /* return results */ + s->current_file_ok = (err == UNZ_OK); + return err; +} + +/* +// Unzip Helper Functions - should be here? +/////////////////////////////////////////// +*/ + +/* + Read the local header of the current zipfile + Check the coherency of the local header and info in the end of central + directory about this file + store in *piSizeVar the size of extra info in local header + (filename and size of extra field data) +*/ +local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, + poffset_local_extrafield, + psize_local_extrafield) + unz_s* s; + uInt* piSizeVar; + uLong *poffset_local_extrafield; + uInt *psize_local_extrafield; +{ + uLong uMagic,uData,uFlags; + uLong size_filename; + uLong size_extra_field; + int err=UNZ_OK; + + *piSizeVar = 0; + *poffset_local_extrafield = 0; + *psize_local_extrafield = 0; + + if (ZSEEK(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile + + s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) + return UNZ_ERRNO; + + + if (err==UNZ_OK) + { + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) + err=UNZ_ERRNO; + else if (uMagic!=0x04034b50) + err=UNZ_BADZIPFILE; + } + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) + err=UNZ_ERRNO; +/* + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) + err=UNZ_BADZIPFILE; +*/ + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) + err=UNZ_BADZIPFILE; + + if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && + (s->cur_file_info.compression_method!=Z_DEFLATED)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */ + err=UNZ_ERRNO; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK) + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) + err=UNZ_BADZIPFILE; + + *piSizeVar += (uInt)size_filename; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK) + err=UNZ_ERRNO; + *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + + SIZEZIPLOCALHEADER + size_filename; + *psize_local_extrafield = (uInt)size_extra_field; + + *piSizeVar += (uInt)size_extra_field; + + return err; +} + +/* + Open for reading data the current file in the zipfile. + If there is no error and the file is opened, the return value is UNZ_OK. +*/ +extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) + unzFile file; + int* method; + int* level; + int raw; + const char* password; +{ + int err=UNZ_OK; + uInt iSizeVar; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + uLong offset_local_extrafield; /* offset of the local extra field */ + uInt size_local_extrafield; /* size of the local extra field */ +# ifndef NOUNCRYPT + char source[12]; +# else + if (password != NULL) + return UNZ_PARAMERROR; +# endif + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_PARAMERROR; + + if (s->pfile_in_zip_read != NULL) + unzCloseCurrentFile(file); + + if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, + &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) + return UNZ_BADZIPFILE; + + pfile_in_zip_read_info = (file_in_zip_read_info_s*) + ALLOC(sizeof(file_in_zip_read_info_s)); + if (pfile_in_zip_read_info==NULL) + return UNZ_INTERNALERROR; + + pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); + pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; + pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; + pfile_in_zip_read_info->pos_local_extrafield=0; + pfile_in_zip_read_info->raw=raw; + + if (pfile_in_zip_read_info->read_buffer==NULL) + { + TRYFREE(pfile_in_zip_read_info); + return UNZ_INTERNALERROR; + } + + pfile_in_zip_read_info->stream_initialised=0; + + if (method!=NULL) + *method = (int)s->cur_file_info.compression_method; + + if (level!=NULL) + { + *level = 6; + switch (s->cur_file_info.flag & 0x06) + { + case 6 : *level = 1; break; + case 4 : *level = 2; break; + case 2 : *level = 9; break; + } + } + + if ((s->cur_file_info.compression_method!=0) && + (s->cur_file_info.compression_method!=Z_DEFLATED)) + err=UNZ_BADZIPFILE; + + pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; + pfile_in_zip_read_info->crc32=0; + pfile_in_zip_read_info->compression_method = + s->cur_file_info.compression_method; + pfile_in_zip_read_info->filestream=s->filestream; + pfile_in_zip_read_info->z_filefunc=s->z_filefunc; + pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; + + pfile_in_zip_read_info->stream.total_out = 0; + + if ((s->cur_file_info.compression_method==Z_DEFLATED) && + (!raw)) + { + pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; + pfile_in_zip_read_info->stream.zfree = (free_func)0; + pfile_in_zip_read_info->stream.opaque = (voidpf)0; + pfile_in_zip_read_info->stream.next_in = (voidpf)0; + pfile_in_zip_read_info->stream.avail_in = 0; + + err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); + if (err == Z_OK) + pfile_in_zip_read_info->stream_initialised=1; + else + { + TRYFREE(pfile_in_zip_read_info); + return err; + } + /* windowBits is passed < 0 to tell that there is no zlib header. + * Note that in this case inflate *requires* an extra "dummy" byte + * after the compressed stream in order to complete decompression and + * return Z_STREAM_END. + * In unzip, i don't wait absolutely Z_STREAM_END because I known the + * size of both compressed and uncompressed data + */ + } + pfile_in_zip_read_info->rest_read_compressed = + s->cur_file_info.compressed_size ; + pfile_in_zip_read_info->rest_read_uncompressed = + s->cur_file_info.uncompressed_size ; + + + pfile_in_zip_read_info->pos_in_zipfile = + s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + + iSizeVar; + + pfile_in_zip_read_info->stream.avail_in = (uInt)0; + + s->pfile_in_zip_read = pfile_in_zip_read_info; + +# ifndef NOUNCRYPT + if (password != NULL) + { + int i; + s->pcrc_32_tab = get_crc_table(); + init_keys(password,s->keys,s->pcrc_32_tab); + if (ZSEEK(s->z_filefunc, s->filestream, + s->pfile_in_zip_read->pos_in_zipfile + + s->pfile_in_zip_read->byte_before_the_zipfile, + SEEK_SET)!=0) + return UNZ_INTERNALERROR; + if(ZREAD(s->z_filefunc, s->filestream,source, 12)<12) + return UNZ_INTERNALERROR; + + for (i = 0; i<12; i++) + zdecode(s->keys,s->pcrc_32_tab,source[i]); + + s->pfile_in_zip_read->pos_in_zipfile+=12; + s->encrypted=1; + } +# endif + + + return UNZ_OK; +} + +extern int ZEXPORT unzOpenCurrentFile (file) + unzFile file; +{ + return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL); +} + +extern int ZEXPORT unzOpenCurrentFilePassword (file, password) + unzFile file; + const char* password; +{ + return unzOpenCurrentFile3(file, NULL, NULL, 0, password); +} + +extern int ZEXPORT unzOpenCurrentFile2 (file,method,level,raw) + unzFile file; + int* method; + int* level; + int raw; +{ + return unzOpenCurrentFile3(file, method, level, raw, NULL); +} + +/* + Read bytes from the current file. + buf contain buffer where data must be copied + len the size of buf. + + return the number of byte copied if somes bytes are copied + return 0 if the end of file was reached + return <0 with error code if there is an error + (UNZ_ERRNO for IO error, or zLib error for uncompress error) +*/ +extern int ZEXPORT unzReadCurrentFile (file, buf, len) + unzFile file; + voidp buf; + unsigned len; +{ + int err=UNZ_OK; + uInt iRead = 0; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + + if ((pfile_in_zip_read_info->read_buffer == NULL)) + return UNZ_END_OF_LIST_OF_FILE; + if (len==0) + return 0; + + pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; + + pfile_in_zip_read_info->stream.avail_out = (uInt)len; + + if ((len>pfile_in_zip_read_info->rest_read_uncompressed) && + (!(pfile_in_zip_read_info->raw))) + pfile_in_zip_read_info->stream.avail_out = + (uInt)pfile_in_zip_read_info->rest_read_uncompressed; + + if ((len>pfile_in_zip_read_info->rest_read_compressed+ + pfile_in_zip_read_info->stream.avail_in) && + (pfile_in_zip_read_info->raw)) + pfile_in_zip_read_info->stream.avail_out = + (uInt)pfile_in_zip_read_info->rest_read_compressed+ + pfile_in_zip_read_info->stream.avail_in; + + while (pfile_in_zip_read_info->stream.avail_out>0) + { + if ((pfile_in_zip_read_info->stream.avail_in==0) && + (pfile_in_zip_read_info->rest_read_compressed>0)) + { + uInt uReadThis = UNZ_BUFSIZE; + if (pfile_in_zip_read_info->rest_read_compressedrest_read_compressed; + if (uReadThis == 0) + return UNZ_EOF; + if (ZSEEK(pfile_in_zip_read_info->z_filefunc, + pfile_in_zip_read_info->filestream, + pfile_in_zip_read_info->pos_in_zipfile + + pfile_in_zip_read_info->byte_before_the_zipfile, + ZLIB_FILEFUNC_SEEK_SET)!=0) + return UNZ_ERRNO; + if (ZREAD(pfile_in_zip_read_info->z_filefunc, + pfile_in_zip_read_info->filestream, + pfile_in_zip_read_info->read_buffer, + uReadThis)!=uReadThis) + return UNZ_ERRNO; + + +# ifndef NOUNCRYPT + if(s->encrypted) + { + uInt i; + for(i=0;iread_buffer[i] = + zdecode(s->keys,s->pcrc_32_tab, + pfile_in_zip_read_info->read_buffer[i]); + } +# endif + + + pfile_in_zip_read_info->pos_in_zipfile += uReadThis; + + pfile_in_zip_read_info->rest_read_compressed-=uReadThis; + + pfile_in_zip_read_info->stream.next_in = + (Bytef*)pfile_in_zip_read_info->read_buffer; + pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; + } + + if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) + { + uInt uDoCopy,i ; + + if ((pfile_in_zip_read_info->stream.avail_in == 0) && + (pfile_in_zip_read_info->rest_read_compressed == 0)) + return (iRead==0) ? UNZ_EOF : iRead; + + if (pfile_in_zip_read_info->stream.avail_out < + pfile_in_zip_read_info->stream.avail_in) + uDoCopy = pfile_in_zip_read_info->stream.avail_out ; + else + uDoCopy = pfile_in_zip_read_info->stream.avail_in ; + + for (i=0;istream.next_out+i) = + *(pfile_in_zip_read_info->stream.next_in+i); + + pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, + pfile_in_zip_read_info->stream.next_out, + uDoCopy); + pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; + pfile_in_zip_read_info->stream.avail_in -= uDoCopy; + pfile_in_zip_read_info->stream.avail_out -= uDoCopy; + pfile_in_zip_read_info->stream.next_out += uDoCopy; + pfile_in_zip_read_info->stream.next_in += uDoCopy; + pfile_in_zip_read_info->stream.total_out += uDoCopy; + iRead += uDoCopy; + } + else + { + uLong uTotalOutBefore,uTotalOutAfter; + const Bytef *bufBefore; + uLong uOutThis; + int flush=Z_SYNC_FLUSH; + + uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; + bufBefore = pfile_in_zip_read_info->stream.next_out; + + /* + if ((pfile_in_zip_read_info->rest_read_uncompressed == + pfile_in_zip_read_info->stream.avail_out) && + (pfile_in_zip_read_info->rest_read_compressed == 0)) + flush = Z_FINISH; + */ + err=inflate(&pfile_in_zip_read_info->stream,flush); + + if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL)) + err = Z_DATA_ERROR; + + uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; + uOutThis = uTotalOutAfter-uTotalOutBefore; + + pfile_in_zip_read_info->crc32 = + crc32(pfile_in_zip_read_info->crc32,bufBefore, + (uInt)(uOutThis)); + + pfile_in_zip_read_info->rest_read_uncompressed -= + uOutThis; + + iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); + + if (err==Z_STREAM_END) + return (iRead==0) ? UNZ_EOF : iRead; + if (err!=Z_OK) + break; + } + } + + if (err==Z_OK) + return iRead; + return err; +} + + +/* + Give the current position in uncompressed data +*/ +extern z_off_t ZEXPORT unztell (file) + unzFile file; +{ + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + return (z_off_t)pfile_in_zip_read_info->stream.total_out; +} + + +/* + return 1 if the end of file was reached, 0 elsewhere +*/ +extern int ZEXPORT unzeof (file) + unzFile file; +{ + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + if (pfile_in_zip_read_info->rest_read_uncompressed == 0) + return 1; + else + return 0; +} + + + +/* + Read extra field from the current file (opened by unzOpenCurrentFile) + This is the local-header version of the extra field (sometimes, there is + more info in the local-header version than in the central-header) + + if buf==NULL, it return the size of the local extra field that can be read + + if buf!=NULL, len is the size of the buffer, the extra header is copied in + buf. + the return value is the number of bytes copied in buf, or (if <0) + the error code +*/ +extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) + unzFile file; + voidp buf; + unsigned len; +{ + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + uInt read_now; + uLong size_to_read; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + size_to_read = (pfile_in_zip_read_info->size_local_extrafield - + pfile_in_zip_read_info->pos_local_extrafield); + + if (buf==NULL) + return (int)size_to_read; + + if (len>size_to_read) + read_now = (uInt)size_to_read; + else + read_now = (uInt)len ; + + if (read_now==0) + return 0; + + if (ZSEEK(pfile_in_zip_read_info->z_filefunc, + pfile_in_zip_read_info->filestream, + pfile_in_zip_read_info->offset_local_extrafield + + pfile_in_zip_read_info->pos_local_extrafield, + ZLIB_FILEFUNC_SEEK_SET)!=0) + return UNZ_ERRNO; + + if (ZREAD(pfile_in_zip_read_info->z_filefunc, + pfile_in_zip_read_info->filestream, + buf,read_now)!=read_now) + return UNZ_ERRNO; + + return (int)read_now; +} + +/* + Close the file in zip opened with unzipOpenCurrentFile + Return UNZ_CRCERROR if all the file was read but the CRC is not good +*/ +extern int ZEXPORT unzCloseCurrentFile (file) + unzFile file; +{ + int err=UNZ_OK; + + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + + if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) && + (!pfile_in_zip_read_info->raw)) + { + if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) + err=UNZ_CRCERROR; + } + + + TRYFREE(pfile_in_zip_read_info->read_buffer); + pfile_in_zip_read_info->read_buffer = NULL; + if (pfile_in_zip_read_info->stream_initialised) + inflateEnd(&pfile_in_zip_read_info->stream); + + pfile_in_zip_read_info->stream_initialised = 0; + TRYFREE(pfile_in_zip_read_info); + + s->pfile_in_zip_read=NULL; + + return err; +} + + +/* + Get the global comment string of the ZipFile, in the szComment buffer. + uSizeBuf is the size of the szComment buffer. + return the number of byte copied or an error code <0 +*/ +extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf) + unzFile file; + char *szComment; + uLong uSizeBuf; +{ + unz_s* s; + uLong uReadThis ; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + + uReadThis = uSizeBuf; + if (uReadThis>s->gi.size_comment) + uReadThis = s->gi.size_comment; + + if (ZSEEK(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0) + return UNZ_ERRNO; + + if (uReadThis>0) + { + *szComment='\0'; + if (ZREAD(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis) + return UNZ_ERRNO; + } + + if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) + *(szComment+s->gi.size_comment)='\0'; + return (int)uReadThis; +} + +/* Additions by RX '2004 */ +extern uLong ZEXPORT unzGetOffset (file) + unzFile file; +{ + unz_s* s; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return 0; + if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff) + if (s->num_file==s->gi.number_entry) + return 0; + return s->pos_in_central_dir; +} + +extern int ZEXPORT unzSetOffset (file, pos) + unzFile file; + uLong pos; +{ + unz_s* s; + int err; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + + s->pos_in_central_dir = pos; + s->num_file = s->gi.number_entry; /* hack */ + err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; +} diff --git a/source/unzip/unzip.h b/source/unzip/unzip.h new file mode 100644 index 00000000..c3206a05 --- /dev/null +++ b/source/unzip/unzip.h @@ -0,0 +1,354 @@ +/* unzip.h -- IO for uncompress .zip files using zlib + Version 1.01e, February 12th, 2005 + + Copyright (C) 1998-2005 Gilles Vollant + + This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g + WinZip, InfoZip tools and compatible. + + Multi volume ZipFile (span) are not supported. + Encryption compatible with pkzip 2.04g only supported + Old compressions used by old PKZip 1.x are not supported + + + I WAIT FEEDBACK at mail info@winimage.com + Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution + + Condition of use and distribution are the same than zlib : + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + +*/ + +/* for more info about .ZIP format, see + http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip + http://www.info-zip.org/pub/infozip/doc/ + PkWare has also a specification at : + ftp://ftp.pkware.com/probdesc.zip +*/ + +#ifndef _unz_H +#define _unz_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ZLIB_H +#include "zlib.h" +#endif + +#ifndef _ZLIBIOAPI_H +#include "ioapi.h" +#endif + +#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) +/* like the STRICT of WIN32, we define a pointer that cannot be converted + from (void*) without cast */ +typedef struct TagunzFile__ { int unused; } unzFile__; +typedef unzFile__ *unzFile; +#else +typedef voidp unzFile; +#endif + + +#define UNZ_OK (0) +#define UNZ_END_OF_LIST_OF_FILE (-100) +#define UNZ_ERRNO (Z_ERRNO) +#define UNZ_EOF (0) +#define UNZ_PARAMERROR (-102) +#define UNZ_BADZIPFILE (-103) +#define UNZ_INTERNALERROR (-104) +#define UNZ_CRCERROR (-105) + +/* tm_unz contain date/time info */ +typedef struct tm_unz_s +{ + uInt tm_sec; /* seconds after the minute - [0,59] */ + uInt tm_min; /* minutes after the hour - [0,59] */ + uInt tm_hour; /* hours since midnight - [0,23] */ + uInt tm_mday; /* day of the month - [1,31] */ + uInt tm_mon; /* months since January - [0,11] */ + uInt tm_year; /* years - [1980..2044] */ +} tm_unz; + +/* unz_global_info structure contain global data about the ZIPfile + These data comes from the end of central dir */ +typedef struct unz_global_info_s +{ + uLong number_entry; /* total number of entries in + the central dir on this disk */ + uLong size_comment; /* size of the global comment of the zipfile */ +} unz_global_info; + + +/* unz_file_info contain information about a file in the zipfile */ +typedef struct unz_file_info_s +{ + uLong version; /* version made by 2 bytes */ + uLong version_needed; /* version needed to extract 2 bytes */ + uLong flag; /* general purpose bit flag 2 bytes */ + uLong compression_method; /* compression method 2 bytes */ + uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ + uLong crc; /* crc-32 4 bytes */ + uLong compressed_size; /* compressed size 4 bytes */ + uLong uncompressed_size; /* uncompressed size 4 bytes */ + uLong size_filename; /* filename length 2 bytes */ + uLong size_file_extra; /* extra field length 2 bytes */ + uLong size_file_comment; /* file comment length 2 bytes */ + + uLong disk_num_start; /* disk number start 2 bytes */ + uLong internal_fa; /* internal file attributes 2 bytes */ + uLong external_fa; /* external file attributes 4 bytes */ + + tm_unz tmu_date; +} unz_file_info; + +extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, + const char* fileName2, + int iCaseSensitivity)); +/* + Compare two filename (fileName1,fileName2). + If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) + If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi + or strcasecmp) + If iCaseSenisivity = 0, case sensitivity is defaut of your operating system + (like 1 on Unix, 2 on Windows) +*/ + + +extern unzFile ZEXPORT unzOpen OF((const char *path)); +/* + Open a Zip file. path contain the full pathname (by example, + on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer + "zlib/zlib113.zip". + If the zipfile cannot be opened (file don't exist or in not valid), the + return value is NULL. + Else, the return value is a unzFile Handle, usable with other function + of this unzip package. +*/ + +extern unzFile ZEXPORT unzOpen2 OF((const char *path, + zlib_filefunc_def* pzlib_filefunc_def)); +/* + Open a Zip file, like unzOpen, but provide a set of file low level API + for read/write the zip file (see ioapi.h) +*/ + +extern int ZEXPORT unzClose OF((unzFile file)); +/* + Close a ZipFile opened with unzipOpen. + If there is files inside the .Zip opened with unzOpenCurrentFile (see later), + these files MUST be closed with unzipCloseCurrentFile before call unzipClose. + return UNZ_OK if there is no problem. */ + +extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, + unz_global_info *pglobal_info)); +/* + Write info about the ZipFile in the *pglobal_info structure. + No preparation of the structure is needed + return UNZ_OK if there is no problem. */ + + +extern int ZEXPORT unzGetGlobalComment OF((unzFile file, + char *szComment, + uLong uSizeBuf)); +/* + Get the global comment string of the ZipFile, in the szComment buffer. + uSizeBuf is the size of the szComment buffer. + return the number of byte copied or an error code <0 +*/ + + +/***************************************************************************/ +/* Unzip package allow you browse the directory of the zipfile */ + +extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); +/* + Set the current file of the zipfile to the first file. + return UNZ_OK if there is no problem +*/ + +extern int ZEXPORT unzGoToNextFile OF((unzFile file)); +/* + Set the current file of the zipfile to the next file. + return UNZ_OK if there is no problem + return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. +*/ + +extern int ZEXPORT unzLocateFile OF((unzFile file, + const char *szFileName, + int iCaseSensitivity)); +/* + Try locate the file szFileName in the zipfile. + For the iCaseSensitivity signification, see unzStringFileNameCompare + + return value : + UNZ_OK if the file is found. It becomes the current file. + UNZ_END_OF_LIST_OF_FILE if the file is not found +*/ + + +/* ****************************************** */ +/* Ryan supplied functions */ +/* unz_file_info contain information about a file in the zipfile */ +typedef struct unz_file_pos_s +{ + uLong pos_in_zip_directory; /* offset in zip file directory */ + uLong num_of_file; /* # of file */ +} unz_file_pos; + +extern int ZEXPORT unzGetFilePos( + unzFile file, + unz_file_pos* file_pos); + +extern int ZEXPORT unzGoToFilePos( + unzFile file, + unz_file_pos* file_pos); + +/* ****************************************** */ + +extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, + unz_file_info *pfile_info, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize)); +/* + Get Info about the current file + if pfile_info!=NULL, the *pfile_info structure will contain somes info about + the current file + if szFileName!=NULL, the filemane string will be copied in szFileName + (fileNameBufferSize is the size of the buffer) + if extraField!=NULL, the extra field information will be copied in extraField + (extraFieldBufferSize is the size of the buffer). + This is the Central-header version of the extra field + if szComment!=NULL, the comment string of the file will be copied in szComment + (commentBufferSize is the size of the buffer) +*/ + +/***************************************************************************/ +/* for reading the content of the current zipfile, you can open it, read data + from it, and close it (you can close it before reading all the file) + */ + +extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); +/* + Open for reading data the current file in the zipfile. + If there is no error, the return value is UNZ_OK. +*/ + +extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file, + const char* password)); +/* + Open for reading data the current file in the zipfile. + password is a crypting password + If there is no error, the return value is UNZ_OK. +*/ + +extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file, + int* method, + int* level, + int raw)); +/* + Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) + if raw==1 + *method will receive method of compression, *level will receive level of + compression + note : you can set level parameter as NULL (if you did not want known level, + but you CANNOT set method parameter as NULL +*/ + +extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file, + int* method, + int* level, + int raw, + const char* password)); +/* + Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) + if raw==1 + *method will receive method of compression, *level will receive level of + compression + note : you can set level parameter as NULL (if you did not want known level, + but you CANNOT set method parameter as NULL +*/ + + +extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); +/* + Close the file in zip opened with unzOpenCurrentFile + Return UNZ_CRCERROR if all the file was read but the CRC is not good +*/ + +extern int ZEXPORT unzReadCurrentFile OF((unzFile file, + voidp buf, + unsigned len)); +/* + Read bytes from the current file (opened by unzOpenCurrentFile) + buf contain buffer where data must be copied + len the size of buf. + + return the number of byte copied if somes bytes are copied + return 0 if the end of file was reached + return <0 with error code if there is an error + (UNZ_ERRNO for IO error, or zLib error for uncompress error) +*/ + +extern z_off_t ZEXPORT unztell OF((unzFile file)); +/* + Give the current position in uncompressed data +*/ + +extern int ZEXPORT unzeof OF((unzFile file)); +/* + return 1 if the end of file was reached, 0 elsewhere +*/ + +extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, + voidp buf, + unsigned len)); +/* + Read extra field from the current file (opened by unzOpenCurrentFile) + This is the local-header version of the extra field (sometimes, there is + more info in the local-header version than in the central-header) + + if buf==NULL, it return the size of the local extra field + + if buf!=NULL, len is the size of the buffer, the extra header is copied in + buf. + the return value is the number of bytes copied in buf, or (if <0) + the error code +*/ + +/***************************************************************************/ + +/* Get the current file offset */ +extern uLong ZEXPORT unzGetOffset (unzFile file); + +/* Set the current file offset */ +extern int ZEXPORT unzSetOffset (unzFile file, uLong pos); + + + +#ifdef __cplusplus +} +#endif + +#endif /* _unz_H */ diff --git a/source/xml.c b/source/xml.c new file mode 100644 index 00000000..a19637dc --- /dev/null +++ b/source/xml.c @@ -0,0 +1,622 @@ +/* +Load game information from XML - Lustar + - Mini-XML ported by Beardface + - MiniZip adapted by Tantric +*/ + +#include "cfg.h" + +#include "mxml/mxml.h" +#include "xml.h" +#include "unzip/unzip.h" + + +bool xmldebug = false; + +extern struct SSettings Settings; // for loader GX + + +char langlist[11][22] = +{{"Console Default"}, +{"Japanese"}, +{"English"}, +{"German"}, +{"French"}, +{"Spanish"}, +{"Italian"}, +{"Dutch"}, +{"S. Chinese"}, +{"T. Chinese"}, +{"Korean"}}; + +char langcodes[11][22] = +{{""}, +{"JA"}, +{"EN"}, +{"DE"}, +{"FR"}, +{"ES"}, +{"IT"}, +{"NL"}, +{"ZH"}, +{"ZH"}, +{"KO"}}; + +char element_text[5000]; + +mxml_node_t *nodetree; +mxml_node_t *nodedata; +mxml_node_t *nodeid; +mxml_node_t *nodeidtmp; +mxml_node_t *nodefound; +mxml_index_t *nodeindex; +mxml_index_t *nodeindextmp; + +int xmlloadtime = 0; + + +/* get_text() taken as is from mini-mxml example mxmldoc.c */ +/* get_text() - Get the text for a node. */ +static char *get_text(mxml_node_t *node, char *buffer, int buflen); +static char * /* O - Text in node */ +get_text(mxml_node_t *node, /* I - Node to get */ + char *buffer, /* I - Buffer */ + int buflen) /* I - Size of buffer */ +{ + char *ptr, /* Pointer into buffer */ + *end; /* End of buffer */ + int len; /* Length of node */ + mxml_node_t *current; /* Current node */ + ptr = buffer; + end = buffer + buflen - 1; + for (current = node->child; current && ptr < end; current = current->next) + { + if (current->type == MXML_TEXT) { + if (current->value.text.whitespace) + *ptr++ = ' '; + len = (int)strlen(current->value.text.string); + if (len > (int)(end - ptr)) + len = (int)(end - ptr); + memcpy(ptr, current->value.text.string, len); + ptr += len; + } else if (current->type == MXML_OPAQUE) { + len = (int)strlen(current->value.opaque); + if (len > (int)(end - ptr)) + len = (int)(end - ptr); + memcpy(ptr, current->value.opaque, len); + ptr += len; + } + } + *ptr = '\0'; + return (buffer); +} + + +void GetTextFromNode(mxml_node_t *currentnode, mxml_node_t *topnode, char *nodename, char *attributename, char *value, int descend, char *dest) +{ + *element_text = 0; // reset text + + nodefound = mxmlFindElement(currentnode, topnode, nodename, attributename, value, descend); + if (nodefound != NULL) { + if (attributename != NULL) { + strcpy(dest,mxmlElementGetAttr(nodefound, attributename)); + } else { + get_text(nodefound, element_text, sizeof(element_text)); + strcpy(dest,element_text); + } + } else { + strcpy(dest,""); + } +} + + +bool OpenXMLFile(char *filename) +{ + mxml_node_t *nodetree; + +// if (xmldebug) +// dbg_time1(); + + char* strresult = strstr(filename,".zip"); + if (strresult == NULL) { + /* Load XML file */ + FILE *filexml; + filexml = fopen(filename, "rb"); + if (!filexml) + return false; + + nodetree = mxmlLoadFile(NULL, filexml, MXML_NO_CALLBACK); + fclose(filexml); + + } else { + /* load zipped XML file */ + unzFile unzfile = unzOpen(filename); + if (unzfile == NULL) + return false; + unzOpenCurrentFile(unzfile); + + unz_file_info zipfileinfo; + unzGetCurrentFileInfo(unzfile, &zipfileinfo, NULL, 0, NULL, 0, NULL, 0); + int zipfilebuffersize = zipfileinfo.uncompressed_size; + char * zipfilebuffer = (char *) calloc(1,zipfilebuffersize); + if (zipfilebuffer == NULL) + return false; + + unzReadCurrentFile(unzfile, zipfilebuffer, zipfilebuffersize); + unzCloseCurrentFile(unzfile); + unzClose(unzfile); + + nodetree = mxmlLoadString(NULL, zipfilebuffer, MXML_NO_CALLBACK); + free(zipfilebuffer); + } + + if (nodetree == NULL) + return false; + + nodedata = mxmlFindElement(nodetree, nodetree, "datafile", NULL, NULL, MXML_DESCEND); + if (nodedata == NULL) + return false; + + /* create index of elements */ + nodeindex = mxmlIndexNew(nodetree,"id", NULL); + if (nodedata == NULL) { + return false; + } else { + //if (xmldebug); + // xmlloadtime = dbg_time2(NULL); + return true; + } +} + + +void FreeXMLMemory() +{ + /* free memory */ + mxmlIndexDelete(nodeindex); + mxmlIndexDelete(nodeindextmp); + mxmlDelete(nodeid); + mxmlDelete(nodeidtmp); + mxmlDelete(nodefound); + mxmlDelete(nodedata); + mxmlDelete(nodetree); +} + + +/* convert language text into ISO 639 two-letter language code */ +char *ConvertLangTextToCode(char *languagetxt) +{ + int i; + for (i=0;i<=10;i++) + { + if (!strcasecmp(languagetxt,langlist[i])) // case insensitive comparison + return langcodes[i]; + } + return ""; +} + + +char ConvertRatingToIndex(char *ratingtext) +{ + int type = -1; + if (strcmp(ratingtext,"CERO") == 0) { type = 0; } + if (strcmp(ratingtext,"ESRB") == 0) { type = 1; } + if (strcmp(ratingtext,"PEGI") == 0) { type = 2; } + return type; +} + + +void ConvertRating(char *ratingvalue, char *fromrating, char *torating, char *destvalue) +{ + if(strcmp(fromrating,torating) == 0) { + strcpy(destvalue,ratingvalue); + return; + } + + strcpy(destvalue,""); + int type = -1; + int desttype = -1; + + type = ConvertRatingToIndex(fromrating); + desttype = ConvertRatingToIndex(torating); + if (type == -1 || desttype == -1) + return; + + /* rating conversion table */ + /* the list is ordered to pick the most likely value first: */ + /* EC and AO are less likely to be used so they are moved down to only be picked up when converting ESRB to PEGI or CERO */ + /* the conversion can never be perfect because ratings can differ between regions for the same game */ + char ratingtable[12][3][4] = + { + {{"A"},{"E"},{"3"}}, + {{"A"},{"E"},{"4"}}, + {{"A"},{"E"},{"6"}}, + {{"A"},{"E"},{"7"}}, + {{"A"},{"EC"},{"3"}}, + {{"A"},{"E10+"},{"7"}}, + {{"B"},{"T"},{"12"}}, + {{"D"},{"M"},{"18"}}, + {{"D"},{"M"},{"16"}}, + {{"C"},{"T"},{"16"}}, + {{"C"},{"T"},{"15"}}, + {{"Z"},{"AO"},{"18"}}, + }; + + int i; + for (i=0;i<=11;i++) + { + if (strcmp(ratingtable[i][type],ratingvalue) == 0) { + strcpy(destvalue,ratingtable[i][desttype]); + return; + } + } +} + + +void LoadTitlesFromXML(char *langtxt, bool forcejptoen) +/* langtxt: set to "English","French","German", to force language for all titles, or "" to load title depending on each game's setting */ +/* forcejptoen: set to true to load English title instead of Japanese title when game is set to Japanese */ +{ + if (nodeindex == NULL) + return; + + bool forcelang = false; + if (strcmp(langtxt,"")) + forcelang = true; + + char langcode[100] = ""; + if (forcelang) + strcpy(langcode,ConvertLangTextToCode(langtxt)); /* convert language text into ISO 639 two-letter language code */ + + /* reset index before new search */ + nodeid = mxmlIndexReset(nodeindex); + *element_text = 0; + char id_text[10]; + char title_text[500] = ""; + char title_text_EN[500] = ""; + + /* search index of id elements, load all id/titles text */ + while (nodeid != NULL) + { + nodeid = mxmlIndexFind(nodeindex,"id", NULL); + if (nodeid != NULL) { + strcpy(title_text,""); + strcpy(title_text_EN,""); + + get_text(nodeid, element_text, sizeof(element_text)); + snprintf(id_text, 7, "%s",element_text); + + // if language is not forced, use game language setting from config + if (!forcelang) { + struct Game_CFG *game_cfg = NULL; + int opt_lang; + game_cfg = CFG_get_game_opt((u8*)id_text); + if (game_cfg) { + opt_lang = game_cfg->language; + } else { + // opt_lang = CFG.language; // for config loader + opt_lang = Settings.language; // for loader GX + } + strcpy(langcode,ConvertLangTextToCode(langlist[opt_lang])); + } + + /* if enabled, force English title for all games set to Japanese */ + if (forcejptoen && strcmp(langcode,"JA") == 0) + strcpy(langcode,"EN"); + + /* load title from nodes */ + nodefound = mxmlFindElement(nodeid, nodedata, "locale", "lang", "EN", MXML_NO_DESCEND); + if (nodefound != NULL) { + GetTextFromNode(nodefound, nodedata, "title", NULL, NULL, MXML_DESCEND, title_text_EN); + } + nodefound = mxmlFindElement(nodeid, nodedata, "locale", "lang", langcode, MXML_NO_DESCEND); + if (nodefound != NULL) { + GetTextFromNode(nodefound, nodedata, "title", NULL, NULL, MXML_DESCEND, title_text); + } + /* fall back to English title if prefered language was not found */ + if (strcmp(title_text,"") == 0) { + strcpy(title_text,title_text_EN); + } + + snprintf(id_text, 5, "%s",id_text); + //printf("%s %s\n",id_text,title_text); + title_set(id_text, title_text); + } + } + //if (xmldebug); + //xmlloadtime = dbg_time2(NULL); +} + + +void GetPublisherFromGameid(char *idtxt, char *dest) +{ + /* guess publisher from company list using last two characters from game id */ + + nodeindextmp = mxmlIndexNew(nodedata,"company", NULL); + nodeidtmp = mxmlIndexReset(nodeindextmp); + + *element_text = 0; + char publishercode[3]; + sprintf(publishercode,"%c%c", idtxt[4],idtxt[5]); + + while (strcmp(element_text,publishercode) != 0) + { + nodeidtmp = mxmlIndexFind(nodeindextmp,"company", NULL); + if (nodeidtmp != NULL) { + strcpy(element_text,mxmlElementGetAttr(nodeidtmp, "code")); + } else { + break; + } + } + if (strcmp(element_text,publishercode) == 0) { + strcpy(dest,mxmlElementGetAttr(nodeidtmp, "name")); + } else { + strcpy(dest,""); + } +} + + +void LoadGameInfoFromXML(char* gameid, char* langtxt) +/* gameid: full game id */ +/* langcode: "English","French","German" */ +{ + if (nodeindex == NULL) + return; + + /* convert language text into ISO 639 two-letter language codes */ + char langcode[100] = ""; + strcpy(langcode,ConvertLangTextToCode(langtxt)); + + /* reset all game info */ + gameinfo = gameinfo_reset; + + /* reset index before new search */ + nodeid = mxmlIndexReset(nodeindex); + *element_text = 0; + + /* search for game matching gameid */ + while (strcmp(element_text,gameid) != 0) + { + nodeid = mxmlIndexFind(nodeindex,"id", NULL); + if (nodeid != NULL) { + get_text(nodeid, element_text, sizeof(element_text)); + } else { + break; + } + } + + if (strcmp(element_text,gameid) == 0) { + /* text from elements */ + strcpy(gameinfo.id,element_text); + GetTextFromNode(nodeid, nodedata, "region", NULL, NULL, MXML_NO_DESCEND, gameinfo.region); + GetTextFromNode(nodeid, nodedata, "version", NULL, NULL, MXML_NO_DESCEND, gameinfo.version); + GetTextFromNode(nodeid, nodedata, "genre", NULL, NULL, MXML_NO_DESCEND, gameinfo.genre); + GetTextFromNode(nodeid, nodedata, "developer", NULL, NULL, MXML_NO_DESCEND, gameinfo.developer); + GetTextFromNode(nodeid, nodedata, "publisher", NULL, NULL, MXML_NO_DESCEND, gameinfo.publisher); + // try to guess publisher from game id in case it is missing + if (strcmp(gameinfo.publisher,"") == 0) { + GetPublisherFromGameid(gameid,gameinfo.publisher); + } + GetPublisherFromGameid(gameid,gameinfo.publisherfromid); + + /* text from attributes */ + GetTextFromNode(nodeid, nodedata, "date", "year", NULL, MXML_NO_DESCEND, gameinfo.year); + GetTextFromNode(nodeid, nodedata, "date", "month", NULL,MXML_NO_DESCEND, gameinfo.month); + GetTextFromNode(nodeid, nodedata, "date", "day", NULL, MXML_NO_DESCEND, gameinfo.day); + GetTextFromNode(nodeid, nodedata, "rating", "type", NULL, MXML_NO_DESCEND, gameinfo.ratingtype); + GetTextFromNode(nodeid, nodedata, "rating", "value", NULL, MXML_NO_DESCEND, gameinfo.ratingvalue); + GetTextFromNode(nodeid, nodedata, "rom", "crc", NULL, MXML_NO_DESCEND, gameinfo.iso_crc); + GetTextFromNode(nodeid, nodedata, "rom", "md5", NULL, MXML_NO_DESCEND, gameinfo.iso_md5); + GetTextFromNode(nodeid, nodedata, "rom", "sha1", NULL, MXML_NO_DESCEND, gameinfo.iso_sha1); + + /* text from child elements */ + nodefound = mxmlFindElement(nodeid, nodedata, "locale", "lang", "EN", MXML_NO_DESCEND); + if (nodefound != NULL) { + GetTextFromNode(nodefound, nodedata, "title", NULL, NULL, MXML_DESCEND, gameinfo.title_EN); + GetTextFromNode(nodefound, nodedata, "synopsis", NULL, NULL, MXML_DESCEND, gameinfo.synopsis_EN); + } + nodefound = mxmlFindElement(nodeid, nodedata, "locale", "lang", langcode, MXML_NO_DESCEND); + if (nodefound != NULL) { + GetTextFromNode(nodefound, nodedata, "title", NULL, NULL, MXML_DESCEND, gameinfo.title); + GetTextFromNode(nodefound, nodedata, "synopsis", NULL, NULL, MXML_DESCEND, gameinfo.synopsis); + } + // fall back to English title and synopsis if prefered language was not found + if (strcmp(gameinfo.title,"") == 0) { + strcpy(gameinfo.title,gameinfo.title_EN); + } + if (strcmp(gameinfo.synopsis,"") == 0) { + strcpy(gameinfo.synopsis,gameinfo.synopsis_EN); + } + + /* list locale lang attributes */ + nodefound = mxmlFindElement(nodeid, nodedata, "locale", "lang", NULL, MXML_NO_DESCEND); + if (nodefound != NULL) { + int incr = 0; + while (nodefound != NULL) + { + ++incr; + strcpy(gameinfo.locales[incr],mxmlElementGetAttr(nodefound, "lang")); + nodefound = mxmlWalkNext(nodefound, nodedata, MXML_NO_DESCEND); + if (nodefound != NULL) { + nodefound = mxmlFindElement(nodefound, nodedata, "locale", "lang", NULL, MXML_NO_DESCEND); + } + } + } + + /* unbounded child elements */ + GetTextFromNode(nodeid, nodedata, "wi-fi", "players", NULL, MXML_NO_DESCEND, gameinfo.wifiplayers); + nodefound = mxmlFindElement(nodeid, nodedata, "wi-fi", NULL, NULL, MXML_NO_DESCEND); + if (nodefound != NULL) { + int incr = 0; + nodeindextmp = mxmlIndexNew(nodefound,"feature", NULL); + nodeidtmp = mxmlIndexReset(nodeindextmp); + + while (nodeidtmp != NULL) + { + nodeidtmp = mxmlIndexFind(nodeindextmp,"feature", NULL); + if (nodeidtmp != NULL) { + ++incr; + GetTextFromNode(nodeidtmp, nodedata, "feature", NULL, NULL, MXML_DESCEND, gameinfo.wififeatures[incr]); + } + } + } + + nodefound = mxmlFindElement(nodeid, nodedata, "rating", NULL, NULL, MXML_NO_DESCEND); + if (nodefound != NULL) { + int incr = 0; + nodeindextmp = mxmlIndexNew(nodefound,"descriptor", NULL); + nodeidtmp = mxmlIndexReset(nodeindextmp); + + while (nodeidtmp != NULL) + { + nodeidtmp = mxmlIndexFind(nodeindextmp,"descriptor", NULL); + if (nodeidtmp != NULL) { + ++incr; + GetTextFromNode(nodeidtmp, nodedata, "descriptor", NULL, NULL, MXML_DESCEND, gameinfo.ratingdescriptors[incr]); + } + } + } + + GetTextFromNode(nodeid, nodedata, "input", "players", NULL, MXML_NO_DESCEND, gameinfo.players); + nodefound = mxmlFindElement(nodeid, nodedata, "input", NULL, NULL, MXML_NO_DESCEND); + if (nodefound != NULL) { + //int incr = 0; + //int incrreq = 0; + gameinfo.accessoryCnt=0; + gameinfo.accessoryReqCnt=0; + + nodeindextmp = mxmlIndexNew(nodefound,"control", NULL); + nodeidtmp = mxmlIndexReset(nodeindextmp); + + while (nodeidtmp != NULL) + { + nodeidtmp = mxmlIndexFind(nodeindextmp,"control", NULL); + if (nodeidtmp != NULL) { + if (strcmp(mxmlElementGetAttr(nodeidtmp, "required"),"true") == 0) { + ++gameinfo.accessoryReqCnt; + strcpy(gameinfo.accessories_required[gameinfo.accessoryReqCnt],mxmlElementGetAttr(nodeidtmp, "type")); + } else { + //++incr; + ++gameinfo.accessoryCnt; + strcpy(gameinfo.accessories[gameinfo.accessoryCnt],mxmlElementGetAttr(nodeidtmp, "type")); + } + } + } + } + + /* convert rating value */ + ConvertRating(gameinfo.ratingvalue, gameinfo.ratingtype, "CERO",gameinfo.ratingvalueCERO); + ConvertRating(gameinfo.ratingvalue, gameinfo.ratingtype, "ESRB",gameinfo.ratingvalueESRB); + ConvertRating(gameinfo.ratingvalue, gameinfo.ratingtype, "PEGI",gameinfo.ratingvaluePEGI); + + //PrintGameInfo(); + + } else { + /*game not found */ + } +} + + +void PrintGameInfo(bool showfullinfo) +{ + if (showfullinfo) { + + //Con_Clear(); + + //printf("id: %s version: %s region: %s",gameinfo.id, gameinfo.version, gameinfo.region); + printf("title: %s\n",gameinfo.title); + int i; + printf("locales:"); + for (i=1;strcmp(gameinfo.locales[i],"") != 0;i++) + { + printf(" %s",gameinfo.locales[i]); + } + printf("\n"); + printf("developer: %s\n",gameinfo.developer); + printf("publisher: %s\n",gameinfo.publisher); + printf("publisher from ID: %s\n",gameinfo.publisherfromid); + printf("year:%s month:%s day:%s\n",gameinfo.year,gameinfo.month,gameinfo.day); + printf("genre: %s\n",gameinfo.genre); + printf("rating: %s %s (CERO: %s ESRB: %s PEGI: %s)\n",gameinfo.ratingtype, gameinfo.ratingvalue, + gameinfo.ratingvalueCERO,gameinfo.ratingvalueESRB,gameinfo.ratingvaluePEGI); + printf("content descriptor:"); + for (i=1;strcmp(gameinfo.wififeatures[i],"") != 0;i++) + { + printf(" %s",gameinfo.ratingdescriptors[i]); + } + printf("\n"); + printf("players: %s wi-fi: %s\n",gameinfo.players,gameinfo.wifiplayers); + printf("wi-fi features:"); + for (i=1;strcmp(gameinfo.wififeatures[i],"") != 0;i++) + { + printf(" %s",gameinfo.wififeatures[i]); + } + printf("\n"); + printf("accessory required:"); + for (i=1;strcmp(gameinfo.accessories_required[i],"") != 0;i++) + { + printf(" %s",gameinfo.accessories_required[i]); + } + printf("\n"); + printf("accessory:"); + for (i=1;strcmp(gameinfo.accessories[i],"") != 0;i++) + { + printf(" %s",gameinfo.accessories[i]); + } + printf("\n"); + //printf("iso_crc: %s iso_md5: %s\n",gameinfo.iso_crc,gameinfo.iso_md5); + //printf("iso_sha1: %s\n",gameinfo.iso_sha1); + printf("synopsis: %s\n",gameinfo.synopsis); + + } else { + + char linebuf[1000] = ""; + + if (xmldebug) { + char xmltime[100]; + sprintf(xmltime,"%d",xmlloadtime); + printf("xml load time: %s\n",xmltime); + /* + printf("xml forcelang: %s\n",CFG.db_lang); + printf("xml url: %s\n",CFG.db_url); + printf("xml file: %s\n",CFG.db_filename); + char xmljptoen[100]; + sprintf(xmljptoen,"%d",CFG.db_JPtoEN); + printf("xml JPtoEN: %s\n",xmljptoen); + */ + } + + //printf("%s: ",gameidfull); + //printf("%s\n",gameinfo.title); + if (strcmp(gameinfo.year,"") != 0) + snprintf(linebuf, sizeof(linebuf), "%s ", gameinfo.year); + if (strcmp(gameinfo.publisher,"") != 0) + snprintf(linebuf, sizeof(linebuf), "%s%s", linebuf, gameinfo.publisher); + if (strcmp(gameinfo.developer,"") != 0 && strcmp(gameinfo.developer,gameinfo.publisher) != 0) + snprintf(linebuf, sizeof(linebuf), "%s / %s", linebuf, gameinfo.developer); + if (strlen(linebuf) >= 100) { + char buffer[200] = ""; + strncpy(buffer, linebuf, 100); + strncat(buffer, "...", 3); + snprintf(linebuf, sizeof(linebuf), "%s", buffer); + } + printf("%s\n",linebuf); + strcpy(linebuf,""); + + if (strcmp(gameinfo.ratingvalue,"") != 0) { + snprintf(linebuf, sizeof(linebuf), "rated %s", gameinfo.ratingvalue); + if (strcmp(gameinfo.ratingtype,"PEGI") == 0) + snprintf(linebuf, sizeof(linebuf), "%s+ ", linebuf); + snprintf(linebuf, sizeof(linebuf), "%s ", linebuf); + } + if (strcmp(gameinfo.players,"") != 0) { + snprintf(linebuf, sizeof(linebuf), "%sfor %s player", linebuf, gameinfo.players); + if (atoi(gameinfo.players) > 1) + snprintf(linebuf, sizeof(linebuf), "%ss", linebuf); + if (atoi(gameinfo.wifiplayers) > 1) + snprintf(linebuf, sizeof(linebuf), "%s (%s online)", linebuf, gameinfo.wifiplayers); + } + printf("%s\n",linebuf); + strcpy(linebuf,""); + } +} + diff --git a/source/xml.h b/source/xml.h new file mode 100644 index 00000000..d75f943f --- /dev/null +++ b/source/xml.h @@ -0,0 +1,70 @@ + +#ifndef _XML_H_ +#define _XML_H_ + + +#ifdef __cplusplus +extern "C" +{ +#endif + + + +struct gameXMLinfo +{ + char id[10]; + char version[500]; + char region[10]; + char title[500]; + char synopsis[2000]; + char title_EN[500]; + char synopsis_EN[2000]; + char locales[100][500]; + char developer[500]; + char publisher[500]; + char publisherfromid[500]; + char year[10]; + char month[10]; + char day[10]; + char genre[500]; + char ratingtype[10]; + char ratingvalue[10]; + char ratingdescriptors[100][500]; + char ratingvalueCERO[10]; + char ratingvalueESRB[10]; + char ratingvaluePEGI[10]; + char wifiplayers[10]; + char wififeatures[100][500]; + char players[10]; + char accessories[100][500]; + char accessories_required[100][500]; + char iso_crc[10]; + char iso_md5[50]; + char iso_sha1[50]; + int accessoryCnt; + int accessoryReqCnt; + +} ; + +struct gameXMLinfo gameinfo; +struct gameXMLinfo gameinfo_reset; + +bool OpenXMLFile(char* filename); +void LoadGameInfoFromXML(char* gameid, char* langcode); +void LoadTitlesFromXML(char *langcode, bool forcejptoen); +void GetPublisherFromGameid(char *idtxt, char *dest); +char *ConvertLangTextToCode(char *langtext); +void ConvertRating(char *ratingvalue, char *fromrating, char *torating, char *destvalue); +void PrintGameInfo(bool showfullinfo); +void FreeXMLMemory(); + +void title_set(char *id, char *title); + + + +#ifdef __cplusplus +} +#endif + +#endif +