- cleaned up cover and banner download coding.

This commit is contained in:
Fledge68 2018-12-12 18:03:33 -06:00
parent b44c415602
commit 43e2dd50e4
6 changed files with 719 additions and 832 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 MiB

After

Width:  |  Height:  |  Size: 3.3 MiB

View File

@ -1050,8 +1050,7 @@ private:
};
void _game(bool launch = false);
void _downloadUrl(const char *url, u8 **dl_file, u32 *dl_size);
void _download(string gameId = string());
void _downloadBnr(const char *gameID);
void _download(string gameId = string(), int dl_type = 0);
bool _code(char code[4], bool erase = false);
void _about(bool help = false);
bool _wbfsOp(WBFS_OP op);
@ -1153,10 +1152,10 @@ private:
//
void _setThrdMsg(const wstringEx &msg, float progress);
void _setDumpMsg(const wstringEx &msg, float progress, float fileprog);
int _coverDownloader();
void _downloadProgress(void *obj, int size, int position);
int _coverDownloader();
int _gametdbDownloaderAsync();
int _downloadBnrAll();
int _bannerDownloader();
static s32 _networkComplete(s32 result, void *usrData);
void _initAsyncNetwork();
@ -1189,7 +1188,6 @@ private:
void _listEmuNands(const char *path, vector<string> &emuNands);
int _downloadCheatFileAsync();
int _downloadBannerAsync();
static void * _downloadUrlAsync(void *obj);
void _playGameSound(void);

View File

@ -78,7 +78,7 @@ void CMenu::_CoverBanner(void)
if(m_btnMgr.selected(m_coverbnrBtnDlCover))
{
_hideCoverBanner();
_download(id);
_download(id, 1);
_showCoverBanner();
}
else if(m_btnMgr.selected(m_coverbnrBtnDeleteCover))
@ -95,7 +95,7 @@ void CMenu::_CoverBanner(void)
fsop_deleteFile(fmt("%s/%s.bnr", m_customBnrDir.c_str(), id));
fsop_deleteFile(fmt("%s/%.3s.bnr", m_bnrCacheDir.c_str(), id));
fsop_deleteFile(fmt("%s/%.3s.bnr", m_customBnrDir.c_str(), id));
_downloadBnr(id);
_download(id, 2);
m_newGame = true;
_showCoverBanner();
}

File diff suppressed because it is too large Load Diff

View File

@ -342,79 +342,6 @@ int getTID(const char *path, u64 *tid)
return 0;
}
void * CMenu::_pThread(void *obj)
{
CMenu *m = (CMenu*)obj;
m->SetupInput();
while(m->m_thrdInstalling)
{
m->_mainLoopCommon();
if(m->m_thrdUpdated)
{
m->m_thrdUpdated = false;
m->_downloadProgress(obj, m->m_thrdTotal, m->m_thrdWritten);
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_thrdDone = true;
}
if(m->m_thrdMessageAdded)
{
m->m_thrdMessageAdded = false;
if(!m->m_thrdMessage.empty())
m_btnMgr.setText(m->m_wbfsLblDialog, m->m_thrdMessage);
}
}
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, _pThread, 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 amount, bool add)
{
if(m_thrdDone)
{
m_thrdDone = false;
if(add)
m_thrdWritten += amount;
else
m_thrdWritten = amount;
m_thrdUpdated = true;
}
}
/* only installs channel wads to emunand and mios wads to real nand */
/* several places gecko prints are used but no error msg to the user is displayed */
void CMenu::_Wad(const char *wad_path)

View File

@ -68,6 +68,14 @@ void CMenu::_addDiscProgress(int status, int total, void *user_data)
}
}
void CMenu::_setThrdMsg(const wstringEx &msg, float progress)
{
if (m_thrdStop) return;
if (msg != L"...") m_thrdMessage = msg;
m_thrdMessageAdded = true;
m_thrdProgress = progress;
}
bool CMenu::_searchGamesByID(const char *gameId)
{
for(vector<dir_discHdr>::iterator itr = m_gameList.begin(); itr != m_gameList.end(); ++itr)