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"
|
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"
|
2019-10-25 00:26:17 +02:00
|
|
|
#include "network/https.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}"
|
|
|
|
|
2019-10-25 00:26:17 +02:00
|
|
|
#define GAMETDB_URL "https://www.gametdb.com/wiitdb.zip?LANG=%s&FALLBACK=TRUE&WIIWARE=TRUE&GAMECUBE=TRUE"
|
|
|
|
#define CUSTOM_BANNER_URL "https://banner.rc24.xyz/{gameid}.bnr"
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2019-10-25 00:26:17 +02:00
|
|
|
static const char FMT_BPIC_URL[] = "https://art.gametdb.com/{console}/coverfullHQ/{loc}/{gameid}.png"\
|
|
|
|
"|https://art.gametdb.com/{console}/coverfull/{loc}/{gameid}.png";
|
|
|
|
static const char FMT_PIC_URL[] = "https://art.gametdb.com/{console}/cover/{loc}/{gameid}.png";
|
|
|
|
static const char FMT_CBPIC_URL[] = "https://art.gametdb.com/{console}/coverfullHQ2/{loc}/{gameid}.png";
|
|
|
|
static const char FMT_CPIC_URL[] = "https://art.gametdb.com/{console}/cover2/{loc}/{gameid}.png";
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2012-02-16 20:19:45 +01:00
|
|
|
static bool settingsmenu = false;
|
2018-12-13 01:03:33 +01:00
|
|
|
static string dl_gameID;
|
2012-01-21 21:57:41 +01:00
|
|
|
|
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
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
|
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);
|
2018-11-23 22:31:04 +01:00
|
|
|
m_btnMgr.show(m_downloadBtnBack);
|
2012-02-12 02:43:31 +01:00
|
|
|
m_btnMgr.show(m_downloadLblCoverPrio);
|
|
|
|
m_btnMgr.show(m_downloadLblPrio);
|
|
|
|
m_btnMgr.show(m_downloadBtnPrioM);
|
|
|
|
m_btnMgr.show(m_downloadBtnPrioP);
|
2020-04-12 21:25:10 +02:00
|
|
|
m_btnMgr.show(m_downloadLblRegion);
|
2012-02-12 02:43:31 +01:00
|
|
|
if( m_downloadPrioVal&C_TYPE_EN )
|
|
|
|
m_btnMgr.show(m_downloadBtnENs);
|
|
|
|
else
|
|
|
|
m_btnMgr.show(m_downloadBtnEN);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
if( m_downloadPrioVal&C_TYPE_JA )
|
|
|
|
m_btnMgr.show(m_downloadBtnJAs);
|
|
|
|
else
|
|
|
|
m_btnMgr.show(m_downloadBtnJA);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
if( m_downloadPrioVal&C_TYPE_FR )
|
|
|
|
m_btnMgr.show(m_downloadBtnFRs);
|
|
|
|
else
|
|
|
|
m_btnMgr.show(m_downloadBtnFR);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
if( m_downloadPrioVal&C_TYPE_DE )
|
|
|
|
m_btnMgr.show(m_downloadBtnDEs);
|
|
|
|
else
|
2020-04-12 21:25:10 +02:00
|
|
|
m_btnMgr.show(m_downloadBtnDE);
|
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
if( m_downloadPrioVal&C_TYPE_ES )
|
|
|
|
m_btnMgr.show(m_downloadBtnESs);
|
|
|
|
else
|
|
|
|
m_btnMgr.show(m_downloadBtnES);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
if( m_downloadPrioVal&C_TYPE_IT )
|
|
|
|
m_btnMgr.show(m_downloadBtnITs);
|
|
|
|
else
|
|
|
|
m_btnMgr.show(m_downloadBtnIT);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
if( m_downloadPrioVal&C_TYPE_NL )
|
|
|
|
m_btnMgr.show(m_downloadBtnNLs);
|
|
|
|
else
|
|
|
|
m_btnMgr.show(m_downloadBtnNL);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
if( m_downloadPrioVal&C_TYPE_PT )
|
|
|
|
m_btnMgr.show(m_downloadBtnPTs);
|
|
|
|
else
|
2020-04-12 21:25:10 +02:00
|
|
|
m_btnMgr.show(m_downloadBtnPT);
|
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
if( m_downloadPrioVal&C_TYPE_RU )
|
|
|
|
m_btnMgr.show(m_downloadBtnRUs);
|
|
|
|
else
|
|
|
|
m_btnMgr.show(m_downloadBtnRU);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
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);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2012-02-12 02:43:31 +01:00
|
|
|
if( m_downloadPrioVal&C_TYPE_AU )
|
|
|
|
m_btnMgr.show(m_downloadBtnAUs);
|
|
|
|
else
|
|
|
|
m_btnMgr.show(m_downloadBtnAU);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2018-11-23 22:31:04 +01:00
|
|
|
//
|
2012-02-12 02:43:31 +01:00
|
|
|
if( m_downloadPrioVal&C_TYPE_ONOR )
|
|
|
|
{
|
2020-04-12 21:25:10 +02:00
|
|
|
m_btnMgr.setText(m_downloadLblPrio, _t("dl24", L"Custom only"));
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
|
|
|
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"));
|
|
|
|
}
|
2020-04-12 21:25:10 +02:00
|
|
|
else
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
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);
|
2018-11-23 22:31:04 +01:00
|
|
|
m_btnMgr.hide(m_downloadBtnBack, instant);
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.hide(m_downloadBtnCancel, instant);
|
2018-12-11 22:24:32 +01:00
|
|
|
m_btnMgr.hide(m_downloadLblCovers, instant);
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.hide(m_downloadBtnAll, instant);
|
2012-02-12 02:43:31 +01:00
|
|
|
m_btnMgr.hide(m_downloadLblCoverSet, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnCoverSet, instant);
|
2018-12-11 22:24:32 +01:00
|
|
|
m_btnMgr.hide(m_downloadLblGameTDBDownload, instant);
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.hide(m_downloadBtnGameTDBDownload, instant);
|
2018-12-11 22:24:32 +01:00
|
|
|
m_btnMgr.hide(m_downloadLblBanners, instant);
|
|
|
|
m_btnMgr.hide(m_downloadBtnBanners, instant);
|
2012-01-21 21:57:41 +01:00
|
|
|
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_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);
|
2016-12-01 01:05:39 +01:00
|
|
|
m_btnMgr.show(m_downloadBtnBack);
|
2016-11-07 16:06:00 +01:00
|
|
|
m_btnMgr.show(m_downloadLblCovers);
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.show(m_downloadBtnAll);
|
2012-02-12 02:43:31 +01:00
|
|
|
m_btnMgr.show(m_downloadLblCoverSet);
|
|
|
|
m_btnMgr.show(m_downloadBtnCoverSet);
|
2016-11-07 16:06:00 +01:00
|
|
|
m_btnMgr.show(m_downloadLblGameTDBDownload);
|
|
|
|
m_btnMgr.show(m_downloadBtnGameTDBDownload);
|
2018-12-11 22:24:32 +01:00
|
|
|
m_btnMgr.show(m_downloadLblBanners);
|
|
|
|
m_btnMgr.show(m_downloadBtnBanners);
|
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)
|
2020-04-12 21:25:10 +02:00
|
|
|
m_btnMgr.show(m_downloadLblUser[i]);
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|
2018-11-19 19:14:40 +01:00
|
|
|
int count, countFlat;
|
|
|
|
u32 n;
|
2018-12-13 01:03:33 +01:00
|
|
|
void CMenu::_download(string gameId, int dl_type)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
dl_gameID = gameId;
|
2018-06-06 13:32:45 +02:00
|
|
|
bool dl_finished = false;
|
|
|
|
SetupInput();
|
|
|
|
_showDownload();
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
while(!m_exit)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
_mainLoopCommon();
|
|
|
|
if(BTN_HOME_PRESSED || BTN_B_PRESSED)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
if(settingsmenu)
|
2012-06-08 21:29:23 +02:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
settingsmenu = false;
|
|
|
|
_hideSettings();
|
|
|
|
_showDownload();
|
2012-06-08 21:29:23 +02:00
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else if(dl_finished)
|
2012-06-08 21:29:23 +02:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
dl_finished = false;
|
|
|
|
m_btnMgr.hide(m_wbfsPBar);
|
|
|
|
m_btnMgr.hide(m_wbfsLblMessage);
|
|
|
|
m_btnMgr.hide(m_wbfsLblDialog);
|
2018-12-13 01:03:33 +01:00
|
|
|
if(strlen(dl_gameID.c_str()) > 0)
|
2018-06-06 13:32:45 +02:00
|
|
|
break;
|
|
|
|
_showDownload();
|
2012-06-08 21:29:23 +02:00
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else
|
|
|
|
break;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else if(BTN_UP_PRESSED)
|
|
|
|
m_btnMgr.up();
|
|
|
|
else if(BTN_DOWN_PRESSED)
|
|
|
|
m_btnMgr.down();
|
2018-12-13 01:03:33 +01:00
|
|
|
if(BTN_A_PRESSED || dl_type > 0)
|
2018-06-06 13:32:45 +02:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
if(m_btnMgr.selected(m_downloadBtnAll) || dl_type == 1)
|
2018-06-06 13:32:45 +02:00
|
|
|
{
|
2020-04-12 21:25:10 +02:00
|
|
|
m_refreshGameList = true; // Not needed instead just initcf()
|
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
m_btnMgr.hide(m_downloadLblCovers);
|
|
|
|
m_btnMgr.hide(m_downloadBtnAll);
|
|
|
|
m_btnMgr.hide(m_downloadLblGameTDBDownload);
|
|
|
|
m_btnMgr.hide(m_downloadBtnGameTDBDownload);
|
|
|
|
m_btnMgr.hide(m_downloadLblCoverSet);
|
|
|
|
m_btnMgr.hide(m_downloadBtnCoverSet);
|
2018-12-11 22:24:32 +01:00
|
|
|
m_btnMgr.hide(m_downloadLblBanners);
|
|
|
|
m_btnMgr.hide(m_downloadBtnBanners);
|
2018-11-23 22:31:04 +01:00
|
|
|
m_btnMgr.hide(m_downloadBtnBack);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
m_btnMgr.setProgress(m_wbfsPBar, 0.f, true);
|
|
|
|
m_btnMgr.setText(m_wbfsLblMessage, L"0%");
|
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, L"");
|
|
|
|
m_btnMgr.show(m_wbfsPBar);
|
|
|
|
m_btnMgr.show(m_wbfsLblMessage);
|
|
|
|
m_btnMgr.show(m_wbfsLblDialog);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
_start_pThread();
|
2018-11-23 22:31:04 +01:00
|
|
|
int ret = _coverDownloader();
|
2018-06-06 13:32:45 +02:00
|
|
|
_stop_pThread();
|
2018-11-23 22:31:04 +01:00
|
|
|
if(ret == 0)
|
2018-11-19 19:14:40 +01:00
|
|
|
{
|
2018-11-23 22:31:04 +01:00
|
|
|
if(countFlat == 0)
|
|
|
|
{
|
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg5", L"%i/%i files downloaded."), count, n);
|
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, m_thrdMessage);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg9", L"%i/%i files downloaded. %i are front covers only."), count + countFlat, n, countFlat);
|
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, m_thrdMessage);
|
|
|
|
}
|
2018-11-19 19:14:40 +01:00
|
|
|
}
|
2018-11-23 22:31:04 +01:00
|
|
|
else if(ret == -1)
|
2018-06-06 13:32:45 +02:00
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg27", L"Not enough memory!"));
|
|
|
|
else if(ret == -2)
|
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg2", L"Network initialization failed!"));
|
|
|
|
else if(ret == -3)
|
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg30", L"No covers missing."));
|
|
|
|
dl_finished = true;
|
2018-12-13 01:03:33 +01:00
|
|
|
dl_type = 0;
|
2020-04-12 21:25:10 +02:00
|
|
|
// Maybe show back button
|
2018-06-06 13:32:45 +02:00
|
|
|
//m_btnMgr.show(m_downloadBtnBack);
|
|
|
|
}
|
2018-12-13 01:03:33 +01:00
|
|
|
if(m_btnMgr.selected(m_downloadBtnBanners) || dl_type == 2)
|
2018-12-11 22:24:32 +01:00
|
|
|
{
|
|
|
|
//m_refreshGameList = true;
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2018-12-11 22:24:32 +01:00
|
|
|
m_btnMgr.hide(m_downloadLblCovers);
|
|
|
|
m_btnMgr.hide(m_downloadBtnAll);
|
|
|
|
m_btnMgr.hide(m_downloadLblGameTDBDownload);
|
|
|
|
m_btnMgr.hide(m_downloadBtnGameTDBDownload);
|
|
|
|
m_btnMgr.hide(m_downloadLblCoverSet);
|
|
|
|
m_btnMgr.hide(m_downloadBtnCoverSet);
|
|
|
|
m_btnMgr.hide(m_downloadLblBanners);
|
|
|
|
m_btnMgr.hide(m_downloadBtnBanners);
|
|
|
|
m_btnMgr.hide(m_downloadBtnBack);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2018-12-11 22:24:32 +01:00
|
|
|
m_btnMgr.setProgress(m_wbfsPBar, 0.f, true);
|
|
|
|
m_btnMgr.setText(m_wbfsLblMessage, L"0%");
|
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, L"");
|
|
|
|
m_btnMgr.show(m_wbfsPBar);
|
|
|
|
m_btnMgr.show(m_wbfsLblMessage);
|
|
|
|
m_btnMgr.show(m_wbfsLblDialog);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2018-12-11 22:24:32 +01:00
|
|
|
_start_pThread();
|
2018-12-13 01:03:33 +01:00
|
|
|
int ret = _bannerDownloader();
|
2018-12-11 22:24:32 +01:00
|
|
|
_stop_pThread();
|
|
|
|
if(ret == 0)
|
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
if(dl_gameID.empty())
|
|
|
|
{
|
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg5", L"%i/%i files downloaded."), count, n);
|
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, m_thrdMessage);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg14", L"Done."));
|
2018-12-11 22:24:32 +01:00
|
|
|
}
|
|
|
|
else if(ret == -1)
|
2020-04-12 21:25:10 +02:00
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg34", L"Banner URL not set properly!")); // Banner URL not set
|
2018-12-11 22:24:32 +01:00
|
|
|
else if(ret == -2)
|
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg2", L"Network initialization failed!"));
|
|
|
|
else if(ret == -3)
|
2020-04-12 21:25:10 +02:00
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg33", L"No banners missing.")); // No banners missing
|
2018-12-11 22:24:32 +01:00
|
|
|
dl_finished = true;
|
2018-12-13 01:03:33 +01:00
|
|
|
dl_type = 0;
|
2020-04-12 21:25:10 +02:00
|
|
|
// Maybe show back button
|
2018-12-11 22:24:32 +01:00
|
|
|
//m_btnMgr.show(m_downloadBtnBack);
|
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else if(m_btnMgr.selected(m_downloadBtnGameTDBDownload))
|
|
|
|
{
|
2020-04-12 21:25:10 +02:00
|
|
|
m_refreshGameList = true; // To refresh titles
|
2018-06-06 13:32:45 +02:00
|
|
|
m_btnMgr.hide(m_downloadLblCovers);
|
|
|
|
m_btnMgr.hide(m_downloadBtnAll);
|
|
|
|
m_btnMgr.hide(m_downloadBtnMissing);
|
|
|
|
m_btnMgr.hide(m_downloadLblGameTDBDownload);
|
|
|
|
m_btnMgr.hide(m_downloadBtnGameTDBDownload);
|
|
|
|
m_btnMgr.hide(m_downloadLblCoverSet);
|
|
|
|
m_btnMgr.hide(m_downloadBtnCoverSet);
|
2018-12-11 22:24:32 +01:00
|
|
|
m_btnMgr.hide(m_downloadLblBanners);
|
|
|
|
m_btnMgr.hide(m_downloadBtnBanners);
|
2018-11-23 22:31:04 +01:00
|
|
|
m_btnMgr.hide(m_downloadBtnBack);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
m_btnMgr.setProgress(m_wbfsPBar, 0.f, true);
|
|
|
|
m_btnMgr.setText(m_wbfsLblMessage, L"0%");
|
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, L"");
|
|
|
|
m_btnMgr.show(m_wbfsPBar);
|
|
|
|
m_btnMgr.show(m_wbfsLblMessage);
|
|
|
|
m_btnMgr.show(m_wbfsLblDialog);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
_start_pThread();
|
|
|
|
int ret = _gametdbDownloaderAsync();
|
|
|
|
_stop_pThread();
|
|
|
|
if(ret == -1)
|
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg27", L"Not enough memory!"));
|
|
|
|
else if(ret == -2)
|
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg2", L"Network initialization failed!"));
|
|
|
|
else if(ret == -3)
|
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg12", L"Download failed!"));
|
|
|
|
else if(ret == -4)
|
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg15", L"Couldn't save ZIP file"));
|
|
|
|
else
|
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg14", L"Done."));
|
|
|
|
dl_finished = true;
|
|
|
|
}
|
|
|
|
/*else if(m_btnMgr.selected(m_downloadBtnCancel))
|
|
|
|
{
|
|
|
|
LockMutex lock(m_mutex);
|
|
|
|
m_thrdStop = true;
|
|
|
|
m_thrdMessageAdded = true;
|
|
|
|
m_thrdMessage = _t("dlmsg6", L"Canceling...");
|
|
|
|
}*/
|
|
|
|
else if(m_btnMgr.selected(m_downloadBtnCoverSet))
|
|
|
|
{
|
|
|
|
settingsmenu = true;
|
2020-04-12 21:25:10 +02:00
|
|
|
_showSettings();
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
|
|
|
else if(m_btnMgr.selected(m_downloadBtnBack))
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
if(settingsmenu)
|
2018-05-17 01:33:56 +02:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
settingsmenu = false;
|
|
|
|
_hideSettings();
|
|
|
|
_showDownload();
|
2018-05-17 01:33:56 +02:00
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else
|
|
|
|
break;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else if(m_btnMgr.selected(m_downloadBtnPrioM))
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
if(m_downloadPrioVal & C_TYPE_ONOR)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
m_downloadPrioVal ^= C_TYPE_ONOR;
|
2013-06-30 20:40:49 +02:00
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
if(m_downloadPrioVal & C_TYPE_ONCU)
|
|
|
|
{
|
|
|
|
if(m_downloadPrioVal & C_TYPE_PRIOA)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
if(m_downloadPrioVal & C_TYPE_PRIOB)
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
m_downloadPrioVal ^= C_TYPE_PRIOB;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_downloadPrioVal ^= C_TYPE_PRIOA;
|
|
|
|
m_downloadPrioVal ^= C_TYPE_PRIOB;
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else
|
2012-06-08 21:29:23 +02:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
if(m_downloadPrioVal & C_TYPE_PRIOB)
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
m_downloadPrioVal ^= C_TYPE_PRIOB;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_downloadPrioVal ^= C_TYPE_ONCU;
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
|
|
|
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);
|
|
|
|
_showSettings();
|
|
|
|
}
|
|
|
|
else if(m_btnMgr.selected(m_downloadBtnPrioP))
|
|
|
|
{
|
|
|
|
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)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
if(m_downloadPrioVal & C_TYPE_PRIOB)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
m_downloadPrioVal ^= C_TYPE_ONOR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_downloadPrioVal ^= C_TYPE_PRIOB;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2012-02-12 02:43:31 +01:00
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else
|
2013-09-24 17:21:31 +02:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
if(m_downloadPrioVal & C_TYPE_PRIOB)
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
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 );
|
|
|
|
_showSettings();
|
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else if(m_btnMgr.selected(m_downloadBtnEN) || m_btnMgr.selected(m_downloadBtnENs))
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_EN;
|
2018-06-06 13:32:45 +02:00
|
|
|
m_cfg.setUInt("GENERAL", "cover_prio", m_downloadPrioVal);
|
2012-02-12 02:43:31 +01:00
|
|
|
_showSettings();
|
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else if(m_btnMgr.selected(m_downloadBtnJA) || m_btnMgr.selected(m_downloadBtnJAs))
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_JA;
|
2018-06-06 13:32:45 +02:00
|
|
|
m_cfg.setUInt("GENERAL", "cover_prio", m_downloadPrioVal);
|
2012-02-12 02:43:31 +01:00
|
|
|
_showSettings();
|
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else if(m_btnMgr.selected(m_downloadBtnFR) || m_btnMgr.selected(m_downloadBtnFRs))
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_FR;
|
2018-06-06 13:32:45 +02:00
|
|
|
m_cfg.setUInt("GENERAL", "cover_prio", m_downloadPrioVal);
|
2012-02-12 02:43:31 +01:00
|
|
|
_showSettings();
|
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else if(m_btnMgr.selected(m_downloadBtnDE) || m_btnMgr.selected(m_downloadBtnDEs))
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_DE;
|
2018-06-06 13:32:45 +02:00
|
|
|
m_cfg.setUInt("GENERAL", "cover_prio", m_downloadPrioVal);
|
2012-02-12 02:43:31 +01:00
|
|
|
_showSettings();
|
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else if(m_btnMgr.selected(m_downloadBtnES) || m_btnMgr.selected(m_downloadBtnESs))
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_ES;
|
2018-06-06 13:32:45 +02:00
|
|
|
m_cfg.setUInt("GENERAL", "cover_prio", m_downloadPrioVal);
|
2012-02-12 02:43:31 +01:00
|
|
|
_showSettings();
|
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else if(m_btnMgr.selected(m_downloadBtnIT) || m_btnMgr.selected(m_downloadBtnITs))
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_IT;
|
2018-06-06 13:32:45 +02:00
|
|
|
m_cfg.setUInt("GENERAL", "cover_prio", m_downloadPrioVal);
|
2012-02-12 02:43:31 +01:00
|
|
|
_showSettings();
|
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else if(m_btnMgr.selected(m_downloadBtnNL) || m_btnMgr.selected(m_downloadBtnNLs))
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_NL;
|
2018-06-06 13:32:45 +02:00
|
|
|
m_cfg.setUInt("GENERAL", "cover_prio", m_downloadPrioVal);
|
2012-02-12 02:43:31 +01:00
|
|
|
_showSettings();
|
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else if(m_btnMgr.selected(m_downloadBtnPT) || m_btnMgr.selected(m_downloadBtnPTs))
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_PT;
|
2018-06-06 13:32:45 +02:00
|
|
|
m_cfg.setUInt("GENERAL", "cover_prio", m_downloadPrioVal);
|
2012-02-12 02:43:31 +01:00
|
|
|
_showSettings();
|
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else if(m_btnMgr.selected(m_downloadBtnRU) || m_btnMgr.selected(m_downloadBtnRUs))
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_RU;
|
2018-06-06 13:32:45 +02:00
|
|
|
m_cfg.setUInt("GENERAL", "cover_prio", m_downloadPrioVal);
|
2012-02-12 02:43:31 +01:00
|
|
|
_showSettings();
|
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else if(m_btnMgr.selected(m_downloadBtnKO) || m_btnMgr.selected(m_downloadBtnKOs))
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_KO;
|
2018-06-06 13:32:45 +02:00
|
|
|
m_cfg.setUInt("GENERAL", "cover_prio", m_downloadPrioVal);
|
2012-02-12 02:43:31 +01:00
|
|
|
_showSettings();
|
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else if(m_btnMgr.selected(m_downloadBtnZHCN) || m_btnMgr.selected(m_downloadBtnZHCNs))
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_ZHCN;
|
2018-06-06 13:32:45 +02:00
|
|
|
m_cfg.setUInt("GENERAL", "cover_prio", m_downloadPrioVal);
|
2012-02-12 02:43:31 +01:00
|
|
|
_showSettings();
|
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
else if(m_btnMgr.selected(m_downloadBtnAU) || m_btnMgr.selected(m_downloadBtnAUs))
|
2012-02-12 02:43:31 +01:00
|
|
|
{
|
|
|
|
_hideSettings();
|
|
|
|
m_downloadPrioVal ^= C_TYPE_AU;
|
2018-06-06 13:32:45 +02:00
|
|
|
m_cfg.setUInt("GENERAL", "cover_prio", m_downloadPrioVal);
|
2012-02-12 02:43:31 +01:00
|
|
|
_showSettings();
|
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
_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);
|
2018-12-28 01:47:00 +01:00
|
|
|
m_downloadLblTitle = _addLabel("DOWNLOAD/TITLE", theme.titleFont, L"", 0, 10, 640, 60, theme.titleFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE);
|
2018-12-11 22:24:32 +01:00
|
|
|
|
2013-11-04 20:46:23 +01:00
|
|
|
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);
|
2018-11-23 22:31:04 +01:00
|
|
|
m_downloadLblCoverSet = _addLabel("DOWNLOAD/COVERSSET", theme.btnFont, L"", 20, 185, 385, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_downloadBtnCoverSet = _addButton("DOWNLOAD/COVERSET_BTN", theme.btnFont, L"", 420, 190, 200, 48, theme.btnFontColor);
|
|
|
|
m_downloadLblGameTDBDownload = _addLabel("DOWNLOAD/GAMETDB_DOWNLOAD", theme.btnFont, L"", 20, 245, 385, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_downloadBtnGameTDBDownload = _addButton("DOWNLOAD/GAMETDB_DOWNLOAD_BTN", theme.btnFont, L"", 420, 250, 200, 48, theme.btnFontColor);
|
2018-12-11 22:24:32 +01:00
|
|
|
m_downloadLblBanners = _addLabel("DOWNLOAD/BANNERS", theme.btnFont, L"", 20, 305, 385, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_downloadBtnBanners = _addButton("DOWNLOAD/BANNERS_BTN", theme.btnFont, L"", 420, 310, 200, 48, theme.btnFontColor);
|
|
|
|
|
2013-11-04 20:46:23 +01:00
|
|
|
m_downloadLblGameTDB = _addLabel("DOWNLOAD/GAMETDB", theme.lblFont, L"", 20, 390, 370, 60, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
2018-06-06 13:32:45 +02:00
|
|
|
m_downloadBtnCancel = _addButton("DOWNLOAD/CANCEL_BTN", theme.btnFont, L"", 420, 400, 200, 48, theme.btnFontColor);
|
|
|
|
m_downloadPBar = _addProgressBar("DOWNLOAD/PROGRESS_BAR", 40, 200, 560, 20);
|
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
|
2018-12-28 01:47:00 +01:00
|
|
|
m_downloadLblSetTitle = _addLabel("DOWNLOAD/SETTITLE", theme.titleFont, L"", 0, 10, 640, 60, theme.titleFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE);
|
2013-11-04 20:46:23 +01:00
|
|
|
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_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);
|
2018-06-06 13:32:45 +02:00
|
|
|
m_downloadBtnAU = _addPicButton("DOWNLOAD/AU", theme.btnAUOff, theme.btnAUOffs, 330, 215, 80, 80);
|
2013-11-04 20:46:23 +01:00
|
|
|
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_downloadBtnKO = _addPicButton("DOWNLOAD/KO", theme.btnKOOff, theme.btnKOOffs, 230, 300, 80, 80);
|
2018-06-06 13:32:45 +02:00
|
|
|
m_downloadBtnJA = _addPicButton("DOWNLOAD/JA", theme.btnJAOff, theme.btnJAOffs, 330, 300, 80, 80);
|
|
|
|
m_downloadBtnRU = _addPicButton("DOWNLOAD/RU", theme.btnRUOff, theme.btnRUOffs, 430, 300, 80, 80);
|
2013-11-04 20:46:23 +01:00
|
|
|
m_downloadBtnZHCN = _addPicButton("DOWNLOAD/ZHCN", theme.btnZHCNOff, theme.btnZHCNOffs, 530, 300, 80, 80);
|
|
|
|
m_downloadBtnENs = _addPicButton("DOWNLOAD/ENS", theme.btnENOn, theme.btnENOns, 20, 215, 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);
|
2018-06-06 13:32:45 +02:00
|
|
|
m_downloadBtnAUs = _addPicButton("DOWNLOAD/AUS", theme.btnAUOn, theme.btnAUOns, 330, 215, 80, 80);
|
2013-11-04 20:46:23 +01:00
|
|
|
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_downloadBtnKOs = _addPicButton("DOWNLOAD/KOS", theme.btnKOOn, theme.btnKOOns, 230, 300, 80, 80);
|
2018-06-06 13:32:45 +02:00
|
|
|
m_downloadBtnJAs = _addPicButton("DOWNLOAD/JAS", theme.btnJAOn, theme.btnJAOns, 330, 300, 80, 80);
|
|
|
|
m_downloadBtnRUs = _addPicButton("DOWNLOAD/RUS", theme.btnRUOn, theme.btnRUOns, 430, 300, 80, 80);
|
2013-11-04 20:46:23 +01:00
|
|
|
m_downloadBtnZHCNs = _addPicButton("DOWNLOAD/ZHCNS", theme.btnZHCNOn, theme.btnZHCNOns, 530, 300, 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);
|
2013-11-04 20:46:23 +01:00
|
|
|
_setHideAnim(m_downloadLblCovers, "DOWNLOAD/COVERS", 50, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnAll, "DOWNLOAD/ALL_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);
|
2018-12-11 22:24:32 +01:00
|
|
|
_setHideAnim(m_downloadLblBanners, "DOWNLOAD/BANNERS", 50, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnBanners, "DOWNLOAD/BANNERS_BTN", -50, 0, 1.f, 0.f);
|
|
|
|
|
2013-11-04 20:46:23 +01:00
|
|
|
_setHideAnim(m_downloadLblGameTDB, "DOWNLOAD/GAMETDB", 50, 0, -2.f, 0.f);
|
2018-06-06 13:32:45 +02:00
|
|
|
_setHideAnim(m_downloadPBar, "DOWNLOAD/PROGRESS_BAR", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnCancel, "DOWNLOAD/CANCEL_BTN", 0, 0, 1.f, -1.f);
|
2012-03-18 00:14:07 +01:00
|
|
|
|
2020-04-12 21:25:10 +02:00
|
|
|
// Cover settings
|
2012-02-12 02:43:31 +01:00
|
|
|
_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_downloadBtnFR, "DOWNLOAD/FR", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnDE, "DOWNLOAD/DE", 0, 0, -2.f, 0.f);
|
2018-06-06 13:32:45 +02:00
|
|
|
_setHideAnim(m_downloadBtnAU, "DOWNLOAD/AU", 0, 0, -2.f, 0.f);
|
2012-02-12 02:43:31 +01:00
|
|
|
_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_downloadBtnKO, "DOWNLOAD/KO", 0, 0, -2.f, 0.f);
|
2018-06-06 13:32:45 +02:00
|
|
|
_setHideAnim(m_downloadBtnJA, "DOWNLOAD/JA", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnRU, "DOWNLOAD/RU", 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);
|
2012-02-12 02:43:31 +01:00
|
|
|
_setHideAnim(m_downloadBtnENs, "DOWNLOAD/ENS", 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);
|
2018-06-06 13:32:45 +02:00
|
|
|
_setHideAnim(m_downloadBtnAUs, "DOWNLOAD/AUS", 0, 0, -2.f, 0.f);
|
2012-02-12 02:43:31 +01:00
|
|
|
_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_downloadBtnKOs, "DOWNLOAD/KOS", 0, 0, -2.f, 0.f);
|
2018-06-06 13:32:45 +02:00
|
|
|
_setHideAnim(m_downloadBtnJAs, "DOWNLOAD/JAS", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_downloadBtnRUs, "DOWNLOAD/RUS", 0, 0, -2.f, 0.f);
|
2012-02-12 02:43:31 +01:00
|
|
|
_setHideAnim(m_downloadBtnZHCNs, "DOWNLOAD/ZHCNS", 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)
|
|
|
|
{
|
2018-11-23 22:31:04 +01:00
|
|
|
m_btnMgr.setText(m_downloadLblTitle, _t("dl5", L"Downloads"));
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.setText(m_downloadLblCovers, _t("dl8", L"Covers"));
|
2018-11-23 22:31:04 +01:00
|
|
|
m_btnMgr.setText(m_downloadBtnAll, _t("dl6", L"Download"));
|
2016-12-01 01:05:39 +01:00
|
|
|
m_btnMgr.setText(m_downloadLblCoverSet, _t("dl15", L"Cover download settings"));
|
2020-04-12 21:25:10 +02:00
|
|
|
m_btnMgr.setText(m_downloadBtnCoverSet, _t("dl16", L"Set"));
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.setText(m_downloadLblGameTDBDownload, _t("dl12", L"GameTDB"));
|
2016-12-01 01:05:39 +01:00
|
|
|
m_btnMgr.setText(m_downloadBtnGameTDBDownload, _t("dl6", L"Download"));
|
2018-12-11 22:24:32 +01:00
|
|
|
m_btnMgr.setText(m_downloadLblBanners, _t("dl26", L"GC Custom Banners"));
|
2020-04-12 21:25:10 +02:00
|
|
|
m_btnMgr.setText(m_downloadBtnBanners, _t("dl6", L"Download"));
|
2018-12-11 22:24:32 +01:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.setText(m_downloadLblGameTDB, _t("dl10", L"Please donate\nto GameTDB.com"));
|
2016-12-01 01:05:39 +01:00
|
|
|
m_btnMgr.setText(m_downloadBtnCancel, _t("dl1", L"Cancel"));
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2016-12-01 01:05:39 +01:00
|
|
|
m_btnMgr.setText(m_downloadLblSetTitle, _t("dl17", L"Cover Download Settings"));
|
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_downloadBtnBack, _t("dl18", L"Back"));
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
/************************************* Setup network connection *********************************************/
|
2020-08-24 01:09:13 +02:00
|
|
|
/*
|
2018-12-24 14:42:31 +01:00
|
|
|
void CMenu::_netInit(void)
|
|
|
|
{
|
2020-08-24 01:09:13 +02:00
|
|
|
if(networkInit || m_exit)
|
2018-12-24 14:42:31 +01:00
|
|
|
return;
|
|
|
|
_initAsyncNetwork();
|
|
|
|
while(net_get_status() == -EBUSY)
|
|
|
|
usleep(100);
|
|
|
|
}
|
2020-08-24 01:09:13 +02:00
|
|
|
*/
|
2018-06-06 13:32:45 +02:00
|
|
|
void CMenu::_initAsyncNetwork()
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2020-08-24 01:09:13 +02:00
|
|
|
if(networkInit || m_exit)
|
|
|
|
return;
|
2018-06-06 13:32:45 +02:00
|
|
|
if(!_isNetworkAvailable())
|
|
|
|
return;
|
|
|
|
m_thrdNetwork = true;
|
|
|
|
net_init_async(_networkComplete, this);
|
2020-08-24 01:09:13 +02:00
|
|
|
while(net_get_status() == -EBUSY)
|
|
|
|
usleep(100);
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
s32 CMenu::_networkComplete(s32 ok, void *usrData)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
CMenu *m = (CMenu *) usrData;
|
|
|
|
|
|
|
|
networkInit = ok == 0;
|
|
|
|
m->m_thrdNetwork = false;
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2020-03-19 23:38:32 +01:00
|
|
|
if(networkInit)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2020-08-24 01:09:13 +02:00
|
|
|
wolfSSL_Init();
|
|
|
|
if(m->m_use_wifi_gecko)
|
|
|
|
{
|
|
|
|
const string &ip = m->m_cfg.getString("DEBUG", "wifi_gecko_ip");
|
|
|
|
u16 port = m->m_cfg.getInt("DEBUG", "wifi_gecko_port", 4405);
|
|
|
|
if(ip.size() > 0 && port != 0)
|
|
|
|
WiFiDebugger.Init(ip.c_str(), port);
|
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
bool CMenu::_isNetworkAvailable()
|
|
|
|
{
|
2020-08-24 01:09:13 +02:00
|
|
|
bool ret = false;
|
2018-06-06 13:32:45 +02:00
|
|
|
u32 size;
|
|
|
|
char ISFS_Filepath[32] ATTRIBUTE_ALIGN(32);
|
|
|
|
strcpy(ISFS_Filepath, "/shared2/sys/net/02/config.dat");
|
|
|
|
u8 *buf = ISFS_GetFile(ISFS_Filepath, &size, -1);
|
|
|
|
if(buf && size > 4)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2020-08-24 01:09:13 +02:00
|
|
|
ret = buf[4] > 0; // There is a valid connection defined.
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2020-06-26 01:11:58 +02:00
|
|
|
MEM2_free(buf);
|
2020-08-24 01:09:13 +02:00
|
|
|
return ret;
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
|
|
|
|
2020-08-24 01:09:13 +02:00
|
|
|
s32 CMenu::_initNetwork()
|
2018-06-06 13:32:45 +02:00
|
|
|
{
|
|
|
|
while(net_get_status() == -EBUSY && m_thrdNetwork == true)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2020-04-12 21:25:10 +02:00
|
|
|
usleep(100); // Async initialization may be busy, wait to see if it succeeds.
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
2020-08-24 01:09:13 +02:00
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
if(networkInit)
|
|
|
|
return 0;
|
2020-08-24 01:09:13 +02:00
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
if(!_isNetworkAvailable())
|
|
|
|
return -2;
|
|
|
|
|
|
|
|
char ip[16];
|
2020-08-24 01:09:13 +02:00
|
|
|
s32 ret = if_config(ip, NULL, NULL, true, 0);
|
2019-10-25 00:26:17 +02:00
|
|
|
|
2020-08-24 01:09:13 +02:00
|
|
|
if(ret == 0)
|
|
|
|
{
|
2019-10-25 00:26:17 +02:00
|
|
|
wolfSSL_Init();
|
2020-08-24 01:09:13 +02:00
|
|
|
networkInit = true;
|
|
|
|
}
|
|
|
|
return ret;
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
/************************************* Cover Downloading ******************************/
|
|
|
|
|
|
|
|
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())
|
2013-06-30 20:40:49 +02:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
case CONF_AREA_BRA:
|
|
|
|
return "PT";
|
|
|
|
case CONF_AREA_AUS:
|
|
|
|
return "AU";
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
switch (CONF_GetLanguage())
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
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";
|
|
|
|
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";
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
return "other";
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
static string makeURL(const string format, const string gameId, const string country)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
string url = format;
|
|
|
|
if(url.find(TAG_LOC) != url.npos)
|
2020-04-12 21:25:10 +02:00
|
|
|
url.replace(url.find(TAG_LOC), strlen(TAG_LOC), country.c_str());
|
2018-06-06 13:32:45 +02:00
|
|
|
|
|
|
|
if(url.find(TAG_CONSOLE) != url.npos)
|
|
|
|
url.replace(url.find(TAG_CONSOLE), strlen(TAG_CONSOLE), "wii");
|
|
|
|
|
|
|
|
url.replace(url.find(TAG_GAME_ID), strlen(TAG_GAME_ID), gameId.c_str());
|
|
|
|
|
|
|
|
return url;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2018-12-13 01:03:33 +01:00
|
|
|
|
|
|
|
void CMenu::_downloadProgress(void *obj, int size, int position)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
CMenu *m = (CMenu *)obj;
|
|
|
|
m->m_progress = size == 0 ? 0.f : (float)position / (float)size;
|
|
|
|
// Don't synchronize too often
|
|
|
|
if(m->m_progress - m->m_thrdProgress >= 0.01f)
|
|
|
|
{
|
|
|
|
LWP_MutexLock(m->m_mutex);
|
|
|
|
m->m_thrdProgress = m->m_progress;
|
|
|
|
LWP_MutexUnlock(m->m_mutex);
|
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2018-12-13 01:03:33 +01:00
|
|
|
void * CMenu::_pThread(void *obj)
|
2018-06-06 13:32:45 +02:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
CMenu *m = (CMenu*)obj;
|
|
|
|
m->SetupInput();
|
|
|
|
while(m->m_thrdInstalling)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
m->_mainLoopCommon();
|
|
|
|
if(m->m_thrdUpdated)
|
|
|
|
{
|
|
|
|
m->m_thrdUpdated = false;
|
|
|
|
m->_downloadProgress(obj, m->m_thrdTotal, m->m_thrdWritten);
|
|
|
|
if(m->m_thrdProgress > 0.f)
|
|
|
|
{
|
|
|
|
m_btnMgr.setText(m->m_wbfsLblMessage, wfmt(L"%i%%", (int)(m->m_thrdProgress * 100.f)));
|
|
|
|
m_btnMgr.setProgress(m->m_wbfsPBar, m->m_thrdProgress);
|
|
|
|
}
|
|
|
|
m->m_thrdDone = true;
|
|
|
|
}
|
|
|
|
if(m->m_thrdMessageAdded)
|
|
|
|
{
|
|
|
|
m->m_thrdMessageAdded = false;
|
|
|
|
if(!m->m_thrdMessage.empty())
|
|
|
|
m_btnMgr.setText(m->m_wbfsLblDialog, m->m_thrdMessage);
|
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2018-12-13 01:03:33 +01:00
|
|
|
m->m_thrdWorking = false;
|
|
|
|
return 0;
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
2018-12-13 01:03:33 +01:00
|
|
|
|
|
|
|
void CMenu::_start_pThread(void)
|
2018-06-06 13:32:45 +02:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
m_thrdPtr = LWP_THREAD_NULL;
|
|
|
|
m_thrdWorking = true;
|
|
|
|
m_thrdMessageAdded = false;
|
|
|
|
m_thrdInstalling = true;
|
|
|
|
m_thrdUpdated = false;
|
|
|
|
m_thrdDone = true;
|
|
|
|
m_thrdProgress = 0.f;
|
|
|
|
m_thrdWritten = 0;
|
|
|
|
m_thrdTotal = 0;
|
|
|
|
LWP_CreateThread(&m_thrdPtr, _pThread, this, 0, 8 * 1024, 64);
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
2012-03-18 00:14:07 +01:00
|
|
|
|
2018-12-13 01:03:33 +01:00
|
|
|
void CMenu::_stop_pThread(void)
|
2018-06-06 13:32:45 +02:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
if(m_thrdPtr == LWP_THREAD_NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if(LWP_ThreadIsSuspended(m_thrdPtr))
|
|
|
|
LWP_ResumeThread(m_thrdPtr);
|
|
|
|
m_thrdInstalling = false;
|
|
|
|
while(m_thrdWorking)
|
|
|
|
usleep(50);
|
|
|
|
LWP_JoinThread(m_thrdPtr, NULL);
|
|
|
|
m_thrdPtr = LWP_THREAD_NULL;
|
|
|
|
|
|
|
|
m_btnMgr.setProgress(m_wbfsPBar, 1.f);
|
|
|
|
m_btnMgr.setText(m_wbfsLblMessage, L"100%");
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::update_pThread(u64 amount, bool add)
|
|
|
|
{
|
|
|
|
if(m_thrdDone)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
m_thrdDone = false;
|
|
|
|
if(add)
|
2021-09-21 00:40:03 +02:00
|
|
|
m_thrdWritten = m_thrdWritten + amount;
|
2018-12-13 01:03:33 +01:00
|
|
|
else
|
|
|
|
m_thrdWritten = amount;
|
|
|
|
m_thrdUpdated = true;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
2012-03-18 00:14:07 +01:00
|
|
|
|
2018-11-23 22:31:04 +01:00
|
|
|
int CMenu::_coverDownloader()
|
2018-06-06 13:32:45 +02:00
|
|
|
{
|
2018-11-19 19:14:40 +01:00
|
|
|
count = 0;
|
|
|
|
countFlat = 0;
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
GameTDB c_gameTDB;
|
|
|
|
if(m_settingsDir.size() > 0)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
c_gameTDB.OpenFile(fmt("%s/wiitdb.xml", m_settingsDir.c_str()));
|
|
|
|
c_gameTDB.SetLanguageCode(m_curLanguage.c_str());
|
|
|
|
}
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2018-06-06 13:32:45 +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-01-21 21:57:41 +01:00
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
vector<string> coverIDList;
|
2020-04-12 21:25:10 +02:00
|
|
|
|
|
|
|
/* Create list of cover ID's that need downloading */
|
2018-12-13 01:03:33 +01:00
|
|
|
if(dl_gameID.empty())
|
2018-06-06 13:32:45 +02:00
|
|
|
{
|
|
|
|
for(u32 i = 0; i < m_gameList.size(); ++i)
|
|
|
|
{
|
|
|
|
if(m_gameList[i].type == TYPE_PLUGIN || m_gameList[i].type == TYPE_HOMEBREW)
|
|
|
|
continue;
|
2018-11-23 22:31:04 +01:00
|
|
|
if(!fsop_FileExist(fmt("%s/%s.png", m_boxPicDir.c_str(), m_gameList[i].id)))
|
|
|
|
coverIDList.push_back(m_gameList[i].id);
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2018-12-13 01:03:33 +01:00
|
|
|
coverIDList.push_back(dl_gameID);
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2018-11-19 19:14:40 +01:00
|
|
|
n = coverIDList.size();
|
2020-04-12 21:25:10 +02:00
|
|
|
m_thrdTotal = n * 3; // 3 = Download cover, save png and make wfc
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
if(m_thrdTotal == 0)
|
|
|
|
{
|
|
|
|
if(c_gameTDB.IsLoaded())
|
|
|
|
c_gameTDB.CloseFile();
|
|
|
|
coverIDList.clear();
|
|
|
|
return -3;
|
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2020-04-12 21:25:10 +02:00
|
|
|
/* Initialize network connection */
|
2018-12-13 01:03:33 +01:00
|
|
|
m_thrdMessage = _t("dlmsg1", L"Initializing network...");
|
|
|
|
m_thrdMessageAdded = true;
|
|
|
|
if(_initNetwork() < 0)
|
2018-06-06 13:32:45 +02:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
if(c_gameTDB.IsLoaded())
|
|
|
|
c_gameTDB.CloseFile();
|
|
|
|
coverIDList.clear();
|
|
|
|
return -2;
|
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
|
2020-04-12 21:25:10 +02:00
|
|
|
/* Download covers in the list */
|
2018-12-13 01:03:33 +01:00
|
|
|
u32 CoverType = 0;
|
|
|
|
string url;
|
|
|
|
char path[256];
|
2018-06-06 13:32:45 +02:00
|
|
|
|
2018-12-13 01:03:33 +01:00
|
|
|
for(u32 i = 0; i < coverIDList.size(); ++i)
|
|
|
|
{
|
|
|
|
string coverID = coverIDList[i];
|
|
|
|
bool success = false;
|
|
|
|
bool original = true;
|
|
|
|
bool custom = false;
|
|
|
|
int c_altCase = 0;
|
|
|
|
|
2020-04-12 21:25:10 +02:00
|
|
|
/* Try downloading the cover 4 times but a different type each time.*/
|
2018-12-13 01:03:33 +01:00
|
|
|
for(int p = 0; p < 4; ++p)
|
2018-06-06 13:32:45 +02:00
|
|
|
{
|
2020-04-12 21:25:10 +02:00
|
|
|
/* The cover type (BOX, CBOX, FLAT, CFLAT) is different each time based on m_downloadPrioVal */
|
2018-12-13 01:03:33 +01:00
|
|
|
switch(p)
|
2018-06-06 13:32:45 +02:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
case 0:
|
|
|
|
CoverType = m_downloadPrioVal & C_TYPE_PRIOA ? CBOX : BOX;
|
|
|
|
break;
|
|
|
|
case 1:
|
2020-04-12 21:25:10 +02:00
|
|
|
CoverType = m_downloadPrioVal & C_TYPE_PRIOA ? (m_downloadPrioVal & C_TYPE_PRIOB ? CFLAT : BOX) : (m_downloadPrioVal & C_TYPE_PRIOB ? CBOX : FLAT);
|
2018-12-13 01:03:33 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-04-12 21:25:10 +02:00
|
|
|
CoverType = m_downloadPrioVal & C_TYPE_PRIOA ? (m_downloadPrioVal & C_TYPE_PRIOB ? BOX : CFLAT) : (m_downloadPrioVal & C_TYPE_PRIOB ? FLAT : CBOX);
|
2018-12-13 01:03:33 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
CoverType = m_downloadPrioVal & C_TYPE_PRIOA ? FLAT : CFLAT;
|
|
|
|
break;
|
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
|
2018-12-13 01:03:33 +01:00
|
|
|
switch(CoverType)
|
|
|
|
{
|
|
|
|
case BOX:
|
|
|
|
if(m_downloadPrioVal & C_TYPE_ONOR)
|
|
|
|
original = false;
|
|
|
|
if(!success && original)
|
|
|
|
{
|
2020-04-12 21:25:10 +02:00
|
|
|
/* Each fmtURL may have more than one URL */
|
2018-12-13 01:03:33 +01:00
|
|
|
for(u8 j = 0; !success && j < fmtURLBox.size(); ++j)
|
2018-06-06 13:32:45 +02:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
url = makeURL(fmtURLBox[j], coverID, countryCode(coverID));
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2018-12-13 01:03:33 +01:00
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg3", L"Downloading %i/%i from %s"), i + 1, n, url.c_str());
|
|
|
|
m_thrdMessageAdded = true;
|
2019-10-25 00:26:17 +02:00
|
|
|
struct download file = {};
|
|
|
|
downloadfile(url.c_str(), &file);
|
2018-06-06 13:32:45 +02:00
|
|
|
|
2018-12-13 01:03:33 +01:00
|
|
|
for(int o = 0; o < 12; ++o)
|
|
|
|
{
|
2020-04-12 21:25:10 +02:00
|
|
|
bool tdl = false; // tdl = try download
|
2019-10-25 00:26:17 +02:00
|
|
|
if(file.size > 0)// && checkPNGBuf(file.data))
|
2018-12-13 01:03:33 +01:00
|
|
|
break;
|
|
|
|
switch( o )
|
2018-11-23 22:31:04 +01:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
case EN:
|
|
|
|
if((coverID[3] == 'E' || coverID[3] == 'X' || coverID[3] == 'Y' || coverID[3] == 'P') && m_downloadPrioVal & C_TYPE_EN)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLBox[j], coverID, "EN");
|
|
|
|
tdl = true;
|
|
|
|
}
|
2018-11-23 22:31:04 +01:00
|
|
|
break;
|
2018-12-13 01:03:33 +01:00
|
|
|
case JA:
|
|
|
|
if(coverID[3] == 'J' && m_downloadPrioVal&C_TYPE_JA)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLBox[j], coverID, "JA");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FR:
|
|
|
|
if((coverID[3] == 'F' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_FR)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLBox[j], coverID, "FR");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DE:
|
|
|
|
if((coverID[3] == 'D' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_DE)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLBox[j], coverID, "DE");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ES:
|
|
|
|
if((coverID[3] == 'S' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_ES)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLBox[j], coverID, "ES");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IT:
|
|
|
|
if((coverID[3] == 'I' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_IT)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLBox[j], coverID, "IT");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NL:
|
|
|
|
if(coverID[3] == 'P' && m_downloadPrioVal&C_TYPE_NL)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLBox[j], coverID, "NL");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PT:
|
|
|
|
if(coverID[3] == 'P' && m_downloadPrioVal&C_TYPE_PT)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLBox[j], coverID, "PT");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RU:
|
|
|
|
if((coverID[3] == 'R' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_RU)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLBox[j], coverID, "RU");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case KO:
|
|
|
|
if(coverID[3] == 'K' && m_downloadPrioVal&C_TYPE_KO)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLBox[j], coverID, "KO");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AU:
|
|
|
|
if(coverID[3] == 'W' && m_downloadPrioVal&C_TYPE_ZHCN)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLBox[j], coverID, "ZH");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ZHCN:
|
|
|
|
break;
|
|
|
|
}
|
2020-04-12 21:25:10 +02:00
|
|
|
if(tdl) // Try another download
|
2018-12-13 01:03:33 +01:00
|
|
|
{
|
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg3", L"Downloading %i/%i from %s"), i + 1, n, url.c_str());
|
|
|
|
m_thrdMessageAdded = true;
|
2019-10-25 00:26:17 +02:00
|
|
|
downloadfile(url.c_str(), &file);
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
|
|
|
}
|
2020-04-12 21:25:10 +02:00
|
|
|
/* If none of the downloads succeeded */
|
2019-10-25 00:26:17 +02:00
|
|
|
if(file.size == 0)// || !checkPNGBuf(file.data))
|
2018-12-13 01:03:33 +01:00
|
|
|
continue;
|
2020-04-12 21:25:10 +02:00
|
|
|
|
|
|
|
/* Download succeeded - save png */
|
2018-12-13 01:03:33 +01:00
|
|
|
strncpy(path, fmt("%s/%s.png", m_boxPicDir.c_str(), coverID.c_str()), 255);
|
|
|
|
update_pThread(1);
|
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg4", L"Saving %s"), path);
|
|
|
|
m_thrdMessageAdded = true;
|
2019-10-25 00:26:17 +02:00
|
|
|
fsop_WriteFile(path, file.data, file.size);
|
2020-04-12 20:39:10 +02:00
|
|
|
MEM2_free(file.data);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
|
|
|
/* Make cover cache file (wfc) */
|
2018-12-13 01:03:33 +01:00
|
|
|
update_pThread(1);
|
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg10", L"Making %s.wfc"), coverID.c_str());
|
|
|
|
m_thrdMessageAdded = true;
|
2020-04-12 21:25:10 +02:00
|
|
|
CoverFlow.cacheCoverFile(fmt("%s/%s.wfc", m_cacheDir.c_str(), coverID.c_str()), path, true); // Might fail if OOM
|
2018-12-13 01:03:33 +01:00
|
|
|
|
|
|
|
++count;
|
|
|
|
update_pThread(1);
|
|
|
|
success = true;
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
2018-12-13 01:03:33 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CBOX:
|
|
|
|
if(m_downloadPrioVal & C_TYPE_ONCU)
|
|
|
|
custom = true;
|
|
|
|
c_altCase = c_gameTDB.GetCaseVersions(coverID.c_str());
|
|
|
|
if(!success && c_gameTDB.IsLoaded() && c_altCase > 1 && custom)
|
|
|
|
{
|
2020-04-12 21:25:10 +02:00
|
|
|
/* Each fmtURL may have more than one URL */
|
2018-12-13 01:03:33 +01:00
|
|
|
for(u8 j = 0; !success && j < fmtURLCBox.size(); ++j)
|
2018-06-06 13:32:45 +02:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
url = makeURL(fmtURLCBox[j], coverID, countryCode(coverID));
|
2018-06-06 13:32:45 +02:00
|
|
|
|
2018-12-13 01:03:33 +01:00
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg3", L"Downloading %i/%i from %s"), i + 1, n, url.c_str());
|
|
|
|
m_thrdMessageAdded = true;
|
2019-10-25 00:26:17 +02:00
|
|
|
struct download file = {};
|
|
|
|
downloadfile(url.c_str(), &file);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2018-12-13 01:03:33 +01:00
|
|
|
for(int o = 0; o < 12; ++o)
|
|
|
|
{
|
|
|
|
bool tdl = false;
|
2019-10-25 00:26:17 +02:00
|
|
|
if(file.size > 0)// && checkPNGBuf(file.data))
|
2018-12-13 01:03:33 +01:00
|
|
|
break;
|
|
|
|
switch( o )
|
2018-11-23 22:31:04 +01:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
case EN:
|
|
|
|
if(( coverID[3] == 'E' || coverID[3] == 'X' || coverID[3] == 'Y' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_EN )
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], coverID, "EN");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case JA:
|
|
|
|
if(coverID[3] == 'J' && m_downloadPrioVal&C_TYPE_JA)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], coverID, "JA");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FR:
|
|
|
|
if((coverID[3] == 'F' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_FR)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], coverID, "FR");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DE:
|
|
|
|
if((coverID[3] == 'D' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_DE)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], coverID, "DE");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ES:
|
|
|
|
if((coverID[3] == 'S' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_ES)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], coverID, "ES");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IT:
|
|
|
|
if((coverID[3] == 'I' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_IT)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], coverID, "IT");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NL:
|
|
|
|
if(coverID[3] == 'P' && m_downloadPrioVal&C_TYPE_NL)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], coverID, "NL");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PT:
|
|
|
|
if(coverID[3] == 'P' && m_downloadPrioVal&C_TYPE_PT)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], coverID, "PT");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RU:
|
|
|
|
if((coverID[3] == 'R' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_RU)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], coverID, "RU");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case KO:
|
|
|
|
if(coverID[3] == 'K' && m_downloadPrioVal&C_TYPE_KO)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCBox[j], coverID, "KO");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AU:
|
|
|
|
if(coverID[3] == 'W' && m_downloadPrioVal&C_TYPE_ZHCN)
|
2020-04-12 21:25:10 +02:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
url = makeURL(fmtURLCBox[j], coverID, "ZH");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ZHCN:
|
2018-11-23 22:31:04 +01:00
|
|
|
break;
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
2018-11-23 22:31:04 +01:00
|
|
|
|
2018-12-13 01:03:33 +01:00
|
|
|
if(tdl)
|
|
|
|
{
|
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg3", L"Downloading %i/%i from %s"), i + 1, n, url.c_str());
|
|
|
|
m_thrdMessageAdded = true;
|
2019-10-25 00:26:17 +02:00
|
|
|
downloadfile(url.c_str(), &file);
|
2018-12-13 01:03:33 +01:00
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
2018-12-13 01:03:33 +01:00
|
|
|
|
2020-04-12 21:25:10 +02:00
|
|
|
/* If none of the downloads succeeded */
|
2019-10-25 00:26:17 +02:00
|
|
|
if(file.size <= 0)// || !checkPNGBuf(file.data))
|
2018-12-13 01:03:33 +01:00
|
|
|
continue;
|
|
|
|
|
2020-04-12 21:25:10 +02:00
|
|
|
/* Download succeeded - save png */
|
2018-12-13 01:03:33 +01:00
|
|
|
strncpy(path, fmt("%s/%s.png", m_boxPicDir.c_str(), coverID.c_str()), 255);
|
|
|
|
update_pThread(1);
|
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg4", L"Saving %s"), path);
|
|
|
|
m_thrdMessageAdded = true;
|
2019-10-25 00:26:17 +02:00
|
|
|
fsop_WriteFile(path, file.data, file.size);
|
2020-04-12 20:39:10 +02:00
|
|
|
MEM2_free(file.data);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
|
|
|
/* Make cover cache file (wfc) */
|
2018-12-13 01:03:33 +01:00
|
|
|
update_pThread(1);
|
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg10", L"Making %s.wfc"), coverID.c_str());
|
|
|
|
m_thrdMessageAdded = true;
|
2020-04-12 21:25:10 +02:00
|
|
|
CoverFlow.cacheCoverFile(fmt("%s/%s.wfc", m_cacheDir.c_str(), coverID.c_str()), path, true); // Might fail if OOM
|
|
|
|
|
2018-12-13 01:03:33 +01:00
|
|
|
++count;
|
2020-04-12 21:25:10 +02:00
|
|
|
update_pThread(1);
|
2018-12-13 01:03:33 +01:00
|
|
|
success = true;
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
2018-12-13 01:03:33 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FLAT:
|
|
|
|
if(m_downloadPrioVal & C_TYPE_ONOR)
|
|
|
|
original = false;
|
|
|
|
if(!success && original)
|
|
|
|
{
|
2020-04-12 21:25:10 +02:00
|
|
|
/* Each fmtURL may have more than one URL */
|
2018-12-13 01:03:33 +01:00
|
|
|
for(u8 j = 0; !success && j < fmtURLFlat.size(); ++j)
|
2018-06-06 13:32:45 +02:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
url = makeURL(fmtURLFlat[j], coverID, countryCode(coverID));
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2018-12-13 01:03:33 +01:00
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg3", L"Downloading %i/%i from %s"), i + 1, n, url.c_str());
|
|
|
|
m_thrdMessageAdded = true;
|
2019-10-25 00:26:17 +02:00
|
|
|
struct download file = {};
|
|
|
|
downloadfile(url.c_str(), &file);
|
2018-06-06 13:32:45 +02:00
|
|
|
|
2018-12-13 01:03:33 +01:00
|
|
|
for(int o = 0; o < 12; ++o)
|
|
|
|
{
|
|
|
|
bool tdl = false;
|
2019-10-25 00:26:17 +02:00
|
|
|
if(file.size > 0)// && checkPNGBuf(file.data))
|
2018-12-13 01:03:33 +01:00
|
|
|
break;
|
|
|
|
switch( o )
|
2018-11-23 22:31:04 +01:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
case EN:
|
|
|
|
if(( coverID[3] == 'E' || coverID[3] == 'X' || coverID[3] == 'Y' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_EN )
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], coverID, "EN");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case JA:
|
|
|
|
if(coverID[3] == 'J' && m_downloadPrioVal&C_TYPE_JA)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], coverID, "JA");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FR:
|
|
|
|
if((coverID[3] == 'F' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_FR)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], coverID, "FR");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DE:
|
|
|
|
if((coverID[3] == 'D' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_DE)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], coverID, "DE");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ES:
|
|
|
|
if((coverID[3] == 'S' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_ES)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], coverID, "ES");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IT:
|
|
|
|
if((coverID[3] == 'I' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_IT)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], coverID, "IT");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NL:
|
|
|
|
if(coverID[3] == 'P' && m_downloadPrioVal&C_TYPE_NL)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], coverID, "NL");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PT:
|
|
|
|
if(coverID[3] == 'P' && m_downloadPrioVal&C_TYPE_PT)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], coverID, "PT");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RU:
|
|
|
|
if((coverID[3] == 'R' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_RU)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], coverID, "RU");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case KO:
|
|
|
|
if(coverID[3] == 'K' && m_downloadPrioVal&C_TYPE_KO)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], coverID, "KO");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AU:
|
|
|
|
if(coverID[3] == 'W' && m_downloadPrioVal&C_TYPE_ZHCN)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLFlat[j], coverID, "ZH");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ZHCN:
|
2018-11-23 22:31:04 +01:00
|
|
|
break;
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
2018-12-13 01:03:33 +01:00
|
|
|
if(tdl)
|
|
|
|
{
|
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg3", L"Downloading %i/%i from %s"), i + 1, n, url.c_str());
|
|
|
|
m_thrdMessageAdded = true;
|
2019-10-25 00:26:17 +02:00
|
|
|
downloadfile(url.c_str(), &file);
|
2018-12-13 01:03:33 +01:00
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
2018-12-13 01:03:33 +01:00
|
|
|
|
2020-04-12 21:25:10 +02:00
|
|
|
/* If none of the downloads succeeded */
|
2019-10-25 00:26:17 +02:00
|
|
|
if(file.size <= 0)// || !checkPNGBuf(file.data))
|
2018-12-13 01:03:33 +01:00
|
|
|
continue;
|
|
|
|
|
2020-04-12 21:25:10 +02:00
|
|
|
/* Download succeeded - save png */
|
2018-12-18 23:43:36 +01:00
|
|
|
strncpy(path, fmt("%s/%s.png", m_picDir.c_str(), coverID.c_str()), 255);
|
2018-12-13 01:03:33 +01:00
|
|
|
update_pThread(1);
|
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg4", L"Saving %s"), path);
|
|
|
|
m_thrdMessageAdded = true;
|
2019-10-25 00:26:17 +02:00
|
|
|
fsop_WriteFile(path, file.data, file.size);
|
2020-04-12 20:39:10 +02:00
|
|
|
MEM2_free(file.data);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
|
|
|
/* Make cover cache file (wfc) */
|
2018-12-13 01:03:33 +01:00
|
|
|
update_pThread(1);
|
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverID.c_str()));
|
|
|
|
m_thrdMessageAdded = true;
|
2020-04-12 21:25:10 +02:00
|
|
|
CoverFlow.cacheCoverFile(fmt("%s/%s.wfc", m_cacheDir.c_str(), coverID.c_str()), path, false); // Might fail if OOM
|
2018-12-13 01:03:33 +01:00
|
|
|
|
|
|
|
++countFlat;
|
|
|
|
update_pThread(1);
|
|
|
|
success = true;
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
2018-12-13 01:03:33 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CFLAT:
|
|
|
|
if(m_downloadPrioVal & C_TYPE_ONCU)
|
|
|
|
custom = true;
|
|
|
|
if(!success && c_gameTDB.IsLoaded() && c_altCase > 1 && custom)
|
|
|
|
{
|
2020-04-12 21:25:10 +02:00
|
|
|
/* Each fmtURL may have more than one URL */
|
2018-12-13 01:03:33 +01:00
|
|
|
for(u8 j = 0; !success && j < fmtURLCFlat.size(); ++j)
|
2018-06-06 13:32:45 +02:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
url = makeURL(fmtURLCFlat[j], coverID, countryCode(coverID));
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2018-12-13 01:03:33 +01:00
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg3", L"Downloading %i/%i from %s"), i + 1, n, url.c_str());
|
|
|
|
m_thrdMessageAdded = true;
|
2019-10-25 00:26:17 +02:00
|
|
|
struct download file = {};
|
|
|
|
downloadfile(url.c_str(), &file);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2018-12-13 01:03:33 +01:00
|
|
|
for(int o = 0; o < 12; ++o)
|
2018-06-06 13:32:45 +02:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
bool tdl = false;
|
2019-10-25 00:26:17 +02:00
|
|
|
if(file.size > 0)// && checkPNGBuf(file.data))
|
2018-12-13 01:03:33 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
switch( o )
|
2018-06-06 13:32:45 +02:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
case EN:
|
|
|
|
if(( coverID[3] == 'E' || coverID[3] == 'X' || coverID[3] == 'Y' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_EN )
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], coverID, "EN");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case JA:
|
|
|
|
if(coverID[3] == 'J' && m_downloadPrioVal&C_TYPE_JA)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], coverID, "JA");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FR:
|
|
|
|
if((coverID[3] == 'F' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_FR)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], coverID, "FR");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DE:
|
|
|
|
if((coverID[3] == 'D' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_DE)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], coverID, "DE");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ES:
|
|
|
|
if((coverID[3] == 'S' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_ES)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], coverID, "ES");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IT:
|
|
|
|
if((coverID[3] == 'I' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_IT)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], coverID, "IT");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NL:
|
|
|
|
if(coverID[3] == 'P' && m_downloadPrioVal&C_TYPE_NL)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], coverID, "NL");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PT:
|
|
|
|
if(coverID[3] == 'P' && m_downloadPrioVal&C_TYPE_PT)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], coverID, "PT");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RU:
|
|
|
|
if((coverID[3] == 'R' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_RU)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], coverID, "RU");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case KO:
|
|
|
|
if(coverID[3] == 'K' && m_downloadPrioVal&C_TYPE_KO)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], coverID, "KO");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AU:
|
|
|
|
if((coverID[3] == 'P' || coverID[3] == 'Y' || coverID[3] == 'X') && m_downloadPrioVal&C_TYPE_ZHCN)
|
|
|
|
{
|
|
|
|
url = makeURL(fmtURLCFlat[j], coverID, "ZH");
|
|
|
|
tdl = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ZHCN:
|
2018-11-23 22:31:04 +01:00
|
|
|
break;
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
2018-12-13 01:03:33 +01:00
|
|
|
if(tdl)
|
|
|
|
{
|
|
|
|
LWP_MutexLock(m_mutex);
|
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg3", L"Downloading %i/%i from %s"), i + 1, n, url.c_str());
|
|
|
|
m_thrdMessageAdded = true;
|
|
|
|
LWP_MutexUnlock(m_mutex);
|
2019-10-25 00:26:17 +02:00
|
|
|
downloadfile(url.c_str(), &file);
|
2018-12-13 01:03:33 +01:00
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
2018-12-13 01:03:33 +01:00
|
|
|
|
2020-04-12 21:25:10 +02:00
|
|
|
/* If none of the downloads succeeded */
|
2019-10-25 00:26:17 +02:00
|
|
|
if(file.size <= 0)// || !checkPNGBuf(file.data))
|
2018-12-13 01:03:33 +01:00
|
|
|
continue;
|
|
|
|
|
2020-04-12 21:25:10 +02:00
|
|
|
/* Download succeeded - save png */
|
2018-12-18 23:43:36 +01:00
|
|
|
strncpy(path, fmt("%s/%s.png", m_picDir.c_str(), coverID.c_str()), 255);
|
2018-12-13 01:03:33 +01:00
|
|
|
update_pThread(1);
|
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg4", L"Saving %s"), path);
|
|
|
|
m_thrdMessageAdded = true;
|
2019-10-25 00:26:17 +02:00
|
|
|
fsop_WriteFile(path, file.data, file.size);
|
2020-04-12 20:39:10 +02:00
|
|
|
MEM2_free(file.data);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
|
|
|
/* Make cover cache file (wfc) */
|
2018-12-13 01:03:33 +01:00
|
|
|
update_pThread(1);
|
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverID.c_str()));
|
|
|
|
m_thrdMessageAdded = true;
|
2020-04-12 21:25:10 +02:00
|
|
|
CoverFlow.cacheCoverFile(fmt("%s/%s.wfc", m_cacheDir.c_str(), coverID.c_str()), path, false); // Might fail if OOM
|
2018-12-13 01:03:33 +01:00
|
|
|
|
|
|
|
++countFlat;
|
|
|
|
update_pThread(1);
|
|
|
|
success = true;
|
2018-06-06 13:32:45 +02:00
|
|
|
}
|
2018-12-13 01:03:33 +01:00
|
|
|
}
|
|
|
|
break;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
}
|
2018-12-13 01:03:33 +01:00
|
|
|
if(!success)
|
|
|
|
update_pThread(3);
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2020-04-12 21:25:10 +02:00
|
|
|
/* Cover list done and downloading complete */
|
2018-06-06 13:32:45 +02:00
|
|
|
if(c_gameTDB.IsLoaded())
|
|
|
|
c_gameTDB.CloseFile();
|
|
|
|
coverIDList.clear();
|
2012-01-21 21:57:41 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
/*************************************************************************************************/
|
|
|
|
/*************************************************************************************************/
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
int CMenu::_gametdbDownloaderAsync()
|
|
|
|
{
|
2013-09-24 17:21:31 +02:00
|
|
|
const string &langCode = m_loc.getString(m_curLanguage, "gametdb_code", "EN");
|
2020-04-12 21:25:10 +02:00
|
|
|
m_thrdTotal = 3; // Download, save and unzip
|
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
m_thrdMessage = _t("dlmsg1", L"Initializing network...");
|
|
|
|
m_thrdMessageAdded = true;
|
|
|
|
if(_initNetwork() < 0)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
return -2;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-06-06 13:32:45 +02:00
|
|
|
m_thrdMessage = _t("dlmsg11", L"Downloading...");
|
2019-10-25 00:26:17 +02:00
|
|
|
m_thrdMessageAdded = true;
|
|
|
|
struct download file = {};
|
|
|
|
downloadfile(fmt(GAMETDB_URL, langCode.c_str()), &file);
|
2021-02-05 20:51:15 +01:00
|
|
|
if(errno == ENOMEM)
|
|
|
|
return -1;
|
|
|
|
else if(file.size <= 0)
|
2018-06-06 13:32:45 +02:00
|
|
|
return -3;
|
2012-01-21 21:57:41 +01:00
|
|
|
else
|
|
|
|
{
|
2020-04-12 21:25:10 +02:00
|
|
|
update_pThread(1); // It's downloaded
|
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);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2013-09-24 17:21:31 +02:00
|
|
|
fsop_deleteFile(zippath);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg4", L"Saving %s"), "wiitdb.zip");
|
2020-04-12 21:25:10 +02:00
|
|
|
m_thrdMessageAdded = true;
|
2019-10-25 00:26:17 +02:00
|
|
|
res = fsop_WriteFile(zippath, file.data, file.size);
|
2020-04-12 20:39:10 +02:00
|
|
|
MEM2_free(file.data);
|
2013-09-24 17:21:31 +02:00
|
|
|
}
|
|
|
|
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);
|
2018-06-06 13:32:45 +02:00
|
|
|
return -4;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-12 21:25:10 +02:00
|
|
|
update_pThread(1); // It's saved
|
2012-01-21 21:57:41 +01:00
|
|
|
gprintf("Extracting zip file: ");
|
2013-06-30 20:40:49 +02:00
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg24", L"Extracting %s"), "wiitdb.zip");
|
2020-04-12 21:25:10 +02:00
|
|
|
m_thrdMessageAdded = true;
|
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");
|
2020-04-12 21:25:10 +02:00
|
|
|
// May add if zres failed return -4 extraction failed
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
// 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()));
|
2020-04-12 21:25:10 +02:00
|
|
|
|
|
|
|
update_pThread(1); // It's extracted
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
// Update cache
|
2016-11-07 16:06:00 +01:00
|
|
|
m_cfg.setBool(WII_DOMAIN, "update_cache", true);
|
|
|
|
m_cfg.setBool(GC_DOMAIN, "update_cache", true);
|
|
|
|
m_cfg.setBool(CHANNEL_DOMAIN, "update_cache", true);
|
|
|
|
m_refreshGameList = true;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2012-05-13 17:13:33 +02:00
|
|
|
}
|
2013-06-27 19:14:11 +02:00
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
/*********************************************************************************/
|
|
|
|
/*********************************************************************************/
|
|
|
|
|
2018-12-13 01:03:33 +01:00
|
|
|
int CMenu::_bannerDownloader()
|
2018-12-11 22:24:32 +01:00
|
|
|
{
|
|
|
|
vector<string> BnrIDList;
|
|
|
|
count = 0;
|
|
|
|
|
2018-12-13 01:03:33 +01:00
|
|
|
if(dl_gameID.empty())
|
2018-12-11 22:24:32 +01:00
|
|
|
{
|
2018-12-13 01:03:33 +01:00
|
|
|
currentPartition = m_cfg.getInt(GC_DOMAIN, "partition", USB1);
|
|
|
|
string gameDir(fmt(gc_games_dir, DeviceName[currentPartition]));
|
|
|
|
string cacheDir(fmt("%s/%s_gamecube.db", m_listCacheDir.c_str(), DeviceName[currentPartition]));
|
2019-11-27 14:28:54 +01:00
|
|
|
m_cacheList.CreateList(COVERFLOW_GAMECUBE, gameDir, stringToVector(".iso|.ciso|root", '|'), cacheDir, false);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2018-12-13 01:03:33 +01:00
|
|
|
for(u32 i = 0; i < m_cacheList.size(); ++i)
|
|
|
|
{
|
|
|
|
if(!fsop_FileExist(fmt("%s/%s.bnr", m_customBnrDir.c_str(), m_cacheList[i].id)))
|
|
|
|
BnrIDList.push_back(m_cacheList[i].id);
|
|
|
|
}
|
|
|
|
m_cacheList.clear();
|
2018-12-11 22:24:32 +01:00
|
|
|
}
|
2018-12-13 01:03:33 +01:00
|
|
|
else
|
|
|
|
BnrIDList.push_back(dl_gameID);
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2018-12-11 22:24:32 +01:00
|
|
|
n = BnrIDList.size();
|
|
|
|
m_thrdTotal = n;
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2018-12-11 22:24:32 +01:00
|
|
|
if(n == 0)
|
|
|
|
{
|
|
|
|
BnrIDList.clear();
|
|
|
|
return -3;
|
|
|
|
}
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2018-12-13 01:03:33 +01:00
|
|
|
const char *banner_url = NULL;
|
|
|
|
const char *banner_url_id3 = NULL;
|
|
|
|
const char *GAME_BNR_ID = "{gameid}";
|
|
|
|
string base_url = m_cfg.getString("GENERAL", "custom_banner_url", CUSTOM_BANNER_URL);
|
|
|
|
if(base_url.size() < 3 || base_url.find(GAME_BNR_ID) == string::npos)
|
|
|
|
{
|
|
|
|
BnrIDList.clear();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2018-12-11 22:24:32 +01:00
|
|
|
m_thrdMessage = _t("dlmsg1", L"Initializing network...");
|
|
|
|
m_thrdMessageAdded = true;
|
|
|
|
if(_initNetwork() < 0)
|
|
|
|
{
|
|
|
|
BnrIDList.clear();
|
|
|
|
return -2;
|
|
|
|
}
|
2020-04-12 21:25:10 +02:00
|
|
|
|
2018-12-11 22:24:32 +01:00
|
|
|
for(u32 i = 0; i < BnrIDList.size(); ++i)
|
|
|
|
{
|
|
|
|
string base_url_id6 = base_url;
|
|
|
|
base_url_id6.replace(base_url_id6.find(GAME_BNR_ID), strlen(GAME_BNR_ID), BnrIDList[i]);
|
2018-12-11 22:35:03 +01:00
|
|
|
banner_url = base_url_id6.c_str();
|
2018-12-11 22:24:32 +01:00
|
|
|
|
|
|
|
string base_url_id3 = base_url;
|
|
|
|
base_url_id3.replace(base_url_id3.find(GAME_BNR_ID), strlen(GAME_BNR_ID), BnrIDList[i].c_str(), 3);
|
|
|
|
banner_url_id3 = base_url_id3.c_str();
|
|
|
|
|
2018-12-13 01:03:33 +01:00
|
|
|
if(dl_gameID.empty())
|
|
|
|
m_thrdMessage = wfmt(_fmt("dlmsg3", L"Downloading banner %i/%i"), i + 1, n);
|
|
|
|
else
|
|
|
|
m_thrdMessage = _t("cfgbnr7", L"Downloading banner...");
|
2018-12-11 22:24:32 +01:00
|
|
|
m_thrdMessageAdded = true;
|
2019-10-25 00:26:17 +02:00
|
|
|
|
|
|
|
struct download file = {};
|
|
|
|
downloadfile(banner_url, &file);
|
|
|
|
if(file.size < 0x5000)
|
|
|
|
{
|
|
|
|
if(file.size > 0)
|
2020-04-12 20:39:10 +02:00
|
|
|
MEM2_free(file.data); // More than 0 bytes and less than 50kb
|
2019-10-25 00:26:17 +02:00
|
|
|
downloadfile(banner_url_id3, &file);
|
|
|
|
}
|
2018-12-11 22:24:32 +01:00
|
|
|
|
2020-04-12 21:25:10 +02:00
|
|
|
/* Minimum 50kb */
|
2019-10-25 00:26:17 +02:00
|
|
|
if(file.size > 51200 && file.data[0] != '<')
|
2018-12-11 22:24:32 +01:00
|
|
|
{
|
2019-10-25 00:26:17 +02:00
|
|
|
fsop_WriteFile(fmt("%s/%s.bnr", m_customBnrDir.c_str(), BnrIDList[i].c_str()), file.data, file.size);
|
2018-12-11 22:24:32 +01:00
|
|
|
count++;
|
|
|
|
}
|
2019-10-25 00:26:17 +02:00
|
|
|
if(file.size > 0)
|
2020-04-12 20:39:10 +02:00
|
|
|
MEM2_free(file.data);
|
2018-12-11 22:24:32 +01:00
|
|
|
update_pThread(1);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-06-06 13:32:45 +02:00
|
|
|
/**************************************************************************************/
|
|
|
|
/**************************************************************************************/
|
|
|
|
|
2013-08-08 20:21:11 +02:00
|
|
|
const char *url_dl = NULL;
|
2020-04-12 21:25:10 +02:00
|
|
|
void CMenu::_downloadUrl(const char *url, u8 **dl_file, u32 *dl_size) // Nothing uses this
|
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;
|
2018-05-29 11:59:57 +02:00
|
|
|
LWP_CreateThread(&thread, _downloadUrlAsync, 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;
|
|
|
|
}
|
|
|
|
|
2018-05-29 11:59:57 +02:00
|
|
|
void * CMenu::_downloadUrlAsync(void *obj)
|
2013-08-08 20:21:11 +02:00
|
|
|
{
|
|
|
|
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;
|
2018-05-29 11:59:57 +02:00
|
|
|
return 0;
|
2013-08-08 20:21:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2018-05-29 11:59:57 +02:00
|
|
|
return 0;
|
2013-08-08 20:21:11 +02:00
|
|
|
}
|
2018-06-06 13:32:45 +02:00
|
|
|
//block file = downloadfile(m->m_buffer, bufferSize, url_dl, CMenu::_downloadProgress, m);
|
2013-08-09 16:52:17 +02:00
|
|
|
DCFlushRange(m->m_buffer, bufferSize);
|
2018-06-06 13:32:45 +02:00
|
|
|
//m->m_file = file.data;
|
|
|
|
//m->m_filesize = file.size;
|
2013-08-08 20:21:11 +02:00
|
|
|
m->m_thrdWorking = false;
|
|
|
|
return 0;
|
|
|
|
}
|