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"
|
2010-09-26 10:33:43 +02:00
|
|
|
#include "themes/CTheme.h"
|
2009-11-22 15:09:08 +01:00
|
|
|
|
|
|
|
float gamesize;
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* MenuInstall
|
|
|
|
***************************************************************************/
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
int MenuInstall()
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
gprintf("\nMenuInstall()");
|
2009-11-22 15:09:08 +01:00
|
|
|
|
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-24 02:48:03 +02:00
|
|
|
Disc_SetUSB(NULL);
|
2009-11-22 15:09:08 +01:00
|
|
|
|
|
|
|
int ret, choice = 0;
|
|
|
|
char name[200];
|
|
|
|
|
2010-10-31 10:30:53 +01:00
|
|
|
ret = DiscWait(tr( "Insert Disk" ), tr( "Waiting..." ), tr( "Cancel" ), 0, 0);
|
|
|
|
if (ret < 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-10-31 10:30:53 +01:00
|
|
|
WindowPrompt(tr( "Error reading Disc" ), 0, tr( "Back" ));
|
2010-12-17 18:50:44 +01:00
|
|
|
return MENU_DISCLIST;
|
2010-10-31 10:30:53 +01:00
|
|
|
}
|
|
|
|
ret = Disc_Open();
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
WindowPrompt(tr( "Could not open Disc" ), 0, tr( "Back" ));
|
2010-12-17 18:50:44 +01:00
|
|
|
return MENU_DISCLIST;
|
2010-10-31 10:30:53 +01:00
|
|
|
}
|
2009-11-22 15:09:08 +01:00
|
|
|
|
2010-10-31 10:30:53 +01:00
|
|
|
ret = Disc_IsWii();
|
|
|
|
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-10-31 10:30:53 +01:00
|
|
|
if (choice == 1)
|
2010-12-17 18:50:44 +01:00
|
|
|
return MENU_INSTALL;
|
|
|
|
else
|
|
|
|
return MENU_DISCLIST;
|
2010-10-31 10:30:53 +01:00
|
|
|
}
|
2009-11-22 15:09:08 +01:00
|
|
|
|
2010-10-31 10:30:53 +01:00
|
|
|
Disc_ReadHeader(&headerdisc);
|
|
|
|
snprintf(name, sizeof(name), "%s", headerdisc.title);
|
2009-11-22 15:09:08 +01:00
|
|
|
|
2010-10-31 10:30:53 +01:00
|
|
|
ret = WBFS_CheckGame(headerdisc.id);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
WindowPrompt(tr( "Game is already installed:" ), name, tr( "Back" ));
|
2010-12-17 18:50:44 +01:00
|
|
|
return MENU_DISCLIST;
|
2010-10-31 10:30:53 +01:00
|
|
|
}
|
2009-11-22 15:09:08 +01:00
|
|
|
|
2010-10-31 10:30:53 +01:00
|
|
|
f32 freespace, used;
|
2009-11-22 15:09:08 +01:00
|
|
|
|
2010-10-31 10:30:53 +01:00
|
|
|
WBFS_DiskSpace(&used, &freespace);
|
|
|
|
gamesize = WBFS_EstimeGameSize() / GB_SIZE;
|
2009-11-22 15:09:08 +01:00
|
|
|
|
2010-10-31 10:30:53 +01:00
|
|
|
char gametxt[50];
|
2009-11-22 15:09:08 +01:00
|
|
|
|
2010-10-31 10:30:53 +01:00
|
|
|
sprintf(gametxt, "%s : %.2fGB", name, gamesize);
|
2009-11-22 15:09:08 +01:00
|
|
|
|
2010-10-31 10:30:53 +01:00
|
|
|
wiilight(1);
|
|
|
|
choice = WindowPrompt(tr( "Continue to install game?" ), gametxt, tr( "OK" ), tr( "Cancel" ));
|
2009-11-22 15:09:08 +01:00
|
|
|
|
2010-10-31 10:30:53 +01:00
|
|
|
if (choice == 1)
|
|
|
|
{
|
|
|
|
sprintf(gametxt, "%s", tr( "Installing game:" ));
|
2009-11-22 15:09:08 +01:00
|
|
|
|
2010-10-31 10:30:53 +01:00
|
|
|
if (gamesize > freespace)
|
|
|
|
{
|
|
|
|
char errortxt[50];
|
|
|
|
sprintf(errortxt, "%s: %.2fGB, %s: %.2fGB", tr( "Game Size" ), gamesize, tr( "Free Space" ), freespace);
|
|
|
|
WindowPrompt(tr( "Not enough free space!" ), errortxt, tr( "OK" ));
|
2010-12-17 18:50:44 +01:00
|
|
|
return MENU_DISCLIST;
|
2010-10-31 10:30:53 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
USBStorage2_Watchdog(0);
|
|
|
|
SetupGameInstallProgress(gametxt, name);
|
|
|
|
ret = WBFS_AddGame();
|
|
|
|
ProgressStop();
|
|
|
|
USBStorage2_Watchdog(1);
|
|
|
|
wiilight(0);
|
|
|
|
if (ret != 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-10-31 10:30:53 +01:00
|
|
|
WindowPrompt(tr( "Install Error!" ), 0, tr( "Back" ));
|
2010-12-17 18:50:44 +01:00
|
|
|
return MENU_DISCLIST;
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-31 10:30:53 +01:00
|
|
|
gameList.ReadGameList(); //get the entries again
|
|
|
|
gameList.FilterList();
|
|
|
|
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();
|
2010-12-17 18:50:44 +01:00
|
|
|
return MENU_DISCLIST;
|
2010-02-01 00:55:59 +01:00
|
|
|
}
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
2010-10-31 10:30:53 +01:00
|
|
|
}
|
|
|
|
else
|
2010-12-17 18:50:44 +01:00
|
|
|
return MENU_DISCLIST;
|
2009-11-22 15:09:08 +01:00
|
|
|
|
|
|
|
//Turn off the WiiLight
|
2010-09-24 02:48:03 +02:00
|
|
|
wiilight(0);
|
2009-11-22 15:09:08 +01:00
|
|
|
|
2010-12-17 18:50:44 +01:00
|
|
|
return MENU_DISCLIST;
|
2009-11-22 15:09:08 +01:00
|
|
|
}
|