*Fixed InstallProgress to show size and speed again

*Added intern GameTitle rename for .wbfs files on FAT32
*Added intern GameID change for .wbfs files on FAT32
This commit is contained in:
dimok321 2009-11-22 14:09:08 +00:00
parent b4b5b5389c
commit b70af2d71d
7 changed files with 229 additions and 171 deletions

View File

@ -2,8 +2,8 @@
<app version="1">
<name> USB Loader GX</name>
<coder>USB Loader GX Team</coder>
<version>1.0 r840</version>
<release_date>200911212330</release_date>
<version>1.0 r841</version>
<release_date>200911221220</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.

File diff suppressed because one or more lines are too long

View File

@ -39,7 +39,6 @@ GuiSound * bgMusic = NULL;
GuiSound *btnClick2 = NULL;
struct discHdr *dvdheader = NULL;
float gamesize;
int currentMenu;
u8 mountMethod=0;
@ -372,7 +371,7 @@ int MainMenu(int menu) {
struct discHdr *header = (mountMethod?dvdheader:&gameList[gameSelected]);
struct Game_CFG* game_cfg = CFG_get_game_opt(header->id);
if (game_cfg) {
videoChoice = game_cfg->video;
languageChoice = game_cfg->language;
@ -593,7 +592,7 @@ int MainMenu(int menu) {
if (ret < 0) {
Sys_LoadMenu();
}
printf("Returning entry point: 0x%0x\n", ret);
}

View File

@ -1,154 +1,156 @@
#include "menus.h"
#include "usbloader/usbstorage.h"
#include "usbloader/wbfs.h"
#include "usbloader/disc.h"
#include "usbloader/utils.h"
#include "usbloader/getentries.h"
#include "prompts/ProgressWindow.h"
/****************************************************************************
* MenuInstall
***************************************************************************/
int MenuInstall() {
gprintf("\nMenuInstall()");
int menu = MENU_NONE;
static struct discHdr headerdisc ATTRIBUTE_ALIGN(32);
Disc_SetUSB(NULL);
int ret, choice = 0;
char name[200];
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
char imgPath[100];
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);
HaltGui();
GuiWindow w(screenwidth, screenheight);
mainWindow->Append(&w);
ResumeGui();
while (menu == MENU_NONE) {
VIDEO_WaitVSync ();
ret = DiscWait(tr("Insert Disk"),tr("Waiting..."),tr("Cancel"),0,0);
if (ret < 0) {
WindowPrompt (tr("Error reading Disc"),0,tr("Back"));
menu = MENU_DISCLIST;
break;
}
ret = Disc_Open();
if (ret < 0) {
WindowPrompt (tr("Could not open Disc"),0,tr("Back"));
menu = MENU_DISCLIST;
break;
}
ret = Disc_IsWii();
if (ret < 0) {
choice = WindowPrompt (tr("Not a Wii Disc"),tr("Insert a Wii Disc!"),tr("OK"),tr("Back"));
if (choice == 1) {
menu = MENU_INSTALL;
break;
} else
menu = MENU_DISCLIST;
break;
}
Disc_ReadHeader(&headerdisc);
snprintf(name, sizeof(name), "%s", headerdisc.title);
ret = WBFS_CheckGame(headerdisc.id);
if (ret) {
WindowPrompt (tr("Game is already installed:"),name,tr("Back"));
menu = MENU_DISCLIST;
break;
}
f32 freespace, used;
WBFS_DiskSpace(&used, &freespace);
float gamesize = WBFS_EstimeGameSize()/GB_SIZE;
char gametxt[50];
sprintf(gametxt, "%s : %.2fGB", name, gamesize);
wiilight(1);
choice = WindowPrompt(tr("Continue to install game?"),gametxt,tr("OK"),tr("Cancel"));
if (choice == 1) {
sprintf(gametxt, "%s", tr("Installing game:"));
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"));
menu = MENU_DISCLIST;
break;
} else {
USBStorage_Watchdog(0);
SetupGameInstallProgress(gametxt, name);
ret = WBFS_AddGame();
ProgressStop();
USBStorage_Watchdog(1);
wiilight(0);
if (ret != 0) {
WindowPrompt(tr("Install Error!"),0,tr("Back"));
menu = MENU_DISCLIST;
break;
} else {
__Menu_GetEntries(); //get the entries again
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();
menu = MENU_DISCLIST;
break;
}
}
} else {
menu = MENU_DISCLIST;
break;
}
if (shutdown == 1) {
wiilight(0);
Sys_Shutdown();
}
if (reset == 1) {
wiilight(0);
Sys_Reboot();
}
}
//Turn off the WiiLight
wiilight(0);
HaltGui();
mainWindow->Remove(&w);
ResumeGui();
return menu;
}
#include "menus.h"
#include "usbloader/usbstorage.h"
#include "usbloader/wbfs.h"
#include "usbloader/disc.h"
#include "usbloader/utils.h"
#include "usbloader/getentries.h"
#include "prompts/ProgressWindow.h"
float gamesize;
/****************************************************************************
* MenuInstall
***************************************************************************/
int MenuInstall() {
gprintf("\nMenuInstall()");
int menu = MENU_NONE;
static struct discHdr headerdisc ATTRIBUTE_ALIGN(32);
Disc_SetUSB(NULL);
int ret, choice = 0;
char name[200];
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
char imgPath[100];
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);
HaltGui();
GuiWindow w(screenwidth, screenheight);
mainWindow->Append(&w);
ResumeGui();
while (menu == MENU_NONE) {
VIDEO_WaitVSync ();
ret = DiscWait(tr("Insert Disk"),tr("Waiting..."),tr("Cancel"),0,0);
if (ret < 0) {
WindowPrompt (tr("Error reading Disc"),0,tr("Back"));
menu = MENU_DISCLIST;
break;
}
ret = Disc_Open();
if (ret < 0) {
WindowPrompt (tr("Could not open Disc"),0,tr("Back"));
menu = MENU_DISCLIST;
break;
}
ret = Disc_IsWii();
if (ret < 0) {
choice = WindowPrompt (tr("Not a Wii Disc"),tr("Insert a Wii Disc!"),tr("OK"),tr("Back"));
if (choice == 1) {
menu = MENU_INSTALL;
break;
} else
menu = MENU_DISCLIST;
break;
}
Disc_ReadHeader(&headerdisc);
snprintf(name, sizeof(name), "%s", headerdisc.title);
ret = WBFS_CheckGame(headerdisc.id);
if (ret) {
WindowPrompt (tr("Game is already installed:"),name,tr("Back"));
menu = MENU_DISCLIST;
break;
}
f32 freespace, used;
WBFS_DiskSpace(&used, &freespace);
gamesize = WBFS_EstimeGameSize()/GB_SIZE;
char gametxt[50];
sprintf(gametxt, "%s : %.2fGB", name, gamesize);
wiilight(1);
choice = WindowPrompt(tr("Continue to install game?"),gametxt,tr("OK"),tr("Cancel"));
if (choice == 1) {
sprintf(gametxt, "%s", tr("Installing game:"));
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"));
menu = MENU_DISCLIST;
break;
} else {
USBStorage_Watchdog(0);
SetupGameInstallProgress(gametxt, name);
ret = WBFS_AddGame();
ProgressStop();
USBStorage_Watchdog(1);
wiilight(0);
if (ret != 0) {
WindowPrompt(tr("Install Error!"),0,tr("Back"));
menu = MENU_DISCLIST;
break;
} else {
__Menu_GetEntries(); //get the entries again
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();
menu = MENU_DISCLIST;
break;
}
}
} else {
menu = MENU_DISCLIST;
break;
}
if (shutdown == 1) {
wiilight(0);
Sys_Shutdown();
}
if (reset == 1) {
wiilight(0);
Sys_Reboot();
}
}
//Turn off the WiiLight
wiilight(0);
HaltGui();
mainWindow->Remove(&w);
ResumeGui();
return menu;
}

View File

@ -305,7 +305,7 @@ s32 WBFS_OpenPart(u32 part_fat, u32 part_idx, u32 part_lba, u32 part_size, char
wbfs_part_fat = part_fat;
wbfs_part_idx = part_idx;
wbfs_part_lba = part_lba;
sprintf(partition, "%s%d", wbfs_part_fat ? "FAT" : "WBFS", wbfs_part_idx);
return 0;
}
@ -551,8 +551,12 @@ s32 WBFS_DiskSpace(f32 *used, f32 *free) {
return 0;
}
s32 WBFS_RenameGame(u8 *discid, const void *newname) {
if (wbfs_part_fat) return -1;
s32 WBFS_RenameGame(u8 *discid, const void *newname)
{
if (wbfs_part_fat)
{
return WBFS_FAT_RenameGame(discid, newname);
}
s32 ret;
@ -566,8 +570,12 @@ s32 WBFS_RenameGame(u8 *discid, const void *newname) {
return 0;
}
s32 WBFS_ReIDGame(u8 *discid, const void *newID) {
if (wbfs_part_fat) return -1;
s32 WBFS_ReIDGame(u8 *discid, const void *newID)
{
if (wbfs_part_fat)
{
return WBFS_FAT_ReIDGame(discid, newID);
}
s32 ret;

View File

@ -100,21 +100,21 @@ s32 _WBFS_FAT_GetHeadersCount(void *outbuf, u32 *count, u32 len)
cnt++;
continue;
}
// no title found, read it from wbfs file directly
FILE *fp = fopen(path, "rb");
if (fp != NULL) {
fseek(fp, 512, SEEK_SET);
fread(&tmpHdr, sizeof(struct discHdr), 1, fp);
fclose(fp);
if (tmpHdr.magic == 0x5D1C9EA3 && (memcmp(tmpHdr.id, id, 6) == 0)) {
memcpy(ptr, &tmpHdr, hdrsize);
cnt++;
continue;
}
}
// no title found, read it from wbfs file
// but this is a little bit slower
// open 'partition' file
@ -217,7 +217,7 @@ wbfs_t* WBFS_FAT_OpenPart(u8 *id)
if (ret) return NULL;
part = wbfs_open_partition(
split_read_sector,
nop_write_sector, //readonly //split_write_sector,
split_write_sector, //readonly //split_write_sector,
&split, fat_sector_size, split.total_sec, 0, 0);
if (!part) {
split_close(&split);
@ -272,7 +272,7 @@ s32 WBFS_FAT_RemoveGame(u8 *discid)
WBFS_FAT_fname(discid, fname, sizeof(fname));
split_create(&split, fname, 0, 0, true);
split_close(&split);
// Reset FAT stats
wbfs_fat_vfs_have = 0;
return 0;
@ -315,7 +315,7 @@ s32 WBFS_FAT_DVD_Size(u64 *comp_size, u64 *real_size)
wbfs_t *part = NULL;
u64 size = (u64)143432*2*0x8000ULL;
u32 n_sector = size / fat_sector_size;
u32 wii_sec_sz;
u32 wii_sec_sz;
// init a temporary dummy part
// as a placeholder for wbfs_size_disc
@ -337,3 +337,50 @@ s32 WBFS_FAT_DVD_Size(u64 *comp_size, u64 *real_size)
return 0;
}
s32 WBFS_FAT_RenameGame(u8 *discid, const void *newname)
{
wbfs_t *part = WBFS_FAT_OpenPart(discid);
if (!part)
return -1;
s32 ret = wbfs_ren_disc(part, discid,(u8*)newname);
WBFS_FAT_ClosePart(part);
return ret;
}
s32 WBFS_FAT_ReIDGame(u8 *discid, const void *newID)
{
wbfs_t *part = WBFS_FAT_OpenPart(discid);
if (!part)
return -1;
s32 ret = wbfs_rID_disc(part, discid,(u8*)newID);
WBFS_FAT_ClosePart(part);
if(ret == 0)
{
char fname[100];
char fnamenew[100];
s32 cnt = 0x31;
WBFS_FAT_fname(discid, fname, sizeof(fname));
WBFS_FAT_fname((u8*) newID, fnamenew, sizeof(fnamenew));
int stringlength = strlen(fname);
while(rename(fname, fnamenew) == 0)
{
fname[stringlength] = cnt;
fname[stringlength+1] = 0;
fnamenew[stringlength] = cnt;
fnamenew[stringlength+1] = 0;
cnt++;
}
}
return ret;
}

View File

@ -11,5 +11,7 @@ s32 WBFS_FAT_DiskSpace(f32 *used, f32 *free);
s32 WBFS_FAT_RemoveGame(u8 *discid);
s32 WBFS_FAT_AddGame(void);
s32 WBFS_FAT_DVD_Size(u64 *comp_size, u64 *real_size);
s32 WBFS_FAT_RenameGame(u8 *discid, const void *newname);
s32 WBFS_FAT_ReIDGame(u8 *discid, const void *newID);
#endif