2009-05-24 20:52:51 +02:00
/****************************************************************************
2009-06-06 19:26:52 +02:00
* USB Loader GX Team
*
2009-05-23 00:08:50 +02:00
* libwiigui Template
2009-06-06 19:26:52 +02:00
* by Tantric 2009
2009-05-23 00:08:50 +02:00
*
* menu . cpp
* Menu flow routines - handles all menu logic
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# include <unistd.h>
# include <string.h>
# include <stdio.h> //CLOCK
2009-06-05 00:13:39 +02:00
# include <time.h>
2009-05-23 00:08:50 +02:00
# include "libwiigui/gui.h"
2009-06-05 00:13:39 +02:00
# include "libwiigui/gui_gamegrid.h"
# include "libwiigui/gui_gamecarousel.h"
# include "libwiigui/gui_gamebrowser.h"
2009-06-13 02:24:36 +02:00
# include "usbloader/usbstorage.h"
# include "usbloader/wbfs.h"
# include "usbloader/disc.h"
# include "usbloader/getentries.h"
2009-06-23 20:59:28 +02:00
# include "language/gettext.h"
2009-06-13 02:24:36 +02:00
# include "settings/Settings.h"
2009-07-19 11:10:25 +02:00
# include "homebrewboot/HomebrewBrowse.h"
# include "homebrewboot/BootHomebrew.h"
2009-06-13 02:24:36 +02:00
# include "prompts/PromptWindows.h"
2009-07-25 11:39:01 +02:00
# include "prompts/filebrowser.h"
2009-07-05 22:22:29 +02:00
# include "prompts/ProgressWindow.h"
2009-07-25 11:39:01 +02:00
# include "prompts/TitleBrowser.h"
2009-06-13 02:24:36 +02:00
# include "prompts/gameinfo.h"
# include "mload/mload.h"
# include "patches/patchcode.h"
2009-06-17 22:44:00 +02:00
# include "network/networkops.h"
2009-07-15 19:20:45 +02:00
# include "cheats/cheatmenu.h"
2009-05-23 00:08:50 +02:00
# include "menu.h"
2009-06-01 17:50:18 +02:00
# include "audio.h"
2009-07-11 17:33:57 +02:00
# include "wad/wad.h"
2009-05-23 00:08:50 +02:00
# include "input.h"
# include "filelist.h"
# include "sys.h"
# include "wpad.h"
2009-05-30 18:58:34 +02:00
# include "listfiles.h"
2009-07-07 15:47:37 +02:00
# include "fatmounter.h"
2009-07-12 16:02:48 +02:00
# include "buffer.h"
2009-07-18 13:04:13 +02:00
# include "xml/xml.h"
2009-07-07 15:47:37 +02:00
# include "usbloader/wdvd.h"
2009-06-09 07:20:49 +02:00
2009-05-23 00:08:50 +02:00
# define MAX_CHARACTERS 38
2009-06-05 00:13:39 +02:00
/*** Variables that are also used extern ***/
GuiWindow * mainWindow = NULL ;
GuiImageData * pointer [ 4 ] ;
GuiImage * bgImg = NULL ;
GuiImageData * background = NULL ;
GuiSound * bgMusic = NULL ;
float gamesize ;
2009-06-25 14:47:09 +02:00
int currentMenu ;
int idiotFlag = - 1 ;
char idiotChar [ 50 ] ;
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
/*** Variables used only in menu.cpp ***/
2009-05-23 00:08:50 +02:00
static GuiImage * coverImg = NULL ;
static GuiImageData * cover = NULL ;
2009-06-01 15:35:43 +02:00
static GuiText * GameIDTxt = NULL ;
static GuiText * GameRegionTxt = NULL ;
2009-05-23 00:08:50 +02:00
static lwp_t guithread = LWP_THREAD_NULL ;
static bool guiHalt = true ;
2009-06-01 17:50:18 +02:00
static int ExitRequested = 0 ;
2009-05-23 00:08:50 +02:00
static char gameregion [ 7 ] ;
2009-06-05 00:13:39 +02:00
/*** Extern variables ***/
extern FreeTypeGX * fontClock ;
2009-05-23 00:08:50 +02:00
extern u8 shutdown ;
extern u8 reset ;
2009-06-05 00:13:39 +02:00
extern int cntMissFiles ;
extern struct discHdr * gameList ;
extern u32 gameCnt ;
extern s32 gameSelected , gameStart ;
2009-05-23 00:08:50 +02:00
extern const u8 data1 ;
2009-07-23 19:24:08 +02:00
extern u8 boothomebrew ;
extern bool updateavailable ;
2009-05-23 00:08:50 +02:00
/****************************************************************************
* ResumeGui
*
* Signals the GUI thread to start , and resumes the thread . This is called
* after finishing the removal / insertion of new elements , and after initial
* GUI setup .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-06-05 00:13:39 +02:00
void
2009-05-23 00:08:50 +02:00
ResumeGui ( )
{
guiHalt = false ;
LWP_ResumeThread ( guithread ) ;
}
/****************************************************************************
* HaltGui
*
* Signals the GUI thread to stop , and waits for GUI thread to stop
* This is necessary whenever removing / inserting new elements into the GUI .
* This eliminates the possibility that the GUI is in the middle of accessing
* an element that is being changed .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-06-05 00:13:39 +02:00
void
2009-05-23 00:08:50 +02:00
HaltGui ( )
{
guiHalt = true ;
// wait for thread to finish
while ( ! LWP_ThreadIsSuspended ( guithread ) )
usleep ( 50 ) ;
}
/****************************************************************************
2009-06-05 00:13:39 +02:00
* UpdateGUI
*
* Primary thread to allow GUI to respond to state changes , and draws GUI
2009-05-23 00:08:50 +02:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-07-05 22:22:29 +02:00
static void * UpdateGUI ( void * arg )
2009-05-23 00:08:50 +02:00
{
2009-06-05 00:13:39 +02:00
while ( 1 )
2009-05-23 00:08:50 +02:00
{
2009-06-05 00:13:39 +02:00
if ( guiHalt )
{
LWP_SuspendThread ( guithread ) ;
}
else
{
2009-06-13 11:51:01 +02:00
if ( ! ExitRequested ) {
2009-06-05 00:13:39 +02:00
mainWindow - > Draw ( ) ;
if ( Settings . tooltips = = TooltipsOn & & THEME . showToolTip ! = 0 & & mainWindow - > GetState ( ) ! = STATE_DISABLED )
mainWindow - > DrawTooltip ( ) ;
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
# ifdef HW_RVL
for ( int i = 3 ; i > = 0 ; i - - ) // so that player 1's cursor appears on top!
{
if ( userInput [ i ] . wpad . ir . valid )
Menu_DrawImg ( userInput [ i ] . wpad . ir . x - 48 , userInput [ i ] . wpad . ir . y - 48 , 200.0 ,
2009-06-10 12:05:43 +02:00
96 , 96 , pointer [ i ] - > GetImage ( ) , userInput [ i ] . wpad . ir . angle , CFG . widescreen ? 0.8 : 1 , 1 , 255 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) ;
2009-06-05 00:13:39 +02:00
if ( Settings . rumble = = RumbleOn )
{
DoRumble ( i ) ;
}
}
# endif
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
Menu_Render ( ) ;
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
for ( int i = 0 ; i < 4 ; i + + )
mainWindow - > Update ( & userInput [ i ] ) ;
2009-07-05 08:39:56 +02:00
2009-06-13 11:51:01 +02:00
} else {
2009-06-05 00:13:39 +02:00
for ( int a = 5 ; a < 255 ; a + = 10 )
{
mainWindow - > Draw ( ) ;
Menu_DrawRectangle ( 0 , 0 , screenwidth , screenheight , ( GXColor ) { 0 , 0 , 0 , a } , 1 ) ;
Menu_Render ( ) ;
}
2009-06-13 02:24:36 +02:00
mainWindow - > RemoveAll ( ) ;
2009-06-05 00:13:39 +02:00
ShutoffRumble ( ) ;
return 0 ;
}
}
2009-07-05 08:39:56 +02:00
2009-06-18 10:37:24 +02:00
switch ( Settings . screensaver )
{
case 1 :
WPad_SetIdleTime ( 180 ) ;
break ;
case 2 :
WPad_SetIdleTime ( 300 ) ;
break ;
case 3 :
WPad_SetIdleTime ( 600 ) ;
break ;
case 4 :
WPad_SetIdleTime ( 1200 ) ;
break ;
case 5 :
WPad_SetIdleTime ( 1800 ) ;
break ;
case 6 :
WPad_SetIdleTime ( 3600 ) ;
break ;
2009-06-18 18:09:45 +02:00
2009-06-18 10:37:24 +02:00
}
2009-06-18 18:09:45 +02:00
2009-06-18 10:37:24 +02:00
2009-06-01 15:35:43 +02:00
}
2009-06-05 00:13:39 +02:00
return NULL ;
2009-05-23 00:08:50 +02:00
}
/****************************************************************************
2009-06-05 00:13:39 +02:00
* InitGUIThread
2009-05-23 00:08:50 +02:00
*
2009-06-05 00:13:39 +02:00
* Startup GUI threads
2009-05-23 00:08:50 +02:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-06-05 00:13:39 +02:00
void InitGUIThreads ( )
2009-05-23 00:08:50 +02:00
{
2009-06-05 00:13:39 +02:00
LWP_CreateThread ( & guithread , UpdateGUI , NULL , NULL , 0 , 70 ) ;
2009-07-05 22:22:29 +02:00
InitProgressThread ( ) ;
2009-07-12 16:02:48 +02:00
InitBufferThread ( ) ;
2009-07-23 19:24:08 +02:00
InitNetworkThread ( ) ;
if ( Settings . autonetwork )
ResumeNetworkThread ( ) ;
2009-06-05 00:13:39 +02:00
}
2009-07-05 22:22:29 +02:00
2009-06-05 00:13:39 +02:00
void ExitGUIThreads ( )
{
ExitRequested = 1 ;
LWP_JoinThread ( guithread , NULL ) ;
2009-06-13 23:10:37 +02:00
guithread = LWP_THREAD_NULL ;
2009-06-05 00:13:39 +02:00
}
2009-05-23 00:08:50 +02:00
2009-06-09 07:20:49 +02:00
2009-06-05 00:13:39 +02:00
/****************************************************************************
* MenuDiscList
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-05-23 00:08:50 +02:00
2009-06-25 14:47:09 +02:00
int MenuDiscList ( )
2009-06-05 00:13:39 +02:00
{
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
int startat = 0 ;
int offset = 0 ;
int datag = 0 ;
int datagB = 0 ;
int dataed = - 1 ;
int cosa = 0 , sina = 0 ;
2009-06-09 07:20:49 +02:00
int selectImg1 = 0 ;
char ID [ 4 ] ;
char IDfull [ 7 ] ;
2009-07-07 15:47:37 +02:00
u32 covert = 0 ;
2009-07-20 16:20:27 +02:00
char imgPath [ 100 ] ;
2009-07-12 16:02:48 +02:00
2009-07-07 15:47:37 +02:00
WDVD_GetCoverStatus ( & covert ) ;
u32 covertOld = covert ;
2009-07-23 19:24:08 +02:00
2009-07-20 16:20:27 +02:00
//i put this here to take care of the disappearing cursors
//at least untill we know why they go away
# ifdef HW_RVL
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 ) ;
# endif
2009-07-07 15:47:37 +02:00
2009-06-18 18:09:45 +02:00
//SCREENSAVER
2009-06-18 10:37:24 +02:00
//WPad_SetIdleTime(300); //needs the time in seconds
2009-06-18 09:36:23 +02:00
int check = 0 ; //to skip the first cycle when wiimote isn't completely connected
2009-06-10 10:19:55 +02:00
2009-06-09 07:20:49 +02:00
datagB = 0 ;
int menu = MENU_NONE , dataef = 0 ;
__Menu_GetEntries ( ) ;
f32 freespace , used , size = 0.0 ;
u32 nolist ;
char text [ MAX_CHARACTERS + 4 ] ;
int choice = 0 , selectedold = 100 ;
s32 ret ;
//CLOCK
struct tm * timeinfo ;
char theTime [ 80 ] = " " ;
time_t lastrawtime = 0 ;
WBFS_DiskSpace ( & used , & freespace ) ;
2009-05-23 00:08:50 +02:00
2009-06-13 11:51:01 +02:00
if ( ! gameCnt ) { //if there is no list of games to display
nolist = 1 ;
}
2009-05-23 00:08:50 +02:00
2009-06-09 07:20:49 +02:00
GuiSound btnSoundOver ( button_over_pcm , button_over_pcm_size , SOUND_PCM , Settings . sfxvolume ) ;
GuiSound btnClick ( button_click2_pcm , button_click2_pcm_size , SOUND_PCM , Settings . sfxvolume ) ;
snprintf ( imgPath , sizeof ( imgPath ) , " %sbutton_install.png " , CFG . theme_path ) ;
GuiImageData btnInstall ( imgPath , button_install_png ) ;
snprintf ( imgPath , sizeof ( imgPath ) , " %sbutton_install_over.png " , CFG . theme_path ) ;
GuiImageData btnInstallOver ( imgPath , button_install_over_png ) ;
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.png " , CFG . theme_path ) ;
GuiImageData btnsdcard ( imgPath , sdcard_png ) ;
snprintf ( imgPath , sizeof ( imgPath ) , " %sbattery.png " , CFG . theme_path ) ;
GuiImageData battery ( imgPath , battery_png ) ;
snprintf ( imgPath , sizeof ( imgPath ) , " %sbattery_red.png " , CFG . theme_path ) ;
GuiImageData batteryRed ( imgPath , battery_red_png ) ;
snprintf ( imgPath , sizeof ( imgPath ) , " %sbattery_bar.png " , CFG . theme_path ) ;
GuiImageData batteryBar ( imgPath , battery_bar_png ) ;
2009-05-23 00:08:50 +02:00
2009-06-13 11:51:01 +02:00
snprintf ( imgPath , sizeof ( imgPath ) , " %sfavIcon.png " , CFG . theme_path ) ;
2009-06-09 07:20:49 +02:00
GuiImageData imgfavIcon ( imgPath , favIcon_png ) ;
2009-06-13 11:51:01 +02:00
snprintf ( imgPath , sizeof ( imgPath ) , " %sfavIcon_gray.png " , CFG . theme_path ) ;
2009-06-09 07:20:49 +02:00
GuiImageData imgfavIcon_gray ( imgPath , favIcon_gray_png ) ;
2009-06-13 11:51:01 +02:00
snprintf ( imgPath , sizeof ( imgPath ) , " %sabcIcon.png " , CFG . theme_path ) ;
2009-06-09 07:20:49 +02:00
GuiImageData imgabcIcon ( imgPath , abcIcon_png ) ;
2009-06-13 11:51:01 +02:00
snprintf ( imgPath , sizeof ( imgPath ) , " %sabcIcon_gray.png " , CFG . theme_path ) ;
2009-06-09 07:20:49 +02:00
GuiImageData imgabcIcon_gray ( imgPath , abcIcon_gray_png ) ;
snprintf ( imgPath , sizeof ( imgPath ) , " %splayCountIcon.png " , CFG . theme_path ) ;
GuiImageData imgplayCountIcon ( imgPath , playCountIcon_png ) ;
snprintf ( imgPath , sizeof ( imgPath ) , " %splayCountIcon_gray.png " , CFG . theme_path ) ;
GuiImageData imgplayCountIcon_gray ( imgPath , playCountIcon_gray_png ) ;
snprintf ( imgPath , sizeof ( imgPath ) , " %sarrangeGrid.png " , CFG . theme_path ) ;
GuiImageData imgarrangeGrid ( imgPath , arrangeGrid_png ) ;
snprintf ( imgPath , sizeof ( imgPath ) , " %sarrangeGrid_gray.png " , CFG . theme_path ) ;
GuiImageData imgarrangeGrid_gray ( imgPath , arrangeGrid_gray_png ) ;
snprintf ( imgPath , sizeof ( imgPath ) , " %sarrangeList.png " , CFG . theme_path ) ;
GuiImageData imgarrangeList ( imgPath , arrangeList_png ) ;
snprintf ( imgPath , sizeof ( imgPath ) , " %sarrangeList_gray.png " , CFG . theme_path ) ;
GuiImageData imgarrangeList_gray ( imgPath , arrangeList_gray_png ) ;
snprintf ( imgPath , sizeof ( imgPath ) , " %sarrangeCarousel.png " , CFG . theme_path ) ;
GuiImageData imgarrangeCarousel ( imgPath , arrangeCarousel_png ) ;
snprintf ( imgPath , sizeof ( imgPath ) , " %sarrangeCarousel_gray.png " , CFG . theme_path ) ;
GuiImageData imgarrangeCarousel_gray ( imgPath , arrangeCarousel_gray_png ) ;
2009-07-20 09:23:30 +02:00
snprintf ( imgPath , sizeof ( imgPath ) , " %sbrowser.png " , CFG . theme_path ) ;
GuiImageData homebrewImgData ( imgPath , browser_png ) ;
2009-07-23 19:24:08 +02:00
2009-05-23 00:08:50 +02:00
2009-06-13 11:51:01 +02:00
GuiTrigger trigA ;
2009-06-09 07:20:49 +02:00
trigA . SetSimpleTrigger ( - 1 , WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A , PAD_BUTTON_A ) ;
2009-06-13 11:51:01 +02:00
GuiTrigger trigHome ;
2009-06-09 07:20:49 +02:00
trigHome . SetButtonOnlyTrigger ( - 1 , WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME , 0 ) ;
2009-06-13 11:51:01 +02:00
GuiTrigger trig2 ;
trig2 . SetButtonOnlyTrigger ( - 1 , WPAD_BUTTON_2 | WPAD_CLASSIC_BUTTON_X , 0 ) ;
2009-06-25 18:41:02 +02:00
GuiTrigger trig1 ;
trig1 . SetButtonOnlyTrigger ( - 1 , WPAD_BUTTON_1 | WPAD_CLASSIC_BUTTON_Y , 0 ) ;
2009-06-09 07:20:49 +02:00
2009-05-23 00:08:50 +02:00
2009-06-13 11:51:01 +02:00
char spaceinfo [ 30 ] ;
2009-06-23 20:59:28 +02:00
sprintf ( spaceinfo , " %.2fGB %s %.2fGB %s " , freespace , tr ( " of " ) , ( freespace + used ) , tr ( " free " ) ) ;
2009-06-09 07:20:49 +02:00
GuiText usedSpaceTxt ( spaceinfo , 18 , ( GXColor ) { THEME . info_r , THEME . info_g , THEME . info_b , 255 } ) ;
usedSpaceTxt . SetAlignment ( THEME . hddInfoAlign , ALIGN_TOP ) ;
usedSpaceTxt . SetPosition ( THEME . hddInfo_x , THEME . hddInfo_y ) ;
char GamesCnt [ 15 ] ;
2009-06-23 20:59:28 +02:00
sprintf ( GamesCnt , " %s: %i " , tr ( " Games " ) , gameCnt ) ;
2009-06-09 07:20:49 +02:00
GuiText gamecntTxt ( GamesCnt , 18 , ( GXColor ) { THEME . info_r , THEME . info_g , THEME . info_b , 255 } ) ;
gamecntTxt . SetAlignment ( THEME . gameCntAlign , ALIGN_TOP ) ;
gamecntTxt . SetPosition ( THEME . gameCnt_x , THEME . gameCnt_y ) ;
2009-06-23 20:59:28 +02:00
GuiTooltip installBtnTT ( tr ( " Install a game " ) ) ;
2009-06-09 07:20:49 +02:00
if ( Settings . wsprompt = = yes )
installBtnTT . SetWidescreen ( CFG . widescreen ) ;
2009-06-20 12:10:40 +02:00
installBtnTT . SetAlpha ( THEME . tooltipAlpha ) ;
2009-06-09 07:20:49 +02:00
GuiImage installBtnImg ( & btnInstall ) ;
GuiImage installBtnImgOver ( & btnInstallOver ) ;
installBtnImg . SetWidescreen ( CFG . widescreen ) ;
installBtnImgOver . SetWidescreen ( CFG . widescreen ) ;
GuiButton installBtn ( & installBtnImg , & installBtnImgOver , ALIGN_LEFT , ALIGN_TOP , THEME . install_x , THEME . install_y , & trigA , & btnSoundOver , & btnClick , 1 , & installBtnTT , 24 , - 30 , 0 , 5 ) ;
2009-06-23 20:59:28 +02:00
GuiTooltip settingsBtnTT ( tr ( " Settings " ) ) ;
2009-06-09 07:20:49 +02:00
if ( Settings . wsprompt = = yes )
settingsBtnTT . SetWidescreen ( CFG . widescreen ) ;
2009-06-20 12:10:40 +02:00
settingsBtnTT . SetAlpha ( THEME . tooltipAlpha ) ;
2009-06-09 07:20:49 +02:00
GuiImage settingsBtnImg ( & btnSettings ) ;
settingsBtnImg . SetWidescreen ( CFG . widescreen ) ;
GuiImage settingsBtnImgOver ( & btnSettingsOver ) ;
settingsBtnImgOver . SetWidescreen ( CFG . widescreen ) ;
GuiButton settingsBtn ( & settingsBtnImg , & settingsBtnImgOver , 0 , 3 , THEME . setting_x , THEME . setting_y , & trigA , & btnSoundOver , & btnClick , 1 , & settingsBtnTT , 65 , - 30 , 0 , 5 ) ;
2009-06-23 20:59:28 +02:00
GuiTooltip homeBtnTT ( tr ( " Back to HBC or Wii Menu " ) ) ;
2009-06-09 07:20:49 +02:00
if ( Settings . wsprompt = = yes )
homeBtnTT . SetWidescreen ( CFG . widescreen ) ;
GuiImage homeBtnImg ( & btnhome ) ;
homeBtnImg . SetWidescreen ( CFG . widescreen ) ;
GuiImage homeBtnImgOver ( & btnhomeOver ) ;
homeBtnImgOver . SetWidescreen ( CFG . widescreen ) ;
GuiButton homeBtn ( & homeBtnImg , & homeBtnImgOver , 0 , 3 , THEME . home_x , THEME . home_y , & trigA , & btnSoundOver , & btnClick , 1 , & homeBtnTT , 15 , - 30 , 1 , 5 ) ;
homeBtn . RemoveSoundClick ( ) ;
homeBtn . SetTrigger ( & trigHome ) ;
2009-06-23 20:59:28 +02:00
GuiTooltip poweroffBtnTT ( tr ( " Power off the Wii " ) ) ;
2009-06-09 07:20:49 +02:00
if ( Settings . wsprompt = = yes )
poweroffBtnTT . SetWidescreen ( CFG . widescreen ) ;
2009-06-20 12:10:40 +02:00
poweroffBtnTT . SetAlpha ( THEME . tooltipAlpha ) ;
2009-06-13 11:51:01 +02:00
GuiImage poweroffBtnImg ( & btnpwroff ) ;
2009-06-09 07:20:49 +02:00
GuiImage poweroffBtnImgOver ( & btnpwroffOver ) ;
poweroffBtnImg . SetWidescreen ( CFG . widescreen ) ;
poweroffBtnImgOver . SetWidescreen ( CFG . widescreen ) ;
GuiButton poweroffBtn ( & poweroffBtnImg , & poweroffBtnImgOver , 0 , 3 , THEME . power_x , THEME . power_y , & trigA , & btnSoundOver , & btnClick , 1 , & poweroffBtnTT , - 10 , - 30 , 1 , 5 ) ;
2009-06-23 20:59:28 +02:00
GuiTooltip sdcardBtnTT ( tr ( " Reload SD " ) ) ;
2009-06-09 07:20:49 +02:00
if ( Settings . wsprompt = = yes )
sdcardBtnTT . SetWidescreen ( CFG . widescreen ) ;
2009-06-20 12:10:40 +02:00
sdcardBtnTT . SetAlpha ( THEME . tooltipAlpha ) ;
2009-06-09 07:20:49 +02:00
GuiImage sdcardImg ( & btnsdcard ) ;
sdcardImg . SetWidescreen ( CFG . widescreen ) ;
GuiButton sdcardBtn ( & sdcardImg , & sdcardImg , 0 , 3 , THEME . sdcard_x , THEME . sdcard_y , & trigA , & btnSoundOver , & btnClick , 1 , & sdcardBtnTT , 15 , - 30 , 0 , 5 ) ;
GuiButton gameInfo ( 0 , 0 ) ;
gameInfo . SetTrigger ( & trig2 ) ;
gameInfo . SetSoundClick ( & btnClick ) ;
2009-06-10 10:19:55 +02:00
2009-06-09 07:20:49 +02:00
GuiImage wiiBtnImg ( & dataID ) ;
wiiBtnImg . SetWidescreen ( CFG . widescreen ) ;
GuiButton wiiBtn ( & wiiBtnImg , & wiiBtnImg , 0 , 4 , 0 , - 10 , & trigA , & btnSoundOver , & btnClick , 0 ) ;
GuiImage favoriteBtnImg ( & imgfavIcon ) ;
GuiImage favoriteBtnImg_g ( & imgfavIcon_gray ) ;
favoriteBtnImg . SetWidescreen ( CFG . widescreen ) ;
favoriteBtnImg_g . SetWidescreen ( CFG . widescreen ) ;
GuiButton favoriteBtn ( & favoriteBtnImg_g , & favoriteBtnImg_g , 2 , 3 , THEME . favorite_x , THEME . favorite_y , & trigA , & btnSoundOver , & btnClick , 1 ) ;
favoriteBtn . SetAlpha ( 180 ) ;
GuiImage abcBtnImg ( & imgabcIcon ) ;
abcBtnImg . SetWidescreen ( CFG . widescreen ) ;
GuiImage abcBtnImg_g ( & imgabcIcon_gray ) ;
abcBtnImg_g . SetWidescreen ( CFG . widescreen ) ;
GuiButton abcBtn ( & abcBtnImg_g , & abcBtnImg_g , 2 , 3 , THEME . abc_x , THEME . abc_y , & trigA , & btnSoundOver , & btnClick , 1 ) ;
abcBtn . SetAlpha ( 180 ) ;
GuiImage countBtnImg ( & imgplayCountIcon ) ;
countBtnImg . SetWidescreen ( CFG . widescreen ) ;
GuiImage countBtnImg_g ( & imgplayCountIcon_gray ) ;
countBtnImg_g . SetWidescreen ( CFG . widescreen ) ;
GuiButton countBtn ( & countBtnImg_g , & countBtnImg_g , 2 , 3 , THEME . count_x , THEME . count_y , & trigA , & btnSoundOver , & btnClick , 1 ) ;
countBtn . SetAlpha ( 180 ) ;
GuiImage listBtnImg ( & imgarrangeList ) ;
listBtnImg . SetWidescreen ( CFG . widescreen ) ;
GuiImage listBtnImg_g ( & imgarrangeList_gray ) ;
listBtnImg_g . SetWidescreen ( CFG . widescreen ) ;
GuiButton listBtn ( & listBtnImg_g , & listBtnImg_g , 2 , 3 , THEME . list_x , THEME . list_y , & trigA , & btnSoundOver , & btnClick , 1 ) ;
listBtn . SetAlpha ( 180 ) ;
GuiImage gridBtnImg ( & imgarrangeGrid ) ;
gridBtnImg . SetWidescreen ( CFG . widescreen ) ;
GuiImage gridBtnImg_g ( & imgarrangeGrid_gray ) ;
gridBtnImg_g . SetWidescreen ( CFG . widescreen ) ;
GuiButton gridBtn ( & gridBtnImg_g , & gridBtnImg_g , 2 , 3 , THEME . grid_x , THEME . grid_y , & trigA , & btnSoundOver , & btnClick , 1 ) ;
gridBtn . SetAlpha ( 180 ) ;
GuiImage carouselBtnImg ( & imgarrangeCarousel ) ;
carouselBtnImg . SetWidescreen ( CFG . widescreen ) ;
GuiImage carouselBtnImg_g ( & imgarrangeCarousel_gray ) ;
carouselBtnImg_g . SetWidescreen ( CFG . widescreen ) ;
GuiButton carouselBtn ( & carouselBtnImg_g , & carouselBtnImg_g , 2 , 3 , THEME . carousel_x , THEME . carousel_y , & trigA , & btnSoundOver , & btnClick , 1 ) ;
carouselBtn . SetAlpha ( 180 ) ;
2009-07-20 09:23:30 +02:00
GuiImage homebrewBtnImg ( & homebrewImgData ) ;
2009-07-19 11:10:25 +02:00
homebrewBtnImg . SetWidescreen ( CFG . widescreen ) ;
GuiButton homebrewBtn ( homebrewBtnImg . GetWidth ( ) , homebrewBtnImg . GetHeight ( ) ) ;
homebrewBtn . SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
2009-07-25 11:39:01 +02:00
homebrewBtn . SetPosition ( THEME . homebrew_x , THEME . homebrew_y ) ;
2009-07-19 11:10:25 +02:00
homebrewBtn . SetImage ( & homebrewBtnImg ) ;
homebrewBtn . SetSoundOver ( & btnSoundOver ) ;
homebrewBtn . SetSoundClick ( & btnClick ) ;
homebrewBtn . SetEffectGrow ( ) ;
homebrewBtn . SetTrigger ( & trigA ) ;
2009-06-09 07:20:49 +02:00
if ( Settings . fave )
{
favoriteBtn . SetImage ( & favoriteBtnImg ) ;
favoriteBtn . SetImageOver ( & favoriteBtnImg ) ;
favoriteBtn . SetAlpha ( 255 ) ;
}
if ( Settings . sort = = all )
{
abcBtn . SetImage ( & abcBtnImg ) ;
abcBtn . SetImageOver ( & abcBtnImg ) ;
abcBtn . SetAlpha ( 255 ) ;
}
else if ( Settings . sort = = pcount )
{
countBtn . SetImage ( & countBtnImg ) ;
countBtn . SetImageOver ( & countBtnImg ) ;
countBtn . SetAlpha ( 255 ) ;
}
if ( Settings . gameDisplay = = list )
{
listBtn . SetImage ( & listBtnImg ) ;
listBtn . SetImageOver ( & listBtnImg ) ;
listBtn . SetAlpha ( 255 ) ;
}
else if ( Settings . gameDisplay = = grid )
{
gridBtn . SetImage ( & gridBtnImg ) ;
gridBtn . SetImageOver ( & gridBtnImg ) ;
gridBtn . SetAlpha ( 255 ) ;
}
else if ( Settings . gameDisplay = = carousel )
{
carouselBtn . SetImage ( & carouselBtnImg ) ;
carouselBtn . SetImageOver ( & carouselBtnImg ) ;
carouselBtn . SetAlpha ( 255 ) ;
}
if ( Settings . gameDisplay = = list )
{
if ( CFG . widescreen )
{
favoriteBtn . SetPosition ( THEME . favorite_x , THEME . favorite_y ) ;
abcBtn . SetPosition ( THEME . abc_x , THEME . abc_y ) ;
countBtn . SetPosition ( THEME . count_x , THEME . count_y ) ;
listBtn . SetPosition ( THEME . list_x , THEME . list_y ) ;
gridBtn . SetPosition ( THEME . grid_x , THEME . grid_y ) ;
carouselBtn . SetPosition ( THEME . carousel_x , THEME . carousel_y ) ;
}
else
{
favoriteBtn . SetPosition ( THEME . favorite_x - 20 , THEME . favorite_y ) ;
abcBtn . SetPosition ( THEME . abc_x - 12 , THEME . abc_y ) ;
countBtn . SetPosition ( THEME . count_x - 4 , THEME . count_y ) ;
listBtn . SetPosition ( THEME . list_x + 4 , THEME . list_y ) ;
gridBtn . SetPosition ( THEME . grid_x + 12 , THEME . grid_y ) ;
carouselBtn . SetPosition ( THEME . carousel_x + 20 , THEME . carousel_y ) ;
}
}
else
{
if ( CFG . widescreen )
{
favoriteBtn . SetPosition ( THEME . favorite_x - THEME . sortBarOffset , THEME . favorite_y ) ;
abcBtn . SetPosition ( THEME . abc_x - THEME . sortBarOffset , THEME . abc_y ) ;
countBtn . SetPosition ( THEME . count_x - THEME . sortBarOffset , THEME . count_y ) ;
listBtn . SetPosition ( THEME . list_x - THEME . sortBarOffset , THEME . list_y ) ;
gridBtn . SetPosition ( THEME . grid_x - THEME . sortBarOffset , THEME . grid_y ) ;
carouselBtn . SetPosition ( THEME . carousel_x - THEME . sortBarOffset , THEME . carousel_y ) ;
}
else
{
favoriteBtn . SetPosition ( THEME . favorite_x - 20 - THEME . sortBarOffset , THEME . favorite_y ) ;
abcBtn . SetPosition ( THEME . abc_x - 12 - THEME . sortBarOffset , THEME . abc_y ) ;
countBtn . SetPosition ( THEME . count_x - 4 - THEME . sortBarOffset , THEME . count_y ) ;
listBtn . SetPosition ( THEME . list_x + 4 - THEME . sortBarOffset , THEME . list_y ) ;
gridBtn . SetPosition ( THEME . grid_x + 12 - THEME . sortBarOffset , THEME . grid_y ) ;
carouselBtn . SetPosition ( THEME . carousel_x + 20 - THEME . sortBarOffset , THEME . carousel_y ) ;
}
}
2009-05-23 00:08:50 +02:00
2009-06-09 07:20:49 +02:00
//Downloading Covers
2009-06-23 20:59:28 +02:00
GuiTooltip DownloadBtnTT ( tr ( " Click to Download Covers " ) ) ;
2009-06-09 07:20:49 +02:00
if ( Settings . wsprompt = = yes )
DownloadBtnTT . SetWidescreen ( CFG . widescreen ) ;
2009-06-20 12:10:40 +02:00
DownloadBtnTT . SetAlpha ( THEME . tooltipAlpha ) ;
2009-06-25 18:41:02 +02:00
GuiButton DownloadBtn ( 0 , 0 ) ;
2009-06-09 07:20:49 +02:00
DownloadBtn . SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
DownloadBtn . SetPosition ( THEME . cover_x , THEME . cover_y ) ;
2009-05-23 00:08:50 +02:00
2009-06-09 07:20:49 +02:00
if ( Settings . godmode = = 1 )
{ //only make the button have trigger & tooltip if in godmode
DownloadBtn . SetSoundOver ( & btnSoundOver ) ;
DownloadBtn . SetTrigger ( & trigA ) ;
2009-06-25 18:41:02 +02:00
DownloadBtn . SetTrigger ( & trig1 ) ;
2009-06-09 07:20:49 +02:00
DownloadBtn . SetToolTip ( & DownloadBtnTT , 205 , - 30 ) ;
2009-06-05 00:13:39 +02:00
}
2009-06-09 07:20:49 +02:00
else
DownloadBtn . SetRumble ( false ) ;
2009-05-31 19:08:09 +02:00
2009-06-08 19:23:35 +02:00
GuiGameBrowser * gameBrowser = NULL ;
GuiGameGrid * gameGrid = NULL ;
GuiGameCarousel * gameCarousel = NULL ;
if ( Settings . gameDisplay = = list ) {
gameBrowser = new GuiGameBrowser ( THEME . selection_w , THEME . selection_h , gameList , gameCnt , CFG . theme_path , bg_options_png , startat , offset ) ;
2009-06-09 07:20:49 +02:00
gameBrowser - > SetPosition ( THEME . selection_x , THEME . selection_y ) ;
gameBrowser - > SetAlignment ( ALIGN_LEFT , ALIGN_CENTRE ) ;
2009-06-08 19:23:35 +02:00
}
else if ( Settings . gameDisplay = = grid ) {
2009-06-09 07:20:49 +02:00
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 ) ;
2009-06-08 19:23:35 +02:00
}
else if ( Settings . gameDisplay = = carousel ) {
2009-06-09 07:20:49 +02:00
//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 ) ;
2009-06-08 19:23:35 +02:00
}
2009-05-23 00:08:50 +02:00
2009-06-09 07:20:49 +02:00
GuiText clockTimeBack ( " 88:88 " , 40 , ( GXColor ) { THEME . clock_r , THEME . clock_g , THEME . clock_b , 40 } ) ;
clockTimeBack . SetAlignment ( THEME . clockAlign , ALIGN_TOP ) ;
clockTimeBack . SetPosition ( THEME . clock_x , THEME . clock_y ) ;
clockTimeBack . SetFont ( fontClock ) ;
GuiText clockTime ( theTime , 40 , ( GXColor ) { THEME . clock_r , THEME . clock_g , THEME . clock_b , 240 } ) ;
clockTime . SetAlignment ( THEME . clockAlign , ALIGN_TOP ) ;
clockTime . SetPosition ( THEME . clock_x , THEME . clock_y ) ;
clockTime . SetFont ( fontClock ) ;
2009-05-29 15:20:28 +02:00
2009-06-09 07:20:49 +02:00
HaltGui ( ) ;
GuiWindow w ( screenwidth , screenheight ) ;
2009-05-23 00:08:50 +02:00
2009-06-09 07:20:49 +02:00
if ( THEME . showHDD = = - 1 | | THEME . showHDD = = 1 ) //force show hdd info
{
w . Append ( & usedSpaceTxt ) ;
}
if ( THEME . showGameCnt = = - 1 | | THEME . showGameCnt = = 1 ) //force show game cnt info
{
w . Append ( & gamecntTxt ) ;
}
w . Append ( & sdcardBtn ) ;
w . Append ( & poweroffBtn ) ;
2009-07-20 09:23:30 +02:00
w . Append ( & gameInfo ) ;
2009-06-09 07:20:49 +02:00
if ( Settings . godmode )
w . Append ( & installBtn ) ;
w . Append ( & homeBtn ) ;
w . Append ( & settingsBtn ) ;
2009-06-25 18:41:02 +02:00
w . Append ( & DownloadBtn ) ;
2009-06-09 07:20:49 +02:00
w . Append ( & favoriteBtn ) ;
w . Append ( & abcBtn ) ;
w . Append ( & countBtn ) ;
w . Append ( & listBtn ) ;
w . Append ( & gridBtn ) ;
w . Append ( & carouselBtn ) ;
2009-07-20 09:23:30 +02:00
if ( Settings . godmode = = 1 )
w . Append ( & homebrewBtn ) ;
2009-06-09 07:20:49 +02:00
if ( ( Settings . hddinfo = = hr12 ) | | ( Settings . hddinfo = = hr24 ) )
{
w . Append ( & clockTimeBack ) ;
w . Append ( & clockTime ) ;
}
2009-05-23 00:08:50 +02:00
2009-06-09 07:20:49 +02:00
if ( Settings . gameDisplay = = list ) { mainWindow - > Append ( gameBrowser ) ; }
if ( Settings . gameDisplay = = grid ) { mainWindow - > Append ( gameGrid ) ; }
if ( Settings . gameDisplay = = carousel ) { mainWindow - > Append ( gameCarousel ) ; }
mainWindow - > Append ( & w ) ;
ResumeGui ( ) ;
2009-07-11 07:55:29 +02:00
while ( menu = = MENU_NONE )
2009-06-09 07:20:49 +02:00
{
2009-07-11 07:55:29 +02:00
//this may not be needed. just messing around with the GHWT controller
u32 expType = 0 ; // Stores only the controller/expansion type.
u32 buttonsDown = WPAD_ButtonsDown ( 0 ) ;
2009-06-09 07:20:49 +02:00
2009-07-11 07:55:29 +02:00
// Use WPAD_Probe to get the expansion type.
WPAD_Probe ( WPAD_CHAN_0 , & expType ) ;
VIDEO_WaitVSync ( ) ;
2009-07-05 08:39:56 +02:00
2009-06-25 14:47:09 +02:00
if ( idiotFlag = = 1 ) {
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. Way to go dipshit. " ) ) ;
2009-07-05 08:39:56 +02:00
2009-07-16 11:36:55 +02:00
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 ) ;
}
}
2009-06-25 14:47:09 +02:00
idiotFlag = - 1 ; }
2009-07-12 16:02:48 +02:00
2009-07-11 07:55:29 +02:00
WDVD_GetCoverStatus ( & covert ) ; //for detecting if i disc has been inserted
2009-07-12 16:02:48 +02:00
2009-07-07 13:06:51 +02:00
// if the idiot is showing favoorites 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 ;
}
2009-06-09 07:20:49 +02:00
//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 ) ;
2009-05-23 00:08:50 +02:00
2009-06-09 07:20:49 +02:00
}
else if ( dataed > 0 ) {
2009-05-23 00:08:50 +02:00
2009-06-09 07:20:49 +02:00
clockTime . SetTextf ( " %i " , ( dataed - 1 ) ) ;
}
2009-05-23 00:08:50 +02:00
2009-06-09 07:20:49 +02:00
}
2009-06-05 00:13:39 +02:00
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 ) ; } }
2009-06-09 07:20:49 +02:00
// respond to button presses
if ( shutdown = = 1 )
{
Sys_Shutdown ( ) ;
}
if ( reset = = 1 )
Sys_Reboot ( ) ;
2009-07-23 19:24:08 +02:00
if ( updateavailable = = true ) {
ProgressUpdateWindow ( ) ;
updateavailable = false ;
}
2009-06-09 07:20:49 +02:00
if ( poweroffBtn . GetState ( ) = = STATE_CLICKED )
{
2009-07-05 08:39:56 +02:00
choice = WindowPrompt ( tr ( " How to Shutdown? " ) , 0 , tr ( " Full Shutdown " ) , tr ( " Shutdown to Idle " ) , tr ( " Cancel " ) ) ;
2009-06-09 07:20:49 +02:00
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 ) ; }
}
2009-05-23 00:08:50 +02:00
2009-06-09 07:20:49 +02:00
}
else if ( homeBtn . GetState ( ) = = STATE_CLICKED )
{
2009-07-05 08:39:56 +02:00
s32 thetimeofbg = bgMusic - > GetPlayTime ( ) ;
bgMusic - > Stop ( ) ;
2009-06-23 20:59:28 +02:00
choice = WindowExitPrompt ( tr ( " Exit USB Loader GX? " ) , 0 , tr ( " Back to Loader " ) , tr ( " Wii Menu " ) , tr ( " Back " ) , 0 ) ;
2009-06-09 07:20:49 +02:00
if ( ! strcmp ( " " , Settings . oggload_path ) | | ! strcmp ( " notset " , Settings . ogg_path ) ) {
2009-07-05 08:39:56 +02:00
bgMusic - > Play ( ) ;
} else {
bgMusic - > PlayOggFile ( Settings . ogg_path ) ;
}
bgMusic - > SetPlayTime ( thetimeofbg ) ;
SetVolumeOgg ( 255 * ( Settings . volume / 100.0 ) ) ;
2009-05-23 00:08:50 +02:00
2009-06-09 07:20:49 +02:00
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 ) ; }
}
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
}
2009-06-09 07:20:49 +02:00
else if ( wiiBtn . GetState ( ) = = STATE_CLICKED )
{ dataed + + ;
wiiBtn . ResetState ( ) ;
if ( Settings . gameDisplay = = list ) { gameBrowser - > SetFocus ( 1 ) ; }
else if ( Settings . gameDisplay = = grid ) { gameGrid - > SetFocus ( 1 ) ; }
else if ( Settings . gameDisplay = = carousel ) { gameCarousel - > SetFocus ( 1 ) ; }
}
2009-07-07 15:47:37 +02:00
else if ( ( installBtn . GetState ( ) = = STATE_CLICKED ) | | ( ( covert & 0x2 ) & & ( covert ! = covertOld ) ) )
2009-06-09 07:20:49 +02:00
{
2009-07-05 08:39:56 +02:00
choice = WindowPrompt ( tr ( " Install a game " ) , 0 , tr ( " Yes " ) , tr ( " No " ) ) ;
2009-06-09 07:20:49 +02:00
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 ) ; }
}
}
2009-07-12 16:02:48 +02:00
2009-06-09 07:20:49 +02:00
2009-07-11 07:55:29 +02:00
else if ( ( sdcardBtn . GetState ( ) = = STATE_CLICKED ) | |
( ( buttonsDown & GUITAR_HERO_3_BUTTON_ORANGE ) & & ( expType = = WPAD_EXP_GUITARHERO3 ) ) )
2009-06-09 07:20:49 +02:00
{
2009-07-11 07:55:29 +02:00
SDCard_deInit ( ) ;
2009-06-09 07:20:49 +02:00
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 ( ) ; }
2009-06-10 01:26:03 +02:00
//if(isSdInserted()) {
if ( isInserted ( bootDevice ) ) {
2009-07-05 08:39:56 +02:00
CFG_Load ( ) ;
}
2009-06-09 07:20:49 +02:00
sdcardBtn . ResetState ( ) ;
menu = MENU_DISCLIST ;
break ;
}
2009-05-23 00:08:50 +02:00
2009-06-09 07:20:49 +02:00
else if ( DownloadBtn . GetState ( ) = = STATE_CLICKED )
{
2009-06-10 01:26:03 +02:00
//if(isSdInserted()) {
if ( isInserted ( bootDevice ) ) {
2009-07-05 08:39:56 +02:00
choice = WindowPrompt ( tr ( " Cover Download " ) , 0 , tr ( " Normal Covers " ) , tr ( " 3D Covers " ) , tr ( " Disc Images " ) , tr ( " Back " ) ) ; // ask for download choice
2009-05-29 18:23:58 +02:00
2009-06-09 07:20:49 +02:00
if ( choice ! = 0 )
{
int choice2 = choice ;
2009-05-29 18:23:58 +02:00
2009-06-13 23:10:37 +02:00
SearchMissingImages ( choice2 ) ;
2009-05-23 00:08:50 +02:00
2009-06-13 23:10:37 +02:00
if ( IsNetworkInit ( ) = = false )
2009-06-09 07:20:49 +02:00
{
2009-07-05 08:39:56 +02:00
WindowPrompt ( tr ( " Network init error " ) , 0 , tr ( " OK " ) ) ;
2009-05-23 00:08:50 +02:00
2009-06-13 23:10:37 +02:00
} else {
2009-05-23 00:08:50 +02:00
2009-06-09 07:20:49 +02:00
if ( GetMissingFiles ( ) ! = NULL & & cntMissFiles > 0 )
2009-05-23 00:08:50 +02:00
2009-06-09 07:20:49 +02:00
{
char tempCnt [ 40 ] ;
2009-05-23 00:08:50 +02:00
2009-06-23 20:59:28 +02:00
sprintf ( tempCnt , " %i %s " , cntMissFiles , tr ( " Missing files " ) ) ;
2009-07-05 08:39:56 +02:00
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 " ) ) ;
2009-06-09 07:20:49 +02:00
if ( choice = = 1 )
{
ret = ProgressDownloadWindow ( choice2 ) ;
if ( ret = = 0 ) {
2009-07-05 08:39:56 +02:00
WindowPrompt ( tr ( " Download finished " ) , 0 , tr ( " OK " ) ) ;
2009-06-09 07:20:49 +02:00
} else {
2009-07-01 04:05:50 +02:00
sprintf ( tempCnt , " %i %s " , ret , tr ( " files not found on the server! " ) ) ;
2009-07-05 08:39:56 +02:00
WindowPrompt ( tr ( " Download finished " ) , tempCnt , tr ( " OK " ) ) ;
2009-07-01 04:05:50 +02:00
}
2009-06-09 07:20:49 +02:00
}
}
else
{
2009-07-05 08:39:56 +02:00
WindowPrompt ( tr ( " No file missing! " ) , 0 , tr ( " OK " ) ) ;
2009-06-09 07:20:49 +02:00
}
2009-07-05 08:39:56 +02:00
}
2009-06-09 07:20:49 +02:00
}
2009-07-05 08:39:56 +02:00
} else {
WindowPrompt ( tr ( " No SD-Card inserted! " ) , tr ( " Insert an SD-Card to download images. " ) , tr ( " OK " ) ) ;
}
DownloadBtn . ResetState ( ) ;
2009-06-09 07:20:49 +02:00
if ( Settings . gameDisplay = = list ) { gameBrowser - > SetFocus ( 1 ) ; }
else if ( Settings . gameDisplay = = grid ) { gameGrid - > SetFocus ( 1 ) ; }
else if ( Settings . gameDisplay = = carousel ) { gameCarousel - > SetFocus ( 1 ) ; }
} //end download
else if ( settingsBtn . GetState ( ) = = STATE_CLICKED )
{ if ( Settings . gameDisplay = = list ) {
startat = gameBrowser - > GetSelectedOption ( ) ;
offset = gameBrowser - > GetOffset ( ) ; }
else if ( Settings . gameDisplay = = grid ) {
startat = gameGrid - > GetSelectedOption ( ) ;
offset = gameGrid - > GetOffset ( ) ; }
else if ( Settings . gameDisplay = = carousel ) {
startat = gameCarousel - > GetSelectedOption ( ) ;
offset = gameCarousel - > GetOffset ( ) ; }
menu = MENU_SETTINGS ;
break ;
2009-05-23 00:08:50 +02:00
2009-06-09 07:20:49 +02:00
}
2009-05-23 00:08:50 +02:00
2009-06-09 07:20:49 +02:00
else if ( favoriteBtn . GetState ( ) = = STATE_CLICKED )
{
Settings . fave = ! Settings . fave ;
2009-06-10 01:26:03 +02:00
//if(isSdInserted()) {
if ( isInserted ( bootDevice ) ) {
2009-06-09 07:20:49 +02:00
cfg_save_global ( ) ;
}
__Menu_GetEntries ( ) ;
menu = MENU_DISCLIST ;
break ;
2009-07-05 08:39:56 +02:00
2009-06-09 07:20:49 +02:00
}
else if ( abcBtn . GetState ( ) = = STATE_CLICKED )
{
if ( Settings . sort ! = all ) {
Settings . sort = all ;
2009-06-10 01:26:03 +02:00
//if(isSdInserted()) {
if ( isInserted ( bootDevice ) ) {
2009-06-09 07:20:49 +02:00
cfg_save_global ( ) ;
}
__Menu_GetEntries ( ) ;
2009-07-05 08:39:56 +02:00
2009-06-09 07:20:49 +02:00
menu = MENU_DISCLIST ;
break ;
}
abcBtn . ResetState ( ) ;
}
else if ( countBtn . GetState ( ) = = STATE_CLICKED )
{
if ( Settings . sort ! = pcount ) {
Settings . sort = pcount ;
2009-06-10 01:26:03 +02:00
//if(isSdInserted()) {
if ( isInserted ( bootDevice ) ) {
2009-06-09 07:20:49 +02:00
cfg_save_global ( ) ;
}
__Menu_GetEntries ( ) ;
2009-07-05 08:39:56 +02:00
2009-06-09 07:20:49 +02:00
menu = MENU_DISCLIST ;
break ;
}
countBtn . ResetState ( ) ;
}
else if ( listBtn . GetState ( ) = = STATE_CLICKED ) {
2009-06-25 18:41:02 +02:00
if ( Settings . gameDisplay ! = list ) {
2009-06-09 07:20:49 +02:00
Settings . gameDisplay = list ;
menu = MENU_DISCLIST ;
2009-06-14 22:43:58 +02:00
if ( isInserted ( bootDevice ) ) {
cfg_save_global ( ) ;
}
listBtn . ResetState ( ) ;
2009-06-09 07:20:49 +02:00
break ;
2009-06-08 19:23:35 +02:00
} else {
2009-06-09 07:20:49 +02:00
listBtn . ResetState ( ) ;
2009-07-05 08:39:56 +02:00
}
2009-06-09 07:20:49 +02:00
}
else if ( gridBtn . GetState ( ) = = STATE_CLICKED ) {
if ( Settings . gameDisplay ! = grid ) {
2009-07-05 08:39:56 +02:00
2009-06-09 07:20:49 +02:00
Settings . gameDisplay = grid ;
menu = MENU_DISCLIST ;
2009-06-14 22:43:58 +02:00
if ( isInserted ( bootDevice ) ) {
cfg_save_global ( ) ;
}
gridBtn . ResetState ( ) ;
2009-06-09 07:20:49 +02:00
break ;
} else {
gridBtn . ResetState ( ) ;
}
}
else if ( carouselBtn . GetState ( ) = = STATE_CLICKED ) {
2009-07-19 11:10:25 +02:00
if ( Settings . gameDisplay ! = carousel ) {
Settings . gameDisplay = carousel ;
menu = MENU_DISCLIST ;
if ( isInserted ( bootDevice ) ) {
2009-06-14 22:43:58 +02:00
cfg_save_global ( ) ;
2009-07-19 11:10:25 +02:00
}
carouselBtn . ResetState ( ) ;
break ;
} else {
carouselBtn . ResetState ( ) ;
}
2009-07-05 08:39:56 +02:00
}
2009-07-19 11:10:25 +02:00
else if ( homebrewBtn . GetState ( ) = = STATE_CLICKED ) {
menu = MENU_HOMEBREWBROWSE ;
break ;
2009-06-09 07:20:49 +02:00
}
else if ( gameInfo . GetState ( ) = = STATE_CLICKED ) {
2009-06-20 02:32:10 +02:00
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 ) ;
2009-07-05 08:39:56 +02:00
gameInfo . ResetState ( ) ;
2009-07-13 13:19:31 +02:00
if ( choice = = 2 )
homeBtn . SetState ( STATE_CLICKED ) ;
2009-07-05 08:39:56 +02:00
}
2009-05-23 00:08:50 +02:00
2009-06-09 07:20:49 +02:00
if ( Settings . gameDisplay = = grid ) {
int selectimg ;
2009-06-25 18:41:02 +02:00
DownloadBtn . SetSize ( 0 , 0 ) ;
2009-06-09 07:20:49 +02:00
selectimg = gameGrid - > GetSelectedOption ( ) ;
gameSelected = gameGrid - > GetClickedOption ( ) ;
selectImg1 = selectimg ;
}
if ( Settings . gameDisplay = = carousel ) {
int selectimg ;
2009-06-25 18:41:02 +02:00
DownloadBtn . SetSize ( 0 , 0 ) ;
2009-06-09 07:20:49 +02:00
selectimg = gameCarousel - > GetSelectedOption ( ) ;
gameSelected = gameCarousel - > GetClickedOption ( ) ;
selectImg1 = selectimg ;
2009-06-05 00:13:39 +02:00
}
2009-06-09 07:20:49 +02:00
if ( Settings . gameDisplay = = list ) {
//Get selected game under cursor
int selectimg ; //, promptnumber;
2009-06-25 18:41:02 +02:00
DownloadBtn . SetSize ( 160 , 224 ) ;
2009-06-10 10:19:55 +02:00
2009-06-09 07:20:49 +02:00
selectimg = gameBrowser - > GetSelectedOption ( ) ;
gameSelected = gameBrowser - > GetClickedOption ( ) ;
selectImg1 = selectimg ;
if ( gameSelected > 0 ) //if click occured
selectimg = gameSelected ;
if ( ( selectimg > = 0 ) & & ( selectimg < ( s32 ) gameCnt ) )
{
if ( selectimg ! = selectedold )
{
selectedold = selectimg ; //update displayed cover, game ID, and region if the selected game changes
struct discHdr * header = & gameList [ selectimg ] ;
snprintf ( ID , sizeof ( ID ) , " %c%c%c " , header - > id [ 0 ] , header - > id [ 1 ] , header - > id [ 2 ] ) ;
snprintf ( IDfull , sizeof ( IDfull ) , " %c%c%c%c%c%c " , header - > id [ 0 ] , header - > id [ 1 ] , header - > id [ 2 ] , header - > id [ 3 ] , header - > id [ 4 ] , header - > id [ 5 ] ) ;
w . Remove ( & DownloadBtn ) ;
if ( GameIDTxt )
{
w . Remove ( GameIDTxt ) ;
delete GameIDTxt ;
GameIDTxt = NULL ;
}
if ( GameRegionTxt )
{
w . Remove ( GameRegionTxt ) ;
delete GameRegionTxt ;
GameRegionTxt = NULL ;
}
switch ( header - > id [ 3 ] )
{
case ' E ' :
sprintf ( gameregion , " NTSC U " ) ;
break ;
case ' J ' :
sprintf ( gameregion , " NTSC J " ) ;
break ;
case ' K ' :
sprintf ( gameregion , " NTSC K " ) ;
break ;
case ' P ' :
case ' D ' :
case ' F ' :
case ' X ' :
case ' S ' :
case ' Y ' :
sprintf ( gameregion , " PAL " ) ;
break ;
}
//load game cover
if ( cover )
{
delete cover ;
cover = NULL ;
}
snprintf ( imgPath , sizeof ( imgPath ) , " %s%s.png " , Settings . covers_path , IDfull ) ;
cover = new GuiImageData ( imgPath , 0 ) ; //load short id
if ( ! cover - > GetImage ( ) ) //if could not load the short id image
{
delete cover ;
snprintf ( imgPath , sizeof ( imgPath ) , " %s%s.png " , Settings . covers_path , ID ) ;
cover = new GuiImageData ( imgPath , 0 ) ; //load full id image
if ( ! cover - > GetImage ( ) )
{
delete cover ;
snprintf ( imgPath , sizeof ( imgPath ) , " %snoimage.png " , Settings . covers_path ) ;
cover = new GuiImageData ( imgPath , nocover_png ) ; //load no image
}
}
if ( coverImg )
{
delete coverImg ;
coverImg = NULL ;
}
coverImg = new GuiImage ( cover ) ;
coverImg - > SetWidescreen ( CFG . widescreen ) ;
DownloadBtn . SetImage ( coverImg ) ; // put the new image on the download button
w . Append ( & DownloadBtn ) ;
if ( ( Settings . sinfo = = GameID ) | | ( Settings . sinfo = = Both ) ) {
GameIDTxt = new GuiText ( IDfull , 22 , ( GXColor ) { THEME . info_r , THEME . info_g , THEME . info_b , 255 } ) ;
GameIDTxt - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
GameIDTxt - > SetPosition ( THEME . id_x , THEME . id_y ) ;
GameIDTxt - > SetEffect ( EFFECT_FADE , 20 ) ;
w . Append ( GameIDTxt ) ;
}
if ( ( Settings . sinfo = = GameRegion ) | | ( Settings . sinfo = = Both ) ) {
GameRegionTxt = new GuiText ( gameregion , 22 , ( GXColor ) { THEME . info_r , THEME . info_g , THEME . info_b , 255 } ) ;
GameRegionTxt - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
GameRegionTxt - > SetPosition ( THEME . region_x , THEME . region_y ) ;
GameRegionTxt - > SetEffect ( EFFECT_FADE , 20 ) ;
w . Append ( GameRegionTxt ) ;
}
}
}
}
2009-06-10 10:19:55 +02:00
2009-06-09 07:20:49 +02:00
if ( ( gameSelected > = 0 ) & & ( gameSelected < ( s32 ) gameCnt ) )
{
struct discHdr * header = & gameList [ gameSelected ] ;
WBFS_GameSize ( header - > id , & size ) ;
if ( strlen ( get_title ( header ) ) < ( MAX_CHARACTERS + 3 ) ) {
sprintf ( text , " %s " , get_title ( header ) ) ;
}
else {
strncpy ( text , get_title ( header ) , MAX_CHARACTERS ) ;
text [ MAX_CHARACTERS ] = ' \0 ' ;
strncat ( text , " ... " , 3 ) ;
}
2009-07-05 08:39:56 +02:00
2009-06-26 14:38:03 +02:00
//check if alt Dol and gct file is present
FILE * exeFile = NULL ;
char nipple [ 100 ] ;
header = & 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 ) {
ocarinaChoice = game_cfg - > ocarina ;
alternatedol = game_cfg - > loadalternatedol ;
} else {
alternatedol = off ;
ocarinaChoice = Settings . ocarina ;
}
2009-07-05 08:39:56 +02:00
2009-05-23 00:08:50 +02:00
2009-06-09 07:20:49 +02:00
if ( Settings . qboot = = yes ) //quickboot game
2009-07-15 19:20:45 +02:00
{ if ( alternatedol = = on ) {
2009-06-25 20:15:58 +02:00
/* Open dol File and check exist */
2009-06-26 14:38:03 +02:00
sprintf ( nipple , " %s%s.dol " , Settings . dolpath , IDfull ) ;
2009-06-25 20:15:58 +02:00
exeFile = fopen ( nipple , " rb " ) ;
if ( exeFile = = NULL )
2009-07-05 08:39:56 +02:00
{
2009-07-15 19:20:45 +02:00
sprintf ( nipple , " %s %s " , nipple , tr ( " does not exist! " ) ) ;
2009-07-05 08:39:56 +02:00
WindowPrompt ( tr ( " Error " ) , nipple , tr ( " OK " ) ) ;
2009-06-26 00:07:13 +02:00
menu = MENU_CHECK ;
2009-06-25 23:15:57 +02:00
wiilight ( 0 ) ;
2009-06-25 20:15:58 +02:00
break ;
2009-07-05 08:39:56 +02:00
}
2009-06-25 20:15:58 +02:00
}
2009-06-26 14:38:03 +02:00
if ( ocarinaChoice ! = off ) {
/* Open gct File and check exist */
sprintf ( nipple , " %s%s.gct " , Settings . Cheatcodespath , IDfull ) ;
exeFile = fopen ( nipple , " rb " ) ;
2009-07-19 11:10:25 +02:00
2009-07-15 04:01:10 +02:00
if ( exeFile = = NULL )
{
sprintf ( nipple , " %s %s " , nipple , tr ( " does not exist! Loading game without cheats. " ) ) ;
WindowPrompt ( tr ( " Error " ) , nipple , NULL , NULL , NULL , NULL , 170 ) ;
}
else
{
2009-07-05 08:39:56 +02:00
fseek ( exeFile , 0 , SEEK_END ) ;
2009-07-01 00:05:40 +02:00
long size = ftell ( exeFile ) ;
rewind ( exeFile ) ;
if ( size > 2056 ) {
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 ) ;
2009-07-15 04:01:10 +02:00
}
2009-07-05 08:39:56 +02:00
}
2009-07-19 11:10:25 +02:00
2009-06-26 14:38:03 +02:00
}
SDCard_deInit ( ) ;
2009-06-12 01:02:05 +02:00
wiilight ( 0 ) ;
2009-06-20 01:20:18 +02:00
if ( isInserted ( bootDevice ) ) {
2009-06-12 01:02:05 +02:00
//////////save game play count////////////////
2009-06-09 07:20:49 +02:00
struct Game_NUM * game_num = CFG_get_game_num ( header - > id ) ;
2009-06-20 01:20:18 +02:00
if ( game_num ) {
favoritevar = game_num - > favorite ;
playcount = game_num - > count ;
} else {
favoritevar = 0 ;
playcount = 0 ;
2009-06-09 07:20:49 +02:00
}
2009-06-20 01:20:18 +02:00
playcount + = 1 ;
CFG_save_game_num ( header - > id ) ;
2009-06-09 07:20:49 +02:00
}
2009-06-20 01:20:18 +02:00
2009-06-12 01:02:05 +02:00
menu = MENU_EXIT ;
2009-06-05 00:13:39 +02:00
break ;
2009-07-05 08:39:56 +02:00
2009-06-12 01:02:05 +02:00
}
2009-06-09 07:20:49 +02:00
bool returnHere = true ; // prompt to start game
while ( returnHere )
{
returnHere = false ;
if ( Settings . wiilight ! = 2 ) wiilight ( 1 ) ;
choice = GameWindowPrompt ( ) ;
2009-06-26 14:38:03 +02:00
// header = &gameList[gameSelected]; //reset header
2009-06-05 00:13:39 +02:00
2009-06-09 07:20:49 +02:00
if ( choice = = 1 )
{
2009-07-15 19:20:45 +02:00
if ( alternatedol = = on ) {
2009-06-25 20:15:58 +02:00
/* Open dol File and check exist */
2009-06-26 14:38:03 +02:00
sprintf ( nipple , " %s%s.dol " , Settings . dolpath , IDfull ) ;
2009-06-25 20:15:58 +02:00
exeFile = fopen ( nipple , " rb " ) ;
if ( exeFile = = NULL )
2009-07-05 08:39:56 +02:00
{
2009-06-25 20:15:58 +02:00
sprintf ( nipple , " %s %s " , nipple , tr ( " does not exist! You Messed something up, Idiot. " ) ) ;
2009-07-05 08:39:56 +02:00
WindowPrompt ( tr ( " Error " ) , nipple , tr ( " OK " ) ) ;
2009-06-26 00:07:13 +02:00
menu = MENU_CHECK ;
2009-06-25 23:15:57 +02:00
wiilight ( 0 ) ;
2009-06-25 20:15:58 +02:00
break ;
2009-07-05 08:39:56 +02:00
}
2009-06-25 20:15:58 +02:00
}
2009-06-26 14:38:03 +02:00
if ( ocarinaChoice ! = off ) {
/* Open gct File and check exist */
sprintf ( nipple , " %s%s.gct " , Settings . Cheatcodespath , IDfull ) ;
exeFile = fopen ( nipple , " rb " ) ;
2009-07-15 04:01:10 +02:00
if ( exeFile = = NULL )
{
sprintf ( nipple , " %s %s " , nipple , tr ( " does not exist! Loading game without cheats. " ) ) ;
WindowPrompt ( tr ( " Error " ) , nipple , NULL , NULL , NULL , NULL , 170 ) ;
}
else
{
2009-07-05 08:39:56 +02:00
fseek ( exeFile , 0 , SEEK_END ) ;
2009-07-01 00:05:40 +02:00
long size = ftell ( exeFile ) ;
rewind ( exeFile ) ;
2009-07-15 04:01:10 +02:00
fclose ( exeFile ) ;
2009-07-01 00:05:40 +02:00
if ( size > 2056 ) {
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 ) ;
2009-07-15 04:01:10 +02:00
}
}
2009-07-19 11:10:25 +02:00
2009-07-05 08:39:56 +02:00
}
2009-07-15 04:01:10 +02:00
SDCard_deInit ( ) ;
wiilight ( 0 ) ;
returnHere = false ;
menu = MENU_EXIT ;
2009-07-05 08:39:56 +02:00
2009-06-25 20:15:58 +02:00
}
2009-06-09 07:20:49 +02:00
else if ( choice = = 2 )
{
wiilight ( 0 ) ;
2009-07-05 08:39:56 +02:00
HaltGui ( ) ;
2009-06-12 01:02:05 +02:00
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 ( ) ;
2009-06-09 07:20:49 +02:00
int settret = GameSettings ( header ) ;
2009-06-14 05:42:46 +02:00
menu = MENU_DISCLIST ; // refresh titles (needed if the language setting has changed)
2009-06-09 07:20:49 +02:00
HaltGui ( ) ;
2009-06-12 01:02:05 +02:00
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 ( ) ;
2009-06-09 07:20:49 +02:00
if ( settret = = 1 ) //if deleted
{
menu = MENU_DISCLIST ;
break ;
}
returnHere = true ;
}
else if ( choice = = 3 ) //WBFS renaming
{
wiilight ( 0 ) ;
//enter new game title
char entered [ 60 ] ;
snprintf ( entered , sizeof ( entered ) , " %s " , get_title ( header ) ) ;
entered [ 59 ] = ' \0 ' ;
int result = OnScreenKeyboard ( entered , 60 , 0 ) ;
if ( result = = 1 ) {
WBFS_RenameGame ( header - > id , entered ) ;
__Menu_GetEntries ( ) ;
menu = MENU_DISCLIST ;
}
}
2009-06-12 01:02:05 +02:00
else if ( choice = = 0 ) {
2009-06-09 07:20:49 +02:00
if ( Settings . gameDisplay = = list ) { gameBrowser - > SetFocus ( 1 ) ; }
else if ( Settings . gameDisplay = = grid ) { gameGrid - > SetFocus ( 1 ) ; }
else if ( Settings . gameDisplay = = carousel ) { gameCarousel - > SetFocus ( 1 ) ; }
2009-06-12 01:02:05 +02:00
}
2009-06-09 07:20:49 +02:00
}
}
2009-06-18 18:09:45 +02:00
// to skip the first call of windowScreensaver at startup when wiimote is not connected
2009-06-18 09:36:23 +02:00
if ( IsWpadConnected ( ) ) { check = 1 ; }
2009-06-18 18:09:45 +02:00
// screensaver is called when wiimote shuts down, depending on the wiimotet idletime
2009-07-11 07:55:29 +02:00
if ( ! IsWpadConnected ( ) & & check ! = 0 & & Settings . screensaver ! = 0 )
2009-06-28 23:56:38 +02:00
{ check + + ;
2009-06-29 21:15:11 +02:00
int screensaverIsOn = 0 ;
2009-07-05 08:39:56 +02:00
if ( check = = 100 ) //to allow time for the wii to turn off and not show the screensaver
2009-06-29 21:15:11 +02:00
screensaverIsOn = WindowScreensaver ( ) ;
if ( screensaverIsOn = = 1 ) check = 0 ;
2009-06-18 09:36:23 +02:00
}
2009-07-07 15:47:37 +02:00
covertOld = covert ;
2009-06-18 09:36:23 +02:00
}
2009-06-18 18:09:45 +02:00
2009-07-19 11:10:25 +02:00
HaltGui ( ) ;
2009-06-09 07:20:49 +02:00
mainWindow - > RemoveAll ( ) ;
mainWindow - > Append ( bgImg ) ;
delete gameBrowser ;
gameBrowser = NULL ;
delete gameGrid ;
gameGrid = NULL ;
delete gameCarousel ;
gameCarousel = NULL ;
ResumeGui ( ) ;
return menu ;
2009-06-05 00:13:39 +02:00
}
2009-05-23 00:08:50 +02:00
2009-06-09 07:20:49 +02:00
2009-06-05 00:13:39 +02:00
/****************************************************************************
* MenuInstall
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
static int MenuInstall ( )
{
int menu = MENU_NONE ;
static struct discHdr headerdisc ATTRIBUTE_ALIGN ( 32 ) ;
2009-05-28 14:12:52 +02:00
2009-06-14 01:39:42 +02:00
Disc_SetUSB ( NULL ) ;
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
int ret , choice = 0 ;
2009-07-05 22:22:29 +02:00
char name [ 200 ] ;
2009-05-30 18:58:34 +02:00
2009-06-06 19:26:52 +02:00
GuiSound btnSoundOver ( button_over_pcm , button_over_pcm_size , SOUND_PCM , Settings . sfxvolume ) ;
2009-05-30 18:58:34 +02:00
2009-06-05 00:13:39 +02:00
char imgPath [ 100 ] ;
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
snprintf ( imgPath , sizeof ( imgPath ) , " %sbattery.png " , CFG . theme_path ) ;
GuiImageData battery ( imgPath , battery_png ) ;
snprintf ( imgPath , sizeof ( imgPath ) , " %sbattery_red.png " , CFG . theme_path ) ;
GuiImageData batteryRed ( imgPath , battery_red_png ) ;
snprintf ( imgPath , sizeof ( imgPath ) , " %sbattery_bar.png " , CFG . theme_path ) ;
GuiImageData batteryBar ( imgPath , battery_bar_png ) ;
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
HaltGui ( ) ;
GuiWindow w ( screenwidth , screenheight ) ;
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
mainWindow - > Append ( & w ) ;
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
ResumeGui ( ) ;
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
while ( menu = = MENU_NONE )
{
VIDEO_WaitVSync ( ) ;
2009-05-23 00:08:50 +02:00
2009-06-23 20:59:28 +02:00
ret = DiscWait ( tr ( " Insert Disk " ) , tr ( " Waiting... " ) , tr ( " Cancel " ) , 0 , 0 ) ;
2009-06-05 00:13:39 +02:00
if ( ret < 0 ) {
2009-07-05 08:39:56 +02:00
WindowPrompt ( tr ( " Error reading Disc " ) , 0 , tr ( " Back " ) ) ;
2009-06-05 00:13:39 +02:00
menu = MENU_DISCLIST ;
break ;
}
ret = Disc_Open ( ) ;
if ( ret < 0 ) {
2009-07-05 08:39:56 +02:00
WindowPrompt ( tr ( " Could not open Disc " ) , 0 , tr ( " Back " ) ) ;
2009-06-05 00:13:39 +02:00
menu = MENU_DISCLIST ;
break ;
}
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
ret = Disc_IsWii ( ) ;
if ( ret < 0 ) {
2009-07-23 02:41:57 +02:00
choice = WindowPrompt ( tr ( " Not a Wii Disc " ) , tr ( " Insert a Wii Disc! " ) , tr ( " OK " ) , tr ( " Back " ) ) ;
2009-06-05 00:13:39 +02:00
if ( choice = = 1 ) {
menu = MENU_INSTALL ;
break ;
} else
2009-05-23 00:08:50 +02:00
menu = MENU_DISCLIST ;
break ;
}
2009-06-05 00:13:39 +02:00
Disc_ReadHeader ( & headerdisc ) ;
2009-07-05 22:22:29 +02:00
snprintf ( name , sizeof ( name ) , " %s " , headerdisc . title ) ;
2009-05-28 14:12:52 +02:00
2009-06-05 00:13:39 +02:00
ret = WBFS_CheckGame ( headerdisc . id ) ;
if ( ret ) {
2009-07-05 08:39:56 +02:00
WindowPrompt ( tr ( " Game is already installed: " ) , name , tr ( " Back " ) ) ;
2009-06-05 00:13:39 +02:00
menu = MENU_DISCLIST ;
break ;
}
2009-06-01 15:35:43 +02:00
2009-06-05 00:13:39 +02:00
f32 freespace , used ;
2009-05-24 15:59:09 +02:00
2009-06-05 00:13:39 +02:00
WBFS_DiskSpace ( & used , & freespace ) ;
2009-07-05 22:22:29 +02:00
gamesize = WBFS_EstimeGameSize ( ) / GBSIZE ;
2009-06-05 00:13:39 +02:00
char gametxt [ 50 ] ;
sprintf ( gametxt , " %s : %.2fGB " , name , gamesize ) ;
wiilight ( 1 ) ;
2009-07-05 08:39:56 +02:00
choice = WindowPrompt ( tr ( " Continue to install game? " ) , gametxt , tr ( " OK " ) , tr ( " Cancel " ) ) ;
2009-06-05 00:13:39 +02:00
if ( choice = = 1 ) {
2009-06-23 20:59:28 +02:00
sprintf ( gametxt , " %s " , tr ( " Installing game: " ) ) ;
2009-06-05 00:13:39 +02:00
if ( gamesize > freespace ) {
char errortxt [ 50 ] ;
2009-06-23 20:59:28 +02:00
sprintf ( errortxt , " %s: %.2fGB, %s: %.2fGB " , tr ( " Game Size " ) , gamesize , tr ( " Free Space " ) , freespace ) ;
2009-07-16 11:36:55 +02:00
WindowPrompt ( tr ( " Not enough free space! " ) , errortxt , tr ( " OK " ) ) ;
2009-06-05 00:13:39 +02:00
menu = MENU_DISCLIST ;
break ;
}
else {
2009-07-05 22:22:29 +02:00
USBStorage_Watchdog ( 0 ) ;
SetupGameInstallProgress ( gametxt , name ) ;
ret = WBFS_AddGame ( ) ;
ProgressStop ( ) ;
USBStorage_Watchdog ( 1 ) ;
2009-06-14 22:43:58 +02:00
wiilight ( 0 ) ;
2009-06-05 00:13:39 +02:00
if ( ret ! = 0 ) {
2009-07-05 22:22:29 +02:00
WindowPrompt ( tr ( " Install Error! " ) , 0 , tr ( " Back " ) ) ;
2009-06-05 00:13:39 +02:00
menu = MENU_DISCLIST ;
break ;
} else {
__Menu_GetEntries ( ) ; //get the entries again
2009-07-05 08:39:56 +02:00
WindowPrompt ( tr ( " Successfully installed: " ) , name , tr ( " OK " ) ) ;
2009-06-05 00:13:39 +02:00
menu = MENU_DISCLIST ;
break ;
2009-05-23 00:08:50 +02:00
}
}
2009-06-05 00:13:39 +02:00
} else {
menu = MENU_DISCLIST ;
break ;
}
if ( shutdown = = 1 ) {
wiilight ( 0 ) ;
Sys_Shutdown ( ) ;
}
if ( reset = = 1 ) {
wiilight ( 0 ) ;
Sys_Reboot ( ) ;
}
2009-05-23 00:08:50 +02:00
}
2009-06-05 00:13:39 +02:00
//Turn off the WiiLight
wiilight ( 0 ) ;
2009-05-23 00:08:50 +02:00
HaltGui ( ) ;
2009-06-05 00:13:39 +02:00
2009-05-23 00:08:50 +02:00
mainWindow - > Remove ( & w ) ;
ResumeGui ( ) ;
return menu ;
}
2009-06-05 00:13:39 +02:00
/****************************************************************************
* MenuFormat
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
static int MenuFormat ( )
2009-05-23 00:08:50 +02:00
{
2009-06-05 00:13:39 +02:00
USBDevice_deInit ( ) ;
int menu = MENU_NONE ;
char imgPath [ 100 ] ;
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
OptionList options ;
partitionEntry partitions [ MAX_PARTITIONS ] ;
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
u32 cnt , sector_size , selected = 2000 ;
int choice , ret ;
char text [ ISFS_MAXPATH ] ;
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
s32 ret2 ;
ret2 = Partition_GetEntries ( partitions , & sector_size ) ;
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
//create the partitionlist
for ( cnt = 0 ; cnt < MAX_PARTITIONS ; cnt + + ) {
partitionEntry * entry = & partitions [ cnt ] ;
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
/* Calculate size in gigabytes */
2009-07-05 22:22:29 +02:00
f32 size = entry - > size * ( sector_size / GBSIZE ) ;
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
if ( size ) {
2009-06-23 20:59:28 +02:00
sprintf ( options . name [ cnt ] , " %s %d: " , tr ( " Partition " ) , cnt + 1 ) ;
2009-06-05 00:13:39 +02:00
sprintf ( options . value [ cnt ] , " %.2fGB " , size ) ;
} else {
2009-06-23 20:59:28 +02:00
sprintf ( options . name [ cnt ] , " %s %d: " , tr ( " Partition " ) , cnt + 1 ) ;
sprintf ( options . value [ cnt ] , tr ( " Can't be formated " ) ) ;
2009-06-05 00:13:39 +02:00
}
}
options . length = cnt ;
2009-06-06 19:26:52 +02:00
GuiSound btnSoundOver ( button_over_pcm , button_over_pcm_size , SOUND_PCM , Settings . sfxvolume ) ;
GuiSound btnClick ( button_click2_pcm , button_click2_pcm_size , SOUND_PCM , Settings . sfxvolume ) ;
2009-06-05 00:13:39 +02:00
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 batteryRed ( battery_red_png ) ;
GuiImageData batteryBar ( battery_bar_png ) ;
2009-05-23 00:08:50 +02:00
GuiTrigger trigA ;
trigA . SetSimpleTrigger ( - 1 , WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A , PAD_BUTTON_A ) ;
2009-06-05 00:13:39 +02:00
GuiTrigger trigHome ;
2009-05-23 00:08:50 +02:00
trigHome . SetButtonOnlyTrigger ( - 1 , WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME , 0 ) ;
2009-06-05 00:13:39 +02:00
GuiImage poweroffBtnImg ( & btnpwroff ) ;
GuiImage poweroffBtnImgOver ( & btnpwroffOver ) ;
poweroffBtnImg . SetWidescreen ( CFG . widescreen ) ;
poweroffBtnImgOver . SetWidescreen ( CFG . widescreen ) ;
GuiButton poweroffBtn ( & poweroffBtnImg , & poweroffBtnImgOver , 0 , 3 , THEME . power_x , THEME . power_y , & trigA , & btnSoundOver , & btnClick , 1 ) ;
GuiImage exitBtnImg ( & btnhome ) ;
GuiImage exitBtnImgOver ( & btnhomeOver ) ;
exitBtnImg . SetWidescreen ( CFG . widescreen ) ;
exitBtnImgOver . SetWidescreen ( CFG . widescreen ) ;
GuiButton exitBtn ( & exitBtnImg , & exitBtnImgOver , 0 , 3 , 0 , - 10 , & trigA , & btnSoundOver , & btnClick , 1 ) ;
exitBtn . SetTrigger ( & trigHome ) ;
2009-05-29 18:23:58 +02:00
2009-06-05 00:13:39 +02:00
GuiOptionBrowser optionBrowser ( THEME . selection_w , THEME . selection_h , & options , CFG . theme_path , bg_options_png , 1 , 0 ) ;
optionBrowser . SetPosition ( THEME . selection_x , THEME . selection_y ) ;
optionBrowser . SetAlignment ( ALIGN_LEFT , ALIGN_CENTRE ) ;
optionBrowser . SetCol2Position ( 200 ) ;
2009-05-23 00:08:50 +02:00
HaltGui ( ) ;
GuiWindow w ( screenwidth , screenheight ) ;
2009-06-05 00:13:39 +02:00
w . Append ( & poweroffBtn ) ;
w . Append ( & exitBtn ) ;
2009-05-23 00:08:50 +02:00
mainWindow - > Append ( & w ) ;
2009-06-05 00:13:39 +02:00
mainWindow - > Append ( & optionBrowser ) ;
2009-05-23 00:08:50 +02:00
ResumeGui ( ) ;
2009-06-05 00:13:39 +02:00
while ( menu = = MENU_NONE )
2009-05-23 00:08:50 +02:00
{
2009-06-05 00:13:39 +02:00
VIDEO_WaitVSync ( ) ;
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
selected = optionBrowser . GetClickedOption ( ) ;
2009-07-23 19:24:08 +02:00
2009-07-20 09:23:30 +02:00
for ( cnt = 0 ; cnt < MAX_PARTITIONS ; cnt + + ) {
if ( ( cnt = = selected ) & & ( ( Settings . godmode = = 1 ) | |
( ! strcmp ( " " , Settings . unlockCode ) ) ) ) {
2009-06-05 00:13:39 +02:00
partitionEntry * entry = & partitions [ selected ] ;
if ( entry - > size ) {
2009-07-05 22:22:29 +02:00
sprintf ( text , " %s %d : %.2fGB " , tr ( " Partition " ) , selected + 1 , entry - > size * ( sector_size / GBSIZE ) ) ;
2009-06-05 00:13:39 +02:00
choice = WindowPrompt (
2009-06-23 20:59:28 +02:00
tr ( " Do you want to format: " ) ,
2009-06-05 00:13:39 +02:00
text ,
2009-06-23 20:59:28 +02:00
tr ( " Yes " ) ,
2009-07-05 08:39:56 +02:00
tr ( " No " ) ) ;
2009-06-05 00:13:39 +02:00
if ( choice = = 1 ) {
2009-06-23 20:59:28 +02:00
ret = FormatingPartition ( tr ( " Formatting, please wait... " ) , entry ) ;
2009-06-05 00:13:39 +02:00
if ( ret < 0 ) {
2009-07-05 08:39:56 +02:00
WindowPrompt ( tr ( " Error ! " ) , tr ( " Failed formating " ) , tr ( " Return " ) ) ;
2009-06-05 00:13:39 +02:00
menu = MENU_SETTINGS ;
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
} else {
2009-06-14 01:39:42 +02:00
ret = WBFS_Open ( ) ;
2009-06-23 20:59:28 +02:00
sprintf ( text , " %s %s " , text , tr ( " formatted! " ) ) ;
2009-07-05 08:39:56 +02:00
WindowPrompt ( tr ( " Success: " ) , text , tr ( " OK " ) ) ;
2009-06-05 00:13:39 +02:00
menu = MENU_DISCLIST ;
}
}
}
}
2009-07-20 09:23:30 +02:00
else if ( ( cnt = = selected ) & & ( 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 " ) ) ;
}
}
}
2009-06-05 00:13:39 +02:00
}
if ( shutdown = = 1 )
2009-05-23 00:08:50 +02:00
Sys_Shutdown ( ) ;
if ( reset = = 1 )
Sys_Reboot ( ) ;
2009-06-05 00:13:39 +02:00
if ( poweroffBtn . GetState ( ) = = STATE_CLICKED )
2009-05-23 00:08:50 +02:00
{
2009-07-05 08:39:56 +02:00
choice = WindowPrompt ( tr ( " Shutdown System " ) , tr ( " Are you sure? " ) , tr ( " Yes " ) , tr ( " No " ) ) ;
2009-06-05 00:13:39 +02:00
if ( choice = = 1 )
2009-05-23 00:08:50 +02:00
{
2009-06-05 00:13:39 +02:00
Sys_Shutdown ( ) ;
2009-05-23 00:08:50 +02:00
}
2009-06-05 00:13:39 +02:00
} else if ( exitBtn . GetState ( ) = = STATE_CLICKED )
{
2009-07-05 08:39:56 +02:00
choice = WindowPrompt ( tr ( " Return to Wii Menu " ) , tr ( " Are you sure? " ) , tr ( " Yes " ) , tr ( " No " ) ) ;
2009-06-05 00:13:39 +02:00
if ( choice = = 1 )
2009-05-23 00:08:50 +02:00
{
2009-06-05 00:13:39 +02:00
Sys_LoadMenu ( ) ;
2009-05-23 00:08:50 +02:00
}
}
}
2009-06-05 00:13:39 +02:00
2009-05-23 00:08:50 +02:00
HaltGui ( ) ;
2009-06-05 00:13:39 +02:00
mainWindow - > Remove ( & optionBrowser ) ;
2009-05-23 00:08:50 +02:00
mainWindow - > Remove ( & w ) ;
ResumeGui ( ) ;
2009-06-05 00:13:39 +02:00
USBDevice_Init ( ) ;
return menu ;
2009-05-23 00:08:50 +02:00
}
/****************************************************************************
* MenuCheck
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static int MenuCheck ( )
{
int menu = MENU_NONE ;
int i = 0 ;
int choice ;
2009-06-20 13:11:07 +02:00
s32 ret2 , wbfsinit ;
2009-05-23 00:08:50 +02:00
OptionList options ;
options . length = i ;
partitionEntry partitions [ MAX_PARTITIONS ] ;
2009-06-05 00:13:39 +02:00
VIDEO_WaitVSync ( ) ;
2009-07-21 10:06:20 +02:00
OpenXMLDatabase ( Settings . titlestxt_path , Settings . db_language , Settings . db_JPtoEN , true , Settings . titlesOverride = = 1 ? true : false , true ) ;
2009-07-23 19:24:08 +02:00
2009-05-23 00:08:50 +02:00
2009-06-20 13:11:07 +02:00
wbfsinit = WBFS_Init ( WBFS_DEVICE_USB ) ;
if ( wbfsinit < 0 )
2009-06-05 00:13:39 +02:00
{
2009-06-23 20:59:28 +02:00
ret2 = WindowPrompt ( tr ( " No USB Device found. " ) ,
tr ( " Do you want to retry for 30 secs? " ) ,
2009-06-05 00:13:39 +02:00
" cIOS249 " , " cIOS222 " ,
2009-07-05 08:39:56 +02:00
tr ( " Back to Wii Menu " ) ) ;
2009-06-12 13:50:14 +02:00
SDCard_deInit ( ) ;
USBDevice_deInit ( ) ;
WPAD_Flush ( 0 ) ;
WPAD_Disconnect ( 0 ) ;
WPAD_Shutdown ( ) ;
2009-06-05 00:13:39 +02:00
if ( ret2 = = 1 ) {
Settings . cios = ios249 ;
} else if ( ret2 = = 2 ) {
2009-06-20 10:19:01 +02:00
Settings . cios = ios222 ;
2009-06-05 00:13:39 +02:00
} else {
Sys_LoadMenu ( ) ;
}
2009-06-23 20:59:28 +02:00
ret2 = DiscWait ( tr ( " No USB Device " ) , tr ( " Waiting for USB Device " ) , 0 , 0 , 1 ) ;
2009-06-05 00:13:39 +02:00
//reinitialize SD and USB
2009-06-12 13:50:14 +02:00
Wpad_Init ( ) ;
WPAD_SetDataFormat ( WPAD_CHAN_ALL , WPAD_FMT_BTNS_ACC_IR ) ;
WPAD_SetVRes ( WPAD_CHAN_ALL , screenwidth , screenheight ) ;
2009-06-20 13:11:07 +02:00
if ( ret2 < 0 ) {
2009-07-05 08:39:56 +02:00
WindowPrompt ( tr ( " Error ! " ) , tr ( " USB Device not found " ) , tr ( " OK " ) ) ;
2009-06-20 13:11:07 +02:00
Sys_LoadMenu ( ) ;
}
2009-06-05 00:13:39 +02:00
}
2009-06-02 08:55:21 +02:00
2009-06-05 00:13:39 +02:00
ret2 = Disc_Init ( ) ;
if ( ret2 < 0 ) {
2009-07-05 08:39:56 +02:00
WindowPrompt ( tr ( " Error ! " ) , tr ( " Could not initialize DIP module! " ) , tr ( " OK " ) ) ;
2009-06-05 00:13:39 +02:00
Sys_LoadMenu ( ) ;
}
2009-05-23 00:08:50 +02:00
2009-06-14 01:39:42 +02:00
ret2 = WBFS_Open ( ) ;
2009-06-05 00:13:39 +02:00
if ( ret2 < 0 ) {
2009-06-23 20:59:28 +02:00
choice = WindowPrompt ( tr ( " No WBFS partition found " ) ,
tr ( " You need to format a partition " ) ,
tr ( " Format " ) ,
2009-07-05 08:39:56 +02:00
tr ( " Return " ) ) ;
2009-06-05 00:13:39 +02:00
if ( choice = = 0 )
{
Sys_LoadMenu ( ) ;
} else {
/* Get partition entries */
u32 sector_size ;
ret2 = Partition_GetEntries ( partitions , & sector_size ) ;
if ( ret2 < 0 ) {
2009-07-05 08:39:56 +02:00
WindowPrompt ( tr ( " No partitions found " ) , 0 , tr ( " Restart " ) ) ;
2009-06-05 00:13:39 +02:00
Sys_LoadMenu ( ) ;
}
menu = MENU_FORMAT ;
}
}
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
if ( shutdown = = 1 )
Sys_Shutdown ( ) ;
if ( reset = = 1 )
Sys_Reboot ( ) ;
2009-06-20 13:11:07 +02:00
if ( wbfsinit < 0 ) {
sleep ( 1 ) ;
}
2009-06-05 00:13:39 +02:00
//Spieleliste laden
__Menu_GetEntries ( ) ;
2009-05-23 00:08:50 +02:00
2009-06-05 00:13:39 +02:00
if ( menu = = MENU_NONE )
menu = MENU_DISCLIST ;
2009-05-23 00:08:50 +02:00
2009-07-06 01:01:29 +02:00
//for HDDs with issues
if ( wbfsinit < 0 ) {
sleep ( 1 ) ;
USBDevice_Init ( ) ;
SDCard_Init ( ) ;
}
2009-05-23 00:08:50 +02:00
return menu ;
}
/****************************************************************************
* MainMenu
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int MainMenu ( int menu )
{
2009-06-25 14:47:09 +02:00
currentMenu = menu ;
2009-05-23 00:08:50 +02:00
char imgPath [ 100 ] ;
2009-06-18 18:09:45 +02:00
2009-05-23 00:08:50 +02:00
# ifdef HW_RVL
snprintf ( imgPath , sizeof ( imgPath ) , " %splayer1_point.png " , CFG . theme_path ) ;
pointer [ 0 ] = new GuiImageData ( imgPath , player1_point_png ) ;
snprintf ( imgPath , sizeof ( imgPath ) , " %splayer2_point.png " , CFG . theme_path ) ;
pointer [ 1 ] = new GuiImageData ( imgPath , player2_point_png ) ;
snprintf ( imgPath , sizeof ( imgPath ) , " %splayer3_point.png " , CFG . theme_path ) ;
pointer [ 2 ] = new GuiImageData ( imgPath , player3_point_png ) ;
snprintf ( imgPath , sizeof ( imgPath ) , " %splayer4_point.png " , CFG . theme_path ) ;
pointer [ 3 ] = new GuiImageData ( imgPath , player4_point_png ) ;
# endif
mainWindow = new GuiWindow ( screenwidth , screenheight ) ;
if ( CFG . widescreen )
snprintf ( imgPath , sizeof ( imgPath ) , " %swbackground.png " , CFG . theme_path ) ;
else
snprintf ( imgPath , sizeof ( imgPath ) , " %sbackground.png " , CFG . theme_path ) ;
background = new GuiImageData ( imgPath , CFG . widescreen ? wbackground_png : background_png ) ;
bgImg = new GuiImage ( background ) ;
mainWindow - > Append ( bgImg ) ;
ResumeGui ( ) ;
2009-06-06 19:26:52 +02:00
bgMusic = new GuiSound ( bg_music_ogg , bg_music_ogg_size , SOUND_OGG , Settings . volume ) ;
bgMusic - > SetVolume ( Settings . volume ) ;
2009-05-23 00:08:50 +02:00
bgMusic - > SetLoop ( 1 ) ; //loop music
// startup music
2009-06-04 03:04:23 +02:00
if ( ! strcmp ( " " , Settings . oggload_path ) | | ! strcmp ( " notset " , Settings . ogg_path ) ) {
2009-05-23 00:08:50 +02:00
bgMusic - > Play ( ) ;
} else {
2009-06-04 03:04:23 +02:00
bgMusic - > PlayOggFile ( Settings . ogg_path ) ;
2009-05-23 00:08:50 +02:00
}
while ( currentMenu ! = MENU_EXIT )
{
2009-06-06 19:26:52 +02:00
SetVolumeOgg ( 255 * ( Settings . volume / 100.0 ) ) ;
2009-05-23 00:08:50 +02:00
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 ;
2009-07-19 11:10:25 +02:00
case MENU_HOMEBREWBROWSE :
currentMenu = MenuHomebrewBrowse ( ) ;
break ;
2009-05-23 00:08:50 +02:00
case MENU_DISCLIST :
currentMenu = MenuDiscList ( ) ;
break ;
default : // unrecognized menu
currentMenu = MenuCheck ( ) ;
break ;
}
}
2009-07-23 19:24:08 +02:00
2009-07-18 13:04:13 +02:00
CloseXMLDatabase ( ) ;
2009-06-13 11:51:01 +02:00
ExitGUIThreads ( ) ;
2009-05-23 00:08:50 +02:00
bgMusic - > Stop ( ) ;
delete bgMusic ;
delete background ;
delete bgImg ;
delete mainWindow ;
2009-06-13 11:51:01 +02:00
for ( int i = 0 ; i < 4 ; i + + )
delete pointer [ i ] ;
2009-06-01 15:35:43 +02:00
delete GameRegionTxt ;
delete GameIDTxt ;
2009-05-23 00:08:50 +02:00
delete cover ;
delete coverImg ;
2009-06-14 01:47:38 +02:00
ShutdownAudio ( ) ;
StopGX ( ) ;
2009-07-23 19:24:08 +02:00
if ( boothomebrew = = 1 ) {
2009-07-19 11:10:25 +02:00
BootHomebrew ( Settings . selected_homebrew ) ;
2009-07-23 19:24:08 +02:00
} else if ( boothomebrew = = 2 ) {
BootHomebrewFromMem ( ) ;
2009-07-19 11:10:25 +02:00
} else {
2009-06-12 01:02:05 +02:00
int ret = 0 ;
2009-05-23 00:08:50 +02:00
struct discHdr * header = & gameList [ gameSelected ] ;
2009-06-12 01:02:05 +02:00
2009-05-23 00:08:50 +02:00
struct Game_CFG * game_cfg = CFG_get_game_opt ( header - > id ) ;
if ( game_cfg ) {
videoChoice = game_cfg - > video ;
languageChoice = game_cfg - > language ;
ocarinaChoice = game_cfg - > ocarina ;
viChoice = game_cfg - > vipatch ;
2009-06-06 19:26:52 +02:00
fix002 = game_cfg - > errorfix002 ;
2009-06-12 01:02:05 +02:00
iosChoice = game_cfg - > ios ;
2009-06-14 20:42:26 +02:00
countrystrings = game_cfg - > patchcountrystrings ;
2009-06-16 13:29:07 +02:00
alternatedol = game_cfg - > loadalternatedol ;
2009-07-15 19:20:45 +02:00
alternatedoloffset = game_cfg - > alternatedolstart ;
2009-06-18 18:09:45 +02:00
reloadblock = game_cfg - > iosreloadblock ;
2009-05-23 00:08:50 +02:00
} else {
videoChoice = Settings . video ;
languageChoice = Settings . language ;
ocarinaChoice = Settings . ocarina ;
viChoice = Settings . vpatch ;
2009-06-12 01:02:05 +02:00
if ( Settings . cios = = ios222 ) {
iosChoice = i222 ;
} else {
iosChoice = i249 ;
}
2009-06-14 20:42:26 +02:00
fix002 = Settings . error002 ;
countrystrings = Settings . patchcountrystrings ;
2009-06-16 13:29:07 +02:00
alternatedol = off ;
2009-07-15 19:20:45 +02:00
alternatedoloffset = 0 ;
2009-06-18 18:09:45 +02:00
reloadblock = off ;
2009-05-23 00:08:50 +02:00
}
2009-06-12 01:02:05 +02:00
int ios2 ;
switch ( iosChoice ) {
case i249 :
ios2 = 249 ;
break ;
case i222 :
ios2 = 222 ;
break ;
2009-06-12 13:50:14 +02:00
case i223 :
ios2 = 223 ;
break ;
2009-06-12 01:02:05 +02:00
default :
ios2 = 249 ;
break ;
}
2009-06-20 10:19:01 +02:00
bool onlinefix = ShutdownWC24 ( ) ;
2009-06-17 21:24:27 +02:00
if ( IOS_GetVersion ( ) ! = ios2 | | onlinefix = = true ) {
ret = Sys_IosReload ( ios2 ) ;
if ( ret < 0 ) {
Sys_IosReload ( 249 ) ;
}
}
2009-06-14 01:39:42 +02:00
ret = Disc_SetUSB ( header - > id ) ;
2009-06-12 01:02:05 +02:00
if ( ret < 0 ) Sys_BackToLoader ( ) ;
ret = Disc_Open ( ) ;
if ( ret < 0 ) Sys_BackToLoader ( ) ;
2009-06-14 01:47:38 +02:00
SDCard_deInit ( ) ;
USBDevice_deInit ( ) ;
2009-06-18 18:09:45 +02:00
if ( reloadblock = = on & & ( IOS_GetVersion ( ) = = 222 | | IOS_GetVersion ( ) = = 223 ) ) {
patch_cios_data ( ) ;
mload_close ( ) ;
}
2009-06-06 19:26:52 +02:00
u8 errorfixer002 = 0 ;
switch ( fix002 )
{
case on :
errorfixer002 = 1 ;
break ;
case off :
errorfixer002 = 0 ;
2009-06-25 17:58:16 +02:00
break ;
case anti :
errorfixer002 = 2 ;
2009-06-06 19:26:52 +02:00
break ;
}
2009-05-23 00:08:50 +02:00
2009-06-25 17:58:16 +02:00
switch ( languageChoice )
2009-05-23 00:08:50 +02:00
{
case ConsoleLangDefault :
configbytes [ 0 ] = 0xCD ;
break ;
case jap :
configbytes [ 0 ] = 0x00 ;
break ;
case eng :
2009-06-01 15:35:43 +02:00
configbytes [ 0 ] = 0x01 ;
2009-05-23 00:08:50 +02:00
break ;
case ger :
configbytes [ 0 ] = 0x02 ;
break ;
case fren :
configbytes [ 0 ] = 0x03 ;
break ;
case esp :
configbytes [ 0 ] = 0x04 ;
break ;
case it :
configbytes [ 0 ] = 0x05 ;
break ;
case dut :
configbytes [ 0 ] = 0x06 ;
break ;
case schin :
configbytes [ 0 ] = 0x07 ;
break ;
case tchin :
configbytes [ 0 ] = 0x08 ;
break ;
case kor :
configbytes [ 0 ] = 0x09 ;
break ;
//wenn nicht genau klar ist welches
default :
configbytes [ 0 ] = 0xCD ;
break ;
}
2009-05-30 18:58:34 +02:00
u8 videoselected = 0 ;
2009-05-23 00:08:50 +02:00
switch ( videoChoice )
{
case discdefault :
2009-06-14 12:08:41 +02:00
videoselected = 0 ;
2009-05-23 00:08:50 +02:00
break ;
case pal50 :
2009-06-14 12:08:41 +02:00
videoselected = 1 ;
2009-05-23 00:08:50 +02:00
break ;
case pal60 :
2009-06-14 12:08:41 +02:00
videoselected = 2 ;
2009-05-23 00:08:50 +02:00
break ;
case ntsc :
2009-06-14 12:08:41 +02:00
videoselected = 3 ;
2009-05-30 18:58:34 +02:00
break ;
2009-05-23 00:08:50 +02:00
case systemdefault :
2009-06-14 12:08:41 +02:00
videoselected = 4 ;
2009-05-23 00:08:50 +02:00
break ;
2009-05-30 18:58:34 +02:00
2009-05-23 00:08:50 +02:00
case patch :
2009-06-14 12:08:41 +02:00
videoselected = 5 ;
2009-05-23 00:08:50 +02:00
break ;
2009-05-30 18:58:34 +02:00
2009-05-23 00:08:50 +02:00
default :
2009-06-14 12:08:41 +02:00
videoselected = 0 ;
2009-05-23 00:08:50 +02:00
break ;
}
u32 cheat = 0 ;
switch ( ocarinaChoice )
{
case on :
cheat = 1 ;
break ;
case off :
cheat = 0 ;
break ;
default :
cheat = 1 ;
break ;
}
u8 vipatch = 0 ;
switch ( viChoice )
{
case on :
vipatch = 1 ;
break ;
case off :
vipatch = 0 ;
break ;
default :
vipatch = 0 ;
break ;
}
2009-07-16 00:13:19 +02:00
ret = Disc_WiiBoot ( videoselected , cheat , vipatch , countrystrings , errorfixer002 , alternatedol , alternatedoloffset ) ;
2009-05-23 00:08:50 +02:00
if ( ret < 0 ) {
2009-06-01 17:50:18 +02:00
Sys_LoadMenu ( ) ;
2009-05-23 00:08:50 +02:00
}
2009-07-19 11:10:25 +02:00
}
2009-05-23 00:08:50 +02:00
return 0 ;
}