2010-01-19 11:48:50 +01:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "menus.h"
|
|
|
|
#include "fatmounter.h"
|
2010-02-22 22:29:47 +01:00
|
|
|
#include "usbloader/usbstorage2.h"
|
2010-01-19 11:48:50 +01:00
|
|
|
#include "usbloader/utils.h"
|
|
|
|
#include "usbloader/wbfs.h"
|
|
|
|
#include "libwiigui/gui_customoptionbrowser.h"
|
|
|
|
|
|
|
|
extern int load_from_fs;
|
|
|
|
extern char game_partition[6];
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* MenuFormat
|
|
|
|
***************************************************************************/
|
2010-09-19 01:16:05 +02:00
|
|
|
int MenuFormat()
|
|
|
|
{
|
2010-01-19 11:48:50 +01:00
|
|
|
|
|
|
|
USBDevice_deInit();
|
2010-09-19 01:16:05 +02:00
|
|
|
sleep( 1 );
|
2010-01-19 11:48:50 +01:00
|
|
|
|
2010-02-22 22:29:47 +01:00
|
|
|
USBStorage2_Init();
|
2010-01-19 11:48:50 +01:00
|
|
|
|
|
|
|
int menu = MENU_NONE;
|
|
|
|
char imgPath[100];
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
customOptionList options( MAX_PARTITIONS_EX );
|
|
|
|
extern PartList partitions;
|
2010-01-19 11:48:50 +01:00
|
|
|
|
|
|
|
u32 cnt, counter = 0;
|
|
|
|
int choice, ret;
|
|
|
|
char text[ISFS_MAXPATH];
|
|
|
|
|
|
|
|
//create the partitionlist
|
2010-09-19 01:16:05 +02:00
|
|
|
for ( cnt = 0; cnt < ( u32 ) partitions.num; cnt++ )
|
|
|
|
{
|
2010-01-19 11:48:50 +01:00
|
|
|
partitionEntry *entry = &partitions.pentry[cnt];
|
|
|
|
|
|
|
|
/* Calculate size in gigabytes */
|
2010-09-19 01:16:05 +02:00
|
|
|
f32 size = entry->size * ( partitions.sector_size / GB_SIZE );
|
|
|
|
|
|
|
|
if ( size )
|
|
|
|
{
|
|
|
|
options.SetName( counter, "%s %d:", tr( "Partition" ), cnt + 1 );
|
|
|
|
options.SetValue( counter, "%.2fGB", size );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
options.SetName( counter, "%s %d:", tr( "Partition" ), cnt + 1 );
|
|
|
|
options.SetValue( counter, tr( "Can't be formatted" ) );
|
2010-01-19 11:48:50 +01:00
|
|
|
}
|
2010-09-19 01:16:05 +02:00
|
|
|
counter++;
|
2010-01-19 11:48:50 +01: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, Settings.sfxvolume);
|
|
|
|
snprintf( imgPath, sizeof( imgPath ), "%swiimote_poweroff.png", CFG.theme_path );
|
|
|
|
GuiImageData btnpwroff( imgPath, wiimote_poweroff_png );
|
|
|
|
snprintf( imgPath, sizeof( imgPath ), "%swiimote_poweroff_over.png", CFG.theme_path );
|
|
|
|
GuiImageData btnpwroffOver( imgPath, wiimote_poweroff_over_png );
|
|
|
|
snprintf( imgPath, sizeof( imgPath ), "%smenu_button.png", CFG.theme_path );
|
|
|
|
GuiImageData btnhome( imgPath, menu_button_png );
|
|
|
|
snprintf( imgPath, sizeof( imgPath ), "%smenu_button_over.png", CFG.theme_path );
|
|
|
|
GuiImageData btnhomeOver( imgPath, menu_button_over_png );
|
|
|
|
GuiImageData battery( battery_png );
|
|
|
|
GuiImageData batteryBar( battery_bar_png );
|
|
|
|
GuiImageData batteryRed( battery_red_png );
|
|
|
|
GuiImageData batteryBarRed( battery_bar_red_png );
|
2010-01-19 11:48:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
GuiTrigger trigA;
|
2010-09-19 01:16:05 +02:00
|
|
|
trigA.SetSimpleTrigger( -1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A );
|
2010-01-19 11:48:50 +01:00
|
|
|
GuiTrigger trigHome;
|
2010-09-19 01:16:05 +02:00
|
|
|
trigHome.SetButtonOnlyTrigger( -1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0 );
|
|
|
|
|
|
|
|
GuiImage poweroffBtnImg( &btnpwroff );
|
|
|
|
GuiImage poweroffBtnImgOver( &btnpwroffOver );
|
|
|
|
poweroffBtnImg.SetWidescreen( CFG.widescreen );
|
|
|
|
poweroffBtnImgOver.SetWidescreen( CFG.widescreen );
|
|
|
|
GuiButton poweroffBtn( &poweroffBtnImg, &poweroffBtnImgOver, 0, 3, THEME.power_x, THEME.power_y, &trigA, &btnSoundOver, btnClick2, 1 );
|
|
|
|
GuiImage exitBtnImg( &btnhome );
|
|
|
|
GuiImage exitBtnImgOver( &btnhomeOver );
|
|
|
|
exitBtnImg.SetWidescreen( CFG.widescreen );
|
|
|
|
exitBtnImgOver.SetWidescreen( CFG.widescreen );
|
|
|
|
GuiButton exitBtn( &exitBtnImg, &exitBtnImgOver, 0, 3, THEME.home_x, THEME.home_y, &trigA, &btnSoundOver, btnClick2, 1 );
|
|
|
|
exitBtn.SetTrigger( &trigHome );
|
|
|
|
|
|
|
|
GuiCustomOptionBrowser optionBrowser( 396, 280, &options, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, 0, 10 );
|
|
|
|
optionBrowser.SetPosition( 0, 40 );
|
|
|
|
optionBrowser.SetAlignment( ALIGN_CENTRE, ALIGN_TOP );
|
2010-01-19 11:48:50 +01:00
|
|
|
|
|
|
|
HaltGui();
|
2010-09-19 01:16:05 +02:00
|
|
|
GuiWindow w( screenwidth, screenheight );
|
|
|
|
w.Append( &poweroffBtn );
|
|
|
|
w.Append( &exitBtn );
|
2010-01-19 11:48:50 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
mainWindow->Append( &w );
|
|
|
|
mainWindow->Append( &optionBrowser );
|
2010-01-19 11:48:50 +01:00
|
|
|
|
|
|
|
ResumeGui();
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
while ( menu == MENU_NONE )
|
|
|
|
{
|
2010-01-19 11:48:50 +01:00
|
|
|
|
|
|
|
VIDEO_WaitVSync ();
|
|
|
|
|
|
|
|
ret = optionBrowser.GetClickedOption();
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( ret >= 0 )
|
|
|
|
{
|
|
|
|
if ( Settings.godmode == 1 )
|
|
|
|
{
|
2010-01-19 11:48:50 +01:00
|
|
|
partitionEntry *entry = &partitions.pentry[ret];
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( entry->size )
|
|
|
|
{
|
|
|
|
if ( load_from_fs == PART_FS_FAT )
|
|
|
|
{
|
|
|
|
WBFS_OpenPart( partitions.pinfo[ret].part_fs, partitions.pinfo[ret].index, entry->sector,
|
|
|
|
entry->size, ( char * ) &game_partition );
|
|
|
|
load_from_fs = partitions.pinfo[ret].part_fs;
|
|
|
|
menu = MENU_DISCLIST;
|
|
|
|
|
|
|
|
Settings.partition = ret;
|
|
|
|
if ( isInserted( bootDevice ) )cfg_save_global();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprintf( text, "%s %d : %.2fGB", tr( "Partition" ), ret + 1, entry->size * ( partitions.sector_size / GB_SIZE ) );
|
|
|
|
choice = WindowPrompt( tr( "Do you want to format:" ), text, tr( "Yes" ), tr( "No" ) );
|
|
|
|
if ( choice == 1 )
|
|
|
|
{
|
|
|
|
ret = FormatingPartition( tr( "Formatting, please wait..." ), entry );
|
|
|
|
if ( ret < 0 )
|
|
|
|
{
|
|
|
|
WindowPrompt( tr( "Error !" ), tr( "Failed formating" ), tr( "Return" ) );
|
|
|
|
menu = MENU_SETTINGS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sleep( 1 );
|
|
|
|
ret = WBFS_Open();
|
|
|
|
sprintf( text, "%s %s", text, tr( "formatted!" ) );
|
|
|
|
WindowPrompt( tr( "Success:" ), text, tr( "OK" ) );
|
|
|
|
if ( ret < 0 )
|
|
|
|
{
|
|
|
|
WindowPrompt( tr( "ERROR" ), tr( "Failed to open partition" ), tr( "OK" ) );
|
|
|
|
Sys_LoadMenu();
|
|
|
|
}
|
|
|
|
menu = MENU_DISCLIST;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( Settings.godmode == 0 )
|
|
|
|
{
|
|
|
|
mainWindow->Remove( &optionBrowser );
|
2010-01-19 11:48:50 +01:00
|
|
|
char entered[20] = "";
|
2010-09-19 01:16:05 +02:00
|
|
|
int result = OnScreenKeyboard( entered, 20, 0 );
|
|
|
|
mainWindow->Append( &optionBrowser );
|
|
|
|
if ( result == 1 )
|
|
|
|
{
|
|
|
|
if ( !strcmp( entered, Settings.unlockCode ) ) //if password correct
|
|
|
|
{
|
|
|
|
if ( Settings.godmode == 0 )
|
|
|
|
{
|
|
|
|
WindowPrompt( tr( "Correct Password" ), tr( "All the features of USB Loader GX are unlocked." ), tr( "OK" ) );
|
2010-01-19 11:48:50 +01:00
|
|
|
Settings.godmode = 1;
|
|
|
|
}
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WindowPrompt( tr( "Wrong Password" ), tr( "USB Loader GX is protected" ), tr( "OK" ) );
|
2010-01-19 11:48:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( shutdown == 1 )
|
2010-01-19 11:48:50 +01:00
|
|
|
Sys_Shutdown();
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( reset == 1 )
|
2010-01-19 11:48:50 +01:00
|
|
|
Sys_Reboot();
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( poweroffBtn.GetState() == STATE_CLICKED )
|
|
|
|
{
|
|
|
|
choice = WindowPrompt ( tr( "Shutdown System" ), tr( "Are you sure?" ), tr( "Yes" ), tr( "No" ) );
|
|
|
|
if ( choice == 1 )
|
|
|
|
{
|
2010-01-19 11:48:50 +01:00
|
|
|
Sys_Shutdown();
|
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
else if ( exitBtn.GetState() == STATE_CLICKED )
|
|
|
|
{
|
|
|
|
choice = WindowPrompt ( tr( "Return to Wii Menu" ), tr( "Are you sure?" ), tr( "Yes" ), tr( "No" ) );
|
|
|
|
if ( choice == 1 )
|
|
|
|
{
|
2010-01-19 11:48:50 +01:00
|
|
|
Sys_LoadMenu();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HaltGui();
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
mainWindow->Remove( &optionBrowser );
|
|
|
|
mainWindow->Remove( &w );
|
2010-01-19 11:48:50 +01:00
|
|
|
ResumeGui();
|
|
|
|
|
|
|
|
return menu;
|
|
|
|
}
|
|
|
|
|