2012-08-05 15:48:15 +02:00
|
|
|
#include <network.h>
|
|
|
|
#include <ogc/lwp_watchdog.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <fstream>
|
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
#include "menu.hpp"
|
|
|
|
#include "svnrev.h"
|
2012-06-17 13:01:43 +02:00
|
|
|
#include "types.h"
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "lockMutex.hpp"
|
|
|
|
#include "channel/nand.hpp"
|
|
|
|
#include "devicemounter/usbstorage.h"
|
|
|
|
#include "gui/GameTDB.hpp"
|
|
|
|
#include "gui/pngu.h"
|
2012-01-21 21:57:41 +01:00
|
|
|
#include "loader/fs.h"
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "loader/wbfs.h"
|
2012-01-21 21:57:41 +01:00
|
|
|
#include "loader/wdvd.h"
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "network/http.h"
|
2012-01-21 21:57:41 +01:00
|
|
|
#include "unzip/ZipFile.h"
|
|
|
|
|
|
|
|
#define TAG_GAME_ID "{gameid}"
|
|
|
|
#define TAG_LOC "{loc}"
|
2012-06-08 21:29:23 +02:00
|
|
|
#define TAG_CONSOLE "{console}"
|
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
#define TITLES_URL "http://www.gametdb.com/titles.txt?LANG=%s"
|
2012-02-12 02:43:31 +01:00
|
|
|
#define GAMETDB_URL "http://www.gametdb.com/wiitdb.zip?LANG=%s&FALLBACK=TRUE&WIIWARE=TRUE&GAMECUBE=TRUE"
|
2016-04-02 17:46:06 +02:00
|
|
|
#define UPDATE_URL_VERSION "http://nintendont.gxarena.com/banners/versions.txt"
|
|
|
|
#define CUSTOM_BANNER_URL "http://nintendont.gxarena.com/banners/{gameid}.bnr"
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2012-06-08 21:29:23 +02:00
|
|
|
static const char FMT_BPIC_URL[] = "http://art.gametdb.com/{console}/coverfullHQ/{loc}/{gameid}.png"\
|
|
|
|
"|http://art.gametdb.com/{console}/coverfull/{loc}/{gameid}.png";
|
|
|
|
static const char FMT_PIC_URL[] = "http://art.gametdb.com/{console}/cover/{loc}/{gameid}.png";
|
|
|
|
static const char FMT_CBPIC_URL[] = "http://art.gametdb.com/{console}/coverfullHQ2/{loc}/{gameid}.png";
|
|
|
|
static const char FMT_CPIC_URL[] = "http://art.gametdb.com/{console}/cover2/{loc}/{gameid}.png";
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
static block download = { 0, 0 };
|
2012-02-16 20:19:45 +01:00
|
|
|
static bool settingsmenu = false;
|
2012-01-21 21:57:41 +01:00
|
|
|
static string countryCode(const string &gameId)
|
|
|
|
{
|
|
|
|
switch (gameId[3])
|
|
|
|
{
|
|
|
|
case 'E':
|
|
|
|
return "US";
|
|
|
|
case 'J':
|
|
|
|
return "JA";
|
|
|
|
case 'W':
|
|
|
|
return "ZH";
|
|
|
|
case 'K':
|
|
|
|
return "KO";
|
|
|
|
case 'R':
|
|
|
|
return "RU";
|
|
|
|
case 'P':
|
|
|
|
case 'D':
|
|
|
|
case 'F':
|
|
|
|
case 'I':
|
|
|
|
case 'S':
|
|
|
|
case 'H':
|
|
|
|
case 'X':
|
|
|
|
case 'Y':
|
|
|
|
case 'Z':
|
|
|
|
switch (CONF_GetArea())
|
|
|
|
{
|
|
|
|
case CONF_AREA_BRA:
|
|
|
|
return "PT";
|
|
|
|
case CONF_AREA_AUS:
|
|
|
|
return "AU";
|
|
|
|
}
|
|
|
|
switch (CONF_GetLanguage())
|
|
|
|
{
|
|
|
|
case CONF_LANG_ENGLISH:
|
|
|
|
return "EN";
|
|
|
|
case CONF_LANG_GERMAN:
|
|
|
|
return "DE";
|
|
|
|
case CONF_LANG_FRENCH:
|
|
|
|
return "FR";
|
|
|
|
case CONF_LANG_SPANISH:
|
|
|
|
return "ES";
|
|
|
|
case CONF_LANG_ITALIAN:
|
|
|
|
return "IT";
|
|
|
|
case CONF_LANG_DUTCH:
|
|
|
|
return "NL";
|
|
|
|
}
|
|
|
|
case 'A':
|
|
|
|
switch (CONF_GetArea())
|
|
|
|
{
|
|
|
|
case CONF_AREA_USA:
|
|
|
|
return "US";
|
|
|
|
case CONF_AREA_JPN:
|
|
|
|
return "JA";
|
|
|
|
case CONF_AREA_CHN:
|
|
|
|
case CONF_AREA_HKG:
|
|
|
|
case CONF_AREA_TWN:
|
|
|
|
return "ZH";
|
|
|
|
case CONF_AREA_KOR:
|
|
|
|
return "KO";
|
|
|
|
case CONF_AREA_BRA:
|
|
|
|
return "PT";
|
|
|
|
case CONF_AREA_AUS:
|
|
|
|
return "AU";
|
|
|
|
}
|
|
|
|
switch (CONF_GetLanguage())
|
|
|
|
{
|
|
|
|
case CONF_LANG_ENGLISH:
|
|
|
|
return "EN";
|
|
|
|
case CONF_LANG_GERMAN:
|
|
|
|
return "DE";
|
|
|
|
case CONF_LANG_FRENCH:
|
|
|
|
return "FR";
|
|
|
|
case CONF_LANG_SPANISH:
|
|
|
|
return "ES";
|
|
|
|
case CONF_LANG_ITALIAN:
|
|
|
|
return "IT";
|
|
|
|
case CONF_LANG_DUTCH:
|
|
|
|
return "NL";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "other";
|
|
|
|
}
|
|
|
|
|
|
|
|
static string makeURL(const string format, const string gameId, const string country)
|
|
|
|
{
|
|
|
|
string url = format;
|
2012-06-08 21:29:23 +02:00
|
|
|
if(url.find(TAG_LOC) != url.npos)
|
|
|
|
url.replace(url.find(TAG_LOC), strlen(TAG_LOC), country.c_str());
|
|
|
|
|
|
|
|
if(url.find(TAG_CONSOLE) != url.npos)
|
2012-06-08 21:31:22 +02:00
|
|
|
url.replace(url.find(TAG_CONSOLE), strlen(TAG_CONSOLE), "wii");
|
2012-06-08 21:29:23 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
url.replace(url.find(TAG_GAME_ID), strlen(TAG_GAME_ID), gameId.c_str());
|
|
|
|
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
void CMenu::_hideSettings(bool instant)
|
|
|
|
{
|
|
|
|
m_btnMgr.hide(m_downloadLblSetTitle, instant);
|
|
|
|
m_btnMgr.hide(m_downloadLblCoverPrio, instant);
|
|
|
|
m_btnMgr.hide(m_downloadLblPrio, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnPrioM, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnPrioP, instant);
|
2013-09-24 17:21:31 +02:00
|
|
|
m_btnMgr.hide(m_downloadLblRegion, instant);
|
2012-02-12 02:43:31 +01:00
|
|
|
m_btnMgr.hide(m_downloadBtnEN, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnJA, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnFR, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnDE, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnES, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnIT, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnNL, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnPT, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnRU, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnKO, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnZHCN, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnAU, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnENs, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnJAs, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnFRs, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnDEs, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnESs, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnITs, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnNLs, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnPTs, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnRUs, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnKOs, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnZHCNs, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnAUs, instant);
|
2013-09-12 15:04:50 +02:00
|
|
|
m_btnMgr.hide(m_downloadBtnBack, instant);
|
|
|
|
for(u8 i = 0; i < ARRAY_SIZE(m_downloadLblUser); ++i)
|
|
|
|
if(m_downloadLblUser[i] != -1)
|
|
|
|
m_btnMgr.hide(m_downloadLblUser[i], instant);
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
|
|
|
void CMenu::_showSettings()
|
|
|
|
{
|
|
|
|
_hideDownload();
|
2013-09-12 15:04:50 +02:00
|
|
|
for(u8 i = 0; i < ARRAY_SIZE(m_downloadLblUser); ++i)
|
|
|
|
if(m_downloadLblUser[i] != -1)
|
|
|
|
m_btnMgr.show(m_downloadLblUser[i]);
|
2012-02-12 02:43:31 +01:00
|
|
|
m_btnMgr.show(m_downloadLblSetTitle);
|
|
|
|
m_btnMgr.show(m_downloadLblCoverPrio);
|
|
|
|
m_btnMgr.show(m_downloadLblPrio);
|
|
|
|
m_btnMgr.show(m_downloadBtnPrioM);
|
|
|
|
m_btnMgr.show(m_downloadBtnPrioP);
|
|
|
|
m_btnMgr.show(m_downloadLblRegion);
|
|
|
|
if( m_downloadPrioVal&C_TYPE_EN )
|
|
|
|
m_btnMgr.show(m_downloadBtnENs);
|
|
|
|
else
|
|
|
|
m_btnMgr.show(m_downloadBtnEN);
|
|
|
|
|
|
|
|
if( m_downloadPrioVal&C_TYPE_JA )
|
|
|
|
m_btnMgr.show(m_downloadBtnJAs);
|
|
|
|
else
|
|
|
|
m_btnMgr.show(m_downloadBtnJA);
|
|
|
|
|
|
|
|
if( m_downloadPrioVal&C_TYPE_FR )
|
|
|
|
m_btnMgr.show(m_downloadBtnFRs);
|
|
|
|
else
|
|
|
|
m_btnMgr.show(m_downloadBtnFR);
|
|
|
|
|
|
|
|
if( m_downloadPrioVal&C_TYPE_DE )
|
|
|
|
m_btnMgr.show(m_downloadBtnDEs);
|
|
|
|
else
|
|
|
|
m_btnMgr.show(m_downloadBtnDE);
|
|
|
|
|
|
|
|
if( m_downloadPrioVal&C_TYPE_ES )
|
|
|
|
m_btnMgr.show(m_downloadBtnESs);
|
|
|
|
else
|
|
|
|
m_btnMgr.show(m_downloadBtnES);
|
|
|
|
|
|
|
|
if( m_downloadPrioVal&C_TYPE_IT )
|
|
|
|
m_btnMgr.show(m_downloadBtnITs);
|
|
|
|
else
|
|
|
|
m_btnMgr.show(m_downloadBtnIT);
|
|
|
|
|
|
|
|
if( m_downloadPrioVal&C_TYPE_NL )
|
|
|
|
m_btnMgr.show(m_downloadBtnNLs);
|
|
|
|
else
|
|
|
|
m_btnMgr.show(m_downloadBtnNL);
|
|
|
|
|
|
|
|
if( m_downloadPrioVal&C_TYPE_PT )
|
|
|
|
m_btnMgr.show(m_downloadBtnPTs);
|
|
|
|
else
|
|
|
|
m_btnMgr.show(m_downloadBtnPT);
|
|
|
|
|
|
|
|
if( m_downloadPrioVal&C_TYPE_RU )
|
|
|
|
m_btnMgr.show(m_downloadBtnRUs);
|
|
|
|
else
|
|
|
|
m_btnMgr.show(m_downloadBtnRU);
|
|
|
|
|
|
|
|
if( m_downloadPrioVal&C_TYPE_KO )
|
|
|
|
m_btnMgr.show(m_downloadBtnKOs);
|
|
|
|
else
|
2012-06-14 14:36:57 +02:00
|
|
|
m_btnMgr.show(m_downloadBtnKO);
|
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
if( m_downloadPrioVal&C_TYPE_ZHCN )
|
|
|
|
m_btnMgr.show(m_downloadBtnZHCNs);
|
|
|
|
else
|
|
|
|
m_btnMgr.show(m_downloadBtnZHCN);
|
|
|
|
|
|
|
|
if( m_downloadPrioVal&C_TYPE_AU )
|
|
|
|
m_btnMgr.show(m_downloadBtnAUs);
|
|
|
|
else
|
|
|
|
m_btnMgr.show(m_downloadBtnAU);
|
|
|
|
|
|
|
|
m_btnMgr.show(m_downloadBtnBack);
|
|
|
|
|
|
|
|
if( m_downloadPrioVal&C_TYPE_ONOR )
|
|
|
|
{
|
|
|
|
m_btnMgr.setText(m_downloadLblPrio, _t("dl24", L"Custom only"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( m_downloadPrioVal&C_TYPE_ONCU )
|
|
|
|
{
|
|
|
|
if( m_downloadPrioVal&C_TYPE_PRIOA )
|
|
|
|
{
|
|
|
|
if(m_downloadPrioVal&C_TYPE_PRIOB )
|
|
|
|
{
|
|
|
|
m_btnMgr.setText(m_downloadLblPrio, _t("dl23", L"Custom/Custom"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_btnMgr.setText(m_downloadLblPrio, _t("dl22", L"Custom/Original"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(m_downloadPrioVal&C_TYPE_PRIOB )
|
|
|
|
{
|
|
|
|
m_btnMgr.setText(m_downloadLblPrio, _t("dl21", L"Original/Custom"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_btnMgr.setText(m_downloadLblPrio, _t("dl20", L"Original/Original"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_btnMgr.setText(m_downloadLblPrio, _t("dl19", L"Original only"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
void CMenu::_hideDownload(bool instant)
|
|
|
|
{
|
|
|
|
m_btnMgr.hide(m_downloadLblTitle, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnCancel, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnAll, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnMissing, instant);
|
2012-02-12 02:43:31 +01:00
|
|
|
m_btnMgr.hide(m_downloadLblCoverSet, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnCoverSet, instant);
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.hide(m_downloadBtnGameTDBDownload, instant);
|
|
|
|
m_btnMgr.hide(m_downloadPBar, instant);
|
|
|
|
m_btnMgr.hide(m_downloadLblMessage[0], 0, 0, -2.f, 0.f, instant);
|
|
|
|
m_btnMgr.hide(m_downloadLblMessage[1], 0, 0, -2.f, 0.f, instant);
|
|
|
|
m_btnMgr.hide(m_downloadLblCovers, instant);
|
|
|
|
m_btnMgr.hide(m_downloadLblGameTDBDownload, instant);
|
|
|
|
m_btnMgr.hide(m_downloadLblGameTDB, instant);
|
2012-07-05 15:15:23 +02:00
|
|
|
for(u8 i = 0; i < ARRAY_SIZE(m_downloadLblUser); ++i)
|
2012-09-13 16:54:17 +02:00
|
|
|
if(m_downloadLblUser[i] != -1)
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.hide(m_downloadLblUser[i], instant);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_showDownload(void)
|
|
|
|
{
|
2012-02-12 02:43:31 +01:00
|
|
|
_hideSettings();
|
2012-01-21 21:57:41 +01:00
|
|
|
_setBg(m_downloadBg, m_downloadBg);
|
|
|
|
m_btnMgr.show(m_downloadLblGameTDB);
|
|
|
|
m_btnMgr.show(m_downloadLblTitle);
|
|
|
|
m_btnMgr.show(m_downloadBtnCancel);
|
|
|
|
m_btnMgr.show(m_downloadBtnAll);
|
|
|
|
m_btnMgr.show(m_downloadBtnMissing);
|
2012-02-12 02:43:31 +01:00
|
|
|
m_btnMgr.show(m_downloadLblCoverSet);
|
|
|
|
m_btnMgr.show(m_downloadBtnCoverSet);
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.show(m_downloadLblCovers);
|
|
|
|
if (!m_locked)
|
|
|
|
{
|
|
|
|
m_btnMgr.show(m_downloadLblGameTDBDownload);
|
|
|
|
m_btnMgr.show(m_downloadBtnGameTDBDownload);
|
|
|
|
}
|
2012-07-05 15:15:23 +02:00
|
|
|
for(u8 i = 0; i < ARRAY_SIZE(m_downloadLblUser); ++i)
|
2012-09-13 16:54:17 +02:00
|
|
|
if(m_downloadLblUser[i] != -1)
|
2012-02-12 02:43:31 +01:00
|
|
|
m_btnMgr.show(m_downloadLblUser[i]);
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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::_downloadProgress(void *obj, int size, int position)
|
|
|
|
{
|
|
|
|
CMenu *m = (CMenu *)obj;
|
|
|
|
LWP_MutexLock(m->m_mutex);
|
|
|
|
m->_setThrdMsg(L"...", m->m_thrdStep + m->m_thrdStepLen * ((float)position / (float)size));
|
|
|
|
LWP_MutexUnlock(m->m_mutex);
|
|
|
|
return !m->m_thrdStop;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CMenu::_coverDownloaderAll(CMenu *m)
|
|
|
|
{
|
|
|
|
if (!m->m_thrdWorking) return 0;
|
|
|
|
m->_coverDownloader(false);
|
|
|
|
m->m_thrdWorking = false;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CMenu::_coverDownloaderMissing(CMenu *m)
|
|
|
|
{
|
|
|
|
if (!m->m_thrdWorking) return 0;
|
|
|
|
m->_coverDownloader(true);
|
|
|
|
m->m_thrdWorking = false;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool checkPNGBuf(u8 *data)
|
|
|
|
{
|
2012-12-09 21:21:47 +01:00
|
|
|
if(data == NULL)
|
|
|
|
return false;
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2012-12-09 21:21:47 +01:00
|
|
|
PNGUPROP imgProp;
|
2012-01-21 21:57:41 +01:00
|
|
|
IMGCTX ctx = PNGU_SelectImageFromBuffer(data);
|
|
|
|
if (ctx == NULL)
|
|
|
|
return false;
|
|
|
|
int ret = PNGU_GetImageProperties(ctx, &imgProp);
|
|
|
|
PNGU_ReleaseImageContext(ctx);
|
|
|
|
return ret == PNGU_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool checkPNGFile(const char *filename)
|
|
|
|
{
|
2013-06-30 20:40:49 +02:00
|
|
|
u32 fileSize = 0;
|
|
|
|
u8 *buffer = fsop_ReadFile(filename, &fileSize);
|
|
|
|
bool ret = false;
|
2012-12-09 21:21:47 +01:00
|
|
|
if(buffer != NULL)
|
2013-06-30 20:40:49 +02:00
|
|
|
{
|
|
|
|
ret = checkPNGBuf(buffer);
|
2012-12-09 21:21:47 +01:00
|
|
|
MEM2_free(buffer);
|
2013-06-30 20:40:49 +02:00
|
|
|
}
|
2012-12-09 21:21:47 +01:00
|
|
|
return ret;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_initAsyncNetwork()
|
|
|
|
{
|
|
|
|
if (!_isNetworkAvailable()) return;
|
|
|
|
m_thrdNetwork = true;
|
|
|
|
net_init_async(_networkComplete, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CMenu::_isNetworkAvailable()
|
|
|
|
{
|
|
|
|
bool retval = false;
|
|
|
|
u32 size;
|
2012-11-12 21:12:00 +01:00
|
|
|
char ISFS_Filepath[32] ATTRIBUTE_ALIGN(32);
|
|
|
|
strcpy(ISFS_Filepath, "/shared2/sys/net/02/config.dat");
|
|
|
|
u8 *buf = ISFS_GetFile(ISFS_Filepath, &size, -1);
|
2012-01-21 21:57:41 +01:00
|
|
|
if (buf && size > 4)
|
|
|
|
{
|
|
|
|
retval = buf[4] > 0; // There is a valid connection defined.
|
2012-07-27 19:26:49 +02:00
|
|
|
free(buf);
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 CMenu::_networkComplete(s32 ok, void *usrData)
|
|
|
|
{
|
|
|
|
CMenu *m = (CMenu *) usrData;
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-12-22 21:57:23 +01:00
|
|
|
networkInit = ok == 0;
|
2012-01-21 21:57:41 +01:00
|
|
|
m->m_thrdNetwork = false;
|
|
|
|
|
2013-09-06 01:52:21 +02:00
|
|
|
gprintf("NET: Network init complete, enabled wifi_gecko: %s\n", m->m_use_wifi_gecko ? "yes" : "no");
|
|
|
|
if(m->m_use_wifi_gecko)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-12-08 17:17:35 +01:00
|
|
|
const string &ip = m->m_cfg.getString("DEBUG", "wifi_gecko_ip");
|
2012-05-11 00:20:18 +02:00
|
|
|
u16 port = m->m_cfg.getInt("DEBUG", "wifi_gecko_port", 4405);
|
2012-12-08 17:17:35 +01:00
|
|
|
if(ip.size() > 0 && port != 0)
|
|
|
|
WiFiDebugger.Init(ip.c_str(), port);
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2013-09-06 01:52:21 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CMenu::_initNetwork()
|
|
|
|
{
|
2013-09-04 18:53:55 +02:00
|
|
|
while (net_get_status() == -EBUSY && m_thrdNetwork == true) { usleep(100); }; // Async initialization may be busy, wait to see if it succeeds.
|
2012-12-22 21:57:23 +01:00
|
|
|
if (networkInit) return 0;
|
2012-01-21 21:57:41 +01:00
|
|
|
if (!_isNetworkAvailable()) return -2;
|
|
|
|
|
|
|
|
char ip[16];
|
|
|
|
int val = if_config(ip, NULL, NULL, true);
|
|
|
|
|
2012-12-22 21:57:23 +01:00
|
|
|
networkInit = !val;
|
2012-01-21 21:57:41 +01:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CMenu::_coverDownloader(bool missingOnly)
|
|
|
|
{
|
2012-05-06 14:03:43 +02:00
|
|
|
vector<string> coverList;
|
2012-06-08 21:29:23 +02:00
|
|
|
vector<dir_discHdr> pluginCoverList;
|
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
int count = 0, countFlat = 0;
|
|
|
|
float listWeight = missingOnly ? 0.125f : 0.f; // 1/8 of the progress bar for testing the PNGs we already have
|
|
|
|
float dlWeight = 1.f - listWeight;
|
|
|
|
|
|
|
|
u32 bufferSize = 0x280000; // Maximum download size 2 MB
|
2012-11-03 20:16:03 +01:00
|
|
|
u8 *buffer = (u8*)MEM2_alloc(bufferSize);
|
|
|
|
if(buffer == NULL)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
2013-08-22 20:55:08 +02:00
|
|
|
_setThrdMsg(_t("dlmsg27", L"Not enough memory!"), 1.f);
|
2012-01-21 21:57:41 +01:00
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
m_thrdWorking = false;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
bool savePNG = m_cfg.getBool("GENERAL", "keep_png", true);
|
|
|
|
|
2012-05-06 14:03:43 +02:00
|
|
|
vector<string> fmtURLBox = stringToVector(m_cfg.getString("GENERAL", "url_full_covers", FMT_BPIC_URL), '|');
|
|
|
|
vector<string> fmtURLFlat = stringToVector(m_cfg.getString("GENERAL", "url_flat_covers", FMT_PIC_URL), '|');
|
|
|
|
vector<string> fmtURLCBox = stringToVector(m_cfg.getString("GENERAL", "url_custom_full_covers", FMT_CBPIC_URL), '|');
|
|
|
|
vector<string> fmtURLCFlat = stringToVector(m_cfg.getString("GENERAL", "url_custom_flat_covers", FMT_CPIC_URL), '|');
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
u32 nbSteps = m_gameList.size();
|
|
|
|
u32 step = 0;
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
GameTDB c_gameTDB;
|
|
|
|
if (m_settingsDir.size() > 0)
|
|
|
|
{
|
2012-05-04 14:30:43 +02:00
|
|
|
c_gameTDB.OpenFile(fmt("%s/wiitdb.xml", m_settingsDir.c_str()));
|
2012-02-12 02:43:31 +01:00
|
|
|
c_gameTDB.SetLanguageCode(m_curLanguage.c_str());
|
|
|
|
}
|
2012-06-17 13:01:43 +02:00
|
|
|
|
|
|
|
Config m_checksums;
|
2012-06-17 13:12:07 +02:00
|
|
|
m_checksums.load(fmt("%s/%s", m_settingsDir.c_str(), PLUGIN_CRCS_FILENAME));
|
2012-06-17 13:01:43 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
if (m_coverDLGameId.empty())
|
|
|
|
{
|
|
|
|
coverList.reserve(m_gameList.size());
|
|
|
|
for (u32 i = 0; i < m_gameList.size() && !m_thrdStop; ++i)
|
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg7", L"Listing covers to download..."), listWeight * (float)step / (float)nbSteps);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
++step;
|
2013-09-24 17:21:31 +02:00
|
|
|
char *path = NULL;
|
|
|
|
const char *id = NULL;
|
2012-06-17 13:01:43 +02:00
|
|
|
if(m_gameList[i].type == TYPE_PLUGIN)
|
2012-06-08 21:29:23 +02:00
|
|
|
{
|
|
|
|
char gamePath[256];
|
2013-09-24 17:21:31 +02:00
|
|
|
if(strchr(m_gameList[i].path, '/') != NULL)
|
|
|
|
strncpy(gamePath, strrchr(m_gameList[i].path, '/') + 1, sizeof(gamePath));
|
2012-06-08 21:29:23 +02:00
|
|
|
else
|
|
|
|
strncpy(gamePath, m_gameList[i].path, sizeof(gamePath));
|
2013-09-24 17:21:31 +02:00
|
|
|
path = fmt_malloc("%s/%s.png", m_boxPicDir.c_str(), gamePath);
|
2012-06-08 21:29:23 +02:00
|
|
|
id = path;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-24 17:21:31 +02:00
|
|
|
path = fmt_malloc("%s/%s.png", m_boxPicDir.c_str(), m_gameList[i].id);
|
|
|
|
id = m_gameList[i].id;
|
2012-06-08 21:29:23 +02:00
|
|
|
}
|
2013-09-24 17:21:31 +02:00
|
|
|
if(!missingOnly || (id != NULL && !CoverFlow.fullCoverCached(id) && path != NULL && !checkPNGFile(path)))
|
2012-06-08 21:29:23 +02:00
|
|
|
{
|
2012-06-17 13:01:43 +02:00
|
|
|
if(m_gameList[i].type == TYPE_PLUGIN)
|
2012-06-08 21:29:23 +02:00
|
|
|
pluginCoverList.push_back(m_gameList[i]);
|
2013-09-24 17:21:31 +02:00
|
|
|
if(id != NULL)
|
|
|
|
coverList.push_back(id);
|
2012-06-08 21:29:23 +02:00
|
|
|
}
|
2013-09-24 17:21:31 +02:00
|
|
|
if(path != NULL)
|
|
|
|
MEM2_free(path);
|
|
|
|
path = NULL;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
coverList.push_back(m_coverDLGameId);
|
|
|
|
|
|
|
|
u32 n = coverList.size();
|
|
|
|
if (n > 0 && !m_thrdStop)
|
|
|
|
{
|
|
|
|
step = 0;
|
|
|
|
nbSteps = 1 + n * 2;
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg1", L"Initializing network..."), listWeight + dlWeight * (float)step / (float)nbSteps);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
if (_initNetwork() < 0)
|
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg2", L"Network initialization failed!"), 1.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
m_thrdWorking = false;
|
2012-11-03 20:16:03 +01:00
|
|
|
free(buffer);
|
2012-01-21 21:57:41 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
m_thrdStepLen = dlWeight / (float)nbSteps;
|
|
|
|
|
|
|
|
Config m_newID;
|
2012-05-04 14:30:43 +02:00
|
|
|
m_newID.load(fmt("%s/newid.ini", m_settingsDir.c_str()));
|
2013-06-30 20:40:49 +02:00
|
|
|
m_newID.setString("CHANNELS", "WFSF", "DWFA");
|
|
|
|
u32 CoverType = 0;
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
for(u32 i = 0; i < coverList.size() && !m_thrdStop; ++i)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
string url;
|
|
|
|
const char *domain = _domainFromView();
|
|
|
|
bool success = false;
|
2012-02-12 02:43:31 +01:00
|
|
|
bool original = true;
|
|
|
|
bool custom = false;
|
|
|
|
int c_altCase = 0;
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2013-09-24 17:21:31 +02:00
|
|
|
const string &newID = m_newID.getString(domain, coverList[i], coverList[i]);
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2013-01-15 14:54:33 +01:00
|
|
|
if(!newID.empty() && strncasecmp(newID.c_str(), coverList[i].c_str(), coverList[i].length()) == 0)
|
2012-01-21 21:57:41 +01:00
|
|
|
m_newID.remove(domain, coverList[i]);
|
|
|
|
else if(!newID.empty())
|
|
|
|
{
|
2012-02-12 02:43:31 +01:00
|
|
|
gprintf("old id = %s\nnew id = %s\n", coverList[i].c_str(), newID.c_str());
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
for( int p = 0; p < 4; ++p )
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-02-12 02:43:31 +01:00
|
|
|
switch(p)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-02-12 02:43:31 +01:00
|
|
|
case 0:
|
|
|
|
CoverType = m_downloadPrioVal&C_TYPE_PRIOA ? CBOX : BOX;
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case 1:
|
|
|
|
CoverType = m_downloadPrioVal&C_TYPE_PRIOA ? ( m_downloadPrioVal&C_TYPE_PRIOB ? CFLAT : BOX ) : ( m_downloadPrioVal&C_TYPE_PRIOB ? CBOX : FLAT );
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case 2:
|
|
|
|
CoverType = m_downloadPrioVal&C_TYPE_PRIOA ? ( m_downloadPrioVal&C_TYPE_PRIOB ? BOX : CFLAT ) : ( m_downloadPrioVal&C_TYPE_PRIOB ? FLAT : CBOX );
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case 3:
|
|
|
|
CoverType = m_downloadPrioVal&C_TYPE_PRIOA ? FLAT : CFLAT;
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
switch( CoverType )
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-02-12 02:43:31 +01:00
|
|
|
case BOX:
|
|
|
|
if( m_downloadPrioVal&C_TYPE_ONOR )
|
|
|
|
original = false;
|
|
|
|
if (!success && !m_thrdStop && original)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2013-09-24 17:21:31 +02:00
|
|
|
char *path = fmt_malloc("%s/%s.png", m_boxPicDir.c_str(), coverList[i].c_str());
|
|
|
|
if(path != NULL && !checkPNGFile(path))
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
for (u32 j = 0; !success && j < fmtURLBox.size() && !m_thrdStop; ++j)
|
2012-06-08 21:29:23 +02:00
|
|
|
{
|
2012-06-17 13:01:43 +02:00
|
|
|
if(pluginCoverList.size() && pluginCoverList[i].type == TYPE_PLUGIN)
|
|
|
|
url = m_plugin.GenerateCoverLink(pluginCoverList[i], fmtURLBox[j], m_checksums);
|
2012-06-08 21:29:23 +02:00
|
|
|
else
|
|
|
|
url = makeURL(fmtURLBox[j], newID, countryCode(newID));
|
2012-02-12 02:43:31 +01:00
|
|
|
if (j == 0) ++step;
|
|
|
|
m_thrdStep = listWeight + dlWeight * (float)step / (float)nbSteps;
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(wfmt(_fmt("dlmsg3", L"Downloading from %s"), url.c_str()), m_thrdStep);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
2012-11-03 20:16:03 +01:00
|
|
|
download = downloadfile(buffer, bufferSize, url.c_str(), CMenu::_downloadProgress, this);
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
for( int o = 0; o < 12; ++o )
|
|
|
|
{
|
|
|
|
bool tdl = false;
|
2012-05-17 15:26:02 +02:00
|
|
|
if(download.data != NULL && download.size > 0 && checkPNGBuf(download.data))
|
2012-02-12 02:43:31 +01:00
|
|
|
break;
|
2012-06-17 13:01:43 +02:00
|
|
|
if(pluginCoverList.size() && pluginCoverList[i].type == TYPE_PLUGIN)
|
2012-06-08 21:29:23 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
switch( o )
|
|
|
|
{
|
2012-06-08 21:29:23 +02:00
|
|
|
case EN:
|
2012-02-12 02:43:31 +01:00
|
|
|
if(( newID[3] == 'E' || newID[3] == 'X' || newID[3] == 'Y' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_EN )
|
|
|
|
url = makeURL(fmtURLBox[j], newID, "EN");
|
|
|
|
tdl = true;
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case JA:
|
|
|
|
if(newID[3] == 'J' && m_downloadPrioVal&C_TYPE_JA)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLBox[j], newID, "JA");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case FR:
|
|
|
|
if((newID[3] == 'F' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_FR)
|
2012-05-13 17:13:33 +02:00
|
|
|
{
|
2012-02-12 02:43:31 +01:00
|
|
|
url = makeURL(fmtURLBox[j], newID, "FR");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case DE:
|
|
|
|
if((newID[3] == 'D' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_DE)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLBox[j], newID, "DE");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case ES:
|
|
|
|
if((newID[3] == 'S' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_ES)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLBox[j], newID, "ES");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case IT:
|
|
|
|
if((newID[3] == 'I' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_IT)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLBox[j], newID, "IT");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case NL:
|
2012-02-12 02:43:31 +01:00
|
|
|
if(newID[3] == 'P' && m_downloadPrioVal&C_TYPE_NL)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLBox[j], newID, "NL");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case PT:
|
2012-02-12 02:43:31 +01:00
|
|
|
if(newID[3] == 'P' && m_downloadPrioVal&C_TYPE_PT)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLBox[j], newID, "PT");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case RU:
|
2012-02-12 02:43:31 +01:00
|
|
|
if((newID[3] == 'R' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_RU)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLBox[j], newID, "RU");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case KO:
|
2012-02-12 02:43:31 +01:00
|
|
|
if(newID[3] == 'K' && m_downloadPrioVal&C_TYPE_KO)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLBox[j], newID, "KO");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case AU:
|
2012-02-12 02:43:31 +01:00
|
|
|
if(newID[3] == 'W' && m_downloadPrioVal&C_TYPE_ZHCN)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLBox[j], newID, "ZH");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case ZHCN:
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
2013-06-30 20:40:49 +02:00
|
|
|
if ( tdl )
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(wfmt(_fmt("dlmsg3", L"Downloading from %s"), url.c_str()), m_thrdStep);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
2012-11-03 20:16:03 +01:00
|
|
|
download = downloadfile(buffer, bufferSize, url.c_str(), CMenu::_downloadProgress, this);
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-17 15:26:02 +02:00
|
|
|
if(download.data == NULL || download.size == 0 || !checkPNGBuf(download.data))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (savePNG)
|
2012-06-08 21:29:23 +02:00
|
|
|
{
|
2012-02-12 02:43:31 +01:00
|
|
|
LWP_MutexLock(m_mutex);
|
2013-09-24 17:21:31 +02:00
|
|
|
_setThrdMsg(wfmt(_fmt("dlmsg4", L"Saving %s"), path), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps);
|
2012-02-12 02:43:31 +01:00
|
|
|
LWP_MutexUnlock(m_mutex);
|
2013-09-24 17:21:31 +02:00
|
|
|
fsop_WriteFile(path, download.data, download.size);
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
2012-05-17 15:26:02 +02:00
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverList[i].c_str()).c_str()), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
2012-11-11 19:28:03 +01:00
|
|
|
if (CoverFlow.preCacheCover(coverList[i].c_str(), download.data, true))
|
2012-05-17 15:26:02 +02:00
|
|
|
{
|
|
|
|
++count;
|
|
|
|
success = true;
|
|
|
|
}
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
|
|
|
}
|
2013-09-24 17:21:31 +02:00
|
|
|
if(path != NULL)
|
|
|
|
MEM2_free(path);
|
|
|
|
path = NULL;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case CBOX:
|
|
|
|
if( m_downloadPrioVal&C_TYPE_ONCU )
|
|
|
|
custom = true;
|
|
|
|
c_altCase = c_gameTDB.GetCaseVersions( coverList[i].c_str() );
|
2013-09-24 17:21:31 +02:00
|
|
|
if(!success && !m_thrdStop && c_gameTDB.IsLoaded() && c_altCase > 1 && custom)
|
2012-06-08 21:29:23 +02:00
|
|
|
{
|
2013-09-24 17:21:31 +02:00
|
|
|
char *path = fmt_malloc("%s/%s.png", m_boxPicDir.c_str(), coverList[i].c_str());
|
|
|
|
if(path != NULL && !checkPNGFile(path))
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
for (u32 j = 0; !success && j < fmtURLCBox.size() && !m_thrdStop; ++j)
|
2012-06-08 21:29:23 +02:00
|
|
|
{
|
2012-06-17 13:01:43 +02:00
|
|
|
if(pluginCoverList.size() && pluginCoverList[i].type == TYPE_PLUGIN)
|
|
|
|
url = m_plugin.GenerateCoverLink(pluginCoverList[i], fmtURLCBox[j], m_checksums);
|
2012-06-08 21:29:23 +02:00
|
|
|
else
|
|
|
|
url = makeURL(fmtURLCBox[j], newID, countryCode(newID));
|
2012-02-12 02:43:31 +01:00
|
|
|
if (j == 0) ++step;
|
|
|
|
m_thrdStep = listWeight + dlWeight * (float)step / (float)nbSteps;
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(wfmt(_fmt("dlmsg3", L"Downloading from %s"), url.c_str()), m_thrdStep);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
2012-11-03 20:16:03 +01:00
|
|
|
download = downloadfile(buffer, bufferSize, url.c_str(), CMenu::_downloadProgress, this);
|
2012-02-12 02:43:31 +01:00
|
|
|
for( int o = 0; o < 12; ++o )
|
|
|
|
{
|
|
|
|
bool tdl = false;
|
2012-05-17 15:26:02 +02:00
|
|
|
if(download.data != NULL && download.size > 0 && checkPNGBuf(download.data))
|
2012-06-08 21:29:23 +02:00
|
|
|
break;
|
2012-06-17 13:01:43 +02:00
|
|
|
if(pluginCoverList.size() && pluginCoverList[i].type == TYPE_PLUGIN)
|
2012-06-08 21:29:23 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
switch( o )
|
|
|
|
{
|
2012-06-08 21:29:23 +02:00
|
|
|
case EN:
|
2012-02-12 02:43:31 +01:00
|
|
|
if(( newID[3] == 'E' || newID[3] == 'X' || newID[3] == 'Y' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_EN )
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], newID, "EN");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case JA:
|
|
|
|
if(newID[3] == 'J' && m_downloadPrioVal&C_TYPE_JA)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], newID, "JA");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case FR:
|
|
|
|
if((newID[3] == 'F' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_FR)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], newID, "FR");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case DE:
|
|
|
|
if((newID[3] == 'D' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_DE)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], newID, "DE");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case ES:
|
|
|
|
if((newID[3] == 'S' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_ES)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], newID, "ES");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case IT:
|
|
|
|
if((newID[3] == 'I' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_IT)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], newID, "IT");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case NL:
|
2012-02-12 02:43:31 +01:00
|
|
|
if(newID[3] == 'P' && m_downloadPrioVal&C_TYPE_NL)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], newID, "NL");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case PT:
|
2012-02-12 02:43:31 +01:00
|
|
|
if(newID[3] == 'P' && m_downloadPrioVal&C_TYPE_PT)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], newID, "PT");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case RU:
|
2012-02-12 02:43:31 +01:00
|
|
|
if((newID[3] == 'R' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_RU)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], newID, "RU");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case KO:
|
2012-02-12 02:43:31 +01:00
|
|
|
if(newID[3] == 'K' && m_downloadPrioVal&C_TYPE_KO)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], newID, "KO");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case AU:
|
2012-02-12 02:43:31 +01:00
|
|
|
if(newID[3] == 'W' && m_downloadPrioVal&C_TYPE_ZHCN)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], newID, "ZH");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case ZHCN:
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2013-06-30 20:40:49 +02:00
|
|
|
if ( tdl )
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(wfmt(_fmt("dlmsg3", L"Downloading from %s"), url.c_str()), m_thrdStep);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
2012-11-03 20:16:03 +01:00
|
|
|
download = downloadfile(buffer, bufferSize, url.c_str(), CMenu::_downloadProgress, this);
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-17 15:26:02 +02:00
|
|
|
if(download.data == NULL || download.size == 0 || !checkPNGBuf(download.data))
|
|
|
|
continue;
|
2012-02-12 02:43:31 +01:00
|
|
|
|
2012-05-17 15:26:02 +02:00
|
|
|
if (savePNG)
|
|
|
|
{
|
2012-02-12 02:43:31 +01:00
|
|
|
LWP_MutexLock(m_mutex);
|
2013-09-24 17:21:31 +02:00
|
|
|
_setThrdMsg(wfmt(_fmt("dlmsg4", L"Saving %s"), path), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps);
|
2012-02-12 02:43:31 +01:00
|
|
|
LWP_MutexUnlock(m_mutex);
|
2013-09-24 17:21:31 +02:00
|
|
|
fsop_WriteFile(path, download.data, download.size);
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
2012-05-17 15:26:02 +02:00
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverList[i].c_str()).c_str()), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
2012-11-11 19:28:03 +01:00
|
|
|
if (CoverFlow.preCacheCover(coverList[i].c_str(), download.data, true))
|
2012-05-17 15:26:02 +02:00
|
|
|
{
|
|
|
|
++count;
|
|
|
|
success = true;
|
|
|
|
}
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
|
|
|
}
|
2013-09-24 17:21:31 +02:00
|
|
|
if(path != NULL)
|
|
|
|
MEM2_free(path);
|
|
|
|
path = NULL;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-06-08 21:29:23 +02:00
|
|
|
case FLAT:
|
2012-02-12 02:43:31 +01:00
|
|
|
if( m_downloadPrioVal&C_TYPE_ONOR )
|
|
|
|
original = false;
|
2013-09-24 17:21:31 +02:00
|
|
|
if(!success && !m_thrdStop && original)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2013-09-24 17:21:31 +02:00
|
|
|
char *path = fmt_malloc("%s/%s.png", m_picDir.c_str(), coverList[i].c_str());
|
|
|
|
if(path != NULL && !checkPNGFile(path))
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-02-12 02:43:31 +01:00
|
|
|
// Try to get the front cover
|
|
|
|
if (m_thrdStop) break;
|
|
|
|
for (u32 j = 0; !success && j < fmtURLFlat.size() && !m_thrdStop; ++j)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-06-17 13:01:43 +02:00
|
|
|
if(pluginCoverList.size() && pluginCoverList[i].type == TYPE_PLUGIN)
|
|
|
|
url = m_plugin.GenerateCoverLink(pluginCoverList[i], fmtURLFlat[j], m_checksums);
|
2012-06-08 21:29:23 +02:00
|
|
|
else
|
|
|
|
url = makeURL(fmtURLFlat[j], newID, countryCode(newID));
|
2012-02-12 02:43:31 +01:00
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(wfmt(_fmt("dlmsg8", L"Full cover not found. Downloading from %s"), url.c_str()), listWeight + dlWeight * (float)step / (float)nbSteps);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
2012-11-03 20:16:03 +01:00
|
|
|
download = downloadfile(buffer, bufferSize, url.c_str(), CMenu::_downloadProgress, this);
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
for( int o = 0; o < 12; ++o )
|
|
|
|
{
|
|
|
|
bool tdl = false;
|
2012-05-17 15:26:02 +02:00
|
|
|
if(download.data != NULL && download.size > 0 && checkPNGBuf(download.data))
|
2012-06-08 21:29:23 +02:00
|
|
|
break;
|
2012-06-17 13:01:43 +02:00
|
|
|
if(pluginCoverList.size() && pluginCoverList[i].type == TYPE_PLUGIN)
|
2012-06-08 21:29:23 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
switch( o )
|
|
|
|
{
|
2012-06-08 21:29:23 +02:00
|
|
|
case EN:
|
2012-02-12 02:43:31 +01:00
|
|
|
if(( newID[3] == 'E' || newID[3] == 'X' || newID[3] == 'Y' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_EN )
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], newID, "EN");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case JA:
|
|
|
|
if(newID[3] == 'J' && m_downloadPrioVal&C_TYPE_JA)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], newID, "JA");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case FR:
|
|
|
|
if((newID[3] == 'F' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_FR)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], newID, "FR");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case DE:
|
|
|
|
if((newID[3] == 'D' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_DE)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], newID, "DE");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case ES:
|
|
|
|
if((newID[3] == 'S' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_ES)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], newID, "ES");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case IT:
|
|
|
|
if((newID[3] == 'I' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_IT)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], newID, "IT");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case NL:
|
2012-02-12 02:43:31 +01:00
|
|
|
if(newID[3] == 'P' && m_downloadPrioVal&C_TYPE_NL)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], newID, "NL");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case PT:
|
2012-02-12 02:43:31 +01:00
|
|
|
if(newID[3] == 'P' && m_downloadPrioVal&C_TYPE_PT)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], newID, "PT");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case RU:
|
2012-02-12 02:43:31 +01:00
|
|
|
if((newID[3] == 'R' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_RU)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], newID, "RU");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case KO:
|
2012-02-12 02:43:31 +01:00
|
|
|
if(newID[3] == 'K' && m_downloadPrioVal&C_TYPE_KO)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], newID, "KO");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case AU:
|
2012-02-12 02:43:31 +01:00
|
|
|
if(newID[3] == 'W' && m_downloadPrioVal&C_TYPE_ZHCN)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], newID, "ZH");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case ZHCN:
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
2013-06-30 20:40:49 +02:00
|
|
|
if ( tdl )
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(wfmt(_fmt("dlmsg3", L"Downloading from %s"), url.c_str()), m_thrdStep);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
2012-11-03 20:16:03 +01:00
|
|
|
download = downloadfile(buffer, bufferSize, url.c_str(), CMenu::_downloadProgress, this);
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-05-17 15:26:02 +02:00
|
|
|
if(download.data == NULL || download.size == 0 || !checkPNGBuf(download.data))
|
|
|
|
continue;
|
2012-02-12 02:43:31 +01:00
|
|
|
|
2012-05-17 15:26:02 +02:00
|
|
|
if (savePNG)
|
|
|
|
{
|
2012-02-12 02:43:31 +01:00
|
|
|
LWP_MutexLock(m_mutex);
|
2013-09-24 17:21:31 +02:00
|
|
|
_setThrdMsg(wfmt(_fmt("dlmsg4", L"Saving %s"), path), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps);
|
2012-02-12 02:43:31 +01:00
|
|
|
LWP_MutexUnlock(m_mutex);
|
2013-09-24 17:21:31 +02:00
|
|
|
fsop_WriteFile(path, download.data, download.size);
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
2012-05-17 15:26:02 +02:00
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverList[i].c_str()).c_str()), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
2012-11-11 19:28:03 +01:00
|
|
|
if (CoverFlow.preCacheCover(coverList[i].c_str(), download.data, false))
|
2012-05-17 15:26:02 +02:00
|
|
|
{
|
|
|
|
++countFlat;
|
|
|
|
success = true;
|
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
}
|
2013-09-24 17:21:31 +02:00
|
|
|
if(path != NULL)
|
|
|
|
MEM2_free(path);
|
|
|
|
path = NULL;
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case CFLAT:
|
2012-02-12 02:43:31 +01:00
|
|
|
if( m_downloadPrioVal&C_TYPE_ONCU )
|
|
|
|
custom = true;
|
2013-09-24 17:21:31 +02:00
|
|
|
if(!success && !m_thrdStop && c_gameTDB.IsLoaded() && c_altCase > 1 && custom)
|
|
|
|
{
|
|
|
|
char *path = fmt_malloc("%s/%s.png", m_picDir.c_str(), coverList[i].c_str());
|
|
|
|
if(path != NULL && !checkPNGFile(path))
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-02-12 02:43:31 +01:00
|
|
|
// Try to get the front cover
|
|
|
|
if (m_thrdStop) break;
|
|
|
|
for (u32 j = 0; !success && j < fmtURLCFlat.size() && !m_thrdStop; ++j)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], newID, countryCode(newID));
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(wfmt(_fmt("dlmsg8", L"Full cover not found. Downloading from %s"), url.c_str()), listWeight + dlWeight * (float)step / (float)nbSteps);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
2012-11-03 20:16:03 +01:00
|
|
|
download = downloadfile(buffer, bufferSize, url.c_str(), CMenu::_downloadProgress, this);
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
for( int o = 0; o < 12; ++o )
|
|
|
|
{
|
|
|
|
bool tdl = false;
|
2012-05-17 15:26:02 +02:00
|
|
|
if(download.data != NULL && download.size > 0 && checkPNGBuf(download.data))
|
2013-06-30 20:40:49 +02:00
|
|
|
break;
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
switch( o )
|
|
|
|
{
|
2013-06-30 20:40:49 +02:00
|
|
|
case EN:
|
2012-02-12 02:43:31 +01:00
|
|
|
if(( newID[3] == 'E' || newID[3] == 'X' || newID[3] == 'Y' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_EN )
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], newID, "EN");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case JA:
|
|
|
|
if(newID[3] == 'J' && m_downloadPrioVal&C_TYPE_JA)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], newID, "JA");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case FR:
|
|
|
|
if((newID[3] == 'F' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_FR)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], newID, "FR");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case DE:
|
|
|
|
if((newID[3] == 'D' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_DE)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], newID, "DE");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case ES:
|
|
|
|
if((newID[3] == 'S' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_ES)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], newID, "ES");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
case IT:
|
|
|
|
if((newID[3] == 'I' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_IT)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], newID, "IT");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case NL:
|
2012-02-12 02:43:31 +01:00
|
|
|
if(newID[3] == 'P' && m_downloadPrioVal&C_TYPE_NL)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], newID, "NL");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case PT:
|
2012-02-12 02:43:31 +01:00
|
|
|
if(newID[3] == 'P' && m_downloadPrioVal&C_TYPE_PT)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], newID, "PT");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case RU:
|
2012-02-12 02:43:31 +01:00
|
|
|
if((newID[3] == 'R' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_RU)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], newID, "RU");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case KO:
|
2012-02-12 02:43:31 +01:00
|
|
|
if(newID[3] == 'K' && m_downloadPrioVal&C_TYPE_KO)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], newID, "KO");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case AU:
|
2012-02-12 02:43:31 +01:00
|
|
|
if((newID[3] == 'P' || newID[3] == 'Y' || newID[3] == 'X') && m_downloadPrioVal&C_TYPE_ZHCN)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], newID, "ZH");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2013-06-30 20:40:49 +02:00
|
|
|
case ZHCN:
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
2013-06-30 20:40:49 +02:00
|
|
|
if ( tdl )
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(wfmt(_fmt("dlmsg3", L"Downloading from %s"), url.c_str()), m_thrdStep);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
2012-11-03 20:16:03 +01:00
|
|
|
download = downloadfile(buffer, bufferSize, url.c_str(), CMenu::_downloadProgress, this);
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-17 15:26:02 +02:00
|
|
|
if(download.data == NULL || download.size == 0 || !checkPNGBuf(download.data))
|
|
|
|
continue;
|
|
|
|
|
2013-06-30 20:40:49 +02:00
|
|
|
if(savePNG)
|
2012-05-17 15:26:02 +02:00
|
|
|
{
|
2012-02-12 02:43:31 +01:00
|
|
|
LWP_MutexLock(m_mutex);
|
2013-09-24 17:21:31 +02:00
|
|
|
_setThrdMsg(wfmt(_fmt("dlmsg4", L"Saving %s"), path), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps);
|
2012-02-12 02:43:31 +01:00
|
|
|
LWP_MutexUnlock(m_mutex);
|
2013-09-24 17:21:31 +02:00
|
|
|
fsop_WriteFile(path, download.data, download.size);
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
2012-05-17 15:26:02 +02:00
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverList[i].c_str()).c_str()), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
2012-11-11 19:28:03 +01:00
|
|
|
if (CoverFlow.preCacheCover(coverList[i].c_str(), download.data, false))
|
2012-05-17 15:26:02 +02:00
|
|
|
{
|
|
|
|
++countFlat;
|
|
|
|
success = true;
|
|
|
|
}
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2013-09-24 17:21:31 +02:00
|
|
|
if(path != NULL)
|
|
|
|
MEM2_free(path);
|
|
|
|
path = NULL;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
++step;
|
|
|
|
}
|
2012-02-12 02:43:31 +01:00
|
|
|
if(c_gameTDB.IsLoaded())
|
|
|
|
c_gameTDB.CloseFile();
|
2012-01-21 21:57:41 +01:00
|
|
|
coverList.clear();
|
2012-06-17 13:01:43 +02:00
|
|
|
m_checksums.unload();
|
2012-01-21 21:57:41 +01:00
|
|
|
m_newID.unload();
|
|
|
|
}
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
if (countFlat == 0)
|
|
|
|
_setThrdMsg(wfmt(_fmt("dlmsg5", L"%i/%i files downloaded."), count, n), 1.f);
|
|
|
|
else
|
|
|
|
_setThrdMsg(wfmt(_fmt("dlmsg9", L"%i/%i files downloaded. %i are front covers only."), count + countFlat, n, countFlat), 1.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
m_thrdWorking = false;
|
2012-06-08 21:29:23 +02:00
|
|
|
pluginCoverList.clear();
|
2012-11-03 20:16:03 +01:00
|
|
|
free(buffer);
|
2012-01-21 21:57:41 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_download(string gameId)
|
|
|
|
{
|
|
|
|
lwp_t thread = LWP_THREAD_NULL;
|
|
|
|
int msg = 0;
|
|
|
|
wstringEx prevMsg;
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
bool _updateGametdb = false;
|
|
|
|
|
|
|
|
SetupInput();
|
|
|
|
_showDownload();
|
|
|
|
m_btnMgr.setText(m_downloadBtnCancel, _t("dl1", L"Cancel"));
|
|
|
|
m_thrdStop = false;
|
|
|
|
m_thrdMessageAdded = false;
|
2012-06-08 21:29:23 +02:00
|
|
|
|
2012-11-11 19:28:03 +01:00
|
|
|
if(gameId.size() && CoverFlow.getHdr()->type == TYPE_PLUGIN)
|
2012-06-08 21:29:23 +02:00
|
|
|
{
|
|
|
|
char gamePath[256];
|
2013-09-24 17:21:31 +02:00
|
|
|
if(strchr(CoverFlow.getHdr()->path, '/') != NULL)
|
|
|
|
strncpy(gamePath, strrchr(CoverFlow.getHdr()->path, '/') + 1, sizeof(gamePath));
|
2012-06-08 21:29:23 +02:00
|
|
|
else
|
2012-11-11 19:28:03 +01:00
|
|
|
strncpy(gamePath, CoverFlow.getHdr()->path, sizeof(gamePath));
|
2012-06-08 21:29:23 +02:00
|
|
|
m_coverDLGameId = gamePath;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_coverDLGameId = gameId;
|
|
|
|
|
2012-09-09 20:35:15 +02:00
|
|
|
while(!m_exit)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-09-09 20:35:15 +02:00
|
|
|
_mainLoopCommon();
|
2012-01-21 21:57:41 +01:00
|
|
|
if ((BTN_HOME_PRESSED || BTN_B_PRESSED) && !m_thrdWorking)
|
2012-02-16 20:19:45 +01:00
|
|
|
{
|
|
|
|
if(settingsmenu)
|
|
|
|
{
|
|
|
|
settingsmenu = false;
|
|
|
|
_hideSettings();
|
|
|
|
_showDownload();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
else if (BTN_UP_PRESSED)
|
|
|
|
m_btnMgr.up();
|
|
|
|
else if (BTN_DOWN_PRESSED)
|
|
|
|
m_btnMgr.down();
|
|
|
|
if ((BTN_A_PRESSED || !gameId.empty()) && !(m_thrdWorking && m_thrdStop))
|
|
|
|
{
|
|
|
|
if ((m_btnMgr.selected(m_downloadBtnAll) || m_btnMgr.selected(m_downloadBtnMissing) || !gameId.empty()) && !m_thrdWorking)
|
|
|
|
{
|
|
|
|
bool dlAll = m_btnMgr.selected(m_downloadBtnAll);
|
|
|
|
m_btnMgr.show(m_downloadPBar);
|
|
|
|
m_btnMgr.setProgress(m_downloadPBar, 0.f);
|
2012-02-12 02:43:31 +01:00
|
|
|
_hideSettings();
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.hide(m_downloadBtnAll);
|
|
|
|
m_btnMgr.hide(m_downloadBtnMissing);
|
|
|
|
m_btnMgr.hide(m_downloadBtnGameTDBDownload);
|
|
|
|
m_btnMgr.hide(m_downloadLblCovers);
|
|
|
|
m_btnMgr.hide(m_downloadLblGameTDBDownload);
|
2012-02-12 02:43:31 +01:00
|
|
|
m_btnMgr.hide(m_downloadLblCoverSet);
|
|
|
|
m_btnMgr.hide(m_downloadBtnCoverSet);
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
m_thrdStop = false;
|
|
|
|
m_thrdWorking = true;
|
|
|
|
gameId.clear();
|
|
|
|
if (dlAll)
|
2014-03-17 18:38:32 +01:00
|
|
|
LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_coverDownloaderAll,
|
|
|
|
(void *)this, downloadStack, downloadStackSize, 40);
|
2012-01-21 21:57:41 +01:00
|
|
|
else
|
2014-03-17 18:38:32 +01:00
|
|
|
LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_coverDownloaderMissing,
|
|
|
|
(void *)this, downloadStack, downloadStackSize, 40);
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2012-02-12 02:43:31 +01:00
|
|
|
else if (m_btnMgr.selected(m_downloadBtnPrioM) && !m_thrdWorking)
|
|
|
|
{
|
|
|
|
if( m_downloadPrioVal&C_TYPE_ONOR )
|
|
|
|
{
|
|
|
|
m_downloadPrioVal ^= C_TYPE_ONOR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( m_downloadPrioVal&C_TYPE_ONCU )
|
|
|
|
{
|
|
|
|
if( m_downloadPrioVal&C_TYPE_PRIOA )
|
|
|
|
{
|
2012-02-12 11:56:18 +01:00
|
|
|
if(m_downloadPrioVal&C_TYPE_PRIOB )
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
m_downloadPrioVal ^= C_TYPE_PRIOB;
|
|
|
|
}
|
2012-02-12 11:56:18 +01:00
|
|
|
else
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
m_downloadPrioVal ^= C_TYPE_PRIOA;
|
|
|
|
m_downloadPrioVal ^= C_TYPE_PRIOB;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-12 11:56:18 +01:00
|
|
|
if(m_downloadPrioVal&C_TYPE_PRIOB )
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
m_downloadPrioVal ^= C_TYPE_PRIOB;
|
|
|
|
}
|
2012-02-12 11:56:18 +01:00
|
|
|
else
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
m_downloadPrioVal ^= C_TYPE_ONCU;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_downloadPrioVal ^= C_TYPE_ONOR;
|
|
|
|
m_downloadPrioVal ^= C_TYPE_ONCU;
|
|
|
|
m_downloadPrioVal ^= C_TYPE_PRIOA;
|
|
|
|
m_downloadPrioVal ^= C_TYPE_PRIOB;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_hideSettings();
|
|
|
|
m_cfg.setUInt( "GENERAL", "cover_prio", m_downloadPrioVal );
|
|
|
|
m_cfg.save();
|
|
|
|
_showSettings();
|
|
|
|
}
|
|
|
|
else if (m_btnMgr.selected(m_downloadBtnPrioP) && !m_thrdWorking)
|
|
|
|
{
|
|
|
|
if( m_downloadPrioVal&C_TYPE_ONOR )
|
|
|
|
{
|
|
|
|
m_downloadPrioVal ^= C_TYPE_ONOR;
|
|
|
|
m_downloadPrioVal ^= C_TYPE_ONCU;
|
|
|
|
m_downloadPrioVal ^= C_TYPE_PRIOA;
|
|
|
|
m_downloadPrioVal ^= C_TYPE_PRIOB;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( m_downloadPrioVal&C_TYPE_ONCU )
|
|
|
|
{
|
|
|
|
if( m_downloadPrioVal&C_TYPE_PRIOA )
|
|
|
|
{
|
|
|
|
if(m_downloadPrioVal&C_TYPE_PRIOB )
|
|
|
|
{
|
|
|
|
m_downloadPrioVal ^= C_TYPE_ONOR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_downloadPrioVal ^= C_TYPE_PRIOB;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(m_downloadPrioVal&C_TYPE_PRIOB )
|
|
|
|
{
|
|
|
|
m_downloadPrioVal ^= C_TYPE_PRIOA;
|
|
|
|
m_downloadPrioVal ^= C_TYPE_PRIOB;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_downloadPrioVal ^= C_TYPE_PRIOB;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_downloadPrioVal ^= C_TYPE_ONCU;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_hideSettings();
|
|
|
|
m_cfg.setUInt( "GENERAL", "cover_prio", m_downloadPrioVal );
|
|
|
|
m_cfg.save();
|
|
|
|
_showSettings();
|
|
|
|
}
|
|
|
|
else if (m_btnMgr.selected(m_downloadBtnCoverSet) && !m_thrdWorking)
|
2012-02-16 20:19:45 +01:00
|
|
|
{
|
|
|
|
settingsmenu = true;
|
2012-02-12 02:43:31 +01:00
|
|
|
_showSettings();
|
|
|
|
}
|
|
|
|
else if (m_btnMgr.selected(m_downloadBtnBack) && !m_thrdWorking)
|
2012-02-16 20:19:45 +01:00
|
|
|
{
|
|
|
|
_hideSettings();
|
2012-02-12 02:43:31 +01:00
|
|
|
_showDownload();
|
|
|
|
}
|
|
|
|
else if ((m_btnMgr.selected(m_downloadBtnEN) || m_btnMgr.selected(m_downloadBtnENs)) && !m_thrdWorking)
|
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_EN;
|
|
|
|
m_cfg.setUInt( "GENERAL", "cover_prio", m_downloadPrioVal );
|
|
|
|
m_cfg.save();
|
|
|
|
_showSettings();
|
|
|
|
}
|
|
|
|
else if ((m_btnMgr.selected(m_downloadBtnJA) || m_btnMgr.selected(m_downloadBtnJAs)) && !m_thrdWorking)
|
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_JA;
|
|
|
|
m_cfg.setUInt( "GENERAL", "cover_prio", m_downloadPrioVal );
|
|
|
|
m_cfg.save();
|
|
|
|
_showSettings();
|
|
|
|
}
|
|
|
|
else if ((m_btnMgr.selected(m_downloadBtnFR) || m_btnMgr.selected(m_downloadBtnFRs)) && !m_thrdWorking)
|
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_FR;
|
|
|
|
m_cfg.setUInt( "GENERAL", "cover_prio", m_downloadPrioVal );
|
|
|
|
m_cfg.save();
|
|
|
|
_showSettings();
|
|
|
|
}
|
|
|
|
else if ((m_btnMgr.selected(m_downloadBtnDE) || m_btnMgr.selected(m_downloadBtnDEs)) && !m_thrdWorking)
|
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_DE;
|
|
|
|
m_cfg.setUInt( "GENERAL", "cover_prio", m_downloadPrioVal );
|
|
|
|
m_cfg.save();
|
|
|
|
_showSettings();
|
|
|
|
}
|
|
|
|
else if ((m_btnMgr.selected(m_downloadBtnES) || m_btnMgr.selected(m_downloadBtnESs)) && !m_thrdWorking)
|
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_ES;
|
|
|
|
m_cfg.setUInt( "GENERAL", "cover_prio", m_downloadPrioVal );
|
|
|
|
m_cfg.save();
|
|
|
|
_showSettings();
|
|
|
|
}
|
|
|
|
else if ((m_btnMgr.selected(m_downloadBtnIT) || m_btnMgr.selected(m_downloadBtnITs)) && !m_thrdWorking)
|
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_IT;
|
|
|
|
m_cfg.setUInt( "GENERAL", "cover_prio", m_downloadPrioVal );
|
|
|
|
m_cfg.save();
|
|
|
|
_showSettings();
|
|
|
|
}
|
|
|
|
else if ((m_btnMgr.selected(m_downloadBtnNL) || m_btnMgr.selected(m_downloadBtnNLs)) && !m_thrdWorking)
|
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_NL;
|
|
|
|
m_cfg.setUInt( "GENERAL", "cover_prio", m_downloadPrioVal );
|
|
|
|
m_cfg.save();
|
|
|
|
_showSettings();
|
|
|
|
}
|
|
|
|
else if ((m_btnMgr.selected(m_downloadBtnPT) || m_btnMgr.selected(m_downloadBtnPTs)) && !m_thrdWorking)
|
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_PT;
|
|
|
|
m_cfg.setUInt( "GENERAL", "cover_prio", m_downloadPrioVal );
|
|
|
|
m_cfg.save();
|
|
|
|
_showSettings();
|
|
|
|
}
|
|
|
|
else if ((m_btnMgr.selected(m_downloadBtnRU) || m_btnMgr.selected(m_downloadBtnRUs)) && !m_thrdWorking)
|
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_RU;
|
|
|
|
m_cfg.setUInt( "GENERAL", "cover_prio", m_downloadPrioVal );
|
|
|
|
m_cfg.save();
|
|
|
|
_showSettings();
|
|
|
|
}
|
|
|
|
else if ((m_btnMgr.selected(m_downloadBtnKO) || m_btnMgr.selected(m_downloadBtnKOs)) && !m_thrdWorking)
|
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_KO;
|
|
|
|
m_cfg.setUInt( "GENERAL", "cover_prio", m_downloadPrioVal );
|
|
|
|
m_cfg.save();
|
|
|
|
_showSettings();
|
|
|
|
}
|
|
|
|
else if ((m_btnMgr.selected(m_downloadBtnZHCN) || m_btnMgr.selected(m_downloadBtnZHCNs)) && !m_thrdWorking)
|
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_ZHCN;
|
|
|
|
m_cfg.setUInt( "GENERAL", "cover_prio", m_downloadPrioVal );
|
|
|
|
m_cfg.save();
|
|
|
|
_showSettings();
|
|
|
|
}
|
|
|
|
else if ((m_btnMgr.selected(m_downloadBtnAU) || m_btnMgr.selected(m_downloadBtnAUs)) && !m_thrdWorking)
|
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_AU;
|
|
|
|
m_cfg.setUInt( "GENERAL", "cover_prio", m_downloadPrioVal );
|
|
|
|
m_cfg.save();
|
|
|
|
_showSettings();
|
|
|
|
}
|
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
else if (m_btnMgr.selected(m_downloadBtnGameTDBDownload) && !m_thrdWorking)
|
|
|
|
{
|
|
|
|
m_btnMgr.show(m_downloadPBar);
|
|
|
|
m_btnMgr.setProgress(m_downloadPBar, 0.f);
|
2012-02-12 02:43:31 +01:00
|
|
|
_hideSettings();
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.hide(m_downloadBtnAll);
|
|
|
|
m_btnMgr.hide(m_downloadBtnMissing);
|
|
|
|
m_btnMgr.hide(m_downloadBtnGameTDBDownload);
|
|
|
|
m_btnMgr.hide(m_downloadLblCovers);
|
|
|
|
m_btnMgr.hide(m_downloadLblGameTDBDownload);
|
2012-02-12 11:56:18 +01:00
|
|
|
m_btnMgr.hide(m_downloadLblCoverSet);
|
|
|
|
m_btnMgr.hide(m_downloadBtnCoverSet);
|
2012-01-21 21:57:41 +01:00
|
|
|
m_thrdStop = false;
|
|
|
|
m_thrdWorking = true;
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
_updateGametdb = true;
|
|
|
|
|
2014-03-17 18:38:32 +01:00
|
|
|
LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_gametdbDownloader,
|
|
|
|
(void *)this, downloadStack, downloadStackSize, 40);
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
else if (m_btnMgr.selected(m_downloadBtnCancel))
|
|
|
|
{
|
|
|
|
LockMutex lock(m_mutex);
|
|
|
|
m_thrdStop = true;
|
|
|
|
m_thrdMessageAdded = true;
|
|
|
|
m_thrdMessage = _t("dlmsg6", L"Canceling...");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Sys_Exiting())
|
|
|
|
{
|
|
|
|
LockMutex lock(m_mutex);
|
|
|
|
m_thrdStop = true;
|
|
|
|
m_thrdMessageAdded = true;
|
|
|
|
m_thrdMessage = _t("dlmsg6", L"Canceling...");
|
|
|
|
m_thrdWorking = false;
|
|
|
|
}
|
2012-02-03 23:38:00 +01:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
if (m_thrdMessageAdded)
|
|
|
|
{
|
|
|
|
LockMutex lock(m_mutex);
|
|
|
|
m_thrdMessageAdded = false;
|
|
|
|
m_btnMgr.setProgress(m_downloadPBar, m_thrdProgress);
|
|
|
|
if (m_thrdProgress == 1.f)
|
|
|
|
{
|
|
|
|
if (_updateGametdb)
|
|
|
|
break;
|
|
|
|
m_btnMgr.setText(m_downloadBtnCancel, _t("dl2", L"Back"));
|
|
|
|
}
|
|
|
|
if (prevMsg != m_thrdMessage)
|
|
|
|
{
|
|
|
|
prevMsg = m_thrdMessage;
|
|
|
|
m_btnMgr.setText(m_downloadLblMessage[msg], m_thrdMessage, false);
|
|
|
|
m_btnMgr.hide(m_downloadLblMessage[msg], 0, 0, -1.f, -1.f, true);
|
|
|
|
m_btnMgr.show(m_downloadLblMessage[msg]);
|
|
|
|
msg ^= 1;
|
|
|
|
m_btnMgr.hide(m_downloadLblMessage[msg], 0, 0, -1.f, -1.f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (m_thrdStop && !m_thrdWorking)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (thread != LWP_THREAD_NULL)
|
|
|
|
{
|
|
|
|
LWP_JoinThread(thread, NULL);
|
|
|
|
thread = LWP_THREAD_NULL;
|
|
|
|
}
|
|
|
|
_hideDownload();
|
2012-02-12 02:43:31 +01:00
|
|
|
_hideSettings();
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|
2012-11-03 20:16:03 +01:00
|
|
|
void CMenu::_initDownloadMenu()
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-02-12 02:43:31 +01:00
|
|
|
// Download menu
|
2012-11-03 20:16:03 +01:00
|
|
|
_addUserLabels(m_downloadLblUser, ARRAY_SIZE(m_downloadLblUser), "DOWNLOAD");
|
|
|
|
m_downloadBg = _texture("DOWNLOAD/BG", "texture", theme.bg, false);
|
2013-11-04 20:46:23 +01:00
|
|
|
m_downloadLblTitle = _addTitle("DOWNLOAD/TITLE", theme.titleFont, L"", 0, 10, 640, 60, theme.titleFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE);
|
2012-11-03 20:16:03 +01:00
|
|
|
m_downloadPBar = _addProgressBar("DOWNLOAD/PROGRESS_BAR", 40, 200, 560, 20);
|
2013-11-04 20:46:23 +01:00
|
|
|
m_downloadBtnCancel = _addButton("DOWNLOAD/CANCEL_BTN", theme.btnFont, L"", 420, 400, 200, 48, theme.btnFontColor);
|
|
|
|
m_downloadLblCovers = _addLabel("DOWNLOAD/COVERS", theme.btnFont, L"", 20, 125, 385, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_downloadBtnAll = _addButton("DOWNLOAD/ALL_BTN", theme.btnFont, L"", 420, 130, 200, 48, theme.btnFontColor);
|
|
|
|
m_downloadBtnMissing = _addButton("DOWNLOAD/MISSING_BTN", theme.btnFont, L"", 420, 190, 200, 48, theme.btnFontColor);
|
|
|
|
m_downloadLblCoverSet = _addLabel("DOWNLOAD/COVERSSET", theme.btnFont, L"", 20, 245, 385, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_downloadBtnCoverSet = _addButton("DOWNLOAD/COVERSET_BTN", theme.btnFont, L"", 420, 250, 200, 48, theme.btnFontColor);
|
|
|
|
m_downloadLblGameTDBDownload = _addLabel("DOWNLOAD/GAMETDB_DOWNLOAD", theme.btnFont, L"", 20, 305, 385, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_downloadBtnGameTDBDownload = _addButton("DOWNLOAD/GAMETDB_DOWNLOAD_BTN", theme.btnFont, L"", 420, 310, 200, 48, theme.btnFontColor);
|
|
|
|
m_downloadLblGameTDB = _addLabel("DOWNLOAD/GAMETDB", theme.lblFont, L"", 20, 390, 370, 60, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
2012-11-03 20:16:03 +01:00
|
|
|
m_downloadLblMessage[0] = _addLabel("DOWNLOAD/MESSAGE1", theme.lblFont, L"", 40, 228, 560, 100, theme.txtFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP);
|
|
|
|
m_downloadLblMessage[1] = _addLabel("DOWNLOAD/MESSAGE2", theme.lblFont, L"", 40, 228, 560, 100, theme.txtFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP);
|
2012-03-18 00:14:07 +01:00
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
// Cover settings
|
2013-11-04 20:46:23 +01:00
|
|
|
m_downloadLblSetTitle = _addTitle("DOWNLOAD/SETTITLE", theme.titleFont, L"", 0, 10, 640, 60, theme.titleFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_downloadLblCoverPrio = _addLabel("DOWNLOAD/COVERPRIO", theme.lblFont, L"", 20, 110, 385, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_downloadLblPrio = _addLabel("DOWNLOAD/PRIO_BTN", theme.btnFont, L"", 394, 110, 178, 48, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC);
|
|
|
|
m_downloadBtnPrioM = _addPicButton("DOWNLOAD/PRIO_MINUS", theme.btnTexMinus, theme.btnTexMinusS, 346, 110, 48, 48);
|
|
|
|
m_downloadBtnPrioP = _addPicButton("DOWNLOAD/PRIO_PLUS", theme.btnTexPlus, theme.btnTexPlusS, 572, 110, 48, 48);
|
|
|
|
m_downloadLblRegion = _addLabel("DOWNLOAD/REGION", theme.lblFont, L"", 20, 160, 600, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_downloadBtnEN = _addPicButton("DOWNLOAD/EN", theme.btnENOff, theme.btnENOffs, 20, 215, 80, 80);
|
|
|
|
m_downloadBtnJA = _addPicButton("DOWNLOAD/JA", theme.btnJAOff, theme.btnJAOffs, 330, 300, 80, 80);
|
|
|
|
m_downloadBtnFR = _addPicButton("DOWNLOAD/FR", theme.btnFROff, theme.btnFROffs, 130, 215, 80, 80);
|
|
|
|
m_downloadBtnDE = _addPicButton("DOWNLOAD/DE", theme.btnDEOff, theme.btnDEOffs, 230, 215, 80, 80);
|
|
|
|
m_downloadBtnES = _addPicButton("DOWNLOAD/ES", theme.btnESOff, theme.btnESOffs, 430, 215, 80, 80);
|
|
|
|
m_downloadBtnIT = _addPicButton("DOWNLOAD/IT", theme.btnITOff, theme.btnITOffs, 530, 215, 80, 80);
|
|
|
|
m_downloadBtnNL = _addPicButton("DOWNLOAD/NL", theme.btnNLOff, theme.btnNLOffs, 30, 300, 80, 80);
|
|
|
|
m_downloadBtnPT = _addPicButton("DOWNLOAD/PT", theme.btnPTOff, theme.btnPTOffs, 130, 300, 80, 80);
|
|
|
|
m_downloadBtnRU = _addPicButton("DOWNLOAD/RU", theme.btnRUOff, theme.btnRUOffs, 430, 300, 80, 80);
|
|
|
|
m_downloadBtnKO = _addPicButton("DOWNLOAD/KO", theme.btnKOOff, theme.btnKOOffs, 230, 300, 80, 80);
|
|
|
|
m_downloadBtnZHCN = _addPicButton("DOWNLOAD/ZHCN", theme.btnZHCNOff, theme.btnZHCNOffs, 530, 300, 80, 80);
|
|
|
|
m_downloadBtnAU = _addPicButton("DOWNLOAD/AU", theme.btnAUOff, theme.btnAUOffs, 330, 215, 80, 80);
|
|
|
|
m_downloadBtnENs = _addPicButton("DOWNLOAD/ENS", theme.btnENOn, theme.btnENOns, 20, 215, 80, 80);
|
|
|
|
m_downloadBtnJAs = _addPicButton("DOWNLOAD/JAS", theme.btnJAOn, theme.btnJAOns, 330, 300, 80, 80);
|
|
|
|
m_downloadBtnFRs = _addPicButton("DOWNLOAD/FRS", theme.btnFROn, theme.btnFROns, 130, 215, 80, 80);
|
|
|
|
m_downloadBtnDEs = _addPicButton("DOWNLOAD/DES", theme.btnDEOn, theme.btnDEOns, 230, 215, 80, 80);
|
|
|
|
m_downloadBtnESs = _addPicButton("DOWNLOAD/ESS", theme.btnESOn, theme.btnESOns, 430, 215, 80, 80);
|
|
|
|
m_downloadBtnITs = _addPicButton("DOWNLOAD/ITS", theme.btnITOn, theme.btnITOns, 530, 215, 80, 80);
|
|
|
|
m_downloadBtnNLs = _addPicButton("DOWNLOAD/NLS", theme.btnNLOn, theme.btnNLOns, 30, 300, 80, 80);
|
|
|
|
m_downloadBtnPTs = _addPicButton("DOWNLOAD/PTS", theme.btnPTOn, theme.btnPTOns, 130, 300, 80, 80);
|
|
|
|
m_downloadBtnRUs = _addPicButton("DOWNLOAD/RUS", theme.btnRUOn, theme.btnRUOns, 430, 300, 80, 80);
|
|
|
|
m_downloadBtnKOs = _addPicButton("DOWNLOAD/KOS", theme.btnKOOn, theme.btnKOOns, 230, 300, 80, 80);
|
|
|
|
m_downloadBtnZHCNs = _addPicButton("DOWNLOAD/ZHCNS", theme.btnZHCNOn, theme.btnZHCNOns, 530, 300, 80, 80);
|
|
|
|
m_downloadBtnAUs = _addPicButton("DOWNLOAD/AUS", theme.btnAUOn, theme.btnAUOns, 330, 215, 80, 80);
|
|
|
|
m_downloadBtnBack = _addButton("DOWNLOAD/BACK_BTN", theme.btnFont, L"", 420, 400, 200, 48, theme.btnFontColor);
|
2012-02-03 23:38:00 +01:00
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
// Download menu
|
2012-01-21 21:57:41 +01:00
|
|
|
_setHideAnim(m_downloadLblTitle, "DOWNLOAD/TITLE", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadPBar, "DOWNLOAD/PROGRESS_BAR", 0, 0, -2.f, 0.f);
|
2013-11-04 20:46:23 +01:00
|
|
|
_setHideAnim(m_downloadLblCovers, "DOWNLOAD/COVERS", 50, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnCancel, "DOWNLOAD/CANCEL_BTN", 0, 0, 1.f, -1.f);
|
|
|
|
_setHideAnim(m_downloadBtnAll, "DOWNLOAD/ALL_BTN", -50, 0, 1.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnMissing, "DOWNLOAD/MISSING_BTN", -50, 0, 1.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadLblCoverSet, "DOWNLOAD/COVERSSET", 50, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnCoverSet, "DOWNLOAD/COVERSET_BTN", -50, 0, 1.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadLblGameTDBDownload, "DOWNLOAD/GAMETDB_DOWNLOAD", 50, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnGameTDBDownload, "DOWNLOAD/GAMETDB_DOWNLOAD_BTN", -50, 0, 1.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadLblGameTDB, "DOWNLOAD/GAMETDB", 50, 0, -2.f, 0.f);
|
2012-03-18 00:14:07 +01:00
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
// Cover settings
|
|
|
|
_setHideAnim(m_downloadLblSetTitle, "DOWNLOAD/SETTITLE", 0, 0, -2.f, 0.f);
|
2013-11-04 20:46:23 +01:00
|
|
|
_setHideAnim(m_downloadLblCoverPrio, "DOWNLOAD/COVERPRIO", 50, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadLblPrio, "DOWNLOAD/PRIO_BTN", -50, 0, 1.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnPrioM, "DOWNLOAD/PRIO_MINUS", -50, 0, 1.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnPrioP, "DOWNLOAD/PRIO_PLUS", -50, 0, 1.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadLblRegion, "DOWNLOAD/REGION", 50, 0, -2.f, 0.f);
|
2012-02-12 02:43:31 +01:00
|
|
|
_setHideAnim(m_downloadBtnEN, "DOWNLOAD/EN", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnJA, "DOWNLOAD/JA", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnFR, "DOWNLOAD/FR", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnDE, "DOWNLOAD/DE", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnES, "DOWNLOAD/ES", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnIT, "DOWNLOAD/IT", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnNL, "DOWNLOAD/NL", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnPT, "DOWNLOAD/PT", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnRU, "DOWNLOAD/RU", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnKO, "DOWNLOAD/KO", 0, 0, -2.f, 0.f);
|
2012-06-14 14:36:57 +02:00
|
|
|
_setHideAnim(m_downloadBtnZHCN, "DOWNLOAD/ZHCN", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnAU, "DOWNLOAD/AU", 0, 0, -2.f, 0.f);
|
2012-02-12 02:43:31 +01:00
|
|
|
_setHideAnim(m_downloadBtnENs, "DOWNLOAD/ENS", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnJAs, "DOWNLOAD/JAS", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnFRs, "DOWNLOAD/FRS", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnDEs, "DOWNLOAD/DES", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnESs, "DOWNLOAD/ESS", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnITs, "DOWNLOAD/ITS", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnNLs, "DOWNLOAD/NLS", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnPTs, "DOWNLOAD/PTS", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnRUs, "DOWNLOAD/RUS", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnKOs, "DOWNLOAD/KOS", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnZHCNs, "DOWNLOAD/ZHCNS", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnAUs, "DOWNLOAD/AUS", 0, 0, -2.f, 0.f);
|
2013-11-04 20:46:23 +01:00
|
|
|
_setHideAnim(m_downloadBtnBack, "DOWNLOAD/BACK_BTN", 0, 0, 1.f, -1.f);
|
2012-03-18 00:14:07 +01:00
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
m_downloadPrioVal = m_cfg.getUInt("GENERAL", "cover_prio", 0);
|
2012-03-18 00:14:07 +01:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
_hideDownload(true);
|
|
|
|
_textDownload();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_textDownload(void)
|
|
|
|
{
|
|
|
|
m_btnMgr.setText(m_downloadBtnCancel, _t("dl1", L"Cancel"));
|
|
|
|
m_btnMgr.setText(m_downloadBtnAll, _t("dl3", L"All"));
|
|
|
|
m_btnMgr.setText(m_downloadBtnMissing, _t("dl4", L"Missing"));
|
|
|
|
m_btnMgr.setText(m_downloadLblTitle, _t("dl5", L"Download"));
|
|
|
|
m_btnMgr.setText(m_downloadBtnGameTDBDownload, _t("dl6", L"Download"));
|
|
|
|
m_btnMgr.setText(m_downloadLblCovers, _t("dl8", L"Covers"));
|
|
|
|
m_btnMgr.setText(m_downloadLblGameTDBDownload, _t("dl12", L"GameTDB"));
|
|
|
|
m_btnMgr.setText(m_downloadLblGameTDB, _t("dl10", L"Please donate\nto GameTDB.com"));
|
2012-02-12 02:43:31 +01:00
|
|
|
m_btnMgr.setText(m_downloadLblCoverPrio, _t("dl13", L"Download order"));
|
|
|
|
m_btnMgr.setText(m_downloadLblRegion, _t("dl14", L"Select regions to check for covers:"));
|
|
|
|
m_btnMgr.setText(m_downloadLblCoverSet, _t("dl15", L"Cover download settings"));
|
|
|
|
m_btnMgr.setText(m_downloadBtnCoverSet, _t("dl16", L"Set"));
|
|
|
|
m_btnMgr.setText(m_downloadLblSetTitle, _t("dl17", L"Cover download settings"));
|
|
|
|
m_btnMgr.setText(m_downloadBtnEN, L"EN");
|
|
|
|
m_btnMgr.setText(m_downloadBtnJA, L"JA");
|
|
|
|
m_btnMgr.setText(m_downloadBtnFR, L"FR");
|
|
|
|
m_btnMgr.setText(m_downloadBtnDE, L"DE");
|
|
|
|
m_btnMgr.setText(m_downloadBtnES, L"ES");
|
|
|
|
m_btnMgr.setText(m_downloadBtnIT, L"IT");
|
|
|
|
m_btnMgr.setText(m_downloadBtnNL, L"NL");
|
|
|
|
m_btnMgr.setText(m_downloadBtnPT, L"PT");
|
|
|
|
m_btnMgr.setText(m_downloadBtnRU, L"RU");
|
|
|
|
m_btnMgr.setText(m_downloadBtnKO, L"KO");
|
|
|
|
m_btnMgr.setText(m_downloadBtnZHCN, L"ZHCN");
|
|
|
|
m_btnMgr.setText(m_downloadBtnAU, L"AU");
|
|
|
|
m_btnMgr.setText(m_downloadBtnENs, L"EN");
|
|
|
|
m_btnMgr.setText(m_downloadBtnJAs, L"JA");
|
|
|
|
m_btnMgr.setText(m_downloadBtnFRs, L"FR");
|
|
|
|
m_btnMgr.setText(m_downloadBtnDEs, L"DE");
|
|
|
|
m_btnMgr.setText(m_downloadBtnESs, L"ES");
|
|
|
|
m_btnMgr.setText(m_downloadBtnITs, L"IT");
|
|
|
|
m_btnMgr.setText(m_downloadBtnNLs, L"NL");
|
|
|
|
m_btnMgr.setText(m_downloadBtnPTs, L"PT");
|
|
|
|
m_btnMgr.setText(m_downloadBtnRUs, L"RU");
|
|
|
|
m_btnMgr.setText(m_downloadBtnKOs, L"KO");
|
|
|
|
m_btnMgr.setText(m_downloadBtnZHCNs, L"ZHCN");
|
|
|
|
m_btnMgr.setText(m_downloadBtnAUs, L"AU");
|
|
|
|
m_btnMgr.setText(m_downloadBtnBack, _t("dl18", L"Back"));
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
s8 CMenu::_versionTxtDownloaderInit(CMenu *m) //Handler to download versions txt file
|
|
|
|
{
|
|
|
|
if (!m->m_thrdWorking) return 0;
|
|
|
|
return m->_versionTxtDownloader();
|
|
|
|
}
|
|
|
|
|
|
|
|
s8 CMenu::_versionTxtDownloader() // code to download new version txt file
|
|
|
|
{
|
2012-05-13 17:13:33 +02:00
|
|
|
u32 bufferSize = 0x010000; // Maximum download size 64kb
|
2012-11-03 20:16:03 +01:00
|
|
|
u8 *buffer = (u8*)MEM2_alloc(bufferSize);
|
|
|
|
if(buffer == NULL)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
2013-08-22 20:55:08 +02:00
|
|
|
_setThrdMsg(_t("dlmsg27", L"Not enough memory"), 1.f);
|
2012-01-21 21:57:41 +01:00
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
m_thrdWorking = false;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg1", L"Initializing network..."), 0.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
if (_initNetwork() < 0)
|
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg2", L"Network initialization failed!"), 1.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// DLoad txt file
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg11", L"Downloading..."), 0.2f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
|
|
|
|
m_thrdStep = 0.2f;
|
|
|
|
m_thrdStepLen = 0.9f - 0.2f;
|
|
|
|
gprintf("TXT update URL: %s\n\n", m_cfg.getString("GENERAL", "updatetxturl", UPDATE_URL_VERSION).c_str());
|
2016-04-02 17:46:06 +02:00
|
|
|
download = downloadfile(buffer, bufferSize, ("http://nintendont.gxarena.com/banners/versions.txt"),CMenu::_downloadProgress, this);
|
2012-01-21 21:57:41 +01:00
|
|
|
if (download.data == 0 || download.size < 19)
|
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg20", L"No version information found."), 1.f); // TODO: Check for 16
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// txt download finished, now save file
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg13", L"Saving..."), 0.9f);
|
2013-06-30 20:40:49 +02:00
|
|
|
LWP_MutexUnlock(m_mutex);
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2013-06-30 20:40:49 +02:00
|
|
|
bool res = fsop_WriteFile(m_ver.c_str(), download.data, download.size);
|
|
|
|
if (res == true)
|
|
|
|
{
|
2012-01-21 21:57:41 +01:00
|
|
|
// version file valid, check for version with SVN_REV
|
|
|
|
int svnrev = atoi(SVN_REV);
|
|
|
|
gprintf("Installed Version: %d\n", svnrev);
|
|
|
|
m_version.load(m_ver.c_str());
|
|
|
|
int rev = m_version.getInt("GENERAL", "version", 0);
|
|
|
|
gprintf("Latest available Version: %d\n", rev);
|
|
|
|
if (svnrev < rev)
|
|
|
|
{
|
|
|
|
// new version available
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg19", L"New update available!"), 1.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// no new version available
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg17", L"No new updates found."), 1.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg15", L"Saving failed!"), 1.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_thrdWorking = false;
|
2012-11-03 20:16:03 +01:00
|
|
|
free(buffer);
|
2012-01-21 21:57:41 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
s8 CMenu::_versionDownloaderInit(CMenu *m) //Handler to download new dol
|
|
|
|
{
|
2012-05-13 17:13:33 +02:00
|
|
|
if (!m->m_thrdWorking)
|
|
|
|
return 0;
|
2012-01-21 21:57:41 +01:00
|
|
|
return m->_versionDownloader();
|
|
|
|
}
|
|
|
|
|
|
|
|
s8 CMenu::_versionDownloader() // code to download new version
|
|
|
|
{
|
2013-06-30 20:40:49 +02:00
|
|
|
bool result = false;
|
2012-01-21 21:57:41 +01:00
|
|
|
char dol_backup[33];
|
|
|
|
strcpy(dol_backup, m_dol.c_str());
|
|
|
|
strcat(dol_backup, ".backup");
|
|
|
|
|
2012-05-13 17:13:33 +02:00
|
|
|
if (m_app_update_size == 0)
|
|
|
|
m_app_update_size = 0x400000;
|
|
|
|
if (m_data_update_size == 0)
|
|
|
|
m_data_update_size = 0x400000;
|
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
// check for existing dol
|
2012-03-18 00:14:07 +01:00
|
|
|
ifstream filestr;
|
2012-01-21 21:57:41 +01:00
|
|
|
gprintf("DOL Path: %s\n", m_dol.c_str());
|
2012-03-18 00:14:07 +01:00
|
|
|
filestr.open(m_dol.c_str());
|
|
|
|
if (filestr.fail())
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
filestr.close();
|
|
|
|
rename(dol_backup, m_dol.c_str());
|
|
|
|
filestr.open(m_dol.c_str());
|
|
|
|
if (filestr.fail())
|
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg18", L"boot.dol not found at default path!"), 1.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
}
|
|
|
|
filestr.close();
|
|
|
|
sleep(3);
|
|
|
|
m_thrdWorking = false;
|
|
|
|
return 0;
|
|
|
|
}
|
2012-03-18 00:14:07 +01:00
|
|
|
filestr.close();
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2016-04-02 17:46:06 +02:00
|
|
|
//u32 bufferSize = max(m_app_update_size, m_data_update_size); // Buffer for size of the biggest file.
|
|
|
|
u32 bufferSize = 0x400000; /* 4mb max */
|
2012-11-03 20:16:03 +01:00
|
|
|
u8 *buffer = (u8*)MEM2_alloc(bufferSize);
|
|
|
|
if(buffer == NULL)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
2013-08-22 20:55:08 +02:00
|
|
|
_setThrdMsg(_t("dlmsg27", L"Not enough memory!"), 1.f);
|
2012-01-21 21:57:41 +01:00
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
sleep(3);
|
|
|
|
m_thrdWorking = false;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg1", L"Initializing network..."), 0.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
|
|
|
|
if (_initNetwork() < 0)
|
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg2", L"Network initialization failed!"), 1.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
sleep(3);
|
|
|
|
m_thrdWorking = false;
|
2012-11-03 20:16:03 +01:00
|
|
|
free(buffer);
|
2012-01-21 21:57:41 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load actual file
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg22", L"Updating application directory..."), 0.2f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
|
|
|
|
m_thrdStep = 0.2f;
|
|
|
|
m_thrdStepLen = 0.9f - 0.2f;
|
|
|
|
gprintf("App Update URL: %s\n", m_app_update_url);
|
2012-03-17 21:25:17 +01:00
|
|
|
gprintf("Data Update URL: %s\n", m_data_update_url);
|
2012-03-18 00:14:07 +01:00
|
|
|
|
2012-11-03 20:16:03 +01:00
|
|
|
download = downloadfile(buffer, bufferSize, m_app_update_url, CMenu::_downloadProgress, this);
|
2016-04-02 17:46:06 +02:00
|
|
|
if (download.data == 0)// || download.size < m_app_update_size)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg12", L"Download failed!"), 1.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
sleep(3);
|
|
|
|
m_thrdWorking = false;
|
2012-11-03 20:16:03 +01:00
|
|
|
free(buffer);
|
2012-01-21 21:57:41 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2012-03-18 00:14:07 +01:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
// download finished, backup boot.dol and write new files.
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg13", L"Saving..."), 0.8f);
|
2013-06-30 20:40:49 +02:00
|
|
|
LWP_MutexUnlock(m_mutex);
|
2012-03-18 00:14:07 +01:00
|
|
|
|
2013-06-27 19:14:11 +02:00
|
|
|
fsop_deleteFile(dol_backup);
|
2012-01-21 21:57:41 +01:00
|
|
|
rename(m_dol.c_str(), dol_backup);
|
|
|
|
|
2013-06-27 19:14:11 +02:00
|
|
|
fsop_deleteFile(m_app_update_zip.c_str());
|
2013-06-30 20:40:49 +02:00
|
|
|
result = fsop_WriteFile(m_app_update_zip.c_str(), download.data, download.size);
|
|
|
|
if (result == true)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg24", L"Extracting..."), 0.8f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
|
|
|
|
ZipFile zFile(m_app_update_zip.c_str());
|
2013-06-30 20:40:49 +02:00
|
|
|
result = zFile.ExtractAll(m_app_update_drive);
|
2013-06-27 19:14:11 +02:00
|
|
|
fsop_deleteFile(m_app_update_zip.c_str());
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2012-05-13 17:13:33 +02:00
|
|
|
if (!result)
|
|
|
|
goto fail;
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
//Update apps dir succeeded, try to update the data dir.
|
|
|
|
download.data = NULL;
|
|
|
|
download.size = 0;
|
|
|
|
|
2012-11-03 20:16:03 +01:00
|
|
|
memset(buffer, 0, bufferSize); //should we be clearing the buffer of any possible data before downloading?
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg23", L"Updating data directory..."), 0.2f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
|
2012-11-03 20:16:03 +01:00
|
|
|
download = downloadfile(buffer, bufferSize, m_data_update_url, CMenu::_downloadProgress, this);
|
2012-01-21 21:57:41 +01:00
|
|
|
if (download.data == 0 || download.size < m_data_update_size)
|
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg12", L"Download failed!"), 1.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
goto success;
|
|
|
|
}
|
2012-03-18 00:14:07 +01:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
// download finished, write new files.
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg13", L"Saving..."), 0.9f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
2012-03-18 00:14:07 +01:00
|
|
|
|
2013-06-27 19:14:11 +02:00
|
|
|
fsop_deleteFile(m_data_update_zip.c_str());
|
2013-06-30 20:40:49 +02:00
|
|
|
result = fsop_WriteFile(m_data_update_zip.c_str(), download.data, download.size);
|
|
|
|
if (result == true)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg24", L"Extracting..."), 0.8f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
2012-03-18 00:14:07 +01:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
ZipFile zDataFile(m_data_update_zip.c_str());
|
|
|
|
result = zDataFile.ExtractAll(m_dataDir.c_str());
|
2013-06-27 19:14:11 +02:00
|
|
|
fsop_deleteFile(m_data_update_zip.c_str());
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
if (!result)
|
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg15", L"Saving failed!"), 1.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
success:
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg21", L"WiiFlow will now exit to allow the update to take effect."), 1.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
|
2012-03-18 00:14:07 +01:00
|
|
|
filestr.open(m_dol.c_str());
|
|
|
|
if (filestr.fail())
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg25", L"Extraction must have failed! Renaming the backup to boot.dol"), 1.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
rename(dol_backup, m_dol.c_str());
|
|
|
|
}
|
2012-03-18 00:14:07 +01:00
|
|
|
else
|
2013-06-27 19:14:11 +02:00
|
|
|
fsop_deleteFile(dol_backup);
|
2012-03-18 00:14:07 +01:00
|
|
|
filestr.close();
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
m_exit = true;
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
rename(dol_backup, m_dol.c_str());
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg15", L"Saving failed!"), 1.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
out:
|
2012-11-03 20:16:03 +01:00
|
|
|
free(buffer);
|
2012-01-21 21:57:41 +01:00
|
|
|
sleep(3);
|
|
|
|
m_thrdWorking = false;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CMenu::_gametdbDownloader(CMenu *m)
|
|
|
|
{
|
|
|
|
if (!m->m_thrdWorking) return 0;
|
|
|
|
return m->_gametdbDownloaderAsync();
|
|
|
|
}
|
|
|
|
|
|
|
|
int CMenu::_gametdbDownloaderAsync()
|
|
|
|
{
|
|
|
|
u32 bufferSize = 0x800000; // 8 MB
|
2012-11-03 20:16:03 +01:00
|
|
|
u8 *buffer = (u8*)MEM2_alloc(bufferSize);
|
|
|
|
if (buffer == NULL)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
2013-08-22 20:55:08 +02:00
|
|
|
_setThrdMsg(_t("dlmsg27", L"Not enough memory"), 1.f);
|
2012-01-21 21:57:41 +01:00
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
return 0;
|
|
|
|
}
|
2013-09-24 17:21:31 +02:00
|
|
|
const string &langCode = m_loc.getString(m_curLanguage, "gametdb_code", "EN");
|
2012-01-21 21:57:41 +01:00
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg1", L"Initializing network..."), 0.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
if (_initNetwork() < 0)
|
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg2", L"Network initialization failed!"), 1.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg11", L"Downloading..."), 0.0f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
m_thrdStep = 0.0f;
|
|
|
|
m_thrdStepLen = 1.0f;
|
2012-11-03 20:16:03 +01:00
|
|
|
download = downloadfile(buffer, bufferSize, fmt(GAMETDB_URL, langCode.c_str()), CMenu::_downloadProgress, this);
|
2012-01-21 21:57:41 +01:00
|
|
|
if (download.data == 0)
|
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg12", L"Download failed!"), 1.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-24 17:21:31 +02:00
|
|
|
bool res = false;
|
|
|
|
char *zippath = fmt_malloc("%s/wiitdb.zip", m_settingsDir.c_str());
|
|
|
|
if(zippath != NULL)
|
|
|
|
{
|
|
|
|
gprintf("Writing file to '%s'\n", zippath);
|
|
|
|
fsop_deleteFile(zippath);
|
|
|
|
_setThrdMsg(wfmt(_fmt("dlmsg4", L"Saving %s"), "wiitdb.zip"), 1.f);
|
|
|
|
res = fsop_WriteFile(zippath, download.data, download.size);
|
|
|
|
}
|
|
|
|
if(res == false)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
gprintf("Can't save zip file\n");
|
2013-09-24 17:21:31 +02:00
|
|
|
if(zippath != NULL)
|
|
|
|
MEM2_free(zippath);
|
2012-01-21 21:57:41 +01:00
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg15", L"Couldn't save ZIP file"), 1.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gprintf("Extracting zip file: ");
|
2013-06-30 20:40:49 +02:00
|
|
|
|
2013-09-24 17:21:31 +02:00
|
|
|
ZipFile zFile(zippath);
|
2012-01-21 21:57:41 +01:00
|
|
|
bool zres = zFile.ExtractAll(m_settingsDir.c_str());
|
|
|
|
gprintf(zres ? "success\n" : "failed\n");
|
|
|
|
|
|
|
|
// We don't need the zipfile anymore
|
2013-09-24 17:21:31 +02:00
|
|
|
fsop_deleteFile(zippath);
|
|
|
|
MEM2_free(zippath);
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-01-28 23:50:00 +01:00
|
|
|
// We should always remove the offsets file to make sure it's reloaded
|
2013-06-30 20:40:49 +02:00
|
|
|
fsop_deleteFile(fmt("%s/gametdb_offsets.bin", m_settingsDir.c_str()));
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
// Update cache
|
|
|
|
UpdateCache();
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
_setThrdMsg(_t("dlmsg26", L"Updating cache..."), 0.f);
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
- PHASE 2 (finally!)
- New Coverflow theme format. no more emuflow, coverflow, brewflow. now we have coverflow, shortflow, sideflow, and smallflow.
- coverflow is the normal coverflow.
- shortflow is automatically used for plugins if all selected plugins require a short CD style cover such as GB, GBC, GBA, and playstation. if there's more let me know and i can add them.
- sideflow is automatically used for plugins if all selected plugins require a cover on its side such as SNES and Nintendo 64.
- smallflow is used if smallbox is set for homebrew and sourceflow.
- no more need for emuflow= with a source btn in the source menu. it is done automatically now using the plugins magic#
- each flow has its own number of modes/layouts. so now coveflow can have 8, smallfow 1, sideflow, 6, and shortflow 4 or whatever you want.
- adjust coverflow works with no problems. just choose the view first before entering the adjust coverflow menu.
- other minor code changes here and there.
- remember themes are now in themes_lite and the coverflow part is seperated and put in the coverflows folder with the same name as the theme or you can use a default coverflow named default.ini for all themes.
2016-05-11 19:58:36 +02:00
|
|
|
m_load_view = true;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-11-03 20:16:03 +01:00
|
|
|
free(buffer);
|
2012-01-21 21:57:41 +01:00
|
|
|
m_thrdWorking = false;
|
|
|
|
return 0;
|
2012-05-13 17:13:33 +02:00
|
|
|
}
|
2013-06-27 19:14:11 +02:00
|
|
|
|
|
|
|
const char *banner_url = NULL;
|
|
|
|
const char *banner_url_id3 = NULL;
|
2013-09-24 17:21:31 +02:00
|
|
|
char *banner_location = NULL;
|
2013-06-27 19:14:11 +02:00
|
|
|
u32 CMenu::_downloadBannerAsync(void *obj)
|
|
|
|
{
|
|
|
|
CMenu *m = (CMenu *)obj;
|
|
|
|
if (!m->m_thrdWorking)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
m->m_thrdStop = false;
|
|
|
|
|
|
|
|
LWP_MutexLock(m->m_mutex);
|
|
|
|
m->_setThrdMsg(m->_t("cfgbnr7", L"Downloading banner..."), 0);
|
|
|
|
LWP_MutexUnlock(m->m_mutex);
|
|
|
|
|
|
|
|
if (m->_initNetwork() < 0)
|
|
|
|
{
|
2013-08-22 20:55:08 +02:00
|
|
|
LWP_MutexLock(m->m_mutex);
|
|
|
|
m->_setThrdMsg(m->_t("dlmsg2", L"Network initialization failed!"), 1.f);
|
|
|
|
LWP_MutexUnlock(m->m_mutex);
|
2013-06-27 19:14:11 +02:00
|
|
|
m->m_thrdWorking = false;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 bufferSize = 0x400000; /* 4mb max */
|
|
|
|
u8 *buffer = (u8*)MEM2_alloc(bufferSize);
|
|
|
|
if(buffer == NULL)
|
|
|
|
{
|
2013-08-22 20:55:08 +02:00
|
|
|
LWP_MutexLock(m->m_mutex);
|
|
|
|
m->_setThrdMsg(m->_t("dlmsg27", L"Not enough memory!"), 1.f);
|
|
|
|
LWP_MutexUnlock(m->m_mutex);
|
2013-06-27 19:14:11 +02:00
|
|
|
m->m_thrdWorking = false;
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
block banner = downloadfile(buffer, bufferSize, banner_url, CMenu::_downloadProgress, m);
|
|
|
|
if(banner.data == NULL || banner.size < 0x5000)
|
|
|
|
banner = downloadfile(buffer, bufferSize, banner_url_id3, CMenu::_downloadProgress, m);
|
|
|
|
|
|
|
|
/* minimum 50kb */
|
|
|
|
if (banner.data != NULL && banner.size > 51200 && banner.data[0] != '<')
|
|
|
|
{
|
2013-09-24 17:21:31 +02:00
|
|
|
if(banner_location != NULL)
|
|
|
|
fsop_WriteFile(banner_location, banner.data, banner.size);
|
2013-08-22 20:55:08 +02:00
|
|
|
LWP_MutexLock(m->m_mutex);
|
|
|
|
m->_setThrdMsg(m->_t("dlmsg14", L"Done."), 1.f);
|
|
|
|
LWP_MutexUnlock(m->m_mutex);
|
2013-06-30 20:40:49 +02:00
|
|
|
free(buffer);
|
|
|
|
m->m_thrdWorking = false;
|
|
|
|
return 0;
|
2013-06-27 19:14:11 +02:00
|
|
|
}
|
2013-08-22 20:55:08 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
LWP_MutexLock(m->m_mutex);
|
|
|
|
m->_setThrdMsg(m->_t("dlmsg12", L"Download failed!"), 1.f);
|
|
|
|
LWP_MutexUnlock(m->m_mutex);
|
|
|
|
m->m_thrdWorking = false;
|
|
|
|
free(buffer);
|
|
|
|
return -3;
|
|
|
|
}
|
2013-06-27 19:14:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const char *GAME_BNR_ID = "{gameid}";
|
|
|
|
void CMenu::_downloadBnr(const char *gameID)
|
|
|
|
{
|
|
|
|
if(gameID == NULL || strlen(gameID) > 6)
|
|
|
|
return;
|
2013-06-27 19:55:42 +02:00
|
|
|
string base_url = m_cfg.getString("GENERAL", "custom_banner_url", CUSTOM_BANNER_URL);
|
2013-06-27 19:14:11 +02:00
|
|
|
if(base_url.size() < 3 || base_url.find(GAME_BNR_ID) == string::npos)
|
|
|
|
return;
|
|
|
|
base_url.replace(base_url.find(GAME_BNR_ID), strlen(GAME_BNR_ID), gameID);
|
|
|
|
banner_url = base_url.c_str();
|
|
|
|
|
2013-06-27 19:55:42 +02:00
|
|
|
string base_url_id3 = m_cfg.getString("GENERAL", "custom_banner_url", CUSTOM_BANNER_URL);
|
2013-06-27 19:14:11 +02:00
|
|
|
base_url_id3.replace(base_url_id3.find(GAME_BNR_ID), strlen(GAME_BNR_ID), gameID, 3);
|
|
|
|
banner_url_id3 = base_url_id3.c_str();
|
|
|
|
|
2013-09-24 17:21:31 +02:00
|
|
|
banner_location = fmt_malloc("%s/%s.bnr", m_customBnrDir.c_str(), gameID);
|
|
|
|
if(banner_location == NULL)
|
|
|
|
return;
|
2013-06-27 19:14:11 +02:00
|
|
|
|
|
|
|
m_btnMgr.show(m_downloadPBar);
|
|
|
|
m_btnMgr.setProgress(m_downloadPBar, 0.f);
|
|
|
|
m_btnMgr.show(m_downloadBtnCancel);
|
|
|
|
m_btnMgr.setText(m_downloadBtnCancel, _t("dl1", L"Cancel"));
|
|
|
|
m_thrdStop = false;
|
|
|
|
m_thrdMessageAdded = false;
|
|
|
|
|
|
|
|
m_thrdWorking = true;
|
|
|
|
lwp_t thread = LWP_THREAD_NULL;
|
2014-03-17 18:38:32 +01:00
|
|
|
LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_downloadBannerAsync,
|
|
|
|
(void *)this, downloadStack, downloadStackSize, 40);
|
2013-06-27 19:14:11 +02:00
|
|
|
|
|
|
|
wstringEx prevMsg;
|
|
|
|
while(m_thrdWorking)
|
|
|
|
{
|
|
|
|
_mainLoopCommon();
|
|
|
|
if ((BTN_HOME_PRESSED || BTN_B_PRESSED) && !m_thrdWorking)
|
|
|
|
break;
|
|
|
|
if (BTN_A_PRESSED && !(m_thrdWorking && m_thrdStop))
|
|
|
|
{
|
|
|
|
if (m_btnMgr.selected(m_downloadBtnCancel))
|
|
|
|
{
|
|
|
|
LockMutex lock(m_mutex);
|
|
|
|
m_thrdStop = true;
|
|
|
|
m_thrdMessageAdded = true;
|
|
|
|
m_thrdMessage = _t("dlmsg6", L"Canceling...");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Sys_Exiting())
|
|
|
|
{
|
|
|
|
LockMutex lock(m_mutex);
|
|
|
|
m_thrdStop = true;
|
|
|
|
m_thrdMessageAdded = true;
|
|
|
|
m_thrdMessage = _t("dlmsg6", L"Canceling...");
|
|
|
|
m_thrdWorking = false;
|
|
|
|
}
|
|
|
|
if (m_thrdMessageAdded)
|
|
|
|
{
|
|
|
|
LockMutex lock(m_mutex);
|
|
|
|
m_thrdMessageAdded = false;
|
|
|
|
m_btnMgr.setProgress(m_downloadPBar, m_thrdProgress);
|
|
|
|
if (prevMsg != m_thrdMessage)
|
|
|
|
{
|
|
|
|
prevMsg = m_thrdMessage;
|
|
|
|
m_btnMgr.setText(m_downloadLblMessage[0], m_thrdMessage, false);
|
|
|
|
m_btnMgr.hide(m_downloadLblMessage[0], 0, 0, -1.f, -1.f, true);
|
|
|
|
m_btnMgr.show(m_downloadLblMessage[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (m_thrdStop && !m_thrdWorking)
|
|
|
|
break;
|
|
|
|
}
|
2013-09-24 17:21:31 +02:00
|
|
|
if(banner_location != NULL)
|
|
|
|
{
|
|
|
|
MEM2_free(banner_location);
|
|
|
|
banner_location = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_btnMgr.setText(m_downloadBtnCancel, _t("gm2", L"Back"));
|
2013-06-27 19:14:11 +02:00
|
|
|
if (thread != LWP_THREAD_NULL)
|
|
|
|
{
|
|
|
|
LWP_JoinThread(thread, NULL);
|
|
|
|
thread = LWP_THREAD_NULL;
|
|
|
|
}
|
2013-08-22 20:55:08 +02:00
|
|
|
|
|
|
|
while(!m_exit && !m_thrdStop)
|
|
|
|
{
|
|
|
|
_mainLoopCommon();
|
|
|
|
if(BTN_HOME_PRESSED || BTN_B_PRESSED || (BTN_A_PRESSED && m_btnMgr.selected(m_downloadBtnCancel)))
|
|
|
|
break;
|
|
|
|
}
|
2013-06-27 19:14:11 +02:00
|
|
|
m_btnMgr.hide(m_downloadLblMessage[0]);
|
|
|
|
m_btnMgr.hide(m_downloadPBar);
|
|
|
|
m_btnMgr.hide(m_downloadBtnCancel);
|
|
|
|
}
|
2013-08-08 20:21:11 +02:00
|
|
|
|
|
|
|
const char *url_dl = NULL;
|
2013-08-09 16:52:17 +02:00
|
|
|
void CMenu::_downloadUrl(const char *url, u8 **dl_file, u32 *dl_size)
|
2013-08-08 20:21:11 +02:00
|
|
|
{
|
|
|
|
m_file = NULL;
|
|
|
|
m_filesize = 0;
|
|
|
|
url_dl = url;
|
|
|
|
|
|
|
|
m_btnMgr.show(m_downloadPBar);
|
|
|
|
m_btnMgr.setProgress(m_downloadPBar, 0.f);
|
|
|
|
m_btnMgr.show(m_downloadBtnCancel);
|
|
|
|
m_btnMgr.setText(m_downloadBtnCancel, _t("dl1", L"Cancel"));
|
|
|
|
m_thrdStop = false;
|
|
|
|
m_thrdMessageAdded = false;
|
|
|
|
|
|
|
|
m_thrdWorking = true;
|
|
|
|
lwp_t thread = LWP_THREAD_NULL;
|
2014-03-17 18:38:32 +01:00
|
|
|
LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_downloadUrlAsync,
|
|
|
|
(void *)this, downloadStack, downloadStackSize, 40);
|
2013-08-08 20:21:11 +02:00
|
|
|
|
|
|
|
wstringEx prevMsg;
|
|
|
|
while(m_thrdWorking)
|
|
|
|
{
|
|
|
|
_mainLoopCommon();
|
|
|
|
if ((BTN_HOME_PRESSED || BTN_B_PRESSED) && !m_thrdWorking)
|
|
|
|
break;
|
|
|
|
if (BTN_A_PRESSED && !(m_thrdWorking && m_thrdStop))
|
|
|
|
{
|
|
|
|
if (m_btnMgr.selected(m_downloadBtnCancel))
|
|
|
|
{
|
|
|
|
LockMutex lock(m_mutex);
|
|
|
|
m_thrdStop = true;
|
|
|
|
m_thrdMessageAdded = true;
|
|
|
|
m_thrdMessage = _t("dlmsg6", L"Canceling...");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Sys_Exiting())
|
|
|
|
{
|
|
|
|
LockMutex lock(m_mutex);
|
|
|
|
m_thrdStop = true;
|
|
|
|
m_thrdMessageAdded = true;
|
|
|
|
m_thrdMessage = _t("dlmsg6", L"Canceling...");
|
|
|
|
m_thrdWorking = false;
|
|
|
|
}
|
|
|
|
if (m_thrdMessageAdded)
|
|
|
|
{
|
|
|
|
LockMutex lock(m_mutex);
|
|
|
|
m_thrdMessageAdded = false;
|
|
|
|
m_btnMgr.setProgress(m_downloadPBar, m_thrdProgress);
|
|
|
|
if (prevMsg != m_thrdMessage)
|
|
|
|
{
|
|
|
|
prevMsg = m_thrdMessage;
|
|
|
|
m_btnMgr.setText(m_downloadLblMessage[0], m_thrdMessage, false);
|
|
|
|
m_btnMgr.hide(m_downloadLblMessage[0], 0, 0, -1.f, -1.f, true);
|
|
|
|
m_btnMgr.show(m_downloadLblMessage[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (m_thrdStop && !m_thrdWorking)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (thread != LWP_THREAD_NULL)
|
|
|
|
{
|
|
|
|
LWP_JoinThread(thread, NULL);
|
|
|
|
thread = LWP_THREAD_NULL;
|
|
|
|
}
|
|
|
|
m_btnMgr.hide(m_downloadLblMessage[0]);
|
|
|
|
m_btnMgr.hide(m_downloadPBar);
|
|
|
|
m_btnMgr.hide(m_downloadBtnCancel);
|
|
|
|
|
|
|
|
*dl_file = m_file;
|
|
|
|
*dl_size = m_filesize;
|
|
|
|
|
|
|
|
m_file = NULL;
|
|
|
|
m_filesize = 0;
|
|
|
|
url_dl = url;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 CMenu::_downloadUrlAsync(void *obj)
|
|
|
|
{
|
|
|
|
CMenu *m = (CMenu *)obj;
|
|
|
|
if (!m->m_thrdWorking)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
m->m_thrdStop = false;
|
|
|
|
|
|
|
|
LWP_MutexLock(m->m_mutex);
|
|
|
|
m->_setThrdMsg(m->_t("dlmsg11", L"Downloading..."), 0);
|
|
|
|
LWP_MutexUnlock(m->m_mutex);
|
|
|
|
|
|
|
|
if(m->_initNetwork() < 0 || url_dl == NULL)
|
|
|
|
{
|
|
|
|
m->m_thrdWorking = false;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 bufferSize = 0x400000; /* 4mb max */
|
2013-08-09 16:52:17 +02:00
|
|
|
m->m_buffer = (u8*)MEM2_alloc(bufferSize);
|
|
|
|
if(m->m_buffer == NULL)
|
2013-08-08 20:21:11 +02:00
|
|
|
{
|
|
|
|
m->m_thrdWorking = false;
|
|
|
|
return -2;
|
|
|
|
}
|
2013-08-09 16:52:17 +02:00
|
|
|
block file = downloadfile(m->m_buffer, bufferSize, url_dl, CMenu::_downloadProgress, m);
|
|
|
|
DCFlushRange(m->m_buffer, bufferSize);
|
2013-08-08 20:21:11 +02:00
|
|
|
m->m_file = file.data;
|
|
|
|
m->m_filesize = file.size;
|
|
|
|
m->m_thrdWorking = false;
|
|
|
|
return 0;
|
|
|
|
}
|