mirror of
https://github.com/wiidev/usbloadergx.git
synced 2025-01-11 03:09:08 +01:00
*Changed whole GameInstall ProgressWindow behaviour
This should fix the weird freezes and crashes while installing. The ProgressWindow is now in its own thread and updates the values fast again. *Added Speed to InstallProgressWindow Lets see who got the fastest WiiDiskDrive :P (i got up to 5.8MB/s)
This commit is contained in:
parent
a8cde60913
commit
79a7fd9017
File diff suppressed because one or more lines are too long
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "libwbfs.h"
|
#include "libwbfs.h"
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#define likely(x) __builtin_expect(!!(x), 1)
|
#define likely(x) __builtin_expect(!!(x), 1)
|
||||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||||
@ -406,8 +405,6 @@ u32 wbfs_add_disc(wbfs_t*p,read_wiidisc_callback_t read_src_wii_disc,
|
|||||||
wbfs_disc_info_t *info = 0;
|
wbfs_disc_info_t *info = 0;
|
||||||
u8* copy_buffer = 0;
|
u8* copy_buffer = 0;
|
||||||
used = wbfs_malloc(p->n_wii_sec_per_disc);
|
used = wbfs_malloc(p->n_wii_sec_per_disc);
|
||||||
time_t last_time = 0;
|
|
||||||
time_t time_now = 0;
|
|
||||||
if(!used)
|
if(!used)
|
||||||
ERROR("unable to alloc memory");
|
ERROR("unable to alloc memory");
|
||||||
if(!copy_1_1)
|
if(!copy_1_1)
|
||||||
@ -464,17 +461,8 @@ u32 wbfs_add_disc(wbfs_t*p,read_wiidisc_callback_t read_src_wii_disc,
|
|||||||
p->write_hdsector(p->callback_data,p->part_lba+bl*(p->wbfs_sec_sz/p->hd_sec_sz)+j*(p->wii_sec_sz/p->hd_sec_sz),
|
p->write_hdsector(p->callback_data,p->part_lba+bl*(p->wbfs_sec_sz/p->hd_sec_sz)+j*(p->wii_sec_sz/p->hd_sec_sz),
|
||||||
p->wii_sec_sz/p->hd_sec_sz,copy_buffer);
|
p->wii_sec_sz/p->hd_sec_sz,copy_buffer);
|
||||||
cur++;
|
cur++;
|
||||||
}
|
if(spinner)
|
||||||
if(spinner) {
|
spinner(cur,tot);
|
||||||
if(last_time == 0)
|
|
||||||
time(&last_time);
|
|
||||||
|
|
||||||
time(&time_now);
|
|
||||||
/* Update that crap only every 0.5 secs */
|
|
||||||
if (difftime(time_now,last_time) > 0.5) {
|
|
||||||
spinner(cur,tot);
|
|
||||||
last_time = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info->wlba_table[i] = wbfs_htons(bl);
|
info->wlba_table[i] = wbfs_htons(bl);
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
#include "wpad.h"
|
#include "wpad.h"
|
||||||
#include "fat.h"
|
#include "fat.h"
|
||||||
|
|
||||||
|
//#define SPECIAL_FOR_ARDI // Fix Problem with Trekstor Classic 250GB
|
||||||
|
|
||||||
/* Constants */
|
/* Constants */
|
||||||
#define CONSOLE_XCOORD 260
|
#define CONSOLE_XCOORD 260
|
||||||
#define CONSOLE_YCOORD 115
|
#define CONSOLE_YCOORD 115
|
||||||
@ -46,7 +48,22 @@ int
|
|||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
s32 ret2;
|
s32 ret2;
|
||||||
|
u8 preloaded_ios = 0;
|
||||||
|
#ifdef SPECIAL_FOR_ARDI
|
||||||
|
if( (ret2 = IOS_ReloadIOS(249)) >=0 )
|
||||||
|
preloaded_ios = 249;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( (ret2 = IOS_ReloadIOS(222)) >=0 )
|
||||||
|
{
|
||||||
|
load_ehc_module();
|
||||||
|
preloaded_ios = 222;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SDCard_Init(); // mount SD for loading cfg's
|
||||||
|
USBDevice_Init(); // and mount USB:/
|
||||||
bool bootDevice_found=false;
|
bool bootDevice_found=false;
|
||||||
if(argc >= 1)
|
if(argc >= 1)
|
||||||
{
|
{
|
||||||
@ -66,49 +83,33 @@ main(int argc, char *argv[])
|
|||||||
strcpy(bootDevice, "USB:");
|
strcpy(bootDevice, "USB:");
|
||||||
}
|
}
|
||||||
|
|
||||||
ret2 = IOS_ReloadIOS(249);
|
|
||||||
if(ret2 < 0) {
|
|
||||||
ret2 = IOS_ReloadIOS(222);
|
|
||||||
load_ehc_module();
|
|
||||||
}
|
|
||||||
|
|
||||||
SDCard_Init(); // mount SD for loading cfg's
|
|
||||||
USBDevice_Init(); // and mount USB:/
|
|
||||||
|
|
||||||
gettextCleanUp();
|
gettextCleanUp();
|
||||||
|
//lang_default();
|
||||||
CFG_Load();
|
CFG_Load();
|
||||||
|
|
||||||
|
SDCard_deInit();// unmount SD for reloading IOS
|
||||||
|
USBDevice_deInit();// unmount USB for reloading IOS
|
||||||
|
|
||||||
/* Load Custom IOS */
|
/* Load Custom IOS */
|
||||||
if(Settings.cios == ios222 && IOS_GetVersion() != 222) {
|
if(Settings.cios == ios222 && preloaded_ios != 222) {
|
||||||
SDCard_deInit();// unmount SD for reloading IOS
|
|
||||||
USBDevice_deInit();// unmount USB for reloading IOS
|
|
||||||
ret2 = IOS_ReloadIOS(222);
|
ret2 = IOS_ReloadIOS(222);
|
||||||
load_ehc_module();
|
load_ehc_module();
|
||||||
if (ret2 < 0) {
|
if (ret2 < 0) {
|
||||||
Settings.cios = ios249;
|
Settings.cios = ios249;
|
||||||
ret2 = IOS_ReloadIOS(249);
|
ret2 = IOS_ReloadIOS(249);
|
||||||
}
|
}
|
||||||
SDCard_Init(); // now mount SD:/
|
} else if(preloaded_ios != 249) {
|
||||||
USBDevice_Init(); // and mount USB:/
|
|
||||||
} else if(Settings.cios == ios249 && IOS_GetVersion() != 249) {
|
|
||||||
SDCard_deInit();// unmount SD for reloading IOS
|
|
||||||
USBDevice_deInit();// unmount USB for reloading IOS
|
|
||||||
ret2 = IOS_ReloadIOS(249);
|
ret2 = IOS_ReloadIOS(249);
|
||||||
if(ret2 < 0) {
|
|
||||||
Settings.cios = ios222;
|
|
||||||
ret2 = IOS_ReloadIOS(222);
|
|
||||||
load_ehc_module();
|
|
||||||
}
|
|
||||||
SDCard_Init(); // now mount SD:/
|
|
||||||
USBDevice_Init(); // and mount USB:/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret2 < 0) {
|
if (ret2 < 0) {
|
||||||
printf("ERROR: cIOS could not be loaded!");
|
printf("ERROR: cIOS could not be loaded!");
|
||||||
sleep(5);
|
|
||||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDCard_Init(); // now mount SD:/
|
||||||
|
USBDevice_Init(); // and mount USB:/
|
||||||
|
|
||||||
Sys_Init();
|
Sys_Init();
|
||||||
|
|
||||||
/** PAD_Init has to be before InitVideo don't move that **/
|
/** PAD_Init has to be before InitVideo don't move that **/
|
||||||
@ -137,5 +138,3 @@ main(int argc, char *argv[])
|
|||||||
MainMenu(MENU_CHECK);
|
MainMenu(MENU_CHECK);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "language/gettext.h"
|
#include "language/gettext.h"
|
||||||
#include "settings/Settings.h"
|
#include "settings/Settings.h"
|
||||||
#include "prompts/PromptWindows.h"
|
#include "prompts/PromptWindows.h"
|
||||||
|
#include "prompts/ProgressWindow.h"
|
||||||
#include "prompts/gameinfo.h"
|
#include "prompts/gameinfo.h"
|
||||||
#include "mload/mload.h"
|
#include "mload/mload.h"
|
||||||
#include "patches/patchcode.h"
|
#include "patches/patchcode.h"
|
||||||
@ -38,7 +39,6 @@
|
|||||||
#include "fatmounter.h"
|
#include "fatmounter.h"
|
||||||
|
|
||||||
#define MAX_CHARACTERS 38
|
#define MAX_CHARACTERS 38
|
||||||
#define GB_SIZE 1073741824.0
|
|
||||||
|
|
||||||
/*** Variables that are also used extern ***/
|
/*** Variables that are also used extern ***/
|
||||||
GuiWindow * mainWindow = NULL;
|
GuiWindow * mainWindow = NULL;
|
||||||
@ -108,8 +108,7 @@ HaltGui()
|
|||||||
*
|
*
|
||||||
* Primary thread to allow GUI to respond to state changes, and draws GUI
|
* Primary thread to allow GUI to respond to state changes, and draws GUI
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
static void *
|
static void * UpdateGUI (void *arg)
|
||||||
UpdateGUI (void *arg)
|
|
||||||
{
|
{
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
@ -193,7 +192,9 @@ UpdateGUI (void *arg)
|
|||||||
void InitGUIThreads()
|
void InitGUIThreads()
|
||||||
{
|
{
|
||||||
LWP_CreateThread(&guithread, UpdateGUI, NULL, NULL, 0, 70);
|
LWP_CreateThread(&guithread, UpdateGUI, NULL, NULL, 0, 70);
|
||||||
|
InitProgressThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExitGUIThreads()
|
void ExitGUIThreads()
|
||||||
{
|
{
|
||||||
ExitRequested = 1;
|
ExitRequested = 1;
|
||||||
@ -1239,8 +1240,7 @@ static int MenuInstall()
|
|||||||
Disc_SetUSB(NULL);
|
Disc_SetUSB(NULL);
|
||||||
|
|
||||||
int ret, choice = 0;
|
int ret, choice = 0;
|
||||||
char *name;
|
char name[200];
|
||||||
static char buffer[MAX_CHARACTERS + 4];
|
|
||||||
|
|
||||||
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume);
|
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume);
|
||||||
|
|
||||||
@ -1290,16 +1290,7 @@ static int MenuInstall()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Disc_ReadHeader(&headerdisc);
|
Disc_ReadHeader(&headerdisc);
|
||||||
name = headerdisc.title;
|
snprintf(name, sizeof(name), "%s", headerdisc.title);
|
||||||
if (strlen(name) < (MAX_CHARACTERS + 3)) {
|
|
||||||
memset(buffer, 0, sizeof(buffer));
|
|
||||||
sprintf(name, "%s", name);
|
|
||||||
} else {
|
|
||||||
strncpy(buffer, name, MAX_CHARACTERS);
|
|
||||||
buffer[MAX_CHARACTERS] = '\0';
|
|
||||||
strncat(buffer, "...", 3);
|
|
||||||
sprintf(name, "%s", buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = WBFS_CheckGame(headerdisc.id);
|
ret = WBFS_CheckGame(headerdisc.id);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@ -1311,7 +1302,8 @@ static int MenuInstall()
|
|||||||
f32 freespace, used;
|
f32 freespace, used;
|
||||||
|
|
||||||
WBFS_DiskSpace(&used, &freespace);
|
WBFS_DiskSpace(&used, &freespace);
|
||||||
gamesize = WBFS_EstimeGameSize()/GB_SIZE;
|
gamesize = WBFS_EstimeGameSize()/GBSIZE;
|
||||||
|
|
||||||
char gametxt[50];
|
char gametxt[50];
|
||||||
|
|
||||||
sprintf(gametxt, "%s : %.2fGB", name, gamesize);
|
sprintf(gametxt, "%s : %.2fGB", name, gamesize);
|
||||||
@ -1328,7 +1320,11 @@ static int MenuInstall()
|
|||||||
sprintf(errortxt, "%s: %.2fGB, %s: %.2fGB",tr("Game Size"), gamesize, tr("Free Space"), freespace);
|
sprintf(errortxt, "%s: %.2fGB, %s: %.2fGB",tr("Game Size"), gamesize, tr("Free Space"), freespace);
|
||||||
choice = WindowPrompt(tr("Not enough free space!"),errortxt,tr("OK"), tr("Return"));
|
choice = WindowPrompt(tr("Not enough free space!"),errortxt,tr("OK"), tr("Return"));
|
||||||
if (choice == 1) {
|
if (choice == 1) {
|
||||||
ret = ProgressWindow(gametxt, name);
|
USBStorage_Watchdog(0);
|
||||||
|
SetupGameInstallProgress(gametxt, name);
|
||||||
|
ret = WBFS_AddGame();
|
||||||
|
ProgressStop();
|
||||||
|
USBStorage_Watchdog(1);
|
||||||
wiilight(0);
|
wiilight(0);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
WindowPrompt (tr("Install Error!"),0,tr("Back"));
|
WindowPrompt (tr("Install Error!"),0,tr("Back"));
|
||||||
@ -1348,10 +1344,14 @@ static int MenuInstall()
|
|||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ret = ProgressWindow(gametxt, name);
|
USBStorage_Watchdog(0);
|
||||||
|
SetupGameInstallProgress(gametxt, name);
|
||||||
|
ret = WBFS_AddGame();
|
||||||
|
ProgressStop();
|
||||||
|
USBStorage_Watchdog(1);
|
||||||
wiilight(0);
|
wiilight(0);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
WindowPrompt (tr("Install Error!"),0,tr("Back"));
|
WindowPrompt(tr("Install Error!"),0,tr("Back"));
|
||||||
menu = MENU_DISCLIST;
|
menu = MENU_DISCLIST;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@ -1383,8 +1383,6 @@ static int MenuInstall()
|
|||||||
|
|
||||||
mainWindow->Remove(&w);
|
mainWindow->Remove(&w);
|
||||||
ResumeGui();
|
ResumeGui();
|
||||||
/// SDCard_deInit();
|
|
||||||
/// SDCard_Init();
|
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -1412,7 +1410,7 @@ static int MenuFormat()
|
|||||||
partitionEntry *entry = &partitions[cnt];
|
partitionEntry *entry = &partitions[cnt];
|
||||||
|
|
||||||
/* Calculate size in gigabytes */
|
/* Calculate size in gigabytes */
|
||||||
f32 size = entry->size * (sector_size / GB_SIZE);
|
f32 size = entry->size * (sector_size / GBSIZE);
|
||||||
|
|
||||||
if (size) {
|
if (size) {
|
||||||
sprintf(options.name[cnt], "%s %d:",tr("Partition"), cnt+1);
|
sprintf(options.name[cnt], "%s %d:",tr("Partition"), cnt+1);
|
||||||
@ -1481,7 +1479,7 @@ static int MenuFormat()
|
|||||||
if (cnt == selected) {
|
if (cnt == selected) {
|
||||||
partitionEntry *entry = &partitions[selected];
|
partitionEntry *entry = &partitions[selected];
|
||||||
if (entry->size) {
|
if (entry->size) {
|
||||||
sprintf(text, "%s %d : %.2fGB",tr("Partition"), selected+1, entry->size * (sector_size / GB_SIZE));
|
sprintf(text, "%s %d : %.2fGB",tr("Partition"), selected+1, entry->size * (sector_size / GBSIZE));
|
||||||
choice = WindowPrompt(
|
choice = WindowPrompt(
|
||||||
tr("Do you want to format:"),
|
tr("Do you want to format:"),
|
||||||
text,
|
text,
|
||||||
|
380
source/prompts/ProgressWindow.cpp
Normal file
380
source/prompts/ProgressWindow.cpp
Normal file
@ -0,0 +1,380 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* ProgressWindow
|
||||||
|
* USB Loader GX 2009
|
||||||
|
*
|
||||||
|
* ProgressWindow.cpp
|
||||||
|
***************************************************************************/
|
||||||
|
#include <gccore.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "menu.h"
|
||||||
|
#include "language/gettext.h"
|
||||||
|
#include "libwiigui/gui.h"
|
||||||
|
#include "prompts/PromptWindows.h"
|
||||||
|
#include "usbloader/wbfs.h"
|
||||||
|
|
||||||
|
/*** Variables used only in this file ***/
|
||||||
|
static lwp_t progressthread = LWP_THREAD_NULL;
|
||||||
|
static char progressTitle[100];
|
||||||
|
static char progressMsg1[150];
|
||||||
|
static char progressMsg2[150];
|
||||||
|
static char progressTime[80];
|
||||||
|
static char progressSizeLeft[80];
|
||||||
|
static int showProgress = 0;
|
||||||
|
static f32 progressDone = 0.0;
|
||||||
|
static bool showTime = false;
|
||||||
|
static bool showSize = false;
|
||||||
|
static s32 gameinstalldone = 0;
|
||||||
|
static s32 gameinstalltotal = -1;
|
||||||
|
static time_t start;
|
||||||
|
|
||||||
|
/*** Extern variables ***/
|
||||||
|
extern GuiWindow * mainWindow;
|
||||||
|
extern float gamesize;
|
||||||
|
|
||||||
|
/*** Extern functions ***/
|
||||||
|
extern void ResumeGui();
|
||||||
|
extern void HaltGui();
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* GameInstallProgress
|
||||||
|
* GameInstallValue updating function
|
||||||
|
***************************************************************************/
|
||||||
|
static void GameInstallProgress() {
|
||||||
|
|
||||||
|
if(gameinstalltotal <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
GetProgressValue(&gameinstalldone, &gameinstalltotal);
|
||||||
|
|
||||||
|
if(gameinstalldone > gameinstalltotal)
|
||||||
|
gameinstalldone = gameinstalltotal;
|
||||||
|
|
||||||
|
static u32 expected = 300;
|
||||||
|
|
||||||
|
u32 elapsed, h, m, s;
|
||||||
|
f32 speed = 0;
|
||||||
|
|
||||||
|
//Elapsed time
|
||||||
|
elapsed = time(0) - start;
|
||||||
|
|
||||||
|
//Calculate speed in MB/s
|
||||||
|
if(elapsed > 0)
|
||||||
|
speed = KBSIZE * gamesize * gameinstalldone/(gameinstalltotal*elapsed);
|
||||||
|
|
||||||
|
if (gameinstalldone != gameinstalltotal) {
|
||||||
|
//Expected time
|
||||||
|
if (elapsed)
|
||||||
|
expected = (expected * 3 + elapsed * gameinstalltotal / gameinstalldone) / 4;
|
||||||
|
|
||||||
|
//Remaining time
|
||||||
|
elapsed = (expected > elapsed) ? (expected - elapsed) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Calculate time values
|
||||||
|
h = elapsed / 3600;
|
||||||
|
m = (elapsed / 60) % 60;
|
||||||
|
s = elapsed % 60;
|
||||||
|
|
||||||
|
progressDone = 100.0*gameinstalldone/gameinstalltotal;
|
||||||
|
|
||||||
|
snprintf(progressTime, sizeof(progressTime), "%s %d:%02d:%02d",tr("Time left:"),h,m,s);
|
||||||
|
snprintf(progressSizeLeft, sizeof(progressSizeLeft), "%.2fGB/%.2fGB %.1fMB/s", gamesize * gameinstalldone/gameinstalltotal, gamesize, speed);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* SetupGameInstallProgress
|
||||||
|
***************************************************************************/
|
||||||
|
void SetupGameInstallProgress(char * title, char * game) {
|
||||||
|
|
||||||
|
strncpy(progressTitle, title, sizeof(progressTitle));
|
||||||
|
strncpy(progressMsg1, game, sizeof(progressMsg1));
|
||||||
|
gameinstalltotal = 1;
|
||||||
|
showProgress = 1;
|
||||||
|
showSize = true;
|
||||||
|
showTime = true;
|
||||||
|
LWP_ResumeThread(progressthread);
|
||||||
|
start = time(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* ProgressWindow
|
||||||
|
*
|
||||||
|
* Opens a window, which displays progress to the user. Can either display a
|
||||||
|
* progress bar showing % completion, or a throbber that only shows that an
|
||||||
|
* action is in progress.
|
||||||
|
***************************************************************************/
|
||||||
|
static void ProgressWindow(const char *title, const char *msg1, const char *msg2)
|
||||||
|
{
|
||||||
|
GuiWindow promptWindow(472,320);
|
||||||
|
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
|
||||||
|
promptWindow.SetPosition(0, -10);
|
||||||
|
|
||||||
|
char imgPath[100];
|
||||||
|
snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path);
|
||||||
|
GuiImageData btnOutline(imgPath, button_dialogue_box_png);
|
||||||
|
snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path);
|
||||||
|
GuiImageData dialogBox(imgPath, dialogue_box_png);
|
||||||
|
|
||||||
|
GuiTrigger trigA;
|
||||||
|
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
||||||
|
|
||||||
|
GuiImage dialogBoxImg(&dialogBox);
|
||||||
|
if (Settings.wsprompt == yes){
|
||||||
|
dialogBoxImg.SetWidescreen(CFG.widescreen);
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(imgPath, sizeof(imgPath), "%sprogressbar_outline.png", CFG.theme_path);
|
||||||
|
GuiImageData progressbarOutline(imgPath, progressbar_outline_png);
|
||||||
|
|
||||||
|
GuiImage progressbarOutlineImg(&progressbarOutline);
|
||||||
|
if (Settings.wsprompt == yes){
|
||||||
|
progressbarOutlineImg.SetWidescreen(CFG.widescreen);}
|
||||||
|
progressbarOutlineImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||||
|
progressbarOutlineImg.SetPosition(25, 40);
|
||||||
|
|
||||||
|
snprintf(imgPath, sizeof(imgPath), "%sprogressbar_empty.png", CFG.theme_path);
|
||||||
|
GuiImageData progressbarEmpty(imgPath, progressbar_empty_png);
|
||||||
|
GuiImage progressbarEmptyImg(&progressbarEmpty);
|
||||||
|
progressbarEmptyImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||||
|
progressbarEmptyImg.SetPosition(25, 40);
|
||||||
|
progressbarEmptyImg.SetTile(100);
|
||||||
|
|
||||||
|
snprintf(imgPath, sizeof(imgPath), "%sprogressbar.png", CFG.theme_path);
|
||||||
|
GuiImageData progressbar(imgPath, progressbar_png);
|
||||||
|
GuiImage progressbarImg(&progressbar);
|
||||||
|
progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||||
|
progressbarImg.SetPosition(25, 40);
|
||||||
|
|
||||||
|
GuiText titleTxt(title, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||||
|
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
||||||
|
titleTxt.SetPosition(0,60);
|
||||||
|
|
||||||
|
GuiText msg1Txt(msg1, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||||
|
msg1Txt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
||||||
|
if(msg2)
|
||||||
|
msg1Txt.SetPosition(0,120);
|
||||||
|
else
|
||||||
|
msg1Txt.SetPosition(0,100);
|
||||||
|
msg1Txt.SetMaxWidth(430, GuiText::DOTTED);
|
||||||
|
|
||||||
|
GuiText msg2Txt(msg2, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||||
|
msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
||||||
|
msg2Txt.SetPosition(0,125);
|
||||||
|
msg2Txt.SetMaxWidth(430, GuiText::DOTTED);
|
||||||
|
|
||||||
|
GuiText prsTxt("%", 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||||
|
prsTxt.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
|
||||||
|
prsTxt.SetPosition(-188,40);
|
||||||
|
|
||||||
|
GuiText timeTxt(NULL, 24, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||||
|
timeTxt.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
|
||||||
|
timeTxt.SetPosition(280,-50);
|
||||||
|
|
||||||
|
GuiText sizeTxt(NULL, 24, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||||
|
sizeTxt.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
|
||||||
|
sizeTxt.SetPosition(35, -50);
|
||||||
|
|
||||||
|
GuiText prTxt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||||
|
prTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||||
|
prTxt.SetPosition(200, 40);
|
||||||
|
|
||||||
|
if ((Settings.wsprompt == yes) && (CFG.widescreen)){/////////////adjust for widescreen
|
||||||
|
progressbarOutlineImg.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
|
||||||
|
progressbarOutlineImg.SetPosition(0, 40);
|
||||||
|
progressbarEmptyImg.SetPosition(80,40);
|
||||||
|
progressbarEmptyImg.SetTile(78);
|
||||||
|
progressbarImg.SetPosition(80, 40);
|
||||||
|
msg1Txt.SetMaxWidth(380, GuiText::DOTTED);
|
||||||
|
msg2Txt.SetMaxWidth(380, GuiText::DOTTED);
|
||||||
|
|
||||||
|
timeTxt.SetPosition(250,-50);
|
||||||
|
timeTxt.SetFontSize(20);
|
||||||
|
sizeTxt.SetPosition(90, -50);
|
||||||
|
sizeTxt.SetFontSize(20);
|
||||||
|
}
|
||||||
|
|
||||||
|
usleep(400000); // wait to see if progress flag changes soon
|
||||||
|
if(!showProgress)
|
||||||
|
return;
|
||||||
|
|
||||||
|
promptWindow.Append(&dialogBoxImg);
|
||||||
|
promptWindow.Append(&progressbarEmptyImg);
|
||||||
|
promptWindow.Append(&progressbarImg);
|
||||||
|
promptWindow.Append(&progressbarOutlineImg);
|
||||||
|
promptWindow.Append(&prTxt);
|
||||||
|
promptWindow.Append(&prsTxt);
|
||||||
|
if(title)
|
||||||
|
promptWindow.Append(&titleTxt);
|
||||||
|
if(msg1)
|
||||||
|
promptWindow.Append(&msg1Txt);
|
||||||
|
if(msg2)
|
||||||
|
promptWindow.Append(&msg2Txt);
|
||||||
|
if(showTime)
|
||||||
|
promptWindow.Append(&timeTxt);
|
||||||
|
if(showSize)
|
||||||
|
promptWindow.Append(&sizeTxt);
|
||||||
|
|
||||||
|
HaltGui();
|
||||||
|
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50);
|
||||||
|
mainWindow->SetState(STATE_DISABLED);
|
||||||
|
mainWindow->Append(&promptWindow);
|
||||||
|
mainWindow->ChangeFocus(&promptWindow);
|
||||||
|
ResumeGui();
|
||||||
|
|
||||||
|
while(promptWindow.GetEffect() > 0) usleep(100);
|
||||||
|
|
||||||
|
while(showProgress)
|
||||||
|
{
|
||||||
|
usleep(20000);
|
||||||
|
|
||||||
|
GameInstallProgress();
|
||||||
|
|
||||||
|
if(CFG.widescreen && Settings.wsprompt == yes)
|
||||||
|
progressbarImg.SetTile(0.8*progressDone);
|
||||||
|
else
|
||||||
|
progressbarImg.SetTile(progressDone);
|
||||||
|
|
||||||
|
prTxt.SetTextf("%.2f", progressDone);
|
||||||
|
|
||||||
|
if(showSize)
|
||||||
|
sizeTxt.SetText(progressSizeLeft);
|
||||||
|
if(showTime)
|
||||||
|
timeTxt.SetText(progressTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
|
||||||
|
while(promptWindow.GetEffect() > 0) usleep(100);
|
||||||
|
|
||||||
|
HaltGui();
|
||||||
|
mainWindow->Remove(&promptWindow);
|
||||||
|
mainWindow->SetState(STATE_DEFAULT);
|
||||||
|
ResumeGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* ProgressThread
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
static void * ProgressThread (void *arg)
|
||||||
|
{
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
if(!showProgress)
|
||||||
|
LWP_SuspendThread (progressthread);
|
||||||
|
|
||||||
|
ProgressWindow(progressTitle, progressMsg1, progressMsg2);
|
||||||
|
usleep(100);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* ProgressStop
|
||||||
|
***************************************************************************/
|
||||||
|
void ProgressStop()
|
||||||
|
{
|
||||||
|
showProgress = 0;
|
||||||
|
gameinstalltotal = -1;
|
||||||
|
|
||||||
|
// wait for thread to finish
|
||||||
|
while(!LWP_ThreadIsSuspended(progressthread))
|
||||||
|
usleep(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* ShowProgress
|
||||||
|
*
|
||||||
|
* Callbackfunction for updating the progress values
|
||||||
|
* Use this function as standard callback
|
||||||
|
***************************************************************************/
|
||||||
|
void ShowProgress(const char *title, const char *msg1, const char *msg2, f32 done, f32 total, bool swSize, bool swTime)
|
||||||
|
{
|
||||||
|
if(total <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
else if(done > total)
|
||||||
|
done = total;
|
||||||
|
|
||||||
|
showSize = swSize;
|
||||||
|
showTime = swTime;
|
||||||
|
|
||||||
|
if(title)
|
||||||
|
strncpy(progressTitle, title, sizeof(progressTitle));
|
||||||
|
if(msg1)
|
||||||
|
strncpy(progressMsg1, msg1, sizeof(progressMsg1));
|
||||||
|
if(msg2)
|
||||||
|
strncpy(progressMsg2, msg2, sizeof(progressMsg2));
|
||||||
|
|
||||||
|
if(swTime == true) {
|
||||||
|
static u32 expected;
|
||||||
|
|
||||||
|
u32 elapsed, h, m, s, speed = 0;
|
||||||
|
|
||||||
|
if (!done) {
|
||||||
|
start = time(0);
|
||||||
|
expected = 300;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Elapsed time
|
||||||
|
elapsed = time(0) - start;
|
||||||
|
|
||||||
|
//Calculate speed in KB/s
|
||||||
|
if(elapsed > 0)
|
||||||
|
speed = done/(elapsed*KBSIZE);
|
||||||
|
|
||||||
|
if (done != total) {
|
||||||
|
//Expected time
|
||||||
|
if (elapsed)
|
||||||
|
expected = (expected * 3 + elapsed * total / done) / 4;
|
||||||
|
|
||||||
|
//Remaining time
|
||||||
|
elapsed = (expected > elapsed) ? (expected - elapsed) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Calculate time values
|
||||||
|
h = elapsed / 3600;
|
||||||
|
m = (elapsed / 60) % 60;
|
||||||
|
s = elapsed % 60;
|
||||||
|
|
||||||
|
snprintf(progressTime, sizeof(progressTime), "%s %d:%02d:%02d",tr("Time left:"),h,m,s);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(swSize == true) {
|
||||||
|
if(total < MBSIZE*10)
|
||||||
|
snprintf(progressSizeLeft, sizeof(progressSizeLeft), "%0.2fKB/%0.2fKB", 100.0* done/total / KBSIZE, total/KBSIZE);
|
||||||
|
else if(total > MBSIZE*10 && total < GBSIZE)
|
||||||
|
snprintf(progressSizeLeft, sizeof(progressSizeLeft), "%0.2fMB/%0.2fMB", 100.0* done/total / MBSIZE, total/MBSIZE);
|
||||||
|
else
|
||||||
|
snprintf(progressSizeLeft, sizeof(progressSizeLeft), "%0.2fGB/%0.2fGB", 100.0* done/total / GBSIZE, total/GBSIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
showProgress = 1;
|
||||||
|
progressDone = 100.0*done/total;
|
||||||
|
|
||||||
|
LWP_ResumeThread(progressthread);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* InitProgressThread
|
||||||
|
*
|
||||||
|
* Startup Progressthread in idle prio
|
||||||
|
***************************************************************************/
|
||||||
|
void InitProgressThread() {
|
||||||
|
LWP_CreateThread(&progressthread, ProgressThread, NULL, NULL, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* ExitProgressThread
|
||||||
|
*
|
||||||
|
* Shutdown Progressthread
|
||||||
|
***************************************************************************/
|
||||||
|
void ExitProgressThread() {
|
||||||
|
LWP_JoinThread(progressthread, NULL);
|
||||||
|
progressthread = LWP_THREAD_NULL;
|
||||||
|
}
|
22
source/prompts/ProgressWindow.h
Normal file
22
source/prompts/ProgressWindow.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* ProgressWindow
|
||||||
|
* USB Loader GX 2009
|
||||||
|
*
|
||||||
|
* ProgressWindow.h
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _PROGRESSWINDOW_H_
|
||||||
|
#define _PROGRESSWINDOW_H_
|
||||||
|
|
||||||
|
#define KBSIZE 1024.0
|
||||||
|
#define MBSIZE 1048576.0
|
||||||
|
#define GBSIZE 1073741824.0
|
||||||
|
|
||||||
|
void InitProgressThread();
|
||||||
|
void ExitProgressThread();
|
||||||
|
void SetupGameInstallProgress(char * titl, char * game);
|
||||||
|
void ShowProgress (const char *title, const char *msg1, const char *msg2,
|
||||||
|
f32 done, f32 total, bool swSize = false, bool swTime = false);
|
||||||
|
void ProgressStop();
|
||||||
|
|
||||||
|
#endif
|
@ -30,11 +30,6 @@
|
|||||||
int cntMissFiles = 0;
|
int cntMissFiles = 0;
|
||||||
|
|
||||||
/*** Variables used only in this file ***/
|
/*** Variables used only in this file ***/
|
||||||
static GuiText prTxt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
|
||||||
static GuiText timeTxt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
|
||||||
static GuiText sizeTxt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
|
||||||
static GuiImageData progressbar(progressbar_png);
|
|
||||||
static GuiImage progressbarImg(&progressbar);
|
|
||||||
static char missingFiles[500][12];
|
static char missingFiles[500][12];
|
||||||
|
|
||||||
/*** Extern variables ***/
|
/*** Extern variables ***/
|
||||||
@ -1774,183 +1769,7 @@ void SearchMissingImages(int choice2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* ShowProgress
|
* ProgressDownloadWindow
|
||||||
*
|
|
||||||
* Updates the variables used by the progress window for drawing a progress
|
|
||||||
* bar. Also resumes the progress window thread if it is suspended.
|
|
||||||
***************************************************************************/
|
|
||||||
void
|
|
||||||
ShowProgress (s32 done, s32 total)
|
|
||||||
{
|
|
||||||
|
|
||||||
static time_t start;
|
|
||||||
static u32 expected;
|
|
||||||
|
|
||||||
u32 d, h, m, s;
|
|
||||||
|
|
||||||
//first time
|
|
||||||
if (!done) {
|
|
||||||
start = time(0);
|
|
||||||
expected = 300;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Elapsed time
|
|
||||||
d = time(0) - start;
|
|
||||||
|
|
||||||
if (done != total) {
|
|
||||||
//Expected time
|
|
||||||
if (d)
|
|
||||||
expected = (expected * 3 + d * total / done) / 4;
|
|
||||||
|
|
||||||
//Remaining time
|
|
||||||
d = (expected > d) ? (expected - d) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Calculate time values
|
|
||||||
h = d / 3600;
|
|
||||||
m = (d / 60) % 60;
|
|
||||||
s = d % 60;
|
|
||||||
|
|
||||||
//Calculate percentage/size
|
|
||||||
f32 percent = (done * 100.0) / total;
|
|
||||||
|
|
||||||
prTxt.SetTextf("%0.2f", percent);
|
|
||||||
|
|
||||||
timeTxt.SetTextf("%s %d:%02d:%02d",tr("Time left:"),h,m,s);
|
|
||||||
|
|
||||||
f32 gamesizedone = gamesize * done/total;
|
|
||||||
|
|
||||||
sizeTxt.SetTextf("%0.2fGB/%0.2fGB", gamesizedone, gamesize);
|
|
||||||
|
|
||||||
if ((Settings.wsprompt == yes) && (CFG.widescreen)){
|
|
||||||
progressbarImg.SetTile((int)(80*done/total));}
|
|
||||||
else {progressbarImg.SetTile((int)(100*done/total));}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* ProgressWindow
|
|
||||||
*
|
|
||||||
* Opens a window, which displays progress to the user. Can either display a
|
|
||||||
* progress bar showing % completion, or a throbber that only shows that an
|
|
||||||
* action is in progress.
|
|
||||||
***************************************************************************/
|
|
||||||
int
|
|
||||||
ProgressWindow(const char *title, const char *msg)
|
|
||||||
{
|
|
||||||
|
|
||||||
wbfs_t * hdd = NULL;
|
|
||||||
hdd = GetHddInfo();
|
|
||||||
|
|
||||||
GuiWindow promptWindow(472,320);
|
|
||||||
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
|
|
||||||
promptWindow.SetPosition(0, -10);
|
|
||||||
char imgPath[100];
|
|
||||||
snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path);
|
|
||||||
GuiImageData btnOutline(imgPath, button_dialogue_box_png);
|
|
||||||
snprintf(imgPath, sizeof(imgPath), "%sdialogue_box.png", CFG.theme_path);
|
|
||||||
GuiImageData dialogBox(imgPath, dialogue_box_png);
|
|
||||||
GuiTrigger trigA;
|
|
||||||
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
|
||||||
|
|
||||||
GuiImage dialogBoxImg(&dialogBox);
|
|
||||||
if (Settings.wsprompt == yes){
|
|
||||||
dialogBoxImg.SetWidescreen(CFG.widescreen);}
|
|
||||||
|
|
||||||
snprintf(imgPath, sizeof(imgPath), "%sprogressbar_outline.png", CFG.theme_path);
|
|
||||||
GuiImageData progressbarOutline(imgPath, progressbar_outline_png);
|
|
||||||
|
|
||||||
GuiImage progressbarOutlineImg(&progressbarOutline);
|
|
||||||
if (Settings.wsprompt == yes){
|
|
||||||
progressbarOutlineImg.SetWidescreen(CFG.widescreen);}
|
|
||||||
progressbarOutlineImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
|
||||||
progressbarOutlineImg.SetPosition(25, 40);
|
|
||||||
|
|
||||||
snprintf(imgPath, sizeof(imgPath), "%sprogressbar_empty.png", CFG.theme_path);
|
|
||||||
GuiImageData progressbarEmpty(imgPath, progressbar_empty_png);
|
|
||||||
GuiImage progressbarEmptyImg(&progressbarEmpty);
|
|
||||||
progressbarEmptyImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
|
||||||
progressbarEmptyImg.SetPosition(25, 40);
|
|
||||||
progressbarEmptyImg.SetTile(100);
|
|
||||||
|
|
||||||
snprintf(imgPath, sizeof(imgPath), "%sprogressbar.png", CFG.theme_path);
|
|
||||||
GuiImageData progressbar(imgPath, progressbar_png);
|
|
||||||
|
|
||||||
progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
|
||||||
progressbarImg.SetPosition(25, 40);
|
|
||||||
|
|
||||||
GuiText titleTxt(title, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
|
||||||
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
|
||||||
titleTxt.SetPosition(0,60);
|
|
||||||
GuiText msgTxt(msg, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
|
||||||
msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
|
||||||
msgTxt.SetPosition(0,120);
|
|
||||||
|
|
||||||
GuiText prsTxt("%", 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
|
||||||
prsTxt.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
|
|
||||||
prsTxt.SetPosition(-188,40);
|
|
||||||
|
|
||||||
timeTxt.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
|
|
||||||
timeTxt.SetPosition(275,-50);
|
|
||||||
|
|
||||||
sizeTxt.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
|
|
||||||
sizeTxt.SetPosition(50, -50);
|
|
||||||
|
|
||||||
prTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
|
||||||
prTxt.SetPosition(200, 40);
|
|
||||||
|
|
||||||
if ((Settings.wsprompt == yes) && (CFG.widescreen)){/////////////adjust for widescreen
|
|
||||||
progressbarOutlineImg.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
|
|
||||||
progressbarOutlineImg.SetPosition(0, 40);
|
|
||||||
progressbarEmptyImg.SetPosition(80,40);
|
|
||||||
progressbarEmptyImg.SetTile(78);
|
|
||||||
progressbarImg.SetPosition(80, 40);
|
|
||||||
msgTxt.SetMaxWidth(380);
|
|
||||||
|
|
||||||
timeTxt.SetPosition(250,-50);
|
|
||||||
timeTxt.SetFontSize(22);
|
|
||||||
sizeTxt.SetPosition(90, -50);
|
|
||||||
sizeTxt.SetFontSize(22);
|
|
||||||
}
|
|
||||||
|
|
||||||
promptWindow.Append(&dialogBoxImg);
|
|
||||||
promptWindow.Append(&titleTxt);
|
|
||||||
promptWindow.Append(&msgTxt);
|
|
||||||
promptWindow.Append(&progressbarEmptyImg);
|
|
||||||
promptWindow.Append(&progressbarImg);
|
|
||||||
promptWindow.Append(&progressbarOutlineImg);
|
|
||||||
promptWindow.Append(&prTxt);
|
|
||||||
promptWindow.Append(&prsTxt);
|
|
||||||
promptWindow.Append(&timeTxt);
|
|
||||||
|
|
||||||
HaltGui();
|
|
||||||
mainWindow->SetState(STATE_DISABLED);
|
|
||||||
mainWindow->Append(&promptWindow);
|
|
||||||
mainWindow->ChangeFocus(&promptWindow);
|
|
||||||
ResumeGui();
|
|
||||||
promptWindow.Append(&prTxt);
|
|
||||||
promptWindow.Append(&sizeTxt);
|
|
||||||
|
|
||||||
s32 ret;
|
|
||||||
|
|
||||||
USBStorage_Watchdog(0);
|
|
||||||
|
|
||||||
ret = wbfs_add_disc(hdd, __WBFS_ReadDVD, NULL, ShowProgress, ONLY_GAME_PARTITION, 0);
|
|
||||||
|
|
||||||
USBStorage_Watchdog(1);
|
|
||||||
|
|
||||||
HaltGui();
|
|
||||||
mainWindow->Remove(&promptWindow);
|
|
||||||
mainWindow->SetState(STATE_DEFAULT);
|
|
||||||
ResumeGui();
|
|
||||||
if (ret < 0) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* ProgressWindow
|
|
||||||
*
|
*
|
||||||
* Opens a window, which displays progress to the user. Can either display a
|
* Opens a window, which displays progress to the user. Can either display a
|
||||||
* progress bar showing % completion, or a throbber that only shows that an
|
* progress bar showing % completion, or a throbber that only shows that an
|
||||||
@ -1998,6 +1817,7 @@ ProgressDownloadWindow(int choice2)
|
|||||||
|
|
||||||
snprintf(imgPath, sizeof(imgPath), "%sprogressbar.png", CFG.theme_path);
|
snprintf(imgPath, sizeof(imgPath), "%sprogressbar.png", CFG.theme_path);
|
||||||
GuiImageData progressbar(imgPath, progressbar_png);
|
GuiImageData progressbar(imgPath, progressbar_png);
|
||||||
|
GuiImage progressbarImg(&progressbar);
|
||||||
progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||||
progressbarImg.SetPosition(25, 40);
|
progressbarImg.SetPosition(25, 40);
|
||||||
|
|
||||||
@ -2017,7 +1837,7 @@ ProgressDownloadWindow(int choice2)
|
|||||||
msg3Txt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
msg3Txt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
||||||
msg3Txt.SetPosition(0,160);
|
msg3Txt.SetPosition(0,160);
|
||||||
|
|
||||||
|
GuiText prTxt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||||
prTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
|
prTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
|
||||||
prTxt.SetPosition(0, 40);
|
prTxt.SetPosition(0, 40);
|
||||||
|
|
||||||
@ -2343,8 +2163,7 @@ ProgressDownloadWindow(int choice2)
|
|||||||
* progress bar showing % completion, or a throbber that only shows that an
|
* progress bar showing % completion, or a throbber that only shows that an
|
||||||
* action is in progress.
|
* action is in progress.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#define BLOCKSIZE 1024
|
#define BLOCKSIZE 1024
|
||||||
|
|
||||||
int ProgressUpdateWindow()
|
int ProgressUpdateWindow()
|
||||||
{
|
{
|
||||||
int ret = 0, failed = 0;
|
int ret = 0, failed = 0;
|
||||||
@ -2385,6 +2204,7 @@ int ProgressUpdateWindow()
|
|||||||
|
|
||||||
snprintf(imgPath, sizeof(imgPath), "%sprogressbar.png", CFG.theme_path);
|
snprintf(imgPath, sizeof(imgPath), "%sprogressbar.png", CFG.theme_path);
|
||||||
GuiImageData progressbar(imgPath, progressbar_png);
|
GuiImageData progressbar(imgPath, progressbar_png);
|
||||||
|
GuiImage progressbarImg(&progressbar);
|
||||||
progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||||
progressbarImg.SetPosition(25, 7);
|
progressbarImg.SetPosition(25, 7);
|
||||||
|
|
||||||
@ -2403,6 +2223,7 @@ int ProgressUpdateWindow()
|
|||||||
msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
|
msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
|
||||||
msg2Txt.SetPosition(0, 50);
|
msg2Txt.SetPosition(0, 50);
|
||||||
|
|
||||||
|
GuiText prTxt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||||
prTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
|
prTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
|
||||||
prTxt.SetPosition(0, 7);
|
prTxt.SetPosition(0, 7);
|
||||||
|
|
||||||
@ -2491,9 +2312,9 @@ int ProgressUpdateWindow()
|
|||||||
if(filesize > 0) {
|
if(filesize > 0) {
|
||||||
FILE * pfile;
|
FILE * pfile;
|
||||||
pfile = fopen(dolpath, "wb");
|
pfile = fopen(dolpath, "wb");
|
||||||
u8 blockbuffer[BLOCKSIZE] ATTRIBUTE_ALIGN(32);
|
u8 * blockbuffer = new unsigned char[BLOCKSIZE];
|
||||||
for (s32 i = 0; i < filesize; i += BLOCKSIZE) {
|
for (s32 i = 0; i < filesize; i += BLOCKSIZE) {
|
||||||
VIDEO_WaitVSync();
|
usleep(100);
|
||||||
prTxt.SetTextf("%i%%", 100*i/filesize);
|
prTxt.SetTextf("%i%%", 100*i/filesize);
|
||||||
if ((Settings.wsprompt == yes) && (CFG.widescreen)) {
|
if ((Settings.wsprompt == yes) && (CFG.widescreen)) {
|
||||||
progressbarImg.SetTile(80*i/filesize);
|
progressbarImg.SetTile(80*i/filesize);
|
||||||
@ -2526,6 +2347,7 @@ int ProgressUpdateWindow()
|
|||||||
fwrite(blockbuffer,1,blksize, pfile);
|
fwrite(blockbuffer,1,blksize, pfile);
|
||||||
}
|
}
|
||||||
fclose(pfile);
|
fclose(pfile);
|
||||||
|
delete blockbuffer;
|
||||||
if(!failed) {
|
if(!failed) {
|
||||||
//remove old
|
//remove old
|
||||||
if(checkfile(dolpathsuccess)){
|
if(checkfile(dolpathsuccess)){
|
||||||
|
@ -21,7 +21,6 @@ int GameWindowPrompt();
|
|||||||
int DiscWait(const char *title, const char *msg, const char *btn1Label, const char *btn2Label, int IsDeviceWait);
|
int DiscWait(const char *title, const char *msg, const char *btn1Label, const char *btn2Label, int IsDeviceWait);
|
||||||
int FormatingPartition(const char *title, partitionEntry *entry);
|
int FormatingPartition(const char *title, partitionEntry *entry);
|
||||||
void SearchMissingImages(int choice2);
|
void SearchMissingImages(int choice2);
|
||||||
int ProgressWindow(const char *title, const char *msg);
|
|
||||||
int ProgressDownloadWindow(int choice2);
|
int ProgressDownloadWindow(int choice2);
|
||||||
int ProgressUpdateWindow();
|
int ProgressUpdateWindow();
|
||||||
char * GetMissingFiles();
|
char * GetMissingFiles();
|
||||||
|
@ -22,53 +22,20 @@ static wbfs_t *hdd = NULL;
|
|||||||
/* WBFS callbacks */
|
/* WBFS callbacks */
|
||||||
static rw_sector_callback_t readCallback = NULL;
|
static rw_sector_callback_t readCallback = NULL;
|
||||||
static rw_sector_callback_t writeCallback = NULL;
|
static rw_sector_callback_t writeCallback = NULL;
|
||||||
|
static s32 done = -1, total = -1;
|
||||||
/* Variables */
|
/* Variables */
|
||||||
|
|
||||||
static u32 nb_sectors, sector_size;
|
static u32 nb_sectors, sector_size;
|
||||||
void __WBFS_Spinner(s32 x, s32 max)
|
static void WBFS_Spinner(s32 x, s32 max)
|
||||||
{
|
{
|
||||||
static time_t start;
|
done = x;
|
||||||
static u32 expected;
|
total = max;
|
||||||
|
}
|
||||||
f32 percent, size;
|
|
||||||
u32 d, h, m, s;
|
|
||||||
|
|
||||||
/* First time */
|
|
||||||
if (!x) {
|
|
||||||
start = time(0);
|
|
||||||
expected = 300;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Elapsed time */
|
|
||||||
d = time(0) - start;
|
|
||||||
|
|
||||||
if (x != max) {
|
|
||||||
/* Expected time */
|
|
||||||
if (d)
|
|
||||||
expected = (expected * 3 + d * max / x) / 4;
|
|
||||||
|
|
||||||
/* Remaining time */
|
|
||||||
d = (expected > d) ? (expected - d) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Calculate time values */
|
|
||||||
h = d / 3600;
|
|
||||||
m = (d / 60) % 60;
|
|
||||||
s = d % 60;
|
|
||||||
|
|
||||||
/* Calculate percentage/size */
|
|
||||||
percent = (x * 100.0) / max;
|
|
||||||
size = (hdd->wii_sec_sz / GB_SIZE) * max;
|
|
||||||
|
|
||||||
//Con_ClearLine();
|
void GetProgressValue(s32 * d, s32 * m)
|
||||||
|
{
|
||||||
/* Show progress */
|
*d = done;
|
||||||
if (x != max) {
|
*m = total;
|
||||||
printf(" %.2f%% of %.2fGB (%c) ETA: %d:%02d:%02d\r", percent, size, "/|\\-"[(x / 10) % 4], h, m, s);
|
|
||||||
fflush(stdout);
|
|
||||||
} else
|
|
||||||
printf(" %.2fGB copied in %d:%02d:%02d\n", size, h, m, s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wbfs_t *GetHddInfo(void)
|
wbfs_t *GetHddInfo(void)
|
||||||
@ -444,7 +411,7 @@ s32 WBFS_AddGame(void)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Add game to device */
|
/* Add game to device */
|
||||||
ret = wbfs_add_disc(hdd, __WBFS_ReadDVD, NULL, __WBFS_Spinner, ALL_PARTITIONS, 0);
|
ret = wbfs_add_disc(hdd, __WBFS_ReadDVD, NULL, WBFS_Spinner, ONLY_GAME_PARTITION, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ enum {
|
|||||||
#define WBFS_MAX_DEVICE 2
|
#define WBFS_MAX_DEVICE 2
|
||||||
|
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
|
void GetProgressValue(s32 * d, s32 * m);
|
||||||
s32 WBFS_Init(u32);
|
s32 WBFS_Init(u32);
|
||||||
s32 WBFS_Open(void);
|
s32 WBFS_Open(void);
|
||||||
s32 WBFS_Close(void);
|
s32 WBFS_Close(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user