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
|
|
|
|
2011-01-16 14:12:07 +01:00
|
|
|
u64 gamesize = 0;
|
2009-11-22 15:09:08 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* MenuInstall
|
|
|
|
***************************************************************************/
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
int MenuInstall()
|
|
|
|
{
|
2011-01-17 23:03:14 +01:00
|
|
|
int ios_ver = IOS_GetVersion();
|
|
|
|
if(ios_ver < 200)
|
|
|
|
{
|
|
|
|
char text[100];
|
|
|
|
snprintf(text, sizeof(text), "%s %i.", tr("You are currently using IOS"), ios_ver);
|
|
|
|
WindowPrompt(text, tr("The game installation is disabled under this IOS because of instability in usb write."), tr("OK"));
|
|
|
|
return MENU_DISCLIST;
|
|
|
|
}
|
|
|
|
|
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);
|
2011-01-16 14:12:07 +01:00
|
|
|
gamesize = WBFS_EstimeGameSize();
|
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
|
|
|
|
2011-01-16 14:12:07 +01:00
|
|
|
sprintf(gametxt, "%s : %.2fGB", name, gamesize/GB_SIZE);
|
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
|
|
|
|
2011-01-16 14:12:07 +01:00
|
|
|
if (gamesize/GB_SIZE > freespace)
|
2010-10-31 10:30:53 +01:00
|
|
|
{
|
|
|
|
char errortxt[50];
|
2011-01-16 14:12:07 +01:00
|
|
|
sprintf(errortxt, "%s: %.2fGB, %s: %.2fGB", tr( "Game Size" ), gamesize/GB_SIZE, tr( "Free Space" ), freespace);
|
2010-10-31 10:30:53 +01:00
|
|
|
WindowPrompt(tr( "Not enough free space!" ), errortxt, tr( "OK" ));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-14 16:39:42 +01:00
|
|
|
StartProgress(gametxt, name, 0, true, true);
|
2010-10-31 10:30:53 +01:00
|
|
|
ret = WBFS_AddGame();
|
|
|
|
ProgressStop();
|
|
|
|
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-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();
|
2011-01-08 13:35:41 +01:00
|
|
|
instsuccess = new GuiSound(Resources::GetFile("success.ogg"), Resources::GetFileSize("success.ogg"), Settings.sfxvolume);
|
2010-10-31 10:30:53 +01:00
|
|
|
instsuccess->SetVolume(Settings.sfxvolume);
|
|
|
|
instsuccess->SetLoop(0);
|
|
|
|
instsuccess->Play();
|
|
|
|
WindowPrompt(tr( "Successfully installed:" ), name, tr( "OK" ));
|
|
|
|
instsuccess->Stop();
|
|
|
|
delete instsuccess;
|
|
|
|
bgMusic->Resume();
|
2010-02-01 00:55:59 +01:00
|
|
|
}
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
2010-10-31 10:30:53 +01:00
|
|
|
}
|
2009-11-22 15:09:08 +01:00
|
|
|
|
|
|
|
//Turn off the WiiLight
|
2010-09-24 02:48:03 +02:00
|
|
|
wiilight(0);
|
2011-01-16 14:12:07 +01:00
|
|
|
gamesize = 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
|
|
|
}
|