2009-11-22 15:09:08 +01:00
|
|
|
#include "menus.h"
|
2010-02-22 22:29:47 +01:00
|
|
|
#include "usbloader/usbstorage2.h"
|
2009-11-22 15:09:08 +01:00
|
|
|
#include "usbloader/wbfs.h"
|
|
|
|
#include "usbloader/disc.h"
|
|
|
|
#include "usbloader/utils.h"
|
2010-09-18 13:46:25 +02:00
|
|
|
#include "usbloader/GameList.h"
|
2009-11-22 15:09:08 +01:00
|
|
|
#include "prompts/ProgressWindow.h"
|
|
|
|
|
|
|
|
float gamesize;
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* MenuInstall
|
|
|
|
***************************************************************************/
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
int MenuInstall()
|
|
|
|
{
|
|
|
|
gprintf( "\nMenuInstall()" );
|
2009-11-22 15:09:08 +01:00
|
|
|
|
|
|
|
int menu = MENU_NONE;
|
2010-09-19 01:16:05 +02:00
|
|
|
static struct discHdr headerdisc ATTRIBUTE_ALIGN( 32 );
|
2009-11-22 15:09:08 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
Disc_SetUSB( NULL );
|
2009-11-22 15:09:08 +01:00
|
|
|
|
|
|
|
int ret, choice = 0;
|
|
|
|
char name[200];
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
GuiSound btnSoundOver( button_over_pcm, button_over_pcm_size, Settings.sfxvolume );
|
2009-11-22 15:09:08 +01:00
|
|
|
|
|
|
|
char imgPath[100];
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
snprintf( imgPath, sizeof( imgPath ), "%sbattery.png", CFG.theme_path );
|
|
|
|
GuiImageData battery( imgPath, battery_png );
|
|
|
|
snprintf( imgPath, sizeof( imgPath ), "%sbattery_bar.png", CFG.theme_path );
|
|
|
|
GuiImageData batteryBar( imgPath, battery_bar_png );
|
|
|
|
snprintf( imgPath, sizeof( imgPath ), "%sbattery_red.png", CFG.theme_path );
|
|
|
|
GuiImageData batteryRed( imgPath, battery_red_png );
|
|
|
|
snprintf( imgPath, sizeof( imgPath ), "%sbattery_bar_red.png", CFG.theme_path );
|
|
|
|
GuiImageData batteryBarRed( imgPath, battery_bar_red_png );
|
2009-11-22 15:09:08 +01:00
|
|
|
|
|
|
|
HaltGui();
|
2010-09-19 01:16:05 +02:00
|
|
|
GuiWindow w( screenwidth, screenheight );
|
2009-11-22 15:09:08 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
mainWindow->Append( &w );
|
2009-11-22 15:09:08 +01:00
|
|
|
|
|
|
|
ResumeGui();
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
while ( menu == MENU_NONE )
|
|
|
|
{
|
2009-11-22 15:09:08 +01:00
|
|
|
VIDEO_WaitVSync ();
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = DiscWait( tr( "Insert Disk" ), tr( "Waiting..." ), tr( "Cancel" ), 0, 0 );
|
|
|
|
if ( ret < 0 )
|
|
|
|
{
|
|
|
|
WindowPrompt ( tr( "Error reading Disc" ), 0, tr( "Back" ) );
|
2009-11-22 15:09:08 +01:00
|
|
|
menu = MENU_DISCLIST;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ret = Disc_Open();
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( ret < 0 )
|
|
|
|
{
|
|
|
|
WindowPrompt ( tr( "Could not open Disc" ), 0, tr( "Back" ) );
|
2009-11-22 15:09:08 +01:00
|
|
|
menu = MENU_DISCLIST;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = Disc_IsWii();
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( ret < 0 )
|
|
|
|
{
|
|
|
|
choice = WindowPrompt ( tr( "Not a Wii Disc" ), tr( "Insert a Wii Disc!" ), tr( "OK" ), tr( "Back" ) );
|
2009-11-22 15:09:08 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( choice == 1 )
|
|
|
|
{
|
2009-11-22 15:09:08 +01:00
|
|
|
menu = MENU_INSTALL;
|
|
|
|
break;
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
else
|
2009-11-22 15:09:08 +01:00
|
|
|
menu = MENU_DISCLIST;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
Disc_ReadHeader( &headerdisc );
|
|
|
|
snprintf( name, sizeof( name ), "%s", headerdisc.title );
|
2009-11-22 15:09:08 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = WBFS_CheckGame( headerdisc.id );
|
|
|
|
if ( ret )
|
|
|
|
{
|
|
|
|
WindowPrompt ( tr( "Game is already installed:" ), name, tr( "Back" ) );
|
2009-11-22 15:09:08 +01:00
|
|
|
menu = MENU_DISCLIST;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
f32 freespace, used;
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
WBFS_DiskSpace( &used, &freespace );
|
|
|
|
gamesize = WBFS_EstimeGameSize() / GB_SIZE;
|
2009-11-22 15:09:08 +01:00
|
|
|
|
|
|
|
char gametxt[50];
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
sprintf( gametxt, "%s : %.2fGB", name, gamesize );
|
2009-11-22 15:09:08 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
wiilight( 1 );
|
|
|
|
choice = WindowPrompt( tr( "Continue to install game?" ), gametxt, tr( "OK" ), tr( "Cancel" ) );
|
2009-11-22 15:09:08 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( choice == 1 )
|
|
|
|
{
|
2009-11-22 15:09:08 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
sprintf( gametxt, "%s", tr( "Installing game:" ) );
|
2009-11-22 15:09:08 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( gamesize > freespace )
|
|
|
|
{
|
2009-11-22 15:09:08 +01:00
|
|
|
char errortxt[50];
|
2010-09-19 01:16:05 +02:00
|
|
|
sprintf( errortxt, "%s: %.2fGB, %s: %.2fGB", tr( "Game Size" ), gamesize, tr( "Free Space" ), freespace );
|
|
|
|
WindowPrompt( tr( "Not enough free space!" ), errortxt, tr( "OK" ) );
|
2009-11-22 15:09:08 +01:00
|
|
|
menu = MENU_DISCLIST;
|
|
|
|
break;
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
USBStorage2_Watchdog( 0 );
|
|
|
|
SetupGameInstallProgress( gametxt, name );
|
2009-11-22 15:09:08 +01:00
|
|
|
ret = WBFS_AddGame();
|
|
|
|
ProgressStop();
|
2010-09-19 01:16:05 +02:00
|
|
|
USBStorage2_Watchdog( 1 );
|
|
|
|
wiilight( 0 );
|
|
|
|
if ( ret != 0 )
|
|
|
|
{
|
|
|
|
WindowPrompt( tr( "Install Error!" ), 0, tr( "Back" ) );
|
2009-11-22 15:09:08 +01:00
|
|
|
menu = MENU_DISCLIST;
|
|
|
|
break;
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-09-18 13:46:25 +02:00
|
|
|
gameList.ReadGameList(); //get the entries again
|
|
|
|
gameList.FilterList();
|
2010-09-19 01:16:05 +02:00
|
|
|
GuiSound * instsuccess = NULL;
|
|
|
|
bgMusic->Pause();
|
|
|
|
instsuccess = new GuiSound( success_ogg, success_ogg_size, Settings.sfxvolume );
|
|
|
|
instsuccess->SetVolume( Settings.sfxvolume );
|
|
|
|
instsuccess->SetLoop( 0 );
|
|
|
|
instsuccess->Play();
|
|
|
|
WindowPrompt ( tr( "Successfully installed:" ), name, tr( "OK" ) );
|
|
|
|
instsuccess->Stop();
|
|
|
|
delete instsuccess;
|
|
|
|
bgMusic->Resume();
|
2009-11-22 15:09:08 +01:00
|
|
|
menu = MENU_DISCLIST;
|
|
|
|
break;
|
|
|
|
}
|
2010-02-01 00:55:59 +01:00
|
|
|
}
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-11-22 15:09:08 +01:00
|
|
|
menu = MENU_DISCLIST;
|
|
|
|
break;
|
|
|
|
}
|
2010-01-19 11:48:50 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( shutdown == 1 )
|
|
|
|
{
|
|
|
|
wiilight( 0 );
|
2010-01-19 11:48:50 +01:00
|
|
|
Sys_Shutdown();
|
|
|
|
}
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( reset == 1 )
|
|
|
|
{
|
|
|
|
wiilight( 0 );
|
2010-01-19 11:48:50 +01:00
|
|
|
Sys_Reboot();
|
|
|
|
}
|
2009-11-22 15:09:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//Turn off the WiiLight
|
2010-09-19 01:16:05 +02:00
|
|
|
wiilight( 0 );
|
2009-11-22 15:09:08 +01:00
|
|
|
|
|
|
|
HaltGui();
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
mainWindow->Remove( &w );
|
2009-11-22 15:09:08 +01:00
|
|
|
ResumeGui();
|
|
|
|
return menu;
|
|
|
|
}
|