*Clean up in partition mount/format process

*Clean up in game boot process
This commit is contained in:
dimok321 2010-10-27 19:50:48 +00:00
parent 78ff6447a4
commit 6baa46b1e6
16 changed files with 520 additions and 626 deletions

View File

@ -2,8 +2,8 @@
<app version="1">
<name> USB Loader GX</name>
<coder>USB Loader GX Team</coder>
<version>1.0 r991</version>
<release_date>201010270652</release_date>
<version>1.0 r992</version>
<release_date>201010271735</release_date>
<short_description>Loads games from USB-devices</short_description>
<long_description>USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times.
The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller.

129
source/GameBootProcess.cpp Normal file
View File

@ -0,0 +1,129 @@
#include "menu/menus.h"
#include "mload/mload.h"
#include "mload/mload_modules.h"
#include "usbloader/disc.h"
#include "usbloader/GameList.h"
#include "settings/Settings.h"
#include "settings/CGameSettings.h"
#include "usbloader/frag.h"
#include "usbloader/wbfs.h"
#include "settings/newtitles.h"
#include "patches/fst.h"
#include "wad/nandtitle.h"
struct discHdr *dvdheader = NULL;
extern int load_from_fs;
extern int mountMethod;
int BootGame(const char * gameID)
{
if(!gameID || strlen(gameID) < 3)
return -1;
gprintf("\tSettings.partition: %d\n", Settings.partition);
gameList.LoadUnfiltered();
struct discHdr *header = gameList.GetDiscHeader(gameID);
if(!header)
{
gprintf("Game was not found: %s\n", gameID);
return -1;
}
int ret = 0;
header = (mountMethod ? dvdheader : header);
u8 videoChoice = Settings.videomode;
u8 languageChoice = Settings.language;
u8 ocarinaChoice = Settings.ocarina;
u8 viChoice = Settings.videopatch;
u8 iosChoice = Settings.cios;
u8 fix002 = Settings.error002;
u8 countrystrings = Settings.patchcountrystrings;
u8 alternatedol = OFF;
u32 alternatedoloffset = 0;
u8 reloadblock = OFF;
u8 returnToLoaderGV = 1;
GameCFG * game_cfg = GameSettings.GetGameCFG(header->id);
if (game_cfg)
{
videoChoice = game_cfg->video;
languageChoice = game_cfg->language;
ocarinaChoice = game_cfg->ocarina;
viChoice = game_cfg->vipatch;
fix002 = game_cfg->errorfix002;
iosChoice = game_cfg->ios;
countrystrings = game_cfg->patchcountrystrings;
alternatedol = game_cfg->loadalternatedol;
alternatedoloffset = game_cfg->alternatedolstart;
reloadblock = game_cfg->iosreloadblock;
returnToLoaderGV = game_cfg->returnTo;
}
if (!mountMethod)
{
gprintf("Loading fragment list...");
ret = get_frag_list(header->id);
gprintf("%d\n", ret);
gprintf("Setting fragment list...");
ret = set_frag_list(header->id);
gprintf("%d\n", ret);
ret = Disc_SetUSB(header->id);
if (ret < 0) Sys_BackToLoader();
gprintf("\tUSB set to game\n");
}
else
{
gprintf("\tUSB not set, loading DVD\n");
}
ret = Disc_Open();
if (ret < 0) Sys_BackToLoader();
if (dvdheader) delete dvdheader;
gprintf("Loading BCA data...");
ret = do_bca_code(header->id);
gprintf("%d\n", ret);
if (reloadblock == ON && Sys_IsHermes())
{
enable_ES_ioctlv_vector();
if (load_from_fs == PART_FS_WBFS)
{
mload_close();
}
}
u32 channel = 0;
if (returnToLoaderGV)
{
int idx = NandTitles.FindU32(Settings.returnTo);
if (idx >= 0) channel = TITLE_LOWER( NandTitles.At( idx ) );
}
//This is temporary
SetCheatFilepath(Settings.Cheatcodespath);
SetBCAFilepath(Settings.BcaCodepath);
gprintf("\tDisc_wiiBoot\n");
shadow_mload();
ret = Disc_WiiBoot(Settings.dolpath, videoChoice, languageChoice, ocarinaChoice, viChoice, countrystrings,
alternatedol, alternatedoloffset, channel, fix002);
if (ret < 0)
Sys_LoadMenu();
//should never get here
printf("Returning entry point: 0x%0x\n", ret);
return ret;
}

6
source/GameBootProcess.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef GAMEBOOTPROCESS_H_
#define GAMEBOOTPROCESS_H_
int BootGame(const char * gameID);
#endif

View File

@ -35,6 +35,7 @@ extern "C"
#include "FontSystem.h"
#include "video.h"
#include "audio.h"
#include "menu/menus.h"
#include "menu.h"
#include "input.h"
#include "filelist.h"
@ -53,10 +54,9 @@ extern "C"
#include "usbloader/usbstorage2.h"
#include "wad/nandtitle.h"
#include "system/IosLoader.h"
#include "GameBootProcess.h"
extern bool geckoinit;
extern char headlessID[8];
char bootDevice[10];
PartList partitions;
@ -100,19 +100,12 @@ int main(int argc, char *argv[])
}
printf("\tLoaded cIOS = %u (Rev %u)\n", IOS_GetVersion(), IOS_GetRevision());
printf("\tWaiting for USB:\n");
if (MountWBFS() < 0)
{
printf("ERROR: No WBFS drive mounted.\n");
sleep(5);
exit(0);
}
//if a ID was passed via args copy it and try to boot it after the partition is mounted
//its not really a headless mode. more like hairless.
if (argc > 1 && argv[1])
{
if (strlen(argv[1]) == 6) strncpy(headlessID, argv[1], sizeof(headlessID));
MountGamePartition(false);
return BootGame(argv[1]);
}
//! Init the rest of the System
@ -127,6 +120,6 @@ int main(int argc, char *argv[])
//gprintf("\tEnd of Main()\n");
InitGUIThreads();
MainMenu( MENU_CHECK);
MainMenu(MENU_DISCLIST);
return 0;
}

View File

@ -36,6 +36,7 @@
#include "usbloader/frag.h"
#include "usbloader/wbfs.h"
#include "wad/nandtitle.h"
#include "GameBootProcess.h"
/*** Variables that are also used extern ***/
GuiWindow * mainWindow = NULL;
@ -45,7 +46,6 @@ GuiImageData * background = NULL;
GuiBGM * bgMusic = NULL;
GuiSound *btnClick2 = NULL;
struct discHdr *dvdheader = NULL;
int currentMenu;
u8 mountMethod = 0;
@ -58,7 +58,6 @@ GuiText * GameRegionTxt = NULL;
GuiImage * coverImg = NULL;
GuiImageData * cover = NULL;
bool altdoldefault = true;
char headlessID[8] = { 0 };
static lwp_t guithread = LWP_THREAD_NULL;
static bool guiHalt = true;
@ -165,7 +164,7 @@ static void * UpdateGUI(void *arg)
for (i = 5; i < 255; i += 10)
{
if (strcmp(headlessID, "") == 0) mainWindow->Draw();
mainWindow->Draw();
Menu_DrawRectangle(0, 0, screenwidth, screenheight, (GXColor) {0, 0, 0, i}, 1);
Menu_Render();
}
@ -255,6 +254,8 @@ int MainMenu(int menu)
{
currentMenu = menu;
MountGamePartition();
pointer[0] = Resources::GetImageData("player1_point.png");
pointer[1] = Resources::GetImageData("player2_point.png");
pointer[2] = Resources::GetImageData("player3_point.png");
@ -267,7 +268,7 @@ int MainMenu(int menu)
bgImg = new GuiImage(background);
mainWindow->Append(bgImg);
if (strcmp(headlessID, "") == 0) ResumeGui();
ResumeGui();
bgMusic = new GuiBGM(bg_music_ogg, bg_music_ogg_size, Settings.volume);
bgMusic->SetLoop(Settings.musicloopmode); //loop music
@ -281,12 +282,6 @@ int MainMenu(int menu)
switch (currentMenu)
{
case MENU_CHECK:
currentMenu = MenuCheck();
break;
case MENU_FORMAT:
currentMenu = MenuFormat();
break;
case MENU_INSTALL:
currentMenu = MenuInstall();
break;
@ -300,10 +295,8 @@ int MainMenu(int menu)
currentMenu = MenuHomebrewBrowse();
break;
case MENU_DISCLIST:
currentMenu = MenuDiscList();
break;
default: // unrecognized menu
currentMenu = MenuCheck();
currentMenu = MenuDiscList();
break;
}
}
@ -314,8 +307,7 @@ int MainMenu(int menu)
CloseXMLDatabase();
NewTitles::DestroyInstance();
if (strcmp(headlessID, "") != 0) //the GUIthread was never started, so it cant be ended and joined properly if headless mode was used. so we resume it and close it.
ResumeGui();
ResumeGui();
ExitGUIThreads();
bgMusic->Stop();
@ -356,146 +348,14 @@ int MainMenu(int menu)
{
gprintf("\nBootHomebrew");
BootHomebrew(Settings.selected_homebrew);
return 0;
}
else if (boothomebrew == 2)
{
gprintf("\nBootHomebrew from Menu");
//BootHomebrew();
BootHomebrewFromMem();
return 0;
}
else
{
gprintf("\tSettings.partition: %d\n", Settings.partition);
struct discHdr *header = NULL;
//if the GUI was "skipped" to boot a game from main(argv[1])
if (strcmp(headlessID, "") != 0)
{
gprintf("\tHeadless mode (%s)\n", headlessID);
gameList.LoadUnfiltered();
if (!gameList.size())
{
gprintf(" ERROR : !gameCnt");
exit(0);
}
//gprintf("\n\tgameCnt:%d",gameCnt);
for (int i = 0; i < gameList.size(); i++)
{
header = gameList[i];
char tmp[8];
sprintf(tmp, "%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2], header->id[3], header->id[4],
header->id[5]);
if (strcmp(tmp, headlessID) == 0)
{
gameSelected = i;
gprintf(" found (%d)\n", i);
break;
}
//if the game was not found
if (i == gameList.GameCount() - 1)
{
gprintf(" not found (%d IDs checked)\n", i);
exit(0);
}
}
}
int ret = 0;
header = (mountMethod ? dvdheader : gameList[gameSelected]);
u8 videoChoice = Settings.videomode;
u8 languageChoice = Settings.language;
u8 ocarinaChoice = Settings.ocarina;
u8 viChoice = Settings.videopatch;
u8 iosChoice = Settings.cios;
u8 fix002 = Settings.error002;
u8 countrystrings = Settings.patchcountrystrings;
u8 alternatedol = OFF;
u32 alternatedoloffset = 0;
u8 reloadblock = OFF;
u8 returnToLoaderGV = 1;
GameCFG * game_cfg = GameSettings.GetGameCFG(header->id);
if (game_cfg)
{
videoChoice = game_cfg->video;
languageChoice = game_cfg->language;
ocarinaChoice = game_cfg->ocarina;
viChoice = game_cfg->vipatch;
fix002 = game_cfg->errorfix002;
iosChoice = game_cfg->ios;
countrystrings = game_cfg->patchcountrystrings;
//if (!altdoldefault)
//{
alternatedol = game_cfg->loadalternatedol;
alternatedoloffset = game_cfg->alternatedolstart;
//}
reloadblock = game_cfg->iosreloadblock;
returnToLoaderGV = game_cfg->returnTo;
}
if (!mountMethod)
{
gprintf("Loading fragment list...");
ret = get_frag_list(header->id);
gprintf("%d\n", ret);
gprintf("Setting fragment list...");
ret = set_frag_list(header->id);
gprintf("%d\n", ret);
ret = Disc_SetUSB(header->id);
if (ret < 0) Sys_BackToLoader();
gprintf("\tUSB set to game\n");
}
else
{
gprintf("\tUSB not set, loading DVD\n");
}
ret = Disc_Open();
if (ret < 0) Sys_BackToLoader();
if (dvdheader) delete dvdheader;
gprintf("Loading BCA data...");
ret = do_bca_code(header->id);
gprintf("%d\n", ret);
if (reloadblock == ON && Sys_IsHermes())
{
enable_ES_ioctlv_vector();
if (load_from_fs == PART_FS_WBFS)
{
mload_close();
}
}
u32 channel = 0;
if (returnToLoaderGV)
{
int idx = NandTitles.FindU32(Settings.returnTo);
if (idx >= 0) channel = TITLE_LOWER( NandTitles.At( idx ) );
}
//This is temporary
SetCheatFilepath(Settings.Cheatcodespath);
SetBCAFilepath(Settings.BcaCodepath);
gprintf("\tDisc_wiiBoot\n");
shadow_mload();
ret = Disc_WiiBoot(Settings.dolpath, videoChoice, languageChoice, ocarinaChoice, viChoice, countrystrings,
alternatedol, alternatedoloffset, channel, fix002);
if (ret < 0)
{
Sys_LoadMenu();
}
//should never get here
printf("Returning entry point: 0x%0x\n", ret);
}
return 0;
return BootGame((const char *) gameList[gameSelected]->id);
}

View File

@ -24,9 +24,7 @@ enum
MENU_NONE,
MENU_SETTINGS,
MENU_DISCLIST,
MENU_FORMAT,
MENU_INSTALL,
MENU_CHECK,
MENU_GAME_SETTINGS,
MENU_HOMEBREWBROWSE,
BOOTHOMEBREW,

View File

@ -0,0 +1,155 @@
#include <dirent.h>
#include <unistd.h>
#include "FileOperations/fileops.h"
#include "menus.h"
#include "wpad.h"
#include "fatmounter.h"
#include "usbloader/wbfs.h"
#include "xml/xml.h"
extern int load_from_fs;
extern char game_partition[6];
extern PartList partitions;
static int FindGamesPartition(PartList * partitions)
{
if (partitions->wbfs_n != 0)
{
WBFS_Open();
for (int p = 0; p < partitions->num; p++)
{
if (partitions->pinfo[p].fs_type == FS_TYPE_WBFS)
{
Settings.partition = p;
load_from_fs = PART_FS_WBFS;
return 0;
}
}
}
// Loop through FAT/NTFS partitions, and find the first partition with games on it (if there is one)
for (int i = 0; i < partitions->num; i++)
{
if (partitions->pinfo[i].fs_type == FS_TYPE_FAT32 || partitions->pinfo[i].fs_type == FS_TYPE_NTFS)
{
if (!WBFS_OpenPart(partitions->pinfo[i].part_fs, partitions->pinfo[i].index,
partitions->pentry[i].sector, partitions->pentry[i].size, (char *) &game_partition))
{
u32 count;
// Get the game count...
WBFS_GetCount(&count);
if (count > 0)
{
load_from_fs = partitions->pinfo[i].part_fs;
Settings.partition = i;
return 0;
}
else
{
WBFS_Close();
}
}
}
}
return -1;
}
static int PartitionChoice()
{
int ret = -1;
int choice = WindowPrompt(tr( "No WBFS or FAT/NTFS partition found" ),
tr( "You need to select or format a partition" ), tr( "Select" ), tr( "Format" ), tr( "Return" ));
if (choice == 0)
{
Sys_LoadMenu();
}
else if(choice == 1)
{
int part_num = SelectPartitionMenu();
if(part_num >= 0)
{
ret = WBFS_OpenPart(partitions.pinfo[part_num].part_fs, partitions.pinfo[part_num].index, partitions.pentry[part_num].sector, partitions.pentry[part_num].size, (char *) &game_partition);
load_from_fs = partitions.pinfo[part_num].part_fs;
Settings.partition = part_num;
Settings.Save();
}
}
else if(choice == 2)
{
while(ret < 0 || ret == -666)
{
int part_num = SelectPartitionMenu();
if(part_num >= 0)
ret = FormatingPartition(tr( "Formatting, please wait..." ), &partitions.pentry[part_num]);
}
}
return ret;
}
/****************************************************************************
* MountGamePartition
***************************************************************************/
int MountGamePartition(bool ShowGUI)
{
gprintf("MenuCheck()\n");
s32 wbfsinit = MountWBFS(ShowGUI);
if (wbfsinit < 0)
{
WindowPrompt(tr( "Error !" ), tr( "USB Device not found" ), tr( "OK" ));
Sys_LoadMenu();
}
s32 ret = -1;
memset(game_partition, 0, 6);
load_from_fs = -1;
// Added for slow HDD
for (int retries = 10; retries > 0; retries--)
{
if (Partition_GetList(WBFS_DEVICE_USB, &partitions) != 0)
break;
}
if (Settings.partition != -1 && partitions.num > Settings.partition)
{
PartInfo pinfo = partitions.pinfo[Settings.partition];
if (!WBFS_OpenPart(pinfo.part_fs, pinfo.index, partitions.pentry[Settings.partition].sector,
partitions.pentry[Settings.partition].size, (char *) &game_partition))
{
ret = 0;
load_from_fs = pinfo.part_fs;
}
}
if(ret < 0)
ret = FindGamesPartition(&partitions);
if (ret < 0 && ShowGUI)
ret = PartitionChoice();
if(ret < 0)
Sys_LoadMenu();
ret = Disc_Init();
if (ret < 0)
{
if(ShowGUI)
WindowPrompt(tr( "Error !" ), tr( "Could not initialize DIP module!" ), tr( "OK" ));
Sys_LoadMenu();
}
// open database if needed, load titles if needed
if (CheckFile(Settings.titlestxt_path))
OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN, true, Settings.titlesOverride == 1 ? true : false, true);
return ret;
}

View File

@ -1,195 +0,0 @@
#include <dirent.h>
#include <unistd.h>
#include "menus.h"
#include "wpad.h"
#include "fatmounter.h"
#include "usbloader/wbfs.h"
#include "xml/xml.h"
extern int load_from_fs;
extern char game_partition[6];
extern char headlessID[8];
/****************************************************************************
* MenuCheck
***************************************************************************/
int MenuCheck()
{
gprintf("MenuCheck()\n");
int menu = MENU_NONE;
int i = 0;
int choice;
s32 ret2, wbfsinit;
OptionList options;
options.length = i;
VIDEO_WaitVSync();
wbfsinit = WBFS_Init(WBFS_DEVICE_USB);
if (wbfsinit < 0)
{
ret2 = WindowPrompt(tr( "No USB Device found." ), tr( "Do you want to retry for 30 secs?" ), "cIOS249",
"cIOS222", tr( "Back to Wii Menu" ));
SDCard_deInit();
USBDevice_deInit();
WPAD_Flush(0);
WPAD_Disconnect(0);
WPAD_Shutdown();
if (ret2 == 1)
{
Settings.cios = 249;
}
else if (ret2 == 2)
{
Settings.cios = 222;
}
else
{
Sys_LoadMenu();
}
ret2 = DiscWait(tr( "No USB Device" ), tr( "Waiting for USB Device" ), 0, 0, 1);
//reinitialize SD and USB
Wpad_Init();
WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR);
WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);
if (ret2 < 0)
{
WindowPrompt(tr( "Error !" ), tr( "USB Device not found" ), tr( "OK" ));
Sys_LoadMenu();
}
}
ret2 = -1;
memset(game_partition, 0, 6);
load_from_fs = -1;
extern PartList partitions;
// Added for slow HDD
for (int runs = 0; runs < 10; runs++)
{
if (Partition_GetList(WBFS_DEVICE_USB, &partitions) != 0)
{
sleep(1);
continue;
}
if (Settings.partition != -1 && partitions.num > Settings.partition)
{
PartInfo pinfo = partitions.pinfo[Settings.partition];
if (!WBFS_OpenPart(pinfo.part_fs, pinfo.index, partitions.pentry[Settings.partition].sector,
partitions.pentry[Settings.partition].size, (char *) &game_partition))
{
ret2 = 0;
load_from_fs = pinfo.part_fs;
break;
}
}
if (partitions.wbfs_n != 0)
{
ret2 = WBFS_Open();
for (int p = 0; p < partitions.num; p++)
{
if (partitions.pinfo[p].fs_type == FS_TYPE_WBFS)
{
Settings.partition = p;
load_from_fs = PART_FS_WBFS;
break;
}
}
}
else if (Sys_IsHermes() && (partitions.fat_n != 0 || partitions.ntfs_n != 0))
{
// Loop through FAT/NTFS partitions, and find the first partition with games on it (if there is one)
u32 count;
for (int i = 0; i < partitions.num; i++)
{
if (partitions.pinfo[i].fs_type == FS_TYPE_FAT32 || partitions.pinfo[i].fs_type == FS_TYPE_NTFS)
{
if (!WBFS_OpenPart(partitions.pinfo[i].part_fs, partitions.pinfo[i].index,
partitions.pentry[i].sector, partitions.pentry[i].size, (char *) &game_partition))
{
// Get the game count...
WBFS_GetCount(&count);
if (count > 0)
{
load_from_fs = partitions.pinfo[i].part_fs;
Settings.partition = i;
break;
}
else
{
WBFS_Close();
}
}
}
}
}
if ((ret2 >= 0 || load_from_fs != PART_FS_WBFS) && isInserted(Settings.BootDevice))
{
Settings.Save();
break;
}
sleep(1);
}
if (ret2 < 0 && load_from_fs != PART_FS_WBFS)
{
choice = WindowPrompt(tr( "No WBFS or FAT/NTFS partition found" ),
tr( "You need to select or format a partition" ), tr( "Select" ), tr( "Format" ), tr( "Return" ));
if (choice == 0)
{
Sys_LoadMenu();
}
else
{
load_from_fs = choice == 1 ? PART_FS_FAT : PART_FS_WBFS;
menu = MENU_FORMAT;
}
}
ret2 = Disc_Init();
if (ret2 < 0)
{
WindowPrompt(tr( "Error !" ), tr( "Could not initialize DIP module!" ), tr( "OK" ));
Sys_LoadMenu();
}
if (shutdown == 1) Sys_Shutdown();
if (reset == 1) Sys_Reboot();
if (wbfsinit < 0)
{
sleep(1);
}
// open database if needed, load titles if needed
if (isInserted(Settings.BootDevice)) OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN,
true, Settings.titlesOverride == 1 ? true : false, true);
// titles.txt loaded after database to override database titles with custom titles
//snprintf(pathname, sizeof(pathname), "%stitles.txt", Settings.titlestxt_path);
//cfg_parsefile(pathname, &title_set);
//Spieleliste laden
//__Menu_GetEntries(0);//no point getting the gamelist here
if (strcmp(headlessID, "") != 0) menu = MENU_EXIT;
if (menu == MENU_NONE) menu = MENU_DISCLIST;
//for HDDs with issues
if (wbfsinit < 0)
{
sleep(1);
USBDevice_Init();
SDCard_Init();
}
return menu;
}

View File

@ -1446,7 +1446,7 @@ int MenuDiscList()
{
sprintf(nipple, "%s %s", nipple, tr( "does not exist!" ));
WindowPrompt(tr( "Error" ), nipple, tr( "OK" ));
menu = MENU_CHECK;
menu = MENU_DISCLIST;
wiilight(0);
break;
}
@ -1508,7 +1508,7 @@ int MenuDiscList()
gprintf("\n\tTried to load alt dol that isn't there");
sprintf(nipple, "%s %s", nipple, tr( "does not exist! You Messed something up, Idiot." ));
WindowPrompt(tr( "Error" ), nipple, tr( "OK" ));
menu = MENU_CHECK;
menu = MENU_DISCLIST;
wiilight(0);
break;
}

View File

@ -1,210 +1,136 @@
#include <unistd.h>
#include "menus.h"
#include "fatmounter.h"
#include "usbloader/usbstorage2.h"
#include "usbloader/utils.h"
#include "usbloader/wbfs.h"
#include "libwiigui/gui_customoptionbrowser.h"
#include "themes/CTheme.h"
extern int load_from_fs;
extern char game_partition[6];
/****************************************************************************
* MenuFormat
***************************************************************************/
int MenuFormat()
{
USBDevice_deInit();
sleep(1);
USBStorage2_Init();
int menu = MENU_NONE;
customOptionList options(MAX_PARTITIONS_EX);
extern PartList partitions;
u32 cnt, counter = 0;
int choice, ret;
char text[ISFS_MAXPATH];
//create the partitionlist
for (cnt = 0; cnt < (u32) partitions.num; cnt++)
{
partitionEntry *entry = &partitions.pentry[cnt];
/* Calculate size in gigabytes */
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" ));
}
counter++;
}
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);
GuiImageData btnpwroff(Resources::GetFile("wiimote_poweroff.png"), Resources::GetFileSize("wiimote_poweroff.png"));
GuiImageData btnpwroffOver(Resources::GetFile("wiimote_poweroff_over.png"), Resources::GetFileSize("wiimote_poweroff_over.png"));
GuiImageData btnhome(Resources::GetFile("menu_button.png"), Resources::GetFileSize("menu_button.png"));
GuiImageData btnhomeOver(Resources::GetFile("menu_button_over.png"), Resources::GetFileSize("menu_button_over.png"));
GuiImageData battery(Resources::GetFile("battery.png"), Resources::GetFileSize("battery.png"));
GuiImageData batteryBar(Resources::GetFile("battery_bar.png"), Resources::GetFileSize("battery_bar.png"));
GuiImageData batteryRed(Resources::GetFile("battery_red.png"), Resources::GetFileSize("battery_red.png"));
GuiImageData batteryBarRed(Resources::GetFile("battery_bar_red.png"), Resources::GetFileSize("battery_bar_red.png"));
GuiTrigger trigA;
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
GuiTrigger trigHome;
trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0);
GuiImage poweroffBtnImg(&btnpwroff);
GuiImage poweroffBtnImgOver(&btnpwroffOver);
poweroffBtnImg.SetWidescreen(Settings.widescreen);
poweroffBtnImgOver.SetWidescreen(Settings.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(Settings.widescreen);
exitBtnImgOver.SetWidescreen(Settings.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, "bg_options_settings.png", 0, 10);
optionBrowser.SetPosition(0, 40);
optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
HaltGui();
GuiWindow w(screenwidth, screenheight);
w.Append(&poweroffBtn);
w.Append(&exitBtn);
mainWindow->Append(&w);
mainWindow->Append(&optionBrowser);
ResumeGui();
while (menu == MENU_NONE)
{
VIDEO_WaitVSync();
ret = optionBrowser.GetClickedOption();
if (ret >= 0)
{
if (Settings.godmode == 1)
{
partitionEntry *entry = &partitions.pentry[ret];
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;
Settings.Save();
}
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);
char entered[20] = "";
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" ));
Settings.godmode = 1;
}
}
else
{
WindowPrompt(tr( "Wrong Password" ), tr( "USB Loader GX is protected" ), tr( "OK" ));
}
}
}
}
}
if (shutdown == 1) Sys_Shutdown();
if (reset == 1) Sys_Reboot();
if (poweroffBtn.GetState() == STATE_CLICKED)
{
choice = WindowPrompt(tr( "Shutdown System" ), tr( "Are you sure?" ), tr( "Yes" ), tr( "No" ));
if (choice == 1)
{
Sys_Shutdown();
}
}
else if (exitBtn.GetState() == STATE_CLICKED)
{
choice = WindowPrompt(tr( "Return to Wii Menu" ), tr( "Are you sure?" ), tr( "Yes" ), tr( "No" ));
if (choice == 1)
{
Sys_LoadMenu();
}
}
}
HaltGui();
mainWindow->Remove(&optionBrowser);
mainWindow->Remove(&w);
ResumeGui();
return menu;
}
#include <unistd.h>
#include "menus.h"
#include "fatmounter.h"
#include "usbloader/usbstorage2.h"
#include "usbloader/utils.h"
#include "usbloader/wbfs.h"
#include "libwiigui/gui_customoptionbrowser.h"
#include "themes/CTheme.h"
extern PartList partitions;
/****************************************************************************
* SelectPartitionMenu
***************************************************************************/
int SelectPartitionMenu()
{
bool ExitSelect = false;
customOptionList options(MAX_PARTITIONS_EX);
u32 cnt, counter = 0;
int choice = -1;
int ret = -1;
//create the partitionlist
for (cnt = 0; cnt < (u32) partitions.num; cnt++)
{
partitionEntry *entry = &partitions.pentry[cnt];
/* Calculate size in gigabytes */
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" ));
}
counter++;
}
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);
GuiImageData btnpwroff(Resources::GetFile("wiimote_poweroff.png"), Resources::GetFileSize("wiimote_poweroff.png"));
GuiImageData btnpwroffOver(Resources::GetFile("wiimote_poweroff_over.png"), Resources::GetFileSize("wiimote_poweroff_over.png"));
GuiImageData btnhome(Resources::GetFile("menu_button.png"), Resources::GetFileSize("menu_button.png"));
GuiImageData btnhomeOver(Resources::GetFile("menu_button_over.png"), Resources::GetFileSize("menu_button_over.png"));
GuiImageData battery(Resources::GetFile("battery.png"), Resources::GetFileSize("battery.png"));
GuiImageData batteryBar(Resources::GetFile("battery_bar.png"), Resources::GetFileSize("battery_bar.png"));
GuiImageData batteryRed(Resources::GetFile("battery_red.png"), Resources::GetFileSize("battery_red.png"));
GuiImageData batteryBarRed(Resources::GetFile("battery_bar_red.png"), Resources::GetFileSize("battery_bar_red.png"));
GuiTrigger trigA;
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
GuiTrigger trigHome;
trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0);
GuiImage poweroffBtnImg(&btnpwroff);
GuiImage poweroffBtnImgOver(&btnpwroffOver);
poweroffBtnImg.SetWidescreen(Settings.widescreen);
poweroffBtnImgOver.SetWidescreen(Settings.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(Settings.widescreen);
exitBtnImgOver.SetWidescreen(Settings.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, "bg_options_settings.png", 0, 10);
optionBrowser.SetPosition(0, 40);
optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
HaltGui();
GuiWindow w(screenwidth, screenheight);
w.Append(&poweroffBtn);
w.Append(&exitBtn);
mainWindow->Append(&w);
mainWindow->Append(&optionBrowser);
ResumeGui();
while (!ExitSelect)
{
VIDEO_WaitVSync();
if (shutdown)
Sys_Shutdown();
if (reset)
Sys_Reboot();
ret = optionBrowser.GetClickedOption();
if (ret >= 0)
{
partitionEntry *entry = &partitions.pentry[ret];
if (entry->size)
{
choice = ret;
ExitSelect = true;
}
}
if (poweroffBtn.GetState() == STATE_CLICKED)
{
choice = WindowPrompt(tr( "Shutdown System" ), tr( "Are you sure?" ), tr( "Yes" ), tr( "No" ));
if (choice == 1)
Sys_Shutdown();
}
else if (exitBtn.GetState() == STATE_CLICKED)
{
choice = WindowPrompt(tr( "Return to Wii Menu" ), tr( "Are you sure?" ), tr( "Yes" ), tr( "No" ));
if (choice == 1)
Sys_LoadMenu();
}
}
HaltGui();
mainWindow->Remove(&optionBrowser);
mainWindow->Remove(&w);
ResumeGui();
return choice;
}

View File

@ -1,25 +1,25 @@
#ifndef _MENUS_H
#define _MENUS_H
#include "libwiigui/gui.h"
#include "libwiigui/gui_bgm.h"
#include "language/gettext.h"
#include "prompts/PromptWindows.h"
#include "menu.h"
#include "gecko.h"
#include "filelist.h"
#include "sys.h"
extern void ResumeGui();
extern void HaltGui();
extern GuiWindow * mainWindow;
extern GuiBGM * bgMusic;
extern u8 shutdown;
extern u8 reset;
int MenuInstall();
int MenuDiscList();
int MenuFormat();
int MenuCheck();
#endif // _MENUS_H
#ifndef _MENUS_H
#define _MENUS_H
#include "libwiigui/gui.h"
#include "libwiigui/gui_bgm.h"
#include "language/gettext.h"
#include "prompts/PromptWindows.h"
#include "menu.h"
#include "gecko.h"
#include "filelist.h"
#include "sys.h"
extern void ResumeGui();
extern void HaltGui();
extern GuiWindow * mainWindow;
extern GuiBGM * bgMusic;
extern u8 shutdown;
extern u8 reset;
int MenuInstall();
int MenuDiscList();
int SelectPartitionMenu();
int MountGamePartition(bool ShowGUI = true);
#endif // _MENUS_H

View File

@ -12,6 +12,7 @@
#include "usbloader/partition_usbloader.h"
#include "usbloader/usbstorage2.h"
#include "usbloader/GameList.h"
#include "usbloader/utils.h"
#include "language/gettext.h"
#include "libwiigui/gui.h"
#include "libwiigui/gui_diskcover.h"
@ -1902,13 +1903,13 @@ int DiscWait(const char *title, const char *msg, const char *btn1Label, const ch
{
VIDEO_WaitVSync();
timerTxt.SetTextf("%u %s", i, tr( "seconds left" ));
sleep(1);
USBDevice_deInit();
USBDevice_Init();
ret = WBFS_Init(WBFS_DEVICE_USB);
if (ret >= 0) break;
i--;
sleep(1);
}
}
else
@ -1941,6 +1942,14 @@ int DiscWait(const char *title, const char *msg, const char *btn1Label, const ch
***************************************************************************/
int FormatingPartition(const char *title, partitionEntry *entry)
{
extern PartList partitions;
char text[255];
sprintf(text, "%s: %.2fGB", tr( "Partition" ), entry->size * (partitions.sector_size / GB_SIZE));
int choice = WindowPrompt(tr( "Do you want to format:" ), text, tr( "Yes" ), tr( "No" ));
if (choice == 0)
return -666;
int ret;
GuiWindow promptWindow(472, 320);
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
@ -1975,6 +1984,23 @@ int FormatingPartition(const char *title, partitionEntry *entry)
VIDEO_WaitVSync();
ret = WBFS_Format(entry->sector, entry->size);
if (ret < 0)
{
WindowPrompt(tr( "Error !" ), tr( "Failed formating" ), tr( "Return" ));
}
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();
}
}
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0)
usleep(50);

View File

@ -56,6 +56,17 @@ struct discHdr * GameList::at(int i)
return FilteredList[i];
}
struct discHdr * GameList::GetDiscHeader(const char * gameID)
{
for (u32 i = 0; i < FilteredList.size(); ++i)
{
if(strncasecmp(gameID, (const char *) FilteredList[i]->id, 6) == 0)
return FilteredList[i];
}
return NULL;
}
int GameList::ReadGameList()
{
FullGameList.clear();

View File

@ -10,34 +10,15 @@ class GameList
public:
GameList();
int ReadGameList();
int size()
{
return FilteredList.size();
}
;
int GameCount()
{
return FullGameList.size();
}
;
int size() { return FilteredList.size(); };
int GameCount() { return FullGameList.size(); };
int FilterList(const wchar_t * gameFilter = NULL);
int LoadUnfiltered();
struct discHdr * at(int i);
struct discHdr * operator[](int i)
{
return at(i);
}
;
const wchar_t * GetCurrentFilter()
{
return GameFilter.c_str();
}
;
const wchar_t * GetAvailableSearchChars()
{
return AvailableSearchChars.c_str();
}
;
struct discHdr * operator[](int i) { return at(i); };
struct discHdr * GetDiscHeader(const char * gameID);
const wchar_t * GetCurrentFilter() { return GameFilter.c_str(); };
const wchar_t * GetAvailableSearchChars() { return AvailableSearchChars.c_str(); };
void SortList();
void clear();
protected:

View File

@ -12,6 +12,7 @@
#include "usbloader/partition_usbloader.h"
#include "usbloader/GameList.h"
#include "menu/menus.h"
#include "gecko.h"
Wbfs *current = NULL;
@ -301,8 +302,11 @@ bool WBFS_ShowFreeSpace(void)
return current->ShowFreeSpace();
}
int MountWBFS()
int MountWBFS(bool ShowGUI)
{
if(ShowGUI)
return DiscWait(tr( "Waiting for USB Device" ), 0, 0, 0, 1);
int ret = -1;
time_t currTime = time(0);

View File

@ -55,7 +55,7 @@ extern "C"
bool WBFS_Close();
bool WBFS_Mounted();
bool WBFS_Selected();
int MountWBFS();
int MountWBFS(bool ShowGUI);
#ifdef __cplusplus
}