From f4459488578d2c43ea69ff60384ac96212db8138 Mon Sep 17 00:00:00 2001 From: Christopher Roy Bratusek Date: Sat, 7 Apr 2012 19:35:07 +0200 Subject: [PATCH] imported rev0 --- source/BootHomebrew/BootHomebrew.cpp | 2 + source/Menus/menu_main.cpp | 796 +++++++++++--------- source/Menus/menu_settings_file.cpp | 142 ++-- source/Menus/menu_settings_font.cpp | 2 +- source/Menus/menu_settings_language.cpp | 2 +- source/Menus/menu_settings_theme.cpp | 2 +- source/Menus/menus.h | 4 +- source/Menus/menus_command.cpp | 51 +- source/Network/network.cpp | 2 +- source/Network/tcp.cpp | 19 +- source/Network/update.cpp | 12 +- source/Prompts/prompt_app_info.cpp | 139 ++-- source/Prompts/prompt_device.cpp | 64 +- source/Prompts/prompt_end.cpp | 14 +- source/Prompts/prompt_font_download.cpp | 8 +- source/Prompts/prompt_info.cpp | 6 +- source/Prompts/prompt_language_download.cpp | 8 +- source/Prompts/prompt_system.cpp | 2 + source/Prompts/prompt_theme_download.cpp | 38 +- source/Prompts/prompt_update.cpp | 30 +- source/Prompts/prompts.h | 10 +- source/Tools/FontSystem.cpp | 6 +- source/Tools/RuntimeIOSPatch.c | 21 +- source/Tools/SelectIos.cpp | 235 +----- source/Tools/SelectIos.h | 9 +- source/Tools/TakeScreenshot.cpp | 6 +- source/Tools/app_list.cpp | 98 +-- source/Tools/category.cpp | 2 +- source/Tools/copy_app_in_category.cpp | 49 +- source/Tools/copy_app_in_category.h | 1 + source/Tools/fileop.cpp | 225 +----- source/Tools/fileop.h | 6 - source/Tools/load.cpp | 10 +- source/Tools/load_channel.cpp | 119 ++- source/Tools/load_channel.h | 5 + source/Tools/save.cpp | 10 +- source/Tools/theme.cpp | 80 +- source/Tools/theme.h | 14 +- source/Tools/translate.cpp | 14 +- source/filelist.h | 51 +- source/main.cpp | 132 ++-- source/main.h | 15 +- source/menu.cpp | 12 +- source/pngu.c | 629 ++++------------ source/pngu.h | 19 +- 45 files changed, 1292 insertions(+), 1829 deletions(-) diff --git a/source/BootHomebrew/BootHomebrew.cpp b/source/BootHomebrew/BootHomebrew.cpp index 63612bb..8a870bf 100644 --- a/source/BootHomebrew/BootHomebrew.cpp +++ b/source/BootHomebrew/BootHomebrew.cpp @@ -228,6 +228,8 @@ int BootGameCubeHomebrew() ES_GetTicketViews(BC, &view, 1); int ret = ES_LaunchTitle(BC, &view); + if(ret < 0) + LoadHBC(); return ret; } diff --git a/source/Menus/menu_main.cpp b/source/Menus/menu_main.cpp index 53179ad..eeb4956 100644 --- a/source/Menus/menu_main.cpp +++ b/source/Menus/menu_main.cpp @@ -42,16 +42,12 @@ int MenuMain() bool vor = false; int app_pos = -1; - int apps_row = 3; - int apps_numers = Options.apps * apps_row; + int apps_row = 1; + int apps_numers = Options.apps; + int gesamt_apps; - GuiTrigger trigA; - GuiTrigger trigB; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - trigB.SetSimpleTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); - - const u8* temp_apps_btn = NULL; - const u8* temp_apps_btnOver = NULL; + const u8* temp_apps_btn = NULL; + const u8* temp_apps_btnOver = NULL; const u8* temp_normal_grid_inactive = NULL; const u8* temp_normal_grid_active = NULL; const u8* temp_sd_usb_active = NULL; @@ -59,34 +55,108 @@ int MenuMain() const u8* temp_wii_gc_active = NULL; const u8* temp_wii_gc_inactive = NULL; + GuiTrigger trigA; + GuiTrigger trigB; + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + trigB.SetSimpleTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); + + /************************************************************************ + * Kategorien pro auswahl + ***********************************************************************/ + if(Settings.unassigned) + { + vechomebrew_list_choice = vechomebrew_list_unassigned; + // Kategoriename + Settings.category_name = tr(Settings.category_name_all); + Settings.category_name += " - "; + Settings.category_name += tr("unassigned"); + } + else if(Settings.view == 2) + { +// vechomebrew_list_choice = vechomebrew_list_pc; + } + else + { + // Kategorie Alle nur anzeigen, wenn aktiviert oder keine andere vorhanden ist + if(!Options.show_all && Settings.current_category == 0 && AvailableCategory.categories.size() -1 > 0) + Settings.current_category++; + + vechomebrew_list_choice = vechomebrew_list_category[Settings.current_category]; + // Kategoriename + Settings.category_name = AvailableCategory.categories[Settings.current_category]; + } + gesamt_apps = vechomebrew_list_choice.size(); + + + // Kategorie button unt text + GuiText categoryTxt(Settings.category_name.c_str(), 28, (GXColor){Theme.category_1, Theme.category_2, Theme.category_3, 255}); + categoryTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + categoryTxt.SetPosition(0,30); + + GuiButton categoryBtn(categoryTxt.GetTextWidth(), 28); + categoryBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + categoryBtn.SetPosition(0, 30); + categoryBtn.SetTrigger(&trigA); + categoryBtn.SetTrigger(&trigB); + + // HBF und Inhaber + GuiImageData LogoHomebrewFilterImgData(LogoHomebrewFilter_png); + GuiImage LogoHomebrewFilterImg(&LogoHomebrewFilterImgData); + LogoHomebrewFilterImg.SetAlignment(ALIGN_LEFT, ALIGN_TOP); + LogoHomebrewFilterImg.SetPosition(30, 420); + LogoHomebrewFilterImg.SetScale(0.65); + + GuiText ownerTxt("hamachi-mp", 18, (GXColor){Theme.owner_1, Theme.owner_2, Theme.owner_3, 255}); + ownerTxt.SetAlignment(ALIGN_RIGHT, ALIGN_TOP); + ownerTxt.SetPosition(-35,430); + /************************************************************************ * icons zuweisen ***********************************************************************/ - // normal / grid ansicht - if(Settings.grid) - { - temp_apps_btn = Theme.apps_grid; - temp_apps_btnOver = Theme.apps_grid_hover; - - // symbol für normale ansicht - temp_normal_grid_inactive = Theme.grid_inactive; - temp_normal_grid_active = Theme.grid_active; - } - else if(!Settings.grid) + // normal, grid und pc ansicht + if(Settings.view == 0) { temp_apps_btn = Theme.apps_list; temp_apps_btnOver = Theme.apps_list_hover; - // symbol für grid ansicht + // symbol für normale ansicht temp_normal_grid_inactive = Theme.normal_inactive; temp_normal_grid_active = Theme.normal_active; + } + else if(Settings.view == 1) + { + temp_apps_btn = Theme.apps_grid; + temp_apps_btnOver = Theme.apps_grid_hover; - apps_numers = Options.apps; - apps_row = 1; + // symbol für grid ansicht + temp_normal_grid_inactive = Theme.grid_inactive; + temp_normal_grid_active = Theme.grid_active; + + apps_row = 3; + apps_numers = Options.apps * apps_row; + } + else if(Settings.view == 2) + { + temp_apps_btn = Theme.apps_grid; + temp_apps_btnOver = Theme.apps_grid_hover; + + // symbol für pc ansicht + temp_normal_grid_inactive = Theme.grid_inactive; + temp_normal_grid_active = Theme.grid_active; + + apps_row = 5; + apps_numers = 8 * apps_row; + // gesamt_apps = apps_numers; + + LogoHomebrewFilterImg.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); + LogoHomebrewFilterImg.SetPosition(45, -15); + + ownerTxt.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); + ownerTxt.SetPosition(-35, -20); } - // sd / usb / dvd Ansicht + // sd / usb ansicht if(Settings.device == "sd1") { temp_sd_usb_active = Theme.sd_active; @@ -102,16 +172,6 @@ int MenuMain() temp_sd_usb_active = Theme.sd_usb_active; temp_sd_usb_inactive = Theme.sd_usb_inactive; } - else if(Settings.device == "dvd") - { - temp_sd_usb_active = Theme.dvd_active; - temp_sd_usb_inactive = Theme.dvd_inactive; - } - else if(Settings.device == "all") - { - temp_sd_usb_active = Theme.all_active; - temp_sd_usb_inactive = Theme.all_inactive; - } // wii / gc ansicht if(Settings.system == 1) @@ -130,54 +190,11 @@ int MenuMain() temp_wii_gc_inactive = Theme.wii_gc_inactive; } - // Seite der zuletzt gestarteten app - if(Settings.last_app_pos != -1) - { - Settings.current_page = Settings.last_app_pos/apps_numers +1; - app_pos = Settings.last_app_pos; - Settings.last_app_pos = -1; - } + /************************************************************************ + * bilder und buttons + ***********************************************************************/ - if(Settings.unassigned) - { - vechomebrew_list_choice = vechomebrew_list_unassigned; - // Kategoriename - Settings.category_name = tr(Settings.category_name_all); - Settings.category_name += " - "; - Settings.category_name += tr("unassigned"); - } - else - { - // Kategorie Alle nur anzeigen, wenn aktiviert oder keine andere vorhanden ist - if(!Options.show_all && Settings.current_category == 0 && AvailableCategory.categories.size() -1 > 0) - Settings.current_category++; - - vechomebrew_list_choice = vechomebrew_list_category[Settings.current_category]; - // Kategoriename - Settings.category_name = AvailableCategory.categories[Settings.current_category]; - } - - GuiText categoryTxt(Settings.category_name.c_str(), 28, (GXColor){Theme.category_1, Theme.category_2, Theme.category_3, 255}); - categoryTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - categoryTxt.SetPosition(0,30); - - GuiButton categoryBtn(categoryTxt.GetTextWidth(), 28); - categoryBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - categoryBtn.SetPosition(0, 30); - categoryBtn.SetTrigger(&trigA); - categoryBtn.SetTrigger(&trigB); - - GuiImageData LogoHomebrewFilterImgData(LogoHomebrewFilter_png); - GuiImage LogoHomebrewFilterImg(&LogoHomebrewFilterImgData); - LogoHomebrewFilterImg.SetAlignment(ALIGN_LEFT, ALIGN_TOP); - LogoHomebrewFilterImg.SetPosition(30, 420); - LogoHomebrewFilterImg.SetScale(0.65); - - GuiText ownerTxt("Nano", 18, (GXColor){Theme.owner_1, Theme.owner_2, Theme.owner_3, 255}); - ownerTxt.SetAlignment(ALIGN_RIGHT, ALIGN_TOP); - ownerTxt.SetPosition(-35,430); - - // button data + // image data GuiImageData apps_next(Theme.apps_next); GuiImageData apps_next_hover(Theme.apps_next_hover); GuiImageData apps_previous(Theme.apps_previous); @@ -196,16 +213,18 @@ int MenuMain() GuiImageData wii_gc_BtnImgDataOver(temp_wii_gc_active); GuiImageData power_BtnImgData(Theme.power_inactive); GuiImageData power_BtnImgDataOver(Theme.power_active); - GuiImageData loader_BtnImgData(Theme.loader_inactive); - GuiImageData loader_BtnImgDataOver(Theme.loader_active); GuiImageData settings_BtnImgData(Theme.settings_inactive); GuiImageData settings_BtnImgDataOver(Theme.settings_active); GuiImageData normal_grid_BtnImgData(temp_normal_grid_inactive); GuiImageData normal_grid_BtnImgDataOver(temp_normal_grid_active); GuiImageData network_BtnImgData(Theme.network_inactive); GuiImageData network_BtnImgDataOver(Theme.network_active); + GuiImageData start_BtnImgData(Theme.button_tiny); + GuiImageData start_BtnImgDataOver(Theme.button_tiny_focus); + GuiImageData bar_ImgData(Theme.bar); + GuiImageData desktop_ImgData(Theme.desktop); - // button + // image GuiImage rightBtnImg(&apps_next); GuiImage leftBtnImg(&apps_previous); GuiImage plusBtnImg(&apps_plus); @@ -214,15 +233,17 @@ int MenuMain() GuiImage sd_usb_BtnImg(&sd_usb_BtnImgData); GuiImage wii_gc_BtnImg(&wii_gc_BtnImgData); GuiImage power_BtnImg(&power_BtnImgData); - GuiImage loader_BtnImg(&loader_BtnImgData); GuiImage settings_BtnImg(&settings_BtnImgData); GuiImage normal_grid_BtnImg(&normal_grid_BtnImgData); GuiImage network_BtnImg(&network_BtnImgData); - GuiImage * appsBtnImg[vechomebrew_list_choice.size()]; - for(int i=0; i < (signed)vechomebrew_list_choice.size(); i++) - appsBtnImg[i] = new GuiImage(&apps_btn); + GuiImage start_BtnImg(&start_BtnImgData); + GuiImage bar_Img(&bar_ImgData); + GuiImage desktop_Img(&desktop_ImgData); + GuiImage * appsBtnImg[gesamt_apps]; + for(int i=0; i < gesamt_apps; i++) + appsBtnImg[i] = new GuiImage(&apps_btn); - // button over + // image over GuiImage rightBtnImgOver(&apps_next_hover); GuiImage leftBtnImgOver(&apps_previous_hover); GuiImage plusBtnImgOver(&apps_plus_hover); @@ -231,14 +252,17 @@ int MenuMain() GuiImage sd_usb_BtnImgOver(&sd_usb_BtnImgDataOver); GuiImage wii_gc_BtnImgOver(&wii_gc_BtnImgDataOver); GuiImage power_BtnImgOver(&power_BtnImgDataOver); - GuiImage loader_BtnImgOver(&loader_BtnImgDataOver); GuiImage settings_BtnImgOver(&settings_BtnImgDataOver); GuiImage normal_grid_BtnImgOver(&normal_grid_BtnImgDataOver); GuiImage network_BtnImgOver(&network_BtnImgDataOver); - GuiImage * appsBtnImgOver[vechomebrew_list_choice.size()]; - for(int i=0; i < (signed)vechomebrew_list_choice.size(); i++) - appsBtnImgOver[i] = new GuiImage(&apps_btnOver); + GuiImage start_BtnImgOver(&start_BtnImgData); + GuiImage * appsBtnImgOver[gesamt_apps]; + for(int i=0; i < gesamt_apps; i++) + appsBtnImgOver[i] = new GuiImage(&apps_btnOver); + /************************************************************************ + * Buttons für seite und kategorie + ***********************************************************************/ GuiButton rightBtn(apps_next.GetWidth(), apps_next.GetHeight()); rightBtn.SetAlignment(ALIGN_RIGHT, ALIGN_TOP); rightBtn.SetPosition(-30, 175); @@ -300,9 +324,9 @@ int MenuMain() // normal / grid ansicht GuiButton normal_grid_Btn(normal_grid_BtnImgData.GetWidth(), normal_grid_BtnImgData.GetHeight()); normal_grid_Btn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - normal_grid_Btn.SetPosition(-25, 355); + normal_grid_Btn.SetPosition(0, 355); if(Options.apps == 5) - normal_grid_Btn.SetPosition(-25, 375); + normal_grid_Btn.SetPosition(0, 375); normal_grid_Btn.SetImage(&normal_grid_BtnImg); normal_grid_Btn.SetImageOver(&normal_grid_BtnImgOver); normal_grid_Btn.SetTrigger(&trigA); @@ -311,25 +335,14 @@ int MenuMain() // settings GuiButton settings_Btn(settings_BtnImgData.GetWidth(), settings_BtnImgData.GetHeight()); settings_Btn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - settings_Btn.SetPosition(25, 355); + settings_Btn.SetPosition(135, 355); if(Options.apps == 5) - settings_Btn.SetPosition(25, 375); + settings_Btn.SetPosition(135, 375); settings_Btn.SetImage(&settings_BtnImg); settings_Btn.SetImageOver(&settings_BtnImgOver); settings_Btn.SetTrigger(&trigA); settings_Btn.SetEffectGrow(); - // loader - GuiButton loader_Btn(loader_BtnImgData.GetWidth(), loader_BtnImgData.GetHeight()); - loader_Btn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - loader_Btn.SetPosition(135, 355); - if(Options.apps == 5) - loader_Btn.SetPosition(135, 375); - loader_Btn.SetImage(&loader_BtnImg); - loader_Btn.SetImageOver(&loader_BtnImgOver); - loader_Btn.SetTrigger(&trigA); - loader_Btn.SetEffectGrow(); - // power GuiButton power_Btn(power_BtnImgData.GetWidth(), power_BtnImgData.GetHeight()); power_Btn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); @@ -355,30 +368,58 @@ int MenuMain() network_Btn.SetTrigger(&trigA); network_Btn.SetEffectGrow(); - // alle button der kategorie erstellen - GuiWindow Apps(screenwidth, screenheight); - GuiButton * AppsBtn[vechomebrew_list_choice.size()]; + // pc ansicht + GuiButton start_Btn(start_BtnImgData.GetWidth(), start_BtnImgData.GetHeight()); + start_Btn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); + start_Btn.SetPosition(6, -6); + start_Btn.SetImage(&start_BtnImg); + start_Btn.SetImageOver(&start_BtnImgOver); + start_Btn.SetTrigger(&trigA); + start_Btn.SetEffectGrow(); +// start_Btn.SetScale(0.75); + bar_Img.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); +// desktop_Img.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); + // alle button der kategorie erstellen + GuiButton * AppsBtn[gesamt_apps]; + + // Seite der zuletzt gestarteten app + if(Settings.last_app_pos != -1) + { + Settings.current_page = Settings.last_app_pos/apps_numers +1; + app_pos = Settings.last_app_pos; + Settings.last_app_pos = -1; + } + + // start position der apps buttons int x = screenwidth / 2 - (apps_btn.GetWidth() * apps_row) / 2; int y = 70; if(Options.apps == 5) y = 55; + if(Settings.view == 2) + { + x = screenwidth / 2 - (apps_btn.GetWidth() * apps_row) / 2 +50; + y = 4; + } + int app_grid = 0; - // position der apps + // position der apps fürs verschieben speichern vector pos_x; vector pos_y; // auflisten der apps int anzahl_pro_seite = 0; - for(int i=0; i < (signed)vechomebrew_list_choice.size(); i++) + for(int i=0; i < gesamt_apps; i++) { + AppsBtn[i] = new GuiButton(apps_btn.GetWidth(), apps_btn.GetHeight()); + if(anzahl_pro_seite == apps_numers) // Apps pro Seite { y = 70; if(Options.apps == 5) y = 55; - anzahl_pro_seite=1; + anzahl_pro_seite = 1; Settings.total_page++; } else @@ -387,7 +428,7 @@ int MenuMain() // device symbol anzeigen GuiImage * viewdevice = NULL; - if((Options.device_icon == 1 || Options.device_icon == 3) && (Settings.device == "sd_usb" || Settings.device == "all")) + if((Options.device_icon == 1 || Options.device_icon == 3) && Settings.device == "sd_usb" && Settings.view != 2) { bool icon = false; if(strncmp(vechomebrew_list_choice[i].foldername.c_str(), "sd", 2) == 0) @@ -400,11 +441,6 @@ int MenuMain() viewdevice = new GuiImage(new GuiImageData(Theme.usb_inactive)); icon = true; } - else if(strncmp(vechomebrew_list_choice[i].foldername.c_str(), "dvd", 3) == 0) - { - viewdevice = new GuiImage (new GuiImageData(Theme.dvd_inactive)); - icon = true; - } if(icon) { @@ -419,21 +455,11 @@ int MenuMain() GuiText * AppsBtnTxt2 = NULL; GuiText * AppsBtnTxt3 = NULL; - // Grid Ansicht - if(Settings.grid) - { - if(vechomebrew_list_choice[i].icon == NULL) - { - AppsBtnTxt1 = new GuiText(vechomebrew_list_choice[i].name.c_str(), 20, (GXColor){Theme.apps_1, Theme.apps_2, Theme.apps_3, 255}); - AppsBtnTxt1->SetMaxWidth(100, SCROLL_HORIZONTAL); - } - viewicon->SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - } // Normale Ansicht - else + if(Settings.view == 0) { AppsBtnTxt1 = new GuiText(vechomebrew_list_choice[i].name.c_str(), 20, (GXColor){Theme.apps_1, Theme.apps_2, Theme.apps_3, 255}); - AppsBtnTxt2 = new GuiText("____________________________________________________", 24, (GXColor){Theme.apps_1, Theme.apps_2, Theme.apps_3, 100}); + AppsBtnTxt2 = new GuiText("....................................................", 24, (GXColor){Theme.apps_1, Theme.apps_2, Theme.apps_3, 100}); AppsBtnTxt3 = new GuiText(tr(vechomebrew_list_choice[i].info.c_str()), 20, (GXColor){Theme.apps_1, Theme.apps_2, Theme.apps_3, 255}); viewicon->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); @@ -449,7 +475,29 @@ int MenuMain() AppsBtnTxt3->SetMaxWidth(265, DOTTED); } - AppsBtn[i] = new GuiButton(apps_btn.GetWidth(), apps_btn.GetHeight()); + // Grid Ansicht + else if(Settings.view == 1) + { + if(vechomebrew_list_choice[i].icon == NULL) + { + AppsBtnTxt1 = new GuiText(vechomebrew_list_choice[i].name.c_str(), 20, (GXColor){Theme.apps_1, Theme.apps_2, Theme.apps_3, 255}); + AppsBtnTxt1->SetMaxWidth(100, SCROLL_HORIZONTAL); + } + viewicon->SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + } + + // PC Ansicht + else if(Settings.view == 2) + { + if(vechomebrew_list_choice[i].icon == NULL) + { + AppsBtnTxt1 = new GuiText(vechomebrew_list_choice[i].name.c_str(), 20, (GXColor){Theme.apps_1, Theme.apps_2, Theme.apps_3, 255}); + AppsBtnTxt1->SetMaxWidth(75, SCROLL_HORIZONTAL); + } + viewicon->SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + AppsBtn[i]->SetScale(0.75); + } + AppsBtn[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); AppsBtn[i]->SetPosition(x, y); AppsBtn[i]->SetLabel(AppsBtnTxt1, 0); @@ -472,18 +520,33 @@ int MenuMain() app_grid++; - // wenn zeile voll, zur nächsten gehen - if(app_grid == apps_row) + if(Settings.view == 2) { - x = screenwidth / 2 - (apps_btn.GetWidth() * apps_row) / 2; - if(Options.apps == 4) - y += 70; - else if(Options.apps == 5) - y += 63; - app_grid = 0; + // wenn zeile voll, zur nächsten gehen + if(app_grid == apps_numers / apps_row) + { + y = 4; + x += 120; + app_grid = 0; + } + else + y += 50; } else - x += 144; + { + // wenn zeile voll, zur nächsten gehen + if(app_grid == apps_row) + { + x = screenwidth / 2 - (apps_btn.GetWidth() * apps_row) / 2; + if(Options.apps == 4) + y += 70; + else if(Options.apps == 5) + y += 63; + app_grid = 0; + } + else + x += 144; + } } if(Settings.current_page > Settings.total_page) @@ -492,7 +555,7 @@ int MenuMain() // wenn nicht seite 1 if(Settings.current_page != 1) { - for(int i=0; i < (signed)vechomebrew_list_choice.size(); i++) + for(int i=0; i < gesamt_apps; i++) { AppsBtn[i]->SetVisible(false); AppsBtn[i]->SetSelectable(false); @@ -500,7 +563,7 @@ int MenuMain() for(int i = 0; i < apps_numers; i++) { - if((Settings.current_page-1)*apps_numers+i < (signed)vechomebrew_list_choice.size()) + if((Settings.current_page-1)*apps_numers+i < gesamt_apps) { AppsBtn[(Settings.current_page-1)*apps_numers+i]->SetVisible(true); AppsBtn[(Settings.current_page-1)*apps_numers+i]->SetSelectable(true); @@ -545,6 +608,8 @@ int MenuMain() newRevTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); newRevTxt.SetPosition(0,415); + // Apps Anzeigefeld + GuiWindow Apps(screenwidth, screenheight); if(Options.slide_effect > 0 && temp_slide) Apps.SetEffect(Settings.Apps_from | EFFECT_SLIDE_IN, Options.slide_effect * 50); @@ -552,28 +617,38 @@ int MenuMain() temp_slide = true; HaltGui(); - Apps.Append(&categoryTxt); - for(int i=0; i < (signed)vechomebrew_list_choice.size(); i++) + for(int i=0; i < gesamt_apps; i++) Apps.Append(AppsBtn[i]); Apps.Append(AppsBtnFree); Apps.Append(AppsBtnMove); GuiWindow w(screenwidth, screenheight); - w.Append(&categoryBtn); + if(Settings.view == 1 || Settings.view == 0) + { + Apps.Append(&categoryTxt); + w.Append(&categoryBtn); + w.Append(&leftBtn); + w.Append(&rightBtn); + w.Append(&minusBtn); + w.Append(&plusBtn); + w.Append(&sd_usb_Btn); + w.Append(&wii_gc_Btn); + w.Append(&normal_grid_Btn); + w.Append(&settings_Btn); + w.Append(&power_Btn); + w.Append(&network_Btn); + w.Append(pageTxt); + } + else if(Settings.view == 2) + { + w.Append(&desktop_Img); + w.Append(&bar_Img); + w.Append(&start_Btn); + } + w.Append(&LogoHomebrewFilterImg); w.Append(&ownerTxt); - w.Append(&leftBtn); - w.Append(&rightBtn); - w.Append(&minusBtn); - w.Append(&plusBtn); - w.Append(&sd_usb_Btn); - w.Append(&wii_gc_Btn); - w.Append(&normal_grid_Btn); - w.Append(&settings_Btn); - w.Append(&power_Btn); - w.Append(&loader_Btn); - w.Append(&network_Btn); - w.Append(pageTxt); + if(CheckRev() && Options.newrevtext) w.Append(&newRevTxt); @@ -586,8 +661,7 @@ int MenuMain() // letzte app markieren if(app_pos != -1) { - // mainWindow->ChangeFocus(&Apps); - for(int i=0; i < (signed)vechomebrew_list_choice.size(); i++) + for(int i=0; i < gesamt_apps; i++) { if(i == app_pos) AppsBtn[i]->SetState(STATE_SELECTED); @@ -661,15 +735,25 @@ int MenuMain() menu = MENU_EXIT; // ansicht wechseln - if(((WPAD_ButtonsDown(0) & WPAD_BUTTON_2) &! (WPAD_ButtonsDown(0) & WPAD_BUTTON_1)) || normal_grid_Btn.GetState() == STATE_CLICKED) + if(normal_grid_Btn.GetState() == STATE_CLICKED) { - Settings.current_page = 1; - if(Settings.grid) - Settings.grid = false; - else - Settings.grid = true; + int choice = viewPrompt(); - menu = MENU_MAIN; + if(choice == 0) + Settings.view = 0; + else if(choice == 1) + Settings.view = 1; + else if(choice == 2) + Settings.view = 2; + + if(choice != -1) + { + // check_device(); + Settings.current_page = 1; + menu = MENU_MAIN; + } + else + normal_grid_Btn.ResetState(); } // wenn A gedrückt @@ -687,9 +771,7 @@ int MenuMain() } // SD, USB - else if(sd_usb_Btn.GetState() == STATE_CLICKED || Settings.sd_insert == -1 || Settings.sd_insert == 2 - || Settings.usb_insert == -1 || Settings.usb_insert == 2 - || Settings.dvd_insert == -1 || Settings.dvd_insert == 2) + else if(sd_usb_Btn.GetState() == STATE_CLICKED || Settings.sd_insert == -1 || Settings.sd_insert == 2 || Settings.usb_insert == -1 || Settings.usb_insert == 2) { int device = -1; if(sd_usb_Btn.GetState() == STATE_CLICKED) @@ -701,14 +783,8 @@ int MenuMain() Settings.device = "usb1"; else if(device == 3) Settings.device = "sd_usb"; - else if(device == 4) - Settings.device = "dvd"; - else if(device == 5) - Settings.device = "all"; - if(device != -1 || Settings.sd_insert == -1 || Settings.sd_insert == 2 - || Settings.usb_insert == -1 || Settings.usb_insert == 2 - || Settings.dvd_insert == -1 || Settings.dvd_insert == 2) + if(device != -1 || Settings.sd_insert == -1 || Settings.sd_insert == 2 || Settings.usb_insert == -1 || Settings.usb_insert == 2) { check_device(); Settings.current_page = 1; @@ -748,14 +824,6 @@ int MenuMain() menu = MENU_EXIT; } - // Loader button - else if(loader_Btn.GetState() == STATE_CLICKED || WPAD_ButtonsDown(0) & (WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME) || PAD_ButtonsDown(0) & PAD_BUTTON_START) - { - loader_Btn.ResetState(); - if(loaderPrompt() == MENU_EXIT) - menu = MENU_EXIT; - } - // Netzwerk button else if(network_Btn.GetState() == STATE_CLICKED) { @@ -763,206 +831,218 @@ int MenuMain() ResumeNetworkThread(); } - // eine Seite weiter bzw zurück - else if((WPAD_ButtonsDown(0) & (WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT) && !Options.navigation) || - (WPAD_ButtonsDown(0) & (WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS) && Options.navigation) || - PAD_ButtonsDown(0) & PAD_BUTTON_RIGHT || rightBtn.GetState() == STATE_CLICKED || - (WPAD_ButtonsDown(0) & (WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT) && !Options.navigation) || - (WPAD_ButtonsDown(0) & (WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS) && Options.navigation) || - PAD_ButtonsDown(0) & PAD_BUTTON_LEFT || leftBtn.GetState() == STATE_CLICKED) + if(Settings.view != 2) { - // Abbrechen Seite zurück + // eine Seite weiter bzw zurück if((WPAD_ButtonsDown(0) & (WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT) && !Options.navigation) || - (WPAD_ButtonsDown(0) & (WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS) && Options.navigation) || - PAD_ButtonsDown(0) & PAD_BUTTON_RIGHT || rightBtn.GetState() == STATE_CLICKED) - previous_page = false; - - // Abbrechen Seite weiter - if((WPAD_ButtonsDown(0) & (WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT) && !Options.navigation) || - (WPAD_ButtonsDown(0) & (WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS) && Options.navigation) || - PAD_ButtonsDown(0) & PAD_BUTTON_LEFT || leftBtn.GetState() == STATE_CLICKED) - next_page = false; - - int page = Settings.current_page; - bool change = false; - if(next_page || rightBtn.GetState() == STATE_CLICKED || (WPAD_ButtonsDown(0) & (WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS) && Options.navigation)) + (WPAD_ButtonsDown(0) & (WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS) && Options.navigation) || + PAD_ButtonsDown(0) & PAD_BUTTON_RIGHT || rightBtn.GetState() == STATE_CLICKED || + (WPAD_ButtonsDown(0) & (WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT) && !Options.navigation) || + (WPAD_ButtonsDown(0) & (WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS) && Options.navigation) || + PAD_ButtonsDown(0) & PAD_BUTTON_LEFT || leftBtn.GetState() == STATE_CLICKED) { - rightBtn.ResetState(); - Settings.current_page++; - if(Settings.current_page > Settings.total_page) - Settings.current_page = 1; + // Abbrechen Seite zurück + if((WPAD_ButtonsDown(0) & (WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT) && !Options.navigation) || + (WPAD_ButtonsDown(0) & (WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS) && Options.navigation) || + PAD_ButtonsDown(0) & PAD_BUTTON_RIGHT || rightBtn.GetState() == STATE_CLICKED) + previous_page = false; - Settings.Apps_from = EFFECT_SLIDE_RIGHT; - Settings.Apps_to = EFFECT_SLIDE_LEFT; + // Abbrechen Seite weiter + if((WPAD_ButtonsDown(0) & (WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT) && !Options.navigation) || + (WPAD_ButtonsDown(0) & (WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS) && Options.navigation) || + PAD_ButtonsDown(0) & PAD_BUTTON_LEFT || leftBtn.GetState() == STATE_CLICKED) + next_page = false; - next_page = false; - - if(Settings.total_page != 1) - change = true; - } - - if(previous_page || leftBtn.GetState() == STATE_CLICKED || (WPAD_ButtonsDown(0) & (WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS) && Options.navigation)) - { - leftBtn.ResetState(); - Settings.current_page--; - if(Settings.current_page == 0) - Settings.current_page = Settings.total_page; - - Settings.Apps_from = EFFECT_SLIDE_LEFT; - Settings.Apps_to = EFFECT_SLIDE_RIGHT; - - previous_page = false; - if(Settings.total_page != 1) - change = true; - } - - if(change) - { - HaltResumeGui(); // -> um nur eine Seite zu blättern - - // alten apps ausblenden - if(Options.slide_effect > 0 && Settings.Apps_to != 0) + int page = Settings.current_page; + bool change = false; + if(next_page || rightBtn.GetState() == STATE_CLICKED || (WPAD_ButtonsDown(0) & (WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS) && Options.navigation)) { - Apps.SetEffect(Settings.Apps_to | EFFECT_SLIDE_OUT, Options.slide_effect * 50); - while(Apps.GetEffect() > 0) - usleep(100); + rightBtn.ResetState(); + Settings.current_page++; + if(Settings.current_page > Settings.total_page) + Settings.current_page = 1; + + Settings.Apps_from = EFFECT_SLIDE_RIGHT; + Settings.Apps_to = EFFECT_SLIDE_LEFT; + + next_page = false; + + if(Settings.total_page != 1) + change = true; } - for(int i = 0; i < apps_numers; i++) + if(previous_page || leftBtn.GetState() == STATE_CLICKED || (WPAD_ButtonsDown(0) & (WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS) && Options.navigation)) { - // vorherige seite ausblenden - if((page-1)*apps_numers+i < (signed)vechomebrew_list_choice.size()) - { - AppsBtn[(page-1)*apps_numers+i]->SetVisible(false); - AppsBtn[(page-1)*apps_numers+i]->SetSelectable(false); - AppsBtn[(page-1)*apps_numers+i]->ResetState(); - } - // aktuelle seite einblenden - if((Settings.current_page-1)*apps_numers+i < (signed)vechomebrew_list_choice.size()) - { - AppsBtn[(Settings.current_page-1)*apps_numers+i]->SetVisible(true); - AppsBtn[(Settings.current_page-1)*apps_numers+i]->SetSelectable(true); - AppsBtn[(Settings.current_page-1)*apps_numers+i]->ResetState(); - } - // zu verschiebene app ausblenden und leeres feld einblenden - if(grab && (Settings.current_page-1)*apps_numers+i == move.nr) - { - AppsBtn[move.nr]->SetVisible(false); - AppsBtn[move.nr]->SetSelectable(false); - } + leftBtn.ResetState(); + Settings.current_page--; + if(Settings.current_page == 0) + Settings.current_page = Settings.total_page; + + Settings.Apps_from = EFFECT_SLIDE_LEFT; + Settings.Apps_to = EFFECT_SLIDE_RIGHT; + + previous_page = false; + if(Settings.total_page != 1) + change = true; } - // felder in ursprungsposition setzen - for(int i=0; i < (signed)vechomebrew_list_choice.size(); i++) - AppsBtn[i]->SetPosition(pos_x[i], pos_y[i]); + if(change) + { + HaltResumeGui(); // -> um nur eine Seite zu blättern - // beim seitenwechsel, leeres feld positionieren - if(Settings.current_page == move.page) - AppsBtnFree->SetPosition(pos_x[move.nr], pos_y[move.nr]); - else - AppsBtnFree->SetPosition(-1000, -1000); + // alten apps ausblenden + if(Options.slide_effect > 0 && Settings.Apps_to != 0) + { + Apps.SetEffect(Settings.Apps_to | EFFECT_SLIDE_OUT, Options.slide_effect * 50); + while(Apps.GetEffect() > 0) + usleep(100); + } - // app 1 auf der aktuellen seite markieren, außer beim verschieben - if(!grab) - AppsBtn[(Settings.current_page-1)*apps_numers]->SetState(STATE_SELECTED); + for(int i = 0; i < apps_numers; i++) + { + // vorherige seite ausblenden + if((page-1)*apps_numers+i < gesamt_apps) + { + AppsBtn[(page-1)*apps_numers+i]->SetVisible(false); + AppsBtn[(page-1)*apps_numers+i]->SetSelectable(false); + AppsBtn[(page-1)*apps_numers+i]->ResetState(); + } + // aktuelle seite einblenden + if((Settings.current_page-1)*apps_numers+i < gesamt_apps) + { + AppsBtn[(Settings.current_page-1)*apps_numers+i]->SetVisible(true); + AppsBtn[(Settings.current_page-1)*apps_numers+i]->SetSelectable(true); + AppsBtn[(Settings.current_page-1)*apps_numers+i]->ResetState(); + } + // zu verschiebene app ausblenden und leeres feld einblenden + if(grab && (Settings.current_page-1)*apps_numers+i == move.nr) + { + AppsBtn[move.nr]->SetVisible(false); + AppsBtn[move.nr]->SetSelectable(false); + } + } - // neue apps einblenden - if(Options.slide_effect > 0) - Apps.SetEffect(Settings.Apps_from | EFFECT_SLIDE_IN, Options.slide_effect * 50); + // felder in ursprungsposition setzen + for(int i=0; i < gesamt_apps; i++) + AppsBtn[i]->SetPosition(pos_x[i], pos_y[i]); - char buffer[100]; - sprintf(buffer, tr("Page %i of %i"), Settings.current_page, Settings.total_page); - pageTxt->SetText(buffer); + // beim seitenwechsel, leeres feld positionieren + if(Settings.current_page == move.page) + AppsBtnFree->SetPosition(pos_x[move.nr], pos_y[move.nr]); + else + AppsBtnFree->SetPosition(-1000, -1000); + + // app 1 auf der aktuellen seite markieren, außer beim verschieben + if(!grab) + AppsBtn[(Settings.current_page-1)*apps_numers]->SetState(STATE_SELECTED); + + // neue apps einblenden + if(Options.slide_effect > 0) + Apps.SetEffect(Settings.Apps_from | EFFECT_SLIDE_IN, Options.slide_effect * 50); + + char buffer[100]; + sprintf(buffer, tr("Page %i of %i"), Settings.current_page, Settings.total_page); + pageTxt->SetText(buffer); + } + + + /* // eine Seite weiter + if((WPAD_ButtonsDown(0) & (WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT) && !Options.navigation) || + (WPAD_ButtonsDown(0) & (WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS) && Options.navigation) || + PAD_ButtonsDown(0) & PAD_BUTTON_RIGHT || rightBtn.GetState() == STATE_CLICKED) + { + for(int i = 1; i < apps_numers/apps_row +1; i++) + { + if(Apps.GetSelected() == i * apps_row -1 + (Settings.current_page -1) * apps_numers || Apps.GetSelected() == gesamt_apps -1) + { + next_page = true; + break; + } + } + } + */ } + // eine Kategorie weiter + else if((WPAD_ButtonsDown(0) & (WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS) && !Options.navigation) || + (WPAD_ButtonsDown(0) & (WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT) && Options.navigation) || + PAD_ButtonsDown(0) & PAD_TRIGGER_R || plusBtn.GetState() == STATE_CLICKED) + { + Next_Category(); + menu = MENU_MAIN; + } + + // eine Kategorie zurück + else if((WPAD_ButtonsDown(0) & (WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS) && !Options.navigation) || + (WPAD_ButtonsDown(0) & (WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT) && Options.navigation) || + PAD_ButtonsDown(0) & PAD_TRIGGER_L || minusBtn.GetState() == STATE_CLICKED) + { + Previous_Category(); + menu = MENU_MAIN; + } + + // Kategorie umbenennen / verschieben + else if(categoryBtn.GetState() == STATE_CLICKED) + { + categoryBtn.ResetState(); + Category_rename_move(button); + temp_slide = false; + menu = MENU_MAIN; + } + + for(int i = 1; i < apps_numers/apps_row +1; i++) + { + if(Apps.GetSelected() == (i -1) * apps_row + (Settings.current_page -1) * apps_numers) + previous_page = true; + + if(Apps.GetSelected() == i * apps_row -1 + (Settings.current_page -1) * apps_numers || Apps.GetSelected() == gesamt_apps -1) + next_page = true; } } - - // eine Kategorie weiter - else if((WPAD_ButtonsDown(0) & (WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS) && !Options.navigation) || - (WPAD_ButtonsDown(0) & (WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT) && Options.navigation) || - PAD_ButtonsDown(0) & PAD_TRIGGER_R || plusBtn.GetState() == STATE_CLICKED) + else { - Next_Category(); - menu = MENU_MAIN; - } + if(start_Btn.GetState() == STATE_CLICKED) + { + start_Btn.ResetState(); + // int CategoryNr, AppNr; + // int choice = startmenuPrompt(CategoryNr, AppNr); + int choice = startmenu2Prompt(); - // eine Kategorie zurück - else if((WPAD_ButtonsDown(0) & (WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS) && !Options.navigation) || - (WPAD_ButtonsDown(0) & (WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT) && Options.navigation) || - PAD_ButtonsDown(0) & PAD_TRIGGER_L || minusBtn.GetState() == STATE_CLICKED) - { - Previous_Category(); - menu = MENU_MAIN; - } + char buffer[20]; + sprintf(buffer, "%i", choice); + debug(buffer); - // Kategorie umbenennen / verschieben - else if(categoryBtn.GetState() == STATE_CLICKED) - { - categoryBtn.ResetState(); - Category_rename_move(button); - temp_slide = false; - menu = MENU_MAIN; - } + if(choice == -1) + normal_grid_Btn.SetState(STATE_CLICKED); + else if(choice == -2) + settings_Btn.SetState(STATE_CLICKED); + else if(choice == -3) + power_Btn.SetState(STATE_CLICKED); + else if(choice == 1) + { + // char buffer[20]; + // sprintf(buffer, "%i %i", CategoryNr, AppNr); + // debug(buffer); - // für die grid ansicht, navigation der einzelnen zellen - previous_page = false; - next_page = false; - for(int i = 0; i< apps_numers/apps_row; i++) - { - if(Apps.GetSelected() == i * apps_row + 1 + (Settings.current_page -1) * apps_numers) - previous_page = true; - - if(Apps.GetSelected() == (i+1) * apps_row + (Settings.current_page -1) * apps_numers || Apps.GetSelected() == (signed)vechomebrew_list_choice.size()) - next_page = true; + // menu = ChoiceAppInfo(vechomebrew_list_category[CategoryNr], AppNr); + temp_slide = false; + } + // normal_grid_Btn.SetState(STATE_CLICKED); + } } // list apps - for(int i = (Settings.current_page-1)*apps_numers; i < Settings.current_page*apps_numers && i < (signed)vechomebrew_list_choice.size(); i++) + for(int i = (Settings.current_page-1)*apps_numers; i < Settings.current_page*apps_numers && i < gesamt_apps; i++) { // show apps info if(AppsBtn[i]->GetState() == STATE_CLICKED && button == "A") { + debug("test"); AppsBtn[i]->SetState(STATE_SELECTED); - again: - int choice; - if(Options.quick_start == 0) - choice = AppInfo(vechomebrew_list_choice[i].name.c_str(), vechomebrew_list_choice[i].foldername, vechomebrew_list_choice[i].icon); - else - choice = 1; - - if(choice == 1) // App starten - { - Settings.forwarder_path = vechomebrew_list_choice[i].pathboot; - Settings.forwarder_arg = vechomebrew_list_choice[i].arg.c_str(); - boothomebrew = true; - menu = MENU_EXIT; - } - if(choice == 2) // App Einfügen - { - string app_in_kategorie = AddApp(vechomebrew_list_choice[i].name.c_str()); - if( app_in_kategorie != "NULL" ) - { - AppEinfuegen(app_in_kategorie, vechomebrew_list_choice[i].foldername.c_str()); - copy_app_in_unassigned(); - temp_slide = false; - menu = MENU_MAIN; - } - } - if(choice == 3 || choice == 4) - { - AppEraseDelate(choice, vechomebrew_list_choice[i].name.c_str(), vechomebrew_list_choice[i].foldername.c_str()); - temp_slide = false; - menu = MENU_MAIN; - } - if(choice == 5) - { - MetaEdit(vechomebrew_list_choice[i].foldername); - temp_slide = false; - goto again; - } + menu = ChoiceAppInfo(vechomebrew_list_choice, i); + temp_slide = false; mainWindow->ChangeFocus(&Apps); - for(int x=0; x < (signed)vechomebrew_list_choice.size(); x++) + for(int x=0; x < gesamt_apps; x++) { if(x == i) AppsBtn[x]->SetState(STATE_SELECTED); @@ -987,7 +1067,7 @@ int MenuMain() ViewIconMove = new GuiImage(icon_dataMove); // Grid Ansicht - if(Settings.grid) + if(Settings.view == 1) { AppsBtnTxtMove1->SetText(""); if(vechomebrew_list_choice[i].icon == NULL) @@ -1061,7 +1141,7 @@ int MenuMain() } AppsBtnFree->SetPosition(pos_x[i], pos_y[i]); - for(i = 0; i < apps_numers && (Settings.current_page-1)*apps_numers+i < (signed)vechomebrew_list_choice.size(); i++) + for(i = 0; i < apps_numers && (Settings.current_page-1)*apps_numers+i < gesamt_apps; i++) { int x = (Settings.current_page-1)*apps_numers+i; // buttons 1 kleiner button 2 @@ -1137,7 +1217,7 @@ int MenuMain() else { // felder in ursprungsposition setzen - for(int i=0; i < (signed)vechomebrew_list_choice.size(); i++) + for(int i=0; i < gesamt_apps; i++) AppsBtn[i]->SetPosition(pos_x[i], pos_y[i]); if(Settings.current_page == move.page) AppsBtn[move.nr]->SetVisible(true); @@ -1157,4 +1237,4 @@ int MenuMain() mainWindow->Remove(&Apps); mainWindow->Remove(&w); return menu; -} +} \ No newline at end of file diff --git a/source/Menus/menu_settings_file.cpp b/source/Menus/menu_settings_file.cpp index 9f9e1d4..08b5021 100644 --- a/source/Menus/menu_settings_file.cpp +++ b/source/Menus/menu_settings_file.cpp @@ -39,11 +39,11 @@ int MenuSettingsFile() int i = 0; bool firstRun = true; int focus = 0; - - int last_category = Options.last_category; - bool quick_start = Options.quick_start; - bool show_all = Options.show_all; - int device_icon = Options.device_icon; + + int last_category = Options.last_category; + bool quick_start = Options.quick_start; + bool show_all = Options.show_all; + int device_icon = Options.device_icon; bool childlock; if(strcasecmp(Settings.code,"NULL") == 0 ) childlock = 0; @@ -56,17 +56,17 @@ int MenuSettingsFile() device_dat = "SD"; else if(Settings.device_dat == "usb1") device_dat = "USB"; - + OptionList options; sprintf(options.name[i++], tr("Theme")); sprintf(options.name[i++], tr("Language")); sprintf(options.name[i++], tr("Font")); + sprintf(options.name[i++], tr("Storage Device")); sprintf(options.name[i++], tr("Slide Effect")); sprintf(options.name[i++], tr("Category remember")); sprintf(options.name[i++], tr("Number of Apps")); sprintf(options.name[i++], tr("Quick Start")); sprintf(options.name[i++], tr("Show All")); - sprintf(options.name[i++], tr("Storage Device")); sprintf(options.name[i++], tr("Device icon")); sprintf(options.name[i++], tr("Childlock")); sprintf(options.name[i++], tr("Navigation key exchange")); @@ -115,7 +115,7 @@ int MenuSettingsFile() optionBrowser.SetPosition(0, 108); optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); optionBrowser.SetCol2Position(280); - optionBrowser.Col2Scroll(280); + optionBrowser.Col2Scroll(230); HaltGui(); GuiWindow w(screenwidth, screenheight); @@ -130,7 +130,7 @@ int MenuSettingsFile() while(menu == MENU_NONE) { usleep(100); - + ret = optionBrowser.GetChangedOption(); ret2 = optionBrowser.GetClickedOption(); @@ -146,7 +146,7 @@ int MenuSettingsFile() change = 5; sprintf (options.value[ret], "%i", change); break; - + case CATEGORY_REMEMBER: change = last_category; change++; @@ -154,7 +154,7 @@ int MenuSettingsFile() change = AvailableCategory.categories.size(); last_category = change; break; - + case NUMBER_OF_APPS: change = atoi(options.value[ret]); change++; @@ -162,15 +162,15 @@ int MenuSettingsFile() change = 5; sprintf (options.value[ret], "%i", change); break; - + case QUICK_START: quick_start = 1; break; - + case SHOW_ALL: show_all = 1; break; - + case DEVICE_ICON: change = device_icon; change++; @@ -178,12 +178,12 @@ int MenuSettingsFile() change = 3; device_icon = change; break; - + case STORAGE_DEVICE: device_dat = "USB"; sprintf (options.value[STORAGE_DEVICE], device_dat.c_str()); break; - + case NAVIGATION: navigation = 1; break; @@ -191,7 +191,7 @@ int MenuSettingsFile() HaltResumeGui(); optionBrowser.TriggerUpdate(); } - + if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT) || PAD_ButtonsDown(0) & PAD_BUTTON_LEFT) { change = 0; @@ -204,7 +204,7 @@ int MenuSettingsFile() change = 0; sprintf (options.value[ret], "%i", change); break; - + case CATEGORY_REMEMBER: change = last_category; change--; @@ -212,7 +212,7 @@ int MenuSettingsFile() change = 0; last_category = change; break; - + case NUMBER_OF_APPS: change = atoi(options.value[ret]); change--; @@ -220,15 +220,15 @@ int MenuSettingsFile() change = 4; sprintf (options.value[ret], "%i", change); break; - + case QUICK_START: quick_start = 0; break; - + case SHOW_ALL: show_all = 0; break; - + case DEVICE_ICON: change = device_icon; change--; @@ -236,12 +236,12 @@ int MenuSettingsFile() change = 0; device_icon = change; break; - + case STORAGE_DEVICE: device_dat = "SD"; sprintf (options.value[STORAGE_DEVICE], device_dat.c_str()); break; - + case NAVIGATION: navigation = 0; break; @@ -249,58 +249,58 @@ int MenuSettingsFile() HaltResumeGui(); optionBrowser.TriggerUpdate(); } - + if(ret2 != -1) { // einstellungen temporär speichern /******************************************************************************/ Options.temp_theme = options.value[THEME]; - Options.temp_language = options.value[LANGUAGE]; + Options.temp_language = options.value[LANGUAGE]; Options.temp_font = options.value[FONT]; temp_slide_effect = atoi(options.value[SLIDE_EFFECT]); temp_last_category = last_category; - temp_apps = atoi(options.value[NUMBER_OF_APPS]); + temp_apps = atoi(options.value[NUMBER_OF_APPS]); temp_quick_start = quick_start; temp_show_all = show_all; temp_device_icon = device_icon; temp_device_dat = device_dat; temp_navigation = navigation; /******************************************************************************/ - + // in weitere einstellungen gehen switch (ret2) { case THEME: menu = MENU_SETTINGS_THEME; break; - + case LANGUAGE: menu = MENU_SETTINGS_LANGUAGE; break; - + case FONT: menu = MENU_SETTINGS_FONT; break; - + case CHILDLOCK: menu = MENU_SETTINGS_CHILDLOCK; break; - + case DISPLAY: menu = MENU_SETTINGS_DISPLAY; break; - + case NETWORK: menu = MENU_SETTINGS_NETWORK; break; - + } } - + if(firstRun) { firstRun = false; - + if(Options.temp_last_setting == 1) { sprintf (options.value[THEME], Options.temp_theme.c_str()); @@ -311,11 +311,11 @@ int MenuSettingsFile() sprintf (options.value[STORAGE_DEVICE], temp_device_dat.c_str()); sprintf (options.value[DISPLAY], " "); sprintf (options.value[NETWORK], " "); - - last_category = temp_last_category; - quick_start = temp_quick_start; - show_all = temp_show_all; - device_icon = temp_device_icon; + + last_category = temp_last_category; + quick_start = temp_quick_start; + show_all = temp_show_all; + device_icon = temp_device_icon; if(strcasecmp(Options.temp_code,"NULL") == 0 ) childlock = 0; else @@ -338,27 +338,27 @@ int MenuSettingsFile() if(change != -1) { change = -1; - + if(!last_category) sprintf (options.value[CATEGORY_REMEMBER], tr("last")); else sprintf (options.value[CATEGORY_REMEMBER], AvailableCategory.categories[last_category - 1].c_str()); - + if(!quick_start) sprintf (options.value[QUICK_START], tr("No")); else sprintf (options.value[QUICK_START], tr("Yes")); - + if(!show_all) sprintf (options.value[SHOW_ALL], tr("No")); else sprintf (options.value[SHOW_ALL], tr("Yes")); - + if(!childlock) sprintf (options.value[CHILDLOCK], tr("No")); else sprintf (options.value[CHILDLOCK], tr("Yes")); - + if(device_icon == 0) sprintf (options.value[DEVICE_ICON], tr("Off")); else if(device_icon == 1) @@ -367,15 +367,15 @@ int MenuSettingsFile() sprintf (options.value[DEVICE_ICON], tr("Dialog box")); else if(device_icon == 3) sprintf (options.value[DEVICE_ICON], tr("All")); - + if(!navigation) sprintf (options.value[NAVIGATION], tr("No")); else sprintf (options.value[NAVIGATION], tr("Yes")); - + optionBrowser.TriggerUpdate(); } - + if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B) || PAD_ButtonsDown(0) & PAD_BUTTON_B) { if(focus == 0) @@ -390,7 +390,7 @@ int MenuSettingsFile() } HaltResumeGui(); } - + if(backBtn.GetState() == STATE_CLICKED) { strcpy (Options.temp_code, Settings.code); @@ -398,7 +398,7 @@ int MenuSettingsFile() Options.temp_newrevtext = Options.newrevtext; menu = MENU_SETTINGS; } - + if(saveBtn.GetState() == STATE_CLICKED) { // Theme ändern @@ -407,17 +407,17 @@ int MenuSettingsFile() sprintf (Options.theme, options.value[THEME]); DefaultTheme(); if(stricmp(Options.theme, tr("STANDARD")) != 0) - theme(Settings.device_dat + ":/config/HBF/themes/" + Options.theme + "/"); + theme(Settings.device_dat + ":/config/Homebrew Filter/themes/" + Options.theme + "/"); // Cursor und Hintergrund ändern #ifdef HW_RVL pointer = new GuiImageData(Theme.player_point); #endif - + mainWindow->Remove(bgImg); bgImg = new GuiImage(new GuiImageData(Theme.background)); mainWindow->Append(bgImg); } - + // Schriftart ändern if(stricmp(Options.font, options.value[FONT]) != 0 || GetMenuSettingsFontDL()) { @@ -427,64 +427,64 @@ int MenuSettingsFile() SetFont(); ResumeGui(); } - + strcpy(Settings.code, Options.temp_code); - Options.slide_effect = atoi(options.value[SLIDE_EFFECT]); - Options.last_category = last_category; + Options.slide_effect = atoi(options.value[SLIDE_EFFECT]); + Options.last_category = last_category; Options.apps = atoi(options.value[NUMBER_OF_APPS]); Options.quick_start = quick_start; Options.show_all = show_all; Options.device_icon = device_icon; - device_dat = options.value[STORAGE_DEVICE]; + device_dat = options.value[STORAGE_DEVICE]; Options.navigation = navigation; Options.network = Options.temp_network; Options.newrevtext = Options.temp_newrevtext; - + if(device_dat == "SD") Settings.device_dat = "sd1"; else if(device_dat == "USB") Settings.device_dat = "usb1"; - + // Sprache ändern zum schluss wegen STANDARD if(stricmp(Options.language, options.value[LANGUAGE]) != 0 || GetMenuSettingsLanguageDL()) { sprintf (Options.language, options.value[LANGUAGE]); - + bool theme = 0, language = 0, font = 0; if(stricmp(Options.theme, tr("STANDARD")) == 0) theme = 1; - + if(stricmp(Options.language, tr("STANDARD")) == 0) language = 1; - + if(stricmp(Options.font, tr("STANDARD")) == 0) font = 1; - + /*********************************************************************/ if(stricmp(Options.language, tr("STANDARD")) == 0) translate(); else - ini_Open(check_path(Settings.device_dat + ":/config/HBF/languages/") + Options.language + ".lang"); + ini_Open(check_path(Settings.device_dat + ":/config/Homebrew Filter/languages/") + Options.language + ".lang"); /*********************************************************************/ - + AvailableCategory.categories[0] = tr(Settings.category_name_all); - + if(theme) sprintf(Options.theme, tr("STANDARD")); - + if(language) sprintf(Options.language, tr("STANDARD")); - + if(font) sprintf(Options.font, tr("STANDARD")); } - + menu = MENU_SETTINGS; } } HaltGui(); Options.temp_last_setting = 0; - + mainWindow->Remove(&optionBrowser); mainWindow->Remove(&w); return menu; diff --git a/source/Menus/menu_settings_font.cpp b/source/Menus/menu_settings_font.cpp index b2e414f..12a5cb9 100644 --- a/source/Menus/menu_settings_font.cpp +++ b/source/Menus/menu_settings_font.cpp @@ -46,7 +46,7 @@ int MenuSettingsFont() DIR *dirHandle; struct dirent * dirEntry; - dirHandle = opendir(check_path(Settings.device_dat + ":/config/HBF/Fonts").c_str()); + dirHandle = opendir(check_path(Settings.device_dat + ":/config/Homebrew Filter/Fonts").c_str()); if (dirHandle) { while (0 != (dirEntry = readdir(dirHandle))) { diff --git a/source/Menus/menu_settings_language.cpp b/source/Menus/menu_settings_language.cpp index f53a227..413f30d 100644 --- a/source/Menus/menu_settings_language.cpp +++ b/source/Menus/menu_settings_language.cpp @@ -46,7 +46,7 @@ int MenuSettingsLanguage() DIR *dirHandle; struct dirent * dirEntry; - dirHandle = opendir(check_path(Settings.device_dat + ":/config/HBF/Languages").c_str()); + dirHandle = opendir(check_path(Settings.device_dat + ":/config/Homebrew Filter/Languages").c_str()); if (dirHandle) { while (0 != (dirEntry = readdir(dirHandle))) diff --git a/source/Menus/menu_settings_theme.cpp b/source/Menus/menu_settings_theme.cpp index 1d2b878..b537972 100644 --- a/source/Menus/menu_settings_theme.cpp +++ b/source/Menus/menu_settings_theme.cpp @@ -46,7 +46,7 @@ int MenuSettingsTheme() DIR *dirHandle; struct dirent * dirEntry; - dirHandle = opendir(check_path(Settings.device_dat + ":/config/HBF/Themes").c_str()); + dirHandle = opendir(check_path(Settings.device_dat + ":/config/Homebrew Filter/Themes").c_str()); if (dirHandle) { while (0 != (dirEntry = readdir(dirHandle))) { diff --git a/source/Menus/menus.h b/source/Menus/menus.h index 74438ca..4c7cf3a 100644 --- a/source/Menus/menus.h +++ b/source/Menus/menus.h @@ -21,12 +21,12 @@ enum THEME, LANGUAGE, FONT, + STORAGE_DEVICE, SLIDE_EFFECT, CATEGORY_REMEMBER, NUMBER_OF_APPS, QUICK_START, SHOW_ALL, - STORAGE_DEVICE, DEVICE_ICON, CHILDLOCK, NAVIGATION, @@ -41,4 +41,4 @@ enum DISPLAY_BOTTOM, DISPLAY_LEFT, DISPLAY_RIGHT -}; +}; \ No newline at end of file diff --git a/source/Menus/menus_command.cpp b/source/Menus/menus_command.cpp index ad24363..6bd72bc 100644 --- a/source/Menus/menus_command.cpp +++ b/source/Menus/menus_command.cpp @@ -20,7 +20,7 @@ void Category_rename_move(string button) Settings.unassigned = false; else Settings.unassigned = true; - + Settings.current_page = 1; } // Kategorie umbenennen @@ -29,7 +29,7 @@ void Category_rename_move(string button) char new_category_name[256]; sprintf (new_category_name, Settings.category_name.c_str()); OnScreenKeyboard(new_category_name, 256, false); - + if(strcasecmp(new_category_name,"NULL") != 0 ) KategorieUmbenennen(Settings.category_name, new_category_name); } @@ -55,29 +55,22 @@ void Category_rename_move(string button) void Next_Category() { - int prev_cat = Settings.current_category; - Settings.current_category++; + if(Settings.current_category > (signed)AvailableCategory.categories.size() -1) + Settings.current_category = 0; + + // Kategorie Alle nur anzeigen, wenn aktiviert oder keine andere vorhanden ist + if(!Options.show_all && Settings.current_category == 0 && AvailableCategory.categories.size() -1 > 0) + Settings.current_category++; - if(Settings.current_category != prev_cat) - { - - if(Settings.current_category > (signed)AvailableCategory.categories.size() -1) - Settings.current_category = 0; - - // Kategorie Alle nur anzeigen, wenn aktiviert oder keine andere vorhanden ist - if(!Options.show_all && Settings.current_category == 0 && AvailableCategory.categories.size() -1 > 0) - Settings.current_category++; - - Settings.current_page = 1; - Settings.unassigned = false; - - if(Settings.current_category != 0) - copy_app_in_category(); - - Settings.Apps_from = EFFECT_SLIDE_RIGHT; - Settings.Apps_to = EFFECT_SLIDE_LEFT; - } + Settings.current_page = 1; + Settings.unassigned = false; + + if(Settings.current_category != 0) + copy_app_in_category(); + + Settings.Apps_from = EFFECT_SLIDE_RIGHT; + Settings.Apps_to = EFFECT_SLIDE_LEFT; } void Previous_Category() @@ -87,16 +80,16 @@ void Previous_Category() // Kategorie Alle nur anzeigen, wenn aktiviert oder keine andere vorhanden ist if(!Options.show_all && Settings.current_category == 0) Settings.current_category--; - + if(Settings.current_category < 0) Settings.current_category = AvailableCategory.categories.size() -1; - + Settings.current_page = 1; Settings.unassigned = false; - + if(Settings.current_category != 0) copy_app_in_category(); - + Settings.Apps_from = EFFECT_SLIDE_LEFT; Settings.Apps_to = EFFECT_SLIDE_RIGHT; } @@ -116,9 +109,9 @@ void AppEraseDelate(int choice, const char* name, const char* foldername) if( eraseDir(name) ) { DeleteDir(foldername); - + app_list(); - + if(Settings.current_category != 0) copy_app_in_category(); else diff --git a/source/Network/network.cpp b/source/Network/network.cpp index 72e7dac..9d22594 100644 --- a/source/Network/network.cpp +++ b/source/Network/network.cpp @@ -54,7 +54,7 @@ void CheckVersion(void) { if(Settings.checkrev == -1) { - struct block file = downloadfile("http://download.tuxfamily.org/hbf/DOL/revisions"); + struct block file = downloadfile("http://hamachi-mp.bplaced.net/Downloads/wii/Homebrew_Filter/version.txt"); if (file.data != NULL) { revs = (char*)file.data; diff --git a/source/Network/tcp.cpp b/source/Network/tcp.cpp index efaecac..0b2ab4f 100644 --- a/source/Network/tcp.cpp +++ b/source/Network/tcp.cpp @@ -16,7 +16,6 @@ u8 *data = (u8 *)0x92000000; /*** Extern variables ***/ extern GuiWindow * mainWindow; extern bool boot_buffer; -extern bool wiiload; /*** Extern functions ***/ extern void ResumeGui(); @@ -114,7 +113,7 @@ void HaltTcpThread() static void * tcp_callback(void *arg) { - u32 offset, read, size, client, uncfilesize; + u32 offset, read, size, ip, client, uncfilesize; u8 *bfr[READ_SIZE]; bool compress = false; struct sockaddr_in addr; @@ -207,14 +206,16 @@ static void * tcp_callback(void *arg) Percent = 100.0f * offset/size; progressbarImg->SetSize(Percent*3.27f, 38); - char buffer[6]; + char buffer[7]; sprintf(buffer, "%i %%", (int)Percent); PercentTxt->SetText(buffer); } + usleep(100000); net_close(client); net_close(listen); +// retry: if(compress) { u8 *zdata = (u8 *) malloc(uncfilesize); @@ -222,14 +223,17 @@ static void * tcp_callback(void *arg) return NULL; uLongf zdatalen = uncfilesize; - int res = uncompress (zdata, &zdatalen, data, (uLongf)size); - + if (res != Z_OK) { free(zdata); - // fprintf (stderr, "error decompressing data: %d\n", res); - return NULL; +// debug("error"); +// PercentTxt->SetText("error"); +// return NULL; +// goto retry; + // fprintf (stderr, "error decompressing data: %d\n", res); + // return NULL; } else { @@ -252,7 +256,6 @@ static void * tcp_callback(void *arg) ResumeGui(); boot_buffer = true; - wiiload = true; break; } } diff --git a/source/Network/update.cpp b/source/Network/update.cpp index 9032646..7274aa5 100644 --- a/source/Network/update.cpp +++ b/source/Network/update.cpp @@ -12,7 +12,7 @@ bool readrev = true; string CheckNewVersions() { string revs = "error"; - struct block file = downloadfile("http://download.tuxfamily.org/hbf/DOL/revisions"); + struct block file = downloadfile("http://hamachi-mp.bplaced.net/Downloads/wii/Homebrew_Filter/version.txt"); if (file.data != NULL) { revs = (char*)file.data; @@ -24,7 +24,7 @@ string CheckNewVersions() string NewVersionsText() { string text = "error"; - struct block file = downloadfile("http://download.tuxfamily.org/hbf/DOL/updates"); + struct block file = downloadfile("http://hamachi-mp.bplaced.net/Downloads/wii/Homebrew_Filter/version_text.txt"); if (file.data != NULL) { text = (char*)file.data; @@ -38,9 +38,9 @@ string new_update(string rev, string filename) { char url[100]; if(rev == "Beta") - sprintf(url, "http://download.tuxfamily.org/hbf/DOL/Beta/%s", filename.c_str()); + sprintf(url, "http://hamachi-mp.bplaced.net/Downloads/wii/Homebrew_Filter/Beta/%s", filename.c_str()); else - sprintf(url, "http://download.tuxfamily.org/hbf/DOL/rev%s/%s", rev.c_str(), filename.c_str()); + sprintf(url, "http://hamachi-mp.bplaced.net/Downloads/wii/Homebrew_Filter/rev%s/%s", rev.c_str(), filename.c_str()); file = downloadfile(url); if (file.data && file.size > 0) @@ -56,7 +56,7 @@ string new_update(string rev, string filename) string new_theme(string themename, string filename) { char url[100]; - sprintf(url, "http://www.nanolx.org/hbf/Themes/%s/%s", themename.c_str(), filename.c_str()); + sprintf(url, "http://hbf.hamachi-mp.bplaced.net/Themes/%s/%s", themename.c_str(), filename.c_str()); file = downloadfile(url); if (file.data && file.size > 0) @@ -73,7 +73,7 @@ void update(string filename) { if (file.data && file.size > 0) { - FILE * data = fopen((Settings.device_dat + ":/config/HBF/"+ filename).c_str(), "wb"); + FILE * data = fopen((Settings.device_dat + ":/config/Homebrew Filter/"+ filename).c_str(), "wb"); if(data) { fwrite(file.data, 1, file.size, data); diff --git a/source/Prompts/prompt_app_info.cpp b/source/Prompts/prompt_app_info.cpp index 844264a..fc37de8 100644 --- a/source/Prompts/prompt_app_info.cpp +++ b/source/Prompts/prompt_app_info.cpp @@ -3,20 +3,67 @@ #include #include "libwiigui/gui.h" -#include "main.h" +#include "menu.h" +#include "Menus/menus_command.h" +#include "Tools/copy_app_in_category.h" #include "Tools/parser.h" #include "Tools/textline.h" #include "Tools/load_channel.h" #include "Tools/SelectIos.h" -#include "Prompts/prompts.h" +#include "prompts.h" + /*** Extern variables ***/ extern GuiWindow * mainWindow; +extern bool boothomebrew; /*** Extern functions ***/ extern void ResumeGui(); extern void HaltGui(); extern void HaltResumeGui(); +int ChoiceAppInfo(vector list, int i) +{ + int menu = MENU_NONE; + again: + int choice; + if(Options.quick_start == 0) + choice = AppInfo(list[i].name.c_str(), list[i].foldername, list[i].icon); + else + choice = 1; + + if(choice == 1) // App starten + { + Settings.forwarder_path = list[i].pathboot; + Settings.forwarder_arg = list[i].arg.c_str(); + boothomebrew = true; + menu = MENU_EXIT; + } + else if(choice == 2) // App Einfügen + { + string app_in_kategorie = AddApp(list[i].name.c_str()); + if( app_in_kategorie != "NULL" ) + { + AppEinfuegen(app_in_kategorie, list[i].foldername.c_str()); + copy_app_in_unassigned(); + // temp_slide = false; + menu = MENU_MAIN; + } + } + else if(choice == 3 || choice == 4) + { + AppEraseDelate(choice, list[i].name.c_str(), list[i].foldername.c_str()); + // temp_slide = false; + menu = MENU_MAIN; + } + else if(choice == 5) + { + MetaEdit(list[i].foldername); + // temp_slide = false; + goto again; + } + return menu; +} + /**************************************************************************** * AppInfo * @@ -31,16 +78,26 @@ AppInfo(const char *title, string dir, u8* icon) dir += "meta.xml"; string line, quelltext = "", version, coder, descriptionTxt; - - ifstream in(dir.c_str()); - while(getline(in, line)) - quelltext = quelltext + line + "\n"; - - string space = " "; - version = tr("Version:") + space + parser(quelltext, "", ""); - coder = tr("Coder:") + space + parser(quelltext, "", ""); - descriptionTxt = parser(quelltext, "", ""); - + + if(strcasecmp(title, "the homebrew channel") == 0) + { + string space = " "; + version = tr("Version:") + space + HBC_version; + coder = tr("Coder:") + space + "HBC Team"; + descriptionTxt = "The Homebrew Channel is a channel for launching Wii homebrew applications. It will list homebrew applications stored and organised on an SD card or USB mass storage device in a nice little GUI, which you can very easily customise with descriptions and shiny little icons all by yourself. You can also launch applications via TCP (with a correctly configured PC) or a USBGecko. Both of those built in options make it extremely convenient for testing out new code, as well as a general purpose homebrew launcher."; + } + else + { + ifstream in(dir.c_str()); + while(getline(in, line)) + quelltext = quelltext + line + "\n"; + + string space = " "; + version = tr("Version:") + space + parser(quelltext, "", ""); + coder = tr("Coder:") + space + parser(quelltext, "", ""); + descriptionTxt = parser(quelltext, "", ""); + } + GuiWindow promptWindow(520, 360); promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); promptWindow.SetPosition(0, -10); @@ -57,10 +114,10 @@ AppInfo(const char *title, string dir, u8* icon) GuiImage viewicon(&icon_data); viewicon.SetAlignment(ALIGN_LEFT, ALIGN_TOP); viewicon.SetPosition(40, 54); - + GuiImage * viewdevice = NULL; - - if((Options.device_icon == 2 || Options.device_icon == 3) && (Settings.device == "sd_usb" || Settings.device == "all")) + + if((Options.device_icon == 2 || Options.device_icon == 3) && Settings.device == "sd_usb") { bool icon = false; if(strncmp(dir.c_str(), "sd", 2) == 0) @@ -73,12 +130,7 @@ AppInfo(const char *title, string dir, u8* icon) viewdevice = new GuiImage(new GuiImageData(Theme.usb_inactive)); icon = true; } - else if(strncmp(dir.c_str(), "dvd", 3) == 0) - { - viewdevice = new GuiImage(new GuiImageData(Theme.dvd_inactive)); - icon = true; - } - + if(icon) { viewdevice->SetAlignment(ALIGN_LEFT, ALIGN_TOP); @@ -86,7 +138,7 @@ AppInfo(const char *title, string dir, u8* icon) viewdevice->SetScale(0.8); } } - + GuiText titleTxt(title, 26, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255}); titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); titleTxt.SetPosition(0, 20); @@ -105,19 +157,19 @@ AppInfo(const char *title, string dir, u8* icon) int i = 0; int y = 125; int place = 25; - + int number = 5; - + GuiText upTxt("c", 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255}); upTxt.SetFont(symbol_ttf, symbol_ttf_size); upTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); upTxt.SetPosition(0, y -20); - + GuiText downTxt("d", 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255}); downTxt.SetFont(symbol_ttf, symbol_ttf_size); downTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); downTxt.SetPosition(0, y + (place * (number-1)) + 15); - + GuiText * Entrie[number]; for(i=0; i < number && i < (signed)description.line.size(); i++) { @@ -138,7 +190,7 @@ AppInfo(const char *title, string dir, u8* icon) GuiImage btn1Img(&btn); GuiImage btn2Img(&btn); GuiImage eraseImg(&btn); - + // image over GuiImageData cancelBtn_over(Theme.cancel_active); GuiImage cancelBtnImgOver(&cancelBtn_over); @@ -150,18 +202,15 @@ AppInfo(const char *title, string dir, u8* icon) GuiImage btn1ImgOver(&btn_over); GuiImage btn2ImgOver(&btn_over); GuiImage eraseImgOver(&btn_over); - + // Edit GuiButton edit(editBtn.GetWidth(), editBtn.GetHeight()); edit.SetAlignment(ALIGN_LEFT, ALIGN_TOP); - if((Options.device_icon == 2 || Options.device_icon == 3) && (Settings.device == "sd_usb" || Settings.device == "all")) - edit.SetPosition(48, 15); - else - edit.SetPosition(10, 10); + edit.SetPosition(10, 10); edit.SetImage(&editBtnImg); edit.SetImageOver(&editBtnImgOver); edit.SetTrigger(&trigA); - + // Cancel GuiButton cancel(cancelBtn.GetWidth(), cancelBtn.GetHeight()); cancel.SetAlignment(ALIGN_RIGHT, ALIGN_TOP); @@ -171,7 +220,7 @@ AppInfo(const char *title, string dir, u8* icon) cancel.SetTrigger(&trigA); cancel.SetTrigger(&trigB); // cancel.SetState(STATE_SELECTED); - + // Laden GuiButton btn1(btn.GetWidth(), btn.GetHeight()); GuiText btn1Txt(tr("Loading"), 22, (GXColor){Theme.button_tiny_text_1, Theme.button_tiny_text_2, Theme.button_tiny_text_3, 255}); @@ -229,7 +278,7 @@ AppInfo(const char *title, string dir, u8* icon) startingAppName.erase(startingAppName.rfind("/")); startingAppName.erase(0, startingAppName.rfind("/") +1); sprintf(SelectIos, tr("Start with IOS %i (-/+)"), SearchAppIOS(startingAppName)); - + GuiText SelectIosTxt(SelectIos, 18, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255}); SelectIosTxt.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); SelectIosTxt.SetPosition(0, -15); @@ -239,20 +288,20 @@ AppInfo(const char *title, string dir, u8* icon) promptWindow.Append(&versionTxt); promptWindow.Append(&coderTxt); promptWindow.Append(viewdevice); - + for(int x=0; x < i; x++) promptWindow.Append(Entrie[x]); - + if((signed)description.line.size() >= number) { promptWindow.Append(&upTxt); promptWindow.Append(&downTxt); } - + if(quelltext != "") promptWindow.Append(&edit); promptWindow.Append(&btn1); - if(strcasecmp(Settings.code,"NULL") == 0 && strncmp(dir.c_str(), "dvd", 3) != 0) + if(strcasecmp(title, "the homebrew channel") != 0 && strcasecmp(Settings.code,"NULL") == 0) promptWindow.Append(&erase); if(AvailableCategory.categories.size() != 1 && strcasecmp(Settings.code,"NULL") == 0) promptWindow.Append(&btn2); @@ -276,14 +325,14 @@ AppInfo(const char *title, string dir, u8* icon) if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP) || PAD_ButtonsDown(0) & PAD_BUTTON_UP) { int z = description.text_up(); - + for(int x=0; x < i; x++) Entrie[x]->SetText(description.line[x + z].c_str()); - + HaltResumeGui(); } - + if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN) || PAD_ButtonsDown(0) & PAD_BUTTON_DOWN) { int z = description.text_down(number); @@ -291,7 +340,6 @@ AppInfo(const char *title, string dir, u8* icon) for(int x=0; x < i; x++) Entrie[x]->SetText(description.line[x + z].c_str()); - HaltResumeGui(); } @@ -301,15 +349,14 @@ AppInfo(const char *title, string dir, u8* icon) SelectIosTxt.SetText(SelectIos); HaltResumeGui(); } - + if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS) || PAD_ButtonsDown(0) & PAD_TRIGGER_L) { sprintf(SelectIos, tr("Start with IOS %i (-/+)"), previousIos()); SelectIosTxt.SetText(SelectIos); HaltResumeGui(); } - - + if(cancel.GetState() == STATE_CLICKED) // Zurück choice = 0; else if(btn1.GetState() == STATE_CLICKED) // Laden diff --git a/source/Prompts/prompt_device.cpp b/source/Prompts/prompt_device.cpp index 57f0518..6243fb5 100644 --- a/source/Prompts/prompt_device.cpp +++ b/source/Prompts/prompt_device.cpp @@ -22,16 +22,18 @@ int devicePrompt() bool stop = false; int device = -1; - GuiWindow promptWindow(232,64); + GuiWindow promptWindow(144,64); promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); promptWindow.SetPosition(-135, 280); + if(Options.apps == 5) + promptWindow.SetPosition(-135, 307); GuiTrigger trigA; GuiTrigger trigB; trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); // Hintergrund - GuiImageData dialogBox(Theme.choice_large); + GuiImageData dialogBox(Theme.choice); GuiImage dialogBoxImg(&dialogBox); // button data @@ -41,60 +43,38 @@ int devicePrompt() GuiImageData usb_BtnImgDataOver(Theme.usb_active); GuiImageData sd_usb_BtnImgData(Theme.sd_usb_inactive); GuiImageData sd_usb_BtnImgDataOver(Theme.sd_usb_active); - GuiImageData dvd_BtnImgData(Theme.dvd_inactive); - GuiImageData dvd_BtnImgDataOver(Theme.dvd_active); - GuiImageData all_BtnImgData(Theme.all_inactive); - GuiImageData all_BtnImgDataOver(Theme.all_active); // button GuiImage sd_BtnImg(&sd_BtnImgData); GuiImage usb_BtnImg(&usb_BtnImgData); GuiImage sd_usb_BtnImg(&sd_usb_BtnImgData); - GuiImage dvd_BtnImg(&dvd_BtnImgData); - GuiImage all_BtnImg(&all_BtnImgData); // button over GuiImage sd_BtnImgOver(&sd_BtnImgDataOver); GuiImage usb_BtnImgOver(&usb_BtnImgDataOver); GuiImage sd_usb_BtnImgOver(&sd_usb_BtnImgDataOver); - GuiImage dvd_BtnImgOver(&dvd_BtnImgDataOver); - GuiImage all_BtnImgOver(&all_BtnImgDataOver); - + GuiButton sd_Btn(sd_BtnImgData.GetWidth(), sd_BtnImgData.GetHeight()); sd_Btn.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); sd_Btn.SetPosition(8, 0); sd_Btn.SetImage(&sd_BtnImg); sd_Btn.SetImageOver(&sd_BtnImgOver); sd_Btn.SetTrigger(&trigA); - + GuiButton usb_Btn(usb_BtnImgData.GetWidth(), usb_BtnImgData.GetHeight()); - usb_Btn.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - usb_Btn.SetPosition(52, 0); + usb_Btn.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + usb_Btn.SetPosition(0, 0); usb_Btn.SetImage(&usb_BtnImg); usb_Btn.SetImageOver(&usb_BtnImgOver); usb_Btn.SetTrigger(&trigA); - + GuiButton sd_usb_Btn(sd_usb_BtnImgData.GetWidth(), sd_usb_BtnImgData.GetHeight()); - sd_usb_Btn.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); - sd_usb_Btn.SetPosition(0, 0); + sd_usb_Btn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE); + sd_usb_Btn.SetPosition(-8, 0); sd_usb_Btn.SetImage(&sd_usb_BtnImg); sd_usb_Btn.SetImageOver(&sd_usb_BtnImgOver); sd_usb_Btn.SetTrigger(&trigA); - GuiButton dvd_Btn(dvd_BtnImgData.GetWidth(), dvd_BtnImgData.GetHeight()); - dvd_Btn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE); - dvd_Btn.SetPosition(-52, 0); - dvd_Btn.SetImage(&dvd_BtnImg); - dvd_Btn.SetImageOver(&dvd_BtnImgOver); - dvd_Btn.SetTrigger(&trigA); - - GuiButton all_Btn(all_BtnImgData.GetWidth(), all_BtnImgData.GetHeight()); - all_Btn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE); - all_Btn.SetPosition(-8, 0); - all_Btn.SetImage(&all_BtnImg); - all_Btn.SetImageOver(&all_BtnImgOver); - all_Btn.SetTrigger(&trigA); - GuiButton back(0, 0); back.SetTrigger(&trigB); @@ -102,8 +82,6 @@ int devicePrompt() promptWindow.Append(&sd_Btn); promptWindow.Append(&usb_Btn); promptWindow.Append(&sd_usb_Btn); - promptWindow.Append(&dvd_Btn); - promptWindow.Append(&all_Btn); promptWindow.Append(&back); HaltGui(); @@ -121,31 +99,19 @@ int devicePrompt() device = 1; stop = true; } - + if(usb_Btn.GetState() == STATE_CLICKED) { device = 2; stop = true; } - + if(sd_usb_Btn.GetState() == STATE_CLICKED) { device = 3; stop = true; } - - if(dvd_Btn.GetState() == STATE_CLICKED) - { - device = 4; - stop = true; - } - - if(all_Btn.GetState() == STATE_CLICKED) - { - device = 5; - stop = true; - } - + if(back.GetState() == STATE_CLICKED) stop = true; } @@ -154,7 +120,7 @@ int devicePrompt() mainWindow->Remove(&promptWindow); mainWindow->SetState(STATE_DEFAULT); ResumeGui(); - + return device; } diff --git a/source/Prompts/prompt_end.cpp b/source/Prompts/prompt_end.cpp index 0eb59b8..b11cfb7 100644 --- a/source/Prompts/prompt_end.cpp +++ b/source/Prompts/prompt_end.cpp @@ -43,7 +43,7 @@ endPrompt() GuiImage bootmiiImg(&btn); GuiImage shutdownImg(&btn); GuiImage backImg(&btn); - + // Buttons over data GuiImageData btn_over(Theme.button_focus); GuiImage bootmiiImgOver(&btn_over); @@ -59,7 +59,7 @@ endPrompt() bootmii.SetImage(&bootmiiImg); bootmii.SetImageOver(&bootmiiImgOver); bootmii.SetTrigger(&trigA); - + GuiText systemmenuTxt(tr("Exit to System Menu"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255}); GuiButton systemmenu(btn.GetWidth(), btn.GetHeight()); systemmenu.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); @@ -70,7 +70,7 @@ endPrompt() systemmenu.SetImage(&systemmenuImg); systemmenu.SetImageOver(&systemmenuImgOver); systemmenu.SetTrigger(&trigA); - + GuiText shutdownTxt(tr("Shutdown"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255}); GuiButton shutdown(btn.GetWidth(), btn.GetHeight()); shutdown.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); @@ -81,7 +81,7 @@ endPrompt() shutdown.SetImage(&shutdownImg); shutdown.SetImageOver(&shutdownImgOver); shutdown.SetTrigger(&trigA); - + GuiText backTxt(tr("Back"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255}); GuiButton back(btn.GetWidth(), btn.GetHeight()); back.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); @@ -121,21 +121,21 @@ endPrompt() menu = MENU_EXIT; stop = true; } - + if(systemmenu.GetState() == STATE_CLICKED) { PowerOff = SYS_RETURNTOMENU; menu = MENU_EXIT; stop = true; } - + if(shutdown.GetState() == STATE_CLICKED) { PowerOff = SYS_POWEROFF_STANDBY; menu = MENU_EXIT; stop = true; } - + if(back.GetState() == STATE_CLICKED || back2.GetState() == STATE_CLICKED) stop = true; } diff --git a/source/Prompts/prompt_font_download.cpp b/source/Prompts/prompt_font_download.cpp index 35bf4fb..fcd976e 100644 --- a/source/Prompts/prompt_font_download.cpp +++ b/source/Prompts/prompt_font_download.cpp @@ -86,11 +86,11 @@ void fontDownload(string fontname) char buffer[100]; msgTxt.SetText(fontname.c_str()); - sprintf(buffer, "http://www.nanolx.org/hbf/Fonts/%s", fontname.c_str()); + sprintf(buffer, "http://hbf.hamachi-mp.bplaced.net/Fonts/%s", fontname.c_str()); struct block file = downloadfile(buffer); if (file.data && file.size > 0 && folder_exists()) { - FILE * data = fopen((Settings.device_dat + ":/config/HBF/Fonts/"+ fontname).c_str(), "wb"); + FILE * data = fopen((Settings.device_dat + ":/config/Homebrew Filter/Fonts/"+ fontname).c_str(), "wb"); if(data) { fwrite(file.data, 1, file.size, data); @@ -126,7 +126,7 @@ string FontList() bool stop = false; char buffer[100]; - sprintf(buffer, "http://www.nanolx.org/hbf/Fonts/"); + sprintf(buffer, "http://hbf.hamachi-mp.bplaced.net/Fonts/"); struct block file = downloadfile(buffer); if (file.data != NULL) @@ -373,4 +373,4 @@ string checkFontsPrompt() ResumeGui(); return downloadfont; -} +} \ No newline at end of file diff --git a/source/Prompts/prompt_info.cpp b/source/Prompts/prompt_info.cpp index 61500b7..df3999b 100644 --- a/source/Prompts/prompt_info.cpp +++ b/source/Prompts/prompt_info.cpp @@ -40,18 +40,18 @@ infoPrompt() int y = 40; GuiText * Entrie[20]; - Entrie[i] = new GuiText(tr("About HomebrewFilter"), 28, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255}); + Entrie[i] = new GuiText(tr("Credits"), 28, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255}); Entrie[i]->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); Entrie[i]->SetPosition(0, y); i++; y += 50; - Entrie[i] = new GuiText(tr("Developer:"), 24, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255}); + Entrie[i] = new GuiText(tr("Coder:"), 24, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255}); Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); Entrie[i]->SetPosition(x, y); i++; - Entrie[i] = new GuiText("Christopher Roy Bratusek", 22, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255}); + Entrie[i] = new GuiText("hamachi-mp", 22, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255}); Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); Entrie[i]->SetPosition(x+200, y); i++; diff --git a/source/Prompts/prompt_language_download.cpp b/source/Prompts/prompt_language_download.cpp index 3e6ef1a..f539a21 100644 --- a/source/Prompts/prompt_language_download.cpp +++ b/source/Prompts/prompt_language_download.cpp @@ -86,11 +86,11 @@ void languageDownload(string languagename) char buffer[100]; msgTxt.SetText(languagename.c_str()); - sprintf(buffer, "http://www.nanolx.org/hbf/Languages/%s", languagename.c_str()); + sprintf(buffer, "http://hbf.hamachi-mp.bplaced.net/Languages/%s", languagename.c_str()); struct block file = downloadfile(buffer); if (file.data && file.size > 0 && folder_exists()) { - FILE * data = fopen((Settings.device_dat + ":/config/HBF/Languages/"+ languagename).c_str(), "wb"); + FILE * data = fopen((Settings.device_dat + ":/config/Homebrew Filter/Languages/"+ languagename).c_str(), "wb"); if(data) { fwrite(file.data, 1, file.size, data); @@ -126,7 +126,7 @@ string LanguageList() bool stop = false; char buffer[100]; - sprintf(buffer, "http://www.nanolx.org/hbf/Languages/"); + sprintf(buffer, "http://hbf.hamachi-mp.bplaced.net/Languages/"); struct block file = downloadfile(buffer); if (file.data != NULL) @@ -374,4 +374,4 @@ string checkLanguagesPrompt() ResumeGui(); return downloadlanguage; -} +} \ No newline at end of file diff --git a/source/Prompts/prompt_system.cpp b/source/Prompts/prompt_system.cpp index c2363d9..c20b5fa 100644 --- a/source/Prompts/prompt_system.cpp +++ b/source/Prompts/prompt_system.cpp @@ -25,6 +25,8 @@ int systemPrompt() GuiWindow promptWindow(144,64); promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); promptWindow.SetPosition(-185, 280); + if(Options.apps == 5) + promptWindow.SetPosition(-185, 307); GuiTrigger trigA; GuiTrigger trigB; trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); diff --git a/source/Prompts/prompt_theme_download.cpp b/source/Prompts/prompt_theme_download.cpp index 9d78b51..fa6e1ab 100644 --- a/source/Prompts/prompt_theme_download.cpp +++ b/source/Prompts/prompt_theme_download.cpp @@ -6,7 +6,6 @@ #include "main.h" #include "Tools/textline.h" -#include "Tools/save.h" #include "Network/network.h" #include "Network/update.h" @@ -85,28 +84,36 @@ void themeDownload(string themename) ResumeGui(); char buffer[100]; - sprintf(buffer, "http://www.nanolx.org/hbf/Themes/%s/filelist", themename.c_str()); - + // download counter + sprintf(buffer, "http://hbf.hamachi-mp.bplaced.net/Themes/counter.php?theme=%s", themename.c_str()); struct block file = downloadfile(buffer); + + sprintf(buffer, "http://hbf.hamachi-mp.bplaced.net/Themes/index.php?path=Themes/%s", themename.c_str()); + file = downloadfile(buffer); if (file.data != NULL) { string source_themes = (char*)file.data; vector themes; + source_themes.erase(0, source_themes.find("?path=Themes")); while(1) { if((signed)source_themes.find(themename.c_str()) == -1) break; - source_themes.erase(0, source_themes.find(themename.c_str()) + themename.length() +6); + source_themes.erase(0, source_themes.find(themename.c_str()) + themename.length() +1); + + if(source_themes.substr(0, source_themes.find("\"")) == "amp;name=settings.xml") + themes.push_back(source_themes.substr(9, source_themes.find("\"") -9)); + else + themes.push_back(source_themes.substr(0, source_themes.find("\""))); - themes.push_back(source_themes.substr(0, source_themes.find("+"))); - - source_themes.erase(0, source_themes.find("+")); + source_themes.erase(0, source_themes.find("\"")); } + for(int i = 0; i < (signed)themes.size(); i++) { msgTxt.SetText(themes[i].c_str()); @@ -116,8 +123,7 @@ void themeDownload(string themename) free(file.data); } - - + msgTxt.SetText(""); downloadTxt.SetText(tr("finished")); @@ -144,7 +150,7 @@ string ThemeList() bool stop = false; char buffer[100]; - sprintf(buffer, "http://www.nanolx.org/hbf/Themes/"); + sprintf(buffer, "http://hbf.hamachi-mp.bplaced.net/Themes/"); struct block file = downloadfile(buffer); if (file.data != NULL) @@ -154,16 +160,16 @@ string ThemeList() while(1) { - if((signed)source_themes.find("../Themes/") == -1) + if((signed)source_themes.find("?path=Themes/") == -1) break; - source_themes.erase(0, source_themes.find("../Themes/")); - source_themes.erase(0, source_themes.find("s/") +2); - + source_themes.erase(0, source_themes.find("?path=Themes/")); + source_themes.erase(0, source_themes.find("/") +1); + if(source_themes.substr(0, source_themes.find("\"")) != "_HBF_") themes.push_back(source_themes.substr(0, source_themes.find("\""))); - source_themes.erase(0, source_themes.find("<")); + source_themes.erase(0, source_themes.find("download.php")); } free(file.data); @@ -395,4 +401,4 @@ string checkThemesPrompt() ResumeGui(); return downloadtheme; -} +} \ No newline at end of file diff --git a/source/Prompts/prompt_update.cpp b/source/Prompts/prompt_update.cpp index f9c6a5e..caef54c 100644 --- a/source/Prompts/prompt_update.cpp +++ b/source/Prompts/prompt_update.cpp @@ -14,10 +14,8 @@ #include "Network/update.h" #include "Network/http.h" -#include -#include -/*** Extern variables ***/ +#/*** Extern variables ***/ extern GuiWindow * mainWindow; extern bool boot_buffer; @@ -101,33 +99,15 @@ updatePrompt(string rev) ResumeGui(); char url[100]; - if(rev == "Beta") - sprintf(url, "http://download.tuxfamily.org/hbf/DOL/Beta/boot.dol"); - else - sprintf(url, "http://download.tuxfamily.org/hbf/DOL/rev%s/boot.dol", rev.c_str()); - - // copy boot.dol to prev.dol - std::ifstream infile((Settings.device_dat + ":/apps/HomebrewFilter/boot.dol").c_str(), std::ios_base::binary); - std::ofstream outfile((Settings.device_dat + ":/apps/HomebrewFilter/prev.dol").c_str(), std::ios_base::binary); - - outfile << infile.rdbuf(); + sprintf(url, "http://hamachi-mp.bplaced.net/Downloads/wii/Homebrew_Filter/rev%s/boot.dol", rev.c_str()); struct block file = downloadfile(url); if (file.data && file.size > 0) { - // write file - FILE * data = fopen((Settings.device_dat + ":/apps/HomebrewFilter/boot.dol").c_str(), "wb"); - if(data) - { - fwrite(file.data, 1, file.size, data); - fclose(data); - } - + CopyHomebrewMemory(file.data, 0, file.size); if(file.data) free(file.data); - - LoadHomebrew ((Settings.device_dat + ":/apps/HomebrewFilter/boot.dol").c_str()); - BootHomebrew (); + boot_buffer = true; } else { @@ -365,4 +345,4 @@ string checkUpdatePrompt() ResumeGui(); return rev; -} +} \ No newline at end of file diff --git a/source/Prompts/prompts.h b/source/Prompts/prompts.h index e03930a..1d083f8 100644 --- a/source/Prompts/prompts.h +++ b/source/Prompts/prompts.h @@ -2,6 +2,8 @@ #ifndef _PROMPTS_H_ #define _PROMPTS_H_ +#include "main.h" + #include using namespace std; @@ -16,11 +18,15 @@ bool RemoveApp(const char *AppName); bool MetaEdit(string dir); int AppInfo(const char *title, string dir, u8* icon); +int ChoiceAppInfo(vector list, int i); int devicePrompt(); -int loaderPrompt(); int endPrompt(); +int menuPrompt(); int sortPrompt(); +int startmenuPrompt(int &CategoryNr, int &AppNr); +int startmenu2Prompt(); int systemPrompt(); +int viewPrompt(); int WindowPrompt(const char *title, const char *msg, const char *btn1Label, const char *btn2Label = NULL); void debug(const char *msg); @@ -42,4 +48,4 @@ void fontDownload(string font); string checkLanguagesPrompt(); void languageDownload(string language); -#endif +#endif \ No newline at end of file diff --git a/source/Tools/FontSystem.cpp b/source/Tools/FontSystem.cpp index 38fd530..84c71f0 100644 --- a/source/Tools/FontSystem.cpp +++ b/source/Tools/FontSystem.cpp @@ -72,7 +72,7 @@ float GetFontScale() void SetFont() { - SetupDefaultFont((check_path(Settings.device_dat + ":/config/HBF/fonts/") + Options.font).c_str()); + SetupDefaultFont((check_path(Settings.device_dat + ":/config/Homebrew Filter/fonts/") + Options.font).c_str()); SetFontScale( (float)51 / (float)fontSystem->getWidth(charToWideChar("a"), 100) ); // 51 -> breite von "a" mit standart schrift } @@ -83,7 +83,7 @@ bool font_folder_exists() { DIR *pDir; - pDir = opendir(check_path(Settings.device_dat + ":/config/HBF/Fonts").c_str()); + pDir = opendir(check_path(Settings.device_dat + ":/config/Homebrew Filter/Fonts").c_str()); if(pDir != NULL) { @@ -92,7 +92,7 @@ bool font_folder_exists() } else { - if (mkdir((Settings.device_dat + ":/config/HBF/Fonts").c_str(), 0777) != -1) + if (mkdir((Settings.device_dat + ":/config/Homebrew Filter/Fonts").c_str(), 0777) != -1) { closedir (pDir); return true; diff --git a/source/Tools/RuntimeIOSPatch.c b/source/Tools/RuntimeIOSPatch.c index 9d15a9f..8e3c373 100644 --- a/source/Tools/RuntimeIOSPatch.c +++ b/source/Tools/RuntimeIOSPatch.c @@ -8,14 +8,6 @@ #define MEM_PROT 0xD8B420A -const u8 di_readlimit_old[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0A, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, - 0x7E, 0xD4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08 -}; -const u8 di_readlimit_patch[] = { 0x7e, 0xd4 }; - const u8 isfs_permissions_old[] = { 0x42, 0x8B, 0xD0, 0x01, 0x25, 0x66 }; const u8 isfs_permissions_patch[] = { 0x42, 0x8B, 0xE0, 0x01, 0x25, 0x66 }; const u8 setuid_old[] = { 0xD1, 0x2A, 0x1C, 0x39 }; @@ -24,7 +16,6 @@ const u8 es_identify_old[] = { 0x28, 0x03, 0xD1, 0x23 }; const u8 es_identify_patch[] = { 0x00, 0x00 }; const u8 hash_old[] = { 0x20, 0x07, 0x4B, 0x0B }; const u8 hash_patch[] = { 0x00 }; -const u8 new_hash_old[] = { 0x20, 0x07, 0x4B, 0x0B }; const u8 addticket_vers_check[] = { 0xD2, 0x01, 0x4E, 0x56 }; const u8 addticket_patch[] = { 0xE0 }; @@ -34,7 +25,7 @@ u32 apply_patch(const char *name, const u8 *old, u32 old_size, const u8 *patch, u8 *ptr = (u8 *) 0x93400000; u32 i, found = 0; u8 *start; - + while ((u32) ptr < (0x94000000 - old_size)) { if(!memcmp(ptr, old, old_size)) @@ -62,19 +53,17 @@ u32 runtimePatchApply() write16(MEM_PROT, 0); count += apply_patch("Trucha", hash_old, sizeof(hash_old), hash_patch, sizeof(hash_patch), 1); - count += apply_patch("New Trucha", new_hash_old, - sizeof(new_hash_old), hash_patch, sizeof(hash_patch), 1); count += apply_patch("ES_Identify", es_identify_old, - sizeof(es_identify_old), es_identify_patch, sizeof(es_identify_patch), 2); + sizeof(es_identify_old), es_identify_patch, sizeof(es_identify_patch), + 2); count += apply_patch("NAND Permissions", isfs_permissions_old, sizeof(isfs_permissions_old), isfs_permissions_patch, sizeof(isfs_permissions_patch), 0); count += apply_patch("add ticket patch", addticket_vers_check, - sizeof(addticket_vers_check), addticket_patch, sizeof(addticket_patch), 0); + sizeof(addticket_vers_check), addticket_patch, sizeof(addticket_patch), + 0); count += apply_patch("ES_SetUID", setuid_old, sizeof(setuid_old), setuid_patch, sizeof(setuid_patch), 0); - count += apply_patch("DI ReadLimit", di_readlimit_old, sizeof(di_readlimit_old), - di_readlimit_patch, sizeof(di_readlimit_patch), 12); write16(MEM_PROT, 1); return count; } diff --git a/source/Tools/SelectIos.cpp b/source/Tools/SelectIos.cpp index 3d04b78..bd320d6 100644 --- a/source/Tools/SelectIos.cpp +++ b/source/Tools/SelectIos.cpp @@ -12,170 +12,6 @@ std::vector ioslist; int selectedIos = IOS_GetVersion(); int ios_pos = 0; int bootmii = 0; -int nandemu = 0; -int priiloader = 0; - -s32 NandReadFile(char *filepath, u8 **buffer, u32 *filesize) -{ - s32 Fd; - int ret; - - if (buffer == NULL) - { - printf("NULL Pointer\n"); - return -1; - } - - Fd = ISFS_Open(filepath, ISFS_OPEN_READ); - if (Fd < 0) - { - printf("ISFS_Open %s failed %d\n", filepath, Fd); - return Fd; - } - - fstats *status; - status = (fstats *)memalign(32, ((sizeof(fstats))+31)&(~31)); - if (status == NULL) - { - printf("Out of memory for status\n"); - return -1; - } - - ret = ISFS_GetFileStats(Fd, status); - if (ret < 0) - { - printf("ISFS_GetFileStats failed %d\n", ret); - ISFS_Close(Fd); - free(status); - return -1; - } - - *buffer = (u8 *)memalign(32, ((status->file_length)+31)&(~31)); - if (*buffer == NULL) - { - printf("Out of memory for buffer\n"); - ISFS_Close(Fd); - free(status); - return -1; - } - - ret = ISFS_Read(Fd, *buffer, status->file_length); - if (ret < 0) - { - printf("ISFS_Read failed %d\n", ret); - ISFS_Close(Fd); - free(status); - free(*buffer); - return ret; - } - - ISFS_Close(Fd); - - *filesize = status->file_length; - free(status); - - if (*filesize > 0) - { - DCFlushRange(*buffer, *filesize); - ICInvalidateRange(*buffer, *filesize); - } - - return 0; -} - -s32 GetTMD(u64 TicketID, signed_blob **Output, u32 *Length) -{ - signed_blob* TMD = NULL; - - u32 TMD_Length; - s32 ret; - - /* Retrieve TMD length */ - ret = ES_GetStoredTMDSize(TicketID, &TMD_Length); - if (ret < 0) - return ret; - - /* Allocate memory */ - TMD = (signed_blob*)memalign(32, (TMD_Length+31)&(~31)); - if (!TMD) - return IPC_ENOMEM; - - /* Retrieve TMD */ - ret = ES_GetStoredTMD(TicketID, TMD, TMD_Length); - if (ret < 0) - { - free(TMD); - return ret; - } - - /* Set values */ - *Output = TMD; - *Length = TMD_Length; - - return 0; -} - -int check_priiloader() { - char filepath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(0x20); - static u64 titleId ATTRIBUTE_ALIGN(32) = 0x0000000100000002LL; - int ret = 0; - tmd *ptmd = NULL; - u32 TMD_size = 0; - signed_blob *stmd = NULL; - u32 i = 0; - u32 filesize = 0; - u8 *buffer = NULL; - const char* checkStr = "priiloader"; - int retValue = -1; - - ret = GetTMD(titleId, &stmd, &TMD_size); - - if (ret < 0) - goto end; - - if (!stmd) - { - ret = -1; - - goto end; - } - - ptmd = (tmd*)SIGNATURE_PAYLOAD(stmd); - - for (i = 0; i < ptmd->num_contents; i++) - { - if (ptmd->contents[i].index == ptmd->boot_index) - { - sprintf(filepath, "/title/%08x/%08x/content/%08x.app" , 0x00000001, 0x00000002, ptmd->contents[i].cid); - ret = NandReadFile(filepath, &buffer, &filesize); - if (ret < 0 || filesize < 0) { - retValue = -2; - goto end; - } - break; - } - } - - for (i = 0; i < filesize - strlen(checkStr); i++) - { - if (!strncmp((char*)buffer + i, checkStr, strlen(checkStr))) - { - retValue = 1; - - break; - } - } - -end: - free(buffer); - - free(stmd); - ptmd = NULL; - - priiloader = retValue; - return retValue; - -} // Check if this is an IOS stub (according to WiiBrew.org) bool IsKnownStub(u32 noIOS, s32 noRevision) @@ -201,12 +37,9 @@ bool IsKnownStub(u32 noIOS, s32 noRevision) if (noIOS == 254 && noRevision == 3) return true; if (noIOS == 254 && noRevision == 260) return true; - // BootMii As IOS is installed on IOS254 rev 31338 +// BootMii As IOS is installed on IOS254 rev 31338 if (noIOS == 254 && noRevision == 31338) return true; - // NAND Emu - if (noIOS == 253 && noRevision == 65535) return true; - return false; } @@ -230,10 +63,10 @@ int nextIos() ios_pos++; if(ios_pos > (signed)ioslist.size() -1) ios_pos = ioslist.size() -1; - + selectedIos= ioslist[ios_pos]; } - + return selectedIos; } int previousIos() @@ -243,10 +76,10 @@ int previousIos() ios_pos--; if(ios_pos < 0) ios_pos = 0; - + selectedIos= ioslist[ios_pos]; } - + return selectedIos; } @@ -254,12 +87,12 @@ bool listIOS() { if(ios_pos > 0) return true; - + ioslist.clear(); u32 nbTitles; if (ES_GetNumTitles(&nbTitles) < 0) return false; - + // Allocate the memory for titles u64 *titles = (u64*)memalign(32, nbTitles*sizeof(u64)); @@ -268,7 +101,7 @@ bool listIOS() if (ES_GetTitles(titles, nbTitles) < 0) return false; - + int i; u32 titleID; @@ -280,7 +113,7 @@ bool listIOS() // Skip the system menu titleID = titles[i] & 0xFFFFFFFF; - + if (titleID == 2) continue; // Skip BC, MIOS and possible other non-IOS titles @@ -288,14 +121,7 @@ bool listIOS() // Skip the running IOS if (titleID == 0) continue; - - // Skip NAND-Emu IOS - if (titleID == 253) - { - nandemu = 1; - continue; - } - + // Skip bootmii IOS if (titleID == 254) { @@ -319,13 +145,13 @@ bool listIOS() return false; iosTMD = (tmd *)SIGNATURE_PAYLOAD(iosTMDBuffer); - + free(iosTMDBuffer); // Get the title version u8 noVersion = iosTMD->title_version; bool isStub = false; - + // Check if this is an IOS stub (according to WiiBrew.org) if (IsKnownStub(titleID, iosTMD->title_version)) isStub = true; @@ -338,7 +164,7 @@ bool listIOS() // - Stub have one app of their own (type 0x1) and 2 shared apps (type 0x8001). if (noVersion == 0) isStub = ((iosTMD->num_contents == 3) && (iosTMD->contents[0].type == 1 && iosTMD->contents[1].type == 0x8001 && iosTMD->contents[2].type == 0x8001)); - else + else isStub = false; } @@ -348,7 +174,6 @@ bool listIOS() } std::sort( ioslist.begin(), ioslist.end() ); // sortieren return true; - } int SelectedIOS() @@ -374,32 +199,28 @@ int SearchAppIOS(std::string foldername) selectedIos = IOS_GetVersion(); getIosPos(selectedIos); } - + return selectedIos; } int GetAppIOS(std::string foldername) { + int GetIos = selectedIos; if(listIOS()) { + bool found = false; for(int i = 0; i < (signed)appios.size(); i++) { if(appios[i].foldername == foldername) - return appios[i].ios; + { + GetIos = appios[i].ios; + found = true; + break; + } } } - - return selectedIos; -} - -int get_priiloader() -{ - return priiloader; -} - -void set_priiloader(int choice) -{ - priiloader = choice; + + return GetIos; } int get_bootmii() @@ -411,13 +232,3 @@ void set_bootmii(int choice) { bootmii = choice; } - -int get_nandemu() -{ - return nandemu; -} - -void set_nandemu(int choice) -{ - nandemu = choice; -} diff --git a/source/Tools/SelectIos.h b/source/Tools/SelectIos.h index 2c50089..8ea2219 100644 --- a/source/Tools/SelectIos.h +++ b/source/Tools/SelectIos.h @@ -7,12 +7,5 @@ int previousIos(); int SelectedIOS(); int SearchAppIOS(std::string foldername); int GetAppIOS(std::string foldername); -int check_priiloader(); -s32 GetTMD(u64 TicketID, signed_blob **Output, u32 *Length); -s32 NandReadFile(char *filepath, u8 **buffer, u32 *filesize); -int get_priiloader(); int get_bootmii(); -int get_nandemu(); -void set_priiloader(int choice); -void set_bootmii(int choice); -void set_nandemu(int choice); +void set_bootmii(int choice); \ No newline at end of file diff --git a/source/Tools/TakeScreenshot.cpp b/source/Tools/TakeScreenshot.cpp index 2b0c660..601ce52 100644 --- a/source/Tools/TakeScreenshot.cpp +++ b/source/Tools/TakeScreenshot.cpp @@ -15,7 +15,7 @@ void Screenshot() bool Exists = false; folder_exists(); - pDir = opendir(check_path(Settings.device_dat + ":/config/HBF/Screenshots").c_str()); + pDir = opendir(check_path(Settings.device_dat + ":/config/Homebrew Filter/Screenshots").c_str()); if(pDir != NULL) { @@ -23,14 +23,14 @@ void Screenshot() closedir (pDir); } else - if(mkdir((Settings.device_dat + ":/config/HBF/Screenshots").c_str(), 777) != -1) + if(mkdir((Settings.device_dat + ":/config/Homebrew Filter/Screenshots").c_str(), 777) != -1) Exists = true; if(Exists) { while(!stop) { - sprintf (temp, "%s/%i.png", check_path(Settings.device_dat + ":/config/HBF/Screenshots").c_str(), i); + sprintf (temp, "%s/%i.png", check_path(Settings.device_dat + ":/config/Homebrew Filter/Screenshots").c_str(), i); FILE * f= fopen (temp,"r"); if (!f) stop = true; diff --git a/source/Tools/app_list.cpp b/source/Tools/app_list.cpp index 05c7d53..dd0e1b8 100644 --- a/source/Tools/app_list.cpp +++ b/source/Tools/app_list.cpp @@ -13,6 +13,7 @@ #include "libwiigui/gui.h" + #include "Prompts/prompts.h" /*** Extern variables ***/ extern GuiWindow * mainWindow; @@ -23,53 +24,55 @@ extern void HaltGui(); void add(string device, string apps_path) { - - DIR *pdir; + char dirname[MAXPATHLEN]; + DIR* dir; struct dirent *pent; - + struct stat statbuf; char pathnameelf[200]; char pathname[200]; - char pathmeta[200]; + char pFilename[200]; string pathboot; - - pdir=opendir((device + ":/" + apps_path).c_str()); - - if(pdir != NULL) + + dir = opendir ((device + ":/" + apps_path).c_str()); +/* + if(dir != NULL) { - while ((pent=readdir(pdir))!=NULL) + //get all dir names + while( (pent=readdir(dir)) !=NULL) +// while( dirnext (dir, dirname, &st) != -1 ) { - sprintf(pathnameelf, (device + ":/" + apps_path + "%s/boot.elf").c_str() ,pent->d_name); - sprintf(pathname, (device + ":/" + apps_path + "%s/boot.dol").c_str() ,pent->d_name); - + // stat(pent->d_name,&statbuf); + sprintf(pathnameelf, (device + ":/" + apps_path + "%s/boot.elf").c_str() ,dirname); + sprintf(pathname, (device + ":/" + apps_path + "%s/boot.dol").c_str() ,dirname); + if(fopen(pathnameelf, "rb") != NULL) pathboot = pathnameelf; if(fopen(pathname, "rb") != NULL) pathboot = pathname; - - if((fopen(pathname, "rb") || fopen(pathnameelf, "rb")) && strstr(pathname, (apps_path + "./").c_str()) == 0 - && strstr(pathname, (apps_path + "../").c_str()) == 0 && strcmp(pent->d_name, "NANDEmu-Boot") != 0) + + if((fopen(pathname, "rb") || fopen(pathnameelf, "rb")) && strstr(pathname, (apps_path + "./").c_str()) == 0 && strstr(pathname, (apps_path + "../").c_str()) == 0 ) { - sprintf(pathmeta, (device + ":/" + apps_path + "%s/meta.xml").c_str() ,pent->d_name); - + sprintf(pFilename, (device + ":/" + apps_path + "%s/meta.xml").c_str() ,dirname); + string line, quelltext, name, info, foldername, iconpath, arg; - ifstream in(pathmeta); + ifstream in(pFilename); while(getline(in, line)) quelltext = quelltext + line + "\n"; - + name = parser(quelltext, "", ""); - if(name == "\0") name = pent->d_name; - + if(name == "\0") name = dirname; + info = parser(quelltext, "", ""); if(info == "\0") info = tr(""); - - foldername = device + ":/" + apps_path + pent->d_name + "/"; + + foldername = device + ":/" + apps_path + dirname + "/"; transform(foldername.begin(), foldername.end(), foldername.begin(),::tolower); // in kleinebuchstaben umwandeln - + u8 *tempicon; u8 *icon = NULL; - + iconpath = foldername + "icon.png"; - + arg = parser(quelltext, "", ""); - + size_t amount_read; FILE *fp = fopen(iconpath.c_str(),"r"); //open the png file if(fp) //make sure the file exists @@ -78,7 +81,7 @@ void add(string device, string apps_path) fseek (fp , 0 , SEEK_END); filesize = ftell(fp); //find the file size rewind(fp); - + tempicon = new u8 [filesize]; //allocate memory for your image buffer if(tempicon) //make sure memory allocated { @@ -87,19 +90,19 @@ void add(string device, string apps_path) } } fclose(fp); //close file - + vechomebrew_list_category[0].push_back(homebrew_list(name, info, foldername, icon, pathboot, arg)); } } - closedir(pdir); - } + closedir(dir); + }*/ } void app_list() { vechomebrew_list_category[0].clear(); - - if(Settings.device == "sd1" || Settings.device == "usb1" || Settings.device == "dvd") + + if(Settings.device == "sd1" || Settings.device == "usb1") { if(Settings.system == 1) add(Settings.device, "apps/"); @@ -131,33 +134,12 @@ void app_list() add("usb1", "gc_apps/"); } } - else if(Settings.device == "all") - { - if(Settings.system == 1) - { - add("sd1", "apps/"); - add("usb1", "apps/"); - add("dvd", "apps/"); - } - else if(Settings.system == 0) - { - add("sd1", "gc_apps/"); - add("usb1", "gc_apps/"); - add("dvd", "gc_apps/"); - } - else if(Settings.system == 2) - { - add("sd1", "apps/"); - add("sd1", "gc_apps/"); - add("usb1", "apps/"); - add("usb1", "gc_apps/"); - add("dvd", "apps/"); - add("dvd", "gc_apps/"); - } - } - + // sortieren std::sort(vechomebrew_list_category[0].begin(),vechomebrew_list_category[0].end(), sort_name_a_z); + // suchen nach hbc + if(DetectHBC() != 0 && Settings.system != 0) + vechomebrew_list_category[0].insert(vechomebrew_list_category[0].begin(), homebrew_list("the homebrew channel", "the homebrew channel", "the homebrew channel", (u8*)hbc_icon_png, "the homebrew channel", "")); } diff --git a/source/Tools/category.cpp b/source/Tools/category.cpp index ca61873..fd05c16 100644 --- a/source/Tools/category.cpp +++ b/source/Tools/category.cpp @@ -46,7 +46,7 @@ void AvailableCategoryLoad(string pfad) AvailableCategory.apps[i].clear(); // Kategorie durchsuchen temp = source.erase(0,source.find("[") +1); - AvailableCategory.categories.push_back(source.substr(0, source.find("]"))); + AvailableCategory.categories.push_back(source.substr(0, source.find("]")).c_str()); temp = source.erase(0,source.find("]") +1); if((signed)temp.find("[") != -1) temp.erase(temp.find("[")); diff --git a/source/Tools/copy_app_in_category.cpp b/source/Tools/copy_app_in_category.cpp index e065946..42e8be1 100644 --- a/source/Tools/copy_app_in_category.cpp +++ b/source/Tools/copy_app_in_category.cpp @@ -6,31 +6,29 @@ void copy_app_in_unassigned() { vector apps; vechomebrew_list_unassigned.clear(); - + for(int a = 1; a < (signed)AvailableCategory.categories.size(); a++) for(int b = 0; b < (signed)AvailableCategory.apps[a].size(); b++) apps.push_back(AvailableCategory.apps[a][b]); - + for(int i = 0; i < (signed)vechomebrew_list_category[0].size(); i++) { bool present = true; - + int anzahl_device = 0, anzahl_ordner = 0; - + // Geräte SD, USB if(Settings.device == "sd1" || Settings.device == "usb1") anzahl_device = 1; else if(Settings.device == "sd_usb") anzahl_device = 2; - else if(Settings.device == "all") - anzahl_device = 3; - + // Ordner APPS, GC_APPS if(Settings.system == 1 || Settings.system == 0) anzahl_ordner = 1; else if(Settings.system == 2) anzahl_ordner = 2; - + for(int x = 0; x < anzahl_device; x++) { for(int y = 0; y < anzahl_ordner; y++) @@ -46,7 +44,7 @@ void copy_app_in_unassigned() ordner = ":/apps/"; else if(Settings.system == 2 && y == 1) ordner = ":/gc_apps/"; - + if(anzahl_device == 1) foldername = Settings.device + ordner + apps[a] + "/"; else @@ -55,10 +53,8 @@ void copy_app_in_unassigned() foldername = "sd1" + ordner + apps[a] + "/"; else if(x == 1) foldername = "usb1" + ordner + apps[a] + "/"; - else if(x == 2) - foldername = "dvd" + ordner + apps[a] + "/"; } - + if( strcasecmp(vechomebrew_list_category[0][i].foldername.c_str(), foldername.c_str()) == 0 || strcasecmp(vechomebrew_list_category[0][i].foldername.c_str(), "the homebrew channel") == 0 @@ -67,7 +63,7 @@ void copy_app_in_unassigned() } } } - + if(present) { vechomebrew_list_unassigned.push_back(homebrew_list( @@ -86,27 +82,26 @@ void copy_app_in_category(int category) //Apps im Kategorie kopieren { copy_app_in_unassigned(); vechomebrew_list_category[category].clear(); - + bool hbc = false; + for(int a = 0; a < (signed)AvailableCategory.apps[category].size(); a++) - { + { for(int i = 0; i < (signed)vechomebrew_list_category[0].size(); i++) { int anzahl_device = 0, anzahl_ordner = 0; - + // Geräte SD, USB if(Settings.device == "sd1" || Settings.device == "usb1") anzahl_device = 1; else if(Settings.device == "sd_usb") anzahl_device = 2; - else if(Settings.device == "all") - anzahl_device = 3; - + // Ordner APPS, GC_APPS if(Settings.system == 1 || Settings.system == 0) anzahl_ordner = 1; else if(Settings.system == 2) anzahl_ordner = 2; - + for(int x = 0; x < anzahl_device; x++ ) { for(int y = 0; y < anzahl_ordner; y++ ) @@ -120,7 +115,7 @@ void copy_app_in_category(int category) //Apps im Kategorie kopieren ordner = ":/apps/"; else if(Settings.system == 2 && y == 1) ordner = ":/gc_apps/"; - + if(anzahl_device == 1) foldername = Settings.device + ordner + AvailableCategory.apps[category][a] + "/"; else @@ -129,16 +124,18 @@ void copy_app_in_category(int category) //Apps im Kategorie kopieren foldername = "sd1" + ordner + AvailableCategory.apps[category][a] + "/"; else if(x == 1) foldername = "usb1" + ordner + AvailableCategory.apps[category][a] + "/"; - else if(x == 2) - foldername = "dvd" + ordner + AvailableCategory.apps[category][a] + "/"; } - + if( strcasecmp(vechomebrew_list_category[0][i].foldername.c_str(), foldername.c_str()) == 0 || strcasecmp(AvailableCategory.apps[category][a].c_str(), "the homebrew channel") == 0 ) { - + if(strcasecmp(AvailableCategory.apps[category][a].c_str(), "the homebrew channel") == 0 && !hbc) + hbc = true; + else if(strcasecmp(AvailableCategory.apps[category][a].c_str(), "the homebrew channel") == 0 && hbc) + break; + vechomebrew_list_category[category].push_back(homebrew_list( vechomebrew_list_category[0][i].name, vechomebrew_list_category[0][i].info, @@ -147,7 +144,7 @@ void copy_app_in_category(int category) //Apps im Kategorie kopieren vechomebrew_list_category[0][i].pathboot, vechomebrew_list_category[0][i].arg )); - + break; } } diff --git a/source/Tools/copy_app_in_category.h b/source/Tools/copy_app_in_category.h index 8f700e5..f551ca8 100644 --- a/source/Tools/copy_app_in_category.h +++ b/source/Tools/copy_app_in_category.h @@ -1,3 +1,4 @@ void copy_app_in_unassigned(); void copy_app_in_category(); +void copy_app_in_category(int category); diff --git a/source/Tools/fileop.cpp b/source/Tools/fileop.cpp index a46e7d0..a79f654 100644 --- a/source/Tools/fileop.cpp +++ b/source/Tools/fileop.cpp @@ -13,29 +13,23 @@ #include #include #include -#include #include #include #include -#include #include "fileop.h" #include "main.h" #include "Tools/app_list.h" #include "Tools/copy_app_in_category.h" #include "Tools/throbber.h" -#include "DiskOperations/iso.h" -#include "DiskOperations/di2.h" static const DISC_INTERFACE* sd = &__io_wiisd; static const DISC_INTERFACE* usb = &__io_usbstorage; -static const DISC_INTERFACE* dvd = &__io_wiidvd; enum { DEVICE_SD, - DEVICE_USB, - DEVICE_DVD + DEVICE_USB }; static char prefix[2][4] = { "sd", "usb" }; @@ -48,7 +42,7 @@ static char prefix[2][4] = { "sd", "usb" }; #define le32_to_cpu(x) bswap32(x) -#define BYTES_PER_SECTOR 4096 +#define BYTES_PER_SECTOR 512 #define NTFS_OEM_ID (0x4e54465320202020ULL) #define PARTITION_TYPE_EMPTY 0x00 /* Empty */ @@ -56,11 +50,6 @@ static char prefix[2][4] = { "sd", "usb" }; #define PARTITION_TYPE_NTFS 0x07 /* Windows NT NTFS */ #define PARTITION_TYPE_WIN95_EXTENDED 0x0F /* Windows 95 extended partition */ -#define PARTITION_TYPE_LINUX 0x83 /* GNU/Linux partition */ -#define PARTITION_TYPE_LINUX_SWAP 0x82 /* GNU/Linux Swap partition */ -#define PARTITION_TYPE_LINUX_LVM 0x8e /* GNU/Linux logical volume manager partition */ -#define PARTITION_TYPE_LINUX_LUKS 0xe8 /* GNU/Linux LUKS partition */ - #define PARTITION_STATUS_NONBOOTABLE 0x00 /* Non-bootable */ #define PARTITION_STATUS_BOOTABLE 0x80 /* Bootable (active) */ @@ -70,10 +59,8 @@ static char prefix[2][4] = { "sd", "usb" }; #define BPB_FAT16_fileSysType 0x36 #define BPB_FAT32_fileSysType 0x52 -#define T_FAT 1 -#define T_NTFS 2 -#define T_EXT2 3 -#define T_ISO9660 4 +#define T_FAT 1 +#define T_NTFS 2 static const char FAT_SIG[3] = {'F', 'A', 'T'}; @@ -169,14 +156,8 @@ static void AddPartition(sec_t sector, int device, int type, int *devnum) DISC_INTERFACE *disc = (DISC_INTERFACE *)sd; - if (device == DEVICE_USB) - { + if(device == DEVICE_USB) disc = (DISC_INTERFACE *)usb; - } - else if (device == DEVICE_DVD) - { - disc = (DISC_INTERFACE *)dvd; - } char mount[10]; sprintf(mount, "%s%i", prefix[device], *devnum+1); @@ -187,7 +168,7 @@ static void AddPartition(sec_t sector, int device, int type, int *devnum) return; fatGetVolumeLabel(mount, part[device][*devnum].name); } - else if (type == T_NTFS) + else { if(!ntfsMount(mount, disc, sector, 8, 64, NTFS_DEFAULT | NTFS_RECOVER)) return; @@ -199,27 +180,6 @@ static void AddPartition(sec_t sector, int device, int type, int *devnum) else part[device][*devnum].name[0] = 0; } - else if (type == T_EXT2) - { - if(!ext2Mount(mount, disc, sector, 8, 64, EXT2_FLAG_64BITS | EXT2_FLAG_JOURNAL_DEV_OK)) - return; - - const char *name = ext2GetVolumeName(mount); - - if(name) - strcpy(part[device][*devnum].name, name); - else - part[device][*devnum].name[0] = 0; - } - else if (type == T_ISO9660) - { - - if (!MountDVD()) - return; - - strcpy(part[device][*devnum].name, "DVD"); - - } strcpy(part[device][*devnum].mount, mount); part[device][*devnum].type = type; @@ -284,7 +244,7 @@ static int FindPartitions(int device) part_lba = le32_to_cpu(mbr.partitions[i].lba_start); debug_printf( - "Partition %i: %s, sector %u, type 0x%x\n", + "Partition %i: %s, sector %lu, type 0x%x\n", i + 1, partition->status == PARTITION_STATUS_BOOTABLE ? "bootable (active)" : "non-bootable", part_lba, partition->type); @@ -332,7 +292,7 @@ static int FindPartitions(int device) if (sector.ebr.signature == EBR_SIGNATURE) { debug_printf( - "Logical Partition @ %d: %s type 0x%x\n", + "Logical Partition @ %d: type 0x%x\n", ebr_lba + next_erb_lba, sector.ebr.partition.status == PARTITION_STATUS_BOOTABLE ? "bootable (active)" @@ -347,13 +307,8 @@ static int FindPartitions(int device) next_erb_lba = le32_to_cpu( sector.ebr.next_ebr.lba_start); - if(sector.ebr.partition.type==PARTITION_TYPE_LINUX) - { - debug_printf("Partition : type EXT2/3/4 found\n"); - AddPartition(part_lba, device, T_EXT2, &devnum); - } // Check if this partition has a valid NTFS boot record - else if (interface->readSectors(part_lba, 1, §or)) + if (interface->readSectors(part_lba, 1, §or)) { if (sector.boot.oem_id == NTFS_OEM_ID) { @@ -392,15 +347,6 @@ static int FindPartitions(int device) break; } - case PARTITION_TYPE_LINUX: - { - debug_printf("Partition %i: Claims to be LINUX\n", i + 1); - - // Read and validate the EXT2 partition - AddPartition(part_lba, device, T_EXT2, &devnum); - break; - } - // Ignore empty partitions case PARTITION_TYPE_EMPTY: debug_printf("Partition %i: Claims to be empty\n", i + 1); @@ -431,11 +377,6 @@ static int FindPartitions(int device) debug_printf("Partition : Valid FAT boot sector found\n"); AddPartition(part_lba, device, T_FAT, &devnum); } - else - { - debug_printf("Trying : EXT partition\n"); - AddPartition(part_lba, device, T_EXT2, &devnum); - } } break; } @@ -465,11 +406,6 @@ static int FindPartitions(int device) AddPartition(i, device, T_FAT, &devnum); break; } - else - { - debug_printf("Trying : EXT partition\n"); - AddPartition(part_lba, device, T_EXT2, &devnum); - } } } } @@ -485,29 +421,14 @@ static void UnmountPartitions(int device) { if(part[device][i].type == T_FAT) { - sprintf(mount, "VFAT: %s:", part[device][i].mount); + sprintf(mount, "%s:", part[device][i].mount); fatUnmount(mount); - break; } else if(part[device][i].type == T_NTFS) { - sprintf(mount, "NTFS: %s:", part[device][i].mount); ntfsUnmount(part[device][i].mount, false); - break; } - else if(part[device][i].type == T_EXT2) - { - sprintf(mount, "EXT2: %s:", part[device][i].mount); - ext2Unmount(part[device][i].mount); - break; - } - else if(part[device][i].type == T_ISO9660) - { - sprintf(mount, "ISO9660: %s:", part[device][i].mount); - UnMountDVD(); - break; - } - + part[device][i].name[0] = 0; part[device][i].mount[0] = 0; part[device][i].sector = 0; @@ -515,18 +436,24 @@ static void UnmountPartitions(int device) part[device][i].type = 0; } + if(device == DEVICE_SD) + sd->shutdown(); + else + { + usb->shutdown(); + USB_Deinitialize(); + } } /**************************************************************************** * MountPartitions - * + * * Shuts down the device * Attempts to startup the device specified and mounts all partitions ***************************************************************************/ static bool MountPartitions(int device) { - const DISC_INTERFACE* disc = NULL; switch(device) @@ -537,9 +464,6 @@ static bool MountPartitions(int device) case DEVICE_USB: disc = usb; break; - case DEVICE_DVD: - disc = dvd; - break; default: return false; // unknown device } @@ -554,72 +478,11 @@ void MountAllDevices() { if(sd->startup() && sd->isInserted()) MountPartitions(DEVICE_SD); - + usleep(250000); // 1/4 sec if(usb->startup() && usb->isInserted()) MountPartitions(DEVICE_USB); - - usleep(250000); // 1/4 sec - - if(dvd->startup() && dvd->isInserted()) - MountDVD(); -} - -bool MountDVDFS() -{ - bool devicemounted = ISO9660_Mount(); - - /*if(!devicemounted) - devicemounted = FST_Mount(); - if(!devicemounted) - devicemounted = GCFST_Mount();*/ - - return devicemounted; -} - -void UnMountDVD() -{ - - ISO9660_Unmount(); -} - -bool MountDVD() -{ - if(!DVD_Inserted()) - return false; - - char read_buffer[2048]; - if(DI2_ReadDVD(read_buffer, 1, 0) == 0) - return true; - - UnMountDVD(); - DI2_Mount(); - - time_t timer1, timer2; - timer1 = time(0); - - while(DI2_GetStatus() & DVD_INIT) - { - timer2 = time(0); - if(timer2-timer1 > 15) - return false; - - usleep(5000); - } - - return MountDVDFS(); -} - -bool DVD_Inserted() -{ - uint32_t cover = 0; - DI2_GetCoverRegister(&cover); - - if(cover & DVD_COVER_DISC_INSERTED) - return true; - - return false; } void UnmountAllDevices() @@ -637,7 +500,7 @@ void check_sd() { if(Settings.sd_insert <= 0) { - + if(sd->startup() && sd->isInserted()) // wenn sd karte gefunden, neu einlesen { MountPartitions(DEVICE_SD); @@ -646,7 +509,7 @@ void check_sd() } else if(Settings.sd_insert == 1) { - if(!SDCard_Inserted()) // wenn sd karte nicht gefunden, beenden + if(!SDCard_Inserted()) // wenn sd karte nicht gefunden, beenden { UnmountPartitions(DEVICE_SD); Settings.sd_insert = -1; @@ -663,7 +526,7 @@ void check_usb() { if(Settings.usb_insert <= 0) { - if(usb->startup() && usb->isInserted()) // wenn usb gerät gefunden, neu einlesen + if(usb->startup() && usb->isInserted()) // wenn usb gerät gefunden, neu einlesen { MountPartitions(DEVICE_USB); Settings.usb_insert = 2; @@ -671,7 +534,7 @@ void check_usb() } else if(Settings.usb_insert == 1) { - if(!USBDevice_Inserted()) // wenn usb gerät nicht mehr gefunden, beenden + if(!USBDevice_Inserted()) // wenn usb gerät nicht mehr gefunden, beenden { UnmountPartitions(DEVICE_USB); Settings.usb_insert = -1; @@ -679,27 +542,6 @@ void check_usb() } } -void check_dvd() -{ - if(Settings.dvd_insert <= 0) - { - - if(DVD_Inserted()) // wenn dvd gefunden, neu einlesen - { - MountDVD(); - Settings.dvd_insert = 2; - } - } - else if(Settings.dvd_insert == 1) - { - if(!DVD_Inserted()) // wenn dvd nicht gefunden, beenden - { - UnMountDVD(); - Settings.dvd_insert = -1; - } - } -} - void check_device() { ResumeThrobberThread(); @@ -710,37 +552,32 @@ void check_device() copy_app_in_category(); else copy_app_in_unassigned(); - + if(Settings.sd_insert == 2) Settings.sd_insert = 1; else if(Settings.sd_insert == -1) Settings.sd_insert = 0; - + if(Settings.usb_insert == 2) Settings.usb_insert = 1; else if(Settings.usb_insert == -1) Settings.usb_insert = 0; - - if(Settings.dvd_insert == 2) - Settings.dvd_insert = 1; - else if(Settings.dvd_insert == -1) - Settings.dvd_insert = 0; - + HaltThrobberThread(); } string check_path(string old_path) -{ +{ DIR *dirHandle; struct dirent * dirEntry; - + if(old_path.length() > 0 && old_path.substr(old_path.length() -1) != "/") old_path += "/"; string new_path = old_path.substr(0, old_path.find(":/") +2); old_path.erase(0, old_path.find("/") +1); string search; - + while((signed)old_path.find("/") != -1) { search = old_path.substr(0, old_path.find("/")); @@ -759,7 +596,7 @@ string check_path(string old_path) new_path += "/"; closedir(dirHandle); } - + old_path.erase(0, old_path.find("/") +1); } diff --git a/source/Tools/fileop.h b/source/Tools/fileop.h index ffc8615..d195ba3 100644 --- a/source/Tools/fileop.h +++ b/source/Tools/fileop.h @@ -34,12 +34,6 @@ extern DEVICE_STRUCT part[2][MAX_DEVICES]; void MountAllDevices(); void UnmountAllDevices(); -bool MountDVD(); -bool MountDVDFS(); -void UnMountDVD(); -bool DVD_Inserted(); -void check_dvd(); - /* //!USB FAT Controls int USBDevice_Init(); diff --git a/source/Tools/load.cpp b/source/Tools/load.cpp index 974346b..beb6409 100644 --- a/source/Tools/load.cpp +++ b/source/Tools/load.cpp @@ -53,13 +53,13 @@ void load() if (get_setting(source, "theme") != "") { sprintf (Options.theme, get_setting(source, "theme").c_str()); - theme(check_path(Settings.device_dat + ":/config/HBF/themes/") + Options.theme + "/"); + theme(check_path(Settings.device_dat + ":/config/Homebrew Filter/themes/") + Options.theme + "/"); } if(get_setting(source, "language") != "") { sprintf (Options.language, get_setting(source, "language").c_str()); - ini_Open(check_path(Settings.device_dat + ":/config/HBF/languages/") + Options.language + ".lang"); + ini_Open(check_path(Settings.device_dat + ":/config/Homebrew Filter/languages/") + Options.language + ".lang"); AvailableCategory.categories[0] = tr(Settings.category_name_all); } @@ -96,10 +96,10 @@ void load() if(get_setting(source, "quick_start") != "") Options.quick_start = atoi(get_setting(source, "quick_start").c_str()); - + if(get_setting(source, "show_all") != "") Options.show_all = atoi(get_setting(source, "show_all").c_str()); - + if(get_setting(source, "navigation") != "") Options.navigation = atoi(get_setting(source, "navigation").c_str()); @@ -122,7 +122,7 @@ void load() } if(get_setting(source, "grid") != "") - Settings.grid = atoi(get_setting(source, "grid").c_str()); + Settings.view = atoi(get_setting(source, "grid").c_str()); if(get_setting(source, "device") != "") Settings.device = get_setting(source, "device"); diff --git a/source/Tools/load_channel.cpp b/source/Tools/load_channel.cpp index 2ae0332..9954c6d 100644 --- a/source/Tools/load_channel.cpp +++ b/source/Tools/load_channel.cpp @@ -8,6 +8,8 @@ #include "filelist.h" using namespace std; +string HBC_version; + template s8 free_pointer(pointer*& ptr) { @@ -18,7 +20,7 @@ s8 free_pointer(pointer*& ptr) //protection incase empty type was given memset(ptr,0,sizeof(pointer)); } - free(ptr); + free(ptr); ptr = NULL; return 0; } @@ -28,6 +30,108 @@ s8 free_pointer(pointer*& ptr) } } +char * DetectHBC_version(const tmd *t) +{ + static char desc[10]; + if (t->title_version) + snprintf(desc, sizeof(desc), "%d.%d", t->title_version >> 8, t->title_version & 0xFF); +/* if (t->sys_version) + snprintf(desc, sizeof(desc), "%s FW: IOS%llu ", desc, t->sys_version & 0xff); +*/ + return desc; +} + +u64 DetectHBC() +{ + u64 *list; + u32 titlecount; + s32 ret; + + vector TitleID; + TitleID.push_back(0x0001000148415858LL); //HAXX + TitleID.push_back(0x000100014A4F4449LL); //JODI + TitleID.push_back(0x00010001AF1BF516LL); //>=0.7 + + + ret = ES_GetNumTitles(&titlecount); + if(ret < 0) + { + printf("DetectHBC: ES_GetNumTitles Fehler\n"); + return 0; + } + + list = (u64*)memalign(32, titlecount * sizeof(u64) + 32); + + ret = ES_GetTitles(list, titlecount); + if(ret < 0) { + printf("DetectHBC: ES_GetTitles Error\n"); + free_pointer(list); + return 0; + } + ret = 0; + + //lets check for known HBC title id's. + for(u32 i=0; i=0.7 + { + if(ret < 3) + { + ret = 3; + HBC_version = DetectHBC_version((tmd *)SIGNATURE_PAYLOAD(s_tmd)); + } + } + } + free_pointer(list); + if(ret != 0) + return TitleID[ret -1]; + else + printf("ERROR_FIND_HBC\n"); + + return 0; +} + +void LoadHBC() +{ + u64 TitleID = DetectHBC(); + if(TitleID != 0) + { + u32 cnt ATTRIBUTE_ALIGN(32); + ES_GetNumTicketViews(TitleID, &cnt); + tikview *views = (tikview *)memalign( 32, sizeof(tikview)*cnt ); + ES_GetTicketViews(TitleID, views, cnt); + ES_LaunchTitle(TitleID, &views[0]); + } + else + { + //well that went wrong + printf("ERROR_BOOT_HBC\n"); + } + +} + bool CheckAppFound(u64 title) { @@ -67,7 +171,7 @@ int DetectHBF() u64 *list; u32 titlecount; int ret; - + vector TitleID; TitleID.push_back(0x0001000154484246LL); //THBF // TitleID.push_back(0x0001000148424630LL); //HBF0 @@ -88,9 +192,9 @@ int DetectHBF() return 0; } ret = 0; - + //lets check for known HBF title id's. - for(u32 i=0; i 0) { tree = mxmlLoadFile(NULL, fp, MXML_NO_CALLBACK); fclose(fp); - + data = mxmlFindElement(tree, tree, "#color#", NULL, NULL, MXML_DESCEND); - + if (mxmlElementGetAttr(data,"category")) { Theme.category_1 = split(mxmlElementGetAttr(data,"category"), 1); Theme.category_2 = split(mxmlElementGetAttr(data,"category"), 2); Theme.category_3 = split(mxmlElementGetAttr(data,"category"), 3); } - + if (mxmlElementGetAttr(data,"page")) { Theme.page_1 = split(mxmlElementGetAttr(data,"page"), 1); Theme.page_2 = split(mxmlElementGetAttr(data,"page"), 2); Theme.page_3 = split(mxmlElementGetAttr(data,"page"), 3); } - + if (mxmlElementGetAttr(data,"owner")) { Theme.owner_1 = split(mxmlElementGetAttr(data,"owner"), 1); Theme.owner_2 = split(mxmlElementGetAttr(data,"owner"), 2); Theme.owner_3 = split(mxmlElementGetAttr(data,"owner"), 3); } - + if (mxmlElementGetAttr(data,"title")) { Theme.title_1 = split(mxmlElementGetAttr(data,"title"), 1); Theme.title_2 = split(mxmlElementGetAttr(data,"title"), 2); Theme.title_3 = split(mxmlElementGetAttr(data,"title"), 3); } - + if (mxmlElementGetAttr(data,"program_name")) { Theme.program_name_1 = split(mxmlElementGetAttr(data,"program_name"), 1); Theme.program_name_2 = split(mxmlElementGetAttr(data,"program_name"), 2); Theme.program_name_3 = split(mxmlElementGetAttr(data,"program_name"), 3); } - + if (mxmlElementGetAttr(data,"apps")) { Theme.apps_1 = split(mxmlElementGetAttr(data,"apps"), 1); Theme.apps_2 = split(mxmlElementGetAttr(data,"apps"), 2); Theme.apps_3 = split(mxmlElementGetAttr(data,"apps"), 3); } - + if (mxmlElementGetAttr(data,"text")) { Theme.text_1 = split(mxmlElementGetAttr(data,"text"), 1); Theme.text_2 = split(mxmlElementGetAttr(data,"text"), 2); Theme.text_3 = split(mxmlElementGetAttr(data,"text"), 3); } - + if (mxmlElementGetAttr(data,"button_small_text")) { Theme.button_small_text_1 = split(mxmlElementGetAttr(data,"button_small_text"), 1); Theme.button_small_text_2 = split(mxmlElementGetAttr(data,"button_small_text"), 2); Theme.button_small_text_3 = split(mxmlElementGetAttr(data,"button_small_text"), 3); } - + if (mxmlElementGetAttr(data,"button_tiny_text")) { Theme.button_tiny_text_1 = split(mxmlElementGetAttr(data,"button_tiny_text"), 1); Theme.button_tiny_text_2 = split(mxmlElementGetAttr(data,"button_tiny_text"), 2); Theme.button_tiny_text_3 = split(mxmlElementGetAttr(data,"button_tiny_text"), 3); } - + if (mxmlElementGetAttr(data,"progressbar_color1")) { Theme.progressbar_color1_1 = split(mxmlElementGetAttr(data,"progressbar_color1"), 1); Theme.progressbar_color1_2 = split(mxmlElementGetAttr(data,"progressbar_color1"), 2); Theme.progressbar_color1_3 = split(mxmlElementGetAttr(data,"progressbar_color1"), 3); } - + if (mxmlElementGetAttr(data,"progressbar_color2")) { Theme.progressbar_color2_1 = split(mxmlElementGetAttr(data,"progressbar_color2"), 1); Theme.progressbar_color2_2 = split(mxmlElementGetAttr(data,"progressbar_color2"), 2); Theme.progressbar_color2_3 = split(mxmlElementGetAttr(data,"progressbar_color2"), 3); } - + mxmlDelete(data); mxmlDelete(tree); } @@ -338,11 +338,11 @@ bool theme_folder_exists(string theme) DIR *pDir; folder_exists(); - pDir = opendir(check_path(Settings.device_dat + ":/config/HBF/Themes").c_str()); + pDir = opendir(check_path(Settings.device_dat + ":/config/Homebrew Filter/Themes").c_str()); if(pDir != NULL) { - pDir = opendir(check_path(Settings.device_dat + ":/config/HBF/Themes/" + theme).c_str()); + pDir = opendir(check_path(Settings.device_dat + ":/config/Homebrew Filter/Themes/" + theme).c_str()); if(pDir != NULL) { closedir (pDir); @@ -350,7 +350,7 @@ bool theme_folder_exists(string theme) } else { - if (mkdir((Settings.device_dat + ":/config/HBF/Themes/" + theme).c_str(), 0777) != -1) + if (mkdir((Settings.device_dat + ":/config/Homebrew Filter/Themes/" + theme).c_str(), 0777) != -1) { closedir (pDir); return true; @@ -359,9 +359,9 @@ bool theme_folder_exists(string theme) } else { - if (mkdir((Settings.device_dat + ":/config/HBF/Themes").c_str(), 0777) != -1) + if (mkdir((Settings.device_dat + ":/config/Homebrew Filter/Themes").c_str(), 0777) != -1) { - if (mkdir((Settings.device_dat + ":/config/HBF/Themes/" + theme).c_str(), 0777) != -1) + if (mkdir((Settings.device_dat + ":/config/Homebrew Filter/Themes/" + theme).c_str(), 0777) != -1) { closedir (pDir); return true; @@ -370,4 +370,4 @@ bool theme_folder_exists(string theme) } closedir (pDir); return false; -} +} \ No newline at end of file diff --git a/source/Tools/theme.h b/source/Tools/theme.h index f045c6e..708363a 100644 --- a/source/Tools/theme.h +++ b/source/Tools/theme.h @@ -32,23 +32,18 @@ struct STheme const u8* dialog_background; const u8* throbber; const u8* choice; - const u8* choice_large; const u8* sd_active; const u8* sd_inactive; const u8* usb_active; const u8* usb_inactive; const u8* sd_usb_active; const u8* sd_usb_inactive; - const u8* dvd_active; - const u8* dvd_inactive; - const u8* all_active; - const u8* all_inactive; - const u8* loader_active; - const u8* loader_inactive; const u8* wii_active; const u8* wii_inactive; const u8* gc_active; const u8* gc_inactive; + const u8* pc_active; + const u8* pc_inactive; const u8* wii_gc_active; const u8* wii_gc_inactive; const u8* power_active; @@ -71,6 +66,11 @@ struct STheme const u8* player_grab; const u8* bg_options; const u8* bg_options_entry; + const u8* bar; + const u8* desktop; + const u8* startmenu; + const u8* startmenu_top; + const u8* menu_selection; const u8* scrollbar; const u8* scrollbar_arrowdown; const u8* scrollbar_arrowdown_over; diff --git a/source/Tools/translate.cpp b/source/Tools/translate.cpp index 14bc2dc..bbc3697 100644 --- a/source/Tools/translate.cpp +++ b/source/Tools/translate.cpp @@ -69,15 +69,15 @@ const char* tr(string translate) void translate() { if(CONF_GetLanguage() == JAPANESE) - ini_Open(check_path(Settings.device_dat + ":/config/HBF/languages/") + "japanese.lang"); + ini_Open(check_path(Settings.device_dat + ":/config/Homebrew Filter/languages/") + "japanese.lang"); else if(CONF_GetLanguage() == ENGLISH) - ini_Open(check_path(Settings.device_dat + ":/config/HBF/languages/") + "english.lang"); + ini_Open(check_path(Settings.device_dat + ":/config/Homebrew Filter/languages/") + "english.lang"); else if(CONF_GetLanguage() == GERMAN) - ini_Open(check_path(Settings.device_dat + ":/config/HBF/languages/") + "german.lang"); + ini_Open(check_path(Settings.device_dat + ":/config/Homebrew Filter/languages/") + "german.lang"); else if(CONF_GetLanguage() == FRENCH) - ini_Open(check_path(Settings.device_dat + ":/config/HBF/languages/") + "french.lang"); + ini_Open(check_path(Settings.device_dat + ":/config/Homebrew Filter/languages/") + "french.lang"); else if(CONF_GetLanguage() == SPANISH) - ini_Open(check_path(Settings.device_dat + ":/config/HBF/languages/") + "spanish.lang"); + ini_Open(check_path(Settings.device_dat + ":/config/Homebrew Filter/languages/") + "spanish.lang"); } bool language_folder_exists() @@ -87,7 +87,7 @@ bool language_folder_exists() { DIR *pDir; - pDir = opendir(check_path(Settings.device_dat + ":/config/HBF/Languages").c_str()); + pDir = opendir(check_path(Settings.device_dat + ":/config/Homebrew Filter/Languages").c_str()); if(pDir != NULL) { @@ -96,7 +96,7 @@ bool language_folder_exists() } else { - if (mkdir((Settings.device_dat + ":/config/HBF/Languages").c_str(), 0777) != -1) + if (mkdir((Settings.device_dat + ":/config/Homebrew Filter/Languages").c_str(), 0777) != -1) { closedir (pDir); return true; diff --git a/source/filelist.h b/source/filelist.h index b359548..f4dab76 100644 --- a/source/filelist.h +++ b/source/filelist.h @@ -38,12 +38,6 @@ extern const u32 button_square_png_size; extern const u8 button_square_focus_png[]; extern const u32 button_square_focus_png_size; -extern const u8 button_large_png[]; -extern const u32 button_large_png_size; - -extern const u8 button_large_over_png[]; -extern const u32 button_large_over_png_size; - extern const u8 dialog_background_png[]; extern const u32 dialog_background_png_size; @@ -170,9 +164,6 @@ extern const u32 throbber_png_size; extern const u8 choice_png[]; extern const u32 choice_png_size; -extern const u8 choice_large_png[]; -extern const u32 choice_large_png_size; - extern const u8 sd_active_png[]; extern const u32 sd_active_png_size; @@ -191,24 +182,6 @@ extern const u32 sd_usb_active_png_size; extern const u8 sd_usb_inactive_png[]; extern const u32 sd_usb_inactive_png_size; -extern const u8 dvd_active_png[]; -extern const u32 dvd_active_png_size; - -extern const u8 all_active_png[]; -extern const u32 all_active_png_size; - -extern const u8 dvd_inactive_png[]; -extern const u32 dvd_inactive_png_size; - -extern const u8 all_inactive_png[]; -extern const u32 all_inactive_png_size; - -extern const u8 loader_active_png[]; -extern const u32 loader_active_png_size; - -extern const u8 loader_inactive_png[]; -extern const u32 loader_inactive_png_size; - extern const u8 wii_active_png[]; extern const u32 wii_active_png_size; @@ -221,6 +194,12 @@ extern const u32 gc_active_png_size; extern const u8 gc_inactive_png[]; extern const u32 gc_inactive_png_size; +extern const u8 pc_active_png[]; +extern const u32 pc_active_png_size; + +extern const u8 pc_inactive_png[]; +extern const u32 pc_inactive_png_size; + extern const u8 wii_gc_active_png[]; extern const u32 wii_gc_active_png_size; @@ -269,12 +248,30 @@ extern const u32 edit_active_png_size; extern const u8 edit_inactive_png[]; extern const u32 edit_inactive_png_size; +extern const u8 hbc_icon_png[]; +extern const u32 hbc_icon_png_size; + extern const u8 recycle_bin_png[]; extern const u32 recycle_bin_png_size; extern const u8 progress_png[]; extern const u32 progress_png_size; +extern const u8 bar_png[]; +extern const u32 bar_png_size; + +extern const u8 desktop_png[]; +extern const u32 desktop_png_size; + +extern const u8 startmenu_png[]; +extern const u32 startmenu_png_size; + +extern const u8 startmenu_top_png[]; +extern const u32 startmenu_top_png_size; + +extern const u8 menu_selection_png[]; +extern const u32 menu_selection_png_size; + extern const u8 LogoHomebrewFilter_png[]; extern const u32 LogoHomebrewFilter_png_size; diff --git a/source/main.cpp b/source/main.cpp index 446aeee..c08397d 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -15,7 +15,6 @@ #include #include #include -#include //#include "audio.h" #include "filelist.h" @@ -31,11 +30,10 @@ #include "Tools/save.h" #include "Tools/SelectIos.h" #include "Tools/throbber.h" +//#include "Memory/mem2.h" #include "Network/network.h" #include "Network/tcp.h" #include "BootHomebrew/BootHomebrew.h" -#include "BootHomebrew/dolloader.h" -#include "DiskOperations/di2.h" #define HAVE_AHBPROT ((*(vu32*)0xcd800064 == 0xFFFFFFFF) ? 1 : 0) @@ -49,6 +47,7 @@ extern void ResumeGui(); std::vector vechomebrew_list_category[99]; std::vector vechomebrew_list_unassigned; std::vector vechomebrew_list_choice; +//std::vector vechomebrew_list_pc; std::vector appios; struct SSettings Settings; @@ -58,7 +57,6 @@ int ExitRequested = 0; s8 PowerOff = -1; bool boothomebrew = false; bool boot_buffer = false; -bool wiiload = false; // kopiere ios für app in einen vector void addAppIos(string foldername, int ios) @@ -80,7 +78,7 @@ void addAppIos(string foldername, int ios) if(found) appios[i].ios = ios; if(!found) - appios.push_back(app_ios(foldername, ios)); + appios.push_back(app_ios(foldername, ios)); } } @@ -88,10 +86,11 @@ void ExitApp() { ShutdownPads(); StopGX(); - //if(strcasecmp(Settings.code,"NULL") == 0) + if(strcasecmp(Settings.code,"NULL") == 0) save(); - UnmountAllDevices(); + UnmountAllDevices(); ISFS_Deinitialize(); +// MEM2_cleanup(); } static void WiiResetPressed() @@ -114,7 +113,6 @@ DefaultSettings() { Settings.sd_insert = SDCard_Inserted(); Settings.usb_insert = USBDevice_Inserted(); - Settings.dvd_insert = DVD_Inserted(); Settings.category_name_all = "All"; sprintf (Settings.new_category_name, "New Category"); Settings.current_category = 0; @@ -122,19 +120,10 @@ DefaultSettings() Settings.last_app_pos = -1; Settings.checkrev = -1; sprintf (Settings.code, "NULL"); - - // in kleinbuchstaben umwandeln -/* transform(Settings.MyDir.begin(),Settings.MyDir.end(),Settings.MyDir.begin(),::tolower); - if(Settings.MyDir.substr(0, Settings.MyDir.find(":/")) == "sd") - Settings.MyPath = "sd1" + Settings.MyDir.substr(Settings.MyDir.find(":/"), Settings.MyDir.rfind("/") - Settings.MyDir.find(":/") +1); - else if(Settings.MyDir.substr(0, Settings.MyDir.find(":/")) == "usb") - Settings.MyPath = "usb1" + Settings.MyDir.substr(Settings.MyDir.find(":/"), Settings.MyDir.rfind("/") - Settings.MyDir.find(":/") +1); - else - Settings.MyPath = Settings.MyDir.substr(0, Settings.MyDir.rfind("/") +1); -*/ + Settings.Apps_from = EFFECT_SLIDE_TOP; // Apps kommen von "EFFECT_SLIDE_TOP", "EFFECT_SLIDE_BOTTOM", "EFFECT_SLIDE_RIGHT", "EFFECT_SLIDE_LEFT" Settings.Apps_to = 0; // Apps geht nach "EFFECT_SLIDE_TOP", "EFFECT_SLIDE_BOTTOM", "EFFECT_SLIDE_RIGHT", "EFFECT_SLIDE_LEFT" - Settings.grid = false; + Settings.view = 0; Settings.system = 1; Settings.device = "sd1"; Settings.device_dat = "sd1"; @@ -147,13 +136,13 @@ DefaultOptions() sprintf (Options.language, tr("STANDARD")); sprintf (Options.font, tr("STANDARD")); sprintf (Options.temp_code, "NULL"); - + Options.slide_effect = 1; Options.last_category = 1; - Options.apps = 4; - Options.quick_start = 0; - Options.show_all = 1; - Options.navigation = 0; + Options.apps = 4; + Options.quick_start = 0; + Options.show_all = 1; + Options.navigation = 0; Options.temp_network = 0; Options.temp_newrevtext = 1; } @@ -161,7 +150,6 @@ DefaultOptions() int main(int argc, char *argv[]) { - SYS_SetResetCallback(WiiResetPressed); SYS_SetPowerCallback(WiiPowerPressed); WPAD_SetPowerButtonCallback(WiimotePowerPressed); @@ -170,15 +158,15 @@ main(int argc, char *argv[]) SetupPads(); // Initialize input // InitAudio(); // Initialize audio InitGUIThreads(); // Initialize GUI - //DI2_Init(); // Initialize DVD MountAllDevices(); InitNetworkThread(); // Initialize Network InitTcpThread(); InitThrobberThread(); // Initialize Throbber ISFS_Initialize(); // Initialize Nand +// MEM2_init(52); // Initialize 52 MB (max is 53469152 bytes though) - LoadHBF(); - +// LoadHBF(); + DefaultSettings(); DefaultOptions(); DefaultTheme(); @@ -188,77 +176,71 @@ main(int argc, char *argv[]) ResumeNetworkThread(); SetFont(); - + #ifdef HW_RVL pointer = new GuiImageData(Theme.player_point); #endif - + mainWindow = new GuiWindow(screenwidth, screenheight); - + GuiTrigger trigA; trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - + ResumeGui(); + debug("test1"); + stretch(Settings.top, Settings.bottom, Settings.left, Settings.right); - + if(HAVE_AHBPROT) runtimePatchApply(); - - DI2_Init(); // Init DVD - + if(strstr(Options.language, tr("STANDARD"))) translate(); - + AvailableCategory.categories[0] = tr(Settings.category_name_all); check_device(); + +/* while(1) + { + WPAD_ScanPads(); + if(PowerOff != -1) + { + char buffer[20]; + sprintf(buffer, "%i", PowerOff); + PowerOff = -1; + debug(buffer); + // menu = MENU_EXIT; + } + + if(WPAD_ButtonsDown(0) & WPAD_BUTTON_A) + break; + } +*/ MainMenu(MENU_NONE); - + if(boothomebrew) { if(SelectedIOS() != IOS_GetVersion()) IOS_ReloadIOS(SelectedIOS()); - - if(strstr(Settings.forwarder_path.c_str(), ":/apps/") != 0) - BootHomebrew(); - else if(strstr(Settings.forwarder_path.c_str(), ":/gc_apps/") != 0) - BootGameCubeHomebrew(); - } + + if(Settings.forwarder_path != "the homebrew channel") + { + if(strstr(Settings.forwarder_path.c_str(), ":/apps/") != 0) + BootHomebrew(); + else if(strstr(Settings.forwarder_path.c_str(), ":/gc_apps/") != 0) + BootGameCubeHomebrew(); + } + else + LoadHBC(); + } else if(boot_buffer) - if(wiiload) BootHomebrew(); - + if(get_bootmii() == 2) IOS_ReloadIOS(254); - - if(get_nandemu() == 2) - { - if (opendir(check_path("sd1:/apps/NANDEmu-Boot").c_str()) != NULL) - { - LoadHomebrew ("sd1:/apps/NANDEmu-Boot/boot.dol"); - BootHomebrew (); - } - else if (opendir(check_path("usb1:/apps/NANDEmu-Boot").c_str()) != NULL) - { - LoadHomebrew ("usb1:/apps/NANDEmu-Boot/boot.dol"); - BootHomebrew (); - } - } - - if(get_priiloader() == 2) - { - *(vu32*)0x8132FFFB = 0x4461636f; - DCFlushRange((void*)0x8132FFFB, 4); - SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); - } - - if(PowerOff == SYS_RETURNTOMENU) - { - *(vu32*)0x8132FFFB = 0x50756E65; - DCFlushRange((void*)0x8132FFFB, 4); - SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); - } - else if(PowerOff != -1) + + if(PowerOff != -1) SYS_ResetSystem(PowerOff, 0, 0); return 0; diff --git a/source/main.h b/source/main.h index ace288b..489a04c 100644 --- a/source/main.h +++ b/source/main.h @@ -17,7 +17,7 @@ #include "Tools/theme.h" #include "Tools/translate.h" #include "Tools/fileop.h" -#include "../svnrev/svnrev.h" +#include "../../svnrev/svnrev.h" #define HW_REG_BASE 0xcd800000 #define HW_ARMIRQMASK (HW_REG_BASE + 0x03c) @@ -48,6 +48,7 @@ public: extern std::vector vechomebrew_list_category[99]; extern std::vector vechomebrew_list_unassigned; extern std::vector vechomebrew_list_choice; +extern std::vector vechomebrew_list_pc; class app_ios { @@ -68,7 +69,6 @@ struct SSettings string device; int sd_insert; int usb_insert; - int dvd_insert; string category_name_all; string category_name; char new_category_name[256]; @@ -90,15 +90,10 @@ struct SSettings int Apps_from; int Apps_to; - bool grid; + int view; bool unassigned; int system; // 0 = GC / 1 = Wii / 2 = Wii/GC - int temp_width; - int temp_height; - int temp_horizontal; - int temp_vertical; - int left, right, bottom, top; }; extern struct SSettings Settings; @@ -118,10 +113,10 @@ struct SOptions char theme[256]; char language[256]; char font[256]; - int apps; + int apps; bool quick_start; bool show_all; - int device_icon; + int device_icon; bool navigation; bool network; bool newrevtext; diff --git a/source/menu.cpp b/source/menu.cpp index 960a284..3700495 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -161,16 +161,6 @@ UpdateGUI (void *arg) check_sd(); check_usb(); } - - else if(Settings.device == "dvd") - check_dvd(); - - else if(Settings.device == "all") - { - check_sd(); - check_usb(); - check_dvd(); - } // screenshoot if(WPAD_ButtonsDown(0) & WPAD_BUTTON_1 && WPAD_ButtonsDown(0) & WPAD_BUTTON_2) @@ -215,6 +205,8 @@ void MainMenu(int menu) bgImg = new GuiImage(new GuiImageData(Theme.background)); mainWindow->Append(bgImg); + + debug("test"); while(currentMenu != MENU_EXIT) { diff --git a/source/pngu.c b/source/pngu.c index c19de93..1a424a4 100644 --- a/source/pngu.c +++ b/source/pngu.c @@ -6,28 +6,23 @@ Coder : frontier More info : http://frontier-dev.net +Modified by Tantric, 2009 + ********************************************************************************************/ #include #include -#include -#include "png.h" #include "pngu.h" -#include "pngu_impl.h" +#include "png.h" -#ifndef SAFE_FREE -#define SAFE_FREE(p) if(p){free(p);p=NULL;} -#endif -#if 0 -// moved to pngu_impl.h // Constants #define PNGU_SOURCE_BUFFER 1 #define PNGU_SOURCE_DEVICE 2 + // Prototypes of helper functions int pngu_info (IMGCTX ctx); int pngu_decode (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stripAlpha); -int pngu_decode_add_alpha (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stripAlpha, int force32bit); void pngu_free_info (IMGCTX ctx); void pngu_read_data_from_buffer (png_structp png_ptr, png_bytep data, png_size_t length); void pngu_write_data_to_buffer (png_structp png_ptr, png_bytep data, png_size_t length); @@ -42,7 +37,6 @@ struct _IMGCTX void *buffer; char *filename; PNGU_u32 cursor; - PNGU_u32 buf_size; // buffer size PNGU_u32 propRead; PNGUPROP prop; @@ -55,19 +49,18 @@ struct _IMGCTX png_bytep *row_pointers; png_bytep img_data; }; -#endif // PNGU Implementation // -IMGCTX PNGU_SelectImageFromBufferX (const void *buffer, int size) +IMGCTX PNGU_SelectImageFromBuffer (const void *buffer) { IMGCTX ctx = NULL; if (!buffer) return NULL; - ctx = calloc (sizeof (struct _IMGCTX), 1); + ctx = malloc (sizeof (struct _IMGCTX)); if (!ctx) return NULL; @@ -77,16 +70,10 @@ IMGCTX PNGU_SelectImageFromBufferX (const void *buffer, int size) ctx->filename = NULL; ctx->propRead = 0; ctx->infoRead = 0; - ctx->buf_size = size; return ctx; } -IMGCTX PNGU_SelectImageFromBuffer (const void *buffer) -{ - return PNGU_SelectImageFromBufferX(buffer, 0); -} - IMGCTX PNGU_SelectImageFromDevice (const char *filename) { @@ -95,7 +82,7 @@ IMGCTX PNGU_SelectImageFromDevice (const char *filename) if (!filename) return NULL; - ctx = calloc (sizeof (struct _IMGCTX), 1); + ctx = malloc (sizeof (struct _IMGCTX)); if (!ctx) return NULL; @@ -698,361 +685,6 @@ int PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu } -//######################################################################################## -//---------- Start CMPR added section --------------------------------------------------- -//######################################################################################## - -static inline PNGU_u16 rgb8ToRGB565(PNGU_u8 *color) -{ - return ((color[0] >> 3) << 11) | ((color[1] >> 2) << 5) | (color[2] >> 3); -} - -static int colorDistance(const PNGU_u8 *c0, const PNGU_u8 *c1) -{ - return (c1[0] - c0[0]) * (c1[0] - c0[0]) + (c1[1] - c0[1]) * (c1[1] - c0[1]) + (c1[2] - c0[2]) * (c1[2] - c0[2]); -} - -static void getBaseColors(PNGU_u8 *color0, PNGU_u8 *color1, const PNGU_u8 *srcBlock) -{ - int maxDistance = -1; - int i; - int j; - - for (i = 0; i < 15; ++i) - for (j = i + 1; j < 16; ++j) - { - int distance = colorDistance(srcBlock + i * 4, srcBlock + j * 4); - if (distance > maxDistance) - { - maxDistance = distance; - *(PNGU_u32 *)color0 = ((PNGU_u32 *)srcBlock)[i]; - *(PNGU_u32 *)color1 = ((PNGU_u32 *)srcBlock)[j]; - } - } - if (rgb8ToRGB565(color0) < rgb8ToRGB565(color1)) - { - PNGU_u32 tmp; - tmp = *(PNGU_u32 *)color0; - *(PNGU_u32 *)color0 = *(PNGU_u32 *)color1; - *(PNGU_u32 *)color1 = tmp; - } -} - -static PNGU_u32 colorIndices(const PNGU_u8 *color0, const PNGU_u8 *color1, const PNGU_u8 *srcBlock) -{ - PNGU_u16 colors[4][4]; - PNGU_u32 res = 0; - int i; - - // Make the 4 colors available in the block - colors[0][0] = (color0[0] & 0xF8) | (color0[0] >> 5); - colors[0][1] = (color0[1] & 0xFC) | (color0[1] >> 6); - colors[0][2] = (color0[2] & 0xF8) | (color0[2] >> 5); - colors[1][0] = (color1[0] & 0xF8) | (color1[0] >> 5); - colors[1][1] = (color1[1] & 0xFC) | (color1[1] >> 6); - colors[1][2] = (color1[2] & 0xF8) | (color1[2] >> 5); - colors[2][0] = (2 * colors[0][0] + 1 * colors[1][0]) / 3; - colors[2][1] = (2 * colors[0][1] + 1 * colors[1][1]) / 3; - colors[2][2] = (2 * colors[0][2] + 1 * colors[1][2]) / 3; - colors[3][0] = (1 * colors[0][0] + 2 * colors[1][0]) / 3; - colors[3][1] = (1 * colors[0][1] + 2 * colors[1][1]) / 3; - colors[3][2] = (1 * colors[0][2] + 2 * colors[1][2]) / 3; - for (i = 15; i >= 0; --i) - { - int c0 = srcBlock[i * 4 + 0]; - int c1 = srcBlock[i * 4 + 1]; - int c2 = srcBlock[i * 4 + 2]; - int d0 = abs(colors[0][0] - c0) + abs(colors[0][1] - c1) + abs(colors[0][2] - c2); - int d1 = abs(colors[1][0] - c0) + abs(colors[1][1] - c1) + abs(colors[1][2] - c2); - int d2 = abs(colors[2][0] - c0) + abs(colors[2][1] - c1) + abs(colors[2][2] - c2); - int d3 = abs(colors[3][0] - c0) + abs(colors[3][1] - c1) + abs(colors[3][2] - c2); - int b0 = d0 > d3; - int b1 = d1 > d2; - int b2 = d0 > d2; - int b3 = d1 > d3; - int b4 = d2 > d3; - int x0 = b1 & b2; - int x1 = b0 & b3; - int x2 = b0 & b4; - res |= (x2 | ((x0 | x1) << 1)) << ((15 - i) << 1); - } - return res; -} - -int PNGU_DecodeToCMPR_Trim(IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer) -{ - int result; - PNGU_u8 srcBlock[16 * 4]; - PNGU_u8 color0[4]; - PNGU_u8 color1[4]; - PNGU_u8 *outBuf = (PNGU_u8 *)buffer; - int ii; - int jj; - int k; - - //check for alpha channel - result = pngu_decode_add_alpha (ctx, width, height, 0, 1); - if (result != PNGU_OK) - return result; - - // trim down - width = width & ~7u; - height = height & ~7u; - - // Alpha channel present, copy image to the output buffer - for (jj = 0; jj < height; jj += 8) - for (ii = 0; ii < width; ii += 8) - for (k = 0; k < 4; ++k) - { - int j = jj + ((k >> 1) << 2); // jj + 0, jj + 0, jj + 4, jj + 4 - int i = ii + ((k & 1) << 2); // ii + 0, ii + 4, ii + 0, ii + 4 - memcpy(srcBlock, ctx->row_pointers[j] + i * 4, 16); - memcpy(srcBlock + 4 * 4, ctx->row_pointers[j + 1] + i * 4, 16); - memcpy(srcBlock + 8 * 4, ctx->row_pointers[j + 2] + i * 4, 16); - memcpy(srcBlock + 12 * 4, ctx->row_pointers[j + 3] + i * 4, 16); - getBaseColors(color0, color1, srcBlock); - *(PNGU_u16 *)outBuf = rgb8ToRGB565(color0); - outBuf += 2; - *(PNGU_u16 *)outBuf = rgb8ToRGB565(color1); - outBuf += 2; - *(PNGU_u32 *)outBuf = colorIndices(color0, color1, srcBlock); - outBuf += 4; - } - // Free resources - free (ctx->img_data); - free (ctx->row_pointers); - - // Success - return PNGU_OK; -} - - -// if width or height is not divisible by 8 -// then the remaining will be padded with last row/column -// buffer must be allocated with width and height rounded up - -int PNGU_DecodeToCMPR_Pad(IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer) -{ - int result; - PNGU_u8 srcBlock[16 * 4]; - PNGU_u8 color0[4]; - PNGU_u8 color1[4]; - PNGU_u8 *outBuf = (PNGU_u8 *)buffer; - int ii; - int jj; - int k; - - //check for alpha channel - result = pngu_decode_add_alpha (ctx, width, height, 0, 1); - if (result != PNGU_OK) - return result; - - // Alpha channel present, copy image to the output buffer - for (jj = 0; jj < height; jj += 8) { - for (ii = 0; ii < width; ii += 8) { - for (k = 0; k < 4; ++k) { - // k(i,j) - // 0(0,0) 1(4,0) - // 2(4,0) 3(4,4) - int i = ii + ((k & 1) << 2); // ii + 0, ii + 4, ii + 0, ii + 4 - int j = jj + ((k >> 1) << 2); // jj + 0, jj + 0, jj + 4, jj + 4 - int ny; // 4 lines - int px = 4; // num columns to copy - if (i >= width) i = width - 1; - if (i + px > width) px = width - i; - for (ny=0; ny<4; ny++) { - if (j >= height) j = height - 1; - memcpy(srcBlock + ny * 4 * 4, - ctx->row_pointers[j] + i * 4, px * 4); - if (px < 4) { - // repeat last column (4-px) times - int x = width - 1; - int nx; - for (nx = px; nx < 4; nx++) { - memcpy(srcBlock + ny * 4 * 4 + nx * 4, - ctx->row_pointers[j] + x * 4, 4); - } - } - j++; - } - getBaseColors(color0, color1, srcBlock); - *(PNGU_u16 *)outBuf = rgb8ToRGB565(color0); - outBuf += 2; - *(PNGU_u16 *)outBuf = rgb8ToRGB565(color1); - outBuf += 2; - *(PNGU_u32 *)outBuf = colorIndices(color0, color1, srcBlock); - outBuf += 4; - } - } - } - // Free resources - free (ctx->img_data); - free (ctx->row_pointers); - - // Success - return PNGU_OK; -} - -void ExtractBlock( PNGU_u8 *inPtr, int y, int x, PNGU_u32 width, int i, PNGU_u8 colorBlock[] ) { - PNGU_u32 offset; - PNGU_u8 r, g, b, a; - - offset = (((y >> 2)<<4)*width) + ((x >> 2)<<6) + ((((y&3) << 2) + (x&3) ) << 1); - //offset = (((y >> 2) << 4)*width) + ((x >> 2) << 6) + (((y % 4 << 2) + x % 4) << 1); - //get rgba values based on the RGBA8 offsets - a = *(inPtr+offset); - r = *(inPtr+offset+1); - g = *(inPtr+offset+32); - b = *(inPtr+offset+33); - colorBlock[i*4] = r; - colorBlock[i*4+1] = g; - colorBlock[i*4+2] = b; - colorBlock[i*4+3] = a; - -} - -/** - * by usptactical - * Converts a 4x4 RGBA8 image to CMPR. - */ -int PNGU_4x4RGBA8_To_CMPR(void *buf_rgb, PNGU_u32 width, PNGU_u32 height, void *buf_cmpr) -{ - PNGU_u8 srcBlock[16 * 4]; - PNGU_u8 color0[4]; - PNGU_u8 color1[4]; - PNGU_u8 *outBuf = (PNGU_u8 *)buf_cmpr; - PNGU_u8 *rgba = (PNGU_u8 *)buf_rgb; - int jj, ii, i, j, k; - - width = width & ~7u; - height = height & ~7u; - - // loop over blocks - //CMPR needs 4x4 block of pixels: - //image row 0: 0, 1, 2, 3 (first 16 block) - //image row 1: 0, 1, 2, 3 (second 16 block) - //image row 2: 0, 1, 2, 3 (third 16 block) - //image row 3: 0, 1, 2, 3 (last 16 block) - - //image row 0: 4, 5, 6, 7 (first 16 block) - //image row 1: 4, 5, 6, 7 (second 16 block) - //image row 2: 4, 5, 6, 7 (third 16 block) - //image row 3: 4, 5, 6, 7 (last 16 block) - - //image row 4: 0, 1, 2, 3 (first 16 block) - //image row 5: 0, 1, 2, 3 (second 16 block) - //image row 6: 0, 1, 2, 3 (third 16 block) - //image row 7: 0, 1, 2, 3 (last 16 block) - - //image row 4: 4, 5, 6, 7 (first 16 block) - //image row 5: 4, 5, 6, 7 (second 16 block) - //image row 6: 4, 5, 6, 7 (third 16 block) - //image row 7: 4, 5, 6, 7 (last 16 block) - - for(jj = 0; jj < height; jj += 8) - for(ii = 0; ii < width; ii += 8) - for (k=0; k < 4; k++) - { - j = jj + ((k >> 1) << 2); // jj + 0, jj + 0, jj + 4, jj + 4 - i = ii + ((k & 1) << 2); // ii + 0, ii + 4, ii + 0, ii + 4 - - ExtractBlock(rgba, j, i, width, 0, srcBlock); - ExtractBlock(rgba, j, i+1, width, 1, srcBlock); - ExtractBlock(rgba, j, i+2, width, 2, srcBlock); - ExtractBlock(rgba, j, i+3, width, 3, srcBlock); - - ExtractBlock(rgba, j+1, i, width, 4, srcBlock); - ExtractBlock(rgba, j+1, i+1, width, 5, srcBlock); - ExtractBlock(rgba, j+1, i+2, width, 6, srcBlock); - ExtractBlock(rgba, j+1, i+3, width, 7, srcBlock); - - ExtractBlock(rgba, j+2, i, width, 8, srcBlock); - ExtractBlock(rgba, j+2, i+1, width, 9, srcBlock); - ExtractBlock(rgba, j+2, i+2, width, 10, srcBlock); - ExtractBlock(rgba, j+2, i+3, width, 11, srcBlock); - - ExtractBlock(rgba, j+3, i, width, 12, srcBlock); - ExtractBlock(rgba, j+3, i+1, width, 13, srcBlock); - ExtractBlock(rgba, j+3, i+2, width, 14, srcBlock); - ExtractBlock(rgba, j+3, i+3, width, 15, srcBlock); - - getBaseColors(color0, color1, srcBlock); - *(PNGU_u16 *)outBuf = rgb8ToRGB565(color0); - outBuf += 2; - *(PNGU_u16 *)outBuf = rgb8ToRGB565(color1); - outBuf += 2; - *(PNGU_u32 *)outBuf = colorIndices(color0, color1, srcBlock); - outBuf += 4; - } - // Success - return PNGU_OK; -} - -// if width or height is not divisible by 8 -// then the remaining will be padded with last row/column -// buffer must be allocated with width and height rounded up -int PNGU_RGBA8_To_CMPR(void *buf_rgb, PNGU_u32 width, PNGU_u32 height, void *buf_cmpr) -{ - PNGU_u8 srcBlock[16 * 4]; - PNGU_u8 color0[4]; - PNGU_u8 color1[4]; - PNGU_u8 *src, *block; - PNGU_u8 *cmpr = (PNGU_u8 *)buf_cmpr; - PNGU_u8 *rgba = (PNGU_u8 *)buf_rgb; - int jj, ii, i, j, k; - int x, y; // counter - int px, py; // pixel coord - - for(jj = 0; jj < height; jj += 8) { - for(ii = 0; ii < width; ii += 8) { - for (k=0; k < 4; k++) { - i = ii + ((k & 1) << 2); // ii + 0, ii + 4, ii + 0, ii + 4 - j = jj + ((k >> 1) << 2); // jj + 0, jj + 0, jj + 4, jj + 4 - - block = srcBlock; - for (y=0; y<4; y++) { - py = j + y; - if (py >= height) py = height - 1; - src = rgba + py * width * 4; - for (x=0; x<4; x++) { - px = i + x; - if (px >= width) px = width - 1; - memcpy(block, src + px * 4, 4); - block += 4; - } - } - - getBaseColors(color0, color1, srcBlock); - *(PNGU_u16 *)cmpr = rgb8ToRGB565(color0); - cmpr += 2; - *(PNGU_u16 *)cmpr = rgb8ToRGB565(color1); - cmpr += 2; - *(PNGU_u32 *)cmpr = colorIndices(color0, color1, srcBlock); - cmpr += 4; - } - } - } - // Success - return PNGU_OK; -} - - -/** - * added by usptactical - * handles png error messages - */ -void user_error (png_structp png_ptr, png_const_charp c) -{ - longjmp(png_jmpbuf(png_ptr), 1); -} - - - -//######################################################################################## -//---------- End CMPR added section ----------------------------------------------------- -//######################################################################################## - - int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride) { png_uint_32 rowbytes; @@ -1077,21 +709,21 @@ int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu // Allocation of libpng structs ctx->png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!(ctx->png_ptr)) + if (!(ctx->png_ptr)) { if (ctx->source == PNGU_SOURCE_DEVICE) fclose (ctx->fd); - return PNGU_LIB_ERROR; + return PNGU_LIB_ERROR; } - ctx->info_ptr = png_create_info_struct (ctx->png_ptr); - if (!(ctx->info_ptr)) - { + ctx->info_ptr = png_create_info_struct (ctx->png_ptr); + if (!(ctx->info_ptr)) + { png_destroy_write_struct (&(ctx->png_ptr), (png_infopp)NULL); if (ctx->source == PNGU_SOURCE_DEVICE) fclose (ctx->fd); - return PNGU_LIB_ERROR; - } + return PNGU_LIB_ERROR; + } if (ctx->source == PNGU_SOURCE_BUFFER) { @@ -1106,7 +738,7 @@ int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu } // Setup output file properties - png_set_IHDR (ctx->png_ptr, ctx->info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB, + png_set_IHDR (ctx->png_ptr, ctx->info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); // Allocate memory to store the image in RGB format @@ -1165,6 +797,138 @@ int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu return PNGU_OK; } +int PNGU_EncodeFromRGB (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride) +{ + png_uint_32 rowbytes; + PNGU_u32 y; + + // Erase from the context any readed info + pngu_free_info (ctx); + ctx->propRead = 0; + + // Check if the user has selected a file to write the image + if (ctx->source == PNGU_SOURCE_BUFFER); + + else if (ctx->source == PNGU_SOURCE_DEVICE) + { + // Open file + if (!(ctx->fd = fopen (ctx->filename, "wb"))) + return PNGU_CANT_OPEN_FILE; + } + + else + return PNGU_NO_FILE_SELECTED; + + // Allocation of libpng structs + ctx->png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (!(ctx->png_ptr)) + { + if (ctx->source == PNGU_SOURCE_DEVICE) + fclose (ctx->fd); + return PNGU_LIB_ERROR; + } + + ctx->info_ptr = png_create_info_struct (ctx->png_ptr); + if (!(ctx->info_ptr)) + { + png_destroy_write_struct (&(ctx->png_ptr), (png_infopp)NULL); + if (ctx->source == PNGU_SOURCE_DEVICE) + fclose (ctx->fd); + return PNGU_LIB_ERROR; + } + + if (ctx->source == PNGU_SOURCE_BUFFER) + { + // Installation of our custom data writer function + ctx->cursor = 0; + png_set_write_fn (ctx->png_ptr, ctx, pngu_write_data_to_buffer, pngu_flush_data_to_buffer); + } + else if (ctx->source == PNGU_SOURCE_DEVICE) + { + // Default data writer uses function fwrite, so it needs to use our FILE* + png_init_io (ctx->png_ptr, ctx->fd); + } + + // Setup output file properties + png_set_IHDR (ctx->png_ptr, ctx->info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB, + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + + // Allocate memory to store the image in RGB format + rowbytes = width * 3; + if (rowbytes % 4) + rowbytes = ((rowbytes / 4) + 1) * 4; // Add extra padding so each row starts in a 4 byte boundary + + ctx->img_data = malloc(rowbytes * height); + memset(ctx->img_data, 0, rowbytes * height); + + if (!ctx->img_data) + { + png_destroy_write_struct (&(ctx->png_ptr), (png_infopp)NULL); + if (ctx->source == PNGU_SOURCE_DEVICE) + fclose (ctx->fd); + return PNGU_LIB_ERROR; + } + + ctx->row_pointers = malloc (sizeof (png_bytep) * height); + memset(ctx->row_pointers, 0, sizeof (png_bytep) * height); + + if (!ctx->row_pointers) + { + png_destroy_write_struct (&(ctx->png_ptr), (png_infopp)NULL); + if (ctx->source == PNGU_SOURCE_DEVICE) + fclose (ctx->fd); + return PNGU_LIB_ERROR; + } + + for (y = 0; y < height; y++) + { + ctx->row_pointers[y] = buffer + (y * rowbytes); + } + + // Tell libpng where is our image data + png_set_rows (ctx->png_ptr, ctx->info_ptr, ctx->row_pointers); + + // Write file header and image data + png_write_png (ctx->png_ptr, ctx->info_ptr, PNG_TRANSFORM_IDENTITY, NULL); + + // Tell libpng we have no more data to write + png_write_end (ctx->png_ptr, (png_infop) NULL); + + // Free resources + free (ctx->img_data); + free (ctx->row_pointers); + png_destroy_write_struct (&(ctx->png_ptr), &(ctx->info_ptr)); + if (ctx->source == PNGU_SOURCE_DEVICE) + fclose (ctx->fd); + + // Success + return ctx->cursor; +} + +int PNGU_EncodeFromGXTexture (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride) +{ + int x,y,res; + unsigned char * ptr = (unsigned char*)buffer; + unsigned char * tmpbuffer = (unsigned char *)malloc(width*height*3); + memset(tmpbuffer, 0, width*height*3); + png_uint_32 offset; + + for(y=0; y < height; y++) + { + for(x=0; x < width; x++) + { + offset = (((y >> 2)<<4)*width) + ((x >> 2)<<6) + (((y%4 << 2) + x%4 ) << 1); + + tmpbuffer[y*640*3+x*3] = ptr[offset+1]; // R + tmpbuffer[y*640*3+x*3+1] = ptr[offset+32]; // G + tmpbuffer[y*640*3+x*3+2] = ptr[offset+33]; // B + } + } + + res = PNGU_EncodeFromRGB (ctx, width, height, tmpbuffer, stride); + free(tmpbuffer); + return res; +} // This function is taken from a libogc example PNGU_u32 PNGU_RGB8_TO_YCbYCr (PNGU_u8 r1, PNGU_u8 g1, PNGU_u8 b1, PNGU_u8 r2, PNGU_u8 g2, PNGU_u8 b2) @@ -1226,7 +990,7 @@ int pngu_info (IMGCTX ctx) return PNGU_CANT_OPEN_FILE; // Load first 8 bytes into magic buffer - if (fread (magic, 1, 8, ctx->fd) != 8) + if (fread (magic, 1, 8, ctx->fd) != 8) { fclose (ctx->fd); return PNGU_CANT_READ_FILE; @@ -1245,21 +1009,21 @@ int pngu_info (IMGCTX ctx) // Allocation of libpng structs ctx->png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!(ctx->png_ptr)) + if (!(ctx->png_ptr)) { if (ctx->source == PNGU_SOURCE_DEVICE) fclose (ctx->fd); - return PNGU_LIB_ERROR; + return PNGU_LIB_ERROR; } - ctx->info_ptr = png_create_info_struct (ctx->png_ptr); - if (!(ctx->info_ptr)) - { + ctx->info_ptr = png_create_info_struct (ctx->png_ptr); + if (!(ctx->info_ptr)) + { if (ctx->source == PNGU_SOURCE_DEVICE) fclose (ctx->fd); - png_destroy_read_struct (&(ctx->png_ptr), (png_infopp)NULL, (png_infopp)NULL); - return PNGU_LIB_ERROR; - } + png_destroy_read_struct (&(ctx->png_ptr), (png_infopp)NULL, (png_infopp)NULL); + return PNGU_LIB_ERROR; + } if (ctx->source == PNGU_SOURCE_BUFFER) { @@ -1376,15 +1140,10 @@ int pngu_info (IMGCTX ctx) } -int pngu_decode_add_alpha (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stripAlpha, int force32bit) +int pngu_decode (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stripAlpha) { png_uint_32 rowbytes; int i; - int chunk; - int rowsLeft; - png_bytep *curRow; - int mem_err = 0; - // Read info if it hasn't been read before if (!ctx->infoRead) @@ -1402,43 +1161,22 @@ int pngu_decode_add_alpha (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 if ( (ctx->prop.imgColorType == PNGU_COLOR_TYPE_PALETTE) || (ctx->prop.imgColorType == PNGU_COLOR_TYPE_UNKNOWN) ) return PNGU_UNSUPPORTED_COLOR_TYPE; - //************************************************* - //* added by usptactical to catch corrupted pngs * - jmp_buf save_jmp; - memcpy(save_jmp, png_jmpbuf(ctx->png_ptr), sizeof(save_jmp)); - if (setjmp(png_jmpbuf(ctx->png_ptr))) { - error: - memcpy(png_jmpbuf(ctx->png_ptr), save_jmp, sizeof(save_jmp)); - SAFE_FREE(ctx->row_pointers); - SAFE_FREE(ctx->img_data); - pngu_free_info (ctx); - //printf("*** This is a corrupted image!!\n"); sleep(5); - return (mem_err)?PNGU_LIB_ERROR:-666; - } - //override default error handler to suppress warning messages from libpng - png_set_error_fn (ctx->png_ptr, NULL, user_error, user_error); - //************************************************* - // Scale 16 bit samples to 8 bit if (ctx->prop.imgBitDepth == 16) - png_set_strip_16 (ctx->png_ptr); + png_set_strip_16 (ctx->png_ptr); // Remove alpha channel if we don't need it if (stripAlpha && ((ctx->prop.imgColorType == PNGU_COLOR_TYPE_RGB_ALPHA) || (ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY_ALPHA))) - png_set_strip_alpha (ctx->png_ptr); + png_set_strip_alpha (ctx->png_ptr); // Expand 1, 2 and 4 bit samples to 8 bit if (ctx->prop.imgBitDepth < 8) - png_set_packing (ctx->png_ptr); + png_set_packing (ctx->png_ptr); // Transform grayscale images to RGB if ( (ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY) || (ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY_ALPHA) ) png_set_gray_to_rgb (ctx->png_ptr); - // Transform RBG images to RGBA - if (force32bit && (ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY || ctx->prop.imgColorType == PNGU_COLOR_TYPE_RGB)) - png_set_filler(ctx->png_ptr, 0xFF, PNG_FILLER_AFTER); - // Flush transformations png_read_update_info (ctx->png_ptr, ctx->info_ptr); @@ -1450,44 +1188,23 @@ int pngu_decode_add_alpha (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 ctx->img_data = malloc (rowbytes * ctx->prop.imgHeight); if (!ctx->img_data) { - //pngu_free_info (ctx); - //return PNGU_LIB_ERROR; - mem_err = 1; - goto error; + pngu_free_info (ctx); + return PNGU_LIB_ERROR; } ctx->row_pointers = malloc (sizeof (png_bytep) * ctx->prop.imgHeight); if (!ctx->row_pointers) { - //free (ctx->img_data); - //pngu_free_info (ctx); - //return PNGU_LIB_ERROR; - mem_err = 1; - goto error; + free (ctx->img_data); + pngu_free_info (ctx); + return PNGU_LIB_ERROR; } - for (i = 0; i < (int)ctx->prop.imgHeight; i++) + for (i = 0; i < ctx->prop.imgHeight; i++) ctx->row_pointers[i] = ctx->img_data + (i * rowbytes); // Transform the image and copy it to our allocated memory - if (png_get_interlace_type(ctx->png_ptr, ctx->info_ptr) != PNG_INTERLACE_NONE) - png_read_image (ctx->png_ptr, ctx->row_pointers); - else - { - rowsLeft = ctx->prop.imgHeight; - curRow = ctx->row_pointers; - while (rowsLeft > 0) - { - chunk = rowsLeft > 0x80 ? 0x80 : rowsLeft; - png_read_rows(ctx->png_ptr, curRow, NULL, chunk); - //usleep(1000); - curRow += chunk; - rowsLeft -= chunk; - } - } - - // restore default error handling - memcpy(png_jmpbuf(ctx->png_ptr), save_jmp, sizeof(save_jmp)); + png_read_image (ctx->png_ptr, ctx->row_pointers); // Free resources pngu_free_info (ctx); @@ -1496,11 +1213,6 @@ int pngu_decode_add_alpha (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 return PNGU_OK; } -int pngu_decode (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stripAlpha) -{ - return pngu_decode_add_alpha(ctx, width, height, stripAlpha, 0); -} - void pngu_free_info (IMGCTX ctx) { @@ -1520,13 +1232,6 @@ void pngu_free_info (IMGCTX ctx) void pngu_read_data_from_buffer (png_structp png_ptr, png_bytep data, png_size_t length) { IMGCTX ctx = (IMGCTX) png_get_io_ptr (png_ptr); - if (ctx->buf_size && (ctx->cursor + length > ctx->buf_size)) - { - static char err_str[40]; - snprintf(err_str, sizeof(err_str), "read error (%x/%x)", - ctx->cursor + length, ctx->buf_size); - png_error(png_ptr, err_str); - } memcpy (data, ctx->buffer + ctx->cursor, length); ctx->cursor += length; } diff --git a/source/pngu.h b/source/pngu.h index bbffc65..cc8fcd8 100644 --- a/source/pngu.h +++ b/source/pngu.h @@ -6,6 +6,8 @@ Coder : frontier More info : http://frontier-dev.net +Modified by Tantric, 2009 + ********************************************************************************************/ #ifndef __PNGU__ #define __PNGU__ @@ -90,7 +92,6 @@ void PNGU_YCbYCr_TO_RGB8 (PNGU_u32 ycbycr, PNGU_u8 *r1, PNGU_u8 *g1, PNGU_u8 *b1 // Selects a PNG file, previosly loaded into a buffer, and creates an image context for subsequent procesing. IMGCTX PNGU_SelectImageFromBuffer (const void *buffer); -IMGCTX PNGU_SelectImageFromBufferX (const void *buffer, int size); // Selects a PNG file, from any devoptab device, and creates an image context for subsequent procesing. IMGCTX PNGU_SelectImageFromDevice (const char *filename); @@ -139,17 +140,12 @@ int PNGU_DecodeToRGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffe // Macro for decoding an image inside a buffer at given coordinates. #define PNGU_DECODE_TO_COORDS_RGBA8(ctx,coordX,coordY,imgWidth,imgHeight,default_alpha,bufferWidth,bufferHeight,buffer) \ \ - PNGU_DecodeToRGBA8 (ctx, imgWidth, imgHeight, ((void *) buffer) + (coordY) * (bufferWidth) * 4 + \ - (coordX) * 4, (bufferWidth) - (imgWidth), default_alpha) + PNGU_DecodeToRGBA8 (ctx, imgWidth, imgHeight, ((void *) buffer) + (coordY) * (bufferWidth) * 2 + \ + (coordX) * 2, (bufferWidth) - (imgWidth), default_alpha) // Expands selected image into a 4x4 tiled RGB565 buffer. You need to specify context, image dimensions // and destination address. int PNGU_DecodeTo4x4RGB565 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer); -// Compressed version (DXT1/CMPR) -int PNGU_DecodeToCMPR_Trim(IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer); -int PNGU_DecodeToCMPR_Pad(IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer); -int PNGU_4x4RGBA8_To_CMPR(void *buf_rgb, PNGU_u32 width, PNGU_u32 height, void *buf_cmpr); -int PNGU_RGBA8_To_CMPR(void *buf_rgb, PNGU_u32 width, PNGU_u32 height, void *buf_cmpr); // Expands selected image into a 4x4 tiled RGB5A3 buffer. You need to specify context, image dimensions, // destination address and default alpha value, which is used if the source image doesn't have an alpha channel. @@ -163,16 +159,15 @@ int PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu // specify context, image dimensions, destination address and stride in pixels (stride = buffer width - image width). int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride); +int PNGU_EncodeFromRGB (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride); +int PNGU_EncodeFromGXTexture (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride); + // Macro for encoding an image stored into an YCbYCr buffer at given coordinates. #define PNGU_ENCODE_TO_COORDS_YCbYCr(ctx,coordX,coordY,imgWidth,imgHeight,bufferWidth,bufferHeight,buffer) \ \ PNGU_EncodeFromYCbYCr (ctx, imgWidth, imgHeight, ((void *) buffer) + (coordY) * (bufferWidth) * 2 + \ (coordX) * 2, (bufferWidth) - (imgWidth)) -PNGU_u8 * PNGU_DecodeTo4x4RGBA8_EX (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, int * dstWidth, int * dstHeight, PNGU_u8 *dstPtr); - -int PNGU_EncodeFromEFB (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stride); - #ifdef __cplusplus } #endif