2009-10-01 01:10:58 +02:00
# include <gccore.h>
# include <stdio.h>
# include <unistd.h>
# include <stdlib.h>
# include <string.h>
# include <dirent.h>
# include <time.h>
# include <stdlib.h>
# include "usbloader/wbfs.h"
# include "usbloader/wdvd.h"
2009-11-15 22:30:44 +01:00
# include "usbloader/partition_usbloader.h"
2010-02-22 22:29:47 +01:00
# include "usbloader/usbstorage2.h"
2010-09-18 13:46:25 +02:00
# include "usbloader/GameList.h"
2009-10-01 01:10:58 +02:00
# include "language/gettext.h"
# include "libwiigui/gui.h"
# include "libwiigui/gui_diskcover.h"
2010-09-17 17:15:21 +02:00
# include "libwiigui/Text.hpp"
2010-09-25 10:51:44 +02:00
# include "settings/CGameStatistics.h"
2009-10-01 01:10:58 +02:00
# include "network/networkops.h"
# include "network/http.h"
# include "prompts/PromptWindows.h"
2009-10-18 23:23:54 +02:00
# include "prompts/gameinfo.h"
2010-09-24 19:58:56 +02:00
# include "themes/CTheme.h"
2009-10-01 01:10:58 +02:00
# include "mload/mload.h"
# include "fatmounter.h"
2010-09-25 08:54:27 +02:00
# include "FileOperations/fileops.h"
2009-10-01 01:10:58 +02:00
# include "menu.h"
2010-01-19 11:48:50 +01:00
# include "menu.h"
2009-10-01 01:10:58 +02:00
# include "filelist.h"
# include "sys.h"
# include "wpad.h"
# include "wad/wad.h"
# include "zlib.h"
# include "svnrev.h"
# include "audio.h"
# include "xml/xml.h"
# include "language/UpdateLanguage.h"
2009-10-21 01:00:19 +02:00
# include "gecko.h"
2009-11-10 00:03:13 +01:00
# include "lstub.h"
# include "bannersound.h"
2009-11-18 10:01:14 +01:00
# include "buildtype.h"
2009-10-01 01:10:58 +02:00
/*** Variables that are also used extern ***/
int cntMissFiles = 0 ;
/*** Variables used only in this file ***/
static char missingFiles [ 500 ] [ 12 ] ;
/*** Extern variables ***/
extern GuiWindow * mainWindow ;
extern GuiSound * bgMusic ;
2010-09-18 13:46:25 +02:00
s32 gameSelected = 0 , gameStart = 0 ;
2009-10-01 01:10:58 +02:00
extern float gamesize ;
2010-01-19 11:48:50 +01:00
extern u8 shutdown ;
extern u8 reset ;
2009-10-01 11:17:55 +02:00
extern u8 mountMethod ;
2009-10-01 01:10:58 +02:00
extern struct discHdr * dvdheader ;
2009-11-22 17:42:53 +01:00
extern char game_partition [ 6 ] ;
2010-01-19 11:48:50 +01:00
/*** Extern functions ***/
extern void ResumeGui ( ) ;
extern void HaltGui ( ) ;
2009-10-01 01:10:58 +02:00
2009-12-10 21:27:36 +01:00
/****************************************************************************
* OnScreenNumpad
*
* Opens an on - screen numpad window , with the data entered being stored
* into the specified variable .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2010-09-24 02:48:03 +02:00
int OnScreenNumpad ( char * var , u32 maxlen )
2010-09-19 01:16:05 +02:00
{
int save = - 1 ;
2010-09-17 17:15:21 +02:00
2010-09-24 02:48:03 +02:00
GuiNumpad numpad ( var , maxlen ) ;
2010-09-17 17:15:21 +02:00
2010-09-24 02:48:03 +02:00
GuiSound btnSoundOver ( button_over_pcm , button_over_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
2010-09-24 02:48:03 +02:00
if ( ! btnClick2 ) btnClick2 = new GuiSound ( button_click2_pcm , button_click2_pcm_size , Settings . sfxvolume ) ;
2009-12-10 21:27:36 +01:00
2010-09-26 10:33:43 +02:00
GuiImageData btnOutline ( Resources : : GetFile ( " button_dialogue_box.png " ) , Resources : : GetFileSize ( " button_dialogue_box.png " ) ) ;
2009-12-10 21:27:36 +01:00
GuiTrigger trigA ;
2010-09-24 02:48:03 +02:00
trigA . SetSimpleTrigger ( - 1 , WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A , PAD_BUTTON_A ) ;
2009-12-10 21:27:36 +01:00
GuiTrigger trigB ;
2010-09-24 02:48:03 +02:00
trigB . SetSimpleTrigger ( - 1 , WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B , PAD_BUTTON_B ) ;
2009-12-10 21:27:36 +01:00
2010-09-24 19:58:56 +02:00
GuiText okBtnTxt ( tr ( " OK " ) , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
GuiImage okBtnImg ( & btnOutline ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
okBtnTxt . SetWidescreen ( Settings . widescreen ) ;
okBtnImg . SetWidescreen ( Settings . widescreen ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
GuiButton okBtn ( & okBtnImg , & okBtnImg , 0 , 4 , 5 , - 15 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
okBtn . SetLabel ( & okBtnTxt ) ;
2010-09-24 19:58:56 +02:00
GuiText cancelBtnTxt ( tr ( " Cancel " ) , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
GuiImage cancelBtnImg ( & btnOutline ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
cancelBtnTxt . SetWidescreen ( Settings . widescreen ) ;
cancelBtnImg . SetWidescreen ( Settings . widescreen ) ;
2009-12-10 21:27:36 +01:00
}
2010-09-24 02:48:03 +02:00
GuiButton cancelBtn ( & cancelBtnImg , & cancelBtnImg , 1 , 4 , - 5 , - 15 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
cancelBtn . SetLabel ( & cancelBtnTxt ) ;
cancelBtn . SetTrigger ( & trigB ) ;
2010-09-17 17:15:21 +02:00
2010-09-24 02:48:03 +02:00
numpad . Append ( & okBtn ) ;
numpad . Append ( & cancelBtn ) ;
2009-12-10 21:27:36 +01:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > SetState ( STATE_DISABLED ) ;
mainWindow - > Append ( & numpad ) ;
mainWindow - > ChangeFocus ( & numpad ) ;
2009-12-10 21:27:36 +01:00
ResumeGui ( ) ;
2010-09-24 02:48:03 +02:00
while ( save = = - 1 )
2010-09-19 01:16:05 +02:00
{
2009-12-10 21:27:36 +01:00
VIDEO_WaitVSync ( ) ;
2010-09-24 02:48:03 +02:00
if ( okBtn . GetState ( ) = = STATE_CLICKED )
2009-12-10 21:27:36 +01:00
save = 1 ;
2010-09-24 02:48:03 +02:00
else if ( cancelBtn . GetState ( ) = = STATE_CLICKED ) save = 0 ;
2009-12-10 21:27:36 +01:00
}
2010-09-24 02:48:03 +02:00
if ( save = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
snprintf ( var , maxlen , " %s " , numpad . kbtextstr ) ;
2009-12-10 21:27:36 +01:00
}
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > Remove ( & numpad ) ;
mainWindow - > SetState ( STATE_DEFAULT ) ;
2009-12-10 21:27:36 +01:00
ResumeGui ( ) ;
2010-09-24 02:48:03 +02:00
gprintf ( " \t %s " , ( save = = 1 ? " saved " : " discarded " ) ) ;
2010-09-17 17:15:21 +02:00
return save ;
2009-12-10 21:27:36 +01:00
}
2009-10-01 01:10:58 +02:00
/****************************************************************************
* OnScreenKeyboard
*
* Opens an on - screen keyboard window , with the data entered being stored
* into the specified variable .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2010-09-24 02:48:03 +02:00
int OnScreenKeyboard ( char * var , u32 maxlen , int min )
2010-09-19 01:16:05 +02:00
{
2009-11-08 21:13:57 +01:00
2009-10-01 01:10:58 +02:00
int save = - 1 ;
int keyset = 0 ;
2010-09-24 02:48:03 +02:00
if ( Settings . keyset = = us )
keyset = 0 ;
else if ( Settings . keyset = = dvorak )
keyset = 1 ;
else if ( Settings . keyset = = euro )
keyset = 2 ;
else if ( Settings . keyset = = azerty )
keyset = 3 ;
else if ( Settings . keyset = = qwerty ) keyset = 4 ;
2009-11-08 21:13:57 +01:00
2010-09-24 02:48:03 +02:00
gprintf ( " \n OnScreenKeyboard(%s, %i, %i) \n \t keyset = %i " , var , maxlen , min , keyset ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
GuiKeyboard keyboard ( var , maxlen , min , keyset ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
GuiSound btnSoundOver ( button_over_pcm , button_over_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
2010-09-24 02:48:03 +02:00
if ( ! btnClick2 ) btnClick2 = new GuiSound ( button_click2_pcm , button_click2_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
2009-10-01 01:10:58 +02:00
2010-09-26 10:33:43 +02:00
GuiImageData btnOutline ( Resources : : GetFile ( " button_dialogue_box.png " ) , Resources : : GetFileSize ( " button_dialogue_box.png " ) ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigA ;
2010-09-24 02:48:03 +02:00
trigA . SetSimpleTrigger ( - 1 , WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A , PAD_BUTTON_A ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigB ;
2010-09-24 02:48:03 +02:00
trigB . SetSimpleTrigger ( - 1 , WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B , PAD_BUTTON_B ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 19:58:56 +02:00
GuiText okBtnTxt ( tr ( " OK " ) , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
GuiImage okBtnImg ( & btnOutline ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
okBtnTxt . SetWidescreen ( Settings . widescreen ) ;
okBtnImg . SetWidescreen ( Settings . widescreen ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
GuiButton okBtn ( & okBtnImg , & okBtnImg , 0 , 4 , 5 , 15 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
okBtn . SetLabel ( & okBtnTxt ) ;
2010-09-24 19:58:56 +02:00
GuiText cancelBtnTxt ( tr ( " Cancel " ) , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
GuiImage cancelBtnImg ( & btnOutline ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
cancelBtnTxt . SetWidescreen ( Settings . widescreen ) ;
cancelBtnImg . SetWidescreen ( Settings . widescreen ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
GuiButton cancelBtn ( & cancelBtnImg , & cancelBtnImg , 1 , 4 , - 5 , 15 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
cancelBtn . SetLabel ( & cancelBtnTxt ) ;
cancelBtn . SetTrigger ( & trigB ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
keyboard . Append ( & okBtn ) ;
keyboard . Append ( & cancelBtn ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > SetState ( STATE_DISABLED ) ;
mainWindow - > Append ( & keyboard ) ;
mainWindow - > ChangeFocus ( & keyboard ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
2010-09-24 02:48:03 +02:00
while ( save = = - 1 )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
VIDEO_WaitVSync ( ) ;
2010-09-24 02:48:03 +02:00
if ( okBtn . GetState ( ) = = STATE_CLICKED )
2009-10-01 01:10:58 +02:00
save = 1 ;
2010-09-24 02:48:03 +02:00
else if ( cancelBtn . GetState ( ) = = STATE_CLICKED ) save = 0 ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
if ( save )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
snprintf ( var , maxlen , " %s " , keyboard . kbtextstr ) ;
2009-10-01 01:10:58 +02:00
}
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > Remove ( & keyboard ) ;
mainWindow - > SetState ( STATE_DEFAULT ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
2010-09-24 02:48:03 +02:00
gprintf ( " \t %s " , ( save ? " saved " : " discarded " ) ) ;
2009-10-01 01:10:58 +02:00
return save ;
}
/****************************************************************************
* WindowCredits
* Display credits
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2010-09-19 01:16:05 +02:00
void WindowCredits ( )
{
2010-09-24 02:48:03 +02:00
gprintf ( " WindowCredits() \n " ) ;
2009-11-08 21:13:57 +01:00
2009-10-01 01:10:58 +02:00
int angle = 0 ;
GuiSound * creditsMusic = NULL ;
2009-11-10 00:03:13 +01:00
bgMusic - > Pause ( ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
creditsMusic = new GuiSound ( credits_music_ogg , credits_music_ogg_size , 55 ) ;
creditsMusic - > SetVolume ( 60 ) ;
creditsMusic - > SetLoop ( 1 ) ;
2009-10-01 01:10:58 +02:00
creditsMusic - > Play ( ) ;
bool exit = false ;
int i = 0 ;
int y = 20 ;
2010-09-24 02:48:03 +02:00
GuiWindow creditsWindow ( screenwidth , screenheight ) ;
GuiWindow creditsWindowBox ( 580 , 448 ) ;
creditsWindowBox . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
2009-10-01 01:10:58 +02:00
2010-09-26 10:33:43 +02:00
GuiImageData creditsBox ( credits_bg_png , credits_bg_png_size ) ;
2010-09-24 02:48:03 +02:00
GuiImage creditsBoxImg ( & creditsBox ) ;
creditsBoxImg . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
creditsWindowBox . Append ( & creditsBoxImg ) ;
2009-10-01 01:10:58 +02:00
2010-09-26 10:33:43 +02:00
GuiImageData star ( little_star_png , little_star_png_size ) ;
2010-09-24 02:48:03 +02:00
GuiImage starImg ( & star ) ;
starImg . SetWidescreen ( Settings . widescreen ) ; //added
starImg . SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
starImg . SetPosition ( 505 , 350 ) ;
2009-10-01 01:10:58 +02:00
2009-12-04 16:05:20 +01:00
int numEntries = 21 ;
2009-10-01 01:10:58 +02:00
GuiText * txt [ numEntries ] ;
2010-09-24 02:48:03 +02:00
txt [ i ] = new GuiText ( tr ( " Credits " ) , 26 , ( GXColor )
{ 255 , 255 , 255 , 255 } ) ;
txt [ i ] - > SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 0 , 12 ) ;
2009-10-01 01:10:58 +02:00
i + + ;
2009-11-18 10:01:14 +01:00
# ifdef FULLCHANNEL
2009-10-01 01:10:58 +02:00
char svnTmp [ 4 ] ; //did this to hide the M after the rev# that is made by altering it
//to be ready to be in a full channel
2010-09-19 01:16:05 +02:00
snprintf ( svnTmp , sizeof ( svnTmp ) , " %s " , GetRev ( ) ) ;
2009-10-01 01:10:58 +02:00
char SvnRev [ 30 ] ;
2010-09-19 01:16:05 +02:00
snprintf ( SvnRev , sizeof ( SvnRev ) , " Rev%sc IOS%u (Rev %u) " , svnTmp , IOS_GetVersion ( ) , IOS_GetRevision ( ) ) ;
2009-11-18 10:01:14 +01:00
# else
char SvnRev [ 30 ] ;
2010-09-24 02:48:03 +02:00
snprintf ( SvnRev , sizeof ( SvnRev ) , " Rev%s IOS%u (Rev %u) " , GetRev ( ) , IOS_GetVersion ( ) , IOS_GetRevision ( ) ) ;
2009-10-01 01:10:58 +02:00
# endif
2010-09-24 02:48:03 +02:00
txt [ i ] = new GuiText ( SvnRev , 16 , ( GXColor )
{ 255 , 255 , 255 , 255 } ) ;
txt [ i ] - > SetAlignment ( ALIGN_RIGHT , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 0 , y ) ;
2009-10-01 01:10:58 +02:00
i + + ;
2010-09-19 01:16:05 +02:00
y + = 34 ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
txt [ i ] = new GuiText ( " USB Loader GX " , 24 , ( GXColor )
{ 255 , 255 , 255 , 255 } ) ;
txt [ i ] - > SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 0 , y ) ;
2009-10-01 01:10:58 +02:00
i + + ;
2010-09-19 01:16:05 +02:00
y + = 26 ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
txt [ i ] = new GuiText ( tr ( " Official Site: " ) , 20 , ( GXColor )
{ 255 , 255 , 255 , 255 } ) ;
txt [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 10 , y ) ;
2009-10-01 01:10:58 +02:00
i + + ;
2009-12-04 16:05:20 +01:00
2010-09-24 02:48:03 +02:00
txt [ i ] = new GuiText ( " http://code.google.com/p/usbloader-gui/ " , 20 , ( GXColor )
{ 255 , 255 , 255 , 255 } ) ;
txt [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 160 , y ) ;
2009-12-04 16:05:20 +01:00
i + + ;
2010-09-19 01:16:05 +02:00
y + = 26 ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
GuiText : : SetPresets ( 22 , ( GXColor )
{ 255 , 255 , 255 , 255 } , 3000 , FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP , ALIGN_LEFT , ALIGN_TOP ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
txt [ i ] = new GuiText ( tr ( " Coding: " ) ) ;
txt [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 10 , y ) ;
2009-10-01 01:10:58 +02:00
i + + ;
2010-09-24 02:48:03 +02:00
txt [ i ] = new GuiText ( " dimok / nIxx / giantpune / ardi " ) ;
txt [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 160 , y ) ;
2009-10-01 01:10:58 +02:00
i + + ;
2010-09-19 01:16:05 +02:00
y + = 22 ;
2009-10-13 12:47:56 +02:00
2010-09-24 02:48:03 +02:00
txt [ i ] = new GuiText ( " hungyip84 / DrayX7 / lustar / r-win " ) ;
txt [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 160 , y ) ;
2009-10-13 12:47:56 +02:00
i + + ;
2010-09-19 01:16:05 +02:00
y + = 26 ;
2009-10-01 01:10:58 +02:00
char text [ 100 ] ;
2010-09-24 02:48:03 +02:00
txt [ i ] = new GuiText ( tr ( " Design: " ) ) ;
txt [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 10 , y ) ;
2009-10-01 01:10:58 +02:00
i + + ;
2010-09-24 02:48:03 +02:00
txt [ i ] = new GuiText ( " cyrex / NeoRame " ) ;
txt [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 160 , y ) ;
2009-10-01 01:10:58 +02:00
i + + ;
2010-09-19 01:16:05 +02:00
y + = 26 ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
txt [ i ] = new GuiText ( tr ( " Big thanks to: " ) ) ;
txt [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 10 , y ) ;
2009-10-01 01:10:58 +02:00
i + + ;
2010-09-24 02:48:03 +02:00
sprintf ( text , " lustar %s " , tr ( " for WiiTDB and hosting covers / disc images " ) ) ;
txt [ i ] = new GuiText ( text ) ;
txt [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 160 , y ) ;
2009-10-01 01:10:58 +02:00
i + + ;
2010-09-19 01:16:05 +02:00
y + = 22 ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
sprintf ( text , " CorneliousJD %s " , tr ( " for hosting the update files " ) ) ;
txt [ i ] = new GuiText ( text ) ;
txt [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 160 , y ) ;
2009-10-15 07:52:33 +02:00
i + + ;
2010-09-19 01:16:05 +02:00
y + = 22 ;
2009-10-15 07:52:33 +02:00
2010-09-24 02:48:03 +02:00
sprintf ( text , " Kinyo %s " , tr ( " and translaters for language files updates " ) ) ;
txt [ i ] = new GuiText ( text ) ;
txt [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 160 , y ) ;
2009-10-01 01:10:58 +02:00
i + + ;
2010-09-19 01:16:05 +02:00
y + = 22 ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
sprintf ( text , " Deak Phreak %s " , tr ( " for hosting the themes " ) ) ;
txt [ i ] = new GuiText ( text ) ;
txt [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 160 , y ) ;
2009-10-22 16:45:07 +02:00
i + + ;
2010-09-19 01:16:05 +02:00
y + = 26 ;
2009-10-22 16:45:07 +02:00
2010-09-24 02:48:03 +02:00
txt [ i ] = new GuiText ( tr ( " Special thanks to: " ) ) ;
txt [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 10 , y ) ;
2009-10-01 01:10:58 +02:00
i + + ;
2010-09-19 01:16:05 +02:00
y + = 22 ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
sprintf ( text , " Waninkoko, Kwiirk & Hermes %s " , tr ( " for the USB Loader source " ) ) ;
txt [ i ] = new GuiText ( text ) ;
txt [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 60 , y ) ;
2009-10-01 01:10:58 +02:00
i + + ;
2010-09-19 01:16:05 +02:00
y + = 22 ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
sprintf ( text , " Tantric %s " , tr ( " for his awesome tool LibWiiGui " ) ) ;
txt [ i ] = new GuiText ( text ) ;
txt [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 60 , y ) ;
2009-10-01 01:10:58 +02:00
i + + ;
2010-09-19 01:16:05 +02:00
y + = 22 ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
sprintf ( text , " Fishears/Nuke %s " , tr ( " for Ocarina " ) ) ;
txt [ i ] = new GuiText ( text ) ;
txt [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 60 , y ) ;
2009-10-01 01:10:58 +02:00
i + + ;
2010-09-19 01:16:05 +02:00
y + = 22 ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
sprintf ( text , " WiiPower %s " , tr ( " for diverse patches " ) ) ;
txt [ i ] = new GuiText ( text ) ;
txt [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 60 , y ) ;
2009-10-01 01:10:58 +02:00
i + + ;
2010-09-19 01:16:05 +02:00
y + = 22 ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
sprintf ( text , " Oggzee %s " , tr ( " for FAT/NTFS support " ) ) ;
txt [ i ] = new GuiText ( text ) ;
txt [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
txt [ i ] - > SetPosition ( 60 , y ) ;
2009-12-04 16:05:20 +01:00
i + + ;
2010-09-19 01:16:05 +02:00
y + = 22 ;
2009-12-04 16:05:20 +01:00
2010-09-24 02:48:03 +02:00
for ( i = 0 ; i < numEntries ; i + + )
creditsWindowBox . Append ( txt [ i ] ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
creditsWindow . Append ( & creditsWindowBox ) ;
creditsWindow . Append ( & starImg ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
creditsWindow . SetEffect ( EFFECT_FADE , 30 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > SetState ( STATE_DISABLED ) ;
mainWindow - > Append ( & creditsWindow ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
2010-09-24 02:48:03 +02:00
while ( ! exit )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
angle + + ;
2010-09-24 02:48:03 +02:00
if ( angle > 360 ) angle = 0 ;
usleep ( 12000 ) ;
starImg . SetAngle ( angle ) ;
if ( ButtonsPressed ( ) ! = 0 ) exit = true ;
2009-10-01 01:10:58 +02:00
}
creditsMusic - > Stop ( ) ;
delete creditsMusic ;
2010-09-24 02:48:03 +02:00
creditsWindow . SetEffect ( EFFECT_FADE , - 30 ) ;
while ( creditsWindow . GetEffect ( ) > 0 )
usleep ( 50 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > Remove ( & creditsWindow ) ;
mainWindow - > SetState ( STATE_DEFAULT ) ;
for ( i = 0 ; i < numEntries ; i + + )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
delete txt [ i ] ;
txt [ i ] = NULL ;
}
ResumeGui ( ) ;
2009-11-10 00:03:13 +01:00
bgMusic - > Resume ( ) ;
2009-10-01 01:10:58 +02:00
}
/****************************************************************************
* WindowScreensaver
* Display screensaver
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2010-09-19 01:16:05 +02:00
int WindowScreensaver ( )
{
2010-09-24 02:48:03 +02:00
gprintf ( " WindowScreenSaver() \n " ) ;
2010-09-19 01:16:05 +02:00
int i = 0 ;
bool exit = false ;
/* initialize random seed: */
2010-09-24 02:48:03 +02:00
srand ( time ( NULL ) ) ;
2010-09-19 01:16:05 +02:00
2010-09-26 10:33:43 +02:00
GuiImageData GXlogo ( Resources : : GetFile ( " gxlogo.png " ) , Resources : : GetFileSize ( " gxlogo.png " ) ) ; //uncomment for themable screensaver
2010-09-19 01:16:05 +02:00
//GuiImageData GXlogo(gxlogo_png);//comment for themable screensaver
2010-09-24 02:48:03 +02:00
GuiImage GXlogoImg ( & GXlogo ) ;
GXlogoImg . SetPosition ( 172 , 152 ) ;
GXlogoImg . SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
GuiImage BackgroundImg ( 640 , 480 , ( GXColor )
{ 0 , 0 , 0 , 255 } ) ;
BackgroundImg . SetPosition ( 0 , 0 ) ;
BackgroundImg . SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
GuiWindow screensaverWindow ( screenwidth , screenheight ) ;
screensaverWindow . Append ( & BackgroundImg ) ;
screensaverWindow . Append ( & GXlogoImg ) ;
2010-09-19 01:16:05 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > SetState ( STATE_DISABLED ) ;
mainWindow - > Append ( & screensaverWindow ) ;
2010-09-19 01:16:05 +02:00
ResumeGui ( ) ;
2010-09-24 02:48:03 +02:00
while ( ! exit )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
i + + ;
2010-09-24 02:48:03 +02:00
if ( IsWpadConnected ( ) )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
exit = true ;
}
/* Set position only every 400000th loop */
2010-09-24 02:48:03 +02:00
if ( ( i % 8000000 ) = = 0 )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
/* Set random position */
2010-09-24 02:48:03 +02:00
GXlogoImg . SetPosition ( ( rand ( ) % 345 ) , ( rand ( ) % 305 ) ) ;
2009-10-01 01:10:58 +02:00
}
}
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > Remove ( & screensaverWindow ) ;
mainWindow - > SetState ( STATE_DEFAULT ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
return 1 ;
}
/****************************************************************************
* WindowPrompt
*
* Displays a prompt window to user , with information , an error message , or
* presenting a user with a choice of up to 4 Buttons .
*
* Give him 1 Title , 1 Subtitle and 4 Buttons
* If title / subtitle or one of the buttons is not needed give him a 0 on that
* place .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2010-09-24 02:48:03 +02:00
int WindowPrompt ( const char * title , const char * msg , const char * btn1Label , const char * btn2Label ,
const char * btn3Label , const char * btn4Label , int wait )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
int choice = - 1 ;
int count = wait ;
2010-09-24 02:48:03 +02:00
gprintf ( " WindowPrompt( %s, %s, %s, %s, %s, %s, %i ): " , title , msg , btn1Label , btn2Label , btn3Label , btn4Label ,
wait ) ;
2009-11-08 21:13:57 +01:00
2010-09-24 02:48:03 +02:00
GuiWindow promptWindow ( 472 , 320 ) ;
promptWindow . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
promptWindow . SetPosition ( 0 , - 10 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
GuiSound btnSoundOver ( button_over_pcm , button_over_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
2010-09-24 02:48:03 +02:00
if ( ! btnClick2 ) btnClick2 = new GuiSound ( button_click2_pcm , button_click2_pcm_size , Settings . sfxvolume ) ;
2010-09-28 20:58:56 +02:00
2010-09-26 10:33:43 +02:00
GuiImageData btnOutline ( Resources : : GetFile ( " button_dialogue_box.png " ) , Resources : : GetFileSize ( " button_dialogue_box.png " ) ) ;
GuiImageData dialogBox ( Resources : : GetFile ( " dialogue_box.png " ) , Resources : : GetFileSize ( " dialogue_box.png " ) ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigA ;
2010-09-24 02:48:03 +02:00
trigA . SetSimpleTrigger ( - 1 , WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A , PAD_BUTTON_A ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigB ;
2010-09-24 02:48:03 +02:00
trigB . SetButtonOnlyTrigger ( - 1 , WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B , PAD_BUTTON_B ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
GuiImage dialogBoxImg ( & dialogBox ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
dialogBoxImg . SetWidescreen ( Settings . widescreen ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 19:58:56 +02:00
GuiText titleTxt ( title , 26 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
titleTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
titleTxt . SetPosition ( 0 , 55 ) ;
2010-09-24 19:58:56 +02:00
GuiText msgTxt ( msg , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
msgTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
msgTxt . SetPosition ( 0 , - 40 ) ;
msgTxt . SetMaxWidth ( 430 ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 19:58:56 +02:00
GuiText btn1Txt ( btn1Label , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
GuiImage btn1Img ( & btnOutline ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
btn1Txt . SetWidescreen ( Settings . widescreen ) ;
btn1Img . SetWidescreen ( Settings . widescreen ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
GuiButton btn1 ( & btn1Img , & btn1Img , 0 , 3 , 0 , 0 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
btn1 . SetLabel ( & btn1Txt ) ;
btn1 . SetState ( STATE_SELECTED ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 19:58:56 +02:00
GuiText btn2Txt ( btn2Label , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
GuiImage btn2Img ( & btnOutline ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
btn2Txt . SetWidescreen ( Settings . widescreen ) ;
btn2Img . SetWidescreen ( Settings . widescreen ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
GuiButton btn2 ( & btn2Img , & btn2Img , 0 , 3 , 0 , 0 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
btn2 . SetLabel ( & btn2Txt ) ;
if ( ! btn3Label & & ! btn4Label ) btn2 . SetTrigger ( & trigB ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 19:58:56 +02:00
GuiText btn3Txt ( btn3Label , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
GuiImage btn3Img ( & btnOutline ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
btn3Txt . SetWidescreen ( Settings . widescreen ) ;
btn3Img . SetWidescreen ( Settings . widescreen ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
GuiButton btn3 ( & btn3Img , & btn3Img , 0 , 3 , 0 , 0 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
btn3 . SetLabel ( & btn3Txt ) ;
if ( ! btn4Label ) btn3 . SetTrigger ( & trigB ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 19:58:56 +02:00
GuiText btn4Txt ( btn4Label , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
GuiImage btn4Img ( & btnOutline ) ;
if ( Settings . wsprompt = = yes )
{
btn4Txt . SetWidescreen ( Settings . widescreen ) ;
btn4Img . SetWidescreen ( Settings . widescreen ) ;
}
GuiButton btn4 ( & btn4Img , & btn4Img , 0 , 3 , 0 , 0 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
btn4 . SetLabel ( & btn4Txt ) ;
if ( btn4Label ) btn4 . SetTrigger ( & trigB ) ;
if ( ( Settings . wsprompt = = yes ) & & ( Settings . widescreen ) ) /////////////adjust buttons for widescreen
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
msgTxt . SetMaxWidth ( 330 ) ;
if ( btn2Label & & ! btn3Label & & ! btn4Label )
{
btn1 . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
btn1 . SetPosition ( 70 , - 80 ) ;
btn2 . SetAlignment ( ALIGN_RIGHT , ALIGN_BOTTOM ) ;
btn2 . SetPosition ( - 70 , - 80 ) ;
btn3 . SetAlignment ( ALIGN_RIGHT , ALIGN_BOTTOM ) ;
btn3 . SetPosition ( - 70 , - 55 ) ;
btn4 . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
btn4 . SetPosition ( 70 , - 55 ) ;
}
else if ( btn2Label & & btn3Label & & ! btn4Label )
{
btn1 . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
btn1 . SetPosition ( 70 , - 120 ) ;
btn2 . SetAlignment ( ALIGN_RIGHT , ALIGN_BOTTOM ) ;
btn2 . SetPosition ( - 70 , - 120 ) ;
btn3 . SetAlignment ( ALIGN_CENTRE , ALIGN_BOTTOM ) ;
btn3 . SetPosition ( 0 , - 55 ) ;
btn4 . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
btn4 . SetPosition ( 70 , - 55 ) ;
}
else if ( btn2Label & & btn3Label & & btn4Label )
{
btn1 . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
btn1 . SetPosition ( 70 , - 120 ) ;
btn2 . SetAlignment ( ALIGN_RIGHT , ALIGN_BOTTOM ) ;
btn2 . SetPosition ( - 70 , - 120 ) ;
btn3 . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
btn3 . SetPosition ( 70 , - 55 ) ;
btn4 . SetAlignment ( ALIGN_RIGHT , ALIGN_BOTTOM ) ;
btn4 . SetPosition ( - 70 , - 55 ) ;
}
else if ( ! btn2Label & & btn3Label & & btn4Label )
{
btn1 . SetAlignment ( ALIGN_CENTRE , ALIGN_BOTTOM ) ;
btn1 . SetPosition ( 0 , - 120 ) ;
btn2 . SetAlignment ( ALIGN_RIGHT , ALIGN_BOTTOM ) ;
btn2 . SetPosition ( - 70 , - 120 ) ;
btn3 . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
btn3 . SetPosition ( 70 , - 55 ) ;
btn4 . SetAlignment ( ALIGN_RIGHT , ALIGN_BOTTOM ) ;
btn4 . SetPosition ( - 70 , - 55 ) ;
2010-09-19 01:16:05 +02:00
}
else
{
2010-09-24 02:48:03 +02:00
btn1 . SetAlignment ( ALIGN_CENTRE , ALIGN_BOTTOM ) ;
btn1 . SetPosition ( 0 , - 80 ) ;
btn2 . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
btn2 . SetPosition ( 70 , - 120 ) ;
btn3 . SetAlignment ( ALIGN_RIGHT , ALIGN_BOTTOM ) ;
btn3 . SetPosition ( - 70 , - 55 ) ;
btn4 . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
btn4 . SetPosition ( 70 , - 55 ) ;
2010-09-19 01:16:05 +02:00
}
}
else
{
2010-09-24 02:48:03 +02:00
if ( btn2Label & & ! btn3Label & & ! btn4Label )
{
btn1 . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
btn1 . SetPosition ( 40 , - 45 ) ;
btn2 . SetAlignment ( ALIGN_RIGHT , ALIGN_BOTTOM ) ;
btn2 . SetPosition ( - 40 , - 45 ) ;
btn3 . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
btn3 . SetPosition ( 50 , - 65 ) ;
btn4 . SetAlignment ( ALIGN_RIGHT , ALIGN_BOTTOM ) ;
btn4 . SetPosition ( - 50 , - 65 ) ;
}
else if ( btn2Label & & btn3Label & & ! btn4Label )
{
btn1 . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
btn1 . SetPosition ( 50 , - 120 ) ;
btn2 . SetAlignment ( ALIGN_RIGHT , ALIGN_BOTTOM ) ;
btn2 . SetPosition ( - 50 , - 120 ) ;
btn3 . SetAlignment ( ALIGN_CENTRE , ALIGN_BOTTOM ) ;
btn3 . SetPosition ( 0 , - 65 ) ;
btn4 . SetAlignment ( ALIGN_RIGHT , ALIGN_BOTTOM ) ;
btn4 . SetPosition ( - 50 , - 65 ) ;
}
else if ( btn2Label & & btn3Label & & btn4Label )
{
btn1 . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
btn1 . SetPosition ( 50 , - 120 ) ;
btn2 . SetAlignment ( ALIGN_RIGHT , ALIGN_BOTTOM ) ;
btn2 . SetPosition ( - 50 , - 120 ) ;
btn3 . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
btn3 . SetPosition ( 50 , - 65 ) ;
btn4 . SetAlignment ( ALIGN_RIGHT , ALIGN_BOTTOM ) ;
btn4 . SetPosition ( - 50 , - 65 ) ;
}
else if ( ! btn2Label & & btn3Label & & btn4Label )
{
btn1 . SetAlignment ( ALIGN_CENTRE , ALIGN_BOTTOM ) ;
btn1 . SetPosition ( 0 , - 120 ) ;
btn2 . SetAlignment ( ALIGN_RIGHT , ALIGN_BOTTOM ) ;
btn2 . SetPosition ( - 50 , - 120 ) ;
btn3 . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
btn3 . SetPosition ( 50 , - 65 ) ;
btn4 . SetAlignment ( ALIGN_RIGHT , ALIGN_BOTTOM ) ;
btn4 . SetPosition ( - 50 , - 65 ) ;
2010-09-19 01:16:05 +02:00
}
else
{
2010-09-24 02:48:03 +02:00
btn1 . SetAlignment ( ALIGN_CENTRE , ALIGN_BOTTOM ) ;
btn1 . SetPosition ( 0 , - 45 ) ;
btn2 . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
btn2 . SetPosition ( 50 , - 120 ) ;
btn3 . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
btn3 . SetPosition ( 50 , - 65 ) ;
btn4 . SetAlignment ( ALIGN_RIGHT , ALIGN_BOTTOM ) ;
btn4 . SetPosition ( - 50 , - 65 ) ;
2009-10-01 01:10:58 +02:00
}
}
2010-01-19 11:48:50 +01:00
GuiTrigger trigZ ;
2010-09-24 02:48:03 +02:00
trigZ . SetButtonOnlyTrigger ( - 1 , WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL , PAD_TRIGGER_Z ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
GuiButton screenShotBtn ( 0 , 0 ) ;
screenShotBtn . SetPosition ( 0 , 0 ) ;
screenShotBtn . SetTrigger ( & trigZ ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
promptWindow . Append ( & dialogBoxImg ) ;
promptWindow . Append ( & titleTxt ) ;
promptWindow . Append ( & msgTxt ) ;
promptWindow . Append ( & screenShotBtn ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
if ( btn1Label ) promptWindow . Append ( & btn1 ) ;
if ( btn2Label ) promptWindow . Append ( & btn2 ) ;
if ( btn3Label ) promptWindow . Append ( & btn3 ) ;
if ( btn4Label ) promptWindow . Append ( & btn4 ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN , 50 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > SetState ( STATE_DISABLED ) ;
mainWindow - > Append ( & promptWindow ) ;
mainWindow - > ChangeFocus ( & promptWindow ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
2010-09-24 02:48:03 +02:00
while ( choice = = - 1 )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
VIDEO_WaitVSync ( ) ;
2010-09-24 02:48:03 +02:00
if ( shutdown = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
wiilight ( 0 ) ;
2010-01-19 11:48:50 +01:00
Sys_Shutdown ( ) ;
}
2010-09-24 02:48:03 +02:00
if ( reset = = 1 ) Sys_Reboot ( ) ;
if ( btn1 . GetState ( ) = = STATE_CLICKED )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
choice = 1 ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( btn2 . GetState ( ) = = STATE_CLICKED )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
if ( ! btn3Label )
2009-10-01 01:10:58 +02:00
choice = 0 ;
2010-09-24 02:48:03 +02:00
else choice = 2 ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( btn3 . GetState ( ) = = STATE_CLICKED )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
if ( ! btn4Label )
2009-10-01 01:10:58 +02:00
choice = 0 ;
2010-09-24 02:48:03 +02:00
else choice = 3 ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( btn4 . GetState ( ) = = STATE_CLICKED )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
choice = 0 ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( screenShotBtn . GetState ( ) = = STATE_CLICKED )
{
2010-09-19 01:16:05 +02:00
screenShotBtn . ResetState ( ) ;
2010-09-24 02:48:03 +02:00
ScreenShot ( ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
if ( count > 0 ) count - - ;
if ( count = = 0 ) choice = 1 ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT , 50 ) ;
while ( promptWindow . GetEffect ( ) > 0 )
usleep ( 50 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > Remove ( & promptWindow ) ;
mainWindow - > SetState ( STATE_DEFAULT ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
2010-09-24 02:48:03 +02:00
gprintf ( " %i \n " , choice ) ;
2009-11-08 21:13:57 +01:00
2009-10-01 01:10:58 +02:00
return choice ;
}
/****************************************************************************
* WindowExitPrompt
*
* Displays a prompt window to user , with information , an error message , or
* presenting a user with a choice of up to 4 Buttons .
*
* Give him 1 Titel , 1 Subtitel and 4 Buttons
* If titel / subtitle or one of the buttons is not needed give him a 0 on that
* place .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2010-02-09 11:59:55 +01:00
int WindowExitPrompt ( )
{
2010-09-24 02:48:03 +02:00
gprintf ( " WindowExitPrompt() \n " ) ;
2009-11-08 21:13:57 +01:00
2009-10-01 01:10:58 +02:00
GuiSound * homein = NULL ;
2010-09-24 02:48:03 +02:00
homein = new GuiSound ( menuin_ogg , menuin_ogg_size , Settings . sfxvolume ) ;
homein - > SetVolume ( Settings . sfxvolume ) ;
homein - > SetLoop ( 0 ) ;
2009-10-01 01:10:58 +02:00
homein - > Play ( ) ;
GuiSound * homeout = NULL ;
2010-09-24 02:48:03 +02:00
homeout = new GuiSound ( menuout_ogg , menuout_ogg_size , Settings . sfxvolume ) ;
homeout - > SetVolume ( Settings . sfxvolume ) ;
homeout - > SetLoop ( 0 ) ;
2009-10-01 01:10:58 +02:00
int choice = - 1 ;
2009-11-08 21:13:57 +01:00
2010-09-19 01:16:05 +02:00
u64 oldstub = getStubDest ( ) ;
loadStub ( ) ;
2010-09-24 02:48:03 +02:00
if ( oldstub ! = 0x00010001554c4e52ll & & oldstub ! = 0x00010001554e454fll ) Set_Stub ( oldstub ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
GuiWindow promptWindow ( 640 , 480 ) ;
promptWindow . SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
promptWindow . SetPosition ( 0 , 0 ) ;
GuiSound btnSoundOver ( button_over_pcm , button_over_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
2010-09-24 02:48:03 +02:00
if ( ! btnClick2 ) btnClick2 = new GuiSound ( button_click2_pcm , button_click2_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
2010-09-26 10:33:43 +02:00
GuiImageData top ( exit_top_png , exit_top_png_size ) ;
GuiImageData topOver ( exit_top_over_png , exit_top_over_png_size ) ;
GuiImageData bottom ( exit_bottom_png , exit_bottom_png_size ) ;
GuiImageData bottomOver ( exit_bottom_over_png , exit_bottom_over_png_size ) ;
GuiImageData button ( exit_button_png , exit_button_png_size ) ;
GuiImageData wiimote ( wiimote_png , wiimote_png_size ) ;
GuiImageData close ( closebutton_png , closebutton_png_size ) ;
GuiImageData battery ( Resources : : GetFile ( " battery_white.png " ) , Resources : : GetFileSize ( " battery_white.png " ) ) ;
GuiImageData batteryBar ( Resources : : GetFile ( " battery_bar_white.png " ) , Resources : : GetFileSize ( " battery_bar_white.png " ) ) ;
GuiImageData batteryRed ( Resources : : GetFile ( " battery_red.png " ) , Resources : : GetFileSize ( " battery_red.png " ) ) ;
GuiImageData batteryBarRed ( Resources : : GetFile ( " battery_bar_red.png " ) , Resources : : GetFileSize ( " battery_bar_red.png " ) ) ;
2009-10-01 01:10:58 +02:00
int i = 0 , ret = 0 , level ;
char txt [ 3 ] ;
GuiText * batteryTxt [ 4 ] ;
GuiImage * batteryImg [ 4 ] ;
GuiImage * batteryBarImg [ 4 ] ;
GuiButton * batteryBtn [ 4 ] ;
2010-09-24 02:48:03 +02:00
for ( i = 0 ; i < 4 ; i + + )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( txt , " P%d " , i + 1 ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
batteryTxt [ i ] = new GuiText ( txt , 22 , ( GXColor )
{ 255 , 255 , 255 , 255 } ) ;
batteryTxt [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_MIDDLE ) ;
batteryImg [ i ] = new GuiImage ( & battery ) ;
batteryImg [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_MIDDLE ) ;
batteryImg [ i ] - > SetPosition ( 36 , 0 ) ;
batteryImg [ i ] - > SetTile ( 0 ) ;
batteryBarImg [ i ] = new GuiImage ( & batteryBar ) ;
batteryBarImg [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_MIDDLE ) ;
batteryBarImg [ i ] - > SetPosition ( 33 , 0 ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
batteryBtn [ i ] = new GuiButton ( 40 , 20 ) ;
batteryBtn [ i ] - > SetLabel ( batteryTxt [ i ] ) ;
batteryBtn [ i ] - > SetImage ( batteryBarImg [ i ] ) ;
batteryBtn [ i ] - > SetIcon ( batteryImg [ i ] ) ;
batteryBtn [ i ] - > SetAlignment ( ALIGN_LEFT , ALIGN_MIDDLE ) ;
batteryBtn [ i ] - > SetRumble ( false ) ;
batteryBtn [ i ] - > SetAlpha ( 70 ) ;
batteryBtn [ i ] - > SetEffect ( EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_IN , 50 ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
batteryBtn [ 0 ] - > SetPosition ( 180 , 150 ) ;
batteryBtn [ 1 ] - > SetPosition ( 284 , 150 ) ;
batteryBtn [ 2 ] - > SetPosition ( 388 , 150 ) ;
batteryBtn [ 3 ] - > SetPosition ( 494 , 150 ) ;
2010-09-19 01:16:05 +02:00
GuiTrigger trigA ;
2010-09-24 02:48:03 +02:00
trigA . SetSimpleTrigger ( - 1 , WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A , PAD_BUTTON_A ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigB ;
2010-09-24 02:48:03 +02:00
trigB . SetButtonOnlyTrigger ( - 1 , WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B , PAD_BUTTON_B ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigHome ;
2010-09-24 02:48:03 +02:00
trigHome . SetButtonOnlyTrigger ( - 1 , WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME , 0 ) ;
GuiText titleTxt ( tr ( " HOME Menu " ) , 36 , ( GXColor )
{ 255 , 255 , 255 , 255 } ) ;
titleTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
titleTxt . SetPosition ( - 180 , 40 ) ;
titleTxt . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN , 50 ) ;
GuiText closeTxt ( tr ( " Close " ) , 28 , ( GXColor )
{ 0 , 0 , 0 , 255 } ) ;
closeTxt . SetPosition ( 10 , 3 ) ;
GuiImage closeImg ( & close ) ;
if ( Settings . wsprompt = = yes )
{
closeTxt . SetWidescreen ( Settings . widescreen ) ;
closeImg . SetWidescreen ( Settings . widescreen ) ;
}
GuiButton closeBtn ( close . GetWidth ( ) , close . GetHeight ( ) ) ;
closeBtn . SetImage ( & closeImg ) ;
closeBtn . SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
closeBtn . SetPosition ( 190 , 30 ) ;
closeBtn . SetLabel ( & closeTxt ) ;
closeBtn . SetRumble ( false ) ;
closeBtn . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN , 50 ) ;
GuiImage btn1Img ( & top ) ;
GuiImage btn1OverImg ( & topOver ) ;
GuiButton btn1 ( & btn1Img , & btn1OverImg , 0 , 3 , 0 , 0 , & trigA , & btnSoundOver , btnClick2 , 0 ) ;
btn1 . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN , 50 ) ;
GuiText btn2Txt ( tr ( " Back to Loader " ) , 28 , ( GXColor )
{ 0 , 0 , 0 , 255 } ) ;
GuiImage btn2Img ( & button ) ;
if ( Settings . wsprompt = = yes )
{
btn2Txt . SetWidescreen ( Settings . widescreen ) ;
btn2Img . SetWidescreen ( Settings . widescreen ) ;
}
GuiButton btn2 ( & btn2Img , & btn2Img , 2 , 5 , - 150 , 0 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
btn2 . SetLabel ( & btn2Txt ) ;
btn2 . SetEffect ( EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN , 50 ) ;
btn2 . SetRumble ( false ) ;
btn2 . SetPosition ( - 150 , 0 ) ;
GuiText btn3Txt ( tr ( " Wii Menu " ) , 28 , ( GXColor )
{ 0 , 0 , 0 , 255 } ) ;
GuiImage btn3Img ( & button ) ;
if ( Settings . wsprompt = = yes )
{
btn3Txt . SetWidescreen ( Settings . widescreen ) ;
btn3Img . SetWidescreen ( Settings . widescreen ) ;
}
GuiButton btn3 ( & btn3Img , & btn3Img , 2 , 5 , 150 , 0 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
btn3 . SetLabel ( & btn3Txt ) ;
btn3 . SetEffect ( EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN , 50 ) ;
btn3 . SetRumble ( false ) ;
btn3 . SetPosition ( 150 , 0 ) ;
GuiImage btn4Img ( & bottom ) ;
GuiImage btn4OverImg ( & bottomOver ) ;
GuiButton btn4 ( & btn4Img , & btn4OverImg , 0 , 4 , 0 , 0 , & trigA , & btnSoundOver , btnClick2 , 0 ) ;
btn4 . SetTrigger ( & trigB ) ;
btn4 . SetTrigger ( & trigHome ) ;
btn4 . SetEffect ( EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_IN , 50 ) ;
GuiImage wiimoteImg ( & wiimote ) ;
if ( Settings . wsprompt = = yes )
{
wiimoteImg . SetWidescreen ( Settings . widescreen ) ;
}
wiimoteImg . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
wiimoteImg . SetEffect ( EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_IN , 50 ) ;
wiimoteImg . SetPosition ( 50 , 210 ) ;
promptWindow . Append ( & btn2 ) ;
promptWindow . Append ( & btn3 ) ;
promptWindow . Append ( & btn4 ) ;
promptWindow . Append ( & btn1 ) ;
promptWindow . Append ( & closeBtn ) ;
promptWindow . Append ( & titleTxt ) ;
promptWindow . Append ( & wiimoteImg ) ;
promptWindow . Append ( batteryBtn [ 0 ] ) ;
promptWindow . Append ( batteryBtn [ 1 ] ) ;
promptWindow . Append ( batteryBtn [ 2 ] ) ;
promptWindow . Append ( batteryBtn [ 3 ] ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > SetState ( STATE_DISABLED ) ;
mainWindow - > Append ( & promptWindow ) ;
mainWindow - > ChangeFocus ( & promptWindow ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
2010-09-24 02:48:03 +02:00
while ( choice = = - 1 )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
VIDEO_WaitVSync ( ) ;
2010-09-24 02:48:03 +02:00
for ( i = 0 ; i < 4 ; i + + )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
if ( WPAD_Probe ( i , NULL ) = = WPAD_ERR_NONE ) // controller connected
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
level = ( userInput [ i ] . wpad . battery_level / 100.0 ) * 4 ;
if ( level > 4 ) level = 4 ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
if ( level < = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
batteryBarImg [ i ] - > SetImage ( & batteryBarRed ) ;
batteryImg [ i ] - > SetImage ( & batteryRed ) ;
2010-09-19 01:16:05 +02:00
}
else
{
2010-09-24 02:48:03 +02:00
batteryBarImg [ i ] - > SetImage ( & batteryBar ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
batteryImg [ i ] - > SetTile ( level ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
batteryBtn [ i ] - > SetAlpha ( 255 ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else // controller not connected
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
batteryImg [ i ] - > SetTile ( 0 ) ;
batteryImg [ i ] - > SetImage ( & battery ) ;
batteryBtn [ i ] - > SetAlpha ( 70 ) ;
2009-10-01 01:10:58 +02:00
}
}
2010-09-24 02:48:03 +02:00
if ( shutdown = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
wiilight ( 0 ) ;
2010-01-19 11:48:50 +01:00
Sys_Shutdown ( ) ;
}
2010-09-24 02:48:03 +02:00
if ( reset = = 1 ) Sys_Reboot ( ) ;
if ( btn1 . GetState ( ) = = STATE_CLICKED )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
choice = 1 ;
2010-09-24 02:48:03 +02:00
btn1 . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT , 50 ) ;
closeBtn . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT , 50 ) ;
btn4 . SetEffect ( EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT , 50 ) ;
btn2 . SetEffect ( EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT , 50 ) ;
btn3 . SetEffect ( EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT , 50 ) ;
titleTxt . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT , 50 ) ;
wiimoteImg . SetEffect ( EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT , 50 ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
for ( int i = 0 ; i < 4 ; i + + )
batteryBtn [ i ] - > SetEffect ( EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT , 50 ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( btn4 . GetState ( ) = = STATE_SELECTED )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
wiimoteImg . SetPosition ( 50 , 165 ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( btn2 . GetState ( ) = = STATE_CLICKED )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
ret = WindowPrompt ( tr ( " Are you sure? " ) , 0 , tr ( " Yes " ) , tr ( " No " ) ) ;
if ( ret = = 1 )
2010-09-19 01:16:05 +02:00
{
2009-10-21 01:00:19 +02:00
2009-10-01 01:10:58 +02:00
choice = 2 ;
}
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > SetState ( STATE_DISABLED ) ;
promptWindow . SetState ( STATE_DEFAULT ) ;
mainWindow - > ChangeFocus ( & promptWindow ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
btn2 . ResetState ( ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( btn3 . GetState ( ) = = STATE_CLICKED )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
ret = WindowPrompt ( tr ( " Are you sure? " ) , 0 , tr ( " Yes " ) , tr ( " No " ) ) ;
if ( ret = = 1 )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
choice = 3 ;
}
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > SetState ( STATE_DISABLED ) ;
promptWindow . SetState ( STATE_DEFAULT ) ;
mainWindow - > ChangeFocus ( & promptWindow ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
btn3 . ResetState ( ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( btn4 . GetState ( ) = = STATE_CLICKED )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
btn1 . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT , 50 ) ;
closeBtn . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT , 50 ) ;
btn4 . SetEffect ( EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT , 50 ) ;
btn2 . SetEffect ( EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT , 50 ) ;
btn3 . SetEffect ( EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT , 50 ) ;
titleTxt . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT , 50 ) ;
wiimoteImg . SetEffect ( EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT , 50 ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
for ( int i = 0 ; i < 4 ; i + + )
batteryBtn [ i ] - > SetEffect ( EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT , 50 ) ;
2009-12-03 02:06:09 +01:00
2009-10-01 01:10:58 +02:00
choice = 0 ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( btn4 . GetState ( ) ! = STATE_SELECTED )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
wiimoteImg . SetPosition ( 50 , 210 ) ;
2009-10-01 01:10:58 +02:00
}
}
homeout - > Play ( ) ;
2010-09-24 02:48:03 +02:00
while ( btn1 . GetEffect ( ) > 0 )
usleep ( 50 ) ;
while ( promptWindow . GetEffect ( ) > 0 )
usleep ( 50 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
homein - > Stop ( ) ;
delete homein ;
2010-09-24 02:48:03 +02:00
mainWindow - > Remove ( & promptWindow ) ;
mainWindow - > SetState ( STATE_DEFAULT ) ;
while ( homeout - > IsPlaying ( ) > 0 )
usleep ( 50 ) ;
2009-10-01 01:10:58 +02:00
homeout - > Stop ( ) ;
delete homeout ;
ResumeGui ( ) ;
return choice ;
}
2010-09-28 20:58:56 +02:00
void SetupLockedButton ( GuiButton * btnLocked , GuiImage * img , GuiSound * sndOver , GuiSound * sndClick ,
GuiTrigger * trig )
{
btnLocked - > SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
//btnLocked->SetPosition(xPos, yPos);
btnLocked - > SetPosition ( 125 , 40 ) ;
btnLocked - > SetImage ( img ) ;
btnLocked - > SetSoundOver ( sndOver ) ;
btnLocked - > SetSoundClick ( sndClick ) ;
btnLocked - > SetTrigger ( trig ) ;
btnLocked - > SetEffectGrow ( ) ;
}
u8 SetLocked ( GuiButton * lock1 , u8 * gameId , u8 locked )
{
int LockStatus = ( locked = = GameStatistics . GetLockStatus ( gameId ) ) ? 0 : locked ; // Press the current rank to reset the rank
GameStatistics . SetLockStatus ( gameId , LockStatus ) ;
GameStatistics . Save ( ) ;
return LockStatus ;
}
void SetLockedImage ( const u8 * gameid , GuiImage * b1 , GuiImageData * on , GuiImageData * off )
{
int lockedvar = GameStatistics . GetLockStatus ( gameid ) ;
b1 - > SetImage ( lockedvar = = 1 ? on : off ) ;
}
2010-09-24 02:48:03 +02:00
void SetupFavoriteButton ( GuiButton * btnFavorite , int xPos , GuiImage * img , GuiSound * sndOver , GuiSound * sndClick ,
GuiTrigger * trig )
2010-02-09 11:59:55 +01:00
{
2010-09-24 02:48:03 +02:00
btnFavorite - > SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
btnFavorite - > SetPosition ( xPos , - 60 ) ;
btnFavorite - > SetImage ( img ) ;
btnFavorite - > SetSoundOver ( sndOver ) ;
btnFavorite - > SetSoundClick ( sndClick ) ;
btnFavorite - > SetTrigger ( trig ) ;
2009-10-13 12:47:56 +02:00
btnFavorite - > SetEffectGrow ( ) ;
}
2010-09-24 02:48:03 +02:00
u8 SetFavorite ( GuiButton * fav1 , GuiButton * fav2 , GuiButton * fav3 , GuiButton * fav4 , GuiButton * fav5 , u8 * gameId ,
u8 favorite )
2010-02-09 11:59:55 +01:00
{
2010-09-25 10:51:44 +02:00
int FavoriteRank = ( favorite = = GameStatistics . GetFavoriteRank ( gameId ) ) ? 0 : favorite ; // Press the current rank to reset the rank
GameStatistics . SetFavoriteRank ( gameId , FavoriteRank ) ;
GameStatistics . Save ( ) ;
return FavoriteRank ;
2009-10-13 12:47:56 +02:00
}
2010-09-25 10:51:44 +02:00
void SetFavoriteImages ( const u8 * gameid , GuiImage * b1 , GuiImage * b2 , GuiImage * b3 , GuiImage * b4 , GuiImage * b5 , GuiImageData * on ,
2010-09-24 02:48:03 +02:00
GuiImageData * off )
2010-02-09 11:59:55 +01:00
{
2010-09-25 10:51:44 +02:00
int favoritevar = GameStatistics . GetFavoriteRank ( gameid ) ;
2010-09-24 02:48:03 +02:00
b1 - > SetImage ( favoritevar > = 1 ? on : off ) ;
b2 - > SetImage ( favoritevar > = 2 ? on : off ) ;
b3 - > SetImage ( favoritevar > = 3 ? on : off ) ;
b4 - > SetImage ( favoritevar > = 4 ? on : off ) ;
b5 - > SetImage ( favoritevar > = 5 ? on : off ) ;
2009-11-08 21:13:57 +01:00
}
2009-10-13 12:47:56 +02:00
2009-10-01 01:10:58 +02:00
/****************************************************************************
* GameWindowPrompt
*
* Displays a prompt window to user , with information , an error message , or
* presenting a user with a choice
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2010-09-19 01:16:05 +02:00
int GameWindowPrompt ( )
{
2009-10-01 01:10:58 +02:00
int choice = - 1 , angle = 0 ;
f32 size = 0.0 ;
char ID [ 5 ] ;
char IDFull [ 7 ] ;
2009-11-10 00:03:13 +01:00
GuiSound * gameSound = NULL ;
2009-11-08 21:13:57 +01:00
2010-09-24 02:48:03 +02:00
gprintf ( " GameWindowPrompt() \n " ) ;
GuiWindow promptWindow ( 472 , 320 ) ;
promptWindow . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
promptWindow . SetPosition ( 0 , - 10 ) ;
GuiSound btnSoundOver ( button_over_pcm , button_over_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
2010-09-24 02:48:03 +02:00
if ( ! btnClick2 ) btnClick2 = new GuiSound ( button_click2_pcm , button_click2_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
2009-10-01 01:10:58 +02:00
2010-09-26 10:33:43 +02:00
GuiImageData btnOutline ( Resources : : GetFile ( " button_dialogue_box.png " ) , Resources : : GetFileSize ( " button_dialogue_box.png " ) ) ;
2009-10-01 01:10:58 +02:00
2010-09-28 20:58:56 +02:00
GuiImageData imgLocked ( Resources : : GetFile ( " lock.png " ) , Resources : : GetFileSize ( " lock.png " ) ) ;
GuiImageData imgNotLocked ( Resources : : GetFile ( " unlock.png " ) , Resources : : GetFileSize ( " unlock.png " ) ) ;
2010-09-26 10:33:43 +02:00
GuiImageData imgFavorite ( Resources : : GetFile ( " favorite.png " ) , Resources : : GetFileSize ( " favorite.png " ) ) ;
GuiImageData imgNotFavorite ( Resources : : GetFile ( " not_favorite.png " ) , Resources : : GetFileSize ( " not_favorite.png " ) ) ;
2009-10-01 01:10:58 +02:00
2010-09-26 10:33:43 +02:00
GuiImageData imgLeft ( Resources : : GetFile ( " startgame_arrow_left.png " ) , Resources : : GetFileSize ( " startgame_arrow_left.png " ) ) ;
GuiImageData imgRight ( Resources : : GetFile ( " startgame_arrow_right.png " ) , Resources : : GetFileSize ( " startgame_arrow_right.png " ) ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigA ;
2010-09-24 02:48:03 +02:00
trigA . SetSimpleTrigger ( - 1 , WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A , PAD_BUTTON_A ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigB ;
2010-09-24 02:48:03 +02:00
trigB . SetButtonOnlyTrigger ( - 1 , WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B , PAD_BUTTON_B ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigL ;
2010-09-24 02:48:03 +02:00
trigL . SetButtonOnlyTrigger ( - 1 , WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT , PAD_BUTTON_LEFT ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigR ;
2010-09-24 02:48:03 +02:00
trigR . SetButtonOnlyTrigger ( - 1 , WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT , PAD_BUTTON_RIGHT ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigPlus ;
2010-09-24 02:48:03 +02:00
trigPlus . SetButtonOnlyTrigger ( - 1 , WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS , 0 ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigMinus ;
2010-09-24 02:48:03 +02:00
trigMinus . SetButtonOnlyTrigger ( - 1 , WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS , 0 ) ;
2010-01-19 11:48:50 +01:00
GuiTrigger trigZ ;
2010-09-24 02:48:03 +02:00
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 ) ;
2010-09-28 20:58:56 +02:00
2010-09-26 10:33:43 +02:00
const char * image = " dialogue_box_startgame.png " ;
2010-09-24 02:48:03 +02:00
if ( Settings . widescreen )
2010-09-26 10:33:43 +02:00
image = " wdialogue_box_startgame.png " ;
2010-09-24 02:48:03 +02:00
2010-09-26 10:33:43 +02:00
GuiImageData dialogBox ( Resources : : GetFile ( image ) , Resources : : GetFileSize ( image ) ) ;
2010-09-24 02:48:03 +02:00
GuiImage dialogBoxImg ( & dialogBox ) ;
GuiTooltip nameBtnTT ( tr ( " Rename Game on WBFS " ) ) ;
if ( Settings . wsprompt = = yes ) nameBtnTT . SetWidescreen ( Settings . widescreen ) ;
2010-09-24 19:58:56 +02:00
GuiText nameTxt ( " " , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
if ( Settings . wsprompt = = yes ) nameTxt . SetWidescreen ( Settings . widescreen ) ;
nameTxt . SetMaxWidth ( 350 , SCROLL_HORIZONTAL ) ;
GuiButton nameBtn ( 120 , 50 ) ;
nameBtn . SetLabel ( & nameTxt ) ;
// nameBtn.SetLabelOver(&nameTxt);
nameBtn . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
nameBtn . SetPosition ( 0 , - 122 ) ;
nameBtn . SetSoundOver ( & btnSoundOver ) ;
nameBtn . SetSoundClick ( btnClick2 ) ;
if ( ! mountMethod ) nameBtn . SetToolTip ( & nameBtnTT , 24 , - 30 , ALIGN_LEFT ) ;
if ( Settings . godmode = = 1 & & ! mountMethod )
{
nameBtn . SetTrigger ( & trigA ) ;
2009-10-01 01:10:58 +02:00
nameBtn . SetEffectGrow ( ) ;
}
2010-09-24 19:58:56 +02:00
GuiText sizeTxt ( ( char * ) NULL , 22 , Theme . prompttext ) ; //TODO: get the size here
2010-09-24 02:48:03 +02:00
sizeTxt . SetAlignment ( ALIGN_RIGHT , ALIGN_TOP ) ;
sizeTxt . SetPosition ( - 60 , 70 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
// GuiImage diskImg;
2009-10-01 01:10:58 +02:00
GuiDiskCover diskImg ;
2010-09-24 02:48:03 +02:00
diskImg . SetWidescreen ( Settings . widescreen ) ;
diskImg . SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
diskImg . SetAngle ( angle ) ;
2009-10-01 01:10:58 +02:00
GuiDiskCover diskImg2 ;
2010-09-24 02:48:03 +02:00
diskImg2 . SetWidescreen ( Settings . widescreen ) ;
diskImg2 . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
diskImg2 . SetPosition ( 0 , - 20 ) ;
diskImg2 . SetAngle ( angle ) ;
diskImg2 . SetBeta ( 180 ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 19:58:56 +02:00
GuiText playcntTxt ( ( char * ) NULL , 18 , Theme . info ) ;
2010-09-24 02:48:03 +02:00
playcntTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
playcntTxt . SetPosition ( - 115 , 45 ) ;
GuiButton btn1 ( 160 , 160 ) ;
btn1 . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
btn1 . SetPosition ( 0 , - 20 ) ;
btn1 . SetImage ( & diskImg ) ;
btn1 . SetSoundOver ( & btnSoundOver ) ;
btn1 . SetSoundClick ( btnClick2 ) ;
btn1 . SetTrigger ( & trigA ) ;
btn1 . SetState ( STATE_SELECTED ) ;
2010-09-24 19:58:56 +02:00
GuiText btn2Txt ( tr ( " Back " ) , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
GuiImage btn2Img ( & btnOutline ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
btn2Txt . SetWidescreen ( Settings . widescreen ) ;
btn2Img . SetWidescreen ( Settings . widescreen ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
GuiButton btn2 ( & btn2Img , & btn2Img , 1 , 5 , 0 , 0 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
if ( Settings . godmode = = 1 & & mountMethod ! = 2 & & mountMethod ! = 3 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
btn2 . SetAlignment ( ALIGN_RIGHT , ALIGN_BOTTOM ) ;
btn2 . SetPosition ( - 50 , - 40 ) ;
2010-09-19 01:16:05 +02:00
}
else
{
2010-09-24 02:48:03 +02:00
btn2 . SetAlignment ( ALIGN_CENTRE , ALIGN_BOTTOM ) ;
btn2 . SetPosition ( 0 , - 40 ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
btn2 . SetLabel ( & btn2Txt ) ;
btn2 . SetTrigger ( & trigB ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 19:58:56 +02:00
GuiText btn3Txt ( tr ( " Settings " ) , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
GuiImage btn3Img ( & btnOutline ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
btn3Txt . SetWidescreen ( Settings . widescreen ) ;
btn3Img . SetWidescreen ( Settings . widescreen ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
GuiButton btn3 ( & btn3Img , & btn3Img , 0 , 4 , 50 , - 40 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
btn3 . SetLabel ( & btn3Txt ) ;
2009-10-01 01:10:58 +02:00
2009-10-13 12:47:56 +02:00
GuiImage btnFavoriteImg1 ;
2010-09-24 02:48:03 +02:00
btnFavoriteImg1 . SetWidescreen ( Settings . widescreen ) ;
2009-10-13 12:47:56 +02:00
GuiImage btnFavoriteImg2 ;
2010-09-24 02:48:03 +02:00
btnFavoriteImg2 . SetWidescreen ( Settings . widescreen ) ;
2009-10-13 12:47:56 +02:00
GuiImage btnFavoriteImg3 ;
2010-09-24 02:48:03 +02:00
btnFavoriteImg3 . SetWidescreen ( Settings . widescreen ) ;
2009-10-13 12:47:56 +02:00
GuiImage btnFavoriteImg4 ;
2010-09-24 02:48:03 +02:00
btnFavoriteImg4 . SetWidescreen ( Settings . widescreen ) ;
2009-10-13 12:47:56 +02:00
GuiImage btnFavoriteImg5 ;
2010-09-24 02:48:03 +02:00
btnFavoriteImg5 . SetWidescreen ( Settings . widescreen ) ;
2009-10-13 12:47:56 +02:00
2009-10-01 01:10:58 +02:00
//GuiButton btnFavorite(&btnFavoriteImg,&btnFavoriteImg, 2, 5, -125, -60, &trigA, &btnSoundOver, &btnClick,1);
2010-09-24 02:48:03 +02:00
GuiButton btnFavorite1 ( imgFavorite . GetWidth ( ) , imgFavorite . GetHeight ( ) ) ;
GuiButton btnFavorite2 ( imgFavorite . GetWidth ( ) , imgFavorite . GetHeight ( ) ) ;
GuiButton btnFavorite3 ( imgFavorite . GetWidth ( ) , imgFavorite . GetHeight ( ) ) ;
GuiButton btnFavorite4 ( imgFavorite . GetWidth ( ) , imgFavorite . GetHeight ( ) ) ;
GuiButton btnFavorite5 ( imgFavorite . GetWidth ( ) , imgFavorite . GetHeight ( ) ) ;
SetupFavoriteButton ( & btnFavorite1 , - 198 , & btnFavoriteImg1 , & btnSoundOver , btnClick2 , & trigA ) ;
SetupFavoriteButton ( & btnFavorite2 , - 171 , & btnFavoriteImg2 , & btnSoundOver , btnClick2 , & trigA ) ;
SetupFavoriteButton ( & btnFavorite3 , - 144 , & btnFavoriteImg3 , & btnSoundOver , btnClick2 , & trigA ) ;
SetupFavoriteButton ( & btnFavorite4 , - 117 , & btnFavoriteImg4 , & btnSoundOver , btnClick2 , & trigA ) ;
SetupFavoriteButton ( & btnFavorite5 , - 90 , & btnFavoriteImg5 , & btnSoundOver , btnClick2 , & trigA ) ;
2010-09-28 20:58:56 +02:00
GuiImage btnLockedImg ;
btnLockedImg . SetWidescreen ( Settings . widescreen ) ;
GuiButton btnLocked ( imgLocked . GetWidth ( ) , imgLocked . GetHeight ( ) ) ;
SetupLockedButton ( & btnLocked , & btnLockedImg , & btnSoundOver , btnClick2 , & trigA ) ;
2010-09-24 02:48:03 +02:00
GuiImage btnLeftImg ( & imgLeft ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
btnLeftImg . SetWidescreen ( Settings . widescreen ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
GuiButton btnLeft ( & btnLeftImg , & btnLeftImg , 0 , 5 , 20 , 0 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
btnLeft . SetTrigger ( & trigL ) ;
btnLeft . SetTrigger ( & trigMinus ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
GuiImage btnRightImg ( & imgRight ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
btnRightImg . SetWidescreen ( Settings . widescreen ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
GuiButton btnRight ( & btnRightImg , & btnRightImg , 1 , 5 , - 20 , 0 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
btnRight . SetTrigger ( & trigR ) ;
btnRight . SetTrigger ( & trigPlus ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
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
{
promptWindow . Append ( & sizeTxt ) ;
promptWindow . Append ( & btnLeft ) ;
promptWindow . Append ( & btnRight ) ;
promptWindow . Append ( & btnFavorite1 ) ;
promptWindow . Append ( & btnFavorite2 ) ;
promptWindow . Append ( & btnFavorite3 ) ;
promptWindow . Append ( & btnFavorite4 ) ;
promptWindow . Append ( & btnFavorite5 ) ;
2010-09-19 01:16:05 +02:00
}
2009-10-01 01:10:58 +02:00
//check if unlocked
2010-09-24 02:48:03 +02:00
if ( Settings . godmode = = 1 & & mountMethod ! = 2 & & mountMethod ! = 3 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
promptWindow . Append ( & btn3 ) ;
2010-09-28 20:58:56 +02:00
promptWindow . Append ( & btnLocked ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
promptWindow . Append ( & diskImg2 ) ;
promptWindow . Append ( & btn1 ) ;
2010-09-17 17:15:21 +02:00
2009-10-01 01:10:58 +02:00
short changed = - 1 ;
GuiImageData * diskCover = NULL ;
GuiImageData * diskCover2 = NULL ;
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN , 50 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
while ( changed )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
if ( changed = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN , 50 ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( changed = = 2 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN , 50 ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( changed = = 3 | | changed = = 4 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
if ( diskCover2 ) delete diskCover2 ;
2009-10-01 01:10:58 +02:00
diskCover2 = NULL ;
2010-09-24 02:48:03 +02:00
if ( diskCover ) diskCover2 = diskCover ;
2009-10-01 01:10:58 +02:00
diskCover = NULL ;
}
//load disc image based or what game is seleted
2010-09-24 02:48:03 +02:00
struct discHdr * header = ( mountMethod = = 1 | | mountMethod = = 2 ? dvdheader : gameList [ gameSelected ] ) ;
if ( Settings . gamesoundvolume > 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
if ( gameSound )
2010-09-19 01:16:05 +02:00
{
gameSound - > Stop ( ) ;
delete gameSound ;
gameSound = NULL ;
}
u32 gameSoundDataLen ;
2010-09-24 02:48:03 +02:00
const u8 * gameSoundData = LoadBannerSound ( header - > id , & gameSoundDataLen ) ;
if ( gameSoundData )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
gameSound = new GuiSound ( gameSoundData , gameSoundDataLen , Settings . gamesoundvolume , false , true ) ;
bgMusic - > SetVolume ( 0 ) ;
if ( Settings . gamesound = = 2 ) gameSound - > SetLoop ( 1 ) ;
2010-09-19 01:16:05 +02:00
gameSound - > Play ( ) ;
}
}
2010-09-24 02:48:03 +02:00
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 ] ) ;
2009-11-08 21:13:57 +01:00
2010-09-24 02:48:03 +02:00
gprintf ( " \t %s \n " , IDFull ) ;
if ( diskCover ) delete diskCover ;
2010-09-26 10:33:43 +02:00
char imgPath [ 150 ] ;
2010-09-24 02:48:03 +02:00
snprintf ( imgPath , sizeof ( imgPath ) , " %s%s.png " , Settings . disc_path , IDFull ) ; //changed to current full id
2010-09-26 10:33:43 +02:00
diskCover = new GuiImageData ( imgPath ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
if ( ! diskCover - > GetImage ( ) )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
delete diskCover ;
2010-09-24 02:48:03 +02:00
snprintf ( imgPath , sizeof ( imgPath ) , " %s%s.png " , Settings . disc_path , ID ) ; //changed to current id
2010-09-26 10:33:43 +02:00
diskCover = new GuiImageData ( imgPath ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
if ( ! diskCover - > GetImage ( ) )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
snprintf ( ID , sizeof ( ID ) , " %c%c%c%c " , header - > id [ 0 ] , header - > id [ 1 ] , header - > id [ 2 ] , header - > id [ 3 ] ) ;
2009-10-01 01:10:58 +02:00
delete diskCover ;
2010-09-24 02:48:03 +02:00
snprintf ( imgPath , sizeof ( imgPath ) , " %s%s.png " , Settings . disc_path , ID ) ; //changed to current id
2010-09-26 10:33:43 +02:00
diskCover = new GuiImageData ( imgPath ) ;
2010-09-24 02:48:03 +02:00
if ( ! diskCover - > GetImage ( ) )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
delete diskCover ;
2010-09-26 10:33:43 +02:00
diskCover = Resources : : GetImageData ( " nodisc.png " ) ;
2009-10-01 01:10:58 +02:00
}
}
}
2010-09-24 02:48:03 +02:00
if ( changed = = 3 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
diskImg . SetImage ( diskCover2 ) ;
diskImg . SetBeta ( 0 ) ;
diskImg . SetBetaRotateEffect ( - 90 , 15 ) ;
diskImg2 . SetImage ( diskCover ) ;
diskImg2 . SetAngle ( diskImg . GetAngle ( ) ) ;
diskImg2 . SetBeta ( 180 ) ;
diskImg2 . SetBetaRotateEffect ( - 90 , 15 ) ;
sizeTxt . SetEffect ( EFFECT_FADE , - 17 ) ;
nameTxt . SetEffect ( EFFECT_FADE , - 17 ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
2010-09-24 02:48:03 +02:00
while ( nameTxt . GetEffect ( ) > 0 | | diskImg . GetBetaRotateEffect ( ) )
usleep ( 50 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
diskImg . SetImage ( diskCover ) ;
diskImg . SetBeta ( 90 ) ;
diskImg . SetBetaRotateEffect ( - 90 , 15 ) ;
diskImg2 . SetImage ( diskCover2 ) ;
diskImg2 . SetBeta ( 270 ) ;
diskImg2 . SetBetaRotateEffect ( - 90 , 15 ) ;
sizeTxt . SetEffect ( EFFECT_FADE , 17 ) ;
nameTxt . SetEffect ( EFFECT_FADE , 17 ) ;
}
else if ( changed = = 4 )
{
diskImg . SetImage ( diskCover2 ) ;
diskImg . SetBeta ( 0 ) ;
diskImg . SetBetaRotateEffect ( 90 , 15 ) ;
diskImg2 . SetImage ( diskCover ) ;
diskImg2 . SetAngle ( diskImg . GetAngle ( ) ) ;
diskImg2 . SetBeta ( 180 ) ;
diskImg2 . SetBetaRotateEffect ( 90 , 15 ) ;
sizeTxt . SetEffect ( EFFECT_FADE , - 17 ) ;
nameTxt . SetEffect ( EFFECT_FADE , - 17 ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
2010-09-24 02:48:03 +02:00
while ( nameTxt . GetEffect ( ) > 0 | | diskImg . GetBetaRotateEffect ( ) )
usleep ( 50 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
diskImg . SetImage ( diskCover ) ;
diskImg . SetBeta ( 270 ) ;
diskImg . SetBetaRotateEffect ( 90 , 15 ) ;
diskImg2 . SetImage ( diskCover2 ) ;
diskImg2 . SetBeta ( 90 ) ;
diskImg2 . SetBetaRotateEffect ( 90 , 15 ) ;
sizeTxt . SetEffect ( EFFECT_FADE , 17 ) ;
nameTxt . SetEffect ( EFFECT_FADE , 17 ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else diskImg . SetImage ( diskCover ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
if ( ! mountMethod )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
WBFS_GameSize ( header - > id , & size ) ;
sizeTxt . SetTextf ( " %.2fGB " , size ) ; //set size text;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
nameTxt . SetText ( get_title ( header ) ) ;
2010-09-25 10:51:44 +02:00
playcntTxt . SetTextf ( " %s: %i " , tr ( " Play Count " ) , GameStatistics . GetPlayCount ( header ) ) ;
SetFavoriteImages ( header - > id , & btnFavoriteImg1 , & btnFavoriteImg2 , & btnFavoriteImg3 , & btnFavoriteImg4 , & btnFavoriteImg5 ,
2010-09-24 02:48:03 +02:00
& imgFavorite , & imgNotFavorite ) ;
2009-10-01 01:10:58 +02:00
2010-09-28 20:58:56 +02:00
SetLockedImage ( header - > id , & btnLockedImg , & imgLocked , & imgNotLocked ) ;
2010-09-24 02:48:03 +02:00
nameTxt . SetPosition ( 0 , 1 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
if ( changed ! = 3 & & changed ! = 4 ) // changed==3 or changed==4 --> only Resume the GUI
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > SetState ( STATE_DISABLED ) ;
mainWindow - > Append ( & promptWindow ) ;
mainWindow - > ChangeFocus ( & promptWindow ) ;
2009-10-01 01:10:58 +02:00
}
ResumeGui ( ) ;
changed = 0 ;
2010-09-24 02:48:03 +02:00
while ( choice = = - 1 )
2010-02-09 11:59:55 +01:00
{
2010-09-24 02:48:03 +02:00
VIDEO_WaitVSync ( ) ;
2009-11-08 21:13:57 +01:00
2010-09-24 02:48:03 +02:00
diskImg . SetSpin ( btn1 . GetState ( ) = = STATE_SELECTED ) ;
diskImg2 . SetSpin ( btn1 . GetState ( ) = = STATE_SELECTED ) ;
if ( shutdown = = 1 ) //for power button
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT , 50 ) ;
mainWindow - > SetState ( STATE_DEFAULT ) ;
while ( promptWindow . GetEffect ( ) > 0 )
usleep ( 50 ) ;
2010-09-19 01:16:05 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > Remove ( & promptWindow ) ;
2010-09-19 01:16:05 +02:00
ResumeGui ( ) ;
2010-09-24 02:48:03 +02:00
wiilight ( 0 ) ;
2010-01-19 11:48:50 +01:00
Sys_Shutdown ( ) ;
}
2010-09-24 02:48:03 +02:00
if ( reset = = 1 ) //for reset button
Sys_Reboot ( ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
if ( gameSound )
2010-02-09 11:59:55 +01:00
{
2010-09-24 02:48:03 +02:00
if ( ! gameSound - > IsPlaying ( ) )
2010-02-09 11:59:55 +01:00
{
2010-09-24 02:48:03 +02:00
if ( Settings . gamesound = = 1 ) bgMusic - > SetVolume ( Settings . volume ) ;
2009-11-10 19:43:56 +01:00
}
2009-11-08 21:13:57 +01:00
}
2010-09-24 02:48:03 +02:00
if ( btn1 . GetState ( ) = = STATE_CLICKED )
2010-09-19 01:16:05 +02:00
{
2010-09-25 10:51:44 +02:00
GameStatistics . SetPlayCount ( header - > id , GameStatistics . GetPlayCount ( header - > id ) + 1 ) ;
GameStatistics . Save ( ) ;
2009-10-01 01:10:58 +02:00
choice = 1 ;
}
2010-09-24 02:48:03 +02:00
else if ( btn2 . GetState ( ) = = STATE_CLICKED ) //back
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
choice = 0 ;
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT , 50 ) ;
mainWindow - > SetState ( STATE_DEFAULT ) ;
wiilight ( 0 ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( btn3 . GetState ( ) = = STATE_CLICKED ) //settings
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
choice = 2 ;
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT , 50 ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( nameBtn . GetState ( ) = = STATE_CLICKED ) //rename
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
choice = 3 ;
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT , 50 ) ;
2010-02-09 11:59:55 +01:00
}
2010-09-24 02:48:03 +02:00
else if ( btnFavorite1 . GetState ( ) = = STATE_CLICKED ) //switch favorite
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
if ( isInserted ( bootDevice ) )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
SetFavorite ( & btnFavorite1 , & btnFavorite2 , & btnFavorite3 , & btnFavorite4 , & btnFavorite5 , header - > id ,
1 ) ;
2010-09-25 10:51:44 +02:00
SetFavoriteImages ( header - > id , & btnFavoriteImg1 , & btnFavoriteImg2 , & btnFavoriteImg3 , & btnFavoriteImg4 ,
2010-09-24 02:48:03 +02:00
& btnFavoriteImg5 , & imgFavorite , & imgNotFavorite ) ;
2009-10-01 01:10:58 +02:00
}
2009-10-13 12:47:56 +02:00
btnFavorite1 . ResetState ( ) ;
2010-02-09 11:59:55 +01:00
}
2010-09-28 20:58:56 +02:00
else if ( btnLocked . GetState ( ) = = STATE_CLICKED ) //switch locked
{
if ( isInserted ( bootDevice ) )
{
SetLocked ( & btnLocked , header - > id , 1 ) ;
SetLockedImage ( header - > id , & btnLockedImg , & imgLocked , & imgNotLocked ) ;
}
btnLocked . ResetState ( ) ;
}
2010-09-24 02:48:03 +02:00
else if ( btnFavorite2 . GetState ( ) = = STATE_CLICKED ) //switch favorite
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
if ( isInserted ( bootDevice ) )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
SetFavorite ( & btnFavorite1 , & btnFavorite2 , & btnFavorite3 , & btnFavorite4 , & btnFavorite5 , header - > id ,
2 ) ;
2010-09-25 10:51:44 +02:00
SetFavoriteImages ( header - > id , & btnFavoriteImg1 , & btnFavoriteImg2 , & btnFavoriteImg3 , & btnFavoriteImg4 ,
2010-09-24 02:48:03 +02:00
& btnFavoriteImg5 , & imgFavorite , & imgNotFavorite ) ;
2009-10-13 12:47:56 +02:00
}
btnFavorite2 . ResetState ( ) ;
2010-02-09 11:59:55 +01:00
}
2010-09-24 02:48:03 +02:00
else if ( btnFavorite3 . GetState ( ) = = STATE_CLICKED ) //switch favorite
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
if ( isInserted ( bootDevice ) )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
SetFavorite ( & btnFavorite1 , & btnFavorite2 , & btnFavorite3 , & btnFavorite4 , & btnFavorite5 , header - > id ,
3 ) ;
2010-09-25 10:51:44 +02:00
SetFavoriteImages ( header - > id , & btnFavoriteImg1 , & btnFavoriteImg2 , & btnFavoriteImg3 , & btnFavoriteImg4 ,
2010-09-24 02:48:03 +02:00
& btnFavoriteImg5 , & imgFavorite , & imgNotFavorite ) ;
2009-10-13 12:47:56 +02:00
}
btnFavorite3 . ResetState ( ) ;
2010-02-09 11:59:55 +01:00
}
2010-09-24 02:48:03 +02:00
else if ( btnFavorite4 . GetState ( ) = = STATE_CLICKED ) //switch favorite
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
if ( isInserted ( bootDevice ) )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
SetFavorite ( & btnFavorite1 , & btnFavorite2 , & btnFavorite3 , & btnFavorite4 , & btnFavorite5 , header - > id ,
4 ) ;
2010-09-25 10:51:44 +02:00
SetFavoriteImages ( header - > id , & btnFavoriteImg1 , & btnFavoriteImg2 , & btnFavoriteImg3 , & btnFavoriteImg4 ,
2010-09-24 02:48:03 +02:00
& btnFavoriteImg5 , & imgFavorite , & imgNotFavorite ) ;
2009-10-13 12:47:56 +02:00
}
btnFavorite4 . ResetState ( ) ;
2010-02-09 11:59:55 +01:00
}
2010-09-24 02:48:03 +02:00
else if ( btnFavorite5 . GetState ( ) = = STATE_CLICKED ) //switch favorite
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
if ( isInserted ( bootDevice ) )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
SetFavorite ( & btnFavorite1 , & btnFavorite2 , & btnFavorite3 , & btnFavorite4 , & btnFavorite5 , header - > id ,
5 ) ;
2010-09-25 10:51:44 +02:00
SetFavoriteImages ( header - > id , & btnFavoriteImg1 , & btnFavoriteImg2 , & btnFavoriteImg3 , & btnFavoriteImg4 ,
2010-09-24 02:48:03 +02:00
& btnFavoriteImg5 , & imgFavorite , & imgNotFavorite ) ;
2009-10-13 12:47:56 +02:00
}
btnFavorite5 . ResetState ( ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( screenShotBtn . GetState ( ) = = STATE_CLICKED )
{
2010-09-19 01:16:05 +02:00
screenShotBtn . ResetState ( ) ;
2010-09-24 02:48:03 +02:00
ScreenShot ( ) ;
2010-09-19 01:16:05 +02:00
}
2009-10-01 01:10:58 +02:00
// this next part is long because nobody could agree on what the left/right buttons should do
2010-09-24 02:48:03 +02:00
else if ( ( btnRight . GetState ( ) = = STATE_CLICKED ) & & ( Settings . xflip = = no ) ) //next game
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT , 50 ) ;
2009-10-01 01:10:58 +02:00
changed = 1 ;
2009-11-10 00:03:13 +01:00
btnClick2 - > Play ( ) ;
2010-09-24 02:48:03 +02:00
gameSelected = ( gameSelected + 1 ) % gameList . size ( ) ;
2009-10-01 01:10:58 +02:00
btnRight . ResetState ( ) ;
break ;
}
2010-09-24 02:48:03 +02:00
else if ( ( btnLeft . GetState ( ) = = STATE_CLICKED ) & & ( Settings . xflip = = no ) ) //previous game
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT , 50 ) ;
2009-10-01 01:10:58 +02:00
changed = 2 ;
2009-11-10 00:03:13 +01:00
btnClick2 - > Play ( ) ;
2010-09-24 02:48:03 +02:00
gameSelected = ( gameSelected - 1 + gameList . size ( ) ) % gameList . size ( ) ;
2009-10-01 01:10:58 +02:00
btnLeft . ResetState ( ) ;
break ;
}
2010-09-24 02:48:03 +02:00
else if ( ( btnRight . GetState ( ) = = STATE_CLICKED ) & & ( Settings . xflip = = yes ) ) //previous game
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT , 50 ) ;
2009-10-01 01:10:58 +02:00
changed = 2 ;
2009-11-10 00:03:13 +01:00
btnClick2 - > Play ( ) ;
2010-09-24 02:48:03 +02:00
gameSelected = ( gameSelected - 1 + gameList . size ( ) ) % gameList . size ( ) ;
2009-10-01 01:10:58 +02:00
btnRight . ResetState ( ) ;
break ;
}
2010-09-24 02:48:03 +02:00
else if ( ( btnLeft . GetState ( ) = = STATE_CLICKED ) & & ( Settings . xflip = = yes ) ) //next game
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT , 50 ) ;
2009-10-01 01:10:58 +02:00
changed = 1 ;
2009-11-10 00:03:13 +01:00
btnClick2 - > Play ( ) ;
2010-09-24 02:48:03 +02:00
gameSelected = ( gameSelected + 1 ) % gameList . size ( ) ;
2009-10-01 01:10:58 +02:00
btnLeft . ResetState ( ) ;
break ;
}
2010-09-24 02:48:03 +02:00
else if ( ( btnRight . GetState ( ) = = STATE_CLICKED ) & & ( Settings . xflip = = sysmenu ) ) //previous game
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT , 50 ) ;
2009-10-01 01:10:58 +02:00
changed = 2 ;
2009-11-10 00:03:13 +01:00
btnClick2 - > Play ( ) ;
2010-09-24 02:48:03 +02:00
gameSelected = ( gameSelected + 1 ) % gameList . size ( ) ;
2009-10-01 01:10:58 +02:00
btnRight . ResetState ( ) ;
break ;
}
2010-09-24 02:48:03 +02:00
else if ( ( btnLeft . GetState ( ) = = STATE_CLICKED ) & & ( Settings . xflip = = sysmenu ) ) //next game
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT , 50 ) ;
2009-10-01 01:10:58 +02:00
changed = 1 ;
2009-11-10 00:03:13 +01:00
btnClick2 - > Play ( ) ;
2010-09-24 02:48:03 +02:00
gameSelected = ( gameSelected - 1 + gameList . size ( ) ) % gameList . size ( ) ;
2009-10-01 01:10:58 +02:00
btnLeft . ResetState ( ) ;
break ;
}
2010-09-24 02:48:03 +02:00
else if ( ( btnRight . GetState ( ) = = STATE_CLICKED ) & & ( Settings . xflip = = wtf ) ) //previous game
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT , 50 ) ;
2009-10-01 01:10:58 +02:00
changed = 1 ;
2009-11-10 00:03:13 +01:00
btnClick2 - > Play ( ) ;
2010-09-24 02:48:03 +02:00
gameSelected = ( gameSelected - 1 + gameList . size ( ) ) % gameList . size ( ) ;
2009-10-01 01:10:58 +02:00
btnRight . ResetState ( ) ;
break ;
}
2010-09-24 02:48:03 +02:00
else if ( ( btnLeft . GetState ( ) = = STATE_CLICKED ) & & ( Settings . xflip = = wtf ) ) //next game
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT , 50 ) ;
2009-10-01 01:10:58 +02:00
changed = 2 ;
2009-11-10 00:03:13 +01:00
btnClick2 - > Play ( ) ;
2010-09-24 02:48:03 +02:00
gameSelected = ( gameSelected + 1 ) % gameList . size ( ) ;
2009-10-01 01:10:58 +02:00
btnLeft . ResetState ( ) ;
break ;
}
2010-09-24 02:48:03 +02:00
else if ( ( btnRight . GetState ( ) = = STATE_CLICKED ) & & ( Settings . xflip = = disk3d ) ) //next game
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
// diskImg.SetBetaRotateEffect(45, 90);
2009-10-01 01:10:58 +02:00
changed = 3 ;
2009-11-10 00:03:13 +01:00
btnClick2 - > Play ( ) ;
2010-09-24 02:48:03 +02:00
gameSelected = ( gameSelected + 1 ) % gameList . size ( ) ;
2009-10-01 01:10:58 +02:00
btnRight . ResetState ( ) ;
break ;
}
2010-09-24 02:48:03 +02:00
else if ( ( btnLeft . GetState ( ) = = STATE_CLICKED ) & & ( Settings . xflip = = disk3d ) ) //previous game
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
// diskImg.SetBetaRotateEffect(-45, 90);
// promptWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 1/*50*/);
2009-10-01 01:10:58 +02:00
changed = 4 ;
2009-11-10 00:03:13 +01:00
btnClick2 - > Play ( ) ;
2010-09-24 02:48:03 +02:00
gameSelected = ( gameSelected - 1 + gameList . size ( ) ) % gameList . size ( ) ;
2009-10-01 01:10:58 +02:00
btnLeft . ResetState ( ) ;
break ;
}
}
2010-09-24 02:48:03 +02:00
while ( promptWindow . GetEffect ( ) > 0 )
usleep ( 50 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
if ( changed ! = 3 & & changed ! = 4 ) // changed==3 or changed==4 --> only Halt the GUI
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
mainWindow - > Remove ( & promptWindow ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
}
}
delete diskCover ;
delete diskCover2 ;
2010-09-24 02:48:03 +02:00
if ( gameSound )
2010-02-09 11:59:55 +01:00
{
2009-11-10 00:03:13 +01:00
gameSound - > Stop ( ) ;
2010-09-19 01:16:05 +02:00
delete gameSound ;
2009-11-08 21:13:57 +01:00
gameSound = NULL ;
}
2010-09-24 02:48:03 +02:00
bgMusic - > SetVolume ( Settings . volume ) ;
2009-11-08 21:13:57 +01:00
2010-09-24 02:48:03 +02:00
gprintf ( " \t ret: %i \n " , choice ) ;
2009-10-01 01:10:58 +02:00
return choice ;
}
/****************************************************************************
* DiscWait
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2010-09-24 02:48:03 +02:00
int DiscWait ( const char * title , const char * msg , const char * btn1Label , const char * btn2Label , int IsDeviceWait )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
int i = 30 , ret = 0 ;
u32 cover = 0 ;
2010-09-24 02:48:03 +02:00
GuiWindow promptWindow ( 472 , 320 ) ;
promptWindow . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
promptWindow . SetPosition ( 0 , - 10 ) ;
GuiSound btnSoundOver ( button_over_pcm , button_over_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
2010-09-24 02:48:03 +02:00
if ( ! btnClick2 ) btnClick2 = new GuiSound ( button_click2_pcm , button_click2_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
2009-10-01 01:10:58 +02:00
2010-09-26 10:33:43 +02:00
GuiImageData btnOutline ( Resources : : GetFile ( " button_dialogue_box.png " ) , Resources : : GetFileSize ( " button_dialogue_box.png " ) ) ;
GuiImageData dialogBox ( Resources : : GetFile ( " dialogue_box.png " ) , Resources : : GetFileSize ( " dialogue_box.png " ) ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigA ;
2010-09-24 02:48:03 +02:00
trigA . SetSimpleTrigger ( - 1 , WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A , PAD_BUTTON_A ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigB ;
2010-09-24 02:48:03 +02:00
trigB . SetButtonOnlyTrigger ( - 1 , WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B , PAD_BUTTON_B ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
GuiImage dialogBoxImg ( & dialogBox ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
dialogBoxImg . SetWidescreen ( Settings . widescreen ) ;
2010-09-19 01:16:05 +02:00
}
2009-10-01 01:10:58 +02:00
2010-09-24 19:58:56 +02:00
GuiText titleTxt ( title , 26 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
titleTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
titleTxt . SetPosition ( 0 , 60 ) ;
2010-09-24 19:58:56 +02:00
GuiText msgTxt ( msg , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
msgTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
msgTxt . SetPosition ( 0 , - 40 ) ;
msgTxt . SetMaxWidth ( 430 ) ;
2009-12-30 10:52:24 +01:00
2010-09-24 19:58:56 +02:00
GuiText btn1Txt ( btn1Label , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
GuiImage btn1Img ( & btnOutline ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
btn1Txt . SetWidescreen ( Settings . widescreen ) ;
btn1Img . SetWidescreen ( Settings . widescreen ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
GuiButton btn1 ( & btn1Img , & btn1Img , 1 , 5 , 0 , 0 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
if ( btn2Label )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
btn1 . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
btn1 . SetPosition ( 40 , - 45 ) ;
2010-09-19 01:16:05 +02:00
}
else
{
2010-09-24 02:48:03 +02:00
btn1 . SetAlignment ( ALIGN_CENTRE , ALIGN_BOTTOM ) ;
btn1 . SetPosition ( 0 , - 45 ) ;
2010-09-19 01:16:05 +02:00
}
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
btn1 . SetLabel ( & btn1Txt ) ;
btn1 . SetTrigger ( & trigB ) ;
btn1 . SetState ( STATE_SELECTED ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 19:58:56 +02:00
GuiText btn2Txt ( btn2Label , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
GuiImage btn2Img ( & btnOutline ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
btn2Txt . SetWidescreen ( Settings . widescreen ) ;
btn2Img . SetWidescreen ( Settings . widescreen ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
GuiButton btn2 ( & btn2Img , & btn2Img , 1 , 4 , - 20 , - 25 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
btn2 . SetLabel ( & btn2Txt ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
if ( ( Settings . wsprompt = = yes ) & & ( Settings . widescreen ) ) /////////////adjust buttons for widescreen
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
msgTxt . SetMaxWidth ( 380 ) ;
if ( btn2Label )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
btn1 . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
btn2 . SetPosition ( - 70 , - 80 ) ;
btn1 . SetPosition ( 70 , - 80 ) ;
2010-09-19 01:16:05 +02:00
}
else
{
2010-09-24 02:48:03 +02:00
btn1 . SetAlignment ( ALIGN_CENTRE , ALIGN_BOTTOM ) ;
btn1 . SetPosition ( 0 , - 80 ) ;
2010-09-19 01:16:05 +02:00
}
}
2010-09-24 19:58:56 +02:00
GuiText timerTxt ( ( char * ) NULL , 26 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
timerTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
timerTxt . SetPosition ( 0 , 160 ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
promptWindow . Append ( & dialogBoxImg ) ;
promptWindow . Append ( & titleTxt ) ;
promptWindow . Append ( & msgTxt ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
if ( btn1Label ) promptWindow . Append ( & btn1 ) ;
if ( btn2Label ) promptWindow . Append ( & btn2 ) ;
if ( IsDeviceWait ) promptWindow . Append ( & timerTxt ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN , 50 ) ;
2010-09-19 01:16:05 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > SetState ( STATE_DISABLED ) ;
mainWindow - > Append ( & promptWindow ) ;
mainWindow - > ChangeFocus ( & promptWindow ) ;
2010-09-19 01:16:05 +02:00
ResumeGui ( ) ;
2010-09-24 02:48:03 +02:00
if ( IsDeviceWait )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
while ( i > = 0 )
2010-09-19 01:16:05 +02:00
{
VIDEO_WaitVSync ( ) ;
2010-09-24 02:48:03 +02:00
timerTxt . SetTextf ( " %u %s " , i , tr ( " seconds left " ) ) ;
2010-09-19 01:16:05 +02:00
/* HaltGui();
if ( Settings . cios = = ios222 ) {
2010-09-24 02:48:03 +02:00
ret = IOS_ReloadIOS ( 222 ) ;
load_ehc_module ( ) ;
2010-09-19 01:16:05 +02:00
} else {
2010-09-24 02:48:03 +02:00
ret = IOS_ReloadIOS ( 249 ) ;
2010-09-19 01:16:05 +02:00
}
ResumeGui ( ) ; */
2010-09-24 02:48:03 +02:00
sleep ( 1 ) ;
2010-09-19 01:16:05 +02:00
USBDevice_deInit ( ) ;
USBDevice_Init ( ) ;
2010-09-24 02:48:03 +02:00
ret = WBFS_Init ( WBFS_DEVICE_USB ) ;
if ( ret > = 0 ) break ;
2010-09-19 01:16:05 +02:00
i - - ;
}
}
else
{
2010-09-24 02:48:03 +02:00
while ( ! ( cover & 0x2 ) )
2010-09-19 01:16:05 +02:00
{
VIDEO_WaitVSync ( ) ;
2010-09-24 02:48:03 +02:00
if ( btn1 . GetState ( ) = = STATE_CLICKED )
2010-09-19 01:16:05 +02:00
{
btn1 . ResetState ( ) ;
break ;
}
2010-09-24 02:48:03 +02:00
ret = WDVD_GetCoverStatus ( & cover ) ;
if ( ret < 0 ) break ;
2010-09-19 01:16:05 +02:00
}
}
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT , 50 ) ;
while ( promptWindow . GetEffect ( ) > 0 )
usleep ( 50 ) ;
2010-09-19 01:16:05 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > Remove ( & promptWindow ) ;
mainWindow - > SetState ( STATE_DEFAULT ) ;
2010-09-19 01:16:05 +02:00
ResumeGui ( ) ;
return ret ;
}
/****************************************************************************
* FormatingPartition
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2010-09-24 02:48:03 +02:00
int FormatingPartition ( const char * title , partitionEntry * entry )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
int ret ;
2010-09-24 02:48:03 +02:00
GuiWindow promptWindow ( 472 , 320 ) ;
promptWindow . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
promptWindow . SetPosition ( 0 , - 10 ) ;
2009-10-01 01:10:58 +02:00
2010-09-26 10:33:43 +02:00
GuiImageData btnOutline ( Resources : : GetFile ( " button_dialogue_box.png " ) , Resources : : GetFileSize ( " button_dialogue_box.png " ) ) ;
GuiImageData dialogBox ( Resources : : GetFile ( " dialogue_box.png " ) , Resources : : GetFileSize ( " dialogue_box.png " ) ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigA ;
2010-09-24 02:48:03 +02:00
trigA . SetSimpleTrigger ( - 1 , WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A , PAD_BUTTON_A ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
GuiImage dialogBoxImg ( & dialogBox ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
dialogBoxImg . SetWidescreen ( Settings . widescreen ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 19:58:56 +02:00
GuiText titleTxt ( title , 26 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
titleTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
titleTxt . SetPosition ( 0 , 60 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
promptWindow . Append ( & dialogBoxImg ) ;
promptWindow . Append ( & titleTxt ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN , 50 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > SetState ( STATE_DISABLED ) ;
mainWindow - > Append ( & promptWindow ) ;
mainWindow - > ChangeFocus ( & promptWindow ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
VIDEO_WaitVSync ( ) ;
2010-09-24 02:48:03 +02:00
ret = WBFS_Format ( entry - > sector , entry - > size ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT , 50 ) ;
while ( promptWindow . GetEffect ( ) > 0 )
usleep ( 50 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > Remove ( & promptWindow ) ;
mainWindow - > SetState ( STATE_DEFAULT ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
return ret ;
}
/****************************************************************************
* SearchMissingImages
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2010-09-24 02:48:03 +02:00
bool SearchMissingImages ( int choice2 )
2010-09-19 01:16:05 +02:00
{
2009-11-08 21:13:57 +01:00
2010-09-24 02:48:03 +02:00
gprintf ( " \n SearchMissingImages(%i) " , choice2 ) ;
GuiWindow promptWindow ( 472 , 320 ) ;
promptWindow . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
promptWindow . SetPosition ( 0 , - 10 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
GuiSound btnSoundOver ( button_over_pcm , button_over_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
2010-09-24 02:48:03 +02:00
if ( ! btnClick2 ) btnClick2 = new GuiSound ( button_click2_pcm , button_click2_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
2009-10-01 01:10:58 +02:00
2010-09-26 10:33:43 +02:00
GuiImageData btnOutline ( Resources : : GetFile ( " button_dialogue_box.png " ) , Resources : : GetFileSize ( " button_dialogue_box.png " ) ) ;
GuiImageData dialogBox ( Resources : : GetFile ( " dialogue_box.png " ) , Resources : : GetFileSize ( " dialogue_box.png " ) ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigA ;
2010-09-24 02:48:03 +02:00
trigA . SetSimpleTrigger ( - 1 , WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A , PAD_BUTTON_A ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
GuiImage dialogBoxImg ( & dialogBox ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
dialogBoxImg . SetWidescreen ( Settings . widescreen ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 19:58:56 +02:00
GuiText titleTxt ( tr ( " Checking existing artwork " ) , 26 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
titleTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
titleTxt . SetPosition ( 0 , 60 ) ;
2009-10-01 01:10:58 +02:00
char msg [ 20 ] = " " ;
2010-09-24 19:58:56 +02:00
GuiText msgTxt ( msg , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
msgTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
msgTxt . SetPosition ( 0 , - 40 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
promptWindow . Append ( & dialogBoxImg ) ;
promptWindow . Append ( & titleTxt ) ;
promptWindow . Append ( & msgTxt ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN , 50 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > SetState ( STATE_DISABLED ) ;
mainWindow - > Append ( & promptWindow ) ;
mainWindow - > ChangeFocus ( & promptWindow ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
2009-11-08 21:13:57 +01:00
2009-10-01 01:10:58 +02:00
//make sure that all games are added to the gamelist
2010-09-18 13:46:25 +02:00
gameList . LoadUnfiltered ( ) ;
2009-10-01 01:10:58 +02:00
2010-09-19 01:16:05 +02:00
cntMissFiles = 0 ;
int i = 0 ;
char filename [ 11 ] ;
//add IDs of games that are missing covers to cntMissFiles
bool found1 = false ;
bool found2 = false ;
bool found3 = false ;
2010-09-24 02:48:03 +02:00
for ( i = 0 ; i < gameList . size ( ) & & cntMissFiles < 500 ; i + + )
2010-09-19 01:16:05 +02:00
{
struct discHdr * header = gameList [ i ] ;
2010-09-24 02:48:03 +02:00
if ( choice2 ! = 3 )
2010-09-19 01:16:05 +02:00
{
char * covers_path = choice2 = = 1 ? Settings . covers2d_path : Settings . covers_path ;
2010-09-24 02:48:03 +02:00
snprintf ( filename , sizeof ( filename ) , " %c%c%c.png " , header - > id [ 0 ] , header - > id [ 1 ] , header - > id [ 2 ] ) ;
2010-09-25 08:54:27 +02:00
found2 = FindFile ( filename , covers_path ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
snprintf ( filename , sizeof ( filename ) , " %c%c%c%c.png " , header - > id [ 0 ] , header - > id [ 1 ] , header - > id [ 2 ] ,
header - > id [ 3 ] ) ;
2010-09-25 08:54:27 +02:00
found3 = FindFile ( filename , covers_path ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
snprintf ( filename , sizeof ( filename ) , " %c%c%c%c%c%c.png " , header - > id [ 0 ] , header - > id [ 1 ] , header - > id [ 2 ] ,
header - > id [ 3 ] , header - > id [ 4 ] , header - > id [ 5 ] ) ; //full id
2010-09-25 08:54:27 +02:00
found1 = FindFile ( filename , covers_path ) ;
2010-09-24 02:48:03 +02:00
if ( ! found1 & & ! found2 & & ! found3 ) //if could not find any image
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
snprintf ( missingFiles [ cntMissFiles ] , 11 , " %s " , filename ) ;
2010-09-19 01:16:05 +02:00
cntMissFiles + + ;
}
}
2010-09-24 02:48:03 +02:00
else if ( choice2 = = 3 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
snprintf ( filename , sizeof ( filename ) , " %c%c%c.png " , header - > id [ 0 ] , header - > id [ 1 ] , header - > id [ 2 ] ) ;
2010-09-25 08:54:27 +02:00
found2 = FindFile ( filename , Settings . disc_path ) ;
2010-09-24 02:48:03 +02:00
snprintf ( filename , sizeof ( filename ) , " %c%c%c%c%c%c.png " , header - > id [ 0 ] , header - > id [ 1 ] , header - > id [ 2 ] ,
header - > id [ 3 ] , header - > id [ 4 ] , header - > id [ 5 ] ) ; //full id
2010-09-25 08:54:27 +02:00
found1 = FindFile ( filename , Settings . disc_path ) ;
2010-09-24 02:48:03 +02:00
if ( ! found1 & & ! found2 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
snprintf ( missingFiles [ cntMissFiles ] , 11 , " %s " , filename ) ;
2010-09-19 01:16:05 +02:00
cntMissFiles + + ;
}
}
}
2010-09-24 02:48:03 +02:00
if ( cntMissFiles = = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
msgTxt . SetText ( tr ( " No file missing! " ) ) ;
sleep ( 1 ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT , 50 ) ;
while ( promptWindow . GetEffect ( ) > 0 )
usleep ( 50 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > Remove ( & promptWindow ) ;
mainWindow - > SetState ( STATE_DEFAULT ) ;
2010-09-19 01:16:05 +02:00
gameList . FilterList ( ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
2009-11-08 21:13:57 +01:00
2010-09-24 02:48:03 +02:00
gprintf ( " = %i " , cntMissFiles ) ;
if ( cntMissFiles > 0 ) //&& !IsNetworkInit()) {
2010-09-19 01:16:05 +02:00
{
NetworkInitPrompt ( ) ;
}
2010-02-09 11:59:55 +01:00
2010-09-24 02:48:03 +02:00
if ( cntMissFiles = = 0 )
2010-09-19 01:16:05 +02:00
{
return false ;
}
else
{
return true ;
}
2009-10-01 01:10:58 +02:00
}
/****************************************************************************
* NetworkInitPrompt
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2010-09-19 01:16:05 +02:00
bool NetworkInitPrompt ( )
{
2009-10-18 23:23:54 +02:00
2010-09-24 02:48:03 +02:00
gprintf ( " \n NetworkinitPrompt() " ) ;
if ( IsNetworkInit ( ) ) return true ;
2009-10-18 23:23:54 +02:00
2009-10-01 01:10:58 +02:00
bool success = true ;
2010-09-24 02:48:03 +02:00
GuiWindow promptWindow ( 472 , 320 ) ;
promptWindow . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
promptWindow . SetPosition ( 0 , - 10 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
GuiSound btnSoundOver ( button_over_pcm , button_over_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
2010-09-24 02:48:03 +02:00
if ( ! btnClick2 ) btnClick2 = new GuiSound ( button_click2_pcm , button_click2_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
2009-10-01 01:10:58 +02:00
2010-09-26 10:33:43 +02:00
GuiImageData btnOutline ( Resources : : GetFile ( " button_dialogue_box.png " ) , Resources : : GetFileSize ( " button_dialogue_box.png " ) ) ;
GuiImageData dialogBox ( Resources : : GetFile ( " dialogue_box.png " ) , Resources : : GetFileSize ( " dialogue_box.png " ) ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigA ;
2010-09-24 02:48:03 +02:00
trigA . SetSimpleTrigger ( - 1 , WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A , PAD_BUTTON_A ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
GuiImage dialogBoxImg ( & dialogBox ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
dialogBoxImg . SetWidescreen ( Settings . widescreen ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 19:58:56 +02:00
GuiText titleTxt ( tr ( " Initializing Network " ) , 26 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
titleTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
titleTxt . SetPosition ( 0 , 60 ) ;
2009-10-01 01:10:58 +02:00
char msg [ 20 ] = " " ;
2010-09-24 19:58:56 +02:00
GuiText msgTxt ( msg , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
msgTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
msgTxt . SetPosition ( 0 , - 40 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 19:58:56 +02:00
GuiText btn1Txt ( tr ( " Cancel " ) , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
GuiImage btn1Img ( & btnOutline ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
btn1Txt . SetWidescreen ( Settings . widescreen ) ;
btn1Img . SetWidescreen ( Settings . widescreen ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
GuiButton btn1 ( & btn1Img , & btn1Img , 2 , 4 , 0 , - 45 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
btn1 . SetLabel ( & btn1Txt ) ;
btn1 . SetState ( STATE_SELECTED ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
if ( ( Settings . wsprompt = = yes ) & & ( Settings . widescreen ) ) /////////////adjust buttons for widescreen
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
btn1 . SetAlignment ( ALIGN_CENTRE , ALIGN_BOTTOM ) ;
btn1 . SetPosition ( 0 , - 80 ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
promptWindow . Append ( & dialogBoxImg ) ;
promptWindow . Append ( & titleTxt ) ;
promptWindow . Append ( & msgTxt ) ;
promptWindow . Append ( & btn1 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN , 50 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > SetState ( STATE_DISABLED ) ;
mainWindow - > Append ( & promptWindow ) ;
mainWindow - > ChangeFocus ( & promptWindow ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
2010-09-24 02:48:03 +02:00
while ( ! IsNetworkInit ( ) )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
VIDEO_WaitVSync ( ) ;
Initialize_Network ( ) ;
2010-09-24 02:48:03 +02:00
if ( ! IsNetworkInit ( ) )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
msgTxt . SetText ( tr ( " Could not initialize network! " ) ) ;
sleep ( 3 ) ;
2009-10-01 01:10:58 +02:00
success = false ;
break ;
}
2010-09-24 02:48:03 +02:00
if ( btn1 . GetState ( ) = = STATE_CLICKED )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
btn1 . ResetState ( ) ;
success = false ;
break ;
}
}
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT , 50 ) ;
while ( promptWindow . GetEffect ( ) > 0 )
usleep ( 50 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > Remove ( & promptWindow ) ;
mainWindow - > SetState ( STATE_DEFAULT ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
return success ;
}
/****************************************************************************
* ProgressDownloadWindow
*
* Opens a window , which displays progress to the user . Can either display a
* progress bar showing % completion , or a throbber that only shows that an
* action is in progress .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2010-09-24 02:48:03 +02:00
int ProgressDownloadWindow ( int choice2 )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
int i = 0 , cntNotFound = 0 ;
2010-09-24 02:48:03 +02:00
GuiWindow promptWindow ( 472 , 320 ) ;
promptWindow . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
promptWindow . SetPosition ( 0 , - 10 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
GuiSound btnSoundOver ( button_over_pcm , button_over_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
2010-09-24 02:48:03 +02:00
if ( ! btnClick2 ) btnClick2 = new GuiSound ( button_click2_pcm , button_click2_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
2009-10-01 01:10:58 +02:00
2010-09-26 10:33:43 +02:00
GuiImageData btnOutline ( Resources : : GetFile ( " button_dialogue_box.png " ) , Resources : : GetFileSize ( " button_dialogue_box.png " ) ) ;
GuiImageData dialogBox ( Resources : : GetFile ( " dialogue_box.png " ) , Resources : : GetFileSize ( " dialogue_box.png " ) ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigA ;
2010-09-24 02:48:03 +02:00
trigA . SetSimpleTrigger ( - 1 , WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A , PAD_BUTTON_A ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
GuiImage dialogBoxImg ( & dialogBox ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
dialogBoxImg . SetWidescreen ( Settings . widescreen ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-26 10:33:43 +02:00
GuiImageData progressbarOutline ( Resources : : GetFile ( " progressbar_outline.png " ) , Resources : : GetFileSize ( " progressbar_outline.png " ) ) ;
2010-09-24 02:48:03 +02:00
GuiImage progressbarOutlineImg ( & progressbarOutline ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
progressbarOutlineImg . SetWidescreen ( Settings . widescreen ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
progressbarOutlineImg . SetAlignment ( ALIGN_LEFT , ALIGN_MIDDLE ) ;
progressbarOutlineImg . SetPosition ( 25 , 40 ) ;
2010-09-19 01:16:05 +02:00
2010-09-26 10:33:43 +02:00
GuiImageData progressbarEmpty ( Resources : : GetFile ( " progressbar_empty.png " ) , Resources : : GetFileSize ( " progressbar_empty.png " ) ) ;
2010-09-24 02:48:03 +02:00
GuiImage progressbarEmptyImg ( & progressbarEmpty ) ;
progressbarEmptyImg . SetAlignment ( ALIGN_LEFT , ALIGN_MIDDLE ) ;
progressbarEmptyImg . SetPosition ( 25 , 40 ) ;
progressbarEmptyImg . SetTile ( 100 ) ;
2010-09-19 01:16:05 +02:00
2010-09-26 10:33:43 +02:00
GuiImageData progressbar ( Resources : : GetFile ( " progressbar.png " ) , Resources : : GetFileSize ( " progressbar.png " ) ) ;
2010-09-24 02:48:03 +02:00
GuiImage progressbarImg ( & progressbar ) ;
progressbarImg . SetAlignment ( ALIGN_LEFT , ALIGN_MIDDLE ) ;
progressbarImg . SetPosition ( 25 , 40 ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 19:58:56 +02:00
GuiText titleTxt ( tr ( " Downloading file " ) , 26 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
titleTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
titleTxt . SetPosition ( 0 , 60 ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 19:58:56 +02:00
GuiText msgTxt ( ( char * ) NULL , 20 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
msgTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
msgTxt . SetPosition ( 0 , 130 ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 19:58:56 +02:00
GuiText msg2Txt ( ( char * ) NULL , 26 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
msg2Txt . SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
msg2Txt . SetPosition ( 0 , 100 ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 19:58:56 +02:00
GuiText prTxt ( ( char * ) NULL , 26 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
prTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
prTxt . SetPosition ( 0 , 40 ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 19:58:56 +02:00
GuiText btn1Txt ( tr ( " Cancel " ) , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
GuiImage btn1Img ( & btnOutline ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
btn1Txt . SetWidescreen ( Settings . widescreen ) ;
btn1Img . SetWidescreen ( Settings . widescreen ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
GuiButton btn1 ( & btn1Img , & btn1Img , 2 , 4 , 0 , - 45 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
btn1 . SetLabel ( & btn1Txt ) ;
btn1 . SetState ( STATE_SELECTED ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
if ( ( Settings . wsprompt = = yes ) & & ( Settings . widescreen ) ) /////////////adjust for widescreen
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
progressbarOutlineImg . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
progressbarOutlineImg . SetPosition ( 0 , 40 ) ;
progressbarEmptyImg . SetPosition ( 80 , 40 ) ;
progressbarEmptyImg . SetTile ( 78 ) ;
progressbarImg . SetPosition ( 80 , 40 ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
promptWindow . Append ( & dialogBoxImg ) ;
promptWindow . Append ( & titleTxt ) ;
promptWindow . Append ( & msgTxt ) ;
promptWindow . Append ( & msg2Txt ) ;
promptWindow . Append ( & progressbarEmptyImg ) ;
promptWindow . Append ( & progressbarImg ) ;
promptWindow . Append ( & progressbarOutlineImg ) ;
promptWindow . Append ( & prTxt ) ;
promptWindow . Append ( & btn1 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > SetState ( STATE_DISABLED ) ;
mainWindow - > Append ( & promptWindow ) ;
mainWindow - > ChangeFocus ( & promptWindow ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
2010-09-19 01:16:05 +02:00
int offset = 0 , tries = 0 ;
int serverCnt3d = 1 , serverCnt2d = 1 , serverCntDisc = 2 ;
2009-10-01 01:10:58 +02:00
char server3d [ 100 ] ;
char serverDisc [ 100 ] ;
char serverDiscCustom [ 100 ] ;
char server2d [ 100 ] ;
2010-09-24 02:48:03 +02:00
snprintf ( server3d , sizeof ( server3d ) , " http://wiitdb.com/wiitdb/artwork/cover3D/ " ) ;
snprintf ( serverDisc , sizeof ( serverDisc ) , " http://wiitdb.com/wiitdb/artwork/disc/ " ) ;
snprintf ( serverDiscCustom , sizeof ( serverDiscCustom ) , " http://wiitdb.com/wiitdb/artwork/disccustom/ " ) ;
snprintf ( server2d , sizeof ( server2d ) , " http://wiitdb.com/wiitdb/artwork/cover/ " ) ;
2009-10-01 01:10:58 +02:00
//check if directory exist and if not create one
struct stat st ;
2010-09-24 02:48:03 +02:00
if ( stat ( Settings . covers_path , & st ) ! = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-25 08:54:27 +02:00
if ( ! CreateSubfolder ( Settings . covers_path ) )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
WindowPrompt ( tr ( " Error ! " ) , tr ( " Can't create directory " ) , tr ( " OK " ) ) ;
2009-10-01 01:10:58 +02:00
cntMissFiles = 0 ;
}
}
2010-09-24 02:48:03 +02:00
if ( stat ( Settings . covers2d_path , & st ) ! = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-25 08:54:27 +02:00
if ( ! CreateSubfolder ( Settings . covers2d_path ) )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
WindowPrompt ( tr ( " Error ! " ) , tr ( " Can't create directory " ) , tr ( " OK " ) ) ;
2009-10-01 01:10:58 +02:00
cntMissFiles = 0 ;
}
}
2010-09-24 02:48:03 +02:00
if ( stat ( Settings . disc_path , & st ) ! = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-25 08:54:27 +02:00
if ( ! CreateSubfolder ( Settings . disc_path ) )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
WindowPrompt ( tr ( " Error ! " ) , tr ( " Can't create directory " ) , tr ( " OK " ) ) ;
2009-10-01 01:10:58 +02:00
cntMissFiles = 0 ;
}
}
//int server = 1;
2010-09-24 02:48:03 +02:00
while ( i < cntMissFiles )
2010-09-19 01:16:05 +02:00
{
tries = 0 ;
2010-09-24 02:48:03 +02:00
prTxt . SetTextf ( " %i%% " , 100 * i / cntMissFiles ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
if ( ( Settings . wsprompt = = yes ) & & ( Settings . widescreen ) )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
//adjust for widescreen
2010-09-24 02:48:03 +02:00
progressbarImg . SetPosition ( 80 , 40 ) ;
progressbarImg . SetTile ( 80 * i / cntMissFiles ) ;
2010-09-19 01:16:05 +02:00
}
else
{
2010-09-24 02:48:03 +02:00
progressbarImg . SetTile ( 100 * i / cntMissFiles ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
if ( cntMissFiles - i > 1 )
msgTxt . SetTextf ( " %i %s " , cntMissFiles - i , tr ( " files left " ) ) ;
else msgTxt . SetTextf ( " %i %s " , cntMissFiles - i , tr ( " file left " ) ) ;
msg2Txt . SetTextf ( " http://wiitdb.com : %s " , missingFiles [ i ] ) ;
2009-10-01 01:10:58 +02:00
//download cover
char imgPath [ 100 ] ;
char URLFile [ 100 ] ;
char tmp [ 75 ] ;
2010-09-24 02:48:03 +02:00
sprintf ( tmp , tr ( " Not Found " ) ) ;
struct block file = downloadfile ( URLFile ) ;
if ( choice2 = = 2 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
while ( tries < serverCnt3d )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
//Creates URL depending from which Country the game is
2010-09-24 02:48:03 +02:00
switch ( missingFiles [ i ] [ 3 ] )
2010-09-19 01:16:05 +02:00
{
case ' J ' :
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sJA/%s " , server3d , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
break ;
case ' W ' :
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sZH/%s " , server3d , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
break ;
case ' K ' :
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sKO/%s " , server3d , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
break ;
case ' P ' :
case ' D ' :
case ' F ' :
case ' I ' :
case ' S ' :
case ' H ' :
case ' U ' :
case ' X ' :
case ' Y ' :
case ' Z ' :
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %s%s/%s " , server3d , Settings . db_language , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
break ;
case ' E ' :
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sUS/%s " , server3d , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
break ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
sprintf ( imgPath , " %s%s " , Settings . covers_path , missingFiles [ i ] ) ;
file = downloadfile ( URLFile ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
if ( ! ( file . size = = 36864 | | file . size < = 1024 | | file . size = = 7386 | | file . size < = 1174 | | file . size
= = 4446 | | file . data = = NULL ) )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
break ;
2010-09-19 01:16:05 +02:00
}
else
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sEN/%s " , server3d , missingFiles [ i ] ) ;
file = downloadfile ( URLFile ) ;
if ( ! ( file . size = = 36864 | | file . size < = 1024 | | file . size = = 7386 | | file . size < = 1174
| | file . size = = 4446 | | file . data = = NULL ) )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
break ;
}
}
tries + + ;
}
}
2010-09-24 02:48:03 +02:00
if ( choice2 = = 3 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
while ( tries < serverCntDisc )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
//Creates URL depending from which Country the game is
2010-09-24 02:48:03 +02:00
switch ( missingFiles [ i ] [ 3 ] )
2010-09-19 01:16:05 +02:00
{
case ' J ' :
2010-09-24 02:48:03 +02:00
if ( Settings . discart = = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sJA/%s " , serverDisc , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sJA/%s " , serverDiscCustom , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 2 & & tries = = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sJA/%s " , serverDisc , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 2 & & tries = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sJA/%s " , serverDiscCustom , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 3 & & tries = = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sJA/%s " , serverDiscCustom , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 3 & & tries = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sJA/%s " , serverDisc , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
break ;
case ' W ' :
2010-09-24 02:48:03 +02:00
if ( Settings . discart = = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sZH/%s " , serverDisc , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sZH/%s " , serverDiscCustom , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 2 & & tries = = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sZH/%s " , serverDisc , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 2 & & tries = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sZH/%s " , serverDiscCustom , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 3 & & tries = = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sZH/%s " , serverDiscCustom , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 3 & & tries = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sZH/%s " , serverDisc , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
break ;
case ' K ' :
2010-09-24 02:48:03 +02:00
if ( Settings . discart = = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sKO/%s " , serverDisc , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sKO/%s " , serverDiscCustom , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 2 & & tries = = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sKO/%s " , serverDisc , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 2 & & tries = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sKO/%s " , serverDiscCustom , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 3 & & tries = = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sKO/%s " , serverDiscCustom , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 3 & & tries = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sKO/%s " , serverDisc , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
break ;
case ' P ' :
case ' D ' :
case ' F ' :
case ' I ' :
case ' S ' :
case ' H ' :
case ' U ' :
case ' X ' :
case ' Y ' :
case ' Z ' :
2010-09-24 02:48:03 +02:00
if ( Settings . discart = = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %s%s/%s " , serverDisc , Settings . db_language , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %s%s/%s " , serverDiscCustom , Settings . db_language , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 2 & & tries = = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %s%s/%s " , serverDisc , Settings . db_language , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 2 & & tries = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %s%s/%s " , serverDiscCustom , Settings . db_language , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 3 & & tries = = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %s%s/%s " , serverDiscCustom , Settings . db_language , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 3 & & tries = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %s%s/%s " , serverDisc , Settings . db_language , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
break ;
case ' E ' :
2010-09-24 02:48:03 +02:00
if ( Settings . discart = = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sUS/%s " , serverDisc , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sUS/%s " , serverDiscCustom , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 2 & & tries = = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sUS/%s " , serverDisc , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 2 & & tries = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sUS/%s " , serverDiscCustom , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 3 & & tries = = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sUS/%s " , serverDiscCustom , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 3 & & tries = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sUS/%s " , serverDisc , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
break ;
}
2010-09-24 02:48:03 +02:00
sprintf ( imgPath , " %s%s " , Settings . disc_path , missingFiles [ i ] ) ;
file = downloadfile ( URLFile ) ;
if ( ! ( file . size = = 36864 | | file . size < = 1024 | | file . size = = 7386 | | file . size < = 1174 | | file . size
= = 4446 | | file . data = = NULL ) )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
break ;
2010-09-19 01:16:05 +02:00
}
else
{
2010-09-24 02:48:03 +02:00
if ( Settings . discart = = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sEN/%s " , serverDisc , missingFiles [ i ] ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sEN/%s " , serverDiscCustom , missingFiles [ i ] ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 2 & & tries = = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sEN/%s " , serverDisc , missingFiles [ i ] ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 2 & & tries = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sEN/%s " , serverDiscCustom , missingFiles [ i ] ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 3 & & tries = = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sEN/%s " , serverDiscCustom , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( Settings . discart = = 3 & & tries = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sEN/%s " , serverDisc , missingFiles [ i ] ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
file = downloadfile ( URLFile ) ;
if ( ! ( file . size = = 36864 | | file . size < = 1024 | | file . size = = 7386 | | file . size < = 1174
| | file . size = = 4446 | | file . data = = NULL ) )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
break ;
}
}
tries + + ;
}
}
2010-09-24 02:48:03 +02:00
if ( choice2 = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
while ( tries < serverCnt2d )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
//Creates URL depending from which Country the game is
2010-09-24 02:48:03 +02:00
switch ( missingFiles [ i ] [ 3 ] )
2010-09-19 01:16:05 +02:00
{
case ' J ' :
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sJA/%s " , server2d , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
break ;
case ' W ' :
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sZH/%s " , server2d , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
break ;
case ' K ' :
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sKO/%s " , server2d , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
break ;
case ' P ' :
case ' D ' :
case ' F ' :
case ' I ' :
case ' S ' :
case ' H ' :
case ' U ' :
case ' X ' :
case ' Y ' :
case ' Z ' :
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %s%s/%s " , server2d , Settings . db_language , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
break ;
case ' E ' :
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sUS/%s " , server2d , missingFiles [ i ] ) ;
2010-09-19 01:16:05 +02:00
break ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
sprintf ( imgPath , " %s%s " , Settings . covers2d_path , missingFiles [ i ] ) ;
file = downloadfile ( URLFile ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
if ( ! ( file . size = = 36864 | | file . size < = 1024 | | file . size = = 7386 | | file . size < = 1174 | | file . size
= = 4446 | | file . data = = NULL ) )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
break ;
2010-09-19 01:16:05 +02:00
}
else
{
2010-09-24 02:48:03 +02:00
sprintf ( URLFile , " %sEN/%s " , server2d , missingFiles [ i ] ) ;
file = downloadfile ( URLFile ) ;
if ( ! ( file . size = = 36864 | | file . size < = 1024 | | file . size = = 7386 | | file . size < = 1174
| | file . size = = 4446 | | file . data = = NULL ) )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
break ;
}
}
tries + + ;
}
}
offset + + ;
2010-09-24 02:48:03 +02:00
if ( file . size = = 36864 | | file . size < = 1024 | | file . size < = 1174 | | file . size = = 7386 | | file . size = = 4446
| | file . data = = NULL )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
cntNotFound + + ;
i + + ;
2010-09-19 01:16:05 +02:00
}
else
{
2010-09-24 02:48:03 +02:00
if ( file . data ! = NULL )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
// save png to sd card
2010-09-19 01:16:05 +02:00
FILE * pfile = NULL ;
2010-09-24 02:48:03 +02:00
if ( ( pfile = fopen ( imgPath , " wb " ) ) ! = NULL )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
fwrite ( file . data , 1 , file . size , pfile ) ;
fclose ( pfile ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
free ( file . data ) ;
2009-10-01 01:10:58 +02:00
}
i + + ;
}
2010-09-24 02:48:03 +02:00
if ( btn1 . GetState ( ) = = STATE_CLICKED )
2010-09-19 01:16:05 +02:00
{
cntNotFound = cntMissFiles - i + cntNotFound ;
2009-10-01 01:10:58 +02:00
break ;
}
}
/**Temporary redownloading 1st image because of a fucking corruption bug **/
2009-11-08 21:13:57 +01:00
#if 0 // is no longer necessary, since libfat is fixed
2009-10-01 01:10:58 +02:00
char URLFile [ 100 ] ;
2010-09-19 01:16:05 +02:00
struct block file = downloadfile ( URLFile ) ;
if ( choice2 = = 2 )
{
while ( tries < serverCnt3d )
{
sprintf ( URLFile , " %s%s " , server3d , missingFiles [ 0 ] ) ;
sprintf ( imgPath , " %s%s " , Settings . covers_path , missingFiles [ 0 ] ) ;
file = downloadfile ( URLFile ) ;
if ( ! ( file . size = = 36864 | | file . size < = 1024 | | file . size < = 1174 | | file . size = = 7386 | | file . size = = 4446 | | file . data = = NULL ) ) break ;
2009-10-01 01:10:58 +02:00
tries + + ;
}
}
2010-09-19 01:16:05 +02:00
if ( choice2 = = 3 )
{
while ( tries < serverCntDisc )
{
sprintf ( URLFile , " %s%s " , serverDisc , missingFiles [ 0 ] ) ;
sprintf ( imgPath , " %s%s " , Settings . disc_path , missingFiles [ 0 ] ) ;
file = downloadfile ( URLFile ) ;
if ( ! ( file . size = = 36864 | | file . size < = 1024 | | file . size < = 1174 | | file . size = = 7386 | | file . size = = 4446 | | file . data = = NULL ) ) break ;
2009-10-01 01:10:58 +02:00
tries + + ;
}
}
2010-09-19 01:16:05 +02:00
if ( choice2 = = 1 )
{
while ( tries < serverCnt2d )
{
sprintf ( URLFile , " %s%s " , server2d , missingFiles [ 0 ] ) ;
sprintf ( imgPath , " %s%s " , Settings . covers2d_path , missingFiles [ 0 ] ) ;
file = downloadfile ( URLFile ) ;
if ( ! ( file . size = = 36864 | | file . size < = 1024 | | file . size < = 1174 | | file . size = = 7386 | | file . size = = 4446 | | file . data = = NULL ) ) break ;
2009-10-01 01:10:58 +02:00
tries + + ;
}
}
2010-09-19 01:16:05 +02:00
if ( file . size = = 36864 | | file . size < = 1024 | | file . size = = 7386 | | file . size < = 1174 | | file . size = = 4446 | | file . data = = NULL )
{
}
else
{
if ( file . data ! = NULL )
{
2009-10-01 01:10:58 +02:00
// save png to sd card
FILE * pfile ;
2010-09-19 01:16:05 +02:00
pfile = fopen ( imgPath , " wb " ) ;
fwrite ( file . data , 1 , file . size , pfile ) ;
fclose ( pfile ) ;
free ( file . data ) ;
2009-10-01 01:10:58 +02:00
}
}
# endif
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > Remove ( & promptWindow ) ;
mainWindow - > SetState ( STATE_DEFAULT ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
2010-09-24 02:48:03 +02:00
if ( cntNotFound ! = 0 )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
return cntNotFound ;
2010-09-19 01:16:05 +02:00
}
else
{
2009-10-01 01:10:58 +02:00
return 0 ;
}
}
/****************************************************************************
* ProgressWindow
*
* Opens a window , which displays progress to the user . Can either display a
* progress bar showing % completion , or a throbber that only shows that an
* action is in progress .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# define BLOCKSIZE 1024
/*bool unzipArchive(char * zipfilepath, char * unzipfolderpath)
2010-09-24 02:48:03 +02:00
{
unzFile uf = unzOpen ( zipfilepath ) ;
if ( uf = = NULL )
{
// printf("Cannot open %s, aborting\n",zipfilepath);
return false ;
}
//printf("%s opened\n",zipfilepath);
if ( chdir ( unzipfolderpath ) ) // can't access dir
{
makedir ( unzipfolderpath ) ; // attempt to make dir
if ( chdir ( unzipfolderpath ) ) // still can't access dir
{
//printf("Error changing into %s, aborting\n", unzipfolderpath);
return false ;
}
}
extractZip ( uf , 0 , 1 , 0 ) ;
unzCloseCurrentFile ( uf ) ;
return true
}
*/
2009-10-01 01:10:58 +02:00
2009-11-18 10:01:14 +01:00
# ifdef FULLCHANNEL ///////////////////this is only used if the dol is being compiled for a full channel
2010-09-19 01:16:05 +02:00
int ProgressUpdateWindow ( )
{
2009-11-18 10:01:14 +01:00
int ret = 0 , failed = 0 ;
2009-10-01 01:10:58 +02:00
2010-09-19 01:16:05 +02:00
gprintf ( " \n ProgressUpdateWindow(full channel) " ) ;
GuiWindow promptWindow ( 472 , 320 ) ;
promptWindow . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
promptWindow . SetPosition ( 0 , - 10 ) ;
2009-10-01 01:10:58 +02:00
2010-09-19 01:16:05 +02:00
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, SOUND_PCM, Settings.sfxvolume);
2009-10-01 01:10:58 +02:00
char imgPath [ 100 ] ;
2010-09-19 22:25:12 +02:00
snprintf ( imgPath , sizeof ( imgPath ) , " %sbutton_dialogue_box.png " , Settings . theme_path ) ;
2010-09-19 01:16:05 +02:00
GuiImageData btnOutline ( imgPath , button_dialogue_box_png ) ;
2010-09-19 22:25:12 +02:00
snprintf ( imgPath , sizeof ( imgPath ) , " %sdialogue_box.png " , Settings . theme_path ) ;
2010-09-19 01:16:05 +02:00
GuiImageData dialogBox ( imgPath , dialogue_box_png ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigA ;
2010-09-19 01:16:05 +02:00
trigA . SetSimpleTrigger ( - 1 , WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A , PAD_BUTTON_A ) ;
2009-10-01 01:10:58 +02:00
2010-09-19 01:16:05 +02:00
GuiImage dialogBoxImg ( & dialogBox ) ;
if ( Settings . wsprompt = = yes )
{
2010-09-19 22:25:12 +02:00
dialogBoxImg . SetWidescreen ( Settings . widescreen ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-19 22:25:12 +02:00
snprintf ( imgPath , sizeof ( imgPath ) , " %sprogressbar_outline.png " , Settings . theme_path ) ;
2010-09-19 01:16:05 +02:00
GuiImageData progressbarOutline ( imgPath , progressbar_outline_png ) ;
GuiImage progressbarOutlineImg ( & progressbarOutline ) ;
if ( Settings . wsprompt = = yes )
{
2010-09-19 22:25:12 +02:00
progressbarOutlineImg . SetWidescreen ( Settings . widescreen ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-19 01:16:05 +02:00
progressbarOutlineImg . SetAlignment ( ALIGN_LEFT , ALIGN_MIDDLE ) ;
progressbarOutlineImg . SetPosition ( 25 , 7 ) ;
2009-10-01 01:10:58 +02:00
2010-09-19 22:25:12 +02:00
snprintf ( imgPath , sizeof ( imgPath ) , " %sprogressbar_empty.png " , Settings . theme_path ) ;
2010-09-19 01:16:05 +02:00
GuiImageData progressbarEmpty ( imgPath , progressbar_empty_png ) ;
GuiImage progressbarEmptyImg ( & progressbarEmpty ) ;
progressbarEmptyImg . SetAlignment ( ALIGN_LEFT , ALIGN_MIDDLE ) ;
progressbarEmptyImg . SetPosition ( 25 , 7 ) ;
progressbarEmptyImg . SetTile ( 100 ) ;
2009-10-01 01:10:58 +02:00
2010-09-19 22:25:12 +02:00
snprintf ( imgPath , sizeof ( imgPath ) , " %sprogressbar.png " , Settings . theme_path ) ;
2010-09-19 01:16:05 +02:00
GuiImageData progressbar ( imgPath , progressbar_png ) ;
GuiImage progressbarImg ( & progressbar ) ;
progressbarImg . SetAlignment ( ALIGN_LEFT , ALIGN_MIDDLE ) ;
progressbarImg . SetPosition ( 25 , 7 ) ;
2009-10-01 01:10:58 +02:00
char title [ 50 ] ;
2010-09-19 01:16:05 +02:00
sprintf ( title , " %s " , tr ( " Checking for Updates " ) ) ;
2010-09-24 19:58:56 +02:00
GuiText titleTxt ( title , 26 , Theme . prompttext ) ;
2010-09-19 01:16:05 +02:00
titleTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
titleTxt . SetPosition ( 0 , 50 ) ;
2009-10-01 01:10:58 +02:00
char msg [ 50 ] ;
2010-09-19 01:16:05 +02:00
sprintf ( msg , " %s " , tr ( " Initializing Network " ) ) ;
2010-09-24 19:58:56 +02:00
GuiText msgTxt ( msg , 26 , Theme . prompttext ) ;
2010-09-19 01:16:05 +02:00
msgTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
msgTxt . SetPosition ( 0 , 140 ) ;
2009-10-01 01:10:58 +02:00
char msg2 [ 50 ] = " " ;
2010-09-24 19:58:56 +02:00
GuiText msg2Txt ( msg2 , 26 , Theme . prompttext ) ;
2010-09-19 01:16:05 +02:00
msg2Txt . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
msg2Txt . SetPosition ( 0 , 50 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 19:58:56 +02:00
GuiText prTxt ( NULL , 26 , Theme . prompttext ) ;
2010-09-19 01:16:05 +02:00
prTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
prTxt . SetPosition ( 0 , 7 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 19:58:56 +02:00
GuiText btn1Txt ( tr ( " Cancel " ) , 22 , Theme . prompttext ) ;
2010-09-19 01:16:05 +02:00
GuiImage btn1Img ( & btnOutline ) ;
if ( Settings . wsprompt = = yes )
{
2010-09-19 22:25:12 +02:00
btn1Txt . SetWidescreen ( Settings . widescreen ) ;
btn1Img . SetWidescreen ( Settings . widescreen ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-19 01:16:05 +02:00
GuiButton btn1 ( & btn1Img , & btn1Img , 2 , 4 , 0 , - 40 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
btn1 . SetLabel ( & btn1Txt ) ;
btn1 . SetState ( STATE_SELECTED ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
if ( ( Settings . wsprompt = = yes ) & & ( Settings . widescreen ) ) /////////////adjust for widescreen
2010-09-19 01:16:05 +02:00
{
progressbarOutlineImg . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
progressbarOutlineImg . SetPosition ( 0 , 7 ) ;
progressbarEmptyImg . SetPosition ( 80 , 7 ) ;
progressbarEmptyImg . SetTile ( 78 ) ;
progressbarImg . SetPosition ( 80 , 7 ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-19 01:16:05 +02:00
promptWindow . Append ( & dialogBoxImg ) ;
promptWindow . Append ( & titleTxt ) ;
promptWindow . Append ( & msgTxt ) ;
promptWindow . Append ( & msg2Txt ) ;
promptWindow . Append ( & btn1 ) ;
2009-10-01 01:10:58 +02:00
2010-09-19 01:16:05 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN , 50 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-19 01:16:05 +02:00
mainWindow - > SetState ( STATE_DISABLED ) ;
mainWindow - > Append ( & promptWindow ) ;
mainWindow - > ChangeFocus ( & promptWindow ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
struct stat st ;
2010-09-19 01:16:05 +02:00
if ( stat ( Settings . update_path , & st ) ! = 0 )
{
if ( subfoldercreate ( Settings . covers_path ) ! = 1 )
{
WindowPrompt ( tr ( " Error ! " ) , tr ( " Can't create directory " ) , tr ( " OK " ) ) ;
2009-10-01 01:10:58 +02:00
ret = - 1 ;
failed = - 1 ;
}
}
2010-09-19 01:16:05 +02:00
if ( stat ( Settings . titlestxt_path , & st ) ! = 0 )
{
if ( subfoldercreate ( Settings . titlestxt_path ) ! = 1 )
{
WindowPrompt ( tr ( " Error ! " ) , tr ( " Can't create directory " ) , tr ( " OK " ) ) ;
2009-11-18 10:01:14 +01:00
ret = - 1 ;
failed = - 1 ;
}
}
2009-10-01 01:10:58 +02:00
2009-11-18 10:01:14 +01:00
//make the URL to get XML based on our games
2010-09-19 01:16:05 +02:00
char XMLurl [ 3540 ] ;
build_XML_URL ( XMLurl , sizeof ( XMLurl ) ) ;
2009-11-18 10:01:14 +01:00
char dolpath [ 150 ] ;
2010-09-24 02:48:03 +02:00
// char dolpathsuccess[150];//use coverspath as a folder for the update wad so we dont make a new folder and have to delete it
2010-09-19 01:16:05 +02:00
snprintf ( dolpath , sizeof ( dolpath ) , " %sULNR.wad " , Settings . covers_path ) ;
2009-11-18 10:01:14 +01:00
//snprintf(dolpathsuccess, sizeof(dolpathsuccess), "%sUNEO.wad", Settings.covers_path);
Initialize_Network ( ) ;
2010-09-19 01:16:05 +02:00
while ( ! IsNetworkInit ( ) )
{
2009-10-01 01:10:58 +02:00
VIDEO_WaitVSync ( ) ;
Initialize_Network ( ) ;
2010-09-19 01:16:05 +02:00
if ( IsNetworkInit ( ) )
{
msgTxt . SetText ( GetNetworkIP ( ) ) ;
}
else
{
msgTxt . SetText ( tr ( " Could not initialize network! " ) ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-19 01:16:05 +02:00
if ( btn1 . GetState ( ) = = STATE_CLICKED )
{
2009-10-01 01:10:58 +02:00
ret = - 1 ;
failed = - 1 ;
btn1 . ResetState ( ) ;
break ;
}
}
2010-09-19 01:16:05 +02:00
if ( IsNetworkInit ( ) & & ret > = 0 )
{
2009-10-01 01:10:58 +02:00
int newrev = CheckUpdate ( ) ;
2010-09-19 01:16:05 +02:00
if ( newrev > 0 )
{
2009-11-18 10:01:14 +01:00
FILE * pfile ;
2010-09-19 01:16:05 +02:00
sprintf ( msg , " Rev%i %s. " , newrev , tr ( " available " ) ) ;
int choice = WindowPrompt ( msg , 0 , tr ( " Update " ) , tr ( " Cancel " ) ) ;
if ( choice = = 1 )
{
titleTxt . SetTextf ( " %s USB Loader GX " , tr ( " Updating " ) ) ;
msgTxt . SetPosition ( 0 , 100 ) ;
msgTxt . SetTextf ( " %s " , tr ( " Updating WiiTDB.zip " ) ) ;
char wiitdbpath [ 200 ] ;
char wiitdbpathtmp [ 200 ] ;
struct block file = downloadfile ( XMLurl ) ;
if ( file . data ! = NULL )
{
snprintf ( wiitdbpath , sizeof ( wiitdbpath ) , " %swiitdb_%s.zip " , Settings . titlestxt_path , game_partition ) ;
snprintf ( wiitdbpathtmp , sizeof ( wiitdbpathtmp ) , " %swiitmp_%s.zip " , Settings . titlestxt_path , game_partition ) ;
rename ( wiitdbpath , wiitdbpathtmp ) ;
pfile = fopen ( wiitdbpath , " wb " ) ;
fwrite ( file . data , 1 , file . size , pfile ) ;
fclose ( pfile ) ;
free ( file . data ) ;
CloseXMLDatabase ( ) ;
2010-09-24 02:48:03 +02:00
if ( OpenXMLDatabase ( Settings . titlestxt_path , Settings . db_language , Settings . db_JPtoEN , true , Settings . titlesOverride = = 1 ? true : false , true ) ) // open file, reload titles, keep in memory
2010-09-19 01:16:05 +02:00
{
remove ( wiitdbpathtmp ) ;
}
else
{
remove ( wiitdbpath ) ;
rename ( wiitdbpathtmp , wiitdbpath ) ;
OpenXMLDatabase ( Settings . titlestxt_path , Settings . db_language , Settings . db_JPtoEN , true , Settings . titlesOverride = = 1 ? true : false , true ) ; // open file, reload titles, keep in memory
}
}
msgTxt . SetTextf ( " %s " , tr ( " Updating Language Files: " ) ) ;
2009-11-18 10:01:14 +01:00
updateLanguageFiles ( ) ;
2010-09-19 01:16:05 +02:00
promptWindow . Append ( & progressbarEmptyImg ) ;
promptWindow . Append ( & progressbarImg ) ;
promptWindow . Append ( & progressbarOutlineImg ) ;
promptWindow . Append ( & prTxt ) ;
msgTxt . SetTextf ( " %s Rev%i wad. " , tr ( " Downloading " ) , newrev ) ;
2009-12-10 21:27:36 +01:00
s32 filesize ;
2010-09-19 01:16:05 +02:00
if ( Settings . beta_upgrades )
{
char url [ 255 ] ;
memset ( & url , 0 , 255 ) ;
sprintf ( ( char * ) & url , " http://usbloader-gui.googlecode.com/files/r%d.wad " , newrev ) ;
filesize = download_request ( ( char * ) & url ) ;
}
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
2009-10-01 01:10:58 +02:00
u8 * blockbuffer = new unsigned char [ BLOCKSIZE ] ;
2010-09-19 01:16:05 +02:00
for ( s32 i = 0 ; i < filesize ; i + = BLOCKSIZE )
{
usleep ( 100 ) ;
prTxt . SetTextf ( " %i%% " , ( 100 * i / filesize ) + 1 ) ;
2010-09-19 22:25:12 +02:00
if ( ( Settings . wsprompt = = yes ) & & ( Settings . widescreen ) )
2010-09-19 01:16:05 +02:00
{
progressbarImg . SetTile ( 80 * i / filesize ) ;
}
else
{
progressbarImg . SetTile ( 100 * i / filesize ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-19 01:16:05 +02:00
msg2Txt . SetTextf ( " %iKB/%iKB " , i / 1024 , filesize / 1024 ) ;
2009-10-01 01:10:58 +02:00
2010-09-19 01:16:05 +02:00
if ( btn1 . GetState ( ) = = STATE_CLICKED )
{
fclose ( pfile ) ;
remove ( dolpath ) ;
2009-10-01 01:10:58 +02:00
failed = - 1 ;
btn1 . ResetState ( ) ;
break ;
}
u32 blksize ;
2010-09-19 01:16:05 +02:00
blksize = ( u32 ) ( filesize - i ) ;
if ( blksize > BLOCKSIZE )
2010-09-24 02:48:03 +02:00
blksize = BLOCKSIZE ;
2009-10-01 01:10:58 +02:00
2010-09-19 01:16:05 +02:00
ret = network_read ( blockbuffer , blksize ) ;
if ( ret ! = ( s32 ) blksize )
{
2009-10-01 01:10:58 +02:00
failed = - 1 ;
ret = - 1 ;
2010-09-19 01:16:05 +02:00
fclose ( pfile ) ;
remove ( dolpath ) ;
2009-10-01 01:10:58 +02:00
break ;
}
2010-09-19 01:16:05 +02:00
fwrite ( blockbuffer , 1 , blksize , pfile ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-19 01:16:05 +02:00
fclose ( pfile ) ;
2009-10-01 01:10:58 +02:00
delete blockbuffer ;
2010-09-19 01:16:05 +02:00
if ( ! failed )
{
2009-10-01 01:10:58 +02:00
}
2010-09-19 01:16:05 +02:00
}
else
{
2009-10-01 01:10:58 +02:00
failed = - 1 ;
}
2010-09-19 01:16:05 +02:00
}
else
{
2009-10-01 01:10:58 +02:00
ret = - 1 ;
}
2009-11-18 10:01:14 +01:00
2010-09-19 01:16:05 +02:00
}
else
{
WindowPrompt ( tr ( " No new updates. " ) , 0 , tr ( " OK " ) ) ;
2009-10-01 01:10:58 +02:00
ret = - 1 ;
}
}
2010-09-19 01:16:05 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT , 50 ) ;
while ( promptWindow . GetEffect ( ) > 0 ) usleep ( 50 ) ;
2009-10-01 01:10:58 +02:00
2009-11-18 10:01:14 +01:00
HaltGui ( ) ;
2010-09-19 01:16:05 +02:00
mainWindow - > Remove ( & promptWindow ) ;
2009-11-18 10:01:14 +01:00
//mainWindow->SetState(STATE_DEFAULT);
ResumeGui ( ) ;
2009-10-01 01:10:58 +02:00
CloseConnection ( ) ;
2010-09-19 01:16:05 +02:00
sleep ( 1 ) ; //sleep 1 because it froze without this for some reason
2009-10-01 01:10:58 +02:00
2010-09-19 01:16:05 +02:00
if ( ! failed & & ret > = 0 )
{
2009-11-08 21:13:57 +01:00
2009-11-18 10:01:14 +01:00
FILE * wadFile = NULL ;
s32 error = 1 ;
int diarhea = 0 ;
char nipple [ 100 ] ;
2010-09-19 01:16:05 +02:00
wadFile = fopen ( dolpath , " rb " ) ;
2010-09-24 02:48:03 +02:00
if ( wadFile = = NULL ) //we can't open the file wad we just downloaded
2010-09-19 01:16:05 +02:00
{
sprintf ( nipple , tr ( " Unable to open the wad that was just downloaded (%s). " ) , dolpath ) ;
WindowPrompt ( tr ( " Error ! " ) , nipple , tr ( " OK " ) ) ;
2009-11-18 10:01:14 +01:00
failed = - 1 ;
2010-09-19 01:16:05 +02:00
}
else
{
2009-11-18 10:01:14 +01:00
//sprintf(nipple, tr("The update wad has been saved as %s. Now let's try to install it."),dolpath);
//WindowPrompt(0,nipple, tr("OK"));
2010-09-19 01:16:05 +02:00
gprintf ( " \n \t install wad " ) ;
error = Wad_Install ( wadFile ) ;
fclose ( wadFile ) ;
if ( error = = 0 )
{
diarhea = remove ( dolpath ) ;
if ( diarhea )
2010-09-24 02:48:03 +02:00
WindowPrompt ( tr ( " Success " ) , tr ( " The wad file was installed. But It could not be deleted from the SD card. " ) , tr ( " OK " ) ) ;
2010-09-19 01:16:05 +02:00
}
else
{
gprintf ( " -> failed " ) ;
sprintf ( nipple , tr ( " The wad installation failed with error %ld " ) , error ) ;
WindowPrompt ( tr ( " Error " ) , nipple , tr ( " OK " ) ) ;
2009-11-18 10:01:14 +01:00
}
}
2010-09-19 01:16:05 +02:00
if ( error )
2010-09-24 02:48:03 +02:00
WindowPrompt ( tr ( " ERROR " ) , tr ( " An Error occured " ) , tr ( " OK " ) ) ;
2009-11-18 10:01:14 +01:00
else
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
WindowPrompt ( tr ( " Restarting... " ) , tr ( " Successfully Updated thanks to www.techjawa.com " ) , 0 , 0 , 0 , 0 , 150 ) ;
2010-09-19 01:16:05 +02:00
}
2009-11-18 10:01:14 +01:00
CloseXMLDatabase ( ) ;
ExitGUIThreads ( ) ;
ShutdownAudio ( ) ;
StopGX ( ) ;
2010-09-19 01:16:05 +02:00
gprintf ( " \n Rebooting " ) ;
WII_Initialize ( ) ;
WII_LaunchTitle ( TITLE_ID ( 0x00010001 , 0x554c4e52 ) ) ;
2009-10-01 01:10:58 +02:00
}
2009-11-18 10:01:14 +01:00
// promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
//while(promptWindow.GetEffect() > 0) usleep(50);
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2009-11-18 10:01:14 +01:00
//mainWindow->Remove(&promptWindow);
2010-09-19 01:16:05 +02:00
mainWindow - > SetState ( STATE_DEFAULT ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
2010-09-19 01:16:05 +02:00
if ( failed ! = 0 )
2010-09-24 02:48:03 +02:00
return failed ;
2009-10-01 01:10:58 +02:00
return 1 ;
}
2010-09-17 17:15:21 +02:00
# else
2010-09-19 01:16:05 +02:00
int ProgressUpdateWindow ( )
{
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
gprintf ( " \n ProgressUpdateWindow(not full channel) " ) ;
2009-11-18 10:01:14 +01:00
int ret = 0 , failed = 0 , updatemode = - 1 ;
2010-09-24 02:48:03 +02:00
GuiWindow promptWindow ( 472 , 320 ) ;
promptWindow . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
promptWindow . SetPosition ( 0 , - 10 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
GuiSound btnSoundOver ( button_over_pcm , button_over_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
2010-09-24 02:48:03 +02:00
if ( ! btnClick2 ) btnClick2 = new GuiSound ( button_click2_pcm , button_click2_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
2009-10-01 01:10:58 +02:00
2010-09-26 10:33:43 +02:00
GuiImageData btnOutline ( Resources : : GetFile ( " button_dialogue_box.png " ) , Resources : : GetFileSize ( " button_dialogue_box.png " ) ) ;
GuiImageData dialogBox ( Resources : : GetFile ( " dialogue_box.png " ) , Resources : : GetFileSize ( " dialogue_box.png " ) ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigA ;
2010-09-24 02:48:03 +02:00
trigA . SetSimpleTrigger ( - 1 , WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A , PAD_BUTTON_A ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
GuiImage dialogBoxImg ( & dialogBox ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
dialogBoxImg . SetWidescreen ( Settings . widescreen ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-26 10:33:43 +02:00
GuiImageData progressbarOutline ( Resources : : GetFile ( " progressbar_outline.png " ) , Resources : : GetFileSize ( " progressbar_outline.png " ) ) ;
2010-09-24 02:48:03 +02:00
GuiImage progressbarOutlineImg ( & progressbarOutline ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
progressbarOutlineImg . SetWidescreen ( Settings . widescreen ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
progressbarOutlineImg . SetAlignment ( ALIGN_LEFT , ALIGN_MIDDLE ) ;
progressbarOutlineImg . SetPosition ( 25 , 7 ) ;
2009-10-01 01:10:58 +02:00
2010-09-26 10:33:43 +02:00
GuiImageData progressbarEmpty ( Resources : : GetFile ( " progressbar_empty.png " ) , Resources : : GetFileSize ( " progressbar_empty.png " ) ) ;
2010-09-24 02:48:03 +02:00
GuiImage progressbarEmptyImg ( & progressbarEmpty ) ;
progressbarEmptyImg . SetAlignment ( ALIGN_LEFT , ALIGN_MIDDLE ) ;
progressbarEmptyImg . SetPosition ( 25 , 7 ) ;
progressbarEmptyImg . SetTile ( 100 ) ;
2009-10-01 01:10:58 +02:00
2010-09-26 10:33:43 +02:00
GuiImageData progressbar ( Resources : : GetFile ( " progressbar.png " ) , Resources : : GetFileSize ( " progressbar.png " ) ) ;
2010-09-24 02:48:03 +02:00
GuiImage progressbarImg ( & progressbar ) ;
progressbarImg . SetAlignment ( ALIGN_LEFT , ALIGN_MIDDLE ) ;
progressbarImg . SetPosition ( 25 , 7 ) ;
2009-10-01 01:10:58 +02:00
char title [ 50 ] ;
2010-09-24 02:48:03 +02:00
sprintf ( title , " %s " , tr ( " Checking for Updates " ) ) ;
2010-09-24 19:58:56 +02:00
GuiText titleTxt ( title , 26 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
titleTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
titleTxt . SetPosition ( 0 , 50 ) ;
2009-10-01 01:10:58 +02:00
char msg [ 50 ] ;
2010-09-24 02:48:03 +02:00
sprintf ( msg , " %s " , tr ( " Initializing Network " ) ) ;
2010-09-24 19:58:56 +02:00
GuiText msgTxt ( msg , 26 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
msgTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
msgTxt . SetPosition ( 0 , 140 ) ;
2009-10-01 01:10:58 +02:00
char msg2 [ 50 ] = " " ;
2010-09-24 19:58:56 +02:00
GuiText msg2Txt ( msg2 , 26 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
msg2Txt . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
msg2Txt . SetPosition ( 0 , 50 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 19:58:56 +02:00
GuiText prTxt ( ( char * ) NULL , 26 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
prTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
prTxt . SetPosition ( 0 , 7 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 19:58:56 +02:00
GuiText btn1Txt ( tr ( " Cancel " ) , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
GuiImage btn1Img ( & btnOutline ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
btn1Txt . SetWidescreen ( Settings . widescreen ) ;
btn1Img . SetWidescreen ( Settings . widescreen ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
GuiButton btn1 ( & btn1Img , & btn1Img , 2 , 4 , 0 , - 40 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
btn1 . SetLabel ( & btn1Txt ) ;
btn1 . SetState ( STATE_SELECTED ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
if ( ( Settings . wsprompt = = yes ) & & ( Settings . widescreen ) ) /////////////adjust for widescreen
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
progressbarOutlineImg . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
progressbarOutlineImg . SetPosition ( 0 , 7 ) ;
progressbarEmptyImg . SetPosition ( 80 , 7 ) ;
progressbarEmptyImg . SetTile ( 78 ) ;
progressbarImg . SetPosition ( 80 , 7 ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
promptWindow . Append ( & dialogBoxImg ) ;
promptWindow . Append ( & titleTxt ) ;
promptWindow . Append ( & msgTxt ) ;
promptWindow . Append ( & msg2Txt ) ;
promptWindow . Append ( & btn1 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN , 50 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > SetState ( STATE_DISABLED ) ;
mainWindow - > Append ( & promptWindow ) ;
mainWindow - > ChangeFocus ( & promptWindow ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
struct stat st ;
2010-09-24 02:48:03 +02:00
if ( stat ( Settings . update_path , & st ) ! = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-25 08:54:27 +02:00
if ( ! CreateSubfolder ( Settings . update_path ) )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
WindowPrompt ( tr ( " Error ! " ) , tr ( " Can't create directory " ) , tr ( " OK " ) ) ;
2009-10-01 01:10:58 +02:00
ret = - 1 ;
failed = - 1 ;
}
}
char dolpath [ 150 ] ;
2009-11-18 10:01:14 +01:00
char dolpathsuccess [ 150 ] ;
2010-09-24 02:48:03 +02:00
snprintf ( dolpath , sizeof ( dolpath ) , " %sbootnew.dol " , Settings . update_path ) ;
snprintf ( dolpathsuccess , sizeof ( dolpathsuccess ) , " %sboot.dol " , Settings . update_path ) ;
2009-11-18 10:01:14 +01:00
2010-09-24 02:48:03 +02:00
while ( ! IsNetworkInit ( ) )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
VIDEO_WaitVSync ( ) ;
Initialize_Network ( ) ;
2010-09-24 02:48:03 +02:00
if ( IsNetworkInit ( ) )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
msgTxt . SetText ( GetNetworkIP ( ) ) ;
2010-09-19 01:16:05 +02:00
}
else
{
2010-09-24 02:48:03 +02:00
msgTxt . SetText ( tr ( " Could not initialize network! " ) ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
if ( btn1 . GetState ( ) = = STATE_CLICKED )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
ret = - 1 ;
failed = - 1 ;
btn1 . ResetState ( ) ;
break ;
}
}
2010-09-19 01:16:05 +02:00
//make the URL to get XML based on our games
char XMLurl [ 3540 ] ;
2010-09-24 02:48:03 +02:00
build_XML_URL ( XMLurl , sizeof ( XMLurl ) ) ;
2009-11-18 10:01:14 +01:00
2010-09-24 02:48:03 +02:00
if ( IsNetworkInit ( ) & & ret > = 0 )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
updatemode = WindowPrompt ( tr ( " What do you want to update? " ) , 0 , " USB Loader GX " , tr ( " WiiTDB Files " ) ,
tr ( " Language File " ) , tr ( " Cancel " ) ) ;
mainWindow - > SetState ( STATE_DISABLED ) ;
promptWindow . SetState ( STATE_DEFAULT ) ;
mainWindow - > ChangeFocus ( & promptWindow ) ;
2010-02-09 11:59:55 +01:00
2010-09-24 02:48:03 +02:00
if ( updatemode = = 1 )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
2010-09-19 01:16:05 +02:00
int newrev = CheckUpdate ( ) ;
2010-09-24 02:48:03 +02:00
if ( newrev > 0 )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
sprintf ( msg , " Rev%i %s. " , newrev , tr ( " available " ) ) ;
int choice = WindowPrompt ( msg , tr ( " How do you want to update? " ) , tr ( " Update DOL " ) ,
tr ( " Update All " ) , tr ( " Cancel " ) ) ;
mainWindow - > SetState ( STATE_DISABLED ) ;
promptWindow . SetState ( STATE_DEFAULT ) ;
mainWindow - > ChangeFocus ( & promptWindow ) ;
if ( choice = = 1 | | choice = = 2 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
titleTxt . SetTextf ( " %s USB Loader GX " , tr ( " Updating " ) ) ;
msgTxt . SetPosition ( 0 , 100 ) ;
promptWindow . Append ( & progressbarEmptyImg ) ;
promptWindow . Append ( & progressbarImg ) ;
promptWindow . Append ( & progressbarOutlineImg ) ;
promptWindow . Append ( & prTxt ) ;
msgTxt . SetTextf ( " %s Rev%i " , tr ( " Update to " ) , newrev ) ;
2010-09-19 01:16:05 +02:00
s32 filesize ;
2010-09-24 02:48:03 +02:00
if ( Settings . beta_upgrades )
2010-09-19 01:16:05 +02:00
{
char url [ 255 ] ;
2010-09-24 02:48:03 +02:00
memset ( & url , 0 , 255 ) ;
sprintf ( ( char * ) & url , " http://usbloader-gui.googlecode.com/files/r%d.dol " , newrev ) ;
filesize = download_request ( ( char * ) & url ) ;
2010-02-09 11:59:55 +01:00
}
2010-09-19 01:16:05 +02:00
else
{
2010-09-24 02:48:03 +02:00
filesize = download_request ( " http://www.techjawa.com/usbloadergx/boot.dol " ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
if ( filesize > 0 )
2010-09-19 01:16:05 +02:00
{
FILE * pfile ;
2010-09-24 02:48:03 +02:00
pfile = fopen ( dolpath , " wb " ) ;
2010-09-19 01:16:05 +02:00
u8 * blockbuffer = new unsigned char [ BLOCKSIZE ] ;
2010-09-24 02:48:03 +02:00
for ( s32 i = 0 ; i < filesize ; i + = BLOCKSIZE )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
usleep ( 100 ) ;
prTxt . SetTextf ( " %i%% " , ( 100 * i / filesize ) + 1 ) ;
if ( ( Settings . wsprompt = = yes ) & & ( Settings . widescreen ) )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
progressbarImg . SetTile ( 80 * i / filesize ) ;
2010-09-19 01:16:05 +02:00
}
else
{
2010-09-24 02:48:03 +02:00
progressbarImg . SetTile ( 100 * i / filesize ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
msg2Txt . SetTextf ( " %iKB/%iKB " , i / 1024 , filesize / 1024 ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
if ( btn1 . GetState ( ) = = STATE_CLICKED )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
fclose ( pfile ) ;
remove ( dolpath ) ;
2010-09-19 01:16:05 +02:00
failed = - 1 ;
btn1 . ResetState ( ) ;
break ;
}
u32 blksize ;
2010-09-24 02:48:03 +02:00
blksize = ( u32 ) ( filesize - i ) ;
if ( blksize > BLOCKSIZE ) blksize = BLOCKSIZE ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
ret = network_read ( blockbuffer , blksize ) ;
if ( ret ! = ( s32 ) blksize )
2010-09-19 01:16:05 +02:00
{
failed = - 1 ;
ret = - 1 ;
2010-09-24 02:48:03 +02:00
fclose ( pfile ) ;
remove ( dolpath ) ;
2010-09-19 01:16:05 +02:00
break ;
2009-11-18 10:01:14 +01:00
}
2010-09-24 02:48:03 +02:00
fwrite ( blockbuffer , 1 , blksize , pfile ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
fclose ( pfile ) ;
2010-09-19 01:16:05 +02:00
delete blockbuffer ;
2010-09-24 02:48:03 +02:00
if ( ! failed )
2010-09-19 01:16:05 +02:00
{
//remove old
2010-09-25 08:54:27 +02:00
if ( CheckFile ( dolpathsuccess ) )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
remove ( dolpathsuccess ) ;
2009-11-18 10:01:14 +01:00
}
2010-09-19 01:16:05 +02:00
//rename new to old
2010-09-24 02:48:03 +02:00
rename ( dolpath , dolpathsuccess ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
if ( choice = = 2 )
2010-09-19 01:16:05 +02:00
{
//get the icon.png and the meta.xml
char xmliconpath [ 150 ] ;
2010-09-24 02:48:03 +02:00
struct block file = downloadfile ( " http://www.techjawa.com/usbloadergx/meta.file " ) ;
if ( file . data ! = NULL )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( xmliconpath , " %smeta.xml " , Settings . update_path ) ;
pfile = fopen ( xmliconpath , " wb " ) ;
fwrite ( file . data , 1 , file . size , pfile ) ;
fclose ( pfile ) ;
free ( file . data ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
file = downloadfile ( " http://www.techjawa.com/usbloadergx/icon.png " ) ;
if ( file . data ! = NULL )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
sprintf ( xmliconpath , " %sicon.png " , Settings . update_path ) ;
pfile = fopen ( xmliconpath , " wb " ) ;
fwrite ( file . data , 1 , file . size , pfile ) ;
fclose ( pfile ) ;
free ( file . data ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
msgTxt . SetTextf ( " %s " , tr ( " Updating WiiTDB.zip " ) ) ;
2010-09-19 01:16:05 +02:00
char wiitdbpath [ 200 ] ;
char wiitdbpathtmp [ 200 ] ;
2010-09-24 02:48:03 +02:00
file = downloadfile ( XMLurl ) ;
if ( file . data ! = NULL )
2010-09-19 01:16:05 +02:00
{
2010-09-25 08:54:27 +02:00
CreateSubfolder ( Settings . titlestxt_path ) ;
2010-09-24 02:48:03 +02:00
snprintf ( wiitdbpath , sizeof ( wiitdbpath ) , " %swiitdb_%s.zip " ,
Settings . titlestxt_path , game_partition ) ;
snprintf ( wiitdbpathtmp , sizeof ( wiitdbpathtmp ) , " %swiitmp_%s.zip " ,
Settings . titlestxt_path , game_partition ) ;
rename ( wiitdbpath , wiitdbpathtmp ) ;
pfile = fopen ( wiitdbpath , " wb " ) ;
fwrite ( file . data , 1 , file . size , pfile ) ;
fclose ( pfile ) ;
free ( file . data ) ;
2010-09-19 01:16:05 +02:00
CloseXMLDatabase ( ) ;
2010-09-24 02:48:03 +02:00
if ( OpenXMLDatabase ( Settings . titlestxt_path , Settings . db_language ,
Settings . db_JPtoEN , true , Settings . titlesOverride = = 1 ? true : false , true ) ) // open file, reload titles, keep in memory
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
remove ( wiitdbpathtmp ) ;
2010-09-19 01:16:05 +02:00
}
else
{
2010-09-24 02:48:03 +02:00
remove ( wiitdbpath ) ;
rename ( wiitdbpathtmp , wiitdbpath ) ;
OpenXMLDatabase ( Settings . titlestxt_path , Settings . db_language ,
Settings . db_JPtoEN , true , Settings . titlesOverride = = 1 ? true : false ,
true ) ; // open file, reload titles, keep in memory
2010-09-19 01:16:05 +02:00
}
}
2010-09-24 02:48:03 +02:00
msgTxt . SetTextf ( " %s " , tr ( " Updating Language Files: " ) ) ;
2010-09-19 01:16:05 +02:00
updateLanguageFiles ( ) ;
2009-11-18 10:01:14 +01:00
}
}
2009-10-01 01:10:58 +02:00
}
2010-09-19 01:16:05 +02:00
else
{
failed = - 1 ;
}
2009-10-01 01:10:58 +02:00
}
2010-09-19 01:16:05 +02:00
else
{
ret = - 1 ;
}
}
else
{
2010-09-24 02:48:03 +02:00
WindowPrompt ( tr ( " No new updates. " ) , 0 , tr ( " OK " ) ) ;
2009-10-01 01:10:58 +02:00
ret = - 1 ;
}
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( updatemode = = 2 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
msgTxt . SetTextf ( " %s " , tr ( " Updating WiiTDB.zip " ) ) ;
2009-11-18 10:01:14 +01:00
char wiitdbpath [ 200 ] ;
char wiitdbpathtmp [ 200 ] ;
2010-09-24 02:48:03 +02:00
struct block file = downloadfile ( XMLurl ) ;
if ( file . data ! = NULL )
2010-09-19 01:16:05 +02:00
{
2010-09-25 08:54:27 +02:00
CreateSubfolder ( Settings . titlestxt_path ) ;
2010-09-24 02:48:03 +02:00
snprintf ( wiitdbpath , sizeof ( wiitdbpath ) , " %swiitdb_%s.zip " , Settings . titlestxt_path , game_partition ) ;
snprintf ( wiitdbpathtmp , sizeof ( wiitdbpathtmp ) , " %swiitmp_%s.zip " , Settings . titlestxt_path ,
game_partition ) ;
rename ( wiitdbpath , wiitdbpathtmp ) ;
FILE * pfile = fopen ( wiitdbpath , " wb " ) ;
fwrite ( file . data , 1 , file . size , pfile ) ;
fclose ( pfile ) ;
free ( file . data ) ;
2010-09-19 01:16:05 +02:00
CloseXMLDatabase ( ) ;
2010-09-24 02:48:03 +02:00
if ( OpenXMLDatabase ( Settings . titlestxt_path , Settings . db_language , Settings . db_JPtoEN , true ,
Settings . titlesOverride = = 1 ? true : false , true ) ) // open file, reload titles, keep in memory
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
remove ( wiitdbpathtmp ) ;
2010-09-19 01:16:05 +02:00
}
else
{
2010-09-24 02:48:03 +02:00
remove ( wiitdbpath ) ;
rename ( wiitdbpathtmp , wiitdbpath ) ;
OpenXMLDatabase ( Settings . titlestxt_path , Settings . db_language , Settings . db_JPtoEN , true ,
Settings . titlesOverride = = 1 ? true : false , true ) ; // open file, reload titles, keep in memory
2010-09-19 01:16:05 +02:00
}
2009-11-18 10:01:14 +01:00
}
ret = 1 ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( updatemode = = 3 )
2010-09-19 01:16:05 +02:00
{
2009-11-18 10:01:14 +01:00
2010-09-24 02:48:03 +02:00
msgTxt . SetTextf ( " %s " , tr ( " Updating Language Files... " ) ) ;
2009-11-18 10:01:14 +01:00
updateLanguageFiles ( ) ;
ret = 1 ;
2010-09-19 01:16:05 +02:00
}
else
{
2009-11-18 10:01:14 +01:00
ret = - 1 ;
}
2009-10-01 01:10:58 +02:00
}
CloseConnection ( ) ;
2010-09-24 02:48:03 +02:00
if ( ! failed & & ret > = 0 & & updatemode = = 1 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
WindowPrompt ( tr ( " Restarting... " ) , tr ( " Successfully Updated thanks to www.techjawa.com " ) , 0 , 0 , 0 , 0 , 150 ) ;
2009-10-01 01:10:58 +02:00
2010-09-19 01:16:05 +02:00
loadStub ( ) ;
2010-09-24 02:48:03 +02:00
Set_Stub_Split ( 0x00010001 , " UNEO " ) ;
2009-11-18 10:01:14 +01:00
Sys_BackToLoader ( ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( updatemode > 0 & & ret > 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
WindowPrompt ( tr ( " Successfully Updated " ) , 0 , tr ( " OK " ) ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT , 50 ) ;
while ( promptWindow . GetEffect ( ) > 0 )
usleep ( 50 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > Remove ( & promptWindow ) ;
mainWindow - > SetState ( STATE_DEFAULT ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
2010-09-24 02:48:03 +02:00
if ( failed ! = 0 ) return failed ;
2009-10-01 01:10:58 +02:00
return 1 ;
}
2009-11-18 10:01:14 +01:00
2009-10-01 01:10:58 +02:00
# endif
2010-09-24 02:48:03 +02:00
int CodeDownload ( const char * id )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
int ret = 0 ;
2010-09-24 02:48:03 +02:00
GuiWindow promptWindow ( 472 , 320 ) ;
promptWindow . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
promptWindow . SetPosition ( 0 , - 10 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
GuiSound btnSoundOver ( button_over_pcm , button_over_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
2010-09-24 02:48:03 +02:00
if ( ! btnClick2 ) btnClick2 = new GuiSound ( button_click2_pcm , button_click2_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
2009-10-01 01:10:58 +02:00
2010-09-26 10:33:43 +02:00
GuiImageData btnOutline ( Resources : : GetFile ( " button_dialogue_box.png " ) , Resources : : GetFileSize ( " button_dialogue_box.png " ) ) ;
GuiImageData dialogBox ( Resources : : GetFile ( " dialogue_box.png " ) , Resources : : GetFileSize ( " dialogue_box.png " ) ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigA ;
2010-09-24 02:48:03 +02:00
trigA . SetSimpleTrigger ( - 1 , WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A , PAD_BUTTON_A ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
GuiImage dialogBoxImg ( & dialogBox ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
dialogBoxImg . SetWidescreen ( Settings . widescreen ) ;
2009-10-01 01:10:58 +02:00
}
char title [ 50 ] ;
2010-09-24 02:48:03 +02:00
sprintf ( title , " %s " , tr ( " Code Download " ) ) ;
2010-09-24 19:58:56 +02:00
GuiText titleTxt ( title , 26 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
titleTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
titleTxt . SetPosition ( 0 , 50 ) ;
2009-10-01 01:10:58 +02:00
char msg [ 50 ] ;
2010-09-24 02:48:03 +02:00
sprintf ( msg , " %s " , tr ( " Initializing Network " ) ) ;
2010-09-24 19:58:56 +02:00
GuiText msgTxt ( msg , 26 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
msgTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
msgTxt . SetPosition ( 0 , 140 ) ;
2009-10-01 01:10:58 +02:00
char msg2 [ 50 ] = " " ;
2010-09-24 19:58:56 +02:00
GuiText msg2Txt ( msg2 , 26 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
msg2Txt . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
msg2Txt . SetPosition ( 0 , 50 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 19:58:56 +02:00
GuiText btn1Txt ( tr ( " Cancel " ) , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
GuiImage btn1Img ( & btnOutline ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
btn1Txt . SetWidescreen ( Settings . widescreen ) ;
btn1Img . SetWidescreen ( Settings . widescreen ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
GuiButton btn1 ( & btn1Img , & btn1Img , 2 , 4 , 0 , - 40 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
btn1 . SetLabel ( & btn1Txt ) ;
btn1 . SetState ( STATE_SELECTED ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
promptWindow . Append ( & dialogBoxImg ) ;
promptWindow . Append ( & titleTxt ) ;
promptWindow . Append ( & msgTxt ) ;
promptWindow . Append ( & msg2Txt ) ;
promptWindow . Append ( & btn1 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN , 50 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > SetState ( STATE_DISABLED ) ;
mainWindow - > Append ( & promptWindow ) ;
mainWindow - > ChangeFocus ( & promptWindow ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
struct stat st ;
2010-09-24 02:48:03 +02:00
if ( stat ( Settings . TxtCheatcodespath , & st ) ! = 0 )
2010-09-19 01:16:05 +02:00
{
2010-09-25 08:54:27 +02:00
if ( ! CreateSubfolder ( Settings . TxtCheatcodespath ) )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
WindowPrompt ( tr ( " Error ! " ) , tr ( " Can't create directory " ) , tr ( " OK " ) ) ;
2009-10-01 01:10:58 +02:00
ret = - 1 ;
goto exit ;
}
}
2010-09-24 02:48:03 +02:00
while ( ! IsNetworkInit ( ) )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
VIDEO_WaitVSync ( ) ;
Initialize_Network ( ) ;
2010-09-24 02:48:03 +02:00
if ( IsNetworkInit ( ) )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
msgTxt . SetText ( GetNetworkIP ( ) ) ;
2010-09-19 01:16:05 +02:00
}
else
{
2010-09-24 02:48:03 +02:00
msgTxt . SetText ( tr ( " Could not initialize network! " ) ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
if ( btn1 . GetState ( ) = = STATE_CLICKED )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
ret = - 1 ;
btn1 . ResetState ( ) ;
goto exit ;
}
}
2010-09-24 02:48:03 +02:00
if ( IsNetworkInit ( ) & & ret > = 0 )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
char txtpath [ 150 ] ;
2010-09-24 02:48:03 +02:00
snprintf ( txtpath , sizeof ( txtpath ) , " %s%s.txt " , Settings . TxtCheatcodespath , id ) ;
2009-10-01 01:10:58 +02:00
char codeurl [ 150 ] ;
2010-09-24 02:48:03 +02:00
snprintf ( codeurl , sizeof ( codeurl ) , " http://geckocodes.org/codes/R/%s.txt " , id ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
struct block file = downloadfile ( codeurl ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
if ( file . size = = 333 | | file . size = = 216 | | file . size = = 284 )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
strcat ( codeurl , tr ( " is not on the server. " ) ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
WindowPrompt ( tr ( " Error " ) , codeurl , tr ( " OK " ) ) ;
2010-09-19 01:16:05 +02:00
ret = - 1 ;
2009-10-01 01:10:58 +02:00
goto exit ;
}
2010-09-24 02:48:03 +02:00
if ( file . data ! = NULL )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
FILE * pfile ;
2010-09-24 02:48:03 +02:00
pfile = fopen ( txtpath , " wb " ) ;
fwrite ( file . data , 1 , file . size , pfile ) ;
fclose ( pfile ) ;
free ( file . data ) ;
2009-10-01 01:10:58 +02:00
ret = 1 ;
2010-09-24 02:48:03 +02:00
strcat (
txtpath ,
tr ( " has been Saved. The text has not been verified. Some of the code may not work right with each other. If you experience trouble, open the text in a real text editor for more information. " ) ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
WindowPrompt ( 0 , txtpath , tr ( " OK " ) ) ;
2010-09-19 01:16:05 +02:00
}
else
{
2010-09-24 02:48:03 +02:00
strcat ( codeurl , tr ( " could not be downloaded. " ) ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
WindowPrompt ( tr ( " Error " ) , codeurl , tr ( " OK " ) ) ;
2010-09-19 01:16:05 +02:00
ret = - 1 ;
2009-10-01 01:10:58 +02:00
}
CloseConnection ( ) ;
}
2010-09-24 02:48:03 +02:00
exit : promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT , 50 ) ;
while ( promptWindow . GetEffect ( ) > 0 )
usleep ( 50 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > Remove ( & promptWindow ) ;
mainWindow - > SetState ( STATE_DEFAULT ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
return ret ;
}
2010-09-19 01:16:05 +02:00
char * GetMissingFiles ( )
{
2010-09-24 02:48:03 +02:00
return ( char * ) missingFiles ;
2009-10-01 01:10:58 +02:00
}
/****************************************************************************
* HBCWindowPrompt
*
* Displays a prompt window to user , with information , an error message , or
* presenting a user with a choice of up to 2 Buttons .
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* <name>
< coder >
2010-09-24 02:48:03 +02:00
< version >
< release_date >
< short_description >
< long_description >
SD : / APPS / FTPII / ICON . PNG */
int HBCWindowPrompt ( const char * name , const char * coder , const char * version , const char * release_date ,
const char * long_description , const char * iconPath , u64 filesize )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
int choice = - 1 ;
2010-09-24 02:48:03 +02:00
GuiWindow promptWindow ( 472 , 320 ) ;
promptWindow . SetAlignment ( ALIGN_CENTRE , ALIGN_MIDDLE ) ;
promptWindow . SetPosition ( 0 , 6 ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigA ;
2010-09-24 02:48:03 +02:00
trigA . SetSimpleTrigger ( - 1 , WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A , PAD_BUTTON_A ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigB ;
2010-09-24 02:48:03 +02:00
trigB . SetButtonOnlyTrigger ( - 1 , WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B , PAD_BUTTON_B ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigU ;
2010-09-24 02:48:03 +02:00
trigU . SetButtonOnlyTrigger ( - 1 , WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP , PAD_BUTTON_UP ) ;
2009-10-01 01:10:58 +02:00
GuiTrigger trigD ;
2010-09-24 02:48:03 +02:00
trigD . SetButtonOnlyTrigger ( - 1 , WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN , PAD_BUTTON_DOWN ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
GuiSound btnSoundOver ( button_over_pcm , button_over_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
2010-09-24 02:48:03 +02:00
if ( ! btnClick2 ) btnClick2 = new GuiSound ( button_click2_pcm , button_click2_pcm_size , Settings . sfxvolume ) ;
2010-09-19 01:16:05 +02:00
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
2010-09-28 20:58:56 +02:00
2010-09-26 10:33:43 +02:00
GuiImageData btnOutline ( Resources : : GetFile ( " button_dialogue_box.png " ) , Resources : : GetFileSize ( " button_dialogue_box.png " ) ) ;
GuiImageData dialogBox ( Resources : : GetFile ( " dialogue_box.png " ) , Resources : : GetFileSize ( " dialogue_box.png " ) ) ;
GuiImageData whiteBox ( Resources : : GetFile ( " bg_options.png " ) , Resources : : GetFileSize ( " bg_options.png " ) ) ;
GuiImageData scrollbar ( Resources : : GetFile ( " scrollbar.png " ) , Resources : : GetFileSize ( " scrollbar.png " ) ) ;
2010-09-24 02:48:03 +02:00
GuiImage scrollbarImg ( & scrollbar ) ;
scrollbarImg . SetAlignment ( ALIGN_RIGHT , ALIGN_TOP ) ;
scrollbarImg . SetPosition ( - 40 , 114 ) ;
scrollbarImg . SetSkew ( 0 , 0 , 0 , 0 , 0 , - 120 , 0 , - 120 ) ;
2010-09-26 10:33:43 +02:00
GuiImageData arrowDown ( Resources : : GetFile ( " scrollbar_arrowdown.png " ) , Resources : : GetFileSize ( " scrollbar_arrowdown.png " ) ) ;
2010-09-24 02:48:03 +02:00
GuiImage arrowDownImg ( & arrowDown ) ;
arrowDownImg . SetScale ( .8 ) ;
2010-09-26 10:33:43 +02:00
GuiImageData arrowUp ( Resources : : GetFile ( " scrollbar_arrowup.png " ) , Resources : : GetFileSize ( " scrollbar_arrowup.png " ) ) ;
2010-09-24 02:48:03 +02:00
GuiImage arrowUpImg ( & arrowUp ) ;
arrowUpImg . SetScale ( .8 ) ;
GuiButton arrowUpBtn ( arrowUpImg . GetWidth ( ) , arrowUpImg . GetHeight ( ) ) ;
arrowUpBtn . SetImage ( & arrowUpImg ) ;
arrowUpBtn . SetAlignment ( ALIGN_RIGHT , ALIGN_TOP ) ;
arrowUpBtn . SetPosition ( - 25 , 91 ) ;
arrowUpBtn . SetTrigger ( & trigA ) ;
arrowUpBtn . SetTrigger ( & trigU ) ;
arrowUpBtn . SetEffectOnOver ( EFFECT_SCALE , 50 , 130 ) ;
arrowUpBtn . SetSoundClick ( btnClick2 ) ;
GuiButton arrowDownBtn ( arrowDownImg . GetWidth ( ) , arrowDownImg . GetHeight ( ) ) ;
arrowDownBtn . SetImage ( & arrowDownImg ) ;
arrowDownBtn . SetAlignment ( ALIGN_RIGHT , ALIGN_BOTTOM ) ;
arrowDownBtn . SetPosition ( - 25 , - 27 ) ;
arrowDownBtn . SetTrigger ( & trigA ) ;
arrowDownBtn . SetTrigger ( & trigD ) ;
arrowDownBtn . SetEffectOnOver ( EFFECT_SCALE , 50 , 130 ) ;
arrowDownBtn . SetSoundClick ( btnClick2 ) ;
2010-09-19 01:16:05 +02:00
GuiImageData * iconData = NULL ;
GuiImage * iconImg = NULL ;
2010-09-28 20:58:56 +02:00
2010-09-26 10:33:43 +02:00
char imgPath [ 150 ] ;
2010-09-24 02:48:03 +02:00
snprintf ( imgPath , sizeof ( imgPath ) , " %s " , iconPath ) ;
2010-09-19 01:16:05 +02:00
2010-09-25 08:54:27 +02:00
bool iconExist = CheckFile ( imgPath ) ;
2010-09-24 02:48:03 +02:00
if ( iconExist )
2010-09-19 01:16:05 +02:00
{
2010-09-26 10:33:43 +02:00
iconData = new GuiImageData ( imgPath ) ;
if ( ! iconData - > GetImage ( ) )
{
delete iconData ;
iconData = new GuiImageData ( Resources : : GetFile ( " dialogue_box.png " ) , Resources : : GetFileSize ( " dialogue_box.png " ) ) ;
}
iconImg = new GuiImage ( iconData ) ;
2010-09-24 02:48:03 +02:00
iconImg - > SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
iconImg - > SetPosition ( 45 , 10 ) ;
2010-09-19 01:16:05 +02:00
}
2010-09-24 02:48:03 +02:00
GuiImage dialogBoxImg ( & dialogBox ) ;
dialogBoxImg . SetSkew ( 0 , - 80 , 0 , - 80 , 0 , 50 , 0 , 50 ) ;
2010-09-19 01:16:05 +02:00
2010-09-24 02:48:03 +02:00
GuiImage whiteBoxImg ( & whiteBox ) ;
whiteBoxImg . SetPosition ( 0 , 110 ) ;
whiteBoxImg . SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
whiteBoxImg . SetSkew ( 0 , 0 , 0 , 0 , 0 , - 120 , 0 , - 120 ) ;
2009-10-01 01:10:58 +02:00
/*if (Settings.wsprompt == yes){
2010-09-24 02:48:03 +02:00
dialogBoxImg . SetWidescreen ( Settings . widescreen ) ;
} */
2009-10-01 01:10:58 +02:00
char tmp [ 510 ] ;
2010-09-24 19:58:56 +02:00
GuiText nameTxt ( name , 30 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
nameTxt . SetAlignment ( ALIGN_CENTRE , ALIGN_TOP ) ;
nameTxt . SetPosition ( 0 , - 15 ) ;
nameTxt . SetMaxWidth ( 430 , SCROLL_HORIZONTAL ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
if ( strcmp ( coder , " " ) ) snprintf ( tmp , sizeof ( tmp ) , tr ( " Coded by: %s " ) , coder ) ;
2010-09-24 19:58:56 +02:00
GuiText coderTxt ( tmp , 16 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
coderTxt . SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
coderTxt . SetPosition ( 180 , 30 ) ;
coderTxt . SetMaxWidth ( 280 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
if ( strcmp ( version , " " ) ) snprintf ( tmp , sizeof ( tmp ) , tr ( " Version: %s " ) , version ) ;
2010-09-24 19:58:56 +02:00
GuiText versionTxt ( tmp , 16 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
versionTxt . SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
versionTxt . SetPosition ( 40 , 65 ) ;
versionTxt . SetMaxWidth ( 430 ) ;
2009-10-01 01:10:58 +02:00
//if (release_date)
//snprintf(tmp, sizeof(tmp), tr("Released: %s"),release_date);
2010-09-24 19:58:56 +02:00
GuiText release_dateTxt ( release_date , 16 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
release_dateTxt . SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
release_dateTxt . SetPosition ( 40 , 85 ) ;
release_dateTxt . SetMaxWidth ( 430 ) ;
2009-10-01 01:10:58 +02:00
int pagesize = 6 ;
2010-09-24 19:58:56 +02:00
Text long_descriptionTxt ( long_description , 20 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
long_descriptionTxt . SetAlignment ( ALIGN_LEFT , ALIGN_TOP ) ;
long_descriptionTxt . SetPosition ( 46 , 117 ) ;
long_descriptionTxt . SetMaxWidth ( 360 ) ;
long_descriptionTxt . SetLinesToDraw ( pagesize ) ;
2010-09-17 18:15:18 +02:00
long_descriptionTxt . Refresh ( ) ;
2009-10-01 01:10:58 +02:00
//convert filesize from u64 to char and put unit of measurement after it
char temp2 [ 7 ] ;
char filesizeCH [ 15 ] ;
f32 sizeAdjusted ;
2010-09-24 02:48:03 +02:00
if ( filesize < = 1024.0 )
2010-09-19 01:16:05 +02:00
{
2009-10-01 01:10:58 +02:00
sizeAdjusted = filesize ;
2010-09-24 02:48:03 +02:00
snprintf ( temp2 , sizeof ( temp2 ) , " %.2f " , sizeAdjusted ) ;
snprintf ( filesizeCH , sizeof ( filesizeCH ) , " %s B " , temp2 ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
if ( filesize > 1024.0 )
2010-09-19 01:16:05 +02:00
{
sizeAdjusted = filesize / 1024.0 ;
2010-09-24 02:48:03 +02:00
snprintf ( temp2 , sizeof ( temp2 ) , " %.2f " , sizeAdjusted ) ;
snprintf ( filesizeCH , sizeof ( filesizeCH ) , " %s KB " , temp2 ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
if ( filesize > 1048576.0 )
2010-09-19 01:16:05 +02:00
{
sizeAdjusted = filesize / 1048576.0 ;
2010-09-24 02:48:03 +02:00
snprintf ( temp2 , sizeof ( temp2 ) , " %.2f " , sizeAdjusted ) ;
snprintf ( filesizeCH , sizeof ( filesizeCH ) , " %s MB " , temp2 ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 19:58:56 +02:00
GuiText filesizeTxt ( filesizeCH , 16 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
filesizeTxt . SetAlignment ( ALIGN_RIGHT , ALIGN_TOP ) ;
filesizeTxt . SetPosition ( - 40 , 12 ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 19:58:56 +02:00
GuiText btn1Txt ( tr ( " Load " ) , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
GuiImage btn1Img ( & btnOutline ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
btn1Txt . SetWidescreen ( Settings . widescreen ) ;
btn1Img . SetWidescreen ( Settings . widescreen ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
GuiButton btn1 ( & btn1Img , & btn1Img , 0 , 3 , 0 , 0 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
btn1 . SetLabel ( & btn1Txt ) ;
btn1 . SetState ( STATE_SELECTED ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 19:58:56 +02:00
GuiText btn2Txt ( tr ( " Back " ) , 22 , Theme . prompttext ) ;
2010-09-24 02:48:03 +02:00
GuiImage btn2Img ( & btnOutline ) ;
if ( Settings . wsprompt = = yes )
2010-09-19 01:16:05 +02:00
{
2010-09-24 02:48:03 +02:00
btn2Txt . SetWidescreen ( Settings . widescreen ) ;
btn2Img . SetWidescreen ( Settings . widescreen ) ;
2009-10-01 01:10:58 +02:00
}
2010-09-24 02:48:03 +02:00
GuiButton btn2 ( & btn2Img , & btn2Img , 0 , 3 , 0 , 0 , & trigA , & btnSoundOver , btnClick2 , 1 ) ;
btn2 . SetLabel ( & btn2Txt ) ;
btn2 . SetTrigger ( & trigB ) ;
2009-10-01 01:10:58 +02:00
2010-09-24 02:48:03 +02:00
btn1 . SetAlignment ( ALIGN_LEFT , ALIGN_BOTTOM ) ;
btn1 . SetPosition ( 40 , 2 ) ;
btn2 . SetAlignment ( ALIGN_RIGHT , ALIGN_BOTTOM ) ;
btn2 . SetPosition ( - 40 , 2 ) ;
2009-10-01 01:10:58 +02:00
2010-01-19 11:48:50 +01:00
GuiTrigger trigZ ;
2010-09-24 02:48:03 +02:00
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 ) ;
if ( strcmp ( long_description , " " ) ) promptWindow . Append ( & arrowDownBtn ) ;
if ( strcmp ( long_description , " " ) ) promptWindow . Append ( & arrowUpBtn ) ;
if ( strcmp ( name , " " ) ) promptWindow . Append ( & nameTxt ) ;
if ( strcmp ( version , " " ) ) promptWindow . Append ( & versionTxt ) ;
if ( strcmp ( coder , " " ) ) promptWindow . Append ( & coderTxt ) ;
if ( strcmp ( release_date , " " ) ) promptWindow . Append ( & release_dateTxt ) ;
if ( strcmp ( long_description , " " ) ) promptWindow . Append ( & long_descriptionTxt ) ;
promptWindow . Append ( & filesizeTxt ) ;
if ( iconExist ) promptWindow . Append ( iconImg ) ;
promptWindow . Append ( & btn1 ) ;
promptWindow . Append ( & btn2 ) ;
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN , 50 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > SetState ( STATE_DISABLED ) ;
mainWindow - > Append ( & promptWindow ) ;
mainWindow - > ChangeFocus ( & promptWindow ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
2010-09-24 02:48:03 +02:00
while ( choice = = - 1 )
2010-09-17 18:15:18 +02:00
{
2009-10-01 01:10:58 +02:00
VIDEO_WaitVSync ( ) ;
2010-09-17 18:15:18 +02:00
2010-09-24 02:48:03 +02:00
if ( shutdown = = 1 )
2010-09-17 18:15:18 +02:00
{
2010-09-24 02:48:03 +02:00
wiilight ( 0 ) ;
2010-01-19 11:48:50 +01:00
Sys_Shutdown ( ) ;
}
2010-09-24 02:48:03 +02:00
else if ( reset = = 1 )
2010-09-17 18:15:18 +02:00
{
2010-09-24 02:48:03 +02:00
wiilight ( 0 ) ;
2010-01-19 11:48:50 +01:00
Sys_Reboot ( ) ;
2010-09-17 18:15:18 +02:00
}
2010-09-24 02:48:03 +02:00
if ( btn1 . GetState ( ) = = STATE_CLICKED )
2009-10-01 01:10:58 +02:00
choice = 1 ;
2010-09-24 02:48:03 +02:00
else if ( btn2 . GetState ( ) = = STATE_CLICKED )
2009-10-01 01:10:58 +02:00
choice = 0 ;
2010-09-17 18:15:18 +02:00
2010-09-24 02:48:03 +02:00
else if ( screenShotBtn . GetState ( ) = = STATE_CLICKED )
2010-09-17 18:15:18 +02:00
{
2010-09-24 02:48:03 +02:00
gprintf ( " \n \t screenShotBtn clicked " ) ;
2010-09-17 18:15:18 +02:00
screenShotBtn . ResetState ( ) ;
ScreenShot ( ) ;
2010-09-24 02:48:03 +02:00
gprintf ( " ...It's easy, mmmmmmKay " ) ;
2010-09-17 18:15:18 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( arrowUpBtn . GetState ( ) = = STATE_CLICKED | | arrowUpBtn . GetState ( ) = = STATE_HELD )
2010-09-17 18:15:18 +02:00
{
long_descriptionTxt . PreviousLine ( ) ;
2010-09-24 02:48:03 +02:00
usleep ( 6000 ) ;
if ( ! ( ( ButtonsHold ( ) & WPAD_BUTTON_UP ) | | ( ButtonsHold ( ) & PAD_BUTTON_UP ) ) ) arrowUpBtn . ResetState ( ) ;
2010-09-17 18:15:18 +02:00
}
2010-09-24 02:48:03 +02:00
else if ( arrowDownBtn . GetState ( ) = = STATE_CLICKED | | arrowDownBtn . GetState ( ) = = STATE_HELD )
2010-09-17 18:15:18 +02:00
{
long_descriptionTxt . NextLine ( ) ;
2009-10-19 22:34:54 +02:00
2010-09-24 02:48:03 +02:00
usleep ( 60000 ) ;
if ( ! ( ( ButtonsHold ( ) & WPAD_BUTTON_DOWN ) | | ( ButtonsHold ( ) & PAD_BUTTON_DOWN ) ) ) arrowDownBtn . ResetState ( ) ;
2009-10-01 01:10:58 +02:00
}
}
2010-09-24 02:48:03 +02:00
promptWindow . SetEffect ( EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT , 50 ) ;
while ( promptWindow . GetEffect ( ) > 0 )
usleep ( 50 ) ;
2009-10-01 01:10:58 +02:00
HaltGui ( ) ;
2010-09-24 02:48:03 +02:00
mainWindow - > Remove ( & promptWindow ) ;
mainWindow - > SetState ( STATE_DEFAULT ) ;
2009-10-01 01:10:58 +02:00
ResumeGui ( ) ;
return choice ;
}