From 15bcbfa48208cb690edce39f6da9f1ac59bd3d33 Mon Sep 17 00:00:00 2001 From: dimok321 <15055714+dimok789@users.noreply.github.com> Date: Wed, 6 Jan 2010 23:07:35 +0000 Subject: [PATCH] *Finished the background initialization thread for devices started by giantpune and merged it into trunk. Now you can startup the loader without a HDD. Also you can put in your device after startup and it will be recognized. Hot swapping not yet added (as in remove and than stick it in). You will see the list of available channels on your system if you start without a HDD or if your HDD is slow and is being recognized late. The list of games is than reloading as soon as it is recognized. *Hot swapping of the SD card was implemented into background thread (by giantpune) *Made lots of cleanups and some fixes *Format menu was moved to settings page 3 (only on godmode accessable) *Added ScreenShot and Reset/Shutdown call to background thread. Removed the not needed ones. Now you can call for Screenshot/Reset/Shutdown anywhere in the loader (after gui is started). --- gui.pnproj | 2 +- source/banner/gui_banner.cpp | 215 +- source/banner/gui_banner.h | 4 +- source/banner/openingbnr.h | 2 + source/bannersound.h | 12 +- source/cheats/cheatmenu.cpp | 6 +- source/homebrewboot/HomebrewBrowse.cpp | 33 +- source/libwiigui/gui_gamebrowser.cpp | 1281 ++++----- source/main.cpp | 458 +--- source/menu.cpp | 327 +-- source/menu.h | 5 +- source/menu/device_check.cpp | 202 ++ source/menu/menu_check.cpp | 164 -- source/menu/menu_disclist.cpp | 3278 ++++++++++++------------ source/menu/menu_format.cpp | 381 +-- source/menu/menu_install.cpp | 9 - source/menu/menus.h | 55 +- source/prompts/DiscBrowser.cpp | 126 +- source/prompts/ProgressWindow.cpp | 4 - source/prompts/PromptWindows.cpp | 101 +- source/prompts/TitleBrowser.cpp | 38 +- source/prompts/filebrowser.cpp | 18 +- source/prompts/gameinfo.cpp | 40 +- source/settings/Settings.cpp | 97 +- source/settings/SettingsPrompts.cpp | 20 +- source/settings/cfg.c | 10 +- source/sys.cpp | 200 +- source/sys.h | 2 + source/themes/Theme_Downloader.cpp | 18 +- source/usbloader/getentries.cpp | 154 +- source/video.cpp | 55 +- source/video.h | 1 + source/wad/wad.cpp | 17 +- 33 files changed, 3592 insertions(+), 3743 deletions(-) create mode 100644 source/menu/device_check.cpp delete mode 100644 source/menu/menu_check.cpp diff --git a/gui.pnproj b/gui.pnproj index 2dc3d5f6..42e19f4c 100644 --- a/gui.pnproj +++ b/gui.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/source/banner/gui_banner.cpp b/source/banner/gui_banner.cpp index 267d2685..53cd34f5 100644 --- a/source/banner/gui_banner.cpp +++ b/source/banner/gui_banner.cpp @@ -5,98 +5,127 @@ * Shows TPL Banner images ***************************************************************************/ #include "gui_banner.h" - -GuiBanner::GuiBanner(const char *tplfilepath) -{ - memory = NULL; - tplfilesize = 0; - width = 0; - height = 0; - - FILE *tplfp = fopen(tplfilepath,"rb"); - - if(tplfp !=NULL) { - - unsigned short heighttemp = 0; - unsigned short widthtemp = 0; - - fseek(tplfp , 0x14, SEEK_SET); - fread((void*)&heighttemp,1,2,tplfp); - fread((void*)&widthtemp,1,2,tplfp); - fseek (tplfp , 0 , SEEK_END); - tplfilesize = ftell (tplfp); - rewind (tplfp); - memory = memalign(32, tplfilesize); - if(!memory) { - fclose(tplfp); - return; - } - fread(memory, 1, tplfilesize, tplfp); - fclose(tplfp); - - TPLFile tplfile; - int ret; - - ret = TPL_OpenTPLFromMemory(&tplfile, memory, tplfilesize); - if(ret < 0) { - free(memory); - memory = NULL; - return; - } - ret = TPL_GetTexture(&tplfile,0,&texObj); - if(ret < 0) { - free(memory); - memory = NULL; - return; - } - TPL_CloseTPLFile(&tplfile); - - width = widthtemp; - height = heighttemp; - widescreen = 0; - filecheck = true; - - } else { - filecheck = false; - fclose(tplfp); - } -} - -GuiBanner::GuiBanner(void *mem, u32 len, int w, int h) -{ - if(!mem || !len) - return; - memory = mem; - tplfilesize = len; - width = w; - height = h; - - TPLFile tplfile; - - int ret; - - ret = TPL_OpenTPLFromMemory(&tplfile, memory, tplfilesize); - if(ret < 0) { - free(memory); - memory = NULL; - return; - } - ret = TPL_GetTexture(&tplfile,0,&texObj); - if(ret < 0) { - free(memory); - memory = NULL; - return; - } - TPL_CloseTPLFile(&tplfile); - - filecheck = true; -} + +typedef struct +{ + u32 texture_header_offset; + u32 palette_header_offset; +} TPLTexture; + +typedef struct +{ + u16 heigth; + u16 width; + //... + //there is more but we only need these +} TPLTextureHeader; + +//only one field tpls +typedef struct +{ + u32 magic; + u32 ntextures; + u32 texture_size; + TPLTexture textures; +} TPLHeader; + + +GuiBanner::GuiBanner(const char *tplfilepath) +{ + memory = NULL; + tplfilesize = 0; + width = 0; + height = 0; + + FILE *tplfp = fopen(tplfilepath,"rb"); + + if(tplfp !=NULL) { + + fseek (tplfp , 0 , SEEK_END); + tplfilesize = ftell (tplfp); + rewind (tplfp); + memory = memalign(32, tplfilesize); + if(!memory) { + fclose(tplfp); + return; + } + fread(memory, 1, tplfilesize, tplfp); + fclose(tplfp); + + const u8 * buffer = (const u8*) memory; + const TPLHeader *hdr = (TPLHeader *) buffer; + const TPLTextureHeader *texhdr = (TPLTextureHeader *) &buffer[hdr->textures.texture_header_offset]; + + height = texhdr[0].heigth; + width = texhdr[0].width; + + TPLFile tplfile; + int ret; + + ret = TPL_OpenTPLFromMemory(&tplfile, memory, tplfilesize); + if(ret < 0) { + free(memory); + memory = NULL; + return; + } + ret = TPL_GetTexture(&tplfile,0,&texObj); + if(ret < 0) { + free(memory); + memory = NULL; + return; + } + TPL_CloseTPLFile(&tplfile); + + widescreen = 0; + filecheck = true; + + } else { + filecheck = false; + fclose(tplfp); + } +} + +GuiBanner::GuiBanner(void *mem, u32 len) +{ + if(!mem || !len) + return; + + memory = mem; + tplfilesize = len; + + const u8 * buffer = (const u8*) memory; + const TPLHeader *hdr = (TPLHeader *) buffer; + const TPLTextureHeader *texhdr = (TPLTextureHeader *) &buffer[hdr->textures.texture_header_offset]; + + height = texhdr[0].heigth; + width = texhdr[0].width; + + TPLFile tplfile; + + int ret; + + ret = TPL_OpenTPLFromMemory(&tplfile, memory, tplfilesize); + if(ret < 0) { + free(memory); + memory = NULL; + return; + } + ret = TPL_GetTexture(&tplfile,0,&texObj); + if(ret < 0) { + free(memory); + memory = NULL; + return; + } + TPL_CloseTPLFile(&tplfile); + + filecheck = true; +} GuiBanner::~GuiBanner() -{ +{ if(memory != NULL) { - free(memory); - memory = NULL; + free(memory); + memory = NULL; } } @@ -104,11 +133,11 @@ void GuiBanner::Draw() { LOCK(this); if(!filecheck ||!this->IsVisible()) - return; + return; - float currScale = this->GetScale(); - - Menu_DrawTPLImg(this->GetLeft(), this->GetTop(), 0, width, height, &texObj, imageangle, widescreen ? currScale*0.80 : currScale, currScale, this->GetAlpha(), xx1,yy1,xx2,yy2,xx3,yy3,xx4,yy4); + float currScale = this->GetScale(); + + Menu_DrawTPLImg(this->GetLeft(), this->GetTop(), 0, width, height, &texObj, imageangle, widescreen ? currScale*0.80 : currScale, currScale, this->GetAlpha(), xx1,yy1,xx2,yy2,xx3,yy3,xx4,yy4); this->UpdateEffects(); } diff --git a/source/banner/gui_banner.h b/source/banner/gui_banner.h index d372baaf..d0f1d61a 100644 --- a/source/banner/gui_banner.h +++ b/source/banner/gui_banner.h @@ -19,9 +19,7 @@ public: //!Constructor //!\param mem Memory of the loaded tpl //!\param len Filesize of the tpl - //!\param w Width of the tpl - //!\param h Height of the tpl - GuiBanner(void *mem, u32 len, int w, int h); + GuiBanner(void *mem, u32 len); //!Destructor ~GuiBanner(); void Draw(); diff --git a/source/banner/openingbnr.h b/source/banner/openingbnr.h index 3142fba0..0895cc74 100644 --- a/source/banner/openingbnr.h +++ b/source/banner/openingbnr.h @@ -13,6 +13,8 @@ extern "C" { #endif +#include + /*********************************************************** * Error description: * 0 Successfully extracted diff --git a/source/bannersound.h b/source/bannersound.h index 6cf7b526..b6da62d1 100644 --- a/source/bannersound.h +++ b/source/bannersound.h @@ -1,6 +1,6 @@ -#ifndef BANNERSOUND_H -#define BANNERSOUND_H - -const u8 *LoadBannerSound(const u8 *discid, u32 *size); - -#endif /* BANNERSOUND_H */ +#ifndef BANNERSOUND_H +#define BANNERSOUND_H + +const u8 *LoadBannerSound(const u8 *discid, u32 *size); + +#endif /* BANNERSOUND_H */ diff --git a/source/cheats/cheatmenu.cpp b/source/cheats/cheatmenu.cpp index 3e751079..96527d0e 100644 --- a/source/cheats/cheatmenu.cpp +++ b/source/cheats/cheatmenu.cpp @@ -12,11 +12,7 @@ #include "filelist.h" #include "sys.h" #include "gct.h" - -/*** Extern functions ***/ -extern void ResumeGui(); -extern void HaltGui(); - +#include "../menu/menus.h" /*** Extern variables ***/ extern GuiWindow * mainWindow; diff --git a/source/homebrewboot/HomebrewBrowse.cpp b/source/homebrewboot/HomebrewBrowse.cpp index ea3bb3b4..dbe90456 100644 --- a/source/homebrewboot/HomebrewBrowse.cpp +++ b/source/homebrewboot/HomebrewBrowse.cpp @@ -28,9 +28,7 @@ #include "unzip/miniunz.h" #include "usbloader/utils.h" -/*** Extern functions ***/ -extern void ResumeGui(); -extern void HaltGui(); +#include "../menu/menus.h" /*** Extern variables ***/ extern GuiWindow * mainWindow; @@ -39,8 +37,6 @@ extern GuiImage * bgImg; extern u32 infilesize; extern u32 uncfilesize; extern char wiiloadVersion[2]; -extern u8 shutdown; -extern u8 reset; extern struct SSettings Settings; extern void *innetbuffer; @@ -731,11 +727,6 @@ int MenuHomebrewBrowse() { MainButton4.ResetState(); } - else if (shutdown == 1) - Sys_Shutdown(); - else if (reset == 1) - Sys_Reboot(); - else if (backBtn.GetState() == STATE_CLICKED) { menu = MENU_DISCLIST; changed = true; @@ -834,29 +825,29 @@ int MenuHomebrewBrowse() { read += result; } - + char filename[101]; if (!error) { - + network_read((u8*) &filename, 100); - + // Do we need to unzip this thing? if (wiiloadVersion[0] > 0 || wiiloadVersion[1] > 4) { // We need to unzip... if (temp[0] == 'P' && temp[1] == 'K' && temp[2] == 0x03 && temp[3] == 0x04) { // It's a zip file, unzip to the apps directory - + // Zip archive, ask for permission to install the zip char zippath[255]; sprintf((char *) &zippath, "%s%s", Settings.homebrewapps_path, filename); - + FILE *fp = fopen(zippath, "wb"); if (fp != NULL) { fwrite(temp, 1, infilesize, fp); fclose(fp); - + // Now unzip the zip file... unzFile uf = unzOpen(zippath); if (uf==NULL) { @@ -864,9 +855,9 @@ int MenuHomebrewBrowse() { } else { extractZip(uf,0,1,0, Settings.homebrewapps_path); unzCloseCurrentFile(uf); - + remove(zippath); - + // Reload this menu here... menu = MENU_HOMEBREWBROWSE; break; @@ -880,17 +871,17 @@ int MenuHomebrewBrowse() { uLongf f = uncfilesize; error = uncompress(unc, &f, temp, infilesize) != Z_OK; uncfilesize = f; - + free(temp); temp = unc; } } - + if (!error && strstr(filename,".zip") == NULL) { innetbuffer = temp; } } - + ProgressStop(); if (error || read != infilesize) { diff --git a/source/libwiigui/gui_gamebrowser.cpp b/source/libwiigui/gui_gamebrowser.cpp index c99c04bb..ef5a39f7 100644 --- a/source/libwiigui/gui_gamebrowser.cpp +++ b/source/libwiigui/gui_gamebrowser.cpp @@ -1,639 +1,642 @@ -/**************************************************************************** - * libwiigui - * - * gui_gamebrowser.cpp - * - * GUI class definitions - ***************************************************************************/ - -#include "gui.h" -#include "../wpad.h" - -#include -#include "gui_gamebrowser.h" -#include "../settings/cfg.h" -#include "../main.h" -#include "settings/newtitles.h" - -#include -#include - -#define GAMESELECTSIZE 30 -int txtscroll = 0; -/** - * Constructor for the GuiGameBrowser class. - */ -GuiGameBrowser::GuiGameBrowser(int w, int h, struct discHdr * l, int gameCnt, const char *themePath, const u8 *imagebg, int selected, int offset) -{ - width = w; - height = h; - this->gameCnt = gameCnt; - gameList = l; - pagesize = THEME.pagesize; - scrollbaron = (gameCnt > pagesize) ? 1 : 0; - selectable = true; - listOffset = MAX(0,MIN(offset,(gameCnt-pagesize))); - selectedItem = selected - offset; - focus = 1; // allow focus - char imgPath[100]; - - trigA = new GuiTrigger; - trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - trigHeldA = new GuiTrigger; - trigHeldA->SetHeldTrigger(-1, WPAD_BUTTON_A, PAD_BUTTON_A); - btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, Settings.sfxvolume); - - snprintf(imgPath, sizeof(imgPath), "%sbg_options.png", themePath); - bgGames = new GuiImageData(imgPath, imagebg); - - snprintf(imgPath, sizeof(imgPath), "%snew.png", themePath); - newGames = new GuiImageData(imgPath, new_png); - - bgGameImg = new GuiImage(bgGames); - bgGameImg->SetParent(this); - bgGameImg->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - - maxTextWidth = bgGameImg->GetWidth() - 24 - 4; - - snprintf(imgPath, sizeof(imgPath), "%sbg_options_entry.png", themePath); - bgGamesEntry = new GuiImageData(imgPath, bg_options_entry_png); - - snprintf(imgPath, sizeof(imgPath), "%sscrollbar.png", themePath); - scrollbar = new GuiImageData(imgPath, scrollbar_png); - scrollbarImg = new GuiImage(scrollbar); - scrollbarImg->SetParent(this); - scrollbarImg->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); - scrollbarImg->SetPosition(0, 4); - - maxTextWidth -= scrollbarImg->GetWidth() + 4; - - snprintf(imgPath, sizeof(imgPath), "%sscrollbar_arrowdown.png", themePath); - arrowDown = new GuiImageData(imgPath, scrollbar_arrowdown_png); - arrowDownImg = new GuiImage(arrowDown); - arrowDownOver = new GuiImageData(imgPath, scrollbar_arrowdown_png); - arrowDownOverImg = new GuiImage(arrowDownOver); - snprintf(imgPath, sizeof(imgPath), "%sscrollbar_arrowup.png", themePath); - arrowUp = new GuiImageData(imgPath, scrollbar_arrowup_png); - arrowUpImg = new GuiImage(arrowUp); - arrowUpOver = new GuiImageData(imgPath, scrollbar_arrowup_png); - arrowUpOverImg = new GuiImage(arrowUpOver); - snprintf(imgPath, sizeof(imgPath), "%sscrollbar_box.png", themePath); - scrollbarBox = new GuiImageData(imgPath, scrollbar_box_png); - scrollbarBoxImg = new GuiImage(scrollbarBox); - scrollbarBoxOver = new GuiImageData(imgPath, scrollbar_box_png); - scrollbarBoxOverImg = new GuiImage(scrollbarBoxOver); - - arrowUpBtn = new GuiButton(arrowUpImg->GetWidth(), arrowUpImg->GetHeight()); - arrowUpBtn->SetParent(this); - arrowUpBtn->SetImage(arrowUpImg); - arrowUpBtn->SetImageOver(arrowUpOverImg); - arrowUpBtn->SetImageHold(arrowUpOverImg); - arrowUpBtn->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - arrowUpBtn->SetPosition(width/2-18+7,-18); - arrowUpBtn->SetSelectable(false); - arrowUpBtn->SetTrigger(trigA); - arrowUpBtn->SetEffectOnOver(EFFECT_SCALE, 50, 130); - arrowUpBtn->SetSoundClick(btnSoundClick); - - arrowDownBtn = new GuiButton(arrowDownImg->GetWidth(), arrowDownImg->GetHeight()); - arrowDownBtn->SetParent(this); - arrowDownBtn->SetImage(arrowDownImg); - arrowDownBtn->SetImageOver(arrowDownOverImg); - arrowDownBtn->SetImageHold(arrowDownOverImg); - arrowDownBtn->SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); - arrowDownBtn->SetPosition(width/2-18+7,18); - arrowDownBtn->SetSelectable(false); - arrowDownBtn->SetTrigger(trigA); - arrowDownBtn->SetEffectOnOver(EFFECT_SCALE, 50, 130); - arrowDownBtn->SetSoundClick(btnSoundClick); - - scrollbarBoxBtn = new GuiButton(scrollbarBoxImg->GetWidth(), scrollbarBoxImg->GetHeight()); - scrollbarBoxBtn->SetParent(this); - scrollbarBoxBtn->SetImage(scrollbarBoxImg); - scrollbarBoxBtn->SetImageOver(scrollbarBoxOverImg); - scrollbarBoxBtn->SetImageHold(scrollbarBoxOverImg); - scrollbarBoxBtn->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - scrollbarBoxBtn->SetSelectable(false); - scrollbarBoxBtn->SetEffectOnOver(EFFECT_SCALE, 50, 120); - scrollbarBoxBtn->SetMinY(0); - scrollbarBoxBtn->SetMaxY(height-30); - scrollbarBoxBtn->SetHoldable(true); - scrollbarBoxBtn->SetTrigger(trigHeldA); - - gameIndex = new int[pagesize]; - game = new GuiButton * [pagesize]; - gameTxt = new GuiText * [pagesize]; - gameTxtOver = new GuiText * [pagesize]; - gameBg = new GuiImage * [pagesize]; - newImg = new GuiImage * [pagesize]; - - for(int i=0; i < pagesize; i++) - { - gameTxt[i] = new GuiText(get_title(&gameList[i]), 20, THEME.gametext); - gameTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - gameTxt[i]->SetPosition(24,0); - gameTxt[i]->SetMaxWidth(maxTextWidth, GuiText::DOTTED); - - - gameTxtOver[i] = new GuiText(get_title(&gameList[i]), 20, THEME.gametext); - gameTxtOver[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - gameTxtOver[i]->SetPosition(24,0); - gameTxtOver[i]->SetMaxWidth(maxTextWidth, GuiText::SCROLL); - - gameBg[i] = new GuiImage(bgGamesEntry); - - newImg[i] = new GuiImage(newGames); - newImg[i]->SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE); - newImg[i]->SetVisible(false); - - game[i] = new GuiButton(width-28,GAMESELECTSIZE); - game[i]->SetParent(this); - game[i]->SetLabel(gameTxt[i]); - game[i]->SetLabelOver(gameTxtOver[i]); - game[i]->SetIcon(newImg[i]); - game[i]->SetImageOver(gameBg[i]); - game[i]->SetPosition(5,GAMESELECTSIZE*i+4); - game[i]->SetRumble(false); - game[i]->SetTrigger(trigA); - game[i]->SetSoundClick(btnSoundClick); - - gameIndex[i] = i; - } - UpdateListEntries(); -} - -/** - * Destructor for the GuiGameBrowser class. - */ -GuiGameBrowser::~GuiGameBrowser() -{ - delete arrowUpBtn; - delete arrowDownBtn; - delete scrollbarBoxBtn; - delete scrollbarImg; - delete arrowDownImg; - delete arrowDownOverImg; - delete arrowUpImg; - delete arrowUpOverImg; - delete scrollbarBoxImg; - delete scrollbarBoxOverImg; - delete scrollbar; - delete arrowDown; - delete arrowDownOver; - delete arrowUp; - delete arrowUpOver; - delete scrollbarBox; - delete scrollbarBoxOver; - delete bgGameImg; - delete bgGames; - delete bgGamesEntry; - delete newGames; - - delete trigA; - delete trigHeldA; - delete btnSoundClick; - - for(int i=0; iResetState(); - - if(f == 1) - game[selectedItem]->SetState(STATE_SELECTED); -} - -void GuiGameBrowser::ResetState() -{ - LOCK(this); - if(state != STATE_DISABLED) - { - state = STATE_DEFAULT; - stateChan = -1; - } - - for(int i=0; iResetState(); - } -} - -int GuiGameBrowser::GetOffset() -{ - return listOffset; -} -int GuiGameBrowser::GetClickedOption() -{ - int found = -1; - for(int i=0; iGetState() == STATE_CLICKED) - { - game[i]->SetState(STATE_SELECTED); - found = gameIndex[i]; - break; - } - } - return found; -} - -int GuiGameBrowser::GetSelectedOption() -{ - int found = -1; - for(int i=0; iGetState() == STATE_SELECTED) - { - game[i]->SetState(STATE_SELECTED); - found = gameIndex[i]; - break; - } - } - return found; -} - -/**************************************************************************** - * FindMenuItem - * - * Help function to find the next visible menu item on the list - ***************************************************************************/ - -int GuiGameBrowser::FindMenuItem(int currentItem, int direction) -{ - int nextItem = currentItem + direction; - - if(nextItem < 0 || nextItem >= gameCnt) - return -1; - - if(strlen(get_title(&gameList[nextItem])) > 0) - return nextItem; - else - return FindMenuItem(nextItem, direction); -} - -/** - * Draw the button on screen - */ -void GuiGameBrowser::Draw() -{ - LOCK(this); - if(!this->IsVisible() || !gameCnt) - return; - - bgGameImg->Draw(); - - int next = listOffset; - - for(int i=0; i= 0) - { - game[i]->Draw(); - next = this->FindMenuItem(next, 1); - } - else - break; - } - - if(scrollbaron == 1) { - scrollbarImg->Draw(); - arrowUpBtn->Draw(); - arrowDownBtn->Draw(); - scrollbarBoxBtn->Draw(); - } - this->UpdateEffects(); -} - -void GuiGameBrowser::UpdateListEntries() -{ - int next = listOffset; - for(int i=0; i= 0) - { - if(game[i]->GetState() == STATE_DISABLED) - { - game[i]->SetVisible(true); - game[i]->SetState(STATE_DEFAULT); - } - gameTxt[i]->SetText(get_title(&gameList[next])); - gameTxt[i]->SetPosition(24, 0); - gameTxtOver[i]->SetText(get_title(&gameList[next])); - gameTxtOver[i]->SetPosition(24, 0); - - if (Settings.marknewtitles) { - bool isNew = NewTitles::Instance()->IsNew(gameList[next].id); - if (isNew) { - gameTxt[i]->SetMaxWidth(maxTextWidth - (newGames->GetWidth() + 1), GuiText::DOTTED); - gameTxtOver[i]->SetMaxWidth(maxTextWidth - (newGames->GetWidth() + 1), GuiText::SCROLL); - } else { - gameTxt[i]->SetMaxWidth(maxTextWidth, GuiText::DOTTED); - gameTxtOver[i]->SetMaxWidth(maxTextWidth, GuiText::SCROLL); - } - newImg[i]->SetVisible(isNew); - } - - gameIndex[i] = next; - next = this->FindMenuItem(next, 1); - } - else - { - game[i]->SetVisible(false); - game[i]->SetState(STATE_DISABLED); - } - } -} - -void GuiGameBrowser::Update(GuiTrigger * t) -{ - LOCK(this); - if(state == STATE_DISABLED || !t || !gameCnt) - return; - - int next, prev; - int old_listOffset = listOffset; - static int position2; - // scrolldelay affects how fast the list scrolls - // when the arrows are clicked - float scrolldelay = 3.5; - - if (scrollbaron == 1) { - // update the location of the scroll box based on the position in the option list - arrowUpBtn->Update(t); - arrowDownBtn->Update(t); - scrollbarBoxBtn->Update(t); - } - - next = listOffset; - - u32 buttonshold = ButtonsHold(); - - if(buttonshold != WPAD_BUTTON_UP && buttonshold != WPAD_BUTTON_DOWN) { - - for(int i=0; i= 0) - next = this->FindMenuItem(next, 1); - - if(focus) - { - if(i != selectedItem && game[i]->GetState() == STATE_SELECTED) - game[i]->ResetState(); - else if(i == selectedItem && game[i]->GetState() == STATE_DEFAULT) - game[selectedItem]->SetState(STATE_SELECTED, t->chan); - } - - game[i]->Update(t); - - if(game[i]->GetState() == STATE_SELECTED) - { - selectedItem = i; - } - } - } - - // pad and joystick navigation - if(!focus || !gameCnt) - return; // skip navigation - - if (scrollbaron == 1) - { - - if (t->Down() || arrowDownBtn->GetState() == STATE_CLICKED || arrowDownBtn->GetState() == STATE_HELD) //down - { - - next = this->FindMenuItem(gameIndex[selectedItem], 1); - - if(next >= 0) - { - if(selectedItem == pagesize-1) - { - // move list down by 1 - listOffset = this->FindMenuItem(listOffset, 1); - } - else if(game[selectedItem+1]->IsVisible()) - { - game[selectedItem]->ResetState(); - game[selectedItem+1]->SetState(STATE_SELECTED, t->chan); - selectedItem++; - } -// scrollbarBoxBtn->Draw(); - usleep(10000 * scrolldelay); - } - if (!(ButtonsHold() & WPAD_BUTTON_A)) - arrowDownBtn->ResetState(); - } - else if(t->Up() || arrowUpBtn->GetState() == STATE_CLICKED || arrowUpBtn->GetState() == STATE_HELD) //up - { - prev = this->FindMenuItem(gameIndex[selectedItem], -1); - - if(prev >= 0) - { - if(selectedItem == 0) - { - // move list up by 1 - listOffset = prev; - } - else - { - game[selectedItem]->ResetState(); - game[selectedItem-1]->SetState(STATE_SELECTED, t->chan); - selectedItem--; - } -// scrollbarBoxBtn->Draw(); - usleep(10000 * scrolldelay); - } - if (!(ButtonsHold() & WPAD_BUTTON_A)) - arrowUpBtn->ResetState(); - } - int position1 = t->wpad.ir.y; - - if (position2 == 0 && position1 > 0) - { - position2 = position1; - } - - if ((buttonshold & WPAD_BUTTON_B) && position1 > 0) - { - scrollbarBoxBtn->ScrollIsOn(1); - if (position2 > position1) - { - - prev = this->FindMenuItem(gameIndex[selectedItem], -1); - - if(prev >= 0) - { - if(selectedItem == 0) - { - // move list up by 1 - listOffset = prev; - } - else - { - game[selectedItem]->ResetState(); - game[selectedItem-1]->SetState(STATE_SELECTED, t->chan); - selectedItem--; - } -// scrollbarBoxBtn->Draw(); - usleep(10000 * scrolldelay); - } - } - else if (position2 < position1) - { - next = this->FindMenuItem(gameIndex[selectedItem], 1); - - if(next >= 0) - { - if(selectedItem == pagesize-1) - { - // move list down by 1 - listOffset = this->FindMenuItem(listOffset, 1); - } - else if(game[selectedItem+1]->IsVisible()) - { - game[selectedItem]->ResetState(); - game[selectedItem+1]->SetState(STATE_SELECTED, t->chan); - selectedItem++; - } -// scrollbarBoxBtn->Draw(); - usleep(10000 * scrolldelay); - } - } - - } - else if(!(buttonshold & WPAD_BUTTON_B)) - { - scrollbarBoxBtn->ScrollIsOn(0); - position2 = 0; - } - - if(scrollbarBoxBtn->GetState() == STATE_HELD && scrollbarBoxBtn->GetStateChan() == t->chan && t->wpad.ir.valid && gameCnt > pagesize) - { - // allow dragging of scrollbar box - scrollbarBoxBtn->SetPosition(width/2-18+7,0); - int position = t->wpad.ir.y - 32 - scrollbarBoxBtn->GetTop(); - - listOffset = (position * gameCnt)/(25.2 * pagesize) - selectedItem; - - if(listOffset <= 0) - { - listOffset = 0; - selectedItem = 0; - } - else if(listOffset+pagesize >= gameCnt) - { - listOffset = gameCnt - pagesize; - selectedItem = pagesize-1; - } - - } - int positionbar = (25.2 * pagesize)*(listOffset + selectedItem) / gameCnt; - - if(positionbar > (24 * pagesize)) - positionbar = (24 * pagesize); - scrollbarBoxBtn->SetPosition(width/2-18+7, positionbar+8); - - - if(t->Right()) //skip pagesize # of games if right is pressed - { - if(listOffset < gameCnt && gameCnt > pagesize) - { - listOffset =listOffset+ pagesize; - if(listOffset+pagesize >= gameCnt) - listOffset = gameCnt-pagesize; - } - } - else if(t->Left()) - { - if(listOffset > 0) - { - listOffset =listOffset- pagesize; - if(listOffset < 0) - listOffset = 0; - } - } - - } - else - { - if(t->Down()) //if there isn't a scrollbar and down is pressed - { - next = this->FindMenuItem(gameIndex[selectedItem], 1); - - if(next >= 0) - { - if(selectedItem == pagesize-1) - { - // move list down by 1 - listOffset = this->FindMenuItem(listOffset, 1); - } - else if(game[selectedItem+1]->IsVisible()) - { - game[selectedItem]->ResetState(); - game[selectedItem+1]->SetState(STATE_SELECTED, t->chan); - selectedItem++; - } - } - } - else if(t->Up()) //up - { - prev = this->FindMenuItem(gameIndex[selectedItem], -1); - - if(prev >= 0) - { - if(selectedItem == 0) - { - // move list up by 1 - listOffset = prev; - } - else - { - game[selectedItem]->ResetState(); - game[selectedItem-1]->SetState(STATE_SELECTED, t->chan); - selectedItem--; - } - } - } - } - - if(old_listOffset != listOffset) - UpdateListEntries(); - - if(updateCB) - updateCB(this); -} - -void GuiGameBrowser::Reload(struct discHdr * l, int count) -{ - LOCK(this); - gameList = l; - gameCnt = count; - scrollbaron = (gameCnt > pagesize) ? 1 : 0; - selectedItem = 0; - listOffset = 0; - focus = 1; - UpdateListEntries(); - - for(int i=0; iResetState(); -} +/**************************************************************************** + * libwiigui + * + * gui_gamebrowser.cpp + * + * GUI class definitions + ***************************************************************************/ + +#include "gui.h" +#include "../wpad.h" + +#include +#include "gui_gamebrowser.h" +#include "../settings/cfg.h" +#include "../main.h" +#include "settings/newtitles.h" + +#include +#include + +#define GAMESELECTSIZE 30 +int txtscroll = 0; +/** + * Constructor for the GuiGameBrowser class. + */ +GuiGameBrowser::GuiGameBrowser(int w, int h, struct discHdr * l, int gameCnt, const char *themePath, const u8 *imagebg, int selected, int offset) +{ + width = w; + height = h; + this->gameCnt = gameCnt; + gameList = l; + pagesize = THEME.pagesize; + scrollbaron = (gameCnt > pagesize) ? 1 : 0; + selectable = true; + listOffset = MAX(0,MIN(offset,(gameCnt-pagesize))); + selectedItem = selected - offset; + focus = 1; // allow focus + char imgPath[100]; + + trigA = new GuiTrigger; + trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + trigHeldA = new GuiTrigger; + trigHeldA->SetHeldTrigger(-1, WPAD_BUTTON_A, PAD_BUTTON_A); + btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, Settings.sfxvolume); + + snprintf(imgPath, sizeof(imgPath), "%sbg_options.png", themePath); + bgGames = new GuiImageData(imgPath, imagebg); + + snprintf(imgPath, sizeof(imgPath), "%snew.png", themePath); + newGames = new GuiImageData(imgPath, new_png); + + bgGameImg = new GuiImage(bgGames); + bgGameImg->SetParent(this); + bgGameImg->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + + maxTextWidth = bgGameImg->GetWidth() - 24 - 4; + + snprintf(imgPath, sizeof(imgPath), "%sbg_options_entry.png", themePath); + bgGamesEntry = new GuiImageData(imgPath, bg_options_entry_png); + + snprintf(imgPath, sizeof(imgPath), "%sscrollbar.png", themePath); + scrollbar = new GuiImageData(imgPath, scrollbar_png); + scrollbarImg = new GuiImage(scrollbar); + scrollbarImg->SetParent(this); + scrollbarImg->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); + scrollbarImg->SetPosition(0, 4); + + maxTextWidth -= scrollbarImg->GetWidth() + 4; + + snprintf(imgPath, sizeof(imgPath), "%sscrollbar_arrowdown.png", themePath); + arrowDown = new GuiImageData(imgPath, scrollbar_arrowdown_png); + arrowDownImg = new GuiImage(arrowDown); + arrowDownOver = new GuiImageData(imgPath, scrollbar_arrowdown_png); + arrowDownOverImg = new GuiImage(arrowDownOver); + snprintf(imgPath, sizeof(imgPath), "%sscrollbar_arrowup.png", themePath); + arrowUp = new GuiImageData(imgPath, scrollbar_arrowup_png); + arrowUpImg = new GuiImage(arrowUp); + arrowUpOver = new GuiImageData(imgPath, scrollbar_arrowup_png); + arrowUpOverImg = new GuiImage(arrowUpOver); + snprintf(imgPath, sizeof(imgPath), "%sscrollbar_box.png", themePath); + scrollbarBox = new GuiImageData(imgPath, scrollbar_box_png); + scrollbarBoxImg = new GuiImage(scrollbarBox); + scrollbarBoxOver = new GuiImageData(imgPath, scrollbar_box_png); + scrollbarBoxOverImg = new GuiImage(scrollbarBoxOver); + + arrowUpBtn = new GuiButton(arrowUpImg->GetWidth(), arrowUpImg->GetHeight()); + arrowUpBtn->SetParent(this); + arrowUpBtn->SetImage(arrowUpImg); + arrowUpBtn->SetImageOver(arrowUpOverImg); + arrowUpBtn->SetImageHold(arrowUpOverImg); + arrowUpBtn->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + arrowUpBtn->SetPosition(width/2-18+7,-18); + arrowUpBtn->SetSelectable(false); + arrowUpBtn->SetTrigger(trigA); + arrowUpBtn->SetEffectOnOver(EFFECT_SCALE, 50, 130); + arrowUpBtn->SetSoundClick(btnSoundClick); + + arrowDownBtn = new GuiButton(arrowDownImg->GetWidth(), arrowDownImg->GetHeight()); + arrowDownBtn->SetParent(this); + arrowDownBtn->SetImage(arrowDownImg); + arrowDownBtn->SetImageOver(arrowDownOverImg); + arrowDownBtn->SetImageHold(arrowDownOverImg); + arrowDownBtn->SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); + arrowDownBtn->SetPosition(width/2-18+7,18); + arrowDownBtn->SetSelectable(false); + arrowDownBtn->SetTrigger(trigA); + arrowDownBtn->SetEffectOnOver(EFFECT_SCALE, 50, 130); + arrowDownBtn->SetSoundClick(btnSoundClick); + + scrollbarBoxBtn = new GuiButton(scrollbarBoxImg->GetWidth(), scrollbarBoxImg->GetHeight()); + scrollbarBoxBtn->SetParent(this); + scrollbarBoxBtn->SetImage(scrollbarBoxImg); + scrollbarBoxBtn->SetImageOver(scrollbarBoxOverImg); + scrollbarBoxBtn->SetImageHold(scrollbarBoxOverImg); + scrollbarBoxBtn->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + scrollbarBoxBtn->SetSelectable(false); + scrollbarBoxBtn->SetEffectOnOver(EFFECT_SCALE, 50, 120); + scrollbarBoxBtn->SetMinY(0); + scrollbarBoxBtn->SetMaxY(height-30); + scrollbarBoxBtn->SetHoldable(true); + scrollbarBoxBtn->SetTrigger(trigHeldA); + + gameIndex = new int[pagesize]; + game = new GuiButton * [pagesize]; + gameTxt = new GuiText * [pagesize]; + gameTxtOver = new GuiText * [pagesize]; + gameBg = new GuiImage * [pagesize]; + newImg = new GuiImage * [pagesize]; + + for(int i=0; i < pagesize; i++) + { + gameTxt[i] = new GuiText(NULL, 20, THEME.gametext); + gameTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + gameTxt[i]->SetPosition(24,0); + gameTxt[i]->SetMaxWidth(maxTextWidth, GuiText::DOTTED); + + + gameTxtOver[i] = new GuiText(NULL, 20, THEME.gametext); + gameTxtOver[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + gameTxtOver[i]->SetPosition(24,0); + gameTxtOver[i]->SetMaxWidth(maxTextWidth, GuiText::SCROLL); + + gameBg[i] = new GuiImage(bgGamesEntry); + + newImg[i] = new GuiImage(newGames); + newImg[i]->SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE); + newImg[i]->SetVisible(false); + + game[i] = new GuiButton(width-28,GAMESELECTSIZE); + game[i]->SetParent(this); + game[i]->SetLabel(gameTxt[i]); + game[i]->SetLabelOver(gameTxtOver[i]); + game[i]->SetIcon(newImg[i]); + game[i]->SetImageOver(gameBg[i]); + game[i]->SetPosition(5,GAMESELECTSIZE*i+4); + game[i]->SetRumble(false); + game[i]->SetTrigger(trigA); + game[i]->SetSoundClick(btnSoundClick); + + gameIndex[i] = i; + } + UpdateListEntries(); +} + +/** + * Destructor for the GuiGameBrowser class. + */ +GuiGameBrowser::~GuiGameBrowser() +{ + delete arrowUpBtn; + delete arrowDownBtn; + delete scrollbarBoxBtn; + delete scrollbarImg; + delete arrowDownImg; + delete arrowDownOverImg; + delete arrowUpImg; + delete arrowUpOverImg; + delete scrollbarBoxImg; + delete scrollbarBoxOverImg; + delete scrollbar; + delete arrowDown; + delete arrowDownOver; + delete arrowUp; + delete arrowUpOver; + delete scrollbarBox; + delete scrollbarBoxOver; + delete bgGameImg; + delete bgGames; + delete bgGamesEntry; + delete newGames; + + delete trigA; + delete trigHeldA; + delete btnSoundClick; + + for(int i=0; iResetState(); + + if(f == 1) + game[selectedItem]->SetState(STATE_SELECTED); +} + +void GuiGameBrowser::ResetState() +{ + LOCK(this); + if(state != STATE_DISABLED) + { + state = STATE_DEFAULT; + stateChan = -1; + } + + for(int i=0; iResetState(); + } +} + +int GuiGameBrowser::GetOffset() +{ + return listOffset; +} +int GuiGameBrowser::GetClickedOption() +{ + int found = -1; + for(int i=0; iGetState() == STATE_CLICKED) + { + game[i]->SetState(STATE_SELECTED); + found = gameIndex[i]; + break; + } + } + return found; +} + +int GuiGameBrowser::GetSelectedOption() +{ + int found = -1; + for(int i=0; iGetState() == STATE_SELECTED) + { + game[i]->SetState(STATE_SELECTED); + found = gameIndex[i]; + break; + } + } + return found; +} + +/**************************************************************************** + * FindMenuItem + * + * Help function to find the next visible menu item on the list + ***************************************************************************/ + +int GuiGameBrowser::FindMenuItem(int currentItem, int direction) +{ + int nextItem = currentItem + direction; + + if(nextItem < 0 || nextItem >= gameCnt) + return -1; + + if(strlen(get_title(&gameList[nextItem])) > 0) + return nextItem; + else + return FindMenuItem(nextItem, direction); +} + +/** + * Draw the button on screen + */ +void GuiGameBrowser::Draw() +{ + LOCK(this); + if(!this->IsVisible() || !gameCnt) + return; + + bgGameImg->Draw(); + + int next = listOffset; + + for(int i=0; i= 0) + { + game[i]->Draw(); + next = this->FindMenuItem(next, 1); + } + else + break; + } + + if(scrollbaron == 1) { + scrollbarImg->Draw(); + arrowUpBtn->Draw(); + arrowDownBtn->Draw(); + scrollbarBoxBtn->Draw(); + } + this->UpdateEffects(); +} + +void GuiGameBrowser::UpdateListEntries() +{ + if(!gameList) + return; + + int next = listOffset; + for(int i=0; i= 0) + { + if(game[i]->GetState() == STATE_DISABLED) + { + game[i]->SetVisible(true); + game[i]->SetState(STATE_DEFAULT); + } + gameTxt[i]->SetText(get_title(&gameList[next])); + gameTxt[i]->SetPosition(24, 0); + gameTxtOver[i]->SetText(get_title(&gameList[next])); + gameTxtOver[i]->SetPosition(24, 0); + + if (Settings.marknewtitles) { + bool isNew = NewTitles::Instance()->IsNew(gameList[next].id); + if (isNew) { + gameTxt[i]->SetMaxWidth(maxTextWidth - (newGames->GetWidth() + 1), GuiText::DOTTED); + gameTxtOver[i]->SetMaxWidth(maxTextWidth - (newGames->GetWidth() + 1), GuiText::SCROLL); + } else { + gameTxt[i]->SetMaxWidth(maxTextWidth, GuiText::DOTTED); + gameTxtOver[i]->SetMaxWidth(maxTextWidth, GuiText::SCROLL); + } + newImg[i]->SetVisible(isNew); + } + + gameIndex[i] = next; + next = this->FindMenuItem(next, 1); + } + else + { + game[i]->SetVisible(false); + game[i]->SetState(STATE_DISABLED); + } + } +} + +void GuiGameBrowser::Update(GuiTrigger * t) +{ + LOCK(this); + if(state == STATE_DISABLED || !t || !gameCnt) + return; + + int next, prev; + int old_listOffset = listOffset; + static int position2; + // scrolldelay affects how fast the list scrolls + // when the arrows are clicked + float scrolldelay = 3.5; + + if (scrollbaron == 1) { + // update the location of the scroll box based on the position in the option list + arrowUpBtn->Update(t); + arrowDownBtn->Update(t); + scrollbarBoxBtn->Update(t); + } + + next = listOffset; + + u32 buttonshold = ButtonsHold(); + + if(buttonshold != WPAD_BUTTON_UP && buttonshold != WPAD_BUTTON_DOWN) { + + for(int i=0; i= 0) + next = this->FindMenuItem(next, 1); + + if(focus) + { + if(i != selectedItem && game[i]->GetState() == STATE_SELECTED) + game[i]->ResetState(); + else if(i == selectedItem && game[i]->GetState() == STATE_DEFAULT) + game[selectedItem]->SetState(STATE_SELECTED, t->chan); + } + + game[i]->Update(t); + + if(game[i]->GetState() == STATE_SELECTED) + { + selectedItem = i; + } + } + } + + // pad and joystick navigation + if(!focus || !gameCnt) + return; // skip navigation + + if (scrollbaron == 1) + { + + if (t->Down() || arrowDownBtn->GetState() == STATE_CLICKED || arrowDownBtn->GetState() == STATE_HELD) //down + { + + next = this->FindMenuItem(gameIndex[selectedItem], 1); + + if(next >= 0) + { + if(selectedItem == pagesize-1) + { + // move list down by 1 + listOffset = this->FindMenuItem(listOffset, 1); + } + else if(game[selectedItem+1]->IsVisible()) + { + game[selectedItem]->ResetState(); + game[selectedItem+1]->SetState(STATE_SELECTED, t->chan); + selectedItem++; + } +// scrollbarBoxBtn->Draw(); + usleep(10000 * scrolldelay); + } + if (!(ButtonsHold() & WPAD_BUTTON_A)) + arrowDownBtn->ResetState(); + } + else if(t->Up() || arrowUpBtn->GetState() == STATE_CLICKED || arrowUpBtn->GetState() == STATE_HELD) //up + { + prev = this->FindMenuItem(gameIndex[selectedItem], -1); + + if(prev >= 0) + { + if(selectedItem == 0) + { + // move list up by 1 + listOffset = prev; + } + else + { + game[selectedItem]->ResetState(); + game[selectedItem-1]->SetState(STATE_SELECTED, t->chan); + selectedItem--; + } +// scrollbarBoxBtn->Draw(); + usleep(10000 * scrolldelay); + } + if (!(ButtonsHold() & WPAD_BUTTON_A)) + arrowUpBtn->ResetState(); + } + int position1 = t->wpad.ir.y; + + if (position2 == 0 && position1 > 0) + { + position2 = position1; + } + + if ((buttonshold & WPAD_BUTTON_B) && position1 > 0) + { + scrollbarBoxBtn->ScrollIsOn(1); + if (position2 > position1) + { + + prev = this->FindMenuItem(gameIndex[selectedItem], -1); + + if(prev >= 0) + { + if(selectedItem == 0) + { + // move list up by 1 + listOffset = prev; + } + else + { + game[selectedItem]->ResetState(); + game[selectedItem-1]->SetState(STATE_SELECTED, t->chan); + selectedItem--; + } +// scrollbarBoxBtn->Draw(); + usleep(10000 * scrolldelay); + } + } + else if (position2 < position1) + { + next = this->FindMenuItem(gameIndex[selectedItem], 1); + + if(next >= 0) + { + if(selectedItem == pagesize-1) + { + // move list down by 1 + listOffset = this->FindMenuItem(listOffset, 1); + } + else if(game[selectedItem+1]->IsVisible()) + { + game[selectedItem]->ResetState(); + game[selectedItem+1]->SetState(STATE_SELECTED, t->chan); + selectedItem++; + } +// scrollbarBoxBtn->Draw(); + usleep(10000 * scrolldelay); + } + } + + } + else if(!(buttonshold & WPAD_BUTTON_B)) + { + scrollbarBoxBtn->ScrollIsOn(0); + position2 = 0; + } + + if(scrollbarBoxBtn->GetState() == STATE_HELD && scrollbarBoxBtn->GetStateChan() == t->chan && t->wpad.ir.valid && gameCnt > pagesize) + { + // allow dragging of scrollbar box + scrollbarBoxBtn->SetPosition(width/2-18+7,0); + int position = t->wpad.ir.y - 32 - scrollbarBoxBtn->GetTop(); + + listOffset = (position * gameCnt)/(25.2 * pagesize) - selectedItem; + + if(listOffset <= 0) + { + listOffset = 0; + selectedItem = 0; + } + else if(listOffset+pagesize >= gameCnt) + { + listOffset = gameCnt - pagesize; + selectedItem = pagesize-1; + } + + } + int positionbar = (25.2 * pagesize)*(listOffset + selectedItem) / gameCnt; + + if(positionbar > (24 * pagesize)) + positionbar = (24 * pagesize); + scrollbarBoxBtn->SetPosition(width/2-18+7, positionbar+8); + + + if(t->Right()) //skip pagesize # of games if right is pressed + { + if(listOffset < gameCnt && gameCnt > pagesize) + { + listOffset =listOffset+ pagesize; + if(listOffset+pagesize >= gameCnt) + listOffset = gameCnt-pagesize; + } + } + else if(t->Left()) + { + if(listOffset > 0) + { + listOffset =listOffset- pagesize; + if(listOffset < 0) + listOffset = 0; + } + } + + } + else + { + if(t->Down()) //if there isn't a scrollbar and down is pressed + { + next = this->FindMenuItem(gameIndex[selectedItem], 1); + + if(next >= 0) + { + if(selectedItem == pagesize-1) + { + // move list down by 1 + listOffset = this->FindMenuItem(listOffset, 1); + } + else if(game[selectedItem+1]->IsVisible()) + { + game[selectedItem]->ResetState(); + game[selectedItem+1]->SetState(STATE_SELECTED, t->chan); + selectedItem++; + } + } + } + else if(t->Up()) //up + { + prev = this->FindMenuItem(gameIndex[selectedItem], -1); + + if(prev >= 0) + { + if(selectedItem == 0) + { + // move list up by 1 + listOffset = prev; + } + else + { + game[selectedItem]->ResetState(); + game[selectedItem-1]->SetState(STATE_SELECTED, t->chan); + selectedItem--; + } + } + } + } + + if(old_listOffset != listOffset) + UpdateListEntries(); + + if(updateCB) + updateCB(this); +} + +void GuiGameBrowser::Reload(struct discHdr * l, int count) +{ + LOCK(this); + gameList = l; + gameCnt = count; + scrollbaron = (gameCnt > pagesize) ? 1 : 0; + selectedItem = 0; + listOffset = 0; + focus = 1; + UpdateListEntries(); + + for(int i=0; iResetState(); +} diff --git a/source/main.cpp b/source/main.cpp index 64919f01..f7deff8a 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -15,14 +15,13 @@ #include #include #include +#include #include //#include -extern "C" -{ - extern void __exception_setreload(int t); +extern "C" { +extern void __exception_setreload(int t); } - #include #include @@ -50,436 +49,144 @@ extern "C" #include "usbloader/usbstorage.h" #include "memory/mem2.h" #include "lstub.h" +#include "xml/xml.h" +#include "settings/newtitles.h" +#include "menu/menus.h" extern bool geckoinit; extern bool textVideoInit; extern char headlessID[8]; +PartList partitions; /* Constants */ -#define CONSOLE_XCOORD 260 -#define CONSOLE_YCOORD 115 -#define CONSOLE_WIDTH 340 -#define CONSOLE_HEIGHT 218 +#define CONSOLE_XCOORD 260 +#define CONSOLE_YCOORD 115 +#define CONSOLE_WIDTH 340 +#define CONSOLE_HEIGHT 218 FreeTypeGX *fontSystem=0; FreeTypeGX *fontClock=0; -PartList partitions; -u8 dbvideo =0; - -static void BootUpProblems() +void LoadHeadlessID(const char * ID) { - s32 ret2; - - // load main font from file, or default to built-in font - fontSystem = new FreeTypeGX(); - fontSystem->loadFont(NULL, font_ttf, font_ttf_size, 0); - fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE); - - GuiImageData bootimageData(gxlogo_png); - GuiImage bootimage(&bootimageData); - GuiText boottext(NULL, 20, (GXColor) {255, 255, 255, 255} - ); - boottext.SetPosition(200, 240-1.2*bootimage.GetHeight()/2+250); - bootimage.SetPosition(320-1.2*bootimage.GetWidth()/2, 240-1.2*bootimage.GetHeight()/2); - bootimage.SetScale(1.2); - - GuiImageData usbimageData(usbport_png); - GuiImage usbimage(&usbimageData); - usbimage.SetPosition(400,300); - usbimage.SetScale(.7); - usbimage.SetAlpha(200); - - time_t curtime; + InitTextVideo(); + strncpy(headlessID, ID, sizeof(headlessID)); + InitCheckThread(); time_t endtime = time(0) + 30; - do + time_t curtime; + printf("\tWaiting for USB-Device:\n"); + while(checkthreadState != 1) { - /*ret2 = IOS_ReloadIOSsafe(249); - if (ret2 < 0) { - ret2 = IOS_ReloadIOSsafe(222); - SDCard_Init(); - load_ehc_module(); - SDCard_deInit(); - if(ret2 <0) { - boottext.SetText("ERROR: cIOS could not be loaded!"); - bootimage.Draw(); - boottext.Draw(); - Menu_Render(); - sleep(5); - SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); - } - }*/ - USBDevice_deInit(); - USBDevice_Init(); - ret2 = WBFS_Init(WBFS_DEVICE_USB); - if (ret2 >= 0) - { - boottext.SetText("Loading..."); - bootimage.Draw(); - boottext.Draw(); - Menu_Render(); - break; - } + usleep(100); curtime = time(0); - boottext.SetTextf("Waiting for your slow USB Device: %i secs...", int(endtime-curtime)); - while(curtime == time(0)) + printf("\t\t%d\n", int(endtime-curtime)); + if(endtime == curtime) { - boottext.Draw(); - bootimage.Draw(); - if (endtime-curtime<15)usbimage.Draw(); - Menu_Render(); + printf("\n\tDevice could not be loaded.\n\tExiting...\n"); + sleep(5); + SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } - } while((endtime-time(0)) > 0); - - /*if(ret2 < 0) { - boottext.SetText("ERROR: USB device could not be loaded!"); - usbimage.Draw(); - bootimage.Draw(); - boottext.Draw(); - Menu_Render(); - SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); - }*/ - - ///delete font to load up custom if set - if(fontSystem) - { - delete fontSystem; - fontSystem = NULL; } + mountMethod = 0; + checkthreadState = 0; + ExitCheckThread(); + CloseXMLDatabase(); + NewTitles::DestroyInstance(); + ShutdownAudio(); + StopGX(); + gettextCleanUp(); + menuBootgame(headlessID); } - -unsigned int *xfb = NULL; - -void InitTextVideo () +int main(int argc, char *argv[]) { - gprintf("\nInitTextVideo ()"); - if (textVideoInit) - { - gprintf("...0"); - return; - } - dbvideo=1; - VIDEO_Init(); - // get default video mode - GXRModeObj *vmode = VIDEO_GetPreferredMode(NULL); + setlocale(LC_ALL, "en.UTF-8"); + geckoinit = InitGecko(); - // widescreen fix - VIDEO_Configure (vmode); + if (hbcStubAvailable() || geckoinit) + InitTextVideo(); - // Allocate the video buffers - xfb = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode)); + __exception_setreload(5);//auto reset code dump nobody gives us codedump info anyways. - // A console is always useful while debugging - console_init (xfb, 20, 64, vmode->fbWidth, vmode->xfbHeight, vmode->fbWidth * 2); - - // Clear framebuffers etc. - VIDEO_ClearFrameBuffer (vmode, xfb, COLOR_BLACK); - VIDEO_SetNextFramebuffer (xfb); - - VIDEO_SetBlack (FALSE); - VIDEO_Flush (); - VIDEO_WaitVSync (); - if (vmode->viTVMode & VI_NON_INTERLACE) - VIDEO_WaitVSync (); - - //send console output to the gecko - if (geckoinit)CON_EnableGecko(1, true); - textVideoInit = true; - gprintf("...1"); - -} - - -int -main(int argc, char *argv[]) -{ - setlocale(LC_ALL, "en.UTF-8"); - geckoinit = InitGecko(); - - if (hbcStubAvailable() || geckoinit) - { - InitTextVideo(); - } - - // DEBUG_Init(GDBSTUB_DEVICE_USB, 1); - //_break(); - - __exception_setreload(5); //auto reset code dump nobody gives us codedump info anyways. - - gprintf("\n\n------------------"); - gprintf("\nUSB Loader GX rev%s",GetRev()); - gprintf("\nmain(%d", argc); - for (int i=0;i"); + gprintf("\n\n------------------"); + gprintf("\nUSB Loader GX rev%s linked with %s",GetRev(), _V_STRING); + gprintf("\nmain(%d", argc); + for (int i=0;i"); gprintf(")"); // This part is added, because we need a identify patched ios -// printf("\n\tReloading into ios 236"); - if (IOS_ReloadIOSsafe(236) < 0) - { -// printf("\n\tIOS 236 not found, reloading into 36"); - IOS_ReloadIOSsafe(36); - } + //printf("\n\tReloading into ios 236"); + if (IOS_ReloadIOSsafe(236) < 0) + IOS_ReloadIOSsafe(36); - printf("\n\tStarting up"); + printf("\n\tStarting up"); - MEM2_init(36); // Initialize 36 MB - MEM2_takeBigOnes(true); + MEM2_init(36); // Initialize 36 MB + MEM2_takeBigOnes(true); s32 ret; - bool startupproblem = false; bool bootDevice_found=false; - if (argc >= 1) - { - if (!strncasecmp(argv[0], "usb:/", 5)) - { + if (argc >= 1) { + if (!strncasecmp(argv[0], "usb:/", 5)) { strcpy(bootDevice, "USB:"); bootDevice_found = true; } else if (!strncasecmp(argv[0], "sd:/", 4)) - bootDevice_found = true; + bootDevice_found = true; } - printf("\n\tInitializing controllers"); + printf("\n\tInitializing controllers"); /** PAD_Init has to be before InitVideo don't move that **/ - PAD_Init(); // initialize PAD/WPAD + PAD_Init(); // initialize PAD/WPAD - printf("\n\tInitialize USB (wake up)"); + printf("\n\tInitialize USB (wake up)"); - USBDevice_Init(); // seems enough to wake up some HDDs if they are in sleep mode when the loader starts (tested with WD MyPassport Essential 2.5") + USBDevice_Init();// seems enough to wake up some HDDs if they are in sleep mode when the loader starts (tested with WD MyPassport Essential 2.5") + USBDevice_deInit(); - gprintf("\n\tChecking for stub IOS"); - ios222rev = getIOSrev(0x00000001000000dell); - ios249rev = getIOSrev(0x00000001000000f9ll); + ret = CheckForCIOS(); - //if we don't like either of the cIOS then scram - if (!(ios222rev==4 || (ios249rev>=9 && ios249rev<65280))) - { - InitTextVideo(); - printf("\x1b[2J"); - if ((ios222rev < 0 && ios222rev != WII_EINSTALL) && (ios249rev < 0 && ios249rev != WII_EINSTALL)) - { - printf("\n\n\n\tWARNING!"); - printf("\n\tUSB Loader GX needs unstubbed cIOS 222 v4 or 249 v9+"); - printf("\n\n\tWe cannot determine the versions on your system,\n\tsince you have no patched ios 36 or 236 installed."); - printf("\n\tTherefor, if loading of USB Loader GX fails, you\n\tprobably have installed the 4.2 update,"); - printf("\n\tand you should go figure out how to get some cios action going on\n\tin your Wii."); - printf("\n\n\tThis message will show every time."); - sleep(5); - } - else - { - printf("\n\n\n\tERROR!"); - printf("\n\tUSB Loader GX needs unstubbed cIOS 222 v4 or 249 v9+"); - printf("\n\n\tI found \n\t\t222 = %d%s",ios222rev,ios222rev==65280?" (Stubbed by 4.2 update)":""); - printf("\n\t\t249 = %d%s",ios249rev,ios249rev==65280?" (Stubbed by 4.2 update)":""); - printf("\n\n\tGo figure out how to get some cIOS action going on\n\tin your Wii and come back and see me."); - - sleep(15); - printf("\n\n\tBye"); - - USBDevice_deInit(); - exit(0); - } - } - - printf("\n\tReloading ios 249..."); - ret = IOS_ReloadIOSsafe(249); - - printf("%d", ret); - - if (ret < 0) - { - printf("\n\tIOS 249 failed, reloading ios 222..."); - ret = IOS_ReloadIOSsafe(222); - printf("%d", ret); - - if (ret < 0) - { - printf("\n\tIOS 222 failed, reloading ios 250..."); - ret = IOS_ReloadIOSsafe(250); - printf("%d", ret); - - if(ret < 0) - { - printf("\n\tIOS 250 failed, reloading ios 223..."); - ret = IOS_ReloadIOSsafe(223); - printf("%d", ret); - - if (ret < 0) - { - printf("\n\tERROR: cIOS could not be loaded!\n"); - sleep(5); - SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); - } - } - } - printf("\n\tInitialize sd card"); - SDCard_Init(); - printf("\n\tLoad ehc module"); - load_ehc_module(); - printf("\n\tdeinit sd card"); - SDCard_deInit(); - } - - printf("\n\tInit wbfs..."); - ret = WBFS_Init(WBFS_DEVICE_USB); - printf("%d", ret); - - if (ret < 0) - { - printf("\n\tYou have issues with a slow disc, or a difficult disc\n\tReloading 222..."); - ret = IOS_ReloadIOSsafe(222); - printf("%d", ret); - /*if(ret < 0) { - // printf("\n\tSleeping for 4 seconds"); - // sleep(4); - - InitVideo(); // Initialise video - Menu_Render(); - BootUpProblems(); - startupproblem = true; - ret = 1; - }*/ - printf("\n\tInitialize sd card"); - SDCard_Init(); - printf("\n\tLoad ehc module"); - load_ehc_module(); - printf("\n\tdeinit sd card"); - SDCard_deInit(); - - printf("\n\tInitialize wbfs..."); - USBDevice_deInit(); - USBDevice_Init(); - ret = WBFS_Init(WBFS_DEVICE_USB); - printf("%d", ret); - - if(ret < 0) - { - // printf("\n\tSleeping for 4 seconds"); - // sleep(4); - InitVideo(); // Initialise video - Menu_Render(); - BootUpProblems(); - startupproblem = true; - ret = 1; - } - } - - printf("\n\tInitialize sd card"); - SDCard_Init(); // mount SD for loading cfg's - - //this should have already been done by now in order to WBFS_Init(). - printf("\n\tInitialize usb device"); - USBDevice_Init(); // and mount USB:/ + printf("\n\tInitialize sd card"); + SDCard_Init(); // mount SD for loading cfg's + printf("\n\tInitialize usb device"); + USBDevice_Init(); // and mount USB:/ if (!bootDevice_found) { - printf("\n\tSearch for configuration file"); - + printf("\n\tSearch for configuration file"); //try USB //left in all the dol and elf files in this check in case this is the first time running the app and they dont have the config if (checkfile((char*) "USB:/config/GXglobal.cfg") || (checkfile((char*) "USB:/apps/usbloader_gx/boot.elf")) - || checkfile((char*) "USB:/apps/usbloadergx/boot.dol") || (checkfile((char*) "USB:/apps/usbloadergx/boot.elf")) - || checkfile((char*) "USB:/apps/usbloader_gx/boot.dol")) + || checkfile((char*) "USB:/apps/usbloadergx/boot.dol") || (checkfile((char*) "USB:/apps/usbloadergx/boot.elf")) + || checkfile((char*) "USB:/apps/usbloader_gx/boot.dol")) strcpy(bootDevice, "USB:"); - printf("\n\tConfiguration file is on %s", bootDevice); - } - - // Try opening and closing the configuration file here - // to prevent a crash dump later on - giantpune - char GXGlobal_cfg[26]; - sprintf(GXGlobal_cfg, "%s/config/GXGlobal.cfg", bootDevice); - FILE *fp = fopen(GXGlobal_cfg, "r"); - if (fp) - { - fclose(fp); + printf("\n\tConfiguration file is on %s", bootDevice); } gettextCleanUp(); - printf("\n\tLoading configuration..."); + printf("\n\tLoading configuration..."); CFG_Load(); - printf("done"); - // gprintf("\n\tbootDevice = %s",bootDevice); + printf("done"); - /* Load Custom IOS */ - if ((Settings.cios == ios222 && IOS_GetVersion() != 222) || - (Settings.cios == ios223 && IOS_GetVersion() != 223)) - { - printf("\n\tReloading IOS to config setting (%d)...", ios222 ? 222 : 223); - SDCard_deInit(); // unmount SD for reloading IOS - USBDevice_deInit(); // unmount USB for reloading IOS - USBStorage_Deinit(); - ret = IOS_ReloadIOSsafe(ios222 ? 222 : 223); - printf("%d", ret); - SDCard_Init(); - load_ehc_module(); - if (ret < 0) - { - SDCard_deInit(); - Settings.cios = ios249; - ret = IOS_ReloadIOSsafe(249); - // now mount SD:/ //no need to keep mindlessly mounting and unmounting SD card - SDCard_Init(); - } + LoadAppCIOS(); + printf("\n\tcIOS = %u (Rev %u)",IOS_GetVersion(), IOS_GetRevision()); - USBDevice_Init(); // and mount USB:/ - WBFS_Init(WBFS_DEVICE_USB); - } else if ((Settings.cios == ios249 && IOS_GetVersion() != 249) || - (Settings.cios == ios250 && IOS_GetVersion() != 250)) - { - - printf("\n\tReloading IOS to config setting (%d)...", ios249 ? 249 : 250); - SDCard_deInit(); // unmount SD for reloading IOS - USBDevice_deInit(); // unmount USB for reloading IOS - USBStorage_Deinit(); - ret = IOS_ReloadIOSsafe(ios249 ? 249 : 250); - printf("%d", ret); - if (ret < 0) - { - Settings.cios = ios222; - ret = IOS_ReloadIOSsafe(222); - SDCard_Init(); - load_ehc_module(); - } - - else SDCard_Init(); // now mount SD:/ //no need to keep mindlessly mounting and unmounting SD card - USBDevice_Init(); // and mount USB:/ - WBFS_Init(WBFS_DEVICE_USB); - } - - // Partition_GetList(&partitions); - - if (ret < 0) - { - printf("\nERROR: cIOS could not be loaded!"); - sleep(5); - exit(0); - //SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); - } - //gprintf("\n\tcIOS = %u (Rev %u)",IOS_GetVersion(), IOS_GetRevision());//don't need gprintf if sending console shit to gecko, too - printf("\n\tcIOS = %u (Rev %u)",IOS_GetVersion(), IOS_GetRevision()); - - // printf("Sleeping for 5 seconds\n"); - // sleep(5); - - //if a ID was passed via args copy it and try to boot it after the partition is mounted - //its not really a headless mode. more like hairless. - if (argc > 1 && argv[1]) - { - if (strlen(argv[1])==6) - strncpy(headlessID, argv[1], sizeof(headlessID)); - } + //if a ID was passed via args copy it and try to boot it after the partition is mounted + //its not really a headless mode. more like hairless. + if (argc > 1 && argv[1]) + { + if (strlen(argv[1]) == 6) + LoadHeadlessID(argv[1]); + } //! Init the rest of the System Sys_Init(); Wpad_Init(); - if(!startupproblem) - InitVideo(); - InitAudio(); // Initialize audio + InitVideo(); + InitAudio(); // Initialize audio WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight); @@ -496,8 +203,9 @@ main(int argc, char *argv[]) fontClock->loadFont(NULL, clock_ttf, clock_ttf_size, 0); fontClock->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE); - gprintf("\n\tEnd of Main()"); + gprintf("\n\tEnd of Main()"); InitGUIThreads(); - MainMenu(MENU_CHECK); + MainMenu(MENU_DISCLIST); + return 0; } diff --git a/source/menu.cpp b/source/menu.cpp index a9945a98..3c461bbf 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -21,7 +21,9 @@ #include "settings/cfg.h" #include "themes/Theme_Downloader.h" #include "usbloader/disc.h" +#include "usbloader/wdvd.h" #include "usbloader/getentries.h" +#include "usbloader/usbstorage.h" #include "wad/title.h" #include "xml/xml.h" #include "audio.h" @@ -44,7 +46,7 @@ GuiSound *btnClick2 = NULL; struct discHdr *dvdheader = NULL; int currentMenu; -u8 mountMethod=0; +u8 mountMethod=3; char game_partition[6]; int load_from_fs; @@ -65,8 +67,6 @@ static int ExitRequested = 0; /*** Extern variables ***/ extern struct discHdr * gameList; extern FreeTypeGX *fontClock; -extern u8 shutdown; -extern u8 reset; extern s32 gameSelected, gameStart; extern u8 boothomebrew; extern u8 dbvideo; @@ -79,7 +79,8 @@ extern u8 dbvideo; * after finishing the removal/insertion of new elements, and after initial * GUI setup. ***************************************************************************/ -void ResumeGui() { +void ResumeGui() +{ guiHalt = false; LWP_ResumeThread (guithread); } @@ -92,8 +93,11 @@ void ResumeGui() { * This eliminates the possibility that the GUI is in the middle of accessing * an element that is being changed. ***************************************************************************/ -void HaltGui() { - if (guiHalt)return; +void HaltGui() +{ + if (guiHalt) + return; + guiHalt = true; // wait for thread to finish @@ -182,13 +186,16 @@ void InitGUIThreads() { LWP_CreateThread(&guithread, UpdateGUI, NULL, NULL, 0, LWP_PRIO_HIGHEST); InitProgressThread(); InitNetworkThread(); + InitCheckThread(); if (Settings.autonetwork) ResumeNetworkThread(); } -void ExitGUIThreads() { +void ExitGUIThreads() +{ ExitRequested = 1; + ExitCheckThread(); LWP_JoinThread(guithread, NULL); guithread = LWP_THREAD_NULL; } @@ -253,9 +260,6 @@ int MainMenu(int menu) { currentMenu = menu; char imgPath[100]; - //if (strcmp(headlessID,"")!=0)HaltGui(); - //WindowPrompt("Can you see me now",0,"ok"); - snprintf(imgPath, sizeof(imgPath), "%splayer1_point.png", CFG.theme_path); pointer[0] = new GuiImageData(imgPath, player1_point_png); snprintf(imgPath, sizeof(imgPath), "%splayer2_point.png", CFG.theme_path); @@ -277,8 +281,7 @@ int MainMenu(int menu) { bgImg = new GuiImage(background); mainWindow->Append(bgImg); - if (strcmp(headlessID,"")==0) - ResumeGui(); + ResumeGui(); bgMusic = new GuiSound(bg_music_ogg, bg_music_ogg_size, Settings.volume); bgMusic->SetLoop(1); //loop music @@ -291,43 +294,37 @@ int MainMenu(int menu) { while (currentMenu != MENU_EXIT) { bgMusic->SetVolume(Settings.volume); - switch (currentMenu) { - case MENU_CHECK: - - currentMenu = MenuCheck(); - break; - case MENU_FORMAT: - currentMenu = MenuFormat(); - break; - case MENU_INSTALL: - currentMenu = MenuInstall(); - break; - case MENU_SETTINGS: - currentMenu = MenuSettings(); - break; - case MENU_THEMEDOWNLOADER: - currentMenu = Theme_Downloader(); - break; - case MENU_HOMEBREWBROWSE: - currentMenu = MenuHomebrewBrowse(); - break; - case MENU_DISCLIST: - currentMenu = MenuDiscList(); - break; - default: // unrecognized menu - currentMenu = MenuCheck(); - break; + switch (currentMenu) + { + case MENU_FORMAT: + currentMenu = MenuFormat(); + break; + case MENU_INSTALL: + currentMenu = MenuInstall(); + break; + case MENU_SETTINGS: + currentMenu = MenuSettings(); + break; + case MENU_THEMEDOWNLOADER: + currentMenu = Theme_Downloader(); + break; + case MENU_HOMEBREWBROWSE: + currentMenu = MenuHomebrewBrowse(); + break; + case MENU_DISCLIST: + currentMenu = MenuDiscList(); + break; + default: // unrecognized menu + currentMenu = MenuDiscList(); + break; } } - // MemInfoPrompt(); gprintf("\nExiting main GUI. mountMethod = %d",mountMethod); CloseXMLDatabase(); NewTitles::DestroyInstance(); - if (strcmp(headlessID,"")!=0)//the GUIthread was never started, so it cant be ended and joined properly if headless mode was used. so we resume it and close it. - ResumeGui(); ExitGUIThreads(); bgMusic->Stop(); @@ -347,70 +344,72 @@ int MainMenu(int menu) { StopGX(); gettextCleanUp(); - if(dbvideo) - { - InitVideodebug (); - printf("\n\n\n\n\n"); - } - if (mountMethod==3) - { - struct discHdr *header = &gameList[gameSelected]; - char tmp[20]; - u32 tid; - sprintf(tmp,"%c%c%c%c",header->id[0],header->id[1],header->id[2],header->id[3]); - memcpy(&tid, tmp, 4); - gprintf("\nBooting title %016llx",TITLE_ID((header->id[5]=='1'?0x00010001:0x00010002),tid)); - WII_Initialize(); - WII_LaunchTitle(TITLE_ID((header->id[5]=='1'?0x00010001:0x00010002),tid)); - } - if (mountMethod==2) - { - gprintf("\nLoading BC for GameCube"); - WII_Initialize(); - WII_LaunchTitle(0x0000000100000100ULL); - } + menuBootgame(""); + + return 0; +} + +void menuBootgame(const char *headless) +{ + if (mountMethod==3) + { + struct discHdr *header = &gameList[gameSelected]; + char tmp[20]; + u32 tid; + sprintf(tmp,"%c%c%c%c",header->id[0],header->id[1],header->id[2],header->id[3]); + memcpy(&tid, tmp, 4); + gprintf("\nBooting title %016llx",TITLE_ID((header->id[5]=='1'?0x00010001:0x00010002),tid)); + WII_Initialize(); + WII_LaunchTitle(TITLE_ID((header->id[5]=='1'?0x00010001:0x00010002),tid)); + } + if (mountMethod==2) + { + gprintf("\nLoading BC for GameCube"); + WII_Initialize(); + WII_LaunchTitle(0x0000000100000100ULL); + } else if (boothomebrew == 1) { - gprintf("\nBootHomebrew"); + gprintf("\nBootHomebrew"); BootHomebrew(Settings.selected_homebrew); } - else if (boothomebrew == 2) { - gprintf("\nBootHomebrewFromMenu"); + else if (boothomebrew == 2) { + gprintf("\nBootHomebrewFromMenu"); BootHomebrewFromMem(); } - else { - gprintf("\n\tSettings.partition:%d",Settings.partition); - struct discHdr *header = NULL; - //if the GUI was "skipped" to boot a game from main(argv[1]) - if (strcmp(headlessID,"")!=0) - { - gprintf("\n\tHeadless mode (%s)",headlessID); - __Menu_GetEntries(1); - if (!gameCnt) - { - gprintf(" ERROR : !gameCnt"); - exit(0); - } - //gprintf("\n\tgameCnt:%d",gameCnt); - for(u32 i=0;iid[0],header->id[1],header->id[2],header->id[3],header->id[4],header->id[5]); - if (strcmp(tmp,headlessID)==0) - { - gameSelected = i; - gprintf(" found (%d)",i); - break; - } - //if the game was not found - if (i==gameCnt-1) - { - gprintf(" not found (%d IDs checked)",i); - exit(0); - } - } - } + else { + gprintf("\n\tSettings.partition:%d",Settings.partition); + struct discHdr *header = NULL; + //if the GUI was "skipped" to boot a game from main(argv[1]) + if (strcmp(headless,"")!=0) + { + gprintf("\n\tHeadless mode (%s)",headless); + __Menu_GetEntries(1); + if (!gameCnt) + { + gprintf(" ERROR : !gameCnt"); + exit(0); + } + gprintf("\n\tgameCnt:%d",gameCnt); + for(u32 i=0;iid[0],header->id[1],header->id[2],header->id[3],header->id[4],header->id[5]); + if (strcmp(tmp,headless)==0) + { + gameSelected = i; + gprintf(" found (%d)",i); + break; + } + //if the game was not found + if (i==gameCnt-1) + { + gprintf(" not found (%d IDs checked)",i); + exit(0); + } + } + } int ret = 0; @@ -426,10 +425,10 @@ int MainMenu(int menu) { fix002 = game_cfg->errorfix002; iosChoice = game_cfg->ios; countrystrings = game_cfg->patchcountrystrings; - if (!altdoldefault) { - alternatedol = game_cfg->loadalternatedol; - alternatedoloffset = game_cfg->alternatedolstart; - } + if (!altdoldefault) { + alternatedol = game_cfg->loadalternatedol; + alternatedoloffset = game_cfg->alternatedolstart; + } reloadblock = game_cfg->iosreloadblock; } else { videoChoice = Settings.video; @@ -443,81 +442,86 @@ int MainMenu(int menu) { } fix002 = Settings.error002; countrystrings = Settings.patchcountrystrings; - if (!altdoldefault) { - alternatedol = off; - alternatedoloffset = 0; - } + if (!altdoldefault) { + alternatedol = off; + alternatedoloffset = 0; + } reloadblock = off; } - int ios2; + int ios2; - switch (iosChoice) { - case i249: - ios2 = 249; - break; + switch (iosChoice) { + case i249: + ios2 = 249; + break; - case i222: - ios2 = 222; - break; + case i222: + ios2 = 222; + break; - case i223: - ios2 = 223; - break; + case i223: + ios2 = 223; + break; - default: - ios2 = 249; - break; - } + default: + ios2 = 249; + break; + } - // When the selected ios is 249, and you're loading from FAT, reset ios to 222 - if (load_from_fs != PART_FS_WBFS && ios2 == 249) { - ios2 = 222; - } - bool onlinefix = ShutdownWC24(); + // When the selected ios is 249, and you're loading from FAT, reset ios to 222 + if (load_from_fs != PART_FS_WBFS && ios2 == 249) + ios2 = 222; - // You cannot reload ios when loading from fat - if (IOS_GetVersion() != ios2 || onlinefix) { + ShutdownWC24(); + + // You cannot reload ios when loading from fat + if (IOS_GetVersion() != ios2) + { ret = Sys_ChangeIos(ios2); - if (ret < 0) { + if (ret < 0) Sys_ChangeIos(249); - } } - if (!mountMethod) - { - gprintf("\nLoading fragment list..."); - ret = get_frag_list(header->id); - gprintf("%d\n", ret); - gprintf("\nSetting fragment list..."); - ret = set_frag_list(header->id); - gprintf("%d\n", ret); + if (!mountMethod) + { + gprintf("\nLoading fragment list..."); + ret = get_frag_list(header->id); + gprintf("%d\n", ret); - ret = Disc_SetUSB(header->id); - if (ret < 0) Sys_BackToLoader(); - gprintf("\n\tUSB set to game"); - } - else { - gprintf("\n\tUSB not set, loading DVD"); - } + gprintf("\nSetting fragment list..."); + ret = set_frag_list(header->id); + gprintf("%d\n", ret); + + ret = Disc_SetUSB(header->id); + if (ret < 0) Sys_BackToLoader(); + gprintf("\n\tUSB set to game"); + } + else { + gprintf("\n\tUSB not set, loading DVD"); + Disc_SetUSB(NULL); + ret = WDVD_Close(); + ret = Disc_Init(); + } ret = Disc_Open(); + gprintf("\n\tDisc_Open():%d",ret); - if (ret < 0) Sys_BackToLoader(); + if (ret < 0 && !mountMethod) Sys_BackToLoader(); - if (gameList){ - free(gameList); - } - if(dvdheader) - delete dvdheader; + if (gameList) + free(gameList); - gprintf("\nLoading BCA data..."); - ret = do_bca_code(header->id); - gprintf("%d\n", ret); + if(dvdheader) + delete dvdheader; - if (reloadblock == on && Sys_IsHermes()) { + gprintf("\nLoading BCA data..."); + ret = do_bca_code(header->id); + gprintf("%d\n", ret); + + if (reloadblock == on && Sys_IsHermes()) + { patch_cios_data(); - if (load_from_fs == PART_FS_WBFS) { - mload_close(); - } + if (load_from_fs == PART_FS_WBFS) + mload_close(); } u8 errorfixer002 = 0; @@ -644,14 +648,13 @@ int MainMenu(int menu) { vipatch = 0; break; } - gprintf("\n\tDisc_wiiBoot"); + gprintf("\n\tDisc_wiiBoot"); ret = Disc_WiiBoot(videoselected, cheat, vipatch, countrystrings, errorfixer002, alternatedol, alternatedoloffset); if (ret < 0) { Sys_LoadMenu(); } - printf("Returning entry point: 0x%0x\n", ret); + printf("Returning entry point: 0x%0x\n", ret); } - return 0; } diff --git a/source/menu.h b/source/menu.h index 0ffb3a75..e2585671 100644 --- a/source/menu.h +++ b/source/menu.h @@ -15,8 +15,11 @@ void InitGUIThreads(void); void ExitGUIThreads(void); +void ResumeGui(); +void HaltGui(); +void menuBootgame(const char *headless); -int MainMenu (int menuitem); +int MainMenu (int menu); enum { MENU_EXIT = -1, diff --git a/source/menu/device_check.cpp b/source/menu/device_check.cpp new file mode 100644 index 00000000..9453786f --- /dev/null +++ b/source/menu/device_check.cpp @@ -0,0 +1,202 @@ +#include +#include + +#include "gecko.h" +#include "menus.h" +#include "wpad.h" +#include "fatmounter.h" +#include "usbloader/getentries.h" +#include "usbloader/wbfs.h" + +extern int load_from_fs; +extern char game_partition[6]; + +static lwp_t checkthread = LWP_THREAD_NULL; +static bool checkHalt = false; +static bool ExitRequested = false; +static u8 sdState =0; +u8 hddState = 0; +u8 checkthreadState = 0; + +extern u8 shutdown; +extern u8 reset; + +void ResumeCheck() +{ + checkHalt = false; + LWP_ResumeThread(checkthread); +} + +void HaltCheck() +{ + if(checkHalt) + return; + + checkHalt = true; + + while (!LWP_ThreadIsSuspended(checkthread)) + usleep(50); +} + +int CheckPartition() +{ + s32 ret2 = -1; + memset(game_partition, 0, 6); + load_from_fs = -1; + + extern PartList partitions; + // Added for slow HDD + for (int runs = 0; runs < 10; runs++) + { + if (Partition_GetList(WBFS_DEVICE_USB, &partitions) != 0) + continue; + + if (Settings.partition != -1 && partitions.num > Settings.partition) + { + PartInfo pinfo = partitions.pinfo[Settings.partition]; + if (WBFS_OpenPart(pinfo.part_fs, pinfo.index, partitions.pentry[Settings.partition].sector, partitions.pentry[Settings.partition].size, (char *) &game_partition) == 0) + { + ret2 = 0; + load_from_fs = pinfo.part_fs; + break; + } + } + + if (partitions.wbfs_n != 0) + { + ret2 = WBFS_Open(); + for (int p = 0; p < partitions.num; p++) + { + if (partitions.pinfo[p].fs_type == FS_TYPE_WBFS) + { + Settings.partition = p; + load_from_fs = PART_FS_WBFS; + break; + } + } + } + + else if (Sys_IsHermes() && (partitions.fat_n != 0 || partitions.ntfs_n != 0)) + { + // Loop through FAT/NTFS partitions, and find the first partition with games on it (if there is one) + u32 count; + for (int i = 0; i < partitions.num; i++) + { + if (partitions.pinfo[i].fs_type == FS_TYPE_FAT32 || partitions.pinfo[i].fs_type == FS_TYPE_NTFS) + { + if (!WBFS_OpenPart(partitions.pinfo[i].part_fs, partitions.pinfo[i].index, partitions.pentry[i].sector, partitions.pentry[i].size, (char *) &game_partition)) + { + // Get the game count... + WBFS_GetCount(&count); + if (count > 0) + { + load_from_fs = partitions.pinfo[i].part_fs; + Settings.partition = i; + break; + } + else + { + WBFS_Close(); + } + } + } + } + } + + if ((ret2 >= 0 || load_from_fs != PART_FS_WBFS) && isInserted(bootDevice)) + { + cfg_save_global(); + break; + } + } + + if (ret2 < 0 && load_from_fs != PART_FS_WBFS) + return ret2; + + ret2 = Disc_Init(); + if (ret2 < 0) + return ret2; + + // open database if needed, load titles if needed + if(isInserted(bootDevice)) + OpenXMLDatabase(Settings.titlestxt_path,Settings.db_language, Settings.db_JPtoEN, true, Settings.titlesOverride==1?true:false, true); + + hddState = 1; + + return hddState; +} + +int CheckHDD() +{ + USBDevice_deInit(); + USBDevice_Init(); + + int wbfsinit = WBFS_Init(WBFS_DEVICE_USB); + + if (wbfsinit >= 0) + wbfsinit = CheckPartition(); + + return wbfsinit; +} + +static void * CheckDevices (void *arg) +{ + sdState = isInserted(bootDevice); + while (!ExitRequested) + { + usleep(100); + + if (checkHalt && !ExitRequested) + { + LWP_SuspendThread(checkthread); + continue; + } + + if (shutdown == 1) + Sys_Shutdown(); + + else if (reset == 1) + Sys_Reboot(); + + if (!hddState) + { + if(CheckHDD() >= 0) + { + checkthreadState = 1; + } + } + + //this really doesnt work right. it seems that isInserted() isn't what it should be. + int sdNow = isInserted(bootDevice); + if (sdState != sdNow) + { + sdState = sdNow; + checkthreadState = 2; + WindowPrompt("2",0,"OK"); + } + + u32 buttons = ButtonsPressed(); + if((buttons & WPAD_NUNCHUK_BUTTON_Z) || (buttons & WPAD_CLASSIC_BUTTON_ZL) || + (buttons & PAD_TRIGGER_Z)) + { + gprintf("\n\tscreenShotBtn clicked"); + ScreenShot(); + gprintf("...It's easy, mmmmmmKay"); + } + } + + return NULL; +} + +void InitCheckThread() +{ + LWP_CreateThread(&checkthread, CheckDevices, NULL, NULL, 0, 0); +} + +void ExitCheckThread() +{ + ExitRequested = true; + LWP_ResumeThread(checkthread); + LWP_JoinThread(checkthread, NULL); + checkthread = LWP_THREAD_NULL; +} diff --git a/source/menu/menu_check.cpp b/source/menu/menu_check.cpp deleted file mode 100644 index b1ee8f62..00000000 --- a/source/menu/menu_check.cpp +++ /dev/null @@ -1,164 +0,0 @@ -#include -#include - -#include "menus.h" -#include "wpad.h" -#include "fatmounter.h" -#include "usbloader/getentries.h" -#include "usbloader/wbfs.h" - -extern int load_from_fs; -extern char game_partition[6]; -extern char headlessID[8]; - -/**************************************************************************** - * MenuCheck - ***************************************************************************/ -int MenuCheck() { - gprintf("\nMenuCheck()"); - int menu = MENU_NONE; - int i = 0; - int choice; - s32 ret2, wbfsinit; - OptionList options; - options.length = i; - - VIDEO_WaitVSync (); - - wbfsinit = WBFS_Init(WBFS_DEVICE_USB); - if (wbfsinit < 0) { - ret2 = WindowPrompt(tr("No USB Device found."), tr("Do you want to retry for 30 secs?"), "cIOS249", "cIOS222", tr("Back to Wii Menu")); - SDCard_deInit(); - USBDevice_deInit(); - WPAD_Flush(0); - WPAD_Disconnect(0); - WPAD_Shutdown(); - if (ret2 == 1) { - Settings.cios = ios249; - } else if (ret2 == 2) { - Settings.cios = ios222; - } else { - Sys_LoadMenu(); - } - ret2 = DiscWait(tr("No USB Device"), tr("Waiting for USB Device"), 0, 0, 1); - //reinitialize SD and USB - Wpad_Init(); - WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); - WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight); - if (ret2 < 0) { - WindowPrompt (tr("Error !"),tr("USB Device not found"), tr("OK")); - Sys_LoadMenu(); - } - } - - ret2 = -1; - memset(game_partition, 0, 6); - load_from_fs = -1; - - extern PartList partitions; - // Added for slow HDD - for (int runs = 0; runs < 10; runs++) { - if (Partition_GetList(WBFS_DEVICE_USB, &partitions) != 0) { - sleep(1); - continue; - } - - if (Settings.partition != -1 && partitions.num > Settings.partition) { - PartInfo pinfo = partitions.pinfo[Settings.partition]; - if (WBFS_OpenPart(pinfo.part_fs, pinfo.index, partitions.pentry[Settings.partition].sector, partitions.pentry[Settings.partition].size, (char *) &game_partition) == 0) - { - ret2 = 0; - load_from_fs = pinfo.part_fs; - break; - } - } - - if (partitions.wbfs_n != 0) { - ret2 = WBFS_Open(); - for (int p = 0; p < partitions.num; p++) { - if (partitions.pinfo[p].fs_type == FS_TYPE_WBFS) { - Settings.partition = p; - load_from_fs = PART_FS_WBFS; - break; - } - } - } else if (Sys_IsHermes() && (partitions.fat_n != 0 || partitions.ntfs_n != 0)) { - // Loop through FAT/NTFS partitions, and find the first partition with games on it (if there is one) - u32 count; - - for (int i = 0; i < partitions.num; i++) { - if (partitions.pinfo[i].fs_type == FS_TYPE_FAT32 || partitions.pinfo[i].fs_type == FS_TYPE_NTFS) { - - if (!WBFS_OpenPart(partitions.pinfo[i].part_fs, partitions.pinfo[i].index, partitions.pentry[i].sector, partitions.pentry[i].size, (char *) &game_partition)) { - // Get the game count... - WBFS_GetCount(&count); - - if (count > 0) { - load_from_fs = partitions.pinfo[i].part_fs; - Settings.partition = i; - break; - } else { - WBFS_Close(); - } - } - } - } - } - - if ((ret2 >= 0 || load_from_fs != PART_FS_WBFS) && isInserted(bootDevice)) { - cfg_save_global(); - break; - } - sleep(1); - } - - if (ret2 < 0 && load_from_fs != PART_FS_WBFS) { - choice = WindowPrompt(tr("No WBFS or FAT/NTFS partition found"),tr("You need to select or format a partition"), tr("Select"), tr("Format"), tr("Return")); - if (choice == 0) { - Sys_LoadMenu(); - } else { - load_from_fs = choice == 1 ? PART_FS_FAT : PART_FS_WBFS; - menu = MENU_FORMAT; - } - } - - ret2 = Disc_Init(); - if (ret2 < 0) { - WindowPrompt (tr("Error !"),tr("Could not initialize DIP module!"),tr("OK")); - Sys_LoadMenu(); - } - - if (shutdown == 1) - Sys_Shutdown(); - if (reset == 1) - Sys_Reboot(); - - if (wbfsinit < 0) { - sleep(1); - } - - // open database if needed, load titles if needed - if(isInserted(bootDevice))OpenXMLDatabase(Settings.titlestxt_path,Settings.db_language, Settings.db_JPtoEN, true, Settings.titlesOverride==1?true:false, true); - - // titles.txt loaded after database to override database titles with custom titles - //snprintf(pathname, sizeof(pathname), "%stitles.txt", Settings.titlestxt_path); - //cfg_parsefile(pathname, &title_set); - - //Spieleliste laden - __Menu_GetEntries(0); - - if (strcmp(headlessID,"")!=0) - menu = MENU_EXIT; - - if (menu == MENU_NONE) - menu = MENU_DISCLIST; - - //for HDDs with issues - if (wbfsinit < 0) { - sleep(1); - USBDevice_Init(); - SDCard_Init(); - } - - return menu; -} diff --git a/source/menu/menu_disclist.cpp b/source/menu/menu_disclist.cpp index dbd37bce..f42bf681 100644 --- a/source/menu/menu_disclist.cpp +++ b/source/menu/menu_disclist.cpp @@ -1,1629 +1,1649 @@ -#include "menus.h" -#include "fatmounter.h" -#include "usbloader/wdvd.h" -#include "usbloader/getentries.h" -#include "usbloader/wbfs.h" -#include "patches/fst.h" -#include "network/networkops.h" -#include "prompts/gameinfo.h" -#include "prompts/DiscBrowser.h" -#include "settings/Settings.h" -#include "wpad.h" -#include "sys.h" - -#include "libwiigui/gui_gamebrowser.h" -#include "libwiigui/gui_gamegrid.h" -#include "libwiigui/gui_gamecarousel.h" -#include "libwiigui/gui_searchbar.h" - -#define MAX_CHARACTERS 38 -extern u8 * gameScreenTex; -extern struct discHdr *dvdheader; -extern u8 mountMethod; -extern int load_from_fs; -extern s32 gameSelected; -extern GuiText * GameIDTxt; -extern GuiText * GameRegionTxt; -extern const u8 data1; -extern FreeTypeGX *fontClock; -extern bool updateavailable; -extern int cntMissFiles; -extern GuiImageData * cover; -extern GuiImage * coverImg; -extern GuiImageData * pointer[4]; -extern bool altdoldefault; -extern GuiImage * bgImg; - -GuiButton *Toolbar[9]; -int idiotFlag=-1; -char idiotChar[50]; - -void DiscListWinUpdateCallback(void * e); -void rockout(int f = 0); - -static u32 startat = 0; - -/**************************************************************************** - * MenuDiscList - ***************************************************************************/ -int MenuDiscList() { - - gprintf("\nMenuDiscList()"); - //TakeScreenshot("SD:/screenshot1.png"); - __Menu_GetEntries(); - int offset = MIN(startat,gameCnt-1); - startat = offset; - //gprintf("\n\tstartat:%d offset:%d",startat,offset); - int datag = 0; - int datagB =0; - int dataed = -1; - int cosa=0,sina=0; - int selectImg1 = 0; - char ID[4]; - char IDfull[7]; - u32 covert = 0; - char imgPath[100]; - if (!dvdheader) - dvdheader = new struct discHdr; - u8 mountMethodOLD =0; - - WDVD_GetCoverStatus(&covert); - u32 covertOld=covert; - - f32 freespace, used, size = 0.0; - wchar_t searchChar; - //SCREENSAVER - int check = 0; //to skip the first cycle when wiimote isn't completely connected - - datagB=0; - int menu = MENU_NONE, dataef=0; - - - u32 nolist; - char text[MAX_CHARACTERS + 4]; - int choice = 0, selectedold = 100; - s32 ret; - - //CLOCK - struct tm * timeinfo; - char theTime[80]=""; - time_t lastrawtime=0; - - if (mountMethod != 3 && load_from_fs == PART_FS_WBFS) { - WBFS_DiskSpace(&used, &freespace); - } - - if (!gameCnt) { //if there is no list of games to display - nolist = 1; - } - - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume); - // because destroy GuiSound must wait while sound playing is finished, we use a global sound - if(!btnClick2) btnClick2=new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume); - // GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume); - - snprintf(imgPath, sizeof(imgPath), "%sbutton_install.png", CFG.theme_path); - GuiImageData btnInstall(imgPath, button_install_png); - snprintf(imgPath, sizeof(imgPath), "%sbutton_install_over.png", CFG.theme_path); - GuiImageData btnInstallOver(imgPath, button_install_over_png); - - snprintf(imgPath, sizeof(imgPath), "%ssettings_button.png", CFG.theme_path); - GuiImageData btnSettings(imgPath, settings_button_png); - snprintf(imgPath, sizeof(imgPath), "%ssettings_button_over.png", CFG.theme_path); - GuiImageData btnSettingsOver(imgPath, settings_button_over_png); - GuiImageData dataID(&data1); - - snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff.png", CFG.theme_path); - GuiImageData btnpwroff(imgPath, wiimote_poweroff_png); - snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff_over.png", CFG.theme_path); - GuiImageData btnpwroffOver(imgPath, wiimote_poweroff_over_png); - snprintf(imgPath, sizeof(imgPath), "%smenu_button.png", CFG.theme_path); - GuiImageData btnhome(imgPath, menu_button_png); - snprintf(imgPath, sizeof(imgPath), "%smenu_button_over.png", CFG.theme_path); - GuiImageData btnhomeOver(imgPath, menu_button_over_png); - snprintf(imgPath, sizeof(imgPath), "%sSDcard_over.png", CFG.theme_path); - GuiImageData btnsdcardOver(imgPath, sdcard_over_png); - snprintf(imgPath, sizeof(imgPath), "%sSDcard.png", CFG.theme_path); - GuiImageData btnsdcard(imgPath, sdcard_png); - - - snprintf(imgPath, sizeof(imgPath), "%sfavIcon.png", CFG.theme_path); - GuiImageData imgfavIcon(imgPath, favIcon_png); - snprintf(imgPath, sizeof(imgPath), "%sfavIcon_gray.png", CFG.theme_path); - GuiImageData imgfavIcon_gray(imgPath, NULL); - snprintf(imgPath, sizeof(imgPath), "%ssearchIcon.png", CFG.theme_path); - GuiImageData imgsearchIcon(imgPath, searchIcon_png); - snprintf(imgPath, sizeof(imgPath), "%ssearchIcon_gray.png", CFG.theme_path); - GuiImageData imgsearchIcon_gray(imgPath, NULL); - snprintf(imgPath, sizeof(imgPath), "%sabcIcon.png", CFG.theme_path); - GuiImageData imgabcIcon(imgPath, abcIcon_png); - snprintf(imgPath, sizeof(imgPath), "%sabcIcon_gray.png", CFG.theme_path); - GuiImageData imgabcIcon_gray(imgPath, NULL); - snprintf(imgPath, sizeof(imgPath), "%srankIcon.png", CFG.theme_path); - GuiImageData imgrankIcon(imgPath, rankIcon_png); - snprintf(imgPath, sizeof(imgPath), "%srankIcon_gray.png", CFG.theme_path); - GuiImageData imgrankIcon_gray(imgPath, NULL); - snprintf(imgPath, sizeof(imgPath), "%splayCountIcon.png", CFG.theme_path); - GuiImageData imgplayCountIcon(imgPath, playCountIcon_png); - snprintf(imgPath, sizeof(imgPath), "%splayCountIcon_gray.png", CFG.theme_path); - GuiImageData imgplayCountIcon_gray(imgPath, NULL); - snprintf(imgPath, sizeof(imgPath), "%sarrangeGrid.png", CFG.theme_path); - GuiImageData imgarrangeGrid(imgPath, arrangeGrid_png); - snprintf(imgPath, sizeof(imgPath), "%sarrangeGrid_gray.png", CFG.theme_path); - GuiImageData imgarrangeGrid_gray(imgPath, NULL); - snprintf(imgPath, sizeof(imgPath), "%sarrangeList.png", CFG.theme_path); - GuiImageData imgarrangeList(imgPath, arrangeList_png); - snprintf(imgPath, sizeof(imgPath), "%sarrangeList_gray.png", CFG.theme_path); - GuiImageData imgarrangeList_gray(imgPath, NULL); - snprintf(imgPath, sizeof(imgPath), "%sarrangeCarousel.png", CFG.theme_path); - GuiImageData imgarrangeCarousel(imgPath, arrangeCarousel_png); - snprintf(imgPath, sizeof(imgPath), "%sarrangeCarousel_gray.png", CFG.theme_path); - GuiImageData imgarrangeCarousel_gray(imgPath, NULL); - - snprintf(imgPath, sizeof(imgPath), "%slock.png", CFG.theme_path); - GuiImageData imgLock(imgPath, lock_png); - snprintf(imgPath, sizeof(imgPath), "%slock_gray.png", CFG.theme_path); - GuiImageData imgLock_gray(imgPath, NULL); - snprintf(imgPath, sizeof(imgPath), "%sunlock.png", CFG.theme_path); - GuiImageData imgUnlock(imgPath, unlock_png); - snprintf(imgPath, sizeof(imgPath), "%sunlock_gray.png", CFG.theme_path); - GuiImageData imgUnlock_gray(imgPath, NULL); - - snprintf(imgPath, sizeof(imgPath), "%sdvd.png", CFG.theme_path); - GuiImageData imgdvd(imgPath, dvd_png); - snprintf(imgPath, sizeof(imgPath), "%sdvd_gray.png", CFG.theme_path); - GuiImageData imgdvd_gray(imgPath, NULL); - - snprintf(imgPath, sizeof(imgPath), "%sbrowser.png", CFG.theme_path); - GuiImageData homebrewImgData(imgPath, browser_png); - snprintf(imgPath, sizeof(imgPath), "%sbrowser_over.png", CFG.theme_path); - GuiImageData homebrewImgDataOver(imgPath, browser_over_png); - - - GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiTrigger trigHome; - trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, PAD_BUTTON_START); - GuiTrigger trig2; - trig2.SetButtonOnlyTrigger(-1, WPAD_BUTTON_2 | WPAD_CLASSIC_BUTTON_X, 0); - GuiTrigger trig1; - trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1 | WPAD_CLASSIC_BUTTON_Y, 0); - GuiTrigger trigZ; - trigZ.SetButtonOnlyTrigger(-1, WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL, PAD_TRIGGER_Z); - - GuiButton screenShotBtn(0,0); - screenShotBtn.SetPosition(0,0); - screenShotBtn.SetTrigger(&trigZ); - - char spaceinfo[30]; - if (load_from_fs != PART_FS_WBFS) { - memset(spaceinfo, 0, 30); - } else { - if (!strcmp(Settings.db_language,"JA")) { - // needs to be "total...used" for Japanese - sprintf(spaceinfo,(mountMethod!=3?"%.2fGB %s %.2fGB %s":" "),(freespace+used),tr("of"),freespace,tr("free")); - } else { - sprintf(spaceinfo,(mountMethod!=3?"%.2fGB %s %.2fGB %s":" "),freespace,tr("of"),(freespace+used),tr("free")); - } - } - GuiText usedSpaceTxt(spaceinfo, 18, THEME.info); - usedSpaceTxt.SetAlignment(THEME.hddinfo_align, ALIGN_TOP); - usedSpaceTxt.SetPosition(THEME.hddinfo_x, THEME.hddinfo_y); - - char GamesCnt[15]; - sprintf(GamesCnt,"%s: %i",(mountMethod!=3?tr("Games"):tr("Channels")), gameCnt); - GuiText gamecntTxt(GamesCnt, 18, THEME.info); - - GuiButton gamecntBtn(100,18); - gamecntBtn.SetAlignment(THEME.gamecount_align, ALIGN_TOP); - gamecntBtn.SetPosition(THEME.gamecount_x,THEME.gamecount_y); - gamecntBtn.SetLabel(&gamecntTxt); - gamecntBtn.SetEffectGrow(); - gamecntBtn.SetTrigger(&trigA); - - GuiTooltip installBtnTT(tr("Install a game")); - if (Settings.wsprompt == yes) - installBtnTT.SetWidescreen(CFG.widescreen); - installBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage installBtnImg(&btnInstall); - GuiImage installBtnImgOver(&btnInstallOver); - installBtnImg.SetWidescreen(CFG.widescreen); - installBtnImgOver.SetWidescreen(CFG.widescreen); - - GuiButton installBtn(&installBtnImg, &installBtnImgOver, ALIGN_LEFT, ALIGN_TOP, THEME.install_x, THEME.install_y, &trigA, &btnSoundOver, btnClick2, 1, &installBtnTT,24,-30, 0,5); - - - GuiTooltip settingsBtnTT(tr("Settings")); - if (Settings.wsprompt == yes) - settingsBtnTT.SetWidescreen(CFG.widescreen); - settingsBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage settingsBtnImg(&btnSettings); - settingsBtnImg.SetWidescreen(CFG.widescreen); - GuiImage settingsBtnImgOver(&btnSettingsOver); - settingsBtnImgOver.SetWidescreen(CFG.widescreen); - GuiButton settingsBtn(&settingsBtnImg,&settingsBtnImgOver, 0, 3, THEME.setting_x, THEME.setting_y, &trigA, &btnSoundOver, btnClick2,1,&settingsBtnTT,65,-30,0,5); - - GuiTooltip homeBtnTT(tr("Back to HBC or Wii Menu")); - if (Settings.wsprompt == yes) - homeBtnTT.SetWidescreen(CFG.widescreen); - settingsBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage homeBtnImg(&btnhome); - homeBtnImg.SetWidescreen(CFG.widescreen); - GuiImage homeBtnImgOver(&btnhomeOver); - homeBtnImgOver.SetWidescreen(CFG.widescreen); - GuiButton homeBtn(&homeBtnImg,&homeBtnImgOver, 0, 3, THEME.home_x, THEME.home_y, &trigA, &btnSoundOver, btnClick2,1,&homeBtnTT,15,-30,1,5); - homeBtn.RemoveSoundClick(); - homeBtn.SetTrigger(&trigHome); - - GuiTooltip poweroffBtnTT(tr("Power off the Wii")); - if (Settings.wsprompt == yes) - poweroffBtnTT.SetWidescreen(CFG.widescreen); - poweroffBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage poweroffBtnImg(&btnpwroff); - GuiImage poweroffBtnImgOver(&btnpwroffOver); - poweroffBtnImg.SetWidescreen(CFG.widescreen); - poweroffBtnImgOver.SetWidescreen(CFG.widescreen); - GuiButton poweroffBtn(&poweroffBtnImg,&poweroffBtnImgOver, 0, 3, THEME.power_x, THEME.power_y, &trigA, &btnSoundOver, btnClick2,1,&poweroffBtnTT,-10,-30,1,5); - - GuiTooltip sdcardBtnTT(tr("Reload SD")); - if (Settings.wsprompt == yes) - sdcardBtnTT.SetWidescreen(CFG.widescreen); - sdcardBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage sdcardImg(&btnsdcard); - GuiImage sdcardImgOver(&btnsdcardOver); - sdcardImg.SetWidescreen(CFG.widescreen); - sdcardImgOver.SetWidescreen(CFG.widescreen); - GuiButton sdcardBtn(&sdcardImg,&sdcardImgOver, 0, 3, THEME.sdcard_x, THEME.sdcard_y, &trigA, &btnSoundOver, btnClick2,1,&sdcardBtnTT,15,-30,0,5); - - GuiButton gameInfo(0,0); - gameInfo.SetTrigger(&trig2); - gameInfo.SetSoundClick(btnClick2); - - - GuiImage wiiBtnImg(&dataID); - wiiBtnImg.SetWidescreen(CFG.widescreen); - GuiButton wiiBtn(&wiiBtnImg,&wiiBtnImg, 0, 4, 0, -10, &trigA, &btnSoundOver, btnClick2,0); - - GuiTooltip favoriteBtnTT(tr("Display favorites")); - if (Settings.wsprompt == yes) - favoriteBtnTT.SetWidescreen(CFG.widescreen); - favoriteBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage favoriteBtnImg(&imgfavIcon); - favoriteBtnImg.SetWidescreen(CFG.widescreen); -// GuiImage favoriteBtnImg_g(favoriteBtnImg);favoriteBtnImg_g.SetGrayscale(); - GuiImage favoriteBtnImg_g(&imgfavIcon_gray); - if(favoriteBtnImg_g.GetImage() == NULL) { favoriteBtnImg_g = favoriteBtnImg; favoriteBtnImg_g.SetGrayscale();} - favoriteBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton favoriteBtn(&favoriteBtnImg_g,&favoriteBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_favorite_x, THEME.gamelist_favorite_y, &trigA, &btnSoundOver, btnClick2,1, &favoriteBtnTT, -15, 52, 0, 3); - favoriteBtn.SetAlpha(180); - - GuiTooltip searchBtnTT(tr("Set Search-Filter")); - if (Settings.wsprompt == yes) - searchBtnTT.SetWidescreen(CFG.widescreen); - searchBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage searchBtnImg(&imgsearchIcon); - searchBtnImg.SetWidescreen(CFG.widescreen); -// GuiImage searchBtnImg_g(searchBtnImg); searchBtnImg_g.SetGrayscale(); - GuiImage searchBtnImg_g(&imgsearchIcon_gray); - if(searchBtnImg_g.GetImage() == NULL) { searchBtnImg_g = searchBtnImg; searchBtnImg_g.SetGrayscale();} - searchBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton searchBtn(&searchBtnImg_g,&searchBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_search_x, THEME.gamelist_search_y, &trigA, &btnSoundOver, btnClick2,1, &searchBtnTT, -15, 52, 0, 3); - searchBtn.SetAlpha(180); - - GuiTooltip abcBtnTT(Settings.fave ? tr("Sort by rank") : tr("Sort alphabetically")); - if (Settings.wsprompt == yes) - abcBtnTT.SetWidescreen(CFG.widescreen); - abcBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage abcBtnImg(Settings.fave ? &imgrankIcon : &imgabcIcon); - abcBtnImg.SetWidescreen(CFG.widescreen); -// GuiImage abcBtnImg_g(abcBtnImg); abcBtnImg_g.SetGrayscale(); - GuiImage abcBtnImg_g(Settings.fave ? &imgrankIcon_gray : &imgabcIcon_gray); - if(abcBtnImg_g.GetImage() == NULL) { abcBtnImg_g = abcBtnImg; abcBtnImg_g.SetGrayscale();} - abcBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton abcBtn(&abcBtnImg_g,&abcBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_abc_x, THEME.gamelist_abc_y, &trigA, &btnSoundOver, btnClick2,1,&abcBtnTT, -15, 52, 0, 3); - abcBtn.SetAlpha(180); - - GuiTooltip countBtnTT(tr("Sort order by most played")); - if (Settings.wsprompt == yes) - countBtnTT.SetWidescreen(CFG.widescreen); - countBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage countBtnImg(&imgplayCountIcon); - countBtnImg.SetWidescreen(CFG.widescreen); -// GuiImage countBtnImg_g(countBtnImg); countBtnImg_g.SetGrayscale(); - GuiImage countBtnImg_g(&imgplayCountIcon_gray); - if(countBtnImg_g.GetImage() == NULL) { countBtnImg_g = countBtnImg; countBtnImg_g.SetGrayscale();} - countBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton countBtn(&countBtnImg_g,&countBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_count_x, THEME.gamelist_count_y, &trigA, &btnSoundOver, btnClick2,1, &countBtnTT, -15, 52, 0, 3); - countBtn.SetAlpha(180); - - GuiTooltip listBtnTT(tr("Display as a list")); - if (Settings.wsprompt == yes) - listBtnTT.SetWidescreen(CFG.widescreen); - listBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage listBtnImg(&imgarrangeList); - listBtnImg.SetWidescreen(CFG.widescreen); -// GuiImage listBtnImg_g(listBtnImg); listBtnImg_g.SetGrayscale(); - GuiImage listBtnImg_g(&imgarrangeList_gray); - if(listBtnImg_g.GetImage() == NULL) { listBtnImg_g = listBtnImg; listBtnImg_g.SetGrayscale();} - listBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton listBtn(&listBtnImg_g,&listBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_list_x, THEME.gamelist_list_y, &trigA, &btnSoundOver, btnClick2,1, &listBtnTT, 15, 52, 1, 3); - listBtn.SetAlpha(180); - - GuiTooltip gridBtnTT(tr("Display as a grid")); - if (Settings.wsprompt == yes) - gridBtnTT.SetWidescreen(CFG.widescreen); - gridBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage gridBtnImg(&imgarrangeGrid); - gridBtnImg.SetWidescreen(CFG.widescreen); -// GuiImage gridBtnImg_g(gridBtnImg); gridBtnImg_g.SetGrayscale(); - GuiImage gridBtnImg_g(&imgarrangeGrid_gray); - if(gridBtnImg_g.GetImage() == NULL) { gridBtnImg_g = gridBtnImg; gridBtnImg_g.SetGrayscale();} - gridBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton gridBtn(&gridBtnImg_g,&gridBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_grid_x, THEME.gamelist_grid_y, &trigA, &btnSoundOver, btnClick2,1, &gridBtnTT, 15, 52, 1, 3); - gridBtn.SetAlpha(180); - - GuiTooltip carouselBtnTT(tr("Display as a carousel")); - if (Settings.wsprompt == yes) - carouselBtnTT.SetWidescreen(CFG.widescreen); - carouselBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage carouselBtnImg(&imgarrangeCarousel); - carouselBtnImg.SetWidescreen(CFG.widescreen); -// GuiImage carouselBtnImg_g(carouselBtnImg); carouselBtnImg_g.SetGrayscale(); - GuiImage carouselBtnImg_g(&imgarrangeCarousel_gray); - if(carouselBtnImg_g.GetImage() == NULL) { carouselBtnImg_g = carouselBtnImg; carouselBtnImg_g.SetGrayscale();} - carouselBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton carouselBtn(&carouselBtnImg_g,&carouselBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_carousel_x, THEME.gamelist_carousel_y, &trigA, &btnSoundOver, btnClick2,1, &carouselBtnTT, 15, 52, 1, 3); - carouselBtn.SetAlpha(180); - - bool canUnlock = (Settings.parentalcontrol == 0 && Settings.parental.enabled == 1); - - GuiTooltip lockBtnTT(canUnlock ? tr("Unlock Parental Control") : tr("Parental Control disabled")); - if (Settings.wsprompt == yes) - lockBtnTT.SetWidescreen(CFG.widescreen); - lockBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage lockBtnImg(&imgLock); - lockBtnImg.SetWidescreen(CFG.widescreen); - GuiImage lockBtnImg_g(&imgLock_gray); - if(lockBtnImg_g.GetImage() == NULL) { lockBtnImg_g = lockBtnImg; lockBtnImg_g.SetGrayscale(); } - lockBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton lockBtn(&lockBtnImg_g, &lockBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_lock_x, THEME.gamelist_lock_y, &trigA, &btnSoundOver, btnClick2,1, &lockBtnTT, 15, 52, 1, 3); - lockBtn.SetAlpha(180); - - GuiTooltip unlockBtnTT(tr("Enable Parental Control")); - if (Settings.wsprompt == yes) - unlockBtnTT.SetWidescreen(CFG.widescreen); - unlockBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage unlockBtnImg(&imgUnlock); - unlockBtnImg.SetWidescreen(CFG.widescreen); - GuiImage unlockBtnImg_g(&imgUnlock_gray); - if(unlockBtnImg_g.GetImage() == NULL) { unlockBtnImg_g = unlockBtnImg; unlockBtnImg_g.SetGrayscale(); } - unlockBtnImg_g.SetWidescreen(CFG.widescreen); - - if (canUnlock && Settings.godmode) - { - lockBtn.SetImage(&unlockBtnImg_g); - lockBtn.SetImageOver(&unlockBtnImg_g); - lockBtn.SetToolTip(&unlockBtnTT, 15, 52, 1, 3); - } - -/* - GuiButton unlockBtn(&unlockBtnImg_g, &unlockBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_lock_x, THEME.gamelist_lock_y, &trigA, &btnSoundOver, btnClick2,1, &lockBtnTT, 15, 52, 1, 3); - unlockBtn.SetAlpha(180); -*/ - - GuiTooltip dvdBtnTT(tr("Mount DVD drive")); - if (Settings.wsprompt == yes) - dvdBtnTT.SetWidescreen(CFG.widescreen); - dvdBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage dvdBtnImg(&imgdvd); - dvdBtnImg.SetWidescreen(CFG.widescreen); - GuiImage dvdBtnImg_g(dvdBtnImg); //dvdBtnImg_g.SetGrayscale(); -// GuiImage carouselBtnImg_g(&imgarrangeCarousel_gray); - dvdBtnImg_g.SetWidescreen(CFG.widescreen); - GuiButton dvdBtn(&dvdBtnImg_g,&dvdBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_dvd_x, THEME.gamelist_dvd_y, &trigA, &btnSoundOver, btnClick2,1, &dvdBtnTT, 15, 52, 1, 3); - dvdBtn.SetAlpha(180); - - GuiTooltip homebrewBtnTT(tr("Homebrew Launcher")); - if (Settings.wsprompt == yes) - homebrewBtnTT.SetWidescreen(CFG.widescreen); - homebrewBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage homebrewImg(&homebrewImgData); - GuiImage homebrewImgOver(&homebrewImgDataOver); - homebrewImg.SetWidescreen(CFG.widescreen); - homebrewImgOver.SetWidescreen(CFG.widescreen); - GuiButton homebrewBtn(&homebrewImg,&homebrewImgOver, ALIGN_LEFT, ALIGN_TOP, THEME.homebrew_x, THEME.homebrew_y, &trigA, &btnSoundOver, btnClick2,1,&homebrewBtnTT,15,-30,1,5); - - if (Settings.fave) { - favoriteBtn.SetImage(&favoriteBtnImg); - favoriteBtn.SetImageOver(&favoriteBtnImg); - favoriteBtn.SetAlpha(255); - } - static bool show_searchwindow = false; - if(gameFilter && *gameFilter) - { - if(show_searchwindow && gameCnt==1) - show_searchwindow = false; - if(!show_searchwindow) - searchBtn.SetEffect(EFFECT_PULSE, 10, 105); - searchBtn.SetImage(&searchBtnImg); - searchBtn.SetImageOver(&searchBtnImg); - searchBtn.SetAlpha(255); - } - if (Settings.sort==all) { - abcBtn.SetImage(&abcBtnImg); - abcBtn.SetImageOver(&abcBtnImg); - abcBtn.SetAlpha(255); - } else if (Settings.sort==pcount) { - countBtn.SetImage(&countBtnImg); - countBtn.SetImageOver(&countBtnImg); - countBtn.SetAlpha(255); - } - if (Settings.gameDisplay==list) { - listBtn.SetImage(&listBtnImg); - listBtn.SetImageOver(&listBtnImg); - listBtn.SetAlpha(255); - } else if (Settings.gameDisplay==grid) { - gridBtn.SetImage(&gridBtnImg); - gridBtn.SetImageOver(&gridBtnImg); - gridBtn.SetAlpha(255); - } else if (Settings.gameDisplay==carousel) { - carouselBtn.SetImage(&carouselBtnImg); - carouselBtn.SetImageOver(&carouselBtnImg); - carouselBtn.SetAlpha(255); - } - - if (Settings.gameDisplay==list) { - favoriteBtn.SetPosition(THEME.gamelist_favorite_x, THEME.gamelist_favorite_y); - searchBtn.SetPosition(THEME.gamelist_search_x, THEME.gamelist_search_y); - abcBtn.SetPosition(THEME.gamelist_abc_x, THEME.gamelist_abc_y); - countBtn.SetPosition(THEME.gamelist_count_x, THEME.gamelist_count_y); - listBtn.SetPosition(THEME.gamelist_list_x, THEME.gamelist_list_y); - gridBtn.SetPosition(THEME.gamelist_grid_x, THEME.gamelist_grid_y); - carouselBtn.SetPosition(THEME.gamelist_carousel_x, THEME.gamelist_carousel_y); - lockBtn.SetPosition(THEME.gamelist_lock_x, THEME.gamelist_lock_y); - dvdBtn.SetPosition(THEME.gamelist_dvd_x, THEME.gamelist_dvd_y); - } else if(Settings.gameDisplay==grid) { - favoriteBtn.SetPosition(THEME.gamegrid_favorite_x, THEME.gamegrid_favorite_y); - searchBtn.SetPosition(THEME.gamegrid_search_x, THEME.gamegrid_search_y); - abcBtn.SetPosition(THEME.gamegrid_abc_x, THEME.gamegrid_abc_y); - countBtn.SetPosition(THEME.gamegrid_count_x, THEME.gamegrid_count_y); - listBtn.SetPosition(THEME.gamegrid_list_x, THEME.gamegrid_list_y); - gridBtn.SetPosition(THEME.gamegrid_grid_x, THEME.gamegrid_grid_y); - carouselBtn.SetPosition(THEME.gamegrid_carousel_x, THEME.gamegrid_carousel_y); - lockBtn.SetPosition(THEME.gamegrid_lock_x, THEME.gamegrid_lock_y); - dvdBtn.SetPosition(THEME.gamegrid_dvd_x, THEME.gamegrid_dvd_y); - } else if(Settings.gameDisplay==carousel) { - favoriteBtn.SetPosition(THEME.gamecarousel_favorite_x, THEME.gamecarousel_favorite_y); - searchBtn.SetPosition(THEME.gamecarousel_search_x, THEME.gamecarousel_favorite_y); - abcBtn.SetPosition(THEME.gamecarousel_abc_x, THEME.gamecarousel_abc_y); - countBtn.SetPosition(THEME.gamecarousel_count_x, THEME.gamecarousel_count_y); - listBtn.SetPosition(THEME.gamecarousel_list_x, THEME.gamecarousel_list_y); - gridBtn.SetPosition(THEME.gamecarousel_grid_x, THEME.gamecarousel_grid_y); - carouselBtn.SetPosition(THEME.gamecarousel_carousel_x, THEME.gamecarousel_carousel_y); - lockBtn.SetPosition(THEME.gamecarousel_lock_x, THEME.gamecarousel_lock_y); - dvdBtn.SetPosition(THEME.gamecarousel_dvd_x, THEME.gamecarousel_dvd_y); - } - - - //Downloading Covers - GuiTooltip DownloadBtnTT(tr("Click to Download Covers")); - if (Settings.wsprompt == yes) - DownloadBtnTT.SetWidescreen(CFG.widescreen); - DownloadBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiButton DownloadBtn(0,0); - DownloadBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); - DownloadBtn.SetPosition(THEME.covers_x,THEME.covers_y); - - GuiTooltip IDBtnTT(tr("Click to change game ID")); - if (Settings.wsprompt == yes) - IDBtnTT.SetWidescreen(CFG.widescreen); - IDBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiButton idBtn(0,0); - idBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); - idBtn.SetPosition(THEME.id_x,THEME.id_y); - - if (Settings.godmode == 1 && mountMethod!=3) {//only make the button have trigger & tooltip if in godmode - DownloadBtn.SetSoundOver(&btnSoundOver); - DownloadBtn.SetTrigger(&trigA); - DownloadBtn.SetTrigger(&trig1); - DownloadBtn.SetToolTip(&DownloadBtnTT,205,-30); - - idBtn.SetSoundOver(&btnSoundOver); - idBtn.SetTrigger(&trigA); - idBtn.SetToolTip(&IDBtnTT,205,-30); - - } else - { - DownloadBtn.SetRumble(false); - idBtn.SetRumble(false); - } - - GuiGameBrowser * gameBrowser = NULL; - GuiGameGrid * gameGrid = NULL; - GuiGameCarousel * gameCarousel = NULL; - if (Settings.gameDisplay==list) { - gameBrowser = new GuiGameBrowser(THEME.gamelist_w, THEME.gamelist_h, gameList, gameCnt, CFG.theme_path, bg_options_png, startat, offset); - gameBrowser->SetPosition(THEME.gamelist_x, THEME.gamelist_y); - gameBrowser->SetAlignment(ALIGN_LEFT, ALIGN_CENTRE); - } else if (Settings.gameDisplay==grid) { - gameGrid = new GuiGameGrid(THEME.gamegrid_w,THEME.gamegrid_h, gameList, gameCnt, CFG.theme_path, bg_options_png, 0, 0); - gameGrid->SetPosition(THEME.gamegrid_x,THEME.gamegrid_y); - gameGrid->SetAlignment(ALIGN_LEFT, ALIGN_CENTRE); - } else if (Settings.gameDisplay==carousel) { - //GuiGameCarousel gameCarousel(THEME.gamecarousel_w, THEME.gamecarousel_h, gameList, gameCnt, CFG.theme_path, bg_options_png, startat, offset); - gameCarousel = new GuiGameCarousel(640, 400, gameList, gameCnt, CFG.theme_path, bg_options_png, startat, offset); - gameCarousel->SetPosition(THEME.gamecarousel_x,THEME.gamecarousel_y); - gameCarousel->SetAlignment(ALIGN_LEFT, ALIGN_CENTRE); - } - - GuiText clockTimeBack("88:88", 40, (GXColor) {THEME.clock.r, THEME.clock.g, THEME.clock.b, THEME.clock.a/6}); - clockTimeBack.SetAlignment(THEME.clock_align, ALIGN_TOP); - clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y); - clockTimeBack.SetFont(fontClock); - GuiText clockTime(theTime, 40, THEME.clock); - clockTime.SetAlignment(THEME.clock_align, ALIGN_TOP); - clockTime.SetPosition(THEME.clock_x, THEME.clock_y); - clockTime.SetFont(fontClock); - - HaltGui(); - GuiWindow w(screenwidth, screenheight); - - if (THEME.show_hddinfo == -1 || THEME.show_hddinfo == 1) { //force show hdd info - w.Append(&usedSpaceTxt); - } - if (THEME.show_gamecount == -1 || THEME.show_gamecount == 1) { //force show game cnt info - w.Append(&gamecntBtn); - } - w.Append(&sdcardBtn); - w.Append(&poweroffBtn); - w.Append(&gameInfo); - if (Settings.godmode && load_from_fs != PART_FS_NTFS) - w.Append(&installBtn); - w.Append(&homeBtn); - w.Append(&settingsBtn); - w.Append(&DownloadBtn); - w.Append(&idBtn); - w.Append(&screenShotBtn); - - - // Begin Toolbar - w.Append(&favoriteBtn); - Toolbar[0] = &favoriteBtn; - w.Append(&searchBtn); - Toolbar[1] = &searchBtn; - w.Append(&abcBtn); - Toolbar[2] = &abcBtn; - w.Append(&countBtn); - Toolbar[3] = &countBtn; - w.Append(&listBtn); - Toolbar[4] = &listBtn; - w.Append(&gridBtn); - Toolbar[5] = &gridBtn; - w.Append(&carouselBtn); - Toolbar[6] = &carouselBtn; - w.Append(&lockBtn); - Toolbar[7] = &lockBtn; - w.Append(&dvdBtn); - Toolbar[8] = &dvdBtn; - w.SetUpdateCallback(DiscListWinUpdateCallback); - // End Toolbar - - - - if (Settings.godmode == 1) - w.Append(&homebrewBtn); - - if ((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) { - w.Append(&clockTimeBack); - w.Append(&clockTime); - } - - if (Settings.gameDisplay==list) { - mainWindow->Append(gameBrowser); - } - if (Settings.gameDisplay==grid) { - mainWindow->Append(gameGrid); - } - if (Settings.gameDisplay==carousel) { - mainWindow->Append(gameCarousel); - } - mainWindow->Append(&w); - - GuiSearchBar *searchBar=NULL; - if(show_searchwindow) { - searchBar = new GuiSearchBar(gameFilterNextList); - if(searchBar) - mainWindow->Append(searchBar); - } - - ResumeGui(); - -// ShowMemInfo(); - - while (menu == MENU_NONE) { - - if (idiotFlag==1) { - gprintf("\n\tIdiot flag"); - char idiotBuffer[200]; - snprintf(idiotBuffer, sizeof(idiotBuffer), "%s (%s). %s",tr("You have attempted to load a bad image"), - idiotChar,tr("Most likely it has dimensions that are not evenly divisible by 4.")); - - int deleteImg = WindowPrompt(0,idiotBuffer,tr("OK"),tr("Delete")); - if (deleteImg==0) { - snprintf(idiotBuffer, sizeof(idiotBuffer), "%s %s.",tr("You are about to delete "), idiotChar); - deleteImg = WindowPrompt(tr("Confirm"),idiotBuffer,tr("Delete"),tr("Cancel")); - if (deleteImg==1) { - remove(idiotChar); - } - } - idiotFlag=-1; - } - - WDVD_GetCoverStatus(&covert);//for detecting if i disc has been inserted - - // if the idiot is showing favorites and don't have any - if (Settings.fave && !gameCnt) { - WindowPrompt(tr("No Favorites"),tr("You are choosing to display favorites and you do not have any selected."),tr("Back")); - Settings.fave=!Settings.fave; - if (isInserted(bootDevice)) { - cfg_save_global(); - } - __Menu_GetEntries(); - menu = MENU_DISCLIST; - break; - } - - //CLOCK - time_t rawtime = time(0); //this fixes code dump caused by the clock - if (((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) && rawtime != lastrawtime) { - lastrawtime = rawtime; - timeinfo = localtime (&rawtime); - if (dataed < 1) { - if (Settings.hddinfo == hr12) { - if (rawtime & 1) - strftime(theTime, sizeof(theTime), "%I:%M", timeinfo); - else - strftime(theTime, sizeof(theTime), "%I %M", timeinfo); - } - if (Settings.hddinfo == hr24) { - if (rawtime & 1) - strftime(theTime, sizeof(theTime), "%H:%M", timeinfo); - else - strftime(theTime, sizeof(theTime), "%H %M", timeinfo); - } - clockTime.SetText(theTime); - - } else if (dataed > 0) { - - clockTime.SetTextf("%i", (dataed-1)); - } - - } - - if ((datagB<1)&&(Settings.cios==1)&&(Settings.video == ntsc)&&(Settings.hddinfo == hr12)&&(Settings.qboot==1)&&(Settings.wsprompt==0)&&(Settings.language==ger)&&(Settings.tooltips==0)){dataed=1;dataef=1;}if (dataef==1){if (cosa>7){cosa=1;}datag++;if (sina==3){wiiBtn.SetAlignment(ALIGN_LEFT,ALIGN_BOTTOM);wiiBtnImg.SetAngle(0);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((cosa)*70),(-2*(datag)+120));}else if(62<=datag){wiiBtn.SetPosition(((cosa)*70),((datag*2)-130));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==2){wiiBtn.SetAlignment(ALIGN_RIGHT,ALIGN_TOP);wiiBtnImg.SetAngle(270);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((-2*(datag)+130)),((cosa)*50));}else if(62<=datag){wiiBtn.SetPosition((2*(datag)-120),((cosa)*50));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==1){wiiBtn.SetAlignment(ALIGN_TOP,ALIGN_LEFT);wiiBtnImg.SetAngle(180);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((cosa)*70),(2*(datag)-120));}else if(62<=datag){wiiBtn.SetPosition(((cosa)*70),(-2*(datag)+130));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==0){wiiBtn.SetAlignment(ALIGN_TOP,ALIGN_LEFT);wiiBtnImg.SetAngle(90);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((2*(datag)-130)),((cosa)*50));}else if(62<=datag){wiiBtn.SetPosition((-2*(datag)+120),((cosa)*50));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}} - // respond to button presses - if (shutdown == 1) { - gprintf("\n\tshutdown"); - Sys_Shutdown(); - } - if (reset == 1) - Sys_Reboot(); - - if (updateavailable == true) { - gprintf("\n\tUpdate Available"); - HaltGui(); - GuiWindow ww(640,480); - w.SetState(STATE_DISABLED); - mainWindow->Append(&ww); - ResumeGui(); - ProgressUpdateWindow(); - updateavailable = false; - mainWindow->Remove(&ww); - w.SetState(STATE_DEFAULT); - menu = MENU_DISCLIST; - } - - if (poweroffBtn.GetState() == STATE_CLICKED) { - - - gprintf("\n\tpoweroffBtn clicked"); - choice = WindowPrompt(tr("How to Shutdown?"),0,tr("Full Shutdown"), tr("Shutdown to Idle"), tr("Cancel")); - if (choice == 2) { - Sys_ShutdownToIdel(); - } else if (choice == 1) { - Sys_ShutdownToStandby(); - } else { - poweroffBtn.ResetState(); - if (Settings.gameDisplay==list) { - gameBrowser->SetFocus(1); - } else if (Settings.gameDisplay==grid) { - gameGrid->SetFocus(1); - } else if (Settings.gameDisplay==carousel) { - gameCarousel->SetFocus(1); - } - } - - } else if (gamecntBtn.GetState() == STATE_CLICKED && mountMethod!=3) { - gprintf("\n\tgameCntBtn clicked"); - gamecntBtn.ResetState(); - char linebuf[150]; - snprintf(linebuf, sizeof(linebuf), "%s %sGameList ?",tr("Save Game List to"), Settings.update_path); - choice = WindowPrompt(0,linebuf,"TXT","CSV",tr("Back")); - if (choice) { - if (save_gamelist(choice-1)) - WindowPrompt(0,tr("Saved"),tr("OK")); - else - WindowPrompt(tr("Error"),tr("Could not save."),tr("OK")); - } - menu = MENU_DISCLIST; - break; - - } - else if (screenShotBtn.GetState() == STATE_CLICKED) { - gprintf("\n\tscreenShotBtn clicked"); - screenShotBtn.ResetState(); - ScreenShot(); - gprintf("...It's easy, mmmmmmKay"); - - - }else if (homeBtn.GetState() == STATE_CLICKED) { - gprintf("\n\thomeBtn clicked"); - bgMusic->Pause(); - choice = WindowExitPrompt(); - bgMusic->Resume(); - - if (choice == 3) { - Sys_LoadMenu(); // Back to System Menu - } else if (choice == 2) { - Sys_BackToLoader(); - } else { - homeBtn.ResetState(); - if (Settings.gameDisplay==list) { - gameBrowser->SetFocus(1); - } else if (Settings.gameDisplay==grid) { - gameGrid->SetFocus(1); - } else if (Settings.gameDisplay==carousel) { - gameCarousel->SetFocus(1); - } - } - - } else if (wiiBtn.GetState() == STATE_CLICKED) { - gprintf("\n\twiiBtn clicked"); - - dataed++; - wiiBtn.ResetState(); - if (Settings.gameDisplay==list) { - gameBrowser->SetFocus(1); - } else if (Settings.gameDisplay==grid) { - gameGrid->SetFocus(1); - } else if (Settings.gameDisplay==carousel) { - gameCarousel->SetFocus(1); - } - } else if (installBtn.GetState() == STATE_CLICKED) { - gprintf("\n\tinstallBtn clicked"); - choice = WindowPrompt(tr("Install a game"),0,tr("Yes"),tr("No")); - if (choice == 1) { - menu = MENU_INSTALL; - break; - } else { - installBtn.ResetState(); - if (Settings.gameDisplay==list) { - gameBrowser->SetFocus(1); - } else if (Settings.gameDisplay==grid) { - gameGrid->SetFocus(1); - } else if (Settings.gameDisplay==carousel) { - gameCarousel->SetFocus(1); - } - } - }else if ((covert & 0x2)&&(covert!=covertOld)) { - gprintf("\n\tNew Disc Detected"); - choice = WindowPrompt(tr("New Disc Detected"),0,tr("Install"),tr("Mount DVD drive"),tr("Cancel")); - if (choice == 1) { - if (load_from_fs == PART_FS_NTFS) { - WindowPrompt(tr("Install not possible"), tr("You are using NTFS filesystem. Due to possible write errors to a NTFS partition, installing a game is not possible."), tr("OK")); - } else { - menu = MENU_INSTALL; - break; - } - } - else if (choice ==2) - { - dvdBtn.SetState(STATE_CLICKED); - }else { - if (Settings.gameDisplay==list) { - gameBrowser->SetFocus(1); - } else if (Settings.gameDisplay==grid) { - gameGrid->SetFocus(1); - } else if (Settings.gameDisplay==carousel) { - gameCarousel->SetFocus(1); - } - } - } - - else if (sdcardBtn.GetState() == STATE_CLICKED) { - gprintf("\n\tsdCardBtn Clicked"); - SDCard_deInit(); - SDCard_Init(); - if (Settings.gameDisplay==list) { - startat = gameBrowser->GetSelectedOption(); - offset = gameBrowser->GetOffset(); - } else if (Settings.gameDisplay==grid) { - startat = gameGrid->GetSelectedOption(); - offset = gameGrid->GetOffset(); - } else if (Settings.gameDisplay==carousel) { - startat = gameCarousel->GetSelectedOption(); - offset = gameCarousel->GetOffset(); - } - if (isInserted(bootDevice)) { - HaltGui(); // to fix endless rumble when clicking on the SD icon when rumble is disabled because rumble is set to on in Global_Default() - CFG_Load(); - ResumeGui(); - } - sdcardBtn.ResetState(); - menu = MENU_DISCLIST; - break; - } - - else if (DownloadBtn.GetState() == STATE_CLICKED) { - gprintf("\n\tDownloadBtn Clicked"); - if (isInserted(bootDevice)) { - choice = WindowPrompt(tr("Cover Download"), 0, tr("Normal Covers"), tr("3D Covers"), tr("Disc Images"), tr("Back")); // ask for download choice - if (choice != 0) { - int choice2 = choice; - bool missing; - missing = SearchMissingImages(choice2); - if (IsNetworkInit() == false && missing == true) { - WindowPrompt(tr("Network init error"), 0, tr("OK")); - } else { - if (GetMissingFiles() != NULL && cntMissFiles > 0) { - char tempCnt[40]; - sprintf(tempCnt,"%i %s",cntMissFiles,tr("Missing files")); - if (choice!=3)choice = WindowPrompt(tr("Download Boxart image?"),tempCnt,tr("Yes"),tr("No")); - else if (choice==3)choice = WindowPrompt(tr("Download Discart image?"),tempCnt,tr("Yes"),tr("No")); - if (choice == 1) { - ret = ProgressDownloadWindow(choice2); - if (ret == 0) { - WindowPrompt(tr("Download finished"),0,tr("OK")); - } else { - sprintf(tempCnt,"%i %s",ret,tr("files not found on the server!")); - WindowPrompt(tr("Download finished"),tempCnt,tr("OK")); - } - } - } - } - } - } else { - WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to download images."), tr("OK")); - } - menu = MENU_DISCLIST; - DownloadBtn.ResetState(); - if (Settings.gameDisplay==list) { - gameBrowser->SetFocus(1); - } else if (Settings.gameDisplay==grid) { - gameGrid->SetFocus(1); - } else if (Settings.gameDisplay==carousel) { - gameCarousel->SetFocus(1); - } - }//end download - - else if (settingsBtn.GetState() == STATE_CLICKED) { - gprintf("\n\tsettingsBtn Clicked"); - if (Settings.gameDisplay==list) { - startat = gameBrowser->GetSelectedOption(); - offset = gameBrowser->GetOffset(); - } else if (Settings.gameDisplay==grid) { - startat = gameGrid->GetSelectedOption(); - offset = gameGrid->GetOffset(); - } else if (Settings.gameDisplay==carousel) { - startat = gameCarousel->GetSelectedOption(); - offset = gameCarousel->GetOffset(); - } - menu = MENU_SETTINGS; - break; - - } - - else if (favoriteBtn.GetState() == STATE_CLICKED) { - gprintf("\n\tfavoriteBtn Clicked"); - Settings.fave=!Settings.fave; - if (isInserted(bootDevice)) { - cfg_save_global(); - } - __Menu_GetEntries(); - menu = MENU_DISCLIST; - break; - - } - - else if (searchBtn.GetState() == STATE_CLICKED && mountMethod!=3) { - - gprintf("\n\tsearchBtn Clicked"); - show_searchwindow=!show_searchwindow; - HaltGui(); - if(searchBar) - { - mainWindow->Remove(searchBar); - delete searchBar; - searchBar = NULL; - } - if(show_searchwindow) - { - if(gameFilter && *gameFilter) - { - searchBtn.StopEffect(); - searchBtn.SetEffectGrow(); - } - searchBar = new GuiSearchBar(gameFilterNextList); - if(searchBar) - mainWindow->Append(searchBar); - } - else - { - if(gameFilter && *gameFilter) - searchBtn.SetEffect(EFFECT_PULSE, 10, 105); - } - searchBtn.ResetState(); - ResumeGui(); - } - - else if (searchBar && (searchChar=searchBar->GetClicked())) { - if(searchChar > 27) - { - int len = gameFilter ? wcslen(gameFilter) : 0; - wchar_t newFilter[len+2]; - if(gameFilter) - wcscpy(newFilter, gameFilter); - newFilter[len] = searchChar; - newFilter[len+1] = 0; - - - __Menu_GetEntries(0, newFilter); - menu = MENU_DISCLIST; - break; - } - else if(searchChar == 7) // Close - { - show_searchwindow=false; - HaltGui(); - if(searchBar) - { - mainWindow->Remove(searchBar); - delete searchBar; - searchBar = NULL; - } - if(gameFilter && *gameFilter) - { - searchBtn.SetEffect(EFFECT_PULSE, 10, 105); - searchBtn.SetImage(&searchBtnImg); - searchBtn.SetImageOver(&searchBtnImg); - searchBtn.SetAlpha(255); - } - else - { - searchBtn.StopEffect(); - searchBtn.SetEffectGrow(); - searchBtn.SetImage(&searchBtnImg_g); - searchBtn.SetImageOver(&searchBtnImg_g); - searchBtn.SetAlpha(180); - } - - ResumeGui(); - } - else if(searchChar == 8) // Backspace - { - __Menu_GetEntries(0, gameFilterPrev); - menu = MENU_DISCLIST; - break; - } - - } - - else if (abcBtn.GetState() == STATE_CLICKED) { - gprintf("\n\tabcBtn clicked"); - if (Settings.sort != all) { - Settings.sort=all; - if (isInserted(bootDevice)) { - cfg_save_global(); - } - __Menu_GetEntries(); - - menu = MENU_DISCLIST; - break; - } - abcBtn.ResetState(); - } - - else if (countBtn.GetState() == STATE_CLICKED) { - gprintf("\n\tcountBtn Clicked"); - if (Settings.sort != pcount) { - Settings.sort=pcount; - //if(isSdInserted()) { - if (isInserted(bootDevice)) { - cfg_save_global(); - } - __Menu_GetEntries(); - - menu = MENU_DISCLIST; - break; - } - countBtn.ResetState(); - - } - - else if (listBtn.GetState() == STATE_CLICKED) { - gprintf("\n\tlistBtn Clicked"); - if (Settings.gameDisplay!=list) { - Settings.gameDisplay=list; - menu = MENU_DISCLIST; - if (isInserted(bootDevice)) { - cfg_save_global(); - } - listBtn.ResetState(); - break; - } else { - listBtn.ResetState(); - } - } - - - else if (gridBtn.GetState() == STATE_CLICKED) { - gprintf("\n\tgridBtn Clicked"); - if (Settings.gameDisplay!=grid) { - - Settings.gameDisplay=grid; - menu = MENU_DISCLIST; - if (isInserted(bootDevice)) { - cfg_save_global(); - } - gridBtn.ResetState(); - break; - } else { - gridBtn.ResetState(); - } - } - - else if (carouselBtn.GetState() == STATE_CLICKED) { - gprintf("\n\tcarouselBtn Clicked"); - if (Settings.gameDisplay!=carousel) { - Settings.gameDisplay=carousel; - menu = MENU_DISCLIST; - if (isInserted(bootDevice)) { - cfg_save_global(); - } - carouselBtn.ResetState(); - break; - } else { - carouselBtn.ResetState(); - } - } - else if (homebrewBtn.GetState() == STATE_CLICKED) { - gprintf("\n\thomebrewBtn Clicked"); - menu = MENU_HOMEBREWBROWSE; - break; - } - else if (gameInfo.GetState() == STATE_CLICKED && mountMethod!=3) { - gprintf("\n\tgameinfo Clicked"); - gameInfo.ResetState(); - if(selectImg1>=0 && selectImg1<(s32)gameCnt) { - gameSelected = selectImg1; - rockout(); - struct discHdr *header = &gameList[selectImg1]; - snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); - choice = showGameInfo(IDfull); - rockout(2); - if (choice==2) - homeBtn.SetState(STATE_CLICKED); - if (choice==3) { - menu = MENU_DISCLIST; - break; - } - } - } - else if (lockBtn.GetState() == STATE_CLICKED) { - gprintf("\n\tlockBtn clicked"); - lockBtn.ResetState(); - if (!canUnlock) { - WindowPrompt(tr("Parental Control"), tr("You don't have Parental Control enabled. If you wish to use Parental Control, enable it in the Wii Settings."), tr("OK")); - } else { - if (Settings.godmode) { - if (WindowPrompt(tr("Parental Control"), tr("Are you sure you want to enable Parent Control?"), tr("Yes"), tr("No")) == 1) { - Settings.godmode = 0; - lockBtn.SetImage(&lockBtnImg_g); - lockBtn.SetImageOver(&lockBtnImg_g); - lockBtn.SetToolTip(&lockBtnTT, 15, 52, 1, 3); - - // Retrieve the gamelist again - menu = MENU_DISCLIST; - break; - } - } else { - // Require the user to enter the PIN code - char pin[5]; - memset(&pin, 0, 5); - int ret = OnScreenNumpad((char *) &pin, 5); - - if (ret == 1) { - if (memcmp(pin, Settings.parental.pin, 4) == 0) { - Settings.godmode = 1; - lockBtn.SetImage(&unlockBtnImg_g); - lockBtn.SetImageOver(&unlockBtnImg_g); - lockBtn.SetToolTip(&unlockBtnTT, 15, 52, 1, 3); - - // Retrieve the gamelist again - menu = MENU_DISCLIST; - break; - } else { - WindowPrompt(tr("Parental Control"), tr("Invalid PIN code"), tr("OK")); - } - } - } - } - } - else if (dvdBtn.GetState() == STATE_CLICKED) { - gprintf("\n\tdvdBtn Clicked"); - mountMethodOLD = (mountMethod==3?mountMethod:0); - - mountMethod=DiscMount(dvdheader); - dvdBtn.ResetState(); - - rockout(); - //break; - } - if (Settings.gameDisplay==grid) { - int selectimg; - DownloadBtn.SetSize(0,0); - selectimg = gameGrid->GetSelectedOption(); - gameSelected = gameGrid->GetClickedOption(); - selectImg1=selectimg; - } - - if (Settings.gameDisplay==carousel) { - int selectimg; - DownloadBtn.SetSize(0,0); - selectimg = gameCarousel->GetSelectedOption(); - gameSelected = gameCarousel->GetClickedOption(); - selectImg1=selectimg; - } - if (Settings.gameDisplay==list) { - //Get selected game under cursor - int selectimg; - DownloadBtn.SetSize(160,224); - idBtn.SetSize(100,40); - - selectimg = gameBrowser->GetSelectedOption(); - gameSelected = gameBrowser->GetClickedOption(); - selectImg1=selectimg; - - if (gameSelected > 0) //if click occured - selectimg = gameSelected; - - char gameregion[7]; - if ((selectimg >= 0) && (selectimg < (s32) gameCnt)) { - if (selectimg != selectedold) { - selectedold = selectimg;//update displayed cover, game ID, and region if the selected game changes - struct discHdr *header = &gameList[selectimg]; - snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]); - snprintf (IDfull,sizeof(IDfull),"%s%c%c%c", ID, header->id[3], header->id[4], header->id[5]); - w.Remove(&DownloadBtn); - - if (GameIDTxt) { - w.Remove(&idBtn); - delete GameIDTxt; - GameIDTxt = NULL; - } - if (GameRegionTxt) { - w.Remove(GameRegionTxt); - delete GameRegionTxt; - GameRegionTxt = NULL; - } - - switch (header->id[3]) { - case 'E': - sprintf(gameregion,"NTSC U"); - break; - case 'J': - sprintf(gameregion,"NTSC J"); - break; - case 'W': - sprintf(gameregion,"NTSC T"); - break; - default: - case 'K': - sprintf(gameregion,"NTSC K"); - break; - case 'P': - case 'D': - case 'F': - case 'I': - case 'S': - case 'H': - case 'U': - case 'X': - case 'Y': - case 'Z': - sprintf(gameregion," PAL "); - break; - } - - //load game cover - if (cover) { - delete cover; - cover = NULL; - } - - cover = LoadCoverImage(header); - - if (coverImg) { - delete coverImg; - coverImg = NULL; - } - coverImg = new GuiImage(cover); - coverImg->SetWidescreen(CFG.widescreen); - - DownloadBtn.SetImage(coverImg);// put the new image on the download button - w.Append(&DownloadBtn); - - if ((Settings.sinfo == GameID) || (Settings.sinfo == Both)) { - GameIDTxt = new GuiText(IDfull, 22, THEME.info); - GameIDTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); - //GameIDTxt->SetPosition(THEME.id_x,THEME.id_y); - idBtn.SetEffect(EFFECT_FADE, 20); - idBtn.SetLabel(GameIDTxt); - w.Append(&idBtn); - } - //don't try to show region for channels because all the custom channels wont follow the rules - if (((Settings.sinfo == GameRegion) || (Settings.sinfo == Both))&&mountMethod!=3) { - GameRegionTxt = new GuiText(gameregion, 22, THEME.info); - GameRegionTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); - GameRegionTxt->SetPosition(THEME.region_x, THEME.region_y); - GameRegionTxt->SetEffect(EFFECT_FADE, 20); - w.Append(GameRegionTxt); - } - } - } - - if (idBtn.GetState() == STATE_CLICKED && mountMethod!=3) { - gprintf("\n\tidBtn Clicked"); - struct discHdr * header = &gameList[gameBrowser->GetSelectedOption()]; - //enter new game ID - char entered[10]; - snprintf(entered, sizeof(entered), "%s", IDfull); - //entered[9] = '\0'; - int result = OnScreenKeyboard(entered, 7,0); - if (result == 1) { - WBFS_ReIDGame(header->id, entered); - //__Menu_GetEntries(); - menu = MENU_DISCLIST; - } - - idBtn.ResetState(); - } - startat=gameBrowser->GetOffset(), offset=startat; - } - - if (((gameSelected >= 0) && (gameSelected < (s32)gameCnt)) - || mountMethod==1 - || mountMethod==2) { - if(searchBar) - { - HaltGui(); - mainWindow->Remove(searchBar); - ResumeGui(); - } - rockout(); - struct discHdr *header = (mountMethod==1||mountMethod==2?dvdheader:&gameList[gameSelected]); - // struct discHdr *header = dvdheader:&gameList[gameSelected]); - if (!mountMethod)//only get this stuff it we are booting a game from USB - { - WBFS_GameSize(header->id, &size); - if (strlen(get_title(header)) < (MAX_CHARACTERS + 3)) { - sprintf(text, "%s", get_title(header)); - } else { - strncpy(text, get_title(header), MAX_CHARACTERS); - text[MAX_CHARACTERS] = '\0'; - strncat(text, "...", 3); - } - } - - //check if alt Dol and gct file is present - FILE *exeFile = NULL; - char nipple[100]; - header = (mountMethod==1||mountMethod==2?dvdheader:&gameList[gameSelected]); //reset header - snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); - struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); - - if (game_cfg) { - alternatedol = game_cfg->loadalternatedol; - ocarinaChoice = game_cfg->ocarina; - } else { - alternatedol = off; - ocarinaChoice = Settings.ocarina; - } - - - if (Settings.qboot == yes) { //quickboot game - if (alternatedol == on) { - /* Open dol File and check exist */ - sprintf(nipple, "%s%s.dol",Settings.dolpath,IDfull); - exeFile = fopen (nipple ,"rb"); - if (exeFile==NULL) { - sprintf(nipple, "%s %s",nipple,tr("does not exist!")); - WindowPrompt(tr("Error"),nipple,tr("OK")); - menu = MENU_CHECK; - wiilight(0); - break; - } else { - fclose(exeFile); - } - } - if (ocarinaChoice != off) { - /* Open gct File and check exist */ - sprintf(nipple, "%s%s.gct",Settings.Cheatcodespath,IDfull); - exeFile = fopen (nipple ,"rb"); - if (exeFile==NULL) { - gprintf("\n\ttried to load missing gct."); - sprintf(nipple, "%s %s",nipple,tr("does not exist! Loading game without cheats.")); - WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170); - } else { - fseek (exeFile, 0, SEEK_END); - long size=ftell (exeFile); - rewind (exeFile); - fclose(exeFile); - if (size>MAX_GCT_SIZE) { - gprintf("\n\tgct is too big"); - sprintf(nipple, "%s %s",nipple,tr("contains over 255 lines of code. It will produce unexpected results.")); - WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170); - } - } - - } - - wiilight(0); - if (isInserted(bootDevice)) { - //////////save game play count//////////////// - struct Game_NUM* game_num = CFG_get_game_num(header->id); - - if (game_num) { - favoritevar = game_num->favorite; - playcount = game_num->count; - } else { - favoritevar = 0; - playcount = 0; - } - playcount += 1; - - CFG_save_game_num(header->id); - gprintf("\n\tplaycount for %c%c%c%c%c%c raised to %i",header->id[0],header->id[1],header->id[2],header->id[3],header->id[4],header->id[5],playcount); - - } - menu = MENU_EXIT; - break; - - } - bool returnHere = true;// prompt to start game - while (returnHere) { - returnHere = false; - if (Settings.wiilight != wiilight_forInstall) wiilight(1); - choice = GameWindowPrompt(); - // header = &gameList[gameSelected]; //reset header - - if (choice == 1) { - if (alternatedol == on) { - /* Open dol File and check exist */ - sprintf(nipple, "%s%s.dol",Settings.dolpath,IDfull); - exeFile = fopen (nipple ,"rb"); - if (exeFile==NULL) { - gprintf("\n\tTried to load alt dol that isn't there"); - sprintf(nipple, "%s %s",nipple,tr("does not exist! You Messed something up, Idiot.")); - WindowPrompt(tr("Error"),nipple,tr("OK")); - menu = MENU_CHECK; - wiilight(0); - break; - } else { - fclose(exeFile); - } - } - if (ocarinaChoice != off) { - /* Open gct File and check exist */ - sprintf(nipple, "%s%s.gct",Settings.Cheatcodespath,IDfull); - exeFile = fopen (nipple ,"rb"); - if (exeFile==NULL) { - gprintf("\n\ttried to load gct file that isn't there"); - sprintf(nipple, "%s %s",nipple,tr("does not exist! Loading game without cheats.")); - WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170); - } else { - fseek (exeFile, 0, SEEK_END); - long size=ftell (exeFile); - rewind (exeFile); - fclose(exeFile); - if (size>MAX_GCT_SIZE) { - gprintf("\n\tgct file is too big"); - sprintf(nipple, "%s %s",nipple,tr("contains over 255 lines of code. It will produce unexpected results.")); - WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170); - } - } - - } - wiilight(0); - returnHere = false; - menu = MENU_EXIT; - - } else if (choice == 2) { - wiilight(0); - HaltGui(); - if (Settings.gameDisplay==list) mainWindow->Remove(gameBrowser); - else if (Settings.gameDisplay==grid) mainWindow->Remove(gameGrid); - else if (Settings.gameDisplay==carousel) mainWindow->Remove(gameCarousel); - mainWindow->Remove(&w); - ResumeGui(); - - //re-evaluate header now in case they changed games while on the game prompt - header = (mountMethod==1||mountMethod==2?dvdheader:&gameList[gameSelected]); - int settret = GameSettings(header); - /* unneeded for now, kept in case database gets a separate language setting - //menu = MENU_DISCLIST; // refresh titles (needed if the language setting has changed) - */ - HaltGui(); - if (Settings.gameDisplay==list) mainWindow->Append(gameBrowser); - else if (Settings.gameDisplay==grid) mainWindow->Append(gameGrid); - else if (Settings.gameDisplay==carousel) mainWindow->Append(gameCarousel); - mainWindow->Append(&w); - ResumeGui(); - if (settret == 1) { //if deleted - menu = MENU_DISCLIST; - break; - } - returnHere = true; - rockout(2); - } - - else if (choice == 3 && !mountMethod) { //WBFS renaming - wiilight(0); - //re-evaluate header now in case they changed games while on the game prompt - header = &gameList[gameSelected]; - - //enter new game title - char entered[60]; - snprintf(entered, sizeof(entered), "%s", get_title(header)); - entered[59] = '\0'; - int result = OnScreenKeyboard(entered, 60,0); - if (result == 1) { - WBFS_RenameGame(header->id, entered); - __Menu_GetEntries(); - menu = MENU_DISCLIST; - } - } else if (choice == 0) { - rockout(2); - if (mountMethod==1||mountMethod==2)mountMethod = mountMethodOLD; - if (Settings.gameDisplay==list) { - gameBrowser->SetFocus(1); - } else if (Settings.gameDisplay==grid) { - gameGrid->SetFocus(1); - } else if (Settings.gameDisplay==carousel) { - gameCarousel->SetFocus(1); - } - } - - - } - if(searchBar) - { - HaltGui(); - mainWindow->Append(searchBar); - ResumeGui(); - } - } - // to skip the first call of windowScreensaver at startup when wiimote is not connected - if (IsWpadConnected()) { - check = 1; - } - - // screensaver is called when wiimote shuts down, depending on the wiimotet idletime - if (!IsWpadConnected() && check !=0 && Settings.screensaver!=0) { - check++; - int screensaverIsOn=0; - if (check==11500) { //to allow time for the wii to turn off and not show the screensaver - screensaverIsOn=WindowScreensaver(); - } - if (screensaverIsOn==1)check=0; - } - covertOld=covert; - } - - // set alt dol default - if (menu == MENU_EXIT && altdoldefault) { - struct discHdr *header = (mountMethod==1||mountMethod==2?dvdheader:&gameList[gameSelected]); - struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); - // use default only if no alt dol was selected manually - if (game_cfg) { - if (game_cfg->alternatedolstart != 0) - altdoldefault = false; - } - if (altdoldefault) { - int autodol = autoSelectDol((char*)header->id, true); - if (autodol>0) { - alternatedol = 2; - alternatedoloffset = autodol; - char temp[20]; - sprintf(temp,"%d",autodol); - } else { - // alt dol menu for games that require more than a single alt dol - int autodol = autoSelectDolMenu((char*)header->id, true); - if (autodol>0) { - alternatedol = 2; - alternatedoloffset = autodol; - } - } - } - } -//no need to close sd here. we still need to get settings and codes and shit - /*if (menu == MENU_EXIT) { - SDCard_deInit(); - }*/ - //if (Settings.gameDisplay==list) {startat=gameBrowser->GetOffset(), offset=startat;}//save the variables in case we are refreshing the list - //gprintf("\n\tstartat:%d offset:%d",startat,offset); - HaltGui(); - mainWindow->RemoveAll(); - mainWindow->Append(bgImg); - delete searchBar; - searchBar = NULL; - delete gameBrowser; - gameBrowser = NULL; - delete gameGrid; - gameGrid = NULL; - delete gameCarousel; - gameCarousel = NULL; - ResumeGui(); - return menu; -} - -void DiscListWinUpdateCallback(void * e) -{ - GuiWindow *w = (GuiWindow *)e; - for(int i=0; i<8; ++i) - { - if(Toolbar[i]->GetState() == STATE_SELECTED) - { - w->Remove(Toolbar[i]); - w->Append(Toolbar[i]); // draw the selected Icon allways on top - break; - } - } -} - -void rockout(int f) { - - - HaltGui(); - int num=(f==2?-1:gameSelected); - - char imgPath[100]; - if ((!(strcasestr(get_title(&gameList[num]),"guitar")|| - strcasestr(get_title(&gameList[num]),"band")|| - strcasestr(get_title(&gameList[num]),"rock")|| - f==1))||mountMethod) { - for (int i = 0; i < 4; i++) - delete pointer[i]; - snprintf(imgPath, sizeof(imgPath), "%splayer1_point.png", CFG.theme_path); - pointer[0] = new GuiImageData(imgPath, player1_point_png); - snprintf(imgPath, sizeof(imgPath), "%splayer2_point.png", CFG.theme_path); - pointer[1] = new GuiImageData(imgPath, player2_point_png); - snprintf(imgPath, sizeof(imgPath), "%splayer3_point.png", CFG.theme_path); - pointer[2] = new GuiImageData(imgPath, player3_point_png); - snprintf(imgPath, sizeof(imgPath), "%splayer4_point.png", CFG.theme_path); - pointer[3] = new GuiImageData(imgPath, player4_point_png); - } else { - - for (int i = 0; i < 4; i++) - delete pointer[i]; - snprintf(imgPath, sizeof(imgPath), "%srplayer1_point.png", CFG.theme_path); - pointer[0] = new GuiImageData(imgPath, rplayer1_point_png); - snprintf(imgPath, sizeof(imgPath), "%srplayer2_point.png", CFG.theme_path); - pointer[1] = new GuiImageData(imgPath, rplayer2_point_png); - snprintf(imgPath, sizeof(imgPath), "%srplayer3_point.png", CFG.theme_path); - pointer[2] = new GuiImageData(imgPath, rplayer3_point_png); - snprintf(imgPath, sizeof(imgPath), "%srplayer4_point.png", CFG.theme_path); - pointer[3] = new GuiImageData(imgPath, rplayer4_point_png); - } - ResumeGui(); -} +#include "menus.h" +#include "fatmounter.h" +#include "usbloader/wdvd.h" +#include "usbloader/getentries.h" +#include "usbloader/wbfs.h" +#include "patches/fst.h" +#include "network/networkops.h" +#include "prompts/gameinfo.h" +#include "prompts/DiscBrowser.h" +#include "settings/Settings.h" +#include "wpad.h" +#include "sys.h" + +#include "libwiigui/gui_gamebrowser.h" +#include "libwiigui/gui_gamegrid.h" +#include "libwiigui/gui_gamecarousel.h" +#include "libwiigui/gui_searchbar.h" + +#define MAX_CHARACTERS 38 +extern u8 * gameScreenTex; +extern struct discHdr *dvdheader; +extern u8 mountMethod; +extern int load_from_fs; +extern s32 gameSelected; +extern GuiText * GameIDTxt; +extern GuiText * GameRegionTxt; +extern const u8 data1; +extern FreeTypeGX *fontClock; +extern bool updateavailable; +extern int cntMissFiles; +extern GuiImageData * cover; +extern GuiImage * coverImg; +extern GuiImageData * pointer[4]; +extern bool altdoldefault; +extern GuiImage * bgImg; + +GuiButton *Toolbar[9]; +int idiotFlag=-1; +char idiotChar[50]; + +void DiscListWinUpdateCallback(void * e); +void rockout(int f = 0); + +static u32 startat = 0; +//static u8 ignoreNewDisc =0;//ignore the new drive when it is detected + +/**************************************************************************** + * MenuDiscList + ***************************************************************************/ +int MenuDiscList() { + + gprintf("\nMenuDiscList()"); + if(checkthreadState == 1) + { + mountMethod = 0; + checkthreadState = 0; + } + __Menu_GetEntries(); + int offset = MIN(startat,gameCnt-1); + startat = offset; + //gprintf("\n\tstartat:%d offset:%d",startat,offset); + int datag = 0; + int datagB =0; + int dataed = -1; + int cosa=0,sina=0; + int selectImg1 = 0; + char ID[4]; + char IDfull[7]; + u32 covert = 0; + char imgPath[100]; + if (!dvdheader) + dvdheader = new struct discHdr; + u8 mountMethodOLD =0; + + WDVD_GetCoverStatus(&covert); + u32 covertOld=covert; + + f32 freespace, used, size = 0.0; + wchar_t searchChar; + //SCREENSAVER + int check = 0; //to skip the first cycle when wiimote isn't completely connected + + datagB=0; + int menu = MENU_NONE, dataef=0; + + + u32 nolist; + char text[MAX_CHARACTERS + 4]; + int choice = 0, selectedold = 100; + s32 ret; + + //CLOCK + struct tm * timeinfo; + char theTime[80]=""; + time_t lastrawtime=0; + + if (mountMethod != 3 && load_from_fs == PART_FS_WBFS) { + WBFS_DiskSpace(&used, &freespace); + } + + if (!gameCnt) { //if there is no list of games to display + nolist = 1; + } + + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume); + // because destroy GuiSound must wait while sound playing is finished, we use a global sound + if(!btnClick2) btnClick2=new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume); + // GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume); + + snprintf(imgPath, sizeof(imgPath), "%sbutton_install.png", CFG.theme_path); + GuiImageData btnInstall(imgPath, button_install_png); + snprintf(imgPath, sizeof(imgPath), "%sbutton_install_over.png", CFG.theme_path); + GuiImageData btnInstallOver(imgPath, button_install_over_png); + + snprintf(imgPath, sizeof(imgPath), "%ssettings_button.png", CFG.theme_path); + GuiImageData btnSettings(imgPath, settings_button_png); + snprintf(imgPath, sizeof(imgPath), "%ssettings_button_over.png", CFG.theme_path); + GuiImageData btnSettingsOver(imgPath, settings_button_over_png); + GuiImageData dataID(&data1); + + snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff.png", CFG.theme_path); + GuiImageData btnpwroff(imgPath, wiimote_poweroff_png); + snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff_over.png", CFG.theme_path); + GuiImageData btnpwroffOver(imgPath, wiimote_poweroff_over_png); + snprintf(imgPath, sizeof(imgPath), "%smenu_button.png", CFG.theme_path); + GuiImageData btnhome(imgPath, menu_button_png); + snprintf(imgPath, sizeof(imgPath), "%smenu_button_over.png", CFG.theme_path); + GuiImageData btnhomeOver(imgPath, menu_button_over_png); + snprintf(imgPath, sizeof(imgPath), "%sSDcard_over.png", CFG.theme_path); + GuiImageData btnsdcardOver(imgPath, sdcard_over_png); + snprintf(imgPath, sizeof(imgPath), "%sSDcard.png", CFG.theme_path); + GuiImageData btnsdcard(imgPath, sdcard_png); + + + snprintf(imgPath, sizeof(imgPath), "%sfavIcon.png", CFG.theme_path); + GuiImageData imgfavIcon(imgPath, favIcon_png); + snprintf(imgPath, sizeof(imgPath), "%sfavIcon_gray.png", CFG.theme_path); + GuiImageData imgfavIcon_gray(imgPath, NULL); + snprintf(imgPath, sizeof(imgPath), "%ssearchIcon.png", CFG.theme_path); + GuiImageData imgsearchIcon(imgPath, searchIcon_png); + snprintf(imgPath, sizeof(imgPath), "%ssearchIcon_gray.png", CFG.theme_path); + GuiImageData imgsearchIcon_gray(imgPath, NULL); + snprintf(imgPath, sizeof(imgPath), "%sabcIcon.png", CFG.theme_path); + GuiImageData imgabcIcon(imgPath, abcIcon_png); + snprintf(imgPath, sizeof(imgPath), "%sabcIcon_gray.png", CFG.theme_path); + GuiImageData imgabcIcon_gray(imgPath, NULL); + snprintf(imgPath, sizeof(imgPath), "%srankIcon.png", CFG.theme_path); + GuiImageData imgrankIcon(imgPath, rankIcon_png); + snprintf(imgPath, sizeof(imgPath), "%srankIcon_gray.png", CFG.theme_path); + GuiImageData imgrankIcon_gray(imgPath, NULL); + snprintf(imgPath, sizeof(imgPath), "%splayCountIcon.png", CFG.theme_path); + GuiImageData imgplayCountIcon(imgPath, playCountIcon_png); + snprintf(imgPath, sizeof(imgPath), "%splayCountIcon_gray.png", CFG.theme_path); + GuiImageData imgplayCountIcon_gray(imgPath, NULL); + snprintf(imgPath, sizeof(imgPath), "%sarrangeGrid.png", CFG.theme_path); + GuiImageData imgarrangeGrid(imgPath, arrangeGrid_png); + snprintf(imgPath, sizeof(imgPath), "%sarrangeGrid_gray.png", CFG.theme_path); + GuiImageData imgarrangeGrid_gray(imgPath, NULL); + snprintf(imgPath, sizeof(imgPath), "%sarrangeList.png", CFG.theme_path); + GuiImageData imgarrangeList(imgPath, arrangeList_png); + snprintf(imgPath, sizeof(imgPath), "%sarrangeList_gray.png", CFG.theme_path); + GuiImageData imgarrangeList_gray(imgPath, NULL); + snprintf(imgPath, sizeof(imgPath), "%sarrangeCarousel.png", CFG.theme_path); + GuiImageData imgarrangeCarousel(imgPath, arrangeCarousel_png); + snprintf(imgPath, sizeof(imgPath), "%sarrangeCarousel_gray.png", CFG.theme_path); + GuiImageData imgarrangeCarousel_gray(imgPath, NULL); + + snprintf(imgPath, sizeof(imgPath), "%slock.png", CFG.theme_path); + GuiImageData imgLock(imgPath, lock_png); + snprintf(imgPath, sizeof(imgPath), "%slock_gray.png", CFG.theme_path); + GuiImageData imgLock_gray(imgPath, NULL); + snprintf(imgPath, sizeof(imgPath), "%sunlock.png", CFG.theme_path); + GuiImageData imgUnlock(imgPath, unlock_png); + snprintf(imgPath, sizeof(imgPath), "%sunlock_gray.png", CFG.theme_path); + GuiImageData imgUnlock_gray(imgPath, NULL); + + snprintf(imgPath, sizeof(imgPath), "%sdvd.png", CFG.theme_path); + GuiImageData imgdvd(imgPath, dvd_png); + snprintf(imgPath, sizeof(imgPath), "%sdvd_gray.png", CFG.theme_path); + GuiImageData imgdvd_gray(imgPath, NULL); + + snprintf(imgPath, sizeof(imgPath), "%sbrowser.png", CFG.theme_path); + GuiImageData homebrewImgData(imgPath, browser_png); + snprintf(imgPath, sizeof(imgPath), "%sbrowser_over.png", CFG.theme_path); + GuiImageData homebrewImgDataOver(imgPath, browser_over_png); + + + GuiTrigger trigA; + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + GuiTrigger trigHome; + trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, PAD_BUTTON_START); + GuiTrigger trig2; + trig2.SetButtonOnlyTrigger(-1, WPAD_BUTTON_2 | WPAD_CLASSIC_BUTTON_X, 0); + GuiTrigger trig1; + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1 | WPAD_CLASSIC_BUTTON_Y, 0); + GuiTrigger trigN; + trigN.SetButtonOnlyTrigger(0, 0, 0); + + char spaceinfo[30]; + if (load_from_fs != PART_FS_WBFS) { + memset(spaceinfo, 0, 30); + } else { + if (!strcmp(Settings.db_language,"JA")) { + // needs to be "total...used" for Japanese + sprintf(spaceinfo,(mountMethod!=3?"%.2fGB %s %.2fGB %s":" "),(freespace+used),tr("of"),freespace,tr("free")); + } else { + sprintf(spaceinfo,(mountMethod!=3?"%.2fGB %s %.2fGB %s":" "),freespace,tr("of"),(freespace+used),tr("free")); + } + } + GuiText usedSpaceTxt(spaceinfo, 18, THEME.info); + usedSpaceTxt.SetAlignment(THEME.hddinfo_align, ALIGN_TOP); + usedSpaceTxt.SetPosition(THEME.hddinfo_x, THEME.hddinfo_y); + + char GamesCnt[15]; + sprintf(GamesCnt,"%s: %i",(mountMethod!=3?tr("Games"):tr("Channels")), gameCnt); + GuiText gamecntTxt(GamesCnt, 18, THEME.info); + + GuiButton gamecntBtn(100,18); + gamecntBtn.SetAlignment(THEME.gamecount_align, ALIGN_TOP); + gamecntBtn.SetPosition(THEME.gamecount_x,THEME.gamecount_y); + gamecntBtn.SetLabel(&gamecntTxt); + gamecntBtn.SetEffectGrow(); + if (mountMethod!=3)gamecntBtn.SetTrigger(&trigA); + + GuiTooltip installBtnTT(tr("Install a game")); + if (Settings.wsprompt == yes) + installBtnTT.SetWidescreen(CFG.widescreen); + installBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage installBtnImg(&btnInstall); + GuiImage installBtnImgOver(&btnInstallOver); + installBtnImg.SetWidescreen(CFG.widescreen); + installBtnImgOver.SetWidescreen(CFG.widescreen); + + GuiButton installBtn(&installBtnImg, &installBtnImgOver, ALIGN_LEFT, ALIGN_TOP, THEME.install_x, THEME.install_y, mountMethod!=3?&trigA:&trigN, &btnSoundOver, btnClick2, 1, &installBtnTT,24,-30, 0,5); + + + GuiTooltip settingsBtnTT(tr("Settings")); + if (Settings.wsprompt == yes) + settingsBtnTT.SetWidescreen(CFG.widescreen); + settingsBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage settingsBtnImg(&btnSettings); + settingsBtnImg.SetWidescreen(CFG.widescreen); + GuiImage settingsBtnImgOver(&btnSettingsOver); + settingsBtnImgOver.SetWidescreen(CFG.widescreen); + GuiButton settingsBtn(&settingsBtnImg,&settingsBtnImgOver, 0, 3, THEME.setting_x, THEME.setting_y, &trigA, &btnSoundOver, btnClick2,1,&settingsBtnTT,65,-30,0,5); + + GuiTooltip homeBtnTT(tr("Back to HBC or Wii Menu")); + if (Settings.wsprompt == yes) + homeBtnTT.SetWidescreen(CFG.widescreen); + settingsBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage homeBtnImg(&btnhome); + homeBtnImg.SetWidescreen(CFG.widescreen); + GuiImage homeBtnImgOver(&btnhomeOver); + homeBtnImgOver.SetWidescreen(CFG.widescreen); + GuiButton homeBtn(&homeBtnImg,&homeBtnImgOver, 0, 3, THEME.home_x, THEME.home_y, &trigA, &btnSoundOver, btnClick2,1,&homeBtnTT,15,-30,1,5); + homeBtn.RemoveSoundClick(); + homeBtn.SetTrigger(&trigHome); + + GuiTooltip poweroffBtnTT(tr("Power off the Wii")); + if (Settings.wsprompt == yes) + poweroffBtnTT.SetWidescreen(CFG.widescreen); + poweroffBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage poweroffBtnImg(&btnpwroff); + GuiImage poweroffBtnImgOver(&btnpwroffOver); + poweroffBtnImg.SetWidescreen(CFG.widescreen); + poweroffBtnImgOver.SetWidescreen(CFG.widescreen); + GuiButton poweroffBtn(&poweroffBtnImg,&poweroffBtnImgOver, 0, 3, THEME.power_x, THEME.power_y, &trigA, &btnSoundOver, btnClick2,1,&poweroffBtnTT,-10,-30,1,5); + + GuiTooltip sdcardBtnTT(tr("Reload SD")); + if (Settings.wsprompt == yes) + sdcardBtnTT.SetWidescreen(CFG.widescreen); + sdcardBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage sdcardImg(&btnsdcard); + GuiImage sdcardImgOver(&btnsdcardOver); + sdcardImg.SetWidescreen(CFG.widescreen); + sdcardImgOver.SetWidescreen(CFG.widescreen); + GuiButton sdcardBtn(&sdcardImg,&sdcardImgOver, 0, 3, THEME.sdcard_x, THEME.sdcard_y, &trigA, &btnSoundOver, btnClick2,1,&sdcardBtnTT,15,-30,0,5); + + GuiButton gameInfo(0,0); + gameInfo.SetTrigger(&trig2); + gameInfo.SetSoundClick(btnClick2); + + + GuiImage wiiBtnImg(&dataID); + wiiBtnImg.SetWidescreen(CFG.widescreen); + GuiButton wiiBtn(&wiiBtnImg,&wiiBtnImg, 0, 4, 0, -10, &trigA, &btnSoundOver, btnClick2,0); + + GuiTooltip favoriteBtnTT(tr("Display favorites")); + if (Settings.wsprompt == yes) + favoriteBtnTT.SetWidescreen(CFG.widescreen); + favoriteBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage favoriteBtnImg(&imgfavIcon); + favoriteBtnImg.SetWidescreen(CFG.widescreen); +// GuiImage favoriteBtnImg_g(favoriteBtnImg);favoriteBtnImg_g.SetGrayscale(); + GuiImage favoriteBtnImg_g(&imgfavIcon_gray); + if(favoriteBtnImg_g.GetImage() == NULL) { favoriteBtnImg_g = favoriteBtnImg; favoriteBtnImg_g.SetGrayscale();} + favoriteBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton favoriteBtn(&favoriteBtnImg_g,&favoriteBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_favorite_x, THEME.gamelist_favorite_y, mountMethod!=3?&trigA:&trigN, &btnSoundOver, btnClick2,1, &favoriteBtnTT, -15, 52, 0, 3); + favoriteBtn.SetAlpha(180); + + GuiTooltip searchBtnTT(tr("Set Search-Filter")); + if (Settings.wsprompt == yes) + searchBtnTT.SetWidescreen(CFG.widescreen); + searchBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage searchBtnImg(&imgsearchIcon); + searchBtnImg.SetWidescreen(CFG.widescreen); +// GuiImage searchBtnImg_g(searchBtnImg); searchBtnImg_g.SetGrayscale(); + GuiImage searchBtnImg_g(&imgsearchIcon_gray); + if(searchBtnImg_g.GetImage() == NULL) { searchBtnImg_g = searchBtnImg; searchBtnImg_g.SetGrayscale();} + searchBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton searchBtn(&searchBtnImg_g,&searchBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_search_x, THEME.gamelist_search_y, mountMethod!=3?&trigA:&trigN, &btnSoundOver, btnClick2,1, &searchBtnTT, -15, 52, 0, 3); + searchBtn.SetAlpha(180); + + GuiTooltip abcBtnTT(Settings.fave ? tr("Sort by rank") : tr("Sort alphabetically")); + if (Settings.wsprompt == yes) + abcBtnTT.SetWidescreen(CFG.widescreen); + abcBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage abcBtnImg(Settings.fave ? &imgrankIcon : &imgabcIcon); + abcBtnImg.SetWidescreen(CFG.widescreen); +// GuiImage abcBtnImg_g(abcBtnImg); abcBtnImg_g.SetGrayscale(); + GuiImage abcBtnImg_g(Settings.fave ? &imgrankIcon_gray : &imgabcIcon_gray); + if(abcBtnImg_g.GetImage() == NULL) { abcBtnImg_g = abcBtnImg; abcBtnImg_g.SetGrayscale();} + abcBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton abcBtn(&abcBtnImg_g,&abcBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_abc_x, THEME.gamelist_abc_y, &trigA, &btnSoundOver, btnClick2,1,&abcBtnTT, -15, 52, 0, 3); + abcBtn.SetAlpha(180); + + GuiTooltip countBtnTT(tr("Sort order by most played")); + if (Settings.wsprompt == yes) + countBtnTT.SetWidescreen(CFG.widescreen); + countBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage countBtnImg(&imgplayCountIcon); + countBtnImg.SetWidescreen(CFG.widescreen); +// GuiImage countBtnImg_g(countBtnImg); countBtnImg_g.SetGrayscale(); + GuiImage countBtnImg_g(&imgplayCountIcon_gray); + if(countBtnImg_g.GetImage() == NULL) { countBtnImg_g = countBtnImg; countBtnImg_g.SetGrayscale();} + countBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton countBtn(&countBtnImg_g,&countBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_count_x, THEME.gamelist_count_y, &trigA, &btnSoundOver, btnClick2,1, &countBtnTT, -15, 52, 0, 3); + countBtn.SetAlpha(180); + + GuiTooltip listBtnTT(tr("Display as a list")); + if (Settings.wsprompt == yes) + listBtnTT.SetWidescreen(CFG.widescreen); + listBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage listBtnImg(&imgarrangeList); + listBtnImg.SetWidescreen(CFG.widescreen); +// GuiImage listBtnImg_g(listBtnImg); listBtnImg_g.SetGrayscale(); + GuiImage listBtnImg_g(&imgarrangeList_gray); + if(listBtnImg_g.GetImage() == NULL) { listBtnImg_g = listBtnImg; listBtnImg_g.SetGrayscale();} + listBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton listBtn(&listBtnImg_g,&listBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_list_x, THEME.gamelist_list_y, mountMethod!=3?&trigA:&trigN, &btnSoundOver, btnClick2,1, &listBtnTT, 15, 52, 1, 3); + listBtn.SetAlpha(180); + + GuiTooltip gridBtnTT(tr("Display as a grid")); + if (Settings.wsprompt == yes) + gridBtnTT.SetWidescreen(CFG.widescreen); + gridBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage gridBtnImg(&imgarrangeGrid); + gridBtnImg.SetWidescreen(CFG.widescreen); +// GuiImage gridBtnImg_g(gridBtnImg); gridBtnImg_g.SetGrayscale(); + GuiImage gridBtnImg_g(&imgarrangeGrid_gray); + if(gridBtnImg_g.GetImage() == NULL) { gridBtnImg_g = gridBtnImg; gridBtnImg_g.SetGrayscale();} + gridBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton gridBtn(&gridBtnImg_g,&gridBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_grid_x, THEME.gamelist_grid_y, mountMethod!=3?&trigA:&trigN, &btnSoundOver, btnClick2,1, &gridBtnTT, 15, 52, 1, 3); + gridBtn.SetAlpha(180); + + GuiTooltip carouselBtnTT(tr("Display as a carousel")); + if (Settings.wsprompt == yes) + carouselBtnTT.SetWidescreen(CFG.widescreen); + carouselBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage carouselBtnImg(&imgarrangeCarousel); + carouselBtnImg.SetWidescreen(CFG.widescreen); +// GuiImage carouselBtnImg_g(carouselBtnImg); carouselBtnImg_g.SetGrayscale(); + GuiImage carouselBtnImg_g(&imgarrangeCarousel_gray); + if(carouselBtnImg_g.GetImage() == NULL) { carouselBtnImg_g = carouselBtnImg; carouselBtnImg_g.SetGrayscale();} + carouselBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton carouselBtn(&carouselBtnImg_g,&carouselBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_carousel_x, THEME.gamelist_carousel_y, mountMethod!=3?&trigA:&trigN, &btnSoundOver, btnClick2,1, &carouselBtnTT, 15, 52, 1, 3); + carouselBtn.SetAlpha(180); + + bool canUnlock = (Settings.parentalcontrol == 0 && Settings.parental.enabled == 1); + + GuiTooltip lockBtnTT(canUnlock ? tr("Unlock Parental Control") : tr("Parental Control disabled")); + if (Settings.wsprompt == yes) + lockBtnTT.SetWidescreen(CFG.widescreen); + lockBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage lockBtnImg(&imgLock); + lockBtnImg.SetWidescreen(CFG.widescreen); + GuiImage lockBtnImg_g(&imgLock_gray); + if(lockBtnImg_g.GetImage() == NULL) { lockBtnImg_g = lockBtnImg; lockBtnImg_g.SetGrayscale(); } + lockBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton lockBtn(&lockBtnImg_g, &lockBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_lock_x, THEME.gamelist_lock_y, &trigA, &btnSoundOver, btnClick2,1, &lockBtnTT, 15, 52, 1, 3); + lockBtn.SetAlpha(180); + + GuiTooltip unlockBtnTT(tr("Enable Parental Control")); + if (Settings.wsprompt == yes) + unlockBtnTT.SetWidescreen(CFG.widescreen); + unlockBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage unlockBtnImg(&imgUnlock); + unlockBtnImg.SetWidescreen(CFG.widescreen); + GuiImage unlockBtnImg_g(&imgUnlock_gray); + if(unlockBtnImg_g.GetImage() == NULL) { unlockBtnImg_g = unlockBtnImg; unlockBtnImg_g.SetGrayscale(); } + unlockBtnImg_g.SetWidescreen(CFG.widescreen); + + if (canUnlock && Settings.godmode) + { + lockBtn.SetImage(&unlockBtnImg_g); + lockBtn.SetImageOver(&unlockBtnImg_g); + lockBtn.SetToolTip(&unlockBtnTT, 15, 52, 1, 3); + } + +/* + GuiButton unlockBtn(&unlockBtnImg_g, &unlockBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_lock_x, THEME.gamelist_lock_y, &trigA, &btnSoundOver, btnClick2,1, &lockBtnTT, 15, 52, 1, 3); + unlockBtn.SetAlpha(180); +*/ + + GuiTooltip dvdBtnTT(tr("Mount DVD drive")); + if (Settings.wsprompt == yes) + dvdBtnTT.SetWidescreen(CFG.widescreen); + dvdBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage dvdBtnImg(&imgdvd); + dvdBtnImg.SetWidescreen(CFG.widescreen); + GuiImage dvdBtnImg_g(dvdBtnImg); //dvdBtnImg_g.SetGrayscale(); +// GuiImage carouselBtnImg_g(&imgarrangeCarousel_gray); + dvdBtnImg_g.SetWidescreen(CFG.widescreen); + GuiButton dvdBtn(&dvdBtnImg_g,&dvdBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_dvd_x, THEME.gamelist_dvd_y, &trigA, &btnSoundOver, btnClick2,1, &dvdBtnTT, 15, 52, 1, 3); + dvdBtn.SetAlpha(180); + + GuiTooltip homebrewBtnTT(tr("Homebrew Launcher")); + if (Settings.wsprompt == yes) + homebrewBtnTT.SetWidescreen(CFG.widescreen); + homebrewBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiImage homebrewImg(&homebrewImgData); + GuiImage homebrewImgOver(&homebrewImgDataOver); + homebrewImg.SetWidescreen(CFG.widescreen); + homebrewImgOver.SetWidescreen(CFG.widescreen); + GuiButton homebrewBtn(&homebrewImg,&homebrewImgOver, ALIGN_LEFT, ALIGN_TOP, THEME.homebrew_x, THEME.homebrew_y, &trigA, &btnSoundOver, btnClick2,1,&homebrewBtnTT,15,-30,1,5); + + if (Settings.fave) { + favoriteBtn.SetImage(&favoriteBtnImg); + favoriteBtn.SetImageOver(&favoriteBtnImg); + favoriteBtn.SetAlpha(255); + } + static bool show_searchwindow = false; + if(gameFilter && *gameFilter) + { + if(show_searchwindow && gameCnt==1) + show_searchwindow = false; + if(!show_searchwindow) + searchBtn.SetEffect(EFFECT_PULSE, 10, 105); + searchBtn.SetImage(&searchBtnImg); + searchBtn.SetImageOver(&searchBtnImg); + searchBtn.SetAlpha(255); + } + if (Settings.sort==all) { + abcBtn.SetImage(&abcBtnImg); + abcBtn.SetImageOver(&abcBtnImg); + abcBtn.SetAlpha(255); + } else if (Settings.sort==pcount) { + countBtn.SetImage(&countBtnImg); + countBtn.SetImageOver(&countBtnImg); + countBtn.SetAlpha(255); + } + if (Settings.gameDisplay==list || mountMethod == 3) { + listBtn.SetImage(&listBtnImg); + listBtn.SetImageOver(&listBtnImg); + listBtn.SetAlpha(255); + } else if (Settings.gameDisplay==grid) { + gridBtn.SetImage(&gridBtnImg); + gridBtn.SetImageOver(&gridBtnImg); + gridBtn.SetAlpha(255); + } else if (Settings.gameDisplay==carousel) { + carouselBtn.SetImage(&carouselBtnImg); + carouselBtn.SetImageOver(&carouselBtnImg); + carouselBtn.SetAlpha(255); + } + + if (Settings.gameDisplay==list|| mountMethod == 3) { + favoriteBtn.SetPosition(THEME.gamelist_favorite_x, THEME.gamelist_favorite_y); + searchBtn.SetPosition(THEME.gamelist_search_x, THEME.gamelist_search_y); + abcBtn.SetPosition(THEME.gamelist_abc_x, THEME.gamelist_abc_y); + countBtn.SetPosition(THEME.gamelist_count_x, THEME.gamelist_count_y); + listBtn.SetPosition(THEME.gamelist_list_x, THEME.gamelist_list_y); + gridBtn.SetPosition(THEME.gamelist_grid_x, THEME.gamelist_grid_y); + carouselBtn.SetPosition(THEME.gamelist_carousel_x, THEME.gamelist_carousel_y); + lockBtn.SetPosition(THEME.gamelist_lock_x, THEME.gamelist_lock_y); + dvdBtn.SetPosition(THEME.gamelist_dvd_x, THEME.gamelist_dvd_y); + } else if(Settings.gameDisplay==grid) { + favoriteBtn.SetPosition(THEME.gamegrid_favorite_x, THEME.gamegrid_favorite_y); + searchBtn.SetPosition(THEME.gamegrid_search_x, THEME.gamegrid_search_y); + abcBtn.SetPosition(THEME.gamegrid_abc_x, THEME.gamegrid_abc_y); + countBtn.SetPosition(THEME.gamegrid_count_x, THEME.gamegrid_count_y); + listBtn.SetPosition(THEME.gamegrid_list_x, THEME.gamegrid_list_y); + gridBtn.SetPosition(THEME.gamegrid_grid_x, THEME.gamegrid_grid_y); + carouselBtn.SetPosition(THEME.gamegrid_carousel_x, THEME.gamegrid_carousel_y); + lockBtn.SetPosition(THEME.gamegrid_lock_x, THEME.gamegrid_lock_y); + dvdBtn.SetPosition(THEME.gamegrid_dvd_x, THEME.gamegrid_dvd_y); + } else if(Settings.gameDisplay==carousel) { + favoriteBtn.SetPosition(THEME.gamecarousel_favorite_x, THEME.gamecarousel_favorite_y); + searchBtn.SetPosition(THEME.gamecarousel_search_x, THEME.gamecarousel_favorite_y); + abcBtn.SetPosition(THEME.gamecarousel_abc_x, THEME.gamecarousel_abc_y); + countBtn.SetPosition(THEME.gamecarousel_count_x, THEME.gamecarousel_count_y); + listBtn.SetPosition(THEME.gamecarousel_list_x, THEME.gamecarousel_list_y); + gridBtn.SetPosition(THEME.gamecarousel_grid_x, THEME.gamecarousel_grid_y); + carouselBtn.SetPosition(THEME.gamecarousel_carousel_x, THEME.gamecarousel_carousel_y); + lockBtn.SetPosition(THEME.gamecarousel_lock_x, THEME.gamecarousel_lock_y); + dvdBtn.SetPosition(THEME.gamecarousel_dvd_x, THEME.gamecarousel_dvd_y); + } + + + //Downloading Covers + GuiTooltip DownloadBtnTT(tr("Click to Download Covers")); + if (Settings.wsprompt == yes) + DownloadBtnTT.SetWidescreen(CFG.widescreen); + DownloadBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiButton DownloadBtn(0,0); + DownloadBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); + DownloadBtn.SetPosition(THEME.covers_x,THEME.covers_y); + + GuiTooltip IDBtnTT(tr("Click to change game ID")); + if (Settings.wsprompt == yes) + IDBtnTT.SetWidescreen(CFG.widescreen); + IDBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiButton idBtn(0,0); + idBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); + idBtn.SetPosition(THEME.id_x,THEME.id_y); + + if (Settings.godmode == 1 && mountMethod!=3) {//only make the button have trigger & tooltip if in godmode + DownloadBtn.SetSoundOver(&btnSoundOver); + DownloadBtn.SetTrigger(&trigA); + DownloadBtn.SetTrigger(&trig1); + DownloadBtn.SetToolTip(&DownloadBtnTT,205,-30); + + idBtn.SetSoundOver(&btnSoundOver); + idBtn.SetTrigger(&trigA); + idBtn.SetToolTip(&IDBtnTT,205,-30); + + } else + { + DownloadBtn.SetRumble(false); + idBtn.SetRumble(false); + } + + GuiGameBrowser * gameBrowser = NULL; + GuiGameGrid * gameGrid = NULL; + GuiGameCarousel * gameCarousel = NULL; + if (Settings.gameDisplay==list|| mountMethod == 3) { + gameBrowser = new GuiGameBrowser(THEME.gamelist_w, THEME.gamelist_h, gameList, gameCnt, CFG.theme_path, bg_options_png, startat, offset); + gameBrowser->SetPosition(THEME.gamelist_x, THEME.gamelist_y); + gameBrowser->SetAlignment(ALIGN_LEFT, ALIGN_CENTRE); + } else if (Settings.gameDisplay==grid) { + gameGrid = new GuiGameGrid(THEME.gamegrid_w,THEME.gamegrid_h, gameList, gameCnt, CFG.theme_path, bg_options_png, 0, 0); + gameGrid->SetPosition(THEME.gamegrid_x,THEME.gamegrid_y); + gameGrid->SetAlignment(ALIGN_LEFT, ALIGN_CENTRE); + } else if (Settings.gameDisplay==carousel) { + //GuiGameCarousel gameCarousel(THEME.gamecarousel_w, THEME.gamecarousel_h, gameList, gameCnt, CFG.theme_path, bg_options_png, startat, offset); + gameCarousel = new GuiGameCarousel(640, 400, gameList, gameCnt, CFG.theme_path, bg_options_png, startat, offset); + gameCarousel->SetPosition(THEME.gamecarousel_x,THEME.gamecarousel_y); + gameCarousel->SetAlignment(ALIGN_LEFT, ALIGN_CENTRE); + } + + GuiText clockTimeBack("88:88", 40, (GXColor) {THEME.clock.r, THEME.clock.g, THEME.clock.b, THEME.clock.a/6}); + clockTimeBack.SetAlignment(THEME.clock_align, ALIGN_TOP); + clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y); + clockTimeBack.SetFont(fontClock); + GuiText clockTime(theTime, 40, THEME.clock); + clockTime.SetAlignment(THEME.clock_align, ALIGN_TOP); + clockTime.SetPosition(THEME.clock_x, THEME.clock_y); + clockTime.SetFont(fontClock); + + HaltGui(); + GuiWindow w(screenwidth, screenheight); + + if (THEME.show_hddinfo == -1 || THEME.show_hddinfo == 1) { //force show hdd info + w.Append(&usedSpaceTxt); + } + if (THEME.show_gamecount == -1 || THEME.show_gamecount == 1) { //force show game cnt info + w.Append(&gamecntBtn); + } + w.Append(&sdcardBtn); + w.Append(&poweroffBtn); + w.Append(&gameInfo); + if (Settings.godmode && load_from_fs != PART_FS_NTFS) + w.Append(&installBtn); + w.Append(&homeBtn); + w.Append(&settingsBtn); + w.Append(&DownloadBtn); + w.Append(&idBtn); + + + // Begin Toolbar + w.Append(&favoriteBtn); + Toolbar[0] = &favoriteBtn; + w.Append(&searchBtn); + Toolbar[1] = &searchBtn; + w.Append(&abcBtn); + Toolbar[2] = &abcBtn; + w.Append(&countBtn); + Toolbar[3] = &countBtn; + w.Append(&listBtn); + Toolbar[4] = &listBtn; + w.Append(&gridBtn); + Toolbar[5] = &gridBtn; + w.Append(&carouselBtn); + Toolbar[6] = &carouselBtn; + w.Append(&lockBtn); + Toolbar[7] = &lockBtn; + w.Append(&dvdBtn); + Toolbar[8] = &dvdBtn; + w.SetUpdateCallback(DiscListWinUpdateCallback); + // End Toolbar + + + + if (Settings.godmode == 1) + w.Append(&homebrewBtn); + + if ((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) { + w.Append(&clockTimeBack); + w.Append(&clockTime); + } + + if (Settings.gameDisplay==list|| mountMethod == 3) { + mainWindow->Append(gameBrowser); + } + else if (Settings.gameDisplay==grid) { + mainWindow->Append(gameGrid); + } + else if (Settings.gameDisplay==carousel) { + mainWindow->Append(gameCarousel); + } + mainWindow->Append(&w); + + GuiSearchBar *searchBar=NULL; + if(show_searchwindow) { + searchBar = new GuiSearchBar(gameFilterNextList); + if(searchBar) + mainWindow->Append(searchBar); + } + + ResumeGui(); + +// ShowMemInfo(); + + while (menu == MENU_NONE) { + + if (idiotFlag==1) { + gprintf("\n\tIdiot flag"); + char idiotBuffer[200]; + snprintf(idiotBuffer, sizeof(idiotBuffer), "%s (%s). %s",tr("You have attempted to load a bad image"), + idiotChar,tr("Most likely it has dimensions that are not evenly divisible by 4.")); + + int deleteImg = WindowPrompt(0,idiotBuffer,tr("OK"),tr("Delete")); + if (deleteImg==0) { + snprintf(idiotBuffer, sizeof(idiotBuffer), "%s %s.",tr("You are about to delete "), idiotChar); + deleteImg = WindowPrompt(tr("Confirm"),idiotBuffer,tr("Delete"),tr("Cancel")); + if (deleteImg==1) { + remove(idiotChar); + } + } + idiotFlag=-1; + } + + WDVD_GetCoverStatus(&covert);//for detecting if i disc has been inserted + + // if the idiot is showing favorites and don't have any + if (Settings.fave && !gameCnt) { + WindowPrompt(tr("No Favorites"),tr("You are choosing to display favorites and you do not have any selected."),tr("Back")); + Settings.fave=!Settings.fave; + if (isInserted(bootDevice)) { + cfg_save_global(); + } + __Menu_GetEntries(); + menu = MENU_DISCLIST; + break; + } + + //CLOCK + time_t rawtime = time(0); //this fixes code dump caused by the clock + if (((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) && rawtime != lastrawtime) { + lastrawtime = rawtime; + timeinfo = localtime (&rawtime); + if (dataed < 1) { + if (Settings.hddinfo == hr12) { + if (rawtime & 1) + strftime(theTime, sizeof(theTime), "%I:%M", timeinfo); + else + strftime(theTime, sizeof(theTime), "%I %M", timeinfo); + } + if (Settings.hddinfo == hr24) { + if (rawtime & 1) + strftime(theTime, sizeof(theTime), "%H:%M", timeinfo); + else + strftime(theTime, sizeof(theTime), "%H %M", timeinfo); + } + clockTime.SetText(theTime); + + } else if (dataed > 0) { + + clockTime.SetTextf("%i", (dataed-1)); + } + + } + + if ((datagB<1)&&(Settings.cios==1)&&(Settings.video == ntsc)&&(Settings.hddinfo == hr12)&&(Settings.qboot==1)&&(Settings.wsprompt==0)&&(Settings.language==ger)&&(Settings.tooltips==0)){dataed=1;dataef=1;}if (dataef==1){if (cosa>7){cosa=1;}datag++;if (sina==3){wiiBtn.SetAlignment(ALIGN_LEFT,ALIGN_BOTTOM);wiiBtnImg.SetAngle(0);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((cosa)*70),(-2*(datag)+120));}else if(62<=datag){wiiBtn.SetPosition(((cosa)*70),((datag*2)-130));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==2){wiiBtn.SetAlignment(ALIGN_RIGHT,ALIGN_TOP);wiiBtnImg.SetAngle(270);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((-2*(datag)+130)),((cosa)*50));}else if(62<=datag){wiiBtn.SetPosition((2*(datag)-120),((cosa)*50));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==1){wiiBtn.SetAlignment(ALIGN_TOP,ALIGN_LEFT);wiiBtnImg.SetAngle(180);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((cosa)*70),(2*(datag)-120));}else if(62<=datag){wiiBtn.SetPosition(((cosa)*70),(-2*(datag)+130));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==0){wiiBtn.SetAlignment(ALIGN_TOP,ALIGN_LEFT);wiiBtnImg.SetAngle(90);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((2*(datag)-130)),((cosa)*50));}else if(62<=datag){wiiBtn.SetPosition((-2*(datag)+120),((cosa)*50));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}} + // respond to button presses + /* if (shutdown == 1) { + gprintf("\n\tshutdown"); + Sys_Shutdown(); + } + if (reset == 1) + Sys_Reboot();*/ + + if (updateavailable == true) { + gprintf("\n\tUpdate Available"); + HaltGui(); + GuiWindow ww(640,480); + w.SetState(STATE_DISABLED); + mainWindow->Append(&ww); + ResumeGui(); + ProgressUpdateWindow(); + updateavailable = false; + mainWindow->Remove(&ww); + w.SetState(STATE_DEFAULT); + menu = MENU_DISCLIST; + } + + if (poweroffBtn.GetState() == STATE_CLICKED) { + + + gprintf("\n\tpoweroffBtn clicked"); + choice = WindowPrompt(tr("How to Shutdown?"),0,tr("Full Shutdown"), tr("Shutdown to Idle"), tr("Cancel")); + if (choice == 2) { + Sys_ShutdownToIdel(); + } else if (choice == 1) { + Sys_ShutdownToStandby(); + } else { + poweroffBtn.ResetState(); + if (Settings.gameDisplay==list|| mountMethod == 3) { + gameBrowser->SetFocus(1); + } else if (Settings.gameDisplay==grid) { + gameGrid->SetFocus(1); + } else if (Settings.gameDisplay==carousel) { + gameCarousel->SetFocus(1); + } + } + + } else if (gamecntBtn.GetState() == STATE_CLICKED && mountMethod!=3) { + gprintf("\n\tgameCntBtn clicked"); + gamecntBtn.ResetState(); + char linebuf[150]; + snprintf(linebuf, sizeof(linebuf), "%s %sGameList ?",tr("Save Game List to"), Settings.update_path); + choice = WindowPrompt(0,linebuf,"TXT","CSV",tr("Back")); + if (choice) { + if (save_gamelist(choice-1)) + WindowPrompt(0,tr("Saved"),tr("OK")); + else + WindowPrompt(tr("Error"),tr("Could not save."),tr("OK")); + } + menu = MENU_DISCLIST; + break; + + } else if (homeBtn.GetState() == STATE_CLICKED) { + gprintf("\n\thomeBtn clicked"); + bgMusic->Pause(); + choice = WindowExitPrompt(); + bgMusic->Resume(); + + if (choice == 3) { + Sys_LoadMenu(); // Back to System Menu + } else if (choice == 2) { + Sys_BackToLoader(); + } else { + homeBtn.ResetState(); + if (Settings.gameDisplay==list|| mountMethod == 3) { + gameBrowser->SetFocus(1); + } else if (Settings.gameDisplay==grid) { + gameGrid->SetFocus(1); + } else if (Settings.gameDisplay==carousel) { + gameCarousel->SetFocus(1); + } + } + + } else if (wiiBtn.GetState() == STATE_CLICKED) { + gprintf("\n\twiiBtn clicked"); + + dataed++; + wiiBtn.ResetState(); + if (Settings.gameDisplay==list|| mountMethod == 3) { + gameBrowser->SetFocus(1); + } else if (Settings.gameDisplay==grid) { + gameGrid->SetFocus(1); + } else if (Settings.gameDisplay==carousel) { + gameCarousel->SetFocus(1); + } + } else if (installBtn.GetState() == STATE_CLICKED) { + gprintf("\n\tinstallBtn clicked"); + choice = WindowPrompt(tr("Install a game"),0,tr("Yes"),tr("No")); + if (choice == 1) { + menu = MENU_INSTALL; + break; + } else { + installBtn.ResetState(); + if (Settings.gameDisplay==list|| mountMethod == 3) { + gameBrowser->SetFocus(1); + } else if (Settings.gameDisplay==grid) { + gameGrid->SetFocus(1); + } else if (Settings.gameDisplay==carousel) { + gameCarousel->SetFocus(1); + } + } + } + else if (dvdBtn.GetState() == STATE_CLICKED) { + gprintf("\n\tdvdBtn Clicked"); + + mountMethodOLD = (mountMethod==3?mountMethod:0); + + int ass =DiscMount(dvdheader); + if (ass>0)mountMethod=ass; + gprintf("\n\tmountMethod:%d",mountMethod); + //dvdBtn.ResetState(); + + covertOld =2; + rockout(); + //break; + } + else if ((covert & 0x2)&&(covert!=covertOld)&& mountMethod!=1 && mountMethod!=2) { + + //gprintf("\n\tNew Disc Detected mountMethod:%d covert:%d old:%d",mountMethod,covert,covertOld); + if(!mountMethod) + choice = WindowPrompt(tr("New Disc Detected"),0,tr("Install"),tr("Mount DVD drive"),tr("Cancel")); + if (choice == 1) { + if (load_from_fs == PART_FS_NTFS) { + WindowPrompt(tr("Install not possible"), tr("You are using NTFS filesystem. Due to possible write errors to a NTFS partition, installing a game is not possible."), tr("OK")); + } else { + menu = MENU_INSTALL; + break; + } + } + else if (choice ==2 || mountMethod==3) + { + dvdBtn.SetState(STATE_CLICKED); + }else { + if (Settings.gameDisplay==list|| mountMethod == 3) { + gameBrowser->SetFocus(1); + } else if (Settings.gameDisplay==grid) { + gameGrid->SetFocus(1); + } else if (Settings.gameDisplay==carousel) { + gameCarousel->SetFocus(1); + } + } + + } + + else if (sdcardBtn.GetState() == STATE_CLICKED) { + gprintf("\n\tsdCardBtn Clicked"); + SDCard_deInit(); + SDCard_Init(); + if (Settings.gameDisplay==list|| mountMethod == 3) { + startat = gameBrowser->GetSelectedOption(); + offset = gameBrowser->GetOffset(); + } else if (Settings.gameDisplay==grid) { + startat = gameGrid->GetSelectedOption(); + offset = gameGrid->GetOffset(); + } else if (Settings.gameDisplay==carousel) { + startat = gameCarousel->GetSelectedOption(); + offset = gameCarousel->GetOffset(); + } + if (isInserted(bootDevice)) { + HaltGui(); // to fix endless rumble when clicking on the SD icon when rumble is disabled because rumble is set to on in Global_Default() + CFG_Load(); + ResumeGui(); + } + sdcardBtn.ResetState(); + menu = MENU_DISCLIST; + break; + } + + else if (DownloadBtn.GetState() == STATE_CLICKED) { + gprintf("\n\tDownloadBtn Clicked"); + if (isInserted(bootDevice)) { + choice = WindowPrompt(tr("Cover Download"), 0, tr("Normal Covers"), tr("3D Covers"), tr("Disc Images"), tr("Back")); // ask for download choice + if (choice != 0) { + int choice2 = choice; + bool missing; + missing = SearchMissingImages(choice2); + if (IsNetworkInit() == false && missing == true) { + WindowPrompt(tr("Network init error"), 0, tr("OK")); + } else { + if (GetMissingFiles() != NULL && cntMissFiles > 0) { + char tempCnt[40]; + sprintf(tempCnt,"%i %s",cntMissFiles,tr("Missing files")); + if (choice!=3)choice = WindowPrompt(tr("Download Boxart image?"),tempCnt,tr("Yes"),tr("No")); + else if (choice==3)choice = WindowPrompt(tr("Download Discart image?"),tempCnt,tr("Yes"),tr("No")); + if (choice == 1) { + ret = ProgressDownloadWindow(choice2); + if (ret == 0) { + WindowPrompt(tr("Download finished"),0,tr("OK")); + } else { + sprintf(tempCnt,"%i %s",ret,tr("files not found on the server!")); + WindowPrompt(tr("Download finished"),tempCnt,tr("OK")); + } + } + } + } + } + } else { + WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to download images."), tr("OK")); + } + if (choice)menu = MENU_DISCLIST; + DownloadBtn.ResetState(); + if (Settings.gameDisplay==list|| mountMethod == 3) { + gameBrowser->SetFocus(1); + } else if (Settings.gameDisplay==grid) { + gameGrid->SetFocus(1); + } else if (Settings.gameDisplay==carousel) { + gameCarousel->SetFocus(1); + } + }//end download + + else if (settingsBtn.GetState() == STATE_CLICKED) { + gprintf("\n\tsettingsBtn Clicked"); + if (Settings.gameDisplay==list|| mountMethod == 3) { + startat = gameBrowser->GetSelectedOption(); + offset = gameBrowser->GetOffset(); + } else if (Settings.gameDisplay==grid) { + startat = gameGrid->GetSelectedOption(); + offset = gameGrid->GetOffset(); + } else if (Settings.gameDisplay==carousel) { + startat = gameCarousel->GetSelectedOption(); + offset = gameCarousel->GetOffset(); + } + menu = MENU_SETTINGS; + break; + + } + + else if (favoriteBtn.GetState() == STATE_CLICKED) { + gprintf("\n\tfavoriteBtn Clicked"); + Settings.fave=!Settings.fave; + if (isInserted(bootDevice)) { + cfg_save_global(); + } + __Menu_GetEntries(); + menu = MENU_DISCLIST; + break; + + } + + else if (searchBtn.GetState() == STATE_CLICKED) { + + gprintf("\n\tsearchBtn Clicked"); + show_searchwindow=!show_searchwindow; + HaltGui(); + if(searchBar) + { + mainWindow->Remove(searchBar); + delete searchBar; + searchBar = NULL; + } + if(show_searchwindow) + { + if(gameFilter && *gameFilter) + { + searchBtn.StopEffect(); + searchBtn.SetEffectGrow(); + } + searchBar = new GuiSearchBar(gameFilterNextList); + if(searchBar) + mainWindow->Append(searchBar); + } + else + { + if(gameFilter && *gameFilter) + searchBtn.SetEffect(EFFECT_PULSE, 10, 105); + } + searchBtn.ResetState(); + ResumeGui(); + } + + else if (searchBar && (searchChar=searchBar->GetClicked())) { + if(searchChar > 27) + { + int len = gameFilter ? wcslen(gameFilter) : 0; + wchar_t newFilter[len+2]; + if(gameFilter) + wcscpy(newFilter, gameFilter); + newFilter[len] = searchChar; + newFilter[len+1] = 0; + + + __Menu_GetEntries(0, newFilter); + menu = MENU_DISCLIST; + break; + } + else if(searchChar == 7) // Close + { + show_searchwindow=false; + HaltGui(); + if(searchBar) + { + mainWindow->Remove(searchBar); + delete searchBar; + searchBar = NULL; + } + if(gameFilter && *gameFilter) + { + searchBtn.SetEffect(EFFECT_PULSE, 10, 105); + searchBtn.SetImage(&searchBtnImg); + searchBtn.SetImageOver(&searchBtnImg); + searchBtn.SetAlpha(255); + } + else + { + searchBtn.StopEffect(); + searchBtn.SetEffectGrow(); + searchBtn.SetImage(&searchBtnImg_g); + searchBtn.SetImageOver(&searchBtnImg_g); + searchBtn.SetAlpha(180); + } + + ResumeGui(); + } + else if(searchChar == 8) // Backspace + { + __Menu_GetEntries(0, gameFilterPrev); + menu = MENU_DISCLIST; + break; + } + + } + + else if (abcBtn.GetState() == STATE_CLICKED) { + gprintf("\n\tabcBtn clicked"); + if (Settings.sort != all) { + Settings.sort=all; + if (isInserted(bootDevice)) { + cfg_save_global(); + } + __Menu_GetEntries(); + + menu = MENU_DISCLIST; + break; + } + abcBtn.ResetState(); + } + + else if (countBtn.GetState() == STATE_CLICKED) { + gprintf("\n\tcountBtn Clicked"); + if (Settings.sort != pcount) { + Settings.sort=pcount; + //if(isSdInserted()) { + if (isInserted(bootDevice)) { + cfg_save_global(); + } + __Menu_GetEntries(); + + menu = MENU_DISCLIST; + break; + } + countBtn.ResetState(); + + } + + else if (listBtn.GetState() == STATE_CLICKED) { + gprintf("\n\tlistBtn Clicked"); + if (Settings.gameDisplay!=list) { + Settings.gameDisplay=list; + menu = MENU_DISCLIST; + if (isInserted(bootDevice)) { + cfg_save_global(); + } + listBtn.ResetState(); + break; + } else { + listBtn.ResetState(); + } + } + + + else if (gridBtn.GetState() == STATE_CLICKED) { + gprintf("\n\tgridBtn Clicked"); + if (Settings.gameDisplay!=grid) { + + Settings.gameDisplay=grid; + menu = MENU_DISCLIST; + if (isInserted(bootDevice)) { + cfg_save_global(); + } + gridBtn.ResetState(); + break; + } else { + gridBtn.ResetState(); + } + } + + else if (carouselBtn.GetState() == STATE_CLICKED) { + gprintf("\n\tcarouselBtn Clicked"); + if (Settings.gameDisplay!=carousel) { + Settings.gameDisplay=carousel; + menu = MENU_DISCLIST; + if (isInserted(bootDevice)) { + cfg_save_global(); + } + carouselBtn.ResetState(); + break; + } else { + carouselBtn.ResetState(); + } + } + else if (homebrewBtn.GetState() == STATE_CLICKED) { + gprintf("\n\thomebrewBtn Clicked"); + menu = MENU_HOMEBREWBROWSE; + break; + } + else if (gameInfo.GetState() == STATE_CLICKED && mountMethod!=3) { + gprintf("\n\tgameinfo Clicked"); + gameInfo.ResetState(); + if(selectImg1>=0 && selectImg1<(s32)gameCnt) { + gameSelected = selectImg1; + rockout(); + struct discHdr *header = &gameList[selectImg1]; + snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); + choice = showGameInfo(IDfull); + rockout(2); + if (choice==2) + homeBtn.SetState(STATE_CLICKED); + if (choice==3) { + menu = MENU_DISCLIST; + break; + } + } + } + else if (lockBtn.GetState() == STATE_CLICKED) { + gprintf("\n\tlockBtn clicked"); + lockBtn.ResetState(); + if (!canUnlock) { + WindowPrompt(tr("Parental Control"), tr("You don't have Parental Control enabled. If you wish to use Parental Control, enable it in the Wii Settings."), tr("OK")); + } else { + if (Settings.godmode) { + if (WindowPrompt(tr("Parental Control"), tr("Are you sure you want to enable Parent Control?"), tr("Yes"), tr("No")) == 1) { + Settings.godmode = 0; + lockBtn.SetImage(&lockBtnImg_g); + lockBtn.SetImageOver(&lockBtnImg_g); + lockBtn.SetToolTip(&lockBtnTT, 15, 52, 1, 3); + + // Retrieve the gamelist again + menu = MENU_DISCLIST; + break; + } + } else { + // Require the user to enter the PIN code + char pin[5]; + memset(&pin, 0, 5); + int ret = OnScreenNumpad((char *) &pin, 5); + + if (ret == 1) { + if (memcmp(pin, Settings.parental.pin, 4) == 0) { + Settings.godmode = 1; + lockBtn.SetImage(&unlockBtnImg_g); + lockBtn.SetImageOver(&unlockBtnImg_g); + lockBtn.SetToolTip(&unlockBtnTT, 15, 52, 1, 3); + + // Retrieve the gamelist again + menu = MENU_DISCLIST; + break; + } else { + WindowPrompt(tr("Parental Control"), tr("Invalid PIN code"), tr("OK")); + } + } + } + } + } + + if (Settings.gameDisplay==grid && mountMethod != 3) { + int selectimg; + DownloadBtn.SetSize(0,0); + selectimg = gameGrid->GetSelectedOption(); + gameSelected = gameGrid->GetClickedOption(); + selectImg1=selectimg; + } + + else if (Settings.gameDisplay==carousel && mountMethod != 3) { + int selectimg; + DownloadBtn.SetSize(0,0); + selectimg = gameCarousel->GetSelectedOption(); + gameSelected = gameCarousel->GetClickedOption(); + selectImg1=selectimg; + } + else if (Settings.gameDisplay==list || mountMethod == 3) { + //Get selected game under cursor + int selectimg; + DownloadBtn.SetSize(160,224); + idBtn.SetSize(100,40); + + selectimg = gameBrowser->GetSelectedOption(); + gameSelected = gameBrowser->GetClickedOption(); + selectImg1=selectimg; + + if (gameSelected > 0) //if click occured + selectimg = gameSelected; + + char gameregion[7]; + if ((selectimg >= 0) && (selectimg < (s32) gameCnt)) { + if (selectimg != selectedold) { + selectedold = selectimg;//update displayed cover, game ID, and region if the selected game changes + struct discHdr *header = &gameList[selectimg]; + snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]); + snprintf (IDfull,sizeof(IDfull),"%s%c%c%c", ID, header->id[3], header->id[4], header->id[5]); + w.Remove(&DownloadBtn); + + if (GameIDTxt) { + w.Remove(&idBtn); + delete GameIDTxt; + GameIDTxt = NULL; + } + if (GameRegionTxt) { + w.Remove(GameRegionTxt); + delete GameRegionTxt; + GameRegionTxt = NULL; + } + + switch (header->id[3]) { + case 'E': + sprintf(gameregion,"NTSC U"); + break; + case 'J': + sprintf(gameregion,"NTSC J"); + break; + case 'W': + sprintf(gameregion,"NTSC T"); + break; + default: + case 'K': + sprintf(gameregion,"NTSC K"); + break; + case 'P': + case 'D': + case 'F': + case 'I': + case 'S': + case 'H': + case 'U': + case 'X': + case 'Y': + case 'Z': + sprintf(gameregion," PAL "); + break; + } + + //load game cover + if (cover) { + delete cover; + cover = NULL; + } + + cover = LoadCoverImage(header); + + if (coverImg) { + delete coverImg; + coverImg = NULL; + } + coverImg = new GuiImage(cover); + coverImg->SetWidescreen(CFG.widescreen); + + DownloadBtn.SetImage(coverImg);// put the new image on the download button + w.Append(&DownloadBtn); + + if ((Settings.sinfo == GameID) || (Settings.sinfo == Both)) { + GameIDTxt = new GuiText(IDfull, 22, THEME.info); + GameIDTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + //GameIDTxt->SetPosition(THEME.id_x,THEME.id_y); + idBtn.SetEffect(EFFECT_FADE, 20); + idBtn.SetLabel(GameIDTxt); + w.Append(&idBtn); + } + //don't try to show region for channels because all the custom channels wont follow the rules + if (((Settings.sinfo == GameRegion) || (Settings.sinfo == Both))&&mountMethod!=3) { + GameRegionTxt = new GuiText(gameregion, 22, THEME.info); + GameRegionTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + GameRegionTxt->SetPosition(THEME.region_x, THEME.region_y); + GameRegionTxt->SetEffect(EFFECT_FADE, 20); + w.Append(GameRegionTxt); + } + } + } + + if (idBtn.GetState() == STATE_CLICKED && mountMethod!=3) { + gprintf("\n\tidBtn Clicked"); + struct discHdr * header = &gameList[gameBrowser->GetSelectedOption()]; + //enter new game ID + char entered[10]; + snprintf(entered, sizeof(entered), "%s", IDfull); + //entered[9] = '\0'; + int result = OnScreenKeyboard(entered, 7,0); + if (result == 1) { + WBFS_ReIDGame(header->id, entered); + //__Menu_GetEntries(); + menu = MENU_DISCLIST; + } + + idBtn.ResetState(); + } + startat=gameBrowser->GetOffset(), offset=startat; + } + + if (((gameSelected >= 0) && (gameSelected < (s32)gameCnt)) + || mountMethod==1 + || mountMethod==2) { + if(searchBar) + { + HaltGui(); + mainWindow->Remove(searchBar); + ResumeGui(); + } + rockout(); + struct discHdr *header = (mountMethod==1||mountMethod==2?dvdheader:&gameList[gameSelected]); + // struct discHdr *header = dvdheader:&gameList[gameSelected]); + if (!mountMethod)//only get this stuff it we are booting a game from USB + { + WBFS_GameSize(header->id, &size); + if (strlen(get_title(header)) < (MAX_CHARACTERS + 3)) { + sprintf(text, "%s", get_title(header)); + } else { + strncpy(text, get_title(header), MAX_CHARACTERS); + text[MAX_CHARACTERS] = '\0'; + strncat(text, "...", 3); + } + } + + //check if alt Dol and gct file is present + FILE *exeFile = NULL; + char nipple[100]; + header = (mountMethod==1||mountMethod==2?dvdheader:&gameList[gameSelected]); //reset header + snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); + struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); + + if (game_cfg) { + alternatedol = game_cfg->loadalternatedol; + ocarinaChoice = game_cfg->ocarina; + } else { + alternatedol = off; + ocarinaChoice = Settings.ocarina; + } + + + if (Settings.qboot == yes) { //quickboot game + if (alternatedol == on) { + /* Open dol File and check exist */ + sprintf(nipple, "%s%s.dol",Settings.dolpath,IDfull); + exeFile = fopen (nipple ,"rb"); + if (exeFile==NULL) { + sprintf(nipple, "%s %s",nipple,tr("does not exist!")); + WindowPrompt(tr("Error"),nipple,tr("OK")); + menu = MENU_CHECK; + wiilight(0); + break; + } else { + fclose(exeFile); + } + } + if (ocarinaChoice != off) { + /* Open gct File and check exist */ + sprintf(nipple, "%s%s.gct",Settings.Cheatcodespath,IDfull); + exeFile = fopen (nipple ,"rb"); + if (exeFile==NULL) { + gprintf("\n\ttried to load missing gct."); + sprintf(nipple, "%s %s",nipple,tr("does not exist! Loading game without cheats.")); + WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170); + } else { + fseek (exeFile, 0, SEEK_END); + long size=ftell (exeFile); + rewind (exeFile); + fclose(exeFile); + if (size>MAX_GCT_SIZE) { + gprintf("\n\tgct is too big"); + sprintf(nipple, "%s %s",nipple,tr("contains over 255 lines of code. It will produce unexpected results.")); + WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170); + } + } + + } + + wiilight(0); + if (isInserted(bootDevice)) { + //////////save game play count//////////////// + struct Game_NUM* game_num = CFG_get_game_num(header->id); + + if (game_num) { + favoritevar = game_num->favorite; + playcount = game_num->count; + } else { + favoritevar = 0; + playcount = 0; + } + playcount += 1; + + CFG_save_game_num(header->id); + gprintf("\n\tplaycount for %c%c%c%c%c%c raised to %i",header->id[0],header->id[1],header->id[2],header->id[3],header->id[4],header->id[5],playcount); + + } + menu = MENU_EXIT; + break; + + } + bool returnHere = true;// prompt to start game + while (returnHere) { + returnHere = false; + if (Settings.wiilight != wiilight_forInstall) wiilight(1); + choice = GameWindowPrompt(); + // header = &gameList[gameSelected]; //reset header + + if (choice == 1) { + if (alternatedol == on) { + /* Open dol File and check exist */ + sprintf(nipple, "%s%s.dol",Settings.dolpath,IDfull); + exeFile = fopen (nipple ,"rb"); + if (exeFile==NULL) { + gprintf("\n\tTried to load alt dol that isn't there"); + sprintf(nipple, "%s %s",nipple,tr("does not exist! You Messed something up, Idiot.")); + WindowPrompt(tr("Error"),nipple,tr("OK")); + menu = MENU_CHECK; + wiilight(0); + break; + } else { + fclose(exeFile); + } + } + if (ocarinaChoice != off) { + /* Open gct File and check exist */ + sprintf(nipple, "%s%s.gct",Settings.Cheatcodespath,IDfull); + exeFile = fopen (nipple ,"rb"); + if (exeFile==NULL) { + gprintf("\n\ttried to load gct file that isn't there"); + sprintf(nipple, "%s %s",nipple,tr("does not exist! Loading game without cheats.")); + WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170); + } else { + fseek (exeFile, 0, SEEK_END); + long size=ftell (exeFile); + rewind (exeFile); + fclose(exeFile); + if (size>MAX_GCT_SIZE) { + gprintf("\n\tgct file is too big"); + sprintf(nipple, "%s %s",nipple,tr("contains over 255 lines of code. It will produce unexpected results.")); + WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170); + } + } + + } + wiilight(0); + returnHere = false; + menu = MENU_EXIT; + + } else if (choice == 2) { + wiilight(0); + HaltGui(); + if (Settings.gameDisplay==list || mountMethod == 3) mainWindow->Remove(gameBrowser); + else if (Settings.gameDisplay==grid) mainWindow->Remove(gameGrid); + else if (Settings.gameDisplay==carousel) mainWindow->Remove(gameCarousel); + mainWindow->Remove(&w); + ResumeGui(); + + //re-evaluate header now in case they changed games while on the game prompt + header = (mountMethod==1||mountMethod==2?dvdheader:&gameList[gameSelected]); + int settret = GameSettings(header); + /* unneeded for now, kept in case database gets a separate language setting + //menu = MENU_DISCLIST; // refresh titles (needed if the language setting has changed) + */ + HaltGui(); + if (Settings.gameDisplay==list || mountMethod == 3) mainWindow->Append(gameBrowser); + else if (Settings.gameDisplay==grid) mainWindow->Append(gameGrid); + else if (Settings.gameDisplay==carousel) mainWindow->Append(gameCarousel); + mainWindow->Append(&w); + ResumeGui(); + if (settret == 1) { //if deleted + menu = MENU_DISCLIST; + break; + } + returnHere = true; + rockout(2); + } + + else if (choice == 3 && !mountMethod) { //WBFS renaming + wiilight(0); + //re-evaluate header now in case they changed games while on the game prompt + header = &gameList[gameSelected]; + + //enter new game title + char entered[60]; + snprintf(entered, sizeof(entered), "%s", get_title(header)); + entered[59] = '\0'; + int result = OnScreenKeyboard(entered, 60,0); + if (result == 1) { + WBFS_RenameGame(header->id, entered); + __Menu_GetEntries(); + menu = MENU_DISCLIST; + } + } else if (choice == 0) { + rockout(2); + if (mountMethod==1||mountMethod==2)mountMethod = mountMethodOLD; + if (Settings.gameDisplay==list || mountMethod == 3) { + gameBrowser->SetFocus(1); + } else if (Settings.gameDisplay==grid) { + gameGrid->SetFocus(1); + } else if (Settings.gameDisplay==carousel) { + gameCarousel->SetFocus(1); + } + } + + + } + if(searchBar) + { + HaltGui(); + mainWindow->Append(searchBar); + ResumeGui(); + } + } + // to skip the first call of windowScreensaver at startup when wiimote is not connected + if (IsWpadConnected()) { + check = 1; + } + + // screensaver is called when wiimote shuts down, depending on the wiimotet idletime + if (!IsWpadConnected() && check !=0 && Settings.screensaver!=0) { + check++; + int screensaverIsOn=0; + if (check==11500) { //to allow time for the wii to turn off and not show the screensaver + screensaverIsOn=WindowScreensaver(); + } + if (screensaverIsOn==1)check=0; + } + if (dvdBtn.GetState() != STATE_CLICKED) + covertOld=covert; + else + dvdBtn.ResetState(); + //respond to the checkthread and unpause it + switch(checkthreadState) + { + case 1: + mountMethod = 0; + menu = MENU_DISCLIST; + checkthreadState = 0; + gprintf("\ncase 1"); + break; + + case 2: + sdcardBtn.SetState(STATE_CLICKED); + checkthreadState = 0; + gprintf("\ncase 2"); + break; + } + } + + // set alt dol default + if (menu == MENU_EXIT && altdoldefault && mountMethod!=3) { + struct discHdr *header = (mountMethod==1||mountMethod==2?dvdheader:&gameList[gameSelected]); + struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); + // use default only if no alt dol was selected manually + if (game_cfg) { + if (game_cfg->alternatedolstart != 0) + altdoldefault = false; + } + if (altdoldefault) { + int autodol = autoSelectDol((char*)header->id, true); + if (autodol>0) { + alternatedol = 2; + alternatedoloffset = autodol; + char temp[20]; + sprintf(temp,"%d",autodol); + } else { + // alt dol menu for games that require more than a single alt dol + int autodol = autoSelectDolMenu((char*)header->id, true); + if (autodol>0) { + alternatedol = 2; + alternatedoloffset = autodol; + } + } + } + } +//no need to close sd here. we still need to get settings and codes and shit + /*if (menu == MENU_EXIT) { + SDCard_deInit(); + }*/ + //if (Settings.gameDisplay==list) {startat=gameBrowser->GetOffset(), offset=startat;}//save the variables in case we are refreshing the list + //gprintf("\n\tstartat:%d offset:%d",startat,offset); + HaltGui(); + mainWindow->RemoveAll(); + mainWindow->Append(bgImg); + delete searchBar; + searchBar = NULL; + delete gameBrowser; + gameBrowser = NULL; + delete gameGrid; + gameGrid = NULL; + delete gameCarousel; + gameCarousel = NULL; + ResumeGui(); + return menu; +} + +void DiscListWinUpdateCallback(void * e) +{ + GuiWindow *w = (GuiWindow *)e; + for(int i=0; i<8; ++i) + { + if(Toolbar[i]->GetState() == STATE_SELECTED) + { + w->Remove(Toolbar[i]); + w->Append(Toolbar[i]); // draw the selected Icon allways on top + break; + } + } +} + +void rockout(int f) { + + + HaltGui(); + int num=(f==2?-1:gameSelected); + + char imgPath[100]; + if ((!(strcasestr(get_title(&gameList[num]),"guitar")|| + strcasestr(get_title(&gameList[num]),"band")|| + strcasestr(get_title(&gameList[num]),"rock")|| + f==1))||mountMethod) { + for (int i = 0; i < 4; i++) + delete pointer[i]; + snprintf(imgPath, sizeof(imgPath), "%splayer1_point.png", CFG.theme_path); + pointer[0] = new GuiImageData(imgPath, player1_point_png); + snprintf(imgPath, sizeof(imgPath), "%splayer2_point.png", CFG.theme_path); + pointer[1] = new GuiImageData(imgPath, player2_point_png); + snprintf(imgPath, sizeof(imgPath), "%splayer3_point.png", CFG.theme_path); + pointer[2] = new GuiImageData(imgPath, player3_point_png); + snprintf(imgPath, sizeof(imgPath), "%splayer4_point.png", CFG.theme_path); + pointer[3] = new GuiImageData(imgPath, player4_point_png); + } else { + + for (int i = 0; i < 4; i++) + delete pointer[i]; + snprintf(imgPath, sizeof(imgPath), "%srplayer1_point.png", CFG.theme_path); + pointer[0] = new GuiImageData(imgPath, rplayer1_point_png); + snprintf(imgPath, sizeof(imgPath), "%srplayer2_point.png", CFG.theme_path); + pointer[1] = new GuiImageData(imgPath, rplayer2_point_png); + snprintf(imgPath, sizeof(imgPath), "%srplayer3_point.png", CFG.theme_path); + pointer[2] = new GuiImageData(imgPath, rplayer3_point_png); + snprintf(imgPath, sizeof(imgPath), "%srplayer4_point.png", CFG.theme_path); + pointer[3] = new GuiImageData(imgPath, rplayer4_point_png); + } + ResumeGui(); +} diff --git a/source/menu/menu_format.cpp b/source/menu/menu_format.cpp index ff97fd76..408ee9a3 100644 --- a/source/menu/menu_format.cpp +++ b/source/menu/menu_format.cpp @@ -1,185 +1,196 @@ -#include - -#include "menus.h" -#include "fatmounter.h" -#include "usbloader/usbstorage.h" -#include "usbloader/utils.h" -#include "usbloader/wbfs.h" -#include "libwiigui/gui_customoptionbrowser.h" - -extern int load_from_fs; -extern char game_partition[6]; - -/**************************************************************************** - * MenuFormat - ***************************************************************************/ -int MenuFormat() { - - USBDevice_deInit(); - sleep(1); - - USBStorage_Init(); - - int menu = MENU_NONE; - char imgPath[100]; - - customOptionList options(MAX_PARTITIONS_EX); - extern PartList partitions; - - u32 cnt, counter = 0; - int choice, ret; - char text[ISFS_MAXPATH]; - - //create the partitionlist - for (cnt = 0; cnt < (u32) partitions.num; cnt++) { - partitionEntry *entry = &partitions.pentry[cnt]; - - /* Calculate size in gigabytes */ - f32 size = entry->size * (partitions.sector_size / GB_SIZE); - - if (size) { - options.SetName(counter, "%s %d:",tr("Partition"), cnt+1); - options.SetValue(counter,"%.2fGB", size); - } else { - options.SetName(counter, "%s %d:",tr("Partition"), cnt+1); - options.SetValue(counter,tr("Can't be formatted")); - } - counter++; - } - - GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume); - // because destroy GuiSound must wait while sound playing is finished, we use a global sound - if(!btnClick2) btnClick2=new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume); - // GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume); - snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff.png", CFG.theme_path); - GuiImageData btnpwroff(imgPath, wiimote_poweroff_png); - snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff_over.png", CFG.theme_path); - GuiImageData btnpwroffOver(imgPath, wiimote_poweroff_over_png); - snprintf(imgPath, sizeof(imgPath), "%smenu_button.png", CFG.theme_path); - GuiImageData btnhome(imgPath, menu_button_png); - snprintf(imgPath, sizeof(imgPath), "%smenu_button_over.png", CFG.theme_path); - GuiImageData btnhomeOver(imgPath, menu_button_over_png); - GuiImageData battery(battery_png); - GuiImageData batteryBar(battery_bar_png); - GuiImageData batteryRed(battery_red_png); - GuiImageData batteryBarRed(battery_bar_red_png); - - - GuiTrigger trigA; - trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); - GuiTrigger trigHome; - trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); - - GuiImage poweroffBtnImg(&btnpwroff); - GuiImage poweroffBtnImgOver(&btnpwroffOver); - poweroffBtnImg.SetWidescreen(CFG.widescreen); - poweroffBtnImgOver.SetWidescreen(CFG.widescreen); - GuiButton poweroffBtn(&poweroffBtnImg,&poweroffBtnImgOver, 0, 3, THEME.power_x, THEME.power_y, &trigA, &btnSoundOver, btnClick2,1); - GuiImage exitBtnImg(&btnhome); - GuiImage exitBtnImgOver(&btnhomeOver); - exitBtnImg.SetWidescreen(CFG.widescreen); - exitBtnImgOver.SetWidescreen(CFG.widescreen); - GuiButton exitBtn(&exitBtnImg,&exitBtnImgOver, 0, 3, THEME.home_x, THEME.home_y, &trigA, &btnSoundOver, btnClick2,1); - exitBtn.SetTrigger(&trigHome); - - GuiCustomOptionBrowser optionBrowser(396, 280, &options, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, 0, 10); - optionBrowser.SetPosition(0, 40); - optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - - HaltGui(); - GuiWindow w(screenwidth, screenheight); - w.Append(&poweroffBtn); - w.Append(&exitBtn); - - mainWindow->Append(&w); - mainWindow->Append(&optionBrowser); - - ResumeGui(); - - while (menu == MENU_NONE) { - - VIDEO_WaitVSync (); - - ret = optionBrowser.GetClickedOption(); - - if(ret >= 0) { - if(Settings.godmode == 1) { - partitionEntry *entry = &partitions.pentry[ret]; - if (entry->size) { - if (load_from_fs == PART_FS_FAT) { - WBFS_OpenPart(partitions.pinfo[ret].part_fs, partitions.pinfo[ret].index, entry->sector, - entry->size, (char *) &game_partition); - load_from_fs = partitions.pinfo[ret].part_fs; - menu = MENU_DISCLIST; - - Settings.partition = ret; - if(isInserted(bootDevice))cfg_save_global(); - } else { - sprintf(text, "%s %d : %.2fGB",tr("Partition"), ret+1, entry->size * (partitions.sector_size / GB_SIZE)); - choice = WindowPrompt( tr("Do you want to format:"), text,tr("Yes"),tr("No")); - if (choice == 1) { - ret = FormatingPartition(tr("Formatting, please wait..."), entry); - if (ret < 0) { - WindowPrompt(tr("Error !"),tr("Failed formating"),tr("Return")); - menu = MENU_SETTINGS; - } else { - sleep(1); - ret = WBFS_Open(); - sprintf(text, "%s %s", text,tr("formatted!")); - WindowPrompt(tr("Success:"),text,tr("OK")); - if(ret < 0) { - WindowPrompt(tr("ERROR"), tr("Failed to open partition"), tr("OK")); - Sys_LoadMenu(); - } - menu = MENU_DISCLIST; - } - } - } - } else if(Settings.godmode == 0) { - mainWindow->Remove(&optionBrowser); - char entered[20] = ""; - int result = OnScreenKeyboard(entered, 20,0); - mainWindow->Append(&optionBrowser); - if ( result == 1 ) { - if (!strcmp(entered, Settings.unlockCode)) { //if password correct - if (Settings.godmode == 0) { - WindowPrompt(tr("Correct Password"),tr("All the features of USB Loader GX are unlocked."),tr("OK")); - Settings.godmode = 1; - } - } else { - WindowPrompt(tr("Wrong Password"),tr("USB Loader GX is protected"),tr("OK")); - } - } - } - } - } - - if (shutdown == 1) - Sys_Shutdown(); - if (reset == 1) - Sys_Reboot(); - - if (poweroffBtn.GetState() == STATE_CLICKED) { - choice = WindowPrompt (tr("Shutdown System"),tr("Are you sure?"),tr("Yes"),tr("No")); - if (choice == 1) { - Sys_Shutdown(); - } - - } else if (exitBtn.GetState() == STATE_CLICKED) { - choice = WindowPrompt (tr("Return to Wii Menu"),tr("Are you sure?"),tr("Yes"),tr("No")); - if (choice == 1) { - Sys_LoadMenu(); - } - } - } - - - HaltGui(); - - mainWindow->Remove(&optionBrowser); - mainWindow->Remove(&w); - ResumeGui(); - - return menu; -} - +#include + +#include "menus.h" +#include "menus.h" +#include "fatmounter.h" +#include "usbloader/usbstorage.h" +#include "usbloader/utils.h" +#include "usbloader/wbfs.h" +#include "libwiigui/gui_customoptionbrowser.h" + +extern int load_from_fs; +extern char game_partition[6]; + +/**************************************************************************** + * MenuFormat + ***************************************************************************/ +int MenuFormat() { + + USBDevice_deInit(); + sleep(1); + + USBStorage_Init(); + + int menu = MENU_NONE; + char imgPath[100]; + + customOptionList options(MAX_PARTITIONS_EX); + extern PartList partitions; + + u32 cnt, counter = 0; + int choice, ret; + char text[ISFS_MAXPATH]; + + //create the partitionlist + for (cnt = 0; cnt < (u32) partitions.num; cnt++) { + partitionEntry *entry = &partitions.pentry[cnt]; + + /* Calculate size in gigabytes */ + f32 size = entry->size * (partitions.sector_size / GB_SIZE); + + if (size) { + options.SetName(counter, "%s %d:",tr("Partition"), cnt+1); + options.SetValue(counter,"%.2fGB", size); + } else { + options.SetName(counter, "%s %d:",tr("Partition"), cnt+1); + options.SetValue(counter,tr("Can't be formatted")); + } + counter++; + } + + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume); + // because destroy GuiSound must wait while sound playing is finished, we use a global sound + if(!btnClick2) btnClick2=new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume); + // GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume); + snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff.png", CFG.theme_path); + GuiImageData btnpwroff(imgPath, wiimote_poweroff_png); + snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff_over.png", CFG.theme_path); + GuiImageData btnpwroffOver(imgPath, wiimote_poweroff_over_png); + snprintf(imgPath, sizeof(imgPath), "%smenu_button.png", CFG.theme_path); + GuiImageData btnhome(imgPath, menu_button_png); + snprintf(imgPath, sizeof(imgPath), "%smenu_button_over.png", CFG.theme_path); + GuiImageData btnhomeOver(imgPath, menu_button_over_png); + GuiImageData battery(battery_png); + GuiImageData batteryBar(battery_bar_png); + GuiImageData batteryRed(battery_red_png); + GuiImageData batteryBarRed(battery_bar_red_png); + + + GuiTrigger trigA; + trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + GuiTrigger trigHome; + trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); + GuiTrigger trigB; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); + + GuiButton backBtn(0,0); + backBtn.SetTrigger(&trigB); + + GuiImage poweroffBtnImg(&btnpwroff); + GuiImage poweroffBtnImgOver(&btnpwroffOver); + poweroffBtnImg.SetWidescreen(CFG.widescreen); + poweroffBtnImgOver.SetWidescreen(CFG.widescreen); + GuiButton poweroffBtn(&poweroffBtnImg,&poweroffBtnImgOver, 0, 3, THEME.power_x, THEME.power_y, &trigA, &btnSoundOver, btnClick2,1); + GuiImage exitBtnImg(&btnhome); + GuiImage exitBtnImgOver(&btnhomeOver); + exitBtnImg.SetWidescreen(CFG.widescreen); + exitBtnImgOver.SetWidescreen(CFG.widescreen); + GuiButton exitBtn(&exitBtnImg,&exitBtnImgOver, 0, 3, THEME.home_x, THEME.home_y, &trigA, &btnSoundOver, btnClick2,1); + exitBtn.SetTrigger(&trigHome); + + GuiCustomOptionBrowser optionBrowser(396, 280, &options, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, 0, 10); + optionBrowser.SetPosition(0, 40); + optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + + HaltGui(); + GuiWindow w(screenwidth, screenheight); + w.Append(&poweroffBtn); + w.Append(&backBtn); + w.Append(&exitBtn); + + mainWindow->Append(&w); + mainWindow->Append(&optionBrowser); + + ResumeGui(); + + while (menu == MENU_NONE) { + + VIDEO_WaitVSync (); + + ret = optionBrowser.GetClickedOption(); + + if(ret >= 0) { + if(Settings.godmode == 1) { + partitionEntry *entry = &partitions.pentry[ret]; + if (entry->size) { + if (load_from_fs == PART_FS_FAT) { + WBFS_OpenPart(partitions.pinfo[ret].part_fs, partitions.pinfo[ret].index, entry->sector, + entry->size, (char *) &game_partition); + load_from_fs = partitions.pinfo[ret].part_fs; + menu = MENU_SETTINGS; + + Settings.partition = ret; + if(isInserted(bootDevice))cfg_save_global(); + } else { + sprintf(text, "%s %d : %.2fGB",tr("Partition"), ret+1, entry->size * (partitions.sector_size / GB_SIZE)); + choice = WindowPrompt( tr("Do you want to format:"), text,tr("Yes"),tr("No")); + if (choice == 1) { + ret = FormatingPartition(tr("Formatting, please wait..."), entry); + if (ret < 0) { + WindowPrompt(tr("Error !"),tr("Failed formating"),tr("Return")); + menu = MENU_SETTINGS; + } else { + sleep(1); + ret = WBFS_Open(); + sprintf(text, "%s %s", text,tr("formatted!")); + WindowPrompt(tr("Success:"),text,tr("OK")); + if(ret < 0) { + WindowPrompt(tr("ERROR"), tr("Failed to open partition"), tr("OK")); + Sys_LoadMenu(); + } + menu = MENU_SETTINGS; + } + } + } + } else if(Settings.godmode == 0) { + mainWindow->Remove(&optionBrowser); + char entered[20] = ""; + int result = OnScreenKeyboard(entered, 20,0); + mainWindow->Append(&optionBrowser); + if ( result == 1 ) { + if (!strcmp(entered, Settings.unlockCode)) { //if password correct + if (Settings.godmode == 0) { + WindowPrompt(tr("Correct Password"),tr("All the features of USB Loader GX are unlocked."),tr("OK")); + Settings.godmode = 1; + } + } else { + WindowPrompt(tr("Wrong Password"),tr("USB Loader GX is protected"),tr("OK")); + } + } + } + } + } + + /* if (shutdown == 1) + Sys_Shutdown(); + if (reset == 1) + Sys_Reboot();*/ + + if (poweroffBtn.GetState() == STATE_CLICKED) { + choice = WindowPrompt (tr("Shutdown System"),tr("Are you sure?"),tr("Yes"),tr("No")); + if (choice == 1) { + Sys_Shutdown(); + } + + } else if (exitBtn.GetState() == STATE_CLICKED) { + choice = WindowPrompt (tr("Return to Wii Menu"),tr("Are you sure?"),tr("Yes"),tr("No")); + if (choice == 1) { + Sys_LoadMenu(); + } + } + else if (backBtn.GetState() == STATE_CLICKED) { + menu = MENU_SETTINGS; + break; + } + } + + + HaltGui(); + + mainWindow->Remove(&optionBrowser); + mainWindow->Remove(&w); + ResumeGui(); + + return menu; +} + diff --git a/source/menu/menu_install.cpp b/source/menu/menu_install.cpp index a9b8fe21..831e3fb0 100644 --- a/source/menu/menu_install.cpp +++ b/source/menu/menu_install.cpp @@ -134,15 +134,6 @@ int MenuInstall() { menu = MENU_DISCLIST; break; } - - if (shutdown == 1) { - wiilight(0); - Sys_Shutdown(); - } - if (reset == 1) { - wiilight(0); - Sys_Reboot(); - } } //Turn off the WiiLight diff --git a/source/menu/menus.h b/source/menu/menus.h index 269d998e..ef935edc 100644 --- a/source/menu/menus.h +++ b/source/menu/menus.h @@ -1,24 +1,31 @@ -#ifndef _MENUS_H -#define _MENUS_H - -#include "libwiigui/gui.h" -#include "language/gettext.h" -#include "prompts/PromptWindows.h" -#include "menu.h" -#include "gecko.h" -#include "filelist.h" -#include "sys.h" - -extern void ResumeGui(); -extern void HaltGui(); -extern GuiWindow * mainWindow; -extern GuiSound * bgMusic; -extern u8 shutdown; -extern u8 reset; - -int MenuInstall(); -int MenuDiscList(); -int MenuFormat(); -int MenuCheck(); - -#endif // _MENUS_H +#ifndef _MENUS_H +#define _MENUS_H + +#include + +#include "libwiigui/gui.h" +#include "language/gettext.h" +#include "prompts/PromptWindows.h" +#include "menu.h" +#include "gecko.h" +#include "filelist.h" +#include "sys.h" + +extern GuiWindow * mainWindow; +extern GuiSound * bgMusic; +extern u8 checkthreadState; +extern u8 needToReloadGamelist; +extern u8 hddOK; +extern u8 mountMethod; + + +int MenuInstall(); +int MenuDiscList(); +int MenuFormat(); + +extern void ResumeCheck(); +extern void HaltCheck(); +extern void InitCheckThread(); +extern void ExitCheckThread(); + +#endif // _MENUS_H diff --git a/source/prompts/DiscBrowser.cpp b/source/prompts/DiscBrowser.cpp index d05efae6..be5bf0b9 100644 --- a/source/prompts/DiscBrowser.cpp +++ b/source/prompts/DiscBrowser.cpp @@ -10,6 +10,7 @@ #include "prompts/PromptWindows.h" #include "filelist.h" #include "menu.h" +#include "../menu/menus.h" #include "usbloader/disc.h" #include "usbloader/fstfile.h" #include "usbloader/wdvd.h" @@ -21,14 +22,8 @@ #include "../gecko.h" #include "../patches/dvd_broadway.h" -/*** Extern functions ***/ -extern void ResumeGui(); -extern void HaltGui(); - /*** Extern variables ***/ extern GuiWindow * mainWindow; -extern u8 shutdown; -extern u8 reset; extern u8 mountMethod; /******************************************************************************** @@ -50,7 +45,7 @@ int DiscBrowse(struct discHdr * header) { return ret; } } - + ret = Disc_Open(); if (ret < 0) { ResumeGui(); @@ -71,7 +66,7 @@ int DiscBrowse(struct discHdr * header) { WindowPrompt(tr("ERROR:"), tr("Could not open WBFS partition"), tr("OK")); return ret; } - + int *buffer = (int*)allocate_memory(0x20); if (buffer == NULL) { @@ -86,7 +81,7 @@ int DiscBrowse(struct discHdr * header) { WindowPrompt(tr("ERROR:"), tr("Could not read the disc."), tr("OK")); return ret; } - + void *fstbuffer = allocate_memory(buffer[2]*4); FST_ENTRY *fst = (FST_ENTRY *)fstbuffer; @@ -204,11 +199,6 @@ int DiscBrowse(struct discHdr * header) { while (!exit) { VIDEO_WaitVSync(); - if (shutdown == 1) - Sys_Shutdown(); - if (reset == 1) - Sys_Reboot(); - ret = optionBrowser3.GetClickedOption(); if (ret > 0) { @@ -244,29 +234,29 @@ int autoSelectDol(const char *id, bool force) { char id4[10]; sprintf(id4,"%c%c%c%c",id[0],id[1],id[2],id[3]); - + ////// games that can be forced (always need alt dol) - //Boogie + //Boogie if (strcmp(id,"RBOP69") == 0) return 675;//previous value was 657 if (strcmp(id,"RBOE69") == 0) return 675;//starstremr - + //Fifa 08 if (strcmp(id,"RF8E69") == 0) return 439;//from isostar if (strcmp(id,"RF8P69") == 0) return 463;//from isostar if (strcmp(id,"RF8X69") == 0) return 464;//from isostar - + //Madden NFL07 if (strcmp(id,"RMDP69") == 0) return 39;//from isostar - + //Madden NFL08 if (strcmp(id,"RNFP69") == 0) return 1079;//from isostar - + //Medal of Honor: Heroes 2 if (strcmp(id,"RM2X69") == 0)return 601;//dj_skual if (strcmp(id,"RM2P69") == 0)return 517;//MZottel - if (strcmp(id,"RM2E69") == 0) return 492;//Old8oy - + if (strcmp(id,"RM2E69") == 0) return 492;//Old8oy + //Mortal Kombat if (strcmp(id,"RKMP5D") == 0) return 290;//from isostar if (strcmp(id,"RKME5D") == 0) return 290;//starstremr @@ -276,7 +266,7 @@ int autoSelectDol(const char *id, bool force) { //Pangya! Golf with Style if (strcmp(id,"RPYP9B") == 0) return 12490;//from isostar - + //Redsteel if (strcmp(id,"REDP41") == 0) return 1957;//from isostar if (strcmp(id,"REDE41") == 0) return 1957;//starstremr @@ -284,37 +274,37 @@ int autoSelectDol(const char *id, bool force) { //SSX if (strcmp(id,"RSXP69") == 0) return 377;//previous value was 337 if (strcmp(id,"RSXE69") == 0) return 377;//previous value was 337 - + //Wii Sports Resort, needs alt dol one time only, to show the Motion Plus video //if (strcmp(id,"RZTP01") == 0 && CheckForSave(id4)==0) return 952;//from isostar //if (strcmp(id,"RZTE01") == 0 && CheckForSave(id4)==0) return 674;//from starstremr //as well as Grand Slam Tennis, Tiger Woods 10, Virtual Tennis 2009 - + ///// games that can't be forced (alt dol is not always needed) if (!force) { - + //Grand Slam Tennis if (strcmp(id,"R5TP69") == 0) return 1493;//from isostar if (strcmp(id,"R5TE69") == 0) return 1493;//starstremr - + //Medal of Honor Heroes if (strcmp(id,"RMZX69") == 0) return 492;//from isostar if (strcmp(id,"RMZP69") == 0) return 492;//from isostar - if (strcmp(id,"RMZE69") == 0) return 492;//starstremr - + if (strcmp(id,"RMZE69") == 0) return 492;//starstremr + //Tiger Woods 10 if (strcmp(id,"R9OP69") == 0) return 1991;//from isostar if (strcmp(id,"R9OE69") == 0) return 1973;//starstremr - + //Virtual Tennis 2009 if (strcmp(id,"RVUP8P") == 0) return 16426;//from isostar if (strcmp(id,"RVUE8P") == 0) return 16405;//from isostar - + //Wii Sports Resort if (strcmp(id,"RZTP01") == 0) return 952;//from isostar if (strcmp(id,"RZTE01") == 0) return 674;//from starstremr } - + return -1; } @@ -323,7 +313,7 @@ int autoSelectDolMenu(const char *id, bool force) { /* char id4[10]; sprintf(id4,"%c%c%c%c",id[0],id[1],id[2],id[3]); - + switch (CheckForSave(id4)) { case 0: WindowPrompt(tr("NO save"),0,tr("OK")); @@ -339,7 +329,7 @@ int autoSelectDolMenu(const char *id, bool force) { } return -1; */ - + //Indiana Jones and the Staff of Kings (Fate of Atlantis) if (strcmp(id,"RJ8E64") == 0) { int choice = WindowPrompt(tr("Select a DOL"), 0, "Fate of Atlantis", tr("Default")); @@ -365,7 +355,7 @@ int autoSelectDolMenu(const char *id, bool force) { } return choice; } - + //Metal Slug Anthology (Metal Slug 6) if (strcmp(id,"RMLEH4") == 0) { int choice = WindowPrompt(tr("Select a DOL"), 0, "Metal Slug 6", tr("Default")); @@ -391,7 +381,7 @@ int autoSelectDolMenu(const char *id, bool force) { } return choice; } - + //Metroid Prime Trilogy if (strcmp(id,"R3ME01") == 0) { //do not use any alt dol if there is no save game in the nand @@ -442,7 +432,7 @@ int autoSelectDolMenu(const char *id, bool force) { } return choice; } - + //Rampage: Total Destruction (M1.dol=Rampage, jarvos.dol=Rampage World Tour) if (strcmp(id,"RPGP5D") == 0) { int choice = WindowPrompt(tr("Select a DOL"), 0, "Rampage", "World Tour", tr("Default")); @@ -459,7 +449,7 @@ int autoSelectDolMenu(const char *id, bool force) { } return choice; } - + //The House Of The Dead 2 & 3 Return (only to play 2) if (strcmp(id,"RHDE8P") == 0) { int choice = WindowPrompt(tr("Select a DOL"), 0, "HotD 2", tr("Default")); @@ -501,11 +491,11 @@ void __dvd_readidcb(s32 result) dvddone = result; } -u8 DiscMount(discHdr *header) { +u8 DiscMount1(discHdr *header) { gprintf("\nDiscMount() "); int ret; HaltGui(); - + u8 *tmpBuff = (u8 *) malloc(0x60); memcpy(tmpBuff, g_diskID, 0x60); // Make a backup of the first 96 bytes at 0x80000000 @@ -513,7 +503,7 @@ u8 DiscMount(discHdr *header) { dvddone = 0; ret = bwDVD_LowReset(__dvd_readidcb); while(ret>=0 && dvddone==0); - + dvddone = 0; ret = bwDVD_LowReadID(g_diskID, __dvd_readidcb); // Leave this one here, or you'll get an IOCTL error while(ret>=0 && dvddone==0); @@ -521,15 +511,65 @@ u8 DiscMount(discHdr *header) { dvddone = 0; ret = bwDVD_LowUnencryptedRead(g_diskID, 0x60, 0x00, __dvd_readidcb); // Overwrite the g_diskID thing while(ret>=0 && dvddone==0); - + memcpy(header, g_diskID, 0x60); memcpy(g_diskID, tmpBuff, 0x60); // Put the backup back, or games won't load free(tmpBuff); - + ResumeGui(); if (dvddone != 1) { return 0; } return (header->magic == 0x5D1C9EA3) ? 1 : 2; // Don't check gamecube magic (0xC2339F3D) } + +u8 DiscMount(discHdr *header) { + gprintf("\nDiscMount() "); + + HaltGui(); + GuiWindow w(screenwidth, screenheight); + + mainWindow->Append(&w); + + ResumeGui(); + +//HaltCheck(); + int ret = Disc_SetUSB(NULL); + ret = WDVD_Close(); + ret = Disc_Init(); + + + + + ret = DiscWait(tr("Insert Disk"),tr("Waiting..."),tr("Cancel"),0,0); + if (ret < 0) { + WindowPrompt (tr("Error reading Disc"),0,tr("Back")); + goto OUT; + } + mainWindow->SetState(STATE_DISABLED); + //gprintf("..1"); + ret = Disc_Open(); + if (ret < 0) { + WindowPrompt (tr("Could not open Disc"),0,tr("Back")); + goto OUT; + } + //gprintf("..2"); + Disc_ReadHeader(header); + //gprintf("..3"); + ret = Disc_IsWii(); + //gprintf("..4"); + //ResumeCheck(); + if (ret < 0) { + ret = 2; + } + ret = 1; + + + OUT: + HaltGui(); + mainWindow->Remove(&w); + mainWindow->SetState(STATE_DEFAULT); + ResumeGui(); + return ret; +} diff --git a/source/prompts/ProgressWindow.cpp b/source/prompts/ProgressWindow.cpp index b1ae11f7..25b5eea6 100644 --- a/source/prompts/ProgressWindow.cpp +++ b/source/prompts/ProgressWindow.cpp @@ -40,10 +40,6 @@ static time_t start; extern GuiWindow * mainWindow; extern float gamesize; -/*** Extern functions ***/ -extern void ResumeGui(); -extern void HaltGui(); - /**************************************************************************** * GameInstallProgress diff --git a/source/prompts/PromptWindows.cpp b/source/prompts/PromptWindows.cpp index cc6d0b5e..3327f8db 100644 --- a/source/prompts/PromptWindows.cpp +++ b/source/prompts/PromptWindows.cpp @@ -23,7 +23,6 @@ #include "fatmounter.h" #include "listfiles.h" #include "menu.h" -#include "menu.h" #include "filelist.h" #include "sys.h" #include "wpad.h" @@ -53,15 +52,10 @@ extern u32 gameCnt; extern s32 gameSelected, gameStart; extern float gamesize; extern struct discHdr * gameList; -extern u8 shutdown; -extern u8 reset; extern u8 mountMethod; extern struct discHdr *dvdheader; extern char game_partition[6]; - -/*** Extern functions ***/ -extern void ResumeGui(); -extern void HaltGui(); +extern u8 shutdown; /**************************************************************************** * OnScreenNumpad @@ -71,9 +65,9 @@ extern void HaltGui(); ***************************************************************************/ int OnScreenNumpad(char * var, u32 maxlen) { int save = -1; - + GuiNumpad numpad(var, maxlen); - + GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume); // because destroy GuiSound must wait while sound playing is finished, we use a global sound if(!btnClick2) btnClick2=new GuiSound(button_click2_pcm, button_click2_pcm_size,Settings.sfxvolume); @@ -104,7 +98,7 @@ int OnScreenNumpad(char * var, u32 maxlen) { GuiButton cancelBtn(&cancelBtnImg,&cancelBtnImg, 1, 4, -5, -15, &trigA, &btnSoundOver, btnClick2,1); cancelBtn.SetLabel(&cancelBtnTxt); cancelBtn.SetTrigger(&trigB); - + numpad.Append(&okBtn); numpad.Append(&cancelBtn); @@ -132,7 +126,7 @@ int OnScreenNumpad(char * var, u32 maxlen) { mainWindow->SetState(STATE_DEFAULT); ResumeGui(); gprintf("\t%s",(save == 1?"saved":"discarded")); - return save; + return save; } /**************************************************************************** @@ -696,17 +690,9 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label, } - GuiTrigger trigZ; - trigZ.SetButtonOnlyTrigger(-1, WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL, PAD_TRIGGER_Z); - - GuiButton screenShotBtn(0,0); - screenShotBtn.SetPosition(0,0); - screenShotBtn.SetTrigger(&trigZ); - promptWindow.Append(&dialogBoxImg); promptWindow.Append(&titleTxt); promptWindow.Append(&msgTxt); - promptWindow.Append(&screenShotBtn); if (btn1Label) promptWindow.Append(&btn1); @@ -726,12 +712,7 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label, while (choice == -1) { VIDEO_WaitVSync(); - if (shutdown == 1) { - wiilight(0); - Sys_Shutdown(); - } - if (reset == 1) - Sys_Reboot(); + if (btn1.GetState() == STATE_CLICKED) { choice = 1; } else if (btn2.GetState() == STATE_CLICKED) { @@ -746,12 +727,7 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label, choice = 3; } else if (btn4.GetState() == STATE_CLICKED) { choice = 0; - } else if (screenShotBtn.GetState() == STATE_CLICKED) { - gprintf("\n\tscreenShotBtn clicked"); - screenShotBtn.ResetState(); - ScreenShot(); - gprintf("...It's easy, mmmmmmKay"); - } + } if (count>0)count--; if (count==0) choice = 1; } @@ -978,12 +954,9 @@ int WindowExitPrompt() } - if (shutdown == 1) { + if (shutdown == 1) wiilight(0); - Sys_Shutdown(); - } - if (reset == 1) - Sys_Reboot(); + if (btn1.GetState() == STATE_CLICKED) { choice = 1; btn1.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); @@ -1138,12 +1111,6 @@ int GameWindowPrompt() { trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0); GuiTrigger trigMinus; trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0); - GuiTrigger trigZ; - trigZ.SetButtonOnlyTrigger(-1, WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL, PAD_TRIGGER_Z); - - GuiButton screenShotBtn(0,0); - screenShotBtn.SetPosition(0,0); - screenShotBtn.SetTrigger(&trigZ); if (CFG.widescreen) snprintf(imgPath, sizeof(imgPath), "%swdialogue_box_startgame.png", CFG.theme_path); @@ -1274,7 +1241,6 @@ int GameWindowPrompt() { promptWindow.Append(&dialogBoxImg); promptWindow.Append(&nameBtn); promptWindow.Append(&playcntTxt); - promptWindow.Append(&screenShotBtn); promptWindow.Append(&btn2); if (!mountMethod)//stuff we don't show if it is a DVD mounted { @@ -1295,7 +1261,7 @@ int GameWindowPrompt() { promptWindow.Append(&diskImg2); promptWindow.Append(&btn1); - + short changed = -1; GuiImageData * diskCover = NULL; GuiImageData * diskCover2 = NULL; @@ -1452,19 +1418,6 @@ int GameWindowPrompt() { diskImg.SetSpin(btn1.GetState() == STATE_SELECTED); diskImg2.SetSpin(btn1.GetState() == STATE_SELECTED); - if (shutdown == 1) { //for power button - promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); - mainWindow->SetState(STATE_DEFAULT); - while (promptWindow.GetEffect() > 0) usleep(50); - HaltGui(); - mainWindow->Remove(&promptWindow); - ResumeGui(); - wiilight(0); - Sys_Shutdown(); - } - - if (reset == 1) //for reset button - Sys_Reboot(); if(gameSound) { @@ -1544,12 +1497,6 @@ int GameWindowPrompt() { } btnFavorite5.ResetState(); } - else if (screenShotBtn.GetState() == STATE_CLICKED) { - gprintf("\n\tscreenShotBtn clicked"); - screenShotBtn.ResetState(); - ScreenShot(); - gprintf("...It's easy, mmmmmmKay"); - } // this next part is long because nobody could agree on what the left/right buttons should do else if ((btnRight.GetState() == STATE_CLICKED) && (Settings.xflip == no)) {//next game promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50); @@ -2768,7 +2715,7 @@ int ProgressUpdateWindow() { } else { filesize = download_request("http://www.techjawa.com/usbloadergx/ULNR.file");//for some reason it didn't download completely when saved as a wad. } - + if (filesize > 0) { pfile = fopen(dolpath, "wb");//here we save the txt as a wad @@ -2887,7 +2834,7 @@ int ProgressUpdateWindow() { return 1; } -#else +#else int ProgressUpdateWindow() { gprintf("\nProgressUpdateWindow(not full channel)"); @@ -3051,7 +2998,7 @@ int ProgressUpdateWindow() { promptWindow.Append(&progressbarOutlineImg); promptWindow.Append(&prTxt); msgTxt.SetTextf("%s Rev%i", tr("Update to"), newrev); - + s32 filesize; if (Settings.beta_upgrades) { char url[255]; @@ -3569,14 +3516,6 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version, btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); btn2.SetPosition(-40, 2); - GuiTrigger trigZ; - trigZ.SetButtonOnlyTrigger(-1, WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL, PAD_TRIGGER_Z); - - GuiButton screenShotBtn(0,0); - screenShotBtn.SetPosition(0,0); - screenShotBtn.SetTrigger(&trigZ); - promptWindow.Append(&screenShotBtn); - promptWindow.Append(&dialogBoxImg); if (strcmp(long_description,""))promptWindow.Append(&whiteBoxImg); if (strcmp(long_description,""))promptWindow.Append(&scrollbarImg); @@ -3603,23 +3542,15 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version, while (choice == -1) { VIDEO_WaitVSync(); - if (shutdown == 1) { + + if (shutdown == 1) wiilight(0); - Sys_Shutdown(); - } - if (reset == 1) - Sys_Reboot(); + if (btn1.GetState() == STATE_CLICKED) { choice = 1; } else if (btn2.GetState() == STATE_CLICKED) { choice = 0; } - else if (screenShotBtn.GetState() == STATE_CLICKED) { - gprintf("\n\tscreenShotBtn clicked"); - screenShotBtn.ResetState(); - ScreenShot(); - gprintf("...It's easy, mmmmmmKay"); - } else if ((arrowUpBtn.GetState()==STATE_CLICKED||arrowUpBtn.GetState()==STATE_HELD) ) { if (long_descriptionTxt.GetFirstLine()>1) long_descriptionTxt.SetFirstLine(long_descriptionTxt.GetFirstLine()-1); diff --git a/source/prompts/TitleBrowser.cpp b/source/prompts/TitleBrowser.cpp index e4245c7c..a64e66fc 100644 --- a/source/prompts/TitleBrowser.cpp +++ b/source/prompts/TitleBrowser.cpp @@ -20,6 +20,7 @@ #include "settings/cfg.h" #include "sys.h" #include "menu.h" +#include "../menu/menus.h" #include "audio.h" #include "wad/wad.h" #include "xml/xml.h" @@ -37,14 +38,8 @@ u32 titleCnt; extern struct discHdr * gameList; extern u32 gameCnt; -/*** Extern functions ***/ -extern void ResumeGui(); -extern void HaltGui(); - /*** Extern variables ***/ extern GuiWindow * mainWindow; -extern u8 shutdown; -extern u8 reset; extern u32 infilesize; extern wchar_t *gameFilter; @@ -123,7 +118,7 @@ int TitleBrowser(u32 type) { char line[200]; char tmp[50]; snprintf(tmp,50," "); - + //check if the content.bin is on the SD card for that game //if there is content.bin,then the game is on the SDmenu and not the wii sprintf(line,"SD:/private/wii/title/%s/content.bin",text); @@ -295,16 +290,8 @@ int TitleBrowser(u32 type) { wifiBtn.SetAlpha(80); wifiBtn.SetTrigger(&trigA); - GuiTrigger trigZ; - trigZ.SetButtonOnlyTrigger(-1, WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL, PAD_TRIGGER_Z); - - GuiButton screenShotBtn(0,0); - screenShotBtn.SetPosition(0,0); - screenShotBtn.SetTrigger(&trigZ); - HaltGui(); GuiWindow w(screenwidth, screenheight); - w.Append(&screenShotBtn); w.Append(&settingsbackgroundbtn); w.Append(&titleTxt); w.Append(&cancelBtn); @@ -320,12 +307,7 @@ int TitleBrowser(u32 type) { while (!exit) { VIDEO_WaitVSync(); - if (shutdown == 1) - Sys_Shutdown(); - if (reset == 1) - Sys_Reboot(); - - else if (wifiBtn.GetState() == STATE_CLICKED) { + if (wifiBtn.GetState() == STATE_CLICKED) { ResumeNetworkWait(); wifiBtn.ResetState(); @@ -418,7 +400,7 @@ int TitleBrowser(u32 type) { char temp[50]; char filepath[100]; u32 read = 0; - + //make sure there is a folder for this to be saved in struct stat st; snprintf(filepath, sizeof(filepath), "%s/wad/", bootDevice); @@ -428,7 +410,7 @@ int TitleBrowser(u32 type) { } } snprintf(filepath, sizeof(filepath), "%s/wad/tmp.tmp", bootDevice); - + if (infilesize < MB_SIZE) snprintf(filesizetxt, sizeof(filesizetxt), tr("Incoming file %0.2fKB"), infilesize/KB_SIZE); @@ -512,9 +494,9 @@ int TitleBrowser(u32 type) { w.Remove(&wifiBtn); w.Remove(&optionBrowser3); ResumeGui(); - + Wad_Install(file); - + HaltGui(); w.Append(&titleTxt); w.Append(&cancelBtn); @@ -547,12 +529,6 @@ int TitleBrowser(u32 type) { exit = true; ret = -10; } - else if (screenShotBtn.GetState() == STATE_CLICKED) { - gprintf("\n\tscreenShotBtn clicked"); - screenShotBtn.ResetState(); - ScreenShot(); - gprintf("...It's easy, mmmmmmKay"); - } } CloseConnection(); diff --git a/source/prompts/filebrowser.cpp b/source/prompts/filebrowser.cpp index 07db483b..55af9882 100644 --- a/source/prompts/filebrowser.cpp +++ b/source/prompts/filebrowser.cpp @@ -20,6 +20,7 @@ #include #include "menu.h" +#include "../menu/menus.h" #include "listfiles.h" #include "language/gettext.h" @@ -27,15 +28,10 @@ #include "libwiigui/gui.h" #include "sys.h" #include "filebrowser.h" +#include "../menu.h" /*** Extern variables ***/ extern GuiWindow * mainWindow; -extern u8 shutdown; -extern u8 reset; - -/*** Extern functions ***/ -extern void ResumeGui(); -extern void HaltGui(); static int curDevice = -1; static std::vector browsers; @@ -317,7 +313,7 @@ int BrowseDevice(char * Path, int Path_size, int Flags, FILTERCASCADE *Filter/*= folderBtn.SetImage(&folderImg); folderBtn.SetTrigger(&trigA); folderBtn.SetEffectGrow(); - + char imgPath[100]; snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); GuiImageData btnOutline(imgPath, button_dialogue_box_png); @@ -393,12 +389,6 @@ int BrowseDevice(char * Path, int Path_size, int Flags, FILTERCASCADE *Filter/*= while (menu == MENU_NONE) { VIDEO_WaitVSync(); - if (shutdown == 1) - Sys_Shutdown(); - - if (reset == 1) - Sys_Reboot(); - for (i=0; iGetState() == STATE_CLICKED) { fileBrowser.fileList[i]->ResetState(); @@ -486,7 +476,7 @@ int BrowseDevice(char * Path, int Path_size, int Flags, FILTERCASCADE *Filter/*= char oldfolder[100]; snprintf(newfolder, sizeof(newfolder), "%s%s", browser->rootdir, browser->dir); strcpy(oldfolder,newfolder); - + int result = OnScreenKeyboard(newfolder, sizeof(newfolder), strlen(browser->rootdir)); if ( result == 1 ) { unsigned int len = strlen(newfolder); diff --git a/source/prompts/gameinfo.cpp b/source/prompts/gameinfo.cpp index 7e8325c2..580bc48b 100644 --- a/source/prompts/gameinfo.cpp +++ b/source/prompts/gameinfo.cpp @@ -19,22 +19,18 @@ #include "gameinfo.h" #include "usbloader/getentries.h" #include "../gecko.h" +#include "../menu.h" +#include "../menu/menus.h" /*** Extern variables ***/ extern GuiWindow * mainWindow; extern GuiSound * bgMusic; -extern u8 shutdown; -extern u8 reset; extern struct gameXMLinfo gameinfo; extern struct gameXMLinfo gameinfo_reset; extern u32 gameCnt; extern struct discHdr * gameList; -/*** Extern functions ***/ -extern void ResumeGui(); -extern void HaltGui(); - /**************************************************************************** * gameinfo @@ -714,7 +710,7 @@ int showGameInfo(char *ID) { snprintf(linebuf, sizeof(linebuf), "%s:",tr("WiFi Features")); } else { strcpy(linebuf,""); - } + } wifiTxt[0] = new GuiText(linebuf, 16, (GXColor) {0,0,0, 255}); wifiTxt[0]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); wifiTxt[0]->SetPosition(205,200+wifiY); @@ -781,13 +777,6 @@ int showGameInfo(char *ID) { gameinfoWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 100); - GuiTrigger trigZ; - trigZ.SetButtonOnlyTrigger(-1, WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL, PAD_TRIGGER_Z); - - GuiButton screenShotBtn(0,0); - screenShotBtn.SetPosition(0,0); - screenShotBtn.SetTrigger(&trigZ); - gameinfoWindow.Append(&screenShotBtn); HaltGui(); //mainWindow->SetState(STATE_DISABLED); mainWindow->Append(&gameinfoWindow); @@ -799,13 +788,8 @@ int showGameInfo(char *ID) { while (choice == -1) { VIDEO_WaitVSync(); - if (shutdown == 1) { - wiilight(0); - Sys_Shutdown(); - } else if (reset == 1) - Sys_Reboot(); - else if ((backBtn.GetState()==STATE_CLICKED)||(backBtn.GetState()==STATE_HELD)) { + if ((backBtn.GetState()==STATE_CLICKED)||(backBtn.GetState()==STATE_HELD)) { backBtn.ResetState(); if (page==1) { choice=1; @@ -816,13 +800,11 @@ int showGameInfo(char *ID) { gameinfoWindow2.Remove(&nextBtn); gameinfoWindow2.Remove(&backBtn); gameinfoWindow2.Remove(&homeBtn); - gameinfoWindow2.Remove(&screenShotBtn); gameinfoWindow2.SetVisible(false); gameinfoWindow.SetVisible(true); gameinfoWindow.Append(&backBtn); gameinfoWindow.Append(&nextBtn); gameinfoWindow.Append(&homeBtn); - gameinfoWindow.Append(&screenShotBtn); mainWindow->Remove(&gameinfoWindow2); ResumeGui(); page=1; @@ -835,14 +817,12 @@ int showGameInfo(char *ID) { gameinfoWindow.Remove(&nextBtn); gameinfoWindow.Remove(&backBtn); gameinfoWindow.Remove(&homeBtn); - gameinfoWindow.Remove(&screenShotBtn); gameinfoWindow.SetVisible(false); gameinfoWindow2.SetVisible(true); coverImg->SetPosition(15,30); gameinfoWindow2.Append(&nextBtn); gameinfoWindow2.Append(&backBtn); gameinfoWindow2.Append(&homeBtn); - gameinfoWindow2.Append(&screenShotBtn); mainWindow->Append(&gameinfoWindow2); ResumeGui(); page=2; @@ -851,13 +831,11 @@ int showGameInfo(char *ID) { gameinfoWindow2.Remove(&nextBtn); gameinfoWindow2.Remove(&backBtn); gameinfoWindow2.Remove(&homeBtn); - gameinfoWindow2.Remove(&screenShotBtn); gameinfoWindow2.SetVisible(false); gameinfoWindow.SetVisible(true); gameinfoWindow.Append(&backBtn); gameinfoWindow.Append(&nextBtn); gameinfoWindow.Append(&homeBtn); - gameinfoWindow.Append(&screenShotBtn); mainWindow->Remove(&gameinfoWindow2); ResumeGui(); page=1; @@ -916,12 +894,6 @@ int showGameInfo(char *ID) { } urlBtn.ResetState(); } - else if (screenShotBtn.GetState() == STATE_CLICKED) { - gprintf("\n\tscreenShotBtn clicked"); - screenShotBtn.ResetState(); - ScreenShot(); - gprintf("...It's easy, mmmmmmKay"); - } } if (page==1) { gameinfoWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 100); @@ -1103,10 +1075,10 @@ bool save_XML_URL() { // save xml url as as txt file for people without wifi sleep(1); return false; } - + char XMLurl[3540]; build_XML_URL(XMLurl,sizeof(XMLurl)); - + fprintf(f, "# USB Loader Has Saved this file\n"); fprintf(f, "# This URL was created based on your list of games and language settings.\n"); fclose(f); diff --git a/source/settings/Settings.cpp b/source/settings/Settings.cpp index 3e1d7384..f6e262f6 100644 --- a/source/settings/Settings.cpp +++ b/source/settings/Settings.cpp @@ -13,6 +13,7 @@ #include "cheats/cheatmenu.h" #include "fatmounter.h" #include "menu.h" +#include "menu/menus.h" #include "filelist.h" #include "listfiles.h" #include "sys.h" @@ -23,9 +24,6 @@ #define MAXOPTIONS 13 -/*** Extern functions ***/ -extern void ResumeGui(); -extern void HaltGui(); extern void titles_default(); /*** Extern variables ***/ @@ -34,8 +32,6 @@ extern GuiSound * bgMusic; extern GuiImage * bgImg; extern GuiImageData * pointer[4]; extern GuiImageData * background; -extern u8 shutdown; -extern u8 reset; extern u8 mountMethod; extern struct discHdr *dvdheader; extern PartList partitions; @@ -76,7 +72,7 @@ int MenuSettings() int opt_override = Settings.titlesOverride; // backup partition index u8 settingspartitionold = Settings.partition; - + enum { @@ -537,7 +533,7 @@ int MenuSettings() snprintf(MainButtonText, sizeof(MainButtonText), "%s", tr("Theme Downloader")); MainButton1Txt.SetText(MainButtonText); - snprintf(MainButtonText, sizeof(MainButtonText), "%s", tr(" ")); + snprintf(MainButtonText, sizeof(MainButtonText), "%s", tr("Partition Format Menu")); MainButton2Txt.SetText(MainButtonText); snprintf(MainButtonText, sizeof(MainButtonText), "%s", tr(" ")); MainButton3Txt.SetText(MainButtonText); @@ -557,6 +553,7 @@ int MenuSettings() w.Append(&GoRightBtn); w.Append(&GoLeftBtn); w.Append(&MainButton1); + w.Append(&MainButton2); PageIndicatorBtn1.SetAlpha(50); PageIndicatorBtn2.SetAlpha(50); @@ -611,10 +608,6 @@ int MenuSettings() { VIDEO_WaitVSync (); - if (shutdown == 1) - Sys_Shutdown(); - if (reset == 1) - Sys_Reboot(); if ( pageToDisplay == 1 ) { @@ -658,12 +651,7 @@ int MenuSettings() returnhere = 1; - if (shutdown == 1) - Sys_Shutdown(); - if (reset == 1) - Sys_Reboot(); - - else if (backBtn.GetState() == STATE_CLICKED) + if (backBtn.GetState() == STATE_CLICKED) { backBtn.ResetState(); exit = true; @@ -865,7 +853,7 @@ int MenuSettings() static const char *opts[settings_screensaver_max] = {trNOOP("OFF"),trNOOP("3 min"),trNOOP("5 min"),trNOOP("10 min"),trNOOP("20 min"),trNOOP("30 min"),trNOOP("1 hour")}; options2.SetValue(Idx,"%s",tr(opts[Settings.screensaver])); } - + if(ret == ++Idx || firstRun) { if(firstRun) options2.SetName(Idx, "%s",tr("Mark new games")); @@ -920,12 +908,7 @@ int MenuSettings() { VIDEO_WaitVSync (); - if (shutdown == 1) - Sys_Shutdown(); - if (reset == 1) - Sys_Reboot(); - - else if (backBtn.GetState() == STATE_CLICKED) + if (backBtn.GetState() == STATE_CLICKED) { backBtn.ResetState(); exit = true; @@ -1010,7 +993,7 @@ int MenuSettings() else options2.SetValue(Idx, "********"); } - + if (ret == ++Idx || firstRun) { if (firstRun) options2.SetName(Idx, "%s", tr("Partition")); @@ -1022,23 +1005,23 @@ int MenuSettings() } while (!IsValidPartition(partitions.pinfo[Settings.partition].fs_type, Settings.cios)); } - + PartInfo pInfo = partitions.pinfo[Settings.partition]; f32 partition_size = partitions.pentry[Settings.partition].size * (partitions.sector_size / GB_SIZE); - + // Get the partition name and it's size in GB's options2.SetValue(Idx,"%s%d (%.2fGB)", pInfo.fs_type == FS_TYPE_FAT32 ? "FAT" : pInfo.fs_type == FS_TYPE_NTFS ? "NTFS" : "WBFS", pInfo.index, partition_size); } - + if (ret == ++Idx || firstRun) { if (firstRun) options2.SetName(Idx, "%s", tr("FAT: Use directories")); if (ret == Idx) { Settings.FatInstallToDir = Settings.FatInstallToDir == 0 ? 1 : 0; } - options2.SetValue(Idx, "%s", tr(opts_no_yes[Settings.FatInstallToDir])); + options2.SetValue(Idx, "%s", tr(opts_no_yes[Settings.FatInstallToDir])); } if(ret == ++Idx || firstRun) @@ -1119,12 +1102,7 @@ int MenuSettings() { VIDEO_WaitVSync (); - if (shutdown == 1) - Sys_Shutdown(); - if (reset == 1) - Sys_Reboot(); - - else if (backBtn.GetState() == STATE_CLICKED) + if (backBtn.GetState() == STATE_CLICKED) { backBtn.ResetState(); exit = true; @@ -1167,7 +1145,7 @@ int MenuSettings() { char entered[20]; memset(entered, 0, 20); - + //password check to unlock Install,Delete and Format w.Remove(&optionBrowser2); w.Remove(&backBtn); @@ -1294,11 +1272,7 @@ int MenuSettings() bool returnhere = true; - if (shutdown == 1) - Sys_Shutdown(); - if (reset == 1) - Sys_Reboot(); - else if (backBtn.GetState() == STATE_CLICKED) + if (backBtn.GetState() == STATE_CLICKED) { backBtn.ResetState(); exit = true; @@ -1474,12 +1448,8 @@ int MenuSettings() { VIDEO_WaitVSync (); - if (shutdown == 1) - Sys_Shutdown(); - if (reset == 1) - Sys_Reboot(); - else if (backBtn.GetState() == STATE_CLICKED) + if (backBtn.GetState() == STATE_CLICKED) { backBtn.ResetState(); exit = true; @@ -1888,7 +1858,7 @@ int MenuSettings() } options2.SetValue(Idx, "%s", Settings.BcaCodepath); } - + if(ret == ++Idx || firstRun) { if(firstRun) options2.SetName(Idx, "%s", tr("WIP Patches Path")); @@ -2048,6 +2018,20 @@ int MenuSettings() pageToDisplay = 0; break; } + if (MainButton2.GetState() == STATE_CLICKED) + { + if(Settings.godmode == 1) + { + if (isInserted(bootDevice)) + cfg_save_global(); + menu = MENU_FORMAT; + pageToDisplay = 0; + break; + } + else + WindowPrompt(tr("You can't access this menu!"), tr("Unlock the app first."), tr("OK")); + MainButton2.ResetState(); + } } @@ -2146,7 +2130,7 @@ int MenuSettings() w.SetEffect(EFFECT_FADE, -20); while (w.GetEffect()>0) usleep(50); - // if partition has changed, Reinitialize it + // if partition has changed, Reinitialize it PartInfo pinfo = partitions.pinfo[Settings.partition]; partitionEntry pentry = partitions.pentry[Settings.partition]; load_from_fs = pinfo.part_fs; @@ -2154,7 +2138,7 @@ int MenuSettings() WBFS_Close(); WBFS_OpenPart(load_from_fs, pinfo.index, pentry.sector, pentry.size, (char *) &game_partition); } - + // if language has changed, reload titles char opt_langnew[100]; strcpy(opt_langnew,Settings.language_path); @@ -2428,7 +2412,7 @@ int GameSettings(struct discHdr * header) iosChoice = i250; else if (Settings.cios == ios223) iosChoice = i223; - else + else iosChoice = i249; parentalcontrolChoice = 0; fix002 = Settings.error002; @@ -2449,11 +2433,6 @@ int GameSettings(struct discHdr * header) { VIDEO_WaitVSync (); - if (shutdown == 1) - Sys_Shutdown(); - if (reset == 1) - Sys_Reboot(); - if (MainButton1.GetState() == STATE_CLICKED) { w.Append(&saveBtn); @@ -2489,10 +2468,6 @@ int GameSettings(struct discHdr * header) returnhere = 1; - if (shutdown == 1) - Sys_Shutdown(); - if (reset == 1) - Sys_Reboot(); if (backBtn.GetState() == STATE_CLICKED) { backBtn.ResetState(); @@ -2762,10 +2737,6 @@ int GameSettings(struct discHdr * header) { VIDEO_WaitVSync (); - if (shutdown == 1) - Sys_Shutdown(); - if (reset == 1) - Sys_Reboot(); if (backBtn.GetState() == STATE_CLICKED) { backBtn.ResetState(); diff --git a/source/settings/SettingsPrompts.cpp b/source/settings/SettingsPrompts.cpp index 6a87e2c3..4d6ca187 100644 --- a/source/settings/SettingsPrompts.cpp +++ b/source/settings/SettingsPrompts.cpp @@ -10,6 +10,7 @@ #include "settings/cfg.h" #include "network/URL_List.h" #include "listfiles.h" +#include "menu/menus.h" #include "main.h" #include "fatmounter.h" #include "filelist.h" @@ -20,13 +21,6 @@ /*** Extern variables ***/ extern GuiWindow * mainWindow; extern GuiSound * bgMusic; -extern u8 shutdown; -extern u8 reset; - -/*** Extern functions ***/ -extern void ResumeGui(); -extern void HaltGui(); - /**************************************************************************** * MenuOGG @@ -183,11 +177,6 @@ bool MenuOGG() { while (!returnhere) { - if (shutdown == 1) - Sys_Shutdown(); - if (reset == 1) - Sys_Reboot(); - if (backBtn.GetState() == STATE_CLICKED) { if (nothingchanged == 1 && countoggs > 0) { if (strcmp("", Settings.oggload_path) && strcmp("notset", Settings.ogg_path)) { @@ -453,12 +442,7 @@ int MenuLanguageSelect() { while (!returnhere) { - if (shutdown == 1) - Sys_Shutdown(); - else if (reset == 1) - Sys_Reboot(); - - else if (backBtn.GetState() == STATE_CLICKED) { + if (backBtn.GetState() == STATE_CLICKED) { backBtn.ResetState(); break; diff --git a/source/settings/cfg.c b/source/settings/cfg.c index 4deba6ff..36460762 100644 --- a/source/settings/cfg.c +++ b/source/settings/cfg.c @@ -366,7 +366,7 @@ void Global_Default(void) { Settings.partitions_to_install = install_game_only; Settings.fullcopy = 0; Settings.beta_upgrades = 0; - + memset(&Settings.parental, 0, sizeof(struct SParental)); char buf[0x4a]; @@ -385,7 +385,11 @@ void Global_Default(void) { } -char *cfg_get_title(u8 *id) { +char *cfg_get_title(u8 *id) +{ + if(!id) + return NULL; + int i; for (i=0; i= 0 && (ios222rev != 4 && ios222rev != 5))return -2; } else if (ios==223) - { + { if (ios223rev == -69) ios223rev = getIOSrev(0x00000001000000dfll); - + if (ios223rev >= 0 && (ios223rev != 4 && ios223rev != 5))return -2; } else if (ios==249) - { + { if (ios249rev == -69) - ios249rev = getIOSrev(0x00000001000000f9ll); - + ios249rev = getIOSrev(0x00000001000000f9ll); + if (ios249rev >= 0 && !(ios249rev>=9 && ios249rev<65280))return -2; } else if (ios==250) - { + { if (ios250rev == -69) ios250rev = getIOSrev(0x00000001000000fall); - + if (ios250rev >= 0 && !(ios250rev>=9 && ios250rev<65280))return -2; } - + s32 r = IOS_ReloadIOS(ios); if (r >= 0) { WII_Initialize(); @@ -263,6 +279,120 @@ s32 IOS_ReloadIOSsafe(int ios) return r; } + + +s32 CheckForCIOS() +{ + gprintf("\n\tChecking for stub IOS"); + s32 ret = -1; + s32 ios222rev = getIOSrev(0x00000001000000dell); + s32 ios249rev = getIOSrev(0x00000001000000f9ll); + + //if we don't like either of the cIOS then scram + if (!(ios222rev==4 || ios222rev==5 || (ios249rev>=9 && ios249rev<65280))) + { + InitTextVideo(); + printf("\x1b[2J"); + if ((ios222rev < 0 && ios222rev != WII_EINSTALL) && (ios249rev < 0 && ios249rev != WII_EINSTALL)) { + printf("\n\n\n\tWARNING!"); + printf("\n\tUSB Loader GX needs unstubbed cIOS 222 v4 or 249 v9+"); + printf("\n\n\tWe cannot determine the versions on your system,\n\tsince you have no patched ios 36 or 236 installed."); + printf("\n\tTherefor, if loading of USB Loader GX fails, you\n\tprobably have installed the 4.2 update,"); + printf("\n\tand you should go figure out how to get some cios action going on\n\tin your Wii."); + printf("\n\n\tThis message will show every time."); + sleep(5); + } else { + printf("\n\n\n\tERROR!"); + printf("\n\tUSB Loader GX needs unstubbed cIOS 222 v4 or 249 v9+"); + printf("\n\n\tI found \n\t\t222 = %d%s",ios222rev,ios222rev==65280?" (Stubbed by 4.2 update)":""); + printf("\n\t\t249 = %d%s",ios249rev,ios249rev==65280?" (Stubbed by 4.2 update)":""); + printf("\n\n\tGo figure out how to get some cIOS action going on\n\tin your Wii and come back and see me."); + + sleep(15); + printf("\n\n\tBye"); + + USBDevice_deInit(); + exit(0); + } + } + + printf("\n\tReloading ios 249..."); + ret = IOS_ReloadIOSsafe(249); + + printf("%d", ret); + + if (ret < 0) + { + printf("\n\tIOS 249 failed, reloading ios 222..."); + ret = IOS_ReloadIOSsafe(222); + printf("%d", ret); + if (ret < 0) { + printf("\n\tIOS 222 failed, reloading ios 250..."); + ret = IOS_ReloadIOSsafe(250); + printf("%d", ret); + if (ret < 0) { + printf("\n\tERROR: cIOS could not be loaded!\n"); + sleep(5); + SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); + } + } + else + { + //only for 222 loading ehc modules + printf("\n\tLoad ehc module"); + load_ehc_module(); + } + } + + return ret; +} + +int LoadAppCIOS() +{ + s32 ret = 1; + /* Load Custom IOS */ + if (Settings.cios == ios222 && IOS_GetVersion() != 222) + { + printf("\n\tReloading IOS to config setting (%d)...", ios222 ? 222 : 223); + SDCard_deInit();// unmount SD for reloading IOS + USBDevice_deInit();// unmount USB for reloading IOS + USBStorage_Deinit(); + ret = IOS_ReloadIOSsafe(ios222 ? 222 : 223); + printf("%d", ret); + if (ret < 0) + { + Settings.cios = ios249; + IOS_ReloadIOSsafe(249); + } + + SDCard_Init(); + USBDevice_Init(); // and mount USB:/ + if(ret >= 0) + load_ehc_module(); + } + else if ((Settings.cios == ios249 && IOS_GetVersion() != 249) || + (Settings.cios == ios250 && IOS_GetVersion() != 250)) + { + printf("\n\tReloading IOS to config setting (%d)...", ios249 ? 249 : 250); + SDCard_deInit();// unmount SD for reloading IOS + USBDevice_deInit();// unmount USB for reloading IOS + USBStorage_Deinit(); + ret = IOS_ReloadIOSsafe(ios249 ? 249 : 250); + printf("%d", ret); + if (ret < 0) { + Settings.cios = ios222; + ret = IOS_ReloadIOSsafe(222); + SDCard_Init(); + load_ehc_module(); + } + + else SDCard_Init(); // now mount SD:/ //no need to keep mindlessly mounting and unmounting SD card + USBDevice_Init(); // and mount USB:/ + } + + return ret; +} + #include void ScreenShot() diff --git a/source/sys.h b/source/sys.h index 2ee89d1b..e2dd3169 100644 --- a/source/sys.h +++ b/source/sys.h @@ -13,6 +13,8 @@ void Sys_LoadMenu(void); void Sys_BackToLoader(void); int Sys_ChangeIos(int ios); int Sys_IosReload(int IOS); +s32 CheckForCIOS(); +int LoadAppCIOS(); bool Sys_IsHermes(); s32 IOS_ReloadIOSsafe(int ios); void ScreenShot(); diff --git a/source/themes/Theme_Downloader.cpp b/source/themes/Theme_Downloader.cpp index b1d00630..e3109dc5 100644 --- a/source/themes/Theme_Downloader.cpp +++ b/source/themes/Theme_Downloader.cpp @@ -24,16 +24,10 @@ #include "ZipFile.h" #include "gecko.h" -/*** Extern functions ***/ -extern void ResumeGui(); -extern void HaltGui(); - /*** Extern variables ***/ extern GuiWindow * mainWindow; extern GuiSound * bgMusic; extern GuiImage * bgImg; -extern u8 shutdown; -extern u8 reset; int DownloadTheme(const char *url, const char *title) @@ -245,11 +239,6 @@ static int Theme_Prompt(const char *title, const char *author, GuiImageData *thu { VIDEO_WaitVSync(); - if (shutdown == 1) - Sys_Shutdown(); - else if (reset == 1) - Sys_Reboot(); - if (downloadBtn.GetState() == STATE_CLICKED) { int choice = WindowPrompt(tr("Do you want to download this theme?"), title, tr("Yes"), tr("Cancel")); @@ -579,12 +568,7 @@ int Theme_Downloader() { VIDEO_WaitVSync (); - if (shutdown == 1) - Sys_Shutdown(); - else if (reset == 1) - Sys_Reboot(); - - else if (wifiBtn.GetState() == STATE_CLICKED) + if (wifiBtn.GetState() == STATE_CLICKED) { Initialize_Network(); wifiBtn.ResetState(); diff --git a/source/usbloader/getentries.cpp b/source/usbloader/getentries.cpp index afd54079..e6328f95 100644 --- a/source/usbloader/getentries.cpp +++ b/source/usbloader/getentries.cpp @@ -9,6 +9,7 @@ #include "../prompts/TitleBrowser.h" +#include "../gecko.h" #include "wad/wad.h" #include "xml/xml.h" #include "../wad/title.h" @@ -50,9 +51,9 @@ static inline int wcsnicmp(const wchar_t *s1, const wchar_t *s2, int len) if (*s1++ == 0) break; } while (--len != 0); - + return (0); -} +} /**************************************************************************** @@ -131,7 +132,7 @@ int __Menu_GetPrevFilter(int t, wchar_t* gameFilter, u32 gameFiltered, wchar_t * struct discHdr *buffer = NULL; u32 cnt, len, i; s32 ret; - + wchar_t *new_gameFilterPrev = wcsdup_new(gameFilter); @@ -182,8 +183,8 @@ int __Menu_GetPrevFilter(int t, wchar_t* gameFilter, u32 gameFiltered, wchar_t * { // Check game rating in WiiTDB, since the default Wii parental control setting is enabled s32 rating = GetRatingForGame((char *) header->id); - - if ((rating != -1 && rating > Settings.parental.rating) || + + if ((rating != -1 && rating > Settings.parental.rating) || (rating == -1 && get_pegi_block(header) > Settings.parental.rating)) { continue; @@ -193,7 +194,7 @@ int __Menu_GetPrevFilter(int t, wchar_t* gameFilter, u32 gameFiltered, wchar_t * wchar_t *wname = FreeTypeGX::charToWideChar(get_title(header)); if(wname) nameList.push_back(wname); } - + NewTitles::Instance()->Save(); /* delete buffer */ @@ -225,7 +226,7 @@ int __Menu_GetPrevFilter(int t, wchar_t* gameFilter, u32 gameFiltered, wchar_t * /**************************************************************************** * Get GameFilter NextList ***************************************************************************/ - + int int_cmp(const void *a, const void *b) { return *((u32*)a)-*((u32*)b); } int __Menu_GetGameFilter_NextList(discHdr *gameList, u32 gameCnt, wchar_t **PgameFilter, wchar_t **PgameFilterNextList) @@ -248,15 +249,15 @@ int __Menu_GetGameFilter_NextList(discHdr *gameList, u32 gameCnt, wchar_t **Pgam } else if(wcslen(gameName) == filter_len) autofill = false; // no autofill when gameNameLen == filterLen - + nextList[i] = nextFilterChar; } qsort(nextList, gameCnt, sizeof(u32), int_cmp); - + *PgameFilterNextList = new wchar_t[gameCnt+1]; if(*PgameFilterNextList == NULL) goto error; - - + + p = *PgameFilterNextList; lastChar = 0; for(i=0; iid[4]='1'; header->id[5]=(i - + //not using these filters right now, but i left them in just in case // Filters /*if (Settings.fave) { @@ -401,32 +402,32 @@ int buildTitleList(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *PgameC if (!game_num || game_num->favorite==0) continue; } - + if (Settings.parentalcontrol && !Settings.godmode) { if (get_block(header) >= Settings.parentalcontrol) continue; }*/ - - if(gameFilter && *gameFilter) { + + /*if(gameFilter && *gameFilter) { u32 filter_len = wcslen(gameFilter); wchar_t *gameName = FreeTypeGX::charToWideChar(get_title(header)); if (!gameName || wcsnicmp(gameName, gameFilter, filter_len)) { delete [] gameName; continue; } - } + }*/ if(i != cnt2) buffer[cnt2] = buffer[i]; cnt2++; } i++; } - + if (f)fclose(f); Uninstall_FromTitle(TITLE_ID(1, 0)); ISFS_Deinitialize(); - + if(cnt > cnt2) { cnt = cnt2; @@ -434,7 +435,7 @@ int buildTitleList(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *PgameC } if (!buffer) return -1; - + if (Settings.sort==pcount) { qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmpCount); } else if (Settings.fave) { @@ -445,12 +446,12 @@ int buildTitleList(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *PgameC /*PgameList = buffer; buffer = NULL; PgameCnt = cnt;*/ - + if(PgameList) *PgameList = buffer; else free(buffer); if(PgameCnt) *PgameCnt = cnt; - + return 0; - + return cnt; } @@ -469,7 +470,7 @@ int __Menu_GetGameList(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *Pg ret = WBFS_GetCount(&cnt); if (ret < 0) return ret; - +//gprintf("\n WBFS_GetCount:%d",cnt); /* Buffer length */ len = sizeof(struct discHdr) * cnt; @@ -487,7 +488,7 @@ int __Menu_GetGameList(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *Pg if (buffer) free(buffer); return ret; } - + for (u32 i = 0; i < cnt; i++) { struct discHdr *header = &buffer[i]; @@ -506,7 +507,7 @@ int __Menu_GetGameList(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *Pg header->id[2]=='C'&&header->id[3]=='F'&& header->id[4]=='G'&&header->id[5]=='_') continue; - + if (Settings.parentalcontrol && !Settings.godmode && t==0) { if (get_block(header) >= Settings.parentalcontrol) continue; @@ -517,13 +518,13 @@ int __Menu_GetGameList(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *Pg { // Check game rating in WiiTDB, since the default Wii parental control setting is enabled s32 rating = GetRatingForGame((char *) header->id); - if ((rating != -1 && rating > Settings.parental.rating) || + if ((rating != -1 && rating > Settings.parental.rating) || (rating == -1 && get_pegi_block(header) > Settings.parental.rating)) { continue; } } - + if(gameFilter && *gameFilter && t==0) { u32 filter_len = wcslen(gameFilter); wchar_t *gameName = FreeTypeGX::charToWideChar(get_title(header)); @@ -537,7 +538,7 @@ int __Menu_GetGameList(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *Pg cnt2++; } NewTitles::Instance()->Save(); - + if(cnt > cnt2) { cnt = cnt2; @@ -545,7 +546,7 @@ int __Menu_GetGameList(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *Pg } if (!buffer) return -1; - + if (Settings.sort==pcount) { qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmpCount); } else if (Settings.fave) { @@ -557,18 +558,18 @@ int __Menu_GetGameList(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *Pg /* Set values */ if(PgameList) *PgameList = buffer; else free(buffer); if(PgameCnt) *PgameCnt = cnt; - + return 0; } int __Menu_GetEntries(int t, const wchar_t* Filter) { - +//gprintf("\n__Menu_GetEntries()"); /*if (mountMethod==3) - { + { return buildTitleList(); }*/ - - + + u32 new_gameCnt = 0; struct discHdr *new_gameList = NULL; wchar_t *new_gameFilter = NULL; @@ -576,32 +577,50 @@ int __Menu_GetEntries(int t, const wchar_t* Filter) { wchar_t *new_gameFilterPrev = NULL; new_gameFilter = wcsdup_new(Filter ? Filter : (gameFilter ? gameFilter : L"") ); - if(new_gameFilter == NULL) return -1; - + if(new_gameFilter == NULL) + { + //gprintf("\nnew_gameFilter == NULL"); + return -1; + } + for(;;) { if (mountMethod==3) - {if(buildTitleList(t, new_gameFilter, &new_gameList, &new_gameCnt) < 0) - return -1;} - - else - {if(__Menu_GetGameList(t, new_gameFilter, &new_gameList, &new_gameCnt) < 0) - return -1;} - - + {int butt =buildTitleList(t, new_gameFilter, &new_gameList, &new_gameCnt); + if (butt < 0) + { + gprintf("\nbutt:%d", butt); + return -1; + } + } + + else + { + if(__Menu_GetGameList(t, new_gameFilter, &new_gameList, &new_gameCnt) < 0) + { + gprintf("\n__Menu_GetGameList(t, new_gameFilter, &new_gameList, &new_gameCnt) < 0"); + return -1; + } + } + + if(new_gameCnt > 0 || new_gameFilter[0] == 0) + { + //gprintf("\nnew_gameCnt:%d",new_gameCnt); break; + } new_gameFilter[wcslen(new_gameFilter)-1] = 0; } + if (mountMethod!=3) + { + /* init GameFilterNextList */ + if(__Menu_GetGameFilter_NextList(new_gameList, new_gameCnt, &new_gameFilter, &new_gameFilterNextList) < 0) + goto error; - /* init GameFilterNextList */ - if(__Menu_GetGameFilter_NextList(new_gameList, new_gameCnt, &new_gameFilter, &new_gameFilterNextList) < 0) - goto error; - - /* init GameFilterPrev */ - if(__Menu_GetPrevFilter(t, new_gameFilter, new_gameCnt, &new_gameFilterPrev) < 0) - goto error; - + /* init GameFilterPrev */ + if(__Menu_GetPrevFilter(t, new_gameFilter, new_gameCnt, &new_gameFilterPrev) < 0) + goto error; + } /* Set values */ if(gameList) free(gameList); if(gameFilter) delete [] gameFilter; @@ -610,14 +629,19 @@ int __Menu_GetEntries(int t, const wchar_t* Filter) { gameList = new_gameList; gameCnt = new_gameCnt; - gameFilter = new_gameFilter; - gameFilterNextList = new_gameFilterNextList; - gameFilterPrev = new_gameFilterPrev; + gameFilter = new_gameFilter; + gameFilterNextList = new_gameFilterNextList; + gameFilterPrev = new_gameFilterPrev; - /* Reset variables */ + + /* Reset variables */ gameSelected = gameStart = 0; - return 0; + //gprintf("\ncnt:%d", gameCnt); + + + return 0; error: // clean up + gprintf("\nERROR"); if(new_gameList) free(new_gameList); if(new_gameFilter) delete [] new_gameFilter; if(new_gameFilterNextList) delete [] new_gameFilterNextList; diff --git a/source/video.cpp b/source/video.cpp index c82226cc..b5a67a36 100644 --- a/source/video.cpp +++ b/source/video.cpp @@ -30,6 +30,9 @@ int screenheight; int screenwidth; u32 frameCount = 0; +extern bool textVideoInit; +extern bool geckoinit; + u8 * gameScreenTex = NULL; // a GX texture screen capture of the game u8 * gameScreenTex2 = NULL; // a GX texture screen capture of the game (copy) @@ -198,6 +201,46 @@ InitVideo () { ResetVideo_Menu(); // Finally, the video is up and ready for use :) } + +void InitTextVideo () +{ + unsigned int *xfb = NULL; + gprintf("\nInitTextVideo ()"); + if (textVideoInit) + { + gprintf("...0"); + return; + } + + VIDEO_Init(); + GXRModeObj *vmode = VIDEO_GetPreferredMode(NULL); // get default video mode + + // widescreen fix + VIDEO_Configure (vmode); + + // Allocate the video buffers + xfb = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode)); + + // A console is always useful while debugging + console_init (xfb, 20, 64, vmode->fbWidth, vmode->xfbHeight, vmode->fbWidth * 2); + + // Clear framebuffers etc. + VIDEO_ClearFrameBuffer (vmode, xfb, COLOR_BLACK); + VIDEO_SetNextFramebuffer (xfb); + + VIDEO_SetBlack (FALSE); + VIDEO_Flush (); + VIDEO_WaitVSync (); + if (vmode->viTVMode & VI_NON_INTERLACE) + VIDEO_WaitVSync (); + + //send console output to the gecko + if (geckoinit)CON_EnableGecko(1, true); + textVideoInit = true; + gprintf("...1"); + +} + static unsigned int *xfbDB = NULL; void InitVideodebug () { @@ -241,8 +284,8 @@ void StopGX() { * * Renders everything current sent to GX, and flushes video ***************************************************************************/ -void Menu_Render() { - +void Menu_Render() +{ whichfb ^= 1; // flip framebuffer GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); GX_SetColorUpdate(GX_TRUE); @@ -492,6 +535,13 @@ void Menu_DrawTPLImg(f32 xpos, f32 ypos, f32 zpos, f32 width, f32 height, GXTexO ***************************************************************************/ s32 TakeScreenshot(const char *path) { + //check if it is possible to write + FILE *f = fopen(path, "wb"); + if(!f) + return -1; + else + fclose(f); + gprintf("\nTakeScreenshot(%s)", path); IMGCTX ctx = PNGU_SelectImageFromDevice (path); s32 ret = PNGU_EncodeFromYCbYCr(ctx,vmode->fbWidth, vmode->efbHeight,xfb[whichfb],0); @@ -499,3 +549,4 @@ s32 TakeScreenshot(const char *path) gprintf(":%d", ret); return 1; } + diff --git a/source/video.h b/source/video.h index 205f9950..e4f2e3bb 100644 --- a/source/video.h +++ b/source/video.h @@ -13,6 +13,7 @@ void InitVideo (); void InitVideodebug(); +void InitTextVideo(); void StopGX(); void ResetVideo_Menu(); void Menu_Render(); diff --git a/source/wad/wad.cpp b/source/wad/wad.cpp index 56f353ed..78920731 100644 --- a/source/wad/wad.cpp +++ b/source/wad/wad.cpp @@ -8,22 +8,15 @@ #include "utils.h" #include "video.h" #include "wad.h" - - - #include "prompts/PromptWindows.h" #include "libwiigui/gui.h" #include "language/gettext.h" #include "menu.h" #include "filelist.h" -/*** Extern functions ***/ -extern void ResumeGui(); -extern void HaltGui(); + /*** Extern variables ***/ extern GuiWindow * mainWindow; - - /* 'WAD Header' structure */ typedef struct { /* Header length */ @@ -347,9 +340,9 @@ s32 Wad_Install(FILE *fp) snprintf(imgPath, sizeof(imgPath), "%s%d...",tr(">> Installing content #"),content->cid); msg4Txt.SetText(imgPath); // Install content data - while (idx < len) { - - //VIDEO_WaitVSync (); + while (idx < len) { + + //VIDEO_WaitVSync (); u32 size; @@ -371,7 +364,7 @@ s32 Wad_Install(FILE *fp) // Increase variables idx += size; offset += size; - + //snprintf(imgPath, sizeof(imgPath), "%s%d (%d)...",tr(">> Installing content #"),content->cid,idx); //msg4Txt.SetText(imgPath);