2012-01-21 21:57:41 +01:00
# include "menu.hpp"
2012-08-05 15:48:15 +02:00
# include "types.h"
2012-01-21 21:57:41 +01:00
# include "lockMutex.hpp"
2012-08-05 15:48:15 +02:00
# include "channel/nand.hpp"
# include "gc/gc.hpp"
# include "fileOps/fileOps.h"
# include "loader/wbfs.h"
# include "loader/wdvd.h"
2012-07-06 02:36:45 +02:00
# include "loader/gc_disc_dump.hpp"
2012-02-27 17:05:10 +01:00
# include "music/SoundHandler.hpp"
2012-01-21 21:57:41 +01:00
void CMenu : : _hideWBFS ( bool instant )
{
m_btnMgr . hide ( m_wbfsLblTitle , instant ) ;
m_btnMgr . hide ( m_wbfsPBar , instant ) ;
m_btnMgr . hide ( m_wbfsBtnBack , instant ) ;
m_btnMgr . hide ( m_wbfsBtnGo , instant ) ;
m_btnMgr . hide ( m_wbfsLblDialog ) ;
m_btnMgr . hide ( m_wbfsLblMessage ) ;
2012-07-05 15:15:23 +02:00
for ( u8 i = 0 ; i < ARRAY_SIZE ( m_wbfsLblUser ) ; + + i )
2012-09-13 16:54:17 +02:00
if ( m_wbfsLblUser [ i ] ! = - 1 )
2012-01-21 21:57:41 +01:00
m_btnMgr . hide ( m_wbfsLblUser [ i ] , instant ) ;
}
void CMenu : : _showWBFS ( CMenu : : WBFS_OP op )
{
_setBg ( m_wbfsBg , m_wbfsBg ) ;
switch ( op )
{
case CMenu : : WO_ADD_GAME :
m_btnMgr . setText ( m_wbfsLblTitle , _t ( " wbfsop1 " , L " Install Game " ) ) ;
break ;
case CMenu : : WO_REMOVE_GAME :
m_btnMgr . setText ( m_wbfsLblTitle , _t ( " wbfsop2 " , L " Delete Game " ) ) ;
break ;
case CMenu : : WO_FORMAT :
// m_btnMgr.setText(m_wbfsLblTitle, _t("wbfsop3", L"Format"));
break ;
2012-02-28 19:44:41 +01:00
case CMenu : : WO_COPY_GAME :
m_btnMgr . setText ( m_wbfsLblTitle , _t ( " wbfsop11 " , L " Copy Game " ) ) ;
break ;
2012-01-21 21:57:41 +01:00
} ;
m_btnMgr . show ( m_wbfsLblTitle ) ;
m_btnMgr . show ( m_wbfsBtnBack ) ;
m_btnMgr . show ( m_wbfsBtnGo ) ;
m_btnMgr . show ( m_wbfsLblDialog ) ;
2012-07-05 15:15:23 +02:00
for ( u8 i = 0 ; i < ARRAY_SIZE ( m_wbfsLblUser ) ; + + i )
2012-09-13 16:54:17 +02:00
if ( m_wbfsLblUser [ i ] ! = - 1 )
2012-01-21 21:57:41 +01:00
m_btnMgr . show ( m_wbfsLblUser [ i ] ) ;
}
static void slotLight ( bool state )
{
if ( state )
2012-09-13 16:54:17 +02:00
* ( u32 * ) 0xCD0000C0 | = 0x20 ;
2012-01-21 21:57:41 +01:00
else
2012-09-13 16:54:17 +02:00
* ( u32 * ) 0xCD0000C0 & = ~ 0x20 ;
2012-01-21 21:57:41 +01:00
}
void CMenu : : _addDiscProgress ( int status , int total , void * user_data )
{
CMenu & m = * ( CMenu * ) user_data ;
2012-03-07 03:05:57 +01:00
m . m_progress = total = = 0 ? 0.f : ( float ) status / ( float ) total ;
2012-01-21 21:57:41 +01:00
// Don't synchronize too often
2012-03-07 03:05:57 +01:00
if ( m . m_progress - m . m_thrdProgress > = 0.01f )
2012-01-21 21:57:41 +01:00
{
LWP_MutexLock ( m . m_mutex ) ;
2012-03-07 03:05:57 +01:00
m . _setThrdMsg ( L " " , m . m_progress ) ;
2012-01-21 21:57:41 +01:00
LWP_MutexUnlock ( m . m_mutex ) ;
}
}
2012-11-01 17:39:42 +01:00
static inline bool _searchGamesByID ( const char * gameId )
2012-06-16 19:03:23 +02:00
{
2012-11-01 17:39:42 +01:00
for ( vector < dir_discHdr > : : const_iterator itr = m_gameList . begin ( ) ; itr ! = m_gameList . end ( ) ; + + itr )
{
if ( strncmp ( itr - > id , gameId , 6 ) = = 0 )
return true ;
}
return false ;
2012-06-16 19:03:23 +02:00
}
2012-02-29 01:19:50 +01:00
void CMenu : : _Messenger ( int message , int info , char * cinfo , void * user_data )
{
CMenu & m = * ( CMenu * ) user_data ;
LWP_MutexLock ( m . m_mutex ) ;
if ( message = = 1 )
2012-03-07 03:05:57 +01:00
m . _setThrdMsg ( wfmt ( m . _fmt ( " wbfsop23 " , L " Calculating space needed for %s... \n Please insert disc %d to continue " ) , cinfo , info ) , m . m_progress ) ;
2012-02-29 01:19:50 +01:00
if ( message = = 2 )
2012-03-07 03:05:57 +01:00
m . _setThrdMsg ( wfmt ( m . _fmt ( " wbfsop15 " , L " Calculating space needed for %s " ) , cinfo ) , m . m_progress ) ;
2012-02-29 01:19:50 +01:00
if ( message = = 3 )
2012-03-07 03:05:57 +01:00
m . _setThrdMsg ( wfmt ( m . _fmt ( " wbfsop16 " , L " Installing %s " ) , cinfo ) , m . m_progress ) ;
2012-02-29 01:19:50 +01:00
if ( message = = 4 )
2012-03-07 03:05:57 +01:00
m . _setThrdMsg ( wfmt ( m . _fmt ( " wbfsop17 " , L " Installing %s disc %d/2 " ) , cinfo , info ) , m . m_progress ) ;
2012-02-29 01:19:50 +01:00
if ( message = = 5 )
2012-03-07 03:05:57 +01:00
m . _setThrdMsg ( m . _t ( " wbfsop18 " , L " Don't try to trick me with a Wii disc!! " ) , m . m_progress ) ;
2012-02-29 01:19:50 +01:00
if ( message = = 6 )
2012-03-07 03:05:57 +01:00
m . _setThrdMsg ( m . _t ( " wbfsop19 " , L " This is not a GC disc!! " ) , m . m_progress ) ;
2012-02-29 01:19:50 +01:00
if ( message = = 7 )
2012-03-07 03:05:57 +01:00
m . _setThrdMsg ( wfmt ( m . _fmt ( " wbfsop20 " , L " You inserted disc %d again!! " ) , info ) , m . m_progress ) ;
2012-02-29 01:19:50 +01:00
if ( message = = 8 )
2012-03-07 03:05:57 +01:00
m . _setThrdMsg ( m . _t ( " wbfsop21 " , L " This is a disc of another game!! " ) , m . m_progress ) ;
2012-02-29 01:19:50 +01:00
if ( message = = 9 )
2012-03-07 03:05:57 +01:00
m . _setThrdMsg ( wfmt ( m . _fmt ( " wbfsop22 " , L " Installing %s... \n Please insert disc 2 to continue " ) , cinfo ) , m . m_progress ) ;
2012-03-09 03:47:41 +01:00
if ( message = = 10 )
m . _setThrdMsg ( m . _t ( " wbfsop25 " , L " Disc read error!! Please clean the disc " ) , m . m_progress ) ;
if ( message = = 11 )
m . _setThrdMsg ( m . _t ( " wbfsop26 " , L " Disc ejected!! Please insert disc again " ) , m . m_progress ) ;
2012-02-29 01:19:50 +01:00
LWP_MutexUnlock ( m . m_mutex ) ;
}
2012-01-21 21:57:41 +01:00
int CMenu : : _gameInstaller ( void * obj )
{
CMenu & m = * ( CMenu * ) obj ;
int ret ;
2012-09-22 15:47:52 +02:00
DeviceHandle . OpenWBFS ( currentPartition ) ;
2012-09-15 21:59:27 +02:00
if ( ! WBFS_Mounted ( ) )
2012-01-21 21:57:41 +01:00
{
m . m_thrdWorking = false ;
return - 1 ;
}
u64 comp_size = 0 , real_size = 0 ;
f32 free , used ;
WBFS_DiskSpace ( & used , & free ) ;
WBFS_DVD_Size ( & comp_size , & real_size ) ;
2012-03-09 03:47:41 +01:00
if ( ( f32 ) comp_size + ( f32 ) 128 * 1024 > = free * GB_SIZE )
2012-01-21 21:57:41 +01:00
{
LWP_MutexLock ( m . m_mutex ) ;
2012-02-28 19:44:41 +01:00
m . _setThrdMsg ( wfmt ( m . _fmt ( " wbfsop10 " , L " Not enough space: %lld blocks needed, %i available " ) , comp_size , free ) , 0.f ) ;
2012-01-21 21:57:41 +01:00
LWP_MutexUnlock ( m . m_mutex ) ;
ret = - 1 ;
}
else
{
LWP_MutexLock ( m . m_mutex ) ;
m . _setThrdMsg ( L " " , 0 ) ;
LWP_MutexUnlock ( m . m_mutex ) ;
ret = WBFS_AddGame ( CMenu : : _addDiscProgress , obj ) ;
LWP_MutexLock ( m . m_mutex ) ;
if ( ret = = 0 )
m . _setThrdMsg ( m . _t ( " wbfsop8 " , L " Game installed " ) , 1.f ) ;
else
m . _setThrdMsg ( m . _t ( " wbfsop9 " , L " An error has occurred " ) , 1.f ) ;
LWP_MutexUnlock ( m . m_mutex ) ;
slotLight ( true ) ;
}
2012-09-22 15:47:52 +02:00
WBFS_Close ( ) ;
2012-01-21 21:57:41 +01:00
m . m_thrdWorking = false ;
return ret ;
}
2012-02-17 03:35:42 +01:00
int CMenu : : _GCgameInstaller ( void * obj )
{
CMenu & m = * ( CMenu * ) obj ;
2012-02-21 21:33:38 +01:00
GCDump m_gcdump ;
2012-04-04 14:22:01 +02:00
2012-11-04 20:22:02 +01:00
bool skip = m . m_cfg . getBool ( GC_DOMAIN , " skip_on_error " , false ) ;
bool comp = m . m_cfg . getBool ( GC_DOMAIN , " compressed_dump " , false ) ;
bool wexf = m . m_cfg . getBool ( GC_DOMAIN , " write_ex_files " , true ) ;
bool alig = m . m_cfg . getBool ( GC_DOMAIN , " force_32k_align_files " , false ) ;
u32 nretry = m . m_cfg . getUInt ( GC_DOMAIN , " num_retries " , 5 ) ;
2012-02-29 15:07:18 +01:00
u32 rsize = 1048576 ; //1MB
2012-04-04 14:22:01 +02:00
2012-03-07 03:05:57 +01:00
if ( skip )
rsize = 8192 ; // Use small chunks when skip on error is enabled
2012-02-28 19:44:41 +01:00
2012-03-09 03:47:41 +01:00
m_gcdump . Init ( skip , comp , wexf , alig , nretry , rsize , DeviceName [ currentPartition ] , m . m_DMLgameDir . c_str ( ) , CMenu : : _addDiscProgress , CMenu : : _Messenger , obj ) ;
2012-02-20 09:26:50 +01:00
2012-03-07 03:05:57 +01:00
int ret ;
m . m_progress = 0.f ;
2012-02-17 03:35:42 +01:00
2012-11-01 17:39:42 +01:00
if ( ! DeviceHandle . IsInserted ( currentPartition ) )
2012-02-17 03:35:42 +01:00
{
m . m_thrdWorking = false ;
return - 1 ;
}
2012-02-29 15:07:18 +01:00
char partition [ 6 ] ;
2012-11-01 17:39:42 +01:00
strncpy ( partition , fmt ( " %s:/ " , DeviceName [ currentPartition ] ) , sizeof ( partition ) ) ;
2012-03-02 19:29:55 +01:00
2012-02-20 09:26:50 +01:00
u32 needed = 0 ;
2012-02-29 19:11:35 +01:00
2012-03-09 03:47:41 +01:00
ret = m_gcdump . CheckSpace ( & needed , comp ) ;
2012-02-29 01:19:50 +01:00
if ( ret ! = 0 )
{
m . _setThrdMsg ( m . _t ( " wbfsop9 " , L " An error has occurred " ) , 1.f ) ;
m . m_thrdWorking = false ;
return ret ;
}
2012-04-04 14:22:01 +02:00
2012-03-09 03:47:41 +01:00
if ( m_gcdump . GetFreeSpace ( partition , BL ) < = needed )
2012-02-17 03:35:42 +01:00
{
2012-03-09 03:47:41 +01:00
gprintf ( " Free space available: %d Mb (%d blocks) \n " , m_gcdump . GetFreeSpace ( partition , MB ) , m_gcdump . GetFreeSpace ( partition , BL ) ) ;
2012-02-17 03:35:42 +01:00
LWP_MutexLock ( m . m_mutex ) ;
2012-03-09 03:47:41 +01:00
m . _setThrdMsg ( wfmt ( m . _fmt ( " wbfsop24 " , L " Not enough space: %d blocks needed, %d available " ) , needed , m_gcdump . GetFreeSpace ( partition , BL ) ) , 0.f ) ;
2012-02-17 03:35:42 +01:00
LWP_MutexUnlock ( m . m_mutex ) ;
ret = - 1 ;
}
else
{
2012-03-09 03:47:41 +01:00
gprintf ( " Free space available: %d Mb (%d blocks) \n " , m_gcdump . GetFreeSpace ( partition , MB ) , m_gcdump . GetFreeSpace ( partition , BL ) ) ;
2012-02-17 03:35:42 +01:00
LWP_MutexLock ( m . m_mutex ) ;
m . _setThrdMsg ( L " " , 0 ) ;
LWP_MutexUnlock ( m . m_mutex ) ;
2012-04-04 14:22:01 +02:00
2012-03-09 03:47:41 +01:00
ret = m_gcdump . DumpGame ( ) ;
2012-02-17 03:35:42 +01:00
LWP_MutexLock ( m . m_mutex ) ;
2012-02-20 09:26:50 +01:00
if ( ret = = 0 )
2012-02-17 03:35:42 +01:00
m . _setThrdMsg ( m . _t ( " wbfsop8 " , L " Game installed " ) , 1.f ) ;
2012-02-20 09:26:50 +01:00
else if ( ret > = 0x30200 )
2012-02-29 01:19:50 +01:00
m . _setThrdMsg ( wfmt ( m . _fmt ( " wbfsop12 " , L " DVDError(%d) " ) , ret ) , 1.f ) ;
2012-02-20 09:26:50 +01:00
else if ( ret > 0 )
2012-02-29 01:19:50 +01:00
m . _setThrdMsg ( wfmt ( m . _fmt ( " wbfsop13 " , L " Game installed, but disc contains errors (%d) " ) , ret ) , 1.f ) ;
2012-02-17 03:35:42 +01:00
else
m . _setThrdMsg ( m . _t ( " wbfsop9 " , L " An error has occurred " ) , 1.f ) ;
LWP_MutexUnlock ( m . m_mutex ) ;
slotLight ( true ) ;
}
m . m_thrdWorking = false ;
return ret ;
}
2012-02-27 17:05:10 +01:00
int CMenu : : _GCcopyGame ( void * obj )
{
CMenu & m = * ( CMenu * ) obj ;
2012-08-26 17:20:51 +02:00
2012-11-11 19:28:03 +01:00
string GC_Path ( CoverFlow . getHdr ( ) - > path ) ;
2012-08-26 17:20:51 +02:00
if ( strcasestr ( GC_Path . c_str ( ) , " boot.bin " ) ! = NULL )
GC_Path . erase ( GC_Path . end ( ) - 13 , GC_Path . end ( ) ) ;
else
GC_Path . erase ( GC_Path . end ( ) - 9 , GC_Path . end ( ) ) ;
2012-11-01 17:39:42 +01:00
char source [ 300 ] ;
2012-08-26 17:20:51 +02:00
strncpy ( source , GC_Path . c_str ( ) , sizeof ( source ) ) ;
2012-11-01 17:39:42 +01:00
source [ 299 ] = ' \0 ' ;
char folder [ 50 ] ;
strncpy ( folder , fmt ( DML_DIR , DeviceName [ SD ] ) , sizeof ( folder ) ) ;
folder [ 49 ] = ' \0 ' ;
char target [ 300 ] ;
strncpy ( target , fmt ( " %s/%s " , folder , strrchr ( source , ' / ' ) + 1 ) , sizeof ( target ) ) ;
target [ 299 ] = ' \0 ' ;
2012-04-03 17:49:52 +02:00
LWP_MutexLock ( m . m_mutex ) ;
m . _setThrdMsg ( L " " , 0 ) ;
2012-08-26 17:20:51 +02:00
gprintf ( " Copying from: \n %s \n to: \n %s \n " , source , target ) ;
2012-04-03 17:49:52 +02:00
LWP_MutexUnlock ( m . m_mutex ) ;
if ( ! fsop_DirExist ( folder ) )
2012-06-07 20:18:21 +02:00
fsop_MakeFolder ( folder ) ;
2012-04-03 17:49:52 +02:00
fsop_CopyFolder ( source , target , CMenu : : _addDiscProgress , obj ) ;
LWP_MutexLock ( m . m_mutex ) ;
m . _setThrdMsg ( m . _t ( " wbfsop14 " , L " Game copied, press Back to boot the game. " ) , 1.f ) ;
gprintf ( " Game copied. \n " ) ;
LWP_MutexUnlock ( m . m_mutex ) ;
slotLight ( true ) ;
2012-02-27 17:05:10 +01:00
m . m_thrdWorking = false ;
2012-04-03 17:49:52 +02:00
return 0 ;
2012-02-27 17:05:10 +01:00
}
2012-01-21 21:57:41 +01:00
bool CMenu : : _wbfsOp ( CMenu : : WBFS_OP op )
{
lwp_t thread = 0 ;
2012-11-01 17:39:42 +01:00
char GameID [ 7 ] ;
GameID [ 6 ] = ' \0 ' ;
2012-01-21 21:57:41 +01:00
static discHdr header ATTRIBUTE_ALIGN ( 32 ) ;
2012-02-17 03:35:42 +01:00
static gc_discHdr gcheader ATTRIBUTE_ALIGN ( 32 ) ;
2012-01-21 21:57:41 +01:00
bool done = false ;
2012-02-17 03:35:42 +01:00
bool upd_usb = false ;
bool upd_dml = false ;
2012-05-24 20:48:26 +02:00
bool upd_emu = false ;
2012-01-21 21:57:41 +01:00
bool out = false ;
2012-11-11 19:28:03 +01:00
string cfPos = CoverFlow . getNextId ( ) ;
2012-01-21 21:57:41 +01:00
SetupInput ( ) ;
_showWBFS ( op ) ;
switch ( op )
{
case CMenu : : WO_ADD_GAME :
2012-02-28 19:44:41 +01:00
m_btnMgr . setText ( m_wbfsLblDialog , _t ( " wbfsadddlg " , L " Please insert the disc you want to copy, then click on Go. " ) ) ;
2012-01-21 21:57:41 +01:00
break ;
case CMenu : : WO_REMOVE_GAME :
2012-11-11 19:28:03 +01:00
m_btnMgr . setText ( m_wbfsLblDialog , wfmt ( _fmt ( " wbfsremdlg " , L " To permanently remove the game: %s, click on Go. " ) , ( u8 * ) CoverFlow . getTitle ( ) . toUTF8 ( ) . c_str ( ) ) ) ;
2012-01-21 21:57:41 +01:00
break ;
case CMenu : : WO_FORMAT :
break ;
2012-02-28 19:44:41 +01:00
case CMenu : : WO_COPY_GAME :
m_btnMgr . setText ( m_wbfsLblDialog , _t ( " wbfscpydlg " , L " If you are sure you want to copy this game to SD, click on Go. " ) ) ;
break ;
2012-01-21 21:57:41 +01:00
}
m_thrdStop = false ;
m_thrdMessageAdded = false ;
2012-09-09 20:35:15 +02:00
while ( ! m_exit )
2012-01-21 21:57:41 +01:00
{
2012-09-09 20:35:15 +02:00
_mainLoopCommon ( ) ;
2012-09-01 11:34:18 +02:00
if ( ( BTN_HOME_PRESSED | | BTN_B_PRESSED ) & & ! m_thrdWorking )
2012-01-21 21:57:41 +01:00
break ;
2012-09-01 11:34:18 +02:00
else if ( BTN_UP_PRESSED )
2012-01-21 21:57:41 +01:00
m_btnMgr . up ( ) ;
2012-09-01 11:34:18 +02:00
else if ( BTN_DOWN_PRESSED )
2012-01-21 21:57:41 +01:00
m_btnMgr . down ( ) ;
2012-09-01 11:34:18 +02:00
if ( BTN_A_PRESSED & & ! m_thrdWorking )
2012-01-21 21:57:41 +01:00
{
2012-09-01 11:34:18 +02:00
if ( m_btnMgr . selected ( m_wbfsBtnBack ) )
2012-01-21 21:57:41 +01:00
break ;
2012-09-01 11:34:18 +02:00
else if ( m_btnMgr . selected ( m_wbfsBtnGo ) )
2012-01-21 21:57:41 +01:00
{
2012-09-01 11:34:18 +02:00
switch ( op )
2012-01-21 21:57:41 +01:00
{
case CMenu : : WO_ADD_GAME :
2012-09-22 15:47:52 +02:00
MusicPlayer . Stop ( ) ;
2012-09-05 17:52:32 +02:00
_TempLoadIOS ( ) ;
2012-01-21 21:57:41 +01:00
m_btnMgr . show ( m_wbfsPBar ) ;
m_btnMgr . setProgress ( m_wbfsPBar , 0.f ) ;
m_btnMgr . hide ( m_wbfsBtnGo ) ;
m_btnMgr . hide ( m_wbfsBtnBack ) ;
m_btnMgr . show ( m_wbfsLblMessage ) ;
m_btnMgr . setText ( m_wbfsLblMessage , L " " ) ;
if ( Disc_Wait ( ) < 0 )
{
error ( _t ( " wbfsoperr1 " , L " Disc_Wait failed " ) ) ;
out = true ;
break ;
}
2012-08-17 17:48:11 +02:00
if ( Disc_Open ( false ) < 0 )
2012-01-21 21:57:41 +01:00
{
error ( _t ( " wbfsoperr2 " , L " Disc_Open failed " ) ) ;
out = true ;
break ;
}
2012-02-17 03:35:42 +01:00
if ( Disc_IsWii ( ) = = 0 )
2012-01-21 21:57:41 +01:00
{
2012-02-17 03:35:42 +01:00
Disc_ReadHeader ( & header ) ;
2012-11-01 17:39:42 +01:00
memcpy ( GameID , header . id , 6 ) ;
if ( _searchGamesByID ( GameID ) )
2012-02-17 03:35:42 +01:00
{
error ( _t ( " wbfsoperr4 " , L " Game already installed " ) ) ;
out = true ;
break ;
}
2012-11-01 17:39:42 +01:00
cfPos = string ( GameID ) ;
m_btnMgr . setText ( m_wbfsLblDialog , wfmt ( _fmt ( " wbfsop6 " , L " Installing [%s] %s... " ) , GameID , header . title ) ) ;
2012-02-17 03:35:42 +01:00
done = true ;
upd_usb = true ;
m_thrdWorking = true ;
m_thrdProgress = 0.f ;
m_thrdMessageAdded = false ;
LWP_CreateThread ( & thread , ( void * ( * ) ( void * ) ) CMenu : : _gameInstaller , ( void * ) this , 0 , 8 * 1024 , 64 ) ;
}
else if ( Disc_IsGC ( ) = = 0 )
2012-01-21 21:57:41 +01:00
{
2012-02-17 03:35:42 +01:00
Disc_ReadGCHeader ( & gcheader ) ;
2012-11-01 17:39:42 +01:00
memcpy ( GameID , gcheader . id , 6 ) ;
if ( _searchGamesByID ( GameID ) )
2012-02-20 09:26:50 +01:00
{
error ( _t ( " wbfsoperr4 " , L " Game already installed " ) ) ;
out = true ;
break ;
}
2012-11-01 17:39:42 +01:00
cfPos = string ( GameID ) ;
m_btnMgr . setText ( m_wbfsLblDialog , wfmt ( _fmt ( " wbfsop6 " , L " Installing [%s] %s... " ) , GameID , gcheader . title ) ) ;
2012-02-17 03:35:42 +01:00
done = true ;
upd_dml = true ;
m_thrdWorking = true ;
m_thrdProgress = 0.f ;
m_thrdMessageAdded = false ;
LWP_CreateThread ( & thread , ( void * ( * ) ( void * ) ) CMenu : : _GCgameInstaller , ( void * ) this , 0 , 8 * 1024 , 64 ) ;
}
else
{
error ( _t ( " wbfsoperr3 " , L " This is not a Wii or GC disc! " ) ) ;
2012-01-21 21:57:41 +01:00
out = true ;
2012-02-25 23:34:52 +01:00
}
2012-01-21 21:57:41 +01:00
break ;
case CMenu : : WO_REMOVE_GAME :
2012-11-11 19:28:03 +01:00
if ( CoverFlow . getHdr ( ) - > type = = TYPE_GC_GAME )
2012-03-02 19:29:55 +01:00
{
2012-11-11 19:28:03 +01:00
if ( strcasestr ( CoverFlow . getHdr ( ) - > path , " boot.bin " ) ! = NULL )
2012-11-01 17:39:42 +01:00
{
2012-11-11 19:28:03 +01:00
string GC_Path ( CoverFlow . getHdr ( ) - > path ) ;
2012-08-20 21:15:52 +02:00
GC_Path . erase ( GC_Path . end ( ) - 13 , GC_Path . end ( ) ) ;
2012-11-01 17:39:42 +01:00
fsop_deleteFolder ( GC_Path . c_str ( ) ) ;
}
2012-08-20 21:15:52 +02:00
else
2012-11-11 19:28:03 +01:00
fsop_deleteFile ( CoverFlow . getHdr ( ) - > path ) ;
2012-03-02 19:29:55 +01:00
upd_dml = true ;
}
2012-11-11 19:28:03 +01:00
else if ( CoverFlow . getHdr ( ) - > type = = TYPE_PLUGIN )
2012-05-24 20:48:26 +02:00
{
2012-11-11 19:28:03 +01:00
fsop_deleteFile ( CoverFlow . getHdr ( ) - > path ) ;
2012-05-24 20:48:26 +02:00
upd_emu = true ;
}
2012-11-11 19:28:03 +01:00
else if ( CoverFlow . getHdr ( ) - > type = = TYPE_WII_GAME )
2012-05-24 20:48:26 +02:00
{
2012-11-11 19:28:03 +01:00
WBFS_RemoveGame ( ( u8 * ) CoverFlow . getId ( ) . c_str ( ) , CoverFlow . getHdr ( ) - > path ) ;
2012-05-24 20:48:26 +02:00
upd_usb = true ;
}
2012-11-01 17:39:42 +01:00
if ( m_cfg . getBool ( " GENERAL " , " delete_cover_and_game " , false ) )
2012-11-11 19:28:03 +01:00
RemoveCover ( CoverFlow . getId ( ) . c_str ( ) ) ;
2012-01-21 21:57:41 +01:00
m_btnMgr . show ( m_wbfsPBar ) ;
m_btnMgr . setProgress ( m_wbfsPBar , 0.f , true ) ;
m_btnMgr . setProgress ( m_wbfsPBar , 1.f ) ;
m_btnMgr . hide ( m_wbfsLblDialog ) ;
m_btnMgr . hide ( m_wbfsBtnGo ) ;
m_btnMgr . show ( m_wbfsLblMessage ) ;
m_btnMgr . setText ( m_wbfsLblMessage , _t ( " wbfsop7 " , L " Game deleted " ) ) ;
done = true ;
break ;
case CMenu : : WO_FORMAT :
break ;
2012-02-28 19:44:41 +01:00
case CMenu : : WO_COPY_GAME :
2012-11-11 19:28:03 +01:00
string GC_Path ( CoverFlow . getHdr ( ) - > path ) ;
2012-08-26 17:20:51 +02:00
if ( strcasestr ( GC_Path . c_str ( ) , " boot.bin " ) ! = NULL )
GC_Path . erase ( GC_Path . end ( ) - 13 , GC_Path . end ( ) ) ;
else
GC_Path . erase ( GC_Path . end ( ) - 9 , GC_Path . end ( ) ) ;
2012-11-01 17:39:42 +01:00
if ( fsop_GetFreeSpaceKb ( " sd:/ " ) < fsop_GetFolderKb ( GC_Path . c_str ( ) ) )
2012-04-03 17:49:52 +02:00
{
m_btnMgr . hide ( m_wbfsBtnGo ) ;
2012-11-01 17:39:42 +01:00
_setThrdMsg ( wfmt ( _fmt ( " wbfsop24 " , L " Not enough space: %d blocks needed, %d available " ) , fsop_GetFolderKb ( GC_Path . c_str ( ) ) , fsop_GetFreeSpaceKb ( " sd:/ " ) ) , 0.f ) ;
2012-04-03 17:49:52 +02:00
break ;
}
2012-02-28 19:44:41 +01:00
m_btnMgr . show ( m_wbfsPBar ) ;
m_btnMgr . setProgress ( m_wbfsPBar , 0.f ) ;
m_btnMgr . hide ( m_wbfsBtnGo ) ;
m_btnMgr . hide ( m_wbfsBtnBack ) ;
m_btnMgr . show ( m_wbfsLblMessage ) ;
m_btnMgr . setText ( m_wbfsLblMessage , L " " ) ;
2012-11-11 19:28:03 +01:00
cfPos = string ( CoverFlow . getHdr ( ) - > id ) ;
m_btnMgr . setText ( m_wbfsLblDialog , wfmt ( _fmt ( " wbfsop10 " , L " Copying [%s] %s... " ) , CoverFlow . getHdr ( ) - > id , CoverFlow . getTitle ( ) . toUTF8 ( ) . c_str ( ) ) ) ;
2012-02-28 19:44:41 +01:00
done = true ;
2012-03-03 18:16:11 +01:00
upd_dml = true ;
2012-02-28 19:44:41 +01:00
m_thrdWorking = true ;
m_thrdProgress = 0.f ;
m_thrdMessageAdded = false ;
LWP_CreateThread ( & thread , ( void * ( * ) ( void * ) ) CMenu : : _GCcopyGame , ( void * ) this , 0 , 8 * 1024 , 64 ) ;
break ;
2012-01-21 21:57:41 +01:00
}
2012-09-01 11:34:18 +02:00
if ( out )
2012-01-21 21:57:41 +01:00
break ;
}
}
2012-04-04 14:22:01 +02:00
2012-09-01 11:34:18 +02:00
if ( m_thrdMessageAdded )
2012-01-21 21:57:41 +01:00
{
LockMutex lock ( m_mutex ) ;
m_thrdMessageAdded = false ;
if ( ! m_thrdMessage . empty ( ) )
m_btnMgr . setText ( m_wbfsLblDialog , m_thrdMessage ) ;
m_btnMgr . setProgress ( m_wbfsPBar , m_thrdProgress ) ;
2012-11-01 17:39:42 +01:00
m_btnMgr . setText ( m_wbfsLblMessage , wfmt ( L " %i%% " , ( int ) ( m_thrdProgress * 100.f ) ) ) ;
2012-09-01 11:34:18 +02:00
if ( ! m_thrdWorking )
2012-05-04 10:04:23 +02:00
{
if ( op = = CMenu : : WO_ADD_GAME )
2012-09-05 17:52:32 +02:00
{
2012-05-04 10:04:23 +02:00
WDVD_StopMotor ( ) ;
2012-09-22 15:47:52 +02:00
MusicPlayer . Stop ( ) ;
2012-09-05 17:52:32 +02:00
_TempLoadIOS ( IOS_TYPE_NORMAL_IOS ) ;
}
2012-01-21 21:57:41 +01:00
m_btnMgr . show ( m_wbfsBtnBack ) ;
2012-05-04 10:04:23 +02:00
}
2012-01-21 21:57:41 +01:00
}
}
_hideWBFS ( ) ;
2012-02-28 19:44:41 +01:00
if ( done & & ( op = = CMenu : : WO_REMOVE_GAME | | op = = CMenu : : WO_ADD_GAME ) )
2012-01-21 21:57:41 +01:00
{
2012-10-03 23:34:37 +02:00
//m_gameList.SetLanguage(m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str());
2012-05-04 10:04:23 +02:00
2012-04-04 14:22:01 +02:00
if ( upd_dml )
2012-02-17 03:35:42 +01:00
UpdateCache ( COVERFLOW_DML ) ;
2012-04-04 14:22:01 +02:00
if ( upd_usb )
2012-02-17 03:35:42 +01:00
UpdateCache ( COVERFLOW_USB ) ;
2012-01-21 21:57:41 +01:00
2012-05-24 20:48:26 +02:00
if ( upd_emu )
2012-10-03 23:34:37 +02:00
UpdateCache ( COVERFLOW_PLUGIN ) ;
2012-05-24 20:48:26 +02:00
2012-01-21 21:57:41 +01:00
_loadList ( ) ;
_initCF ( ) ;
2012-11-11 19:28:03 +01:00
CoverFlow . findId ( cfPos . c_str ( ) , true ) ;
2012-01-21 21:57:41 +01:00
}
2012-04-04 14:22:01 +02:00
else if ( done & & op = = CMenu : : WO_COPY_GAME )
{
2012-10-03 23:34:37 +02:00
//m_gameList.SetLanguage(m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str());
2012-04-04 14:22:01 +02:00
if ( upd_dml )
{
UpdateCache ( COVERFLOW_DML ) ;
currentPartition = SD ;
UpdateCache ( COVERFLOW_DML ) ;
}
}
2012-01-21 21:57:41 +01:00
return done ;
}
2012-11-03 20:16:03 +01:00
void CMenu : : _initWBFSMenu ( )
2012-01-21 21:57:41 +01:00
{
2012-11-03 20:16:03 +01:00
_addUserLabels ( m_wbfsLblUser , ARRAY_SIZE ( m_wbfsLblUser ) , " WBFS " ) ;
m_wbfsBg = _texture ( " WBFS/BG " , " texture " , theme . bg , false ) ;
m_wbfsLblTitle = _addTitle ( " WBFS/TITLE " , theme . titleFont , L " " , 20 , 30 , 600 , 60 , theme . titleFontColor , FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE ) ;
m_wbfsLblDialog = _addLabel ( " WBFS/DIALOG " , theme . lblFont , L " " , 40 , 90 , 560 , 200 , theme . lblFontColor , FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE ) ;
m_wbfsLblMessage = _addLabel ( " WBFS/MESSAGE " , theme . lblFont , L " " , 40 , 300 , 560 , 100 , theme . lblFontColor , FTGX_JUSTIFY_CENTER | FTGX_ALIGN_TOP ) ;
m_wbfsPBar = _addProgressBar ( " WBFS/PROGRESS_BAR " , 40 , 270 , 560 , 20 ) ;
m_wbfsBtnBack = _addButton ( " WBFS/BACK_BTN " , theme . btnFont , L " " , 420 , 400 , 200 , 56 , theme . btnFontColor ) ;
m_wbfsBtnGo = _addButton ( " WBFS/GO_BTN " , theme . btnFont , L " " , 245 , 260 , 150 , 56 , theme . btnFontColor ) ;
2012-02-28 19:44:41 +01:00
2012-01-21 21:57:41 +01:00
_setHideAnim ( m_wbfsLblTitle , " WBFS/TITLE " , 0 , 0 , - 2.f , 0.f ) ;
_setHideAnim ( m_wbfsLblDialog , " WBFS/DIALOG " , 0 , 0 , - 2.f , 0.f ) ;
_setHideAnim ( m_wbfsLblMessage , " WBFS/MESSAGE " , 0 , 0 , - 2.f , 0.f ) ;
_setHideAnim ( m_wbfsPBar , " WBFS/PROGRESS_BAR " , 0 , 0 , - 2.f , 0.f ) ;
_setHideAnim ( m_wbfsBtnBack , " WBFS/BACK_BTN " , 0 , 0 , - 2.f , 0.f ) ;
_setHideAnim ( m_wbfsBtnGo , " WBFS/GO_BTN " , 0 , 0 , - 2.f , 0.f ) ;
_hideWBFS ( true ) ;
_textWBFS ( ) ;
}
void CMenu : : _textWBFS ( void )
{
m_btnMgr . setText ( m_wbfsBtnBack , _t ( " wbfsop4 " , L " Back " ) ) ;
m_btnMgr . setText ( m_wbfsBtnGo , _t ( " wbfsop5 " , L " Go " ) ) ;
}