mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-24 19:01:56 +01:00
-added progress bar to the wad installer
-updated the gc game installer progress bar
This commit is contained in:
parent
57b02cac30
commit
a59330463e
@ -161,7 +161,7 @@ s32 GCDump::__DiscWriteFile(FILE *f, u64 offset, u32 length, u8 *ReadBuffer)
|
||||
offset += toread;
|
||||
length -= toread;
|
||||
gc_done += toread;
|
||||
mainMenu.GC_Refresh(gc_done/1024, DiscSizeCalculated);
|
||||
mainMenu.update_pThread(toread);
|
||||
}
|
||||
return wrote;
|
||||
}
|
||||
@ -666,6 +666,7 @@ s32 GCDump::CheckSpace(u32 *needed, bool comp)
|
||||
gamedone = true;
|
||||
}
|
||||
MEM2_free(ReadBuffer);
|
||||
mainMenu.m_thrdTotal = size;
|
||||
DiscSizeCalculated = size/0x400;
|
||||
*needed = (size/0x8000) >> 2;
|
||||
gprintf("Free space needed: %d Mb (%d blocks)\n", size/0x100000, (size/0x8000) >> 2);
|
||||
|
@ -135,6 +135,13 @@ CMenu::CMenu()
|
||||
m_file = NULL;
|
||||
m_buffer = NULL;
|
||||
m_filesize = 0;
|
||||
/* thread stuff */
|
||||
m_thrdPtr = LWP_THREAD_NULL;
|
||||
m_thrdInstalling = false;
|
||||
m_thrdUpdated = false;
|
||||
m_thrdDone = false;
|
||||
m_thrdWritten = 0;
|
||||
m_thrdTotal = 0;
|
||||
}
|
||||
|
||||
void CMenu::init()
|
||||
|
@ -1069,9 +1069,21 @@ private:
|
||||
public:
|
||||
void _hideWaitMessage();
|
||||
bool m_Emulator_boot;
|
||||
void GC_Refresh(int status, int total);
|
||||
void GC_Messenger(int message, int info, char *cinfo);
|
||||
|
||||
/* general thread updating stuff */
|
||||
u64 m_thrdTotal;
|
||||
void update_pThread(u64 added);
|
||||
private:
|
||||
static int _pThread(void *obj);
|
||||
void _start_pThread(void);
|
||||
void _stop_pThread(void);
|
||||
lwp_t m_thrdPtr;
|
||||
volatile bool m_thrdInstalling;
|
||||
volatile bool m_thrdUpdated;
|
||||
volatile bool m_thrdDone;
|
||||
vu64 m_thrdWritten;
|
||||
|
||||
GuiSound *_sound(CMenu::SoundSet &soundSet, const char *domain, const char *key, const u8 * snd, u32 len, const char *name, bool isAllocated);
|
||||
GuiSound *_sound(CMenu::SoundSet &soundSet, const char *domain, const char *key, const char *name);
|
||||
u16 _textStyle(const char *domain, const char *key, u16 def);
|
||||
|
@ -76,8 +76,8 @@ int installWad(const char *path)
|
||||
fread(&hdr, sizeof(hdr), 1, wad_file);
|
||||
skip_align(wad_file, sizeof(hdr));
|
||||
|
||||
if(size < (hdr.certs_len + hdr.crl_len + hdr.tik_len + hdr.tmd_len + hdr.data_len + hdr.footer_len)
|
||||
|| hdr.tik_len == 0 || hdr.tmd_len == 0 || hdr.data_len == 0)
|
||||
mainMenu.m_thrdTotal = (hdr.certs_len + hdr.crl_len + hdr.tik_len + hdr.tmd_len + hdr.data_len + hdr.footer_len);
|
||||
if(size < mainMenu.m_thrdTotal || hdr.tik_len == 0 || hdr.tmd_len == 0 || hdr.data_len == 0)
|
||||
{
|
||||
fclose(wad_file);
|
||||
return -3;
|
||||
@ -234,6 +234,7 @@ int installWad(const char *path)
|
||||
ISFS_Write(fd, decBuf, size_dec);
|
||||
/* dont forget to increase the read size */
|
||||
read += size_enc;
|
||||
mainMenu.update_pThread(size_enc);
|
||||
}
|
||||
sha1 app_sha1;
|
||||
SHA1Final(app_sha1, &ctx);
|
||||
@ -344,6 +345,75 @@ int getTID(const char *path, u64 *tid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMenu::_pThread(void *obj)
|
||||
{
|
||||
CMenu *m = (CMenu*)obj;
|
||||
while(m->m_thrdInstalling)
|
||||
{
|
||||
m->_mainLoopCommon();
|
||||
if(m->m_thrdUpdated)
|
||||
{
|
||||
m->m_thrdUpdated = false;
|
||||
m->_addDiscProgress(m->m_thrdWritten, m->m_thrdTotal, obj);
|
||||
m->m_thrdDone = true;
|
||||
}
|
||||
if(m->m_thrdMessageAdded)
|
||||
{
|
||||
m->m_thrdMessageAdded = false;
|
||||
if(!m->m_thrdMessage.empty())
|
||||
m_btnMgr.setText(m->m_wbfsLblDialog, m->m_thrdMessage);
|
||||
if(m->m_thrdProgress > 0.f)
|
||||
{
|
||||
m_btnMgr.setText(m->m_wbfsLblMessage, wfmt(L"%i%%", (int)(m->m_thrdProgress * 100.f)));
|
||||
m_btnMgr.setProgress(m->m_wbfsPBar, m->m_thrdProgress);
|
||||
}
|
||||
}
|
||||
}
|
||||
m->m_thrdWorking = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CMenu::_start_pThread(void)
|
||||
{
|
||||
m_thrdPtr = LWP_THREAD_NULL;
|
||||
m_thrdWorking = true;
|
||||
m_thrdMessageAdded = false;
|
||||
m_thrdInstalling = true;
|
||||
m_thrdUpdated = false;
|
||||
m_thrdDone = true;
|
||||
m_thrdProgress = 0.f;
|
||||
m_thrdWritten = 0;
|
||||
m_thrdTotal = 0;
|
||||
LWP_CreateThread(&m_thrdPtr, (void *(*)(void *))_pThread, (void*)this, 0, 8 * 1024, 64);
|
||||
}
|
||||
|
||||
void CMenu::_stop_pThread(void)
|
||||
{
|
||||
if(m_thrdPtr == LWP_THREAD_NULL)
|
||||
return;
|
||||
|
||||
if(LWP_ThreadIsSuspended(m_thrdPtr))
|
||||
LWP_ResumeThread(m_thrdPtr);
|
||||
m_thrdInstalling = false;
|
||||
while(m_thrdWorking)
|
||||
usleep(50);
|
||||
LWP_JoinThread(m_thrdPtr, NULL);
|
||||
m_thrdPtr = LWP_THREAD_NULL;
|
||||
|
||||
m_btnMgr.setProgress(m_wbfsPBar, 1.f);
|
||||
m_btnMgr.setText(m_wbfsLblMessage, L"100%");
|
||||
}
|
||||
|
||||
void CMenu::update_pThread(u64 added)
|
||||
{
|
||||
if(m_thrdDone)
|
||||
{
|
||||
m_thrdDone = false;
|
||||
m_thrdWritten += added;
|
||||
m_thrdUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
void CMenu::_Wad(const char *wad_path)
|
||||
{
|
||||
if(wad_path == NULL)
|
||||
@ -383,22 +453,27 @@ void CMenu::_Wad(const char *wad_path)
|
||||
if(m_btnMgr.selected(m_wadBtnInstall))
|
||||
{
|
||||
_hideWad(true);
|
||||
m_btnMgr.setText(m_wbfsLblMessage, _t("wad4", L"Installing WAD, please wait..."));
|
||||
m_btnMgr.show(m_wbfsLblMessage, true);
|
||||
/* who cares about making a thread, just refresh a second */
|
||||
for(u8 i = 0; i < 60; ++i)
|
||||
_mainLoopCommon();
|
||||
m_btnMgr.setProgress(m_wbfsPBar, 0.f);
|
||||
m_btnMgr.setText(m_wbfsLblMessage, L"");
|
||||
m_btnMgr.setText(m_wbfsLblDialog, L"");
|
||||
m_btnMgr.show(m_wbfsPBar);
|
||||
m_btnMgr.show(m_wbfsLblMessage);
|
||||
m_btnMgr.show(m_wbfsLblDialog);
|
||||
/* mios is real nand, chans are emu */
|
||||
if(mios == false)
|
||||
{
|
||||
const char *emu_char = m_cfg.getString(CHANNEL_DOMAIN, "path", "/").c_str();
|
||||
NandHandle.SetPaths(emu_char, DeviceName[currentPartition]);
|
||||
}
|
||||
_start_pThread();
|
||||
m_thrdMessage = _t("wad4", L"Installing WAD, please wait...");
|
||||
m_thrdMessageAdded = true;
|
||||
int result = installWad(wad_path);
|
||||
_stop_pThread();
|
||||
if(result < 0)
|
||||
m_btnMgr.setText(m_wbfsLblMessage, wfmt(_fmt("wad5", L"Installation error %i!"), result));
|
||||
m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wad5", L"Installation error %i!"), result));
|
||||
else
|
||||
m_btnMgr.setText(m_wbfsLblMessage, wfmt(_fmt("wad6", L"Installation finished with %i hash fails."), result));
|
||||
m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wad6", L"Installation finished with %i hash fails."), result));
|
||||
}
|
||||
else if((m_btnMgr.selected(m_configBtnPartitionP) || m_btnMgr.selected(m_configBtnPartitionM)))
|
||||
{
|
||||
@ -413,6 +488,8 @@ void CMenu::_Wad(const char *wad_path)
|
||||
_hideWad();
|
||||
/* onscreen message might be onscreen still */
|
||||
m_btnMgr.hide(m_wbfsLblMessage);
|
||||
m_btnMgr.hide(m_wbfsLblDialog);
|
||||
m_btnMgr.hide(m_wbfsPBar);
|
||||
}
|
||||
|
||||
void CMenu::_initWad()
|
||||
|
@ -111,10 +111,7 @@ void CMenu::GC_Messenger(int message, int info, char *cinfo)
|
||||
m_thrdMessage = _t("wbfsop25", L"Disc read error!! Please clean the disc");
|
||||
else if(message == 11)
|
||||
m_thrdMessage = _t("wbfsop26", L"Disc ejected!! Please insert disc again");
|
||||
|
||||
if(!m_thrdMessage.empty())
|
||||
m_btnMgr.setText(m_wbfsLblDialog, m_thrdMessage);
|
||||
_mainLoopCommon();
|
||||
m_thrdMessageAdded = true;
|
||||
}
|
||||
|
||||
int CMenu::_gameInstaller(void *obj)
|
||||
@ -364,14 +361,16 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
|
||||
break;
|
||||
}
|
||||
strncpy(cfPos, GameID, 6);
|
||||
m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wbfsop6", L"Installing [%s] %s..."), GameID, gc_hdr.title));
|
||||
done = true;
|
||||
upd_dml = true;
|
||||
m_thrdWorking = true;
|
||||
m_thrdProgress = 0.f;
|
||||
m_thrdMessageAdded = false;
|
||||
//LWP_CreateThread(&thread, (void *(*)(void *))_GCgameInstaller, (void *)this, 0, 8 * 1024, 64);
|
||||
_start_pThread();
|
||||
m_thrdMessage = wfmt(_fmt("wbfsop6", L"Installing [%s] %s..."), GameID, gc_hdr.title);
|
||||
m_thrdMessageAdded = true;
|
||||
_GCgameInstaller();
|
||||
_stop_pThread();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -535,16 +534,3 @@ void CMenu::_textWBFS(void)
|
||||
{
|
||||
m_btnMgr.setText(m_wbfsBtnGo, _t("wbfsop5", L"Go"));
|
||||
}
|
||||
|
||||
void CMenu::GC_Refresh(int status, int total)
|
||||
{
|
||||
m_progress = (float)status / (float)total;
|
||||
// Don't synchronize too often
|
||||
if(m_progress - m_thrdProgress >= 0.01f)
|
||||
{
|
||||
m_thrdProgress = m_progress;
|
||||
m_btnMgr.setProgress(m_wbfsPBar, m_thrdProgress);
|
||||
m_btnMgr.setText(m_wbfsLblMessage, wfmt(L"%i%%", (int)(m_thrdProgress * 100.f)));
|
||||
_mainLoopCommon();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user