2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
#include "menu.hpp"
|
|
|
|
|
|
|
|
void CMenu::_hideCode(bool instant)
|
|
|
|
{
|
2012-07-05 15:15:23 +02:00
|
|
|
for(u8 i = 0; i < 10; ++i)
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.hide(m_codeBtnKey[i], instant);
|
|
|
|
m_btnMgr.hide(m_codeBtnBack, instant);
|
|
|
|
m_btnMgr.hide(m_codeBtnErase, instant);
|
|
|
|
m_btnMgr.hide(m_codeLblTitle, instant);
|
2012-07-05 15:15:23 +02:00
|
|
|
for(u8 i = 0; i < ARRAY_SIZE(m_codeLblUser); ++i)
|
2012-09-13 16:54:17 +02:00
|
|
|
if(m_codeLblUser[i] != -1)
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.hide(m_codeLblUser[i], instant);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_showCode(void)
|
|
|
|
{
|
|
|
|
_setBg(m_codeBg, m_codeBg);
|
2012-07-05 15:15:23 +02:00
|
|
|
for(u8 i = 0; i < 10; ++i)
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.show(m_codeBtnKey[i]);
|
|
|
|
m_btnMgr.show(m_codeBtnBack);
|
|
|
|
m_btnMgr.show(m_codeLblTitle);
|
2012-07-05 15:15:23 +02:00
|
|
|
for(u8 i = 0; i < ARRAY_SIZE(m_codeLblUser); ++i)
|
2012-09-13 16:54:17 +02:00
|
|
|
if(m_codeLblUser[i] != -1)
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.show(m_codeLblUser[i]);
|
|
|
|
}
|
|
|
|
|
2012-05-14 07:37:10 +02:00
|
|
|
|
2016-04-02 18:47:18 +02:00
|
|
|
bool CMenu::_code(char code[4], bool erase)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
u32 n = 0;
|
|
|
|
wchar_t codeLbl[] = L"_ _ _ _";
|
|
|
|
|
|
|
|
SetupInput();
|
2016-04-02 18:47:18 +02:00
|
|
|
memset(code, 0, 4);
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.setText(m_codeLblTitle, codeLbl);
|
|
|
|
_showCode();
|
2018-05-08 15:49:43 +02:00
|
|
|
if(erase)// only for setting code and erase btn clears the code so you no longer need to unlock wiiflow
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.show(m_codeBtnErase);
|
2016-04-02 18:47:18 +02:00
|
|
|
|
2012-09-09 20:35:15 +02:00
|
|
|
while(!m_exit)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
_mainLoopCommon();
|
2016-04-02 18:47:18 +02:00
|
|
|
if(BTN_HOME_PRESSED)
|
|
|
|
break;
|
|
|
|
else if(WPadIR_ANY())
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2016-04-02 18:47:18 +02:00
|
|
|
if(BTN_B_PRESSED)
|
|
|
|
break;
|
|
|
|
else if(BTN_UP_PRESSED)
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.up();
|
2016-04-02 18:47:18 +02:00
|
|
|
else if(BTN_DOWN_PRESSED)
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.down();
|
2016-04-02 18:47:18 +02:00
|
|
|
if(BTN_A_PRESSED)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2016-04-02 18:47:18 +02:00
|
|
|
if(!m_locked && m_btnMgr.selected(m_codeBtnErase))
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2016-04-02 18:47:18 +02:00
|
|
|
memset(code, 0, 4);
|
|
|
|
m_cfg.remove("GENERAL", "parent_code");
|
|
|
|
n = 0;
|
|
|
|
m_locked = false;
|
|
|
|
break;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2016-04-02 18:47:18 +02:00
|
|
|
if(m_btnMgr.selected(m_codeBtnBack))
|
|
|
|
break;
|
2012-01-21 21:57:41 +01:00
|
|
|
else
|
2016-04-02 18:47:18 +02:00
|
|
|
for(int i = 0; i < 10; ++i)
|
|
|
|
if(m_btnMgr.selected(m_codeBtnKey[i]))
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2016-04-02 18:47:18 +02:00
|
|
|
codeLbl[n * 2] = 'X';
|
|
|
|
code[n++] = '0' + i;
|
|
|
|
m_btnMgr.setText(m_codeLblTitle, codeLbl);
|
2012-01-21 21:57:41 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-04-02 18:47:18 +02:00
|
|
|
else
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
// Map buttons to numbers
|
2016-04-02 18:47:18 +02:00
|
|
|
int c = -1;
|
|
|
|
if(BTN_UP_PRESSED) c = 0;
|
|
|
|
else if(BTN_LEFT_PRESSED) c = 1;
|
|
|
|
else if(BTN_RIGHT_PRESSED) c = 2;
|
|
|
|
else if(BTN_DOWN_PRESSED) c = 3;
|
|
|
|
else if(BTN_MINUS_PRESSED) c = 4;
|
|
|
|
else if(BTN_PLUS_PRESSED) c = 5;
|
|
|
|
else if(BTN_A_PRESSED) c = 6;
|
|
|
|
else if(BTN_B_PRESSED) c = 7;
|
|
|
|
else if(BTN_1_PRESSED) c = 8;
|
|
|
|
else if(BTN_2_PRESSED) c = 9;
|
2012-05-14 07:37:10 +02:00
|
|
|
|
2016-04-02 18:47:18 +02:00
|
|
|
if(c != -1)
|
2012-05-14 07:37:10 +02:00
|
|
|
{
|
2016-04-02 18:47:18 +02:00
|
|
|
codeLbl[n * 2] = 'X';
|
|
|
|
code[n++] = '0' + c;
|
|
|
|
m_btnMgr.setText(m_codeLblTitle, codeLbl);
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_hideCode();
|
2018-05-08 15:49:43 +02:00
|
|
|
return n == 4;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|
2012-11-03 20:16:03 +01:00
|
|
|
void CMenu::_initCodeMenu()
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-11-03 20:16:03 +01:00
|
|
|
_addUserLabels(m_codeLblUser, ARRAY_SIZE(m_codeLblUser), "CODE");
|
|
|
|
m_codeBg = _texture("CODE/BG", "texture", theme.bg, false);
|
2013-11-04 20:46:23 +01:00
|
|
|
m_codeLblTitle = _addLabel("CODE/CODE", theme.titleFont, L"_ _ _ _", 0, 10, 640, 60, theme.titleFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_codeBtnKey[0] = _addButton("CODE/0_BTN", theme.btnFont, L"0", 270, 320, 100, 50, theme.btnFontColor);
|
|
|
|
m_codeBtnErase = _addButton("CODE/ERASE_BTN", theme.btnFont, L"", 20, 400, 200, 48, theme.btnFontColor);
|
|
|
|
m_codeBtnBack = _addButton("CODE/BACK_BTN", theme.btnFont, L"", 420, 400, 200, 48, theme.btnFontColor);
|
2012-05-14 07:37:10 +02:00
|
|
|
|
2016-04-02 18:47:18 +02:00
|
|
|
for(int i = 0; i < 10; ++i)
|
2012-05-14 07:37:10 +02:00
|
|
|
{
|
2013-09-24 17:21:31 +02:00
|
|
|
char *codeText = fmt_malloc("CODE/%i_BTN", i);
|
|
|
|
if(codeText == NULL) continue;
|
2016-04-02 18:47:18 +02:00
|
|
|
if(i > 0)
|
2012-05-14 07:37:10 +02:00
|
|
|
{
|
|
|
|
int x = i - 1;
|
|
|
|
int y = x / 3;
|
|
|
|
x %= 3;
|
|
|
|
x = 160 + x * 110;
|
2013-11-04 20:46:23 +01:00
|
|
|
y = 240 - y * 80;
|
2012-11-03 20:16:03 +01:00
|
|
|
m_codeBtnKey[i] = _addButton(codeText, theme.btnFont, wfmt(L"%i", i), x, y, 100, 50, theme.btnFontColor);
|
2012-05-14 07:37:10 +02:00
|
|
|
}
|
|
|
|
_setHideAnim(m_codeBtnKey[i], codeText, 0, 0, 0.f, 0.f);
|
2013-09-24 17:21:31 +02:00
|
|
|
MEM2_free(codeText);
|
2012-05-14 07:37:10 +02:00
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
_setHideAnim(m_codeBtnErase, "CODE/ERASE_BTN", 0, 0, -2.f, 0.f);
|
2013-11-04 20:46:23 +01:00
|
|
|
_setHideAnim(m_codeBtnBack, "CODE/BACK_BTN", 0, 0, 1.f, -1.f);
|
2012-05-14 07:37:10 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
_hideCode(true);
|
|
|
|
_textCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_textCode(void)
|
|
|
|
{
|
|
|
|
m_btnMgr.setText(m_codeBtnBack, _t("cd1", L"Back"));
|
|
|
|
m_btnMgr.setText(m_codeBtnErase, _t("cd2", L"Erase"));
|
2016-04-02 18:47:18 +02:00
|
|
|
m_btnMgr.setText(m_codeLblTitle, L"_ _ _ _");
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|