2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
#include "menu.hpp"
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "gui/text.hpp"
|
2016-11-07 16:06:00 +01:00
|
|
|
#include "lockMutex.hpp"
|
2019-10-25 00:26:17 +02:00
|
|
|
#include "network/https.h"
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2020-10-05 22:27:02 +02:00
|
|
|
#define GECKOURL "https://codes.rc24.xyz/txt.php?txt=%s"
|
2012-01-21 21:57:41 +01:00
|
|
|
#define CHEATSPERPAGE 4
|
|
|
|
|
2012-09-13 16:54:17 +02:00
|
|
|
u8 m_cheatSettingsPage = 0;
|
2019-11-04 18:29:12 +01:00
|
|
|
int txtavailable;
|
2021-10-07 23:38:32 +02:00
|
|
|
GCTCheats m_cheatfile;
|
2012-09-13 16:54:17 +02:00
|
|
|
|
2022-08-25 00:26:36 +02:00
|
|
|
void CMenu::_hideCheatSettings(bool instant)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2022-08-25 00:26:36 +02:00
|
|
|
m_btnMgr.hide(m_cheatBtnBack, instant);
|
|
|
|
m_btnMgr.hide(m_cheatBtnApply, instant);
|
|
|
|
m_btnMgr.hide(m_cheatBtnDownload, instant);
|
|
|
|
m_btnMgr.hide(m_cheatLblTitle, instant);
|
|
|
|
|
|
|
|
m_btnMgr.hide(m_cheatLblPage, instant);
|
|
|
|
m_btnMgr.hide(m_cheatBtnPageM, instant);
|
|
|
|
m_btnMgr.hide(m_cheatBtnPageP, instant);
|
2018-06-06 23:56:21 +02:00
|
|
|
|
2023-03-20 20:05:21 +01:00
|
|
|
for(u8 i = 0; i < CHEATSPERPAGE; ++i)
|
|
|
|
{
|
2022-08-25 00:26:36 +02:00
|
|
|
m_btnMgr.hide(m_cheatBtnItem[i], instant);
|
|
|
|
m_btnMgr.hide(m_cheatLblItem[i], instant);
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2019-10-28 19:17:03 +01:00
|
|
|
|
2022-08-25 00:26:36 +02:00
|
|
|
for(u8 i = 0; i < ARRAY_SIZE(m_cheatLblUser); ++i)
|
|
|
|
if(m_cheatLblUser[i] != -1)
|
|
|
|
m_btnMgr.hide(m_cheatLblUser[i], instant);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_showCheatSettings(void)
|
|
|
|
{
|
|
|
|
_setBg(m_cheatBg, m_cheatBg);
|
|
|
|
m_btnMgr.show(m_cheatLblTitle);
|
|
|
|
m_btnMgr.show(m_cheatBtnBack);
|
|
|
|
|
|
|
|
for(u8 i = 0; i < ARRAY_SIZE(m_cheatLblUser); ++i)
|
|
|
|
if(m_cheatLblUser[i] != -1)
|
|
|
|
m_btnMgr.show(m_cheatLblUser[i]);
|
|
|
|
|
2023-03-20 20:05:21 +01:00
|
|
|
if(txtavailable)// if we have a cheat file (txt)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2023-03-20 20:05:21 +01:00
|
|
|
if(m_cheatfile.getCnt() > 0)// if it's not empty
|
2022-08-25 00:26:36 +02:00
|
|
|
{
|
2023-03-20 20:05:21 +01:00
|
|
|
m_btnMgr.setText(m_cheatLblTitle, m_cheatfile.getGameName());
|
|
|
|
|
|
|
|
for(u8 i = 0; i < CHEATSPERPAGE; ++i)
|
2022-08-25 00:26:36 +02:00
|
|
|
{
|
2023-03-20 20:05:21 +01:00
|
|
|
m_btnMgr.hide(m_cheatBtnItem[i], true);
|
|
|
|
m_btnMgr.hide(m_cheatLblItem[i], true);
|
2022-08-25 00:26:36 +02:00
|
|
|
}
|
2023-03-20 20:05:21 +01:00
|
|
|
m_btnMgr.setText(m_cheatLblPage, wfmt(L"%i / %i", m_cheatSettingsPage, (m_cheatfile.getCnt() + CHEATSPERPAGE - 1) / CHEATSPERPAGE));
|
|
|
|
m_btnMgr.show(m_cheatLblPage);
|
|
|
|
m_btnMgr.show(m_cheatBtnPageM);
|
|
|
|
m_btnMgr.show(m_cheatBtnPageP);
|
|
|
|
m_btnMgr.show(m_cheatBtnApply);
|
|
|
|
|
|
|
|
for(u8 i = 0; i < CHEATSPERPAGE; ++i)
|
2022-08-25 00:26:36 +02:00
|
|
|
{
|
2023-03-20 20:05:21 +01:00
|
|
|
if((u8)((m_cheatSettingsPage - 1) * CHEATSPERPAGE + i + 1) <= m_cheatfile.getCnt())
|
|
|
|
{
|
|
|
|
wstringEx chtName;
|
|
|
|
chtName.fromUTF8(m_cheatfile.getCheatName((m_cheatSettingsPage - 1) * CHEATSPERPAGE + i));// converted from utf8 to WS
|
|
|
|
m_btnMgr.setText(m_cheatLblItem[i], chtName);
|
|
|
|
m_btnMgr.setText(m_cheatBtnItem[i], _optBoolToString(m_cheatfile.sCheatSelected[(m_cheatSettingsPage - 1) * CHEATSPERPAGE + i]));
|
|
|
|
|
|
|
|
m_btnMgr.show(m_cheatLblItem[i], false);
|
|
|
|
m_btnMgr.show(m_cheatBtnItem[i], false);
|
|
|
|
}
|
2022-08-25 00:26:36 +02:00
|
|
|
}
|
|
|
|
}
|
2023-03-20 20:05:21 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
m_btnMgr.setText(m_cheatLblTitle, L"");
|
|
|
|
m_btnMgr.setText(m_cheatLblItem[0], _t("dlmsg35", L"Downloaded cheat file has no cheats!"));
|
|
|
|
m_btnMgr.show(m_cheatLblItem[0]);
|
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2023-03-20 20:05:21 +01:00
|
|
|
else// no cheat file (txt). ask to download
|
2019-10-27 02:08:21 +02:00
|
|
|
{
|
2023-03-20 20:05:21 +01:00
|
|
|
m_btnMgr.setText(m_cheatLblTitle, L"");
|
2022-08-25 00:26:36 +02:00
|
|
|
m_btnMgr.show(m_cheatBtnDownload);
|
|
|
|
m_btnMgr.setText(m_cheatLblItem[0], _t("cheat3", L"Cheat file for game not found."));
|
|
|
|
m_btnMgr.show(m_cheatLblItem[0]);
|
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_CheatSettings()
|
|
|
|
{
|
2021-10-11 17:51:50 +02:00
|
|
|
m_cheatSettingsPage = 1;
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2012-12-27 21:22:40 +01:00
|
|
|
const char *id = CoverFlow.getId();
|
2021-10-11 17:51:50 +02:00
|
|
|
txtavailable = m_cheatfile.openTxtfile(fmt("%s/%s.txt", m_txtCheatDir.c_str(), id));
|
|
|
|
|
|
|
|
u32 gctSize = 0;
|
|
|
|
u8 *gctBuf = NULL;
|
|
|
|
if(txtavailable > 0)
|
|
|
|
gctBuf = fsop_ReadFile(fmt("%s/%s.gct", m_cheatDir.c_str(), id), &gctSize);
|
|
|
|
|
|
|
|
u8 chtsCnt = m_cheatfile.getCnt();
|
2023-03-20 20:05:21 +01:00
|
|
|
for(u16 i = 0; i < chtsCnt; ++i)
|
2021-10-11 17:51:50 +02:00
|
|
|
{
|
|
|
|
if(gctBuf && m_cheatfile.IsCheatIncluded(i, gctBuf, gctSize))
|
|
|
|
m_cheatfile.sCheatSelected.push_back(true);
|
|
|
|
else
|
|
|
|
m_cheatfile.sCheatSelected.push_back(false);
|
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2023-03-20 20:05:21 +01:00
|
|
|
SetupInput();
|
2019-11-04 18:29:12 +01:00
|
|
|
_showCheatSettings();
|
|
|
|
|
2012-09-09 20:35:15 +02:00
|
|
|
while(!m_exit)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
_mainLoopCommon();
|
2012-09-09 20:35:15 +02:00
|
|
|
if(BTN_HOME_PRESSED || BTN_B_PRESSED)
|
2012-01-21 21:57:41 +01:00
|
|
|
break;
|
2023-03-20 20:05:21 +01:00
|
|
|
else if(BTN_UP_PRESSED)
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.up();
|
2023-03-20 20:05:21 +01:00
|
|
|
else if(BTN_DOWN_PRESSED)
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.down();
|
2023-03-20 20:05:21 +01:00
|
|
|
else if(txtavailable && (BTN_MINUS_PRESSED || BTN_LEFT_PRESSED || (BTN_A_PRESSED && m_btnMgr.selected(m_cheatBtnPageM))))
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2023-03-20 20:05:21 +01:00
|
|
|
if(m_cheatSettingsPage == 1)
|
|
|
|
m_cheatSettingsPage = (m_cheatfile.getCnt() + CHEATSPERPAGE - 1) / CHEATSPERPAGE;
|
|
|
|
else if(m_cheatSettingsPage > 1)
|
2012-01-21 21:57:41 +01:00
|
|
|
--m_cheatSettingsPage;
|
|
|
|
if(BTN_LEFT_PRESSED || BTN_MINUS_PRESSED) m_btnMgr.click(m_cheatBtnPageM);
|
|
|
|
_showCheatSettings();
|
|
|
|
}
|
2023-03-20 20:05:21 +01:00
|
|
|
else if(txtavailable && (BTN_PLUS_PRESSED || BTN_RIGHT_PRESSED || (BTN_A_PRESSED && m_btnMgr.selected(m_cheatBtnPageP))))
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2023-03-20 20:05:21 +01:00
|
|
|
if(m_cheatSettingsPage == (m_cheatfile.getCnt() + CHEATSPERPAGE - 1) / CHEATSPERPAGE)
|
2012-01-21 21:57:41 +01:00
|
|
|
m_cheatSettingsPage = 1;
|
2023-03-20 20:05:21 +01:00
|
|
|
else if(m_cheatSettingsPage < (m_cheatfile.getCnt() + CHEATSPERPAGE - 1) / CHEATSPERPAGE)
|
2012-01-21 21:57:41 +01:00
|
|
|
++m_cheatSettingsPage;
|
|
|
|
if(BTN_RIGHT_PRESSED || BTN_PLUS_PRESSED) m_btnMgr.click(m_cheatBtnPageP);
|
|
|
|
_showCheatSettings();
|
|
|
|
}
|
2023-03-20 20:05:21 +01:00
|
|
|
else if((WBTN_2_HELD && WBTN_1_PRESSED) || (WBTN_1_HELD && WBTN_2_PRESSED))// pressing 1 and 2 deletes everything so cheats can be downloaded again.
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2013-06-27 19:14:11 +02:00
|
|
|
fsop_deleteFile(fmt("%s/%s.gct", m_cheatDir.c_str(), id));
|
|
|
|
fsop_deleteFile(fmt("%s/%s.txt", m_txtCheatDir.c_str(), id));
|
2012-03-10 20:02:59 +01:00
|
|
|
m_gcfg2.remove(id, "cheat");
|
|
|
|
m_gcfg2.remove(id, "hooktype");
|
2012-01-21 21:57:41 +01:00
|
|
|
break;
|
|
|
|
}
|
2023-03-20 20:05:21 +01:00
|
|
|
else if(BTN_A_PRESSED)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2023-03-20 20:05:21 +01:00
|
|
|
if(m_btnMgr.selected(m_cheatBtnBack))
|
2012-01-21 21:57:41 +01:00
|
|
|
break;
|
2023-03-20 20:05:21 +01:00
|
|
|
u16 pgFirstCht = (m_cheatSettingsPage - 1) * CHEATSPERPAGE;
|
|
|
|
for(int i = 0; i < CHEATSPERPAGE; ++i)
|
|
|
|
{
|
|
|
|
if(m_btnMgr.selected(m_cheatBtnItem[i]))
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2023-03-20 20:05:21 +01:00
|
|
|
m_cheatfile.sCheatSelected[pgFirstCht + i] = !m_cheatfile.sCheatSelected[pgFirstCht + i];
|
2012-01-21 21:57:41 +01:00
|
|
|
_showCheatSettings();
|
|
|
|
}
|
2023-03-20 20:05:21 +01:00
|
|
|
}
|
|
|
|
if(m_btnMgr.selected(m_cheatBtnApply))
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
bool selected = false;
|
|
|
|
//checks if at least one cheat is selected
|
2023-03-20 20:05:21 +01:00
|
|
|
for(u16 i = 0; i < m_cheatfile.getCnt(); ++i)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2023-03-20 20:05:21 +01:00
|
|
|
if(m_cheatfile.sCheatSelected[i] == true)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
selected = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-20 20:05:21 +01:00
|
|
|
if(selected)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-12-27 21:22:40 +01:00
|
|
|
m_cheatfile.createGCT(fmt("%s/%s.gct", m_cheatDir.c_str(), id));
|
2012-03-10 20:02:59 +01:00
|
|
|
m_gcfg2.setOptBool(id, "cheat", 1);
|
|
|
|
m_gcfg2.setInt(id, "hooktype", m_gcfg2.getInt(id, "hooktype", 1));
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-06-27 19:14:11 +02:00
|
|
|
fsop_deleteFile(fmt("%s/%s.gct", m_cheatDir.c_str(), id));
|
2012-03-10 20:02:59 +01:00
|
|
|
m_gcfg2.remove(id, "cheat");
|
|
|
|
m_gcfg2.remove(id, "hooktype");
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2023-03-20 20:05:21 +01:00
|
|
|
else if(m_btnMgr.selected(m_cheatBtnDownload))
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
_hideCheatSettings();
|
2018-06-06 23:56:21 +02:00
|
|
|
bool dl_finished = false;
|
|
|
|
while(!m_exit)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-09-09 20:35:15 +02:00
|
|
|
_mainLoopCommon();
|
2018-06-06 23:56:21 +02:00
|
|
|
if((BTN_HOME_PRESSED || BTN_B_PRESSED) && dl_finished)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2022-08-25 00:26:36 +02:00
|
|
|
m_btnMgr.hide(m_downloadPBar);
|
|
|
|
m_btnMgr.hide(m_downloadLblMessage);
|
|
|
|
m_btnMgr.hide(m_downloadLblDialog);
|
2018-06-06 23:56:21 +02:00
|
|
|
break;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2018-06-06 23:56:21 +02:00
|
|
|
if(!dl_finished)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2022-08-25 00:26:36 +02:00
|
|
|
m_btnMgr.setProgress(m_downloadPBar, 0.f, true);
|
|
|
|
m_btnMgr.setText(m_downloadLblMessage, L"0%");
|
|
|
|
m_btnMgr.setText(m_downloadLblDialog, L"");
|
|
|
|
m_btnMgr.show(m_downloadPBar);
|
|
|
|
m_btnMgr.show(m_downloadLblMessage);
|
|
|
|
m_btnMgr.show(m_downloadLblDialog);
|
2018-06-06 23:56:21 +02:00
|
|
|
|
|
|
|
_start_pThread();
|
|
|
|
int ret = _downloadCheatFileAsync();
|
|
|
|
_stop_pThread();
|
|
|
|
if(ret == -1)
|
2022-08-25 00:26:36 +02:00
|
|
|
m_btnMgr.setText(m_downloadLblDialog, _t("dlmsg27", L"Not enough memory!"));
|
2018-06-06 23:56:21 +02:00
|
|
|
else if(ret == -2)
|
2022-08-25 00:26:36 +02:00
|
|
|
m_btnMgr.setText(m_downloadLblDialog, _t("dlmsg2", L"Network initialization failed!"));
|
2018-06-06 23:56:21 +02:00
|
|
|
else if(ret == -3)
|
2022-08-25 00:26:36 +02:00
|
|
|
m_btnMgr.setText(m_downloadLblDialog, _t("dlmsg12", L"Download failed!"));
|
2019-10-27 02:08:21 +02:00
|
|
|
else if(ret == -4)
|
2022-08-25 00:26:36 +02:00
|
|
|
m_btnMgr.setText(m_downloadLblDialog, _t("dlmsg36", L"No cheat file available to download."));
|
2018-06-06 23:56:21 +02:00
|
|
|
else
|
2022-08-25 00:26:36 +02:00
|
|
|
m_btnMgr.setText(m_downloadLblDialog, _t("dlmsg14", L"Done."));
|
2018-06-06 23:56:21 +02:00
|
|
|
dl_finished = true;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
}
|
2012-12-27 21:22:40 +01:00
|
|
|
txtavailable = m_cheatfile.openTxtfile(fmt("%s/%s.txt", m_txtCheatDir.c_str(), id));
|
2021-10-11 17:51:50 +02:00
|
|
|
if(txtavailable > 0)
|
|
|
|
gctBuf = fsop_ReadFile(fmt("%s/%s.gct", m_cheatDir.c_str(), id), &gctSize);
|
|
|
|
|
|
|
|
chtsCnt = m_cheatfile.getCnt();
|
2023-03-20 20:05:21 +01:00
|
|
|
for(u16 i = 0; i < chtsCnt; ++i)
|
2021-10-11 17:51:50 +02:00
|
|
|
{
|
|
|
|
if(gctBuf && m_cheatfile.IsCheatIncluded(i, gctBuf, gctSize))
|
|
|
|
m_cheatfile.sCheatSelected.push_back(true);
|
|
|
|
else
|
|
|
|
m_cheatfile.sCheatSelected.push_back(false);
|
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
_showCheatSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_hideCheatSettings();
|
|
|
|
}
|
|
|
|
|
2012-11-03 20:16:03 +01:00
|
|
|
void CMenu::_initCheatSettingsMenu()
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-11-03 20:16:03 +01:00
|
|
|
_addUserLabels(m_cheatLblUser, ARRAY_SIZE(m_cheatLblUser), "CHEAT");
|
|
|
|
m_cheatBg = _texture("CHEAT/BG", "texture", theme.bg, false);
|
2018-12-28 01:47:00 +01:00
|
|
|
m_cheatLblTitle = _addLabel("CHEAT/TITLE", theme.titleFont, L"Cheats", 0, 10, 640, 60, theme.titleFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE);
|
2013-11-04 20:46:23 +01:00
|
|
|
m_cheatBtnBack = _addButton("CHEAT/BACK_BTN", theme.btnFont, L"", 420, 400, 200, 48, theme.btnFontColor);
|
|
|
|
m_cheatBtnApply = _addButton("CHEAT/APPLY_BTN", theme.btnFont, L"", 220, 400, 200, 48, theme.btnFontColor);
|
|
|
|
m_cheatBtnDownload = _addButton("CHEAT/DOWNLOAD_BTN", theme.btnFont, L"", 470, 130, 150, 48, theme.btnFontColor);
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2013-11-04 20:46:23 +01:00
|
|
|
m_cheatLblPage = _addLabel("CHEAT/PAGE_BTN", theme.btnFont, L"", 68, 400, 104, 48, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC);
|
|
|
|
m_cheatBtnPageM = _addPicButton("CHEAT/PAGE_MINUS", theme.btnTexMinus, theme.btnTexMinusS, 20, 400, 48, 48);
|
|
|
|
m_cheatBtnPageP = _addPicButton("CHEAT/PAGE_PLUS", theme.btnTexPlus, theme.btnTexPlusS, 172, 400, 48, 48);
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2013-11-04 20:46:23 +01:00
|
|
|
m_cheatLblItem[0] = _addLabel("CHEAT/ITEM_0", theme.lblFont, L"", 20, 125, 460, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_cheatBtnItem[0] = _addButton("CHEAT/ITEM_0_BTN", theme.btnFont, L"", 500, 130, 120, 48, theme.btnFontColor);
|
|
|
|
m_cheatLblItem[1] = _addLabel("CHEAT/ITEM_1", theme.lblFont, L"", 20, 185, 460, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_cheatBtnItem[1] = _addButton("CHEAT/ITEM_1_BTN", theme.btnFont, L"", 500, 190, 120, 48, theme.btnFontColor);
|
|
|
|
m_cheatLblItem[2] = _addLabel("CHEAT/ITEM_2", theme.lblFont, L"", 20, 245, 460, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_cheatBtnItem[2] = _addButton("CHEAT/ITEM_2_BTN", theme.btnFont, L"", 500, 250, 120, 48, theme.btnFontColor);
|
|
|
|
m_cheatLblItem[3] = _addLabel("CHEAT/ITEM_3", theme.lblFont, L"", 20, 305, 460, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_cheatBtnItem[3] = _addButton("CHEAT/ITEM_3_BTN", theme.btnFont, L"", 500, 305, 120, 48, theme.btnFontColor);
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2013-11-04 20:46:23 +01:00
|
|
|
_setHideAnim(m_cheatLblTitle, "CHEAT/TITLE", 0, 0, -2.f, 0.f);
|
2012-02-10 19:45:42 +01:00
|
|
|
_setHideAnim(m_cheatBtnApply, "CHEAT/APPLY_BTN", 0, 0, 1.f, -1.f);
|
|
|
|
_setHideAnim(m_cheatBtnBack, "CHEAT/BACK_BTN", 0, 0, 1.f, -1.f);
|
2013-11-04 20:46:23 +01:00
|
|
|
_setHideAnim(m_cheatBtnDownload, "CHEAT/DOWNLOAD_BTN", -50, 0, 1.f, 0.f);
|
2012-02-10 19:45:42 +01:00
|
|
|
_setHideAnim(m_cheatLblPage, "CHEAT/PAGE_BTN", 0, 0, 1.f, -1.f);
|
|
|
|
_setHideAnim(m_cheatBtnPageM, "CHEAT/PAGE_MINUS", 0, 0, 1.f, -1.f);
|
|
|
|
_setHideAnim(m_cheatBtnPageP, "CHEAT/PAGE_PLUS", 0, 0, 1.f, -1.f);
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2023-03-20 20:05:21 +01:00
|
|
|
for (u8 i = 0;i < CHEATSPERPAGE; ++i)
|
|
|
|
{
|
2013-11-04 20:46:23 +01:00
|
|
|
_setHideAnim(m_cheatLblItem[i], fmt("CHEAT/ITEM_%i", i), 50, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_cheatBtnItem[i], fmt("CHEAT/ITEM_%i_BTN", i), -50, 0, 1.f, 0.f);
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_hideCheatSettings();
|
|
|
|
_textCheatSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_textCheatSettings(void)
|
|
|
|
{
|
|
|
|
m_btnMgr.setText(m_cheatBtnBack, _t("cheat1", L"Back"));
|
|
|
|
m_btnMgr.setText(m_cheatBtnApply, _t("cheat2", L"Apply"));
|
|
|
|
m_btnMgr.setText(m_cheatBtnDownload, _t("cfg4", L"Download"));
|
|
|
|
}
|
2022-08-25 00:26:36 +02:00
|
|
|
|
|
|
|
int CMenu::_downloadCheatFileAsync()
|
|
|
|
{
|
|
|
|
m_thrdTotal = 2;// download and save
|
|
|
|
|
|
|
|
m_thrdMessage = _t("dlmsg1", L"Initializing network...");
|
|
|
|
m_thrdMessageAdded = true;
|
|
|
|
if(_initNetwork() < 0)
|
|
|
|
{
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
m_thrdMessage = _t("dlmsg11", L"Downloading...");
|
|
|
|
m_thrdMessageAdded = true;
|
|
|
|
|
|
|
|
const char *id = CoverFlow.getId();
|
|
|
|
struct download file = {};
|
|
|
|
downloadfile(fmt(m_cfg.getString("general", "cheats_url", GECKOURL).c_str(), id), &file);
|
|
|
|
if(file.size > 0 && file.data[0] != '<')
|
|
|
|
{
|
|
|
|
m_thrdMessage = _t("dlmsg13", L"Saving...");
|
|
|
|
m_thrdMessageAdded = true;
|
|
|
|
update_pThread(1);// its downloaded
|
|
|
|
fsop_WriteFile(fmt("%s/%s.txt", m_txtCheatDir.c_str(), id), file.data, file.size);
|
|
|
|
MEM2_free(file.data);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if(file.size > 0)// received a 301/302 redirect instead of a 404?
|
|
|
|
{
|
|
|
|
MEM2_free(file.data);
|
|
|
|
return -4;// the file doesn't exist on the server
|
|
|
|
}
|
|
|
|
return -3;// download failed
|
|
|
|
}
|