2012-01-21 21:57:41 +01:00
|
|
|
#include "menu.hpp"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <gccore.h>
|
|
|
|
|
2012-04-08 16:48:50 +02:00
|
|
|
u8 m_categories[21];
|
2012-03-26 16:29:57 +02:00
|
|
|
u32 C_curPage;
|
|
|
|
bool gameSet;
|
2012-04-08 16:48:50 +02:00
|
|
|
u8 lastBtn;
|
2012-03-26 16:29:57 +02:00
|
|
|
|
|
|
|
void CMenu::_hideCategorySettings(bool instant)
|
|
|
|
{
|
|
|
|
m_btnMgr.hide(m_categoryLblTitle, instant);
|
|
|
|
m_btnMgr.hide(m_categoryBtnBack, instant);
|
|
|
|
m_btnMgr.hide(m_categoryLblPage, instant);
|
|
|
|
m_btnMgr.hide(m_categoryBtnPageM, instant);
|
|
|
|
m_btnMgr.hide(m_categoryBtnPageP, instant);
|
|
|
|
for (u32 i = 0; i < ARRAY_SIZE(m_categoryLblUser); ++i)
|
|
|
|
if (m_categoryLblUser[i] != -1u) m_btnMgr.hide(m_categoryLblUser[i], instant);
|
|
|
|
|
2012-04-08 16:48:50 +02:00
|
|
|
for (int i=0; i<21; ++i)
|
2012-03-26 16:29:57 +02:00
|
|
|
{
|
|
|
|
m_btnMgr.hide(m_categoryLblCat[i]);
|
2012-04-08 16:48:50 +02:00
|
|
|
m_btnMgr.hide(m_categoryBtn[i]);
|
2012-03-26 16:29:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_showCategorySettings(void)
|
|
|
|
{
|
|
|
|
_setBg(m_categoryBg, m_categoryBg);
|
2012-04-08 16:48:50 +02:00
|
|
|
for (u32 i = 0; i < ARRAY_SIZE(m_categoryLblUser); ++i) if (m_categoryLblUser[i] != -1u) m_btnMgr.show(m_categoryLblUser[i]);
|
2012-03-26 16:29:57 +02:00
|
|
|
m_btnMgr.show(m_categoryLblTitle);
|
|
|
|
m_btnMgr.show(m_categoryBtnBack);
|
2012-04-30 14:38:35 +02:00
|
|
|
_updateCheckboxes();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_updateCheckboxes(void)
|
|
|
|
{
|
2012-04-08 16:48:50 +02:00
|
|
|
if (m_max_categories > 10)
|
|
|
|
{
|
|
|
|
m_btnMgr.setText(m_categoryLblPage, wfmt(L"%i / 2", C_curPage));
|
|
|
|
m_btnMgr.show(m_categoryLblPage);
|
|
|
|
m_btnMgr.show(m_categoryBtnPageM);
|
|
|
|
m_btnMgr.show(m_categoryBtnPageP);
|
|
|
|
}
|
|
|
|
for (int i=0; i<21; ++i)
|
|
|
|
{
|
|
|
|
m_btnMgr.hide(m_categoryBtn[i]);
|
|
|
|
m_btnMgr.hide(m_categoryLblCat[i]);
|
|
|
|
}
|
2012-03-26 16:29:57 +02:00
|
|
|
string id(m_cf.getId());
|
|
|
|
const char *catflags;
|
|
|
|
if (gameSet) catflags = m_cat.getString("CATEGORIES", id, "").c_str();
|
2012-04-08 16:48:50 +02:00
|
|
|
else catflags = m_cat.getString(_domainFromView(), "categories", "100000000000000000000").c_str();
|
2012-03-26 16:29:57 +02:00
|
|
|
memset(&m_categories, '0', sizeof(m_categories));
|
|
|
|
if (strlen(catflags) == sizeof(m_categories)) memcpy(&m_categories, catflags, sizeof(m_categories));
|
|
|
|
|
|
|
|
if (C_curPage == 1)
|
|
|
|
{
|
2012-04-08 16:48:50 +02:00
|
|
|
int j = 11;
|
|
|
|
if (m_max_categories < 11) j = m_max_categories;
|
|
|
|
for (int i = 0; i < j; ++i)
|
2012-03-26 16:29:57 +02:00
|
|
|
{
|
|
|
|
if (i == 0 && gameSet) continue;
|
|
|
|
m_btnMgr.show(m_categoryLblCat[i]);
|
2012-04-08 16:48:50 +02:00
|
|
|
if (catflags[i] == '1') m_categoryBtn[i] = m_categoryBtnCats[i];
|
|
|
|
else m_categoryBtn[i] = m_categoryBtnCat[i];
|
|
|
|
m_btnMgr.show(m_categoryBtn[i]);
|
2012-03-26 16:29:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-04-08 16:48:50 +02:00
|
|
|
for (int i = 11; i < m_max_categories; ++i)
|
2012-03-26 16:29:57 +02:00
|
|
|
{
|
|
|
|
m_btnMgr.show(m_categoryLblCat[i]);
|
2012-04-08 16:48:50 +02:00
|
|
|
if (catflags[i] == '1') m_categoryBtn[i] = m_categoryBtnCats[i];
|
|
|
|
else m_categoryBtn[i] = m_categoryBtnCat[i];
|
|
|
|
m_btnMgr.show(m_categoryBtn[i]);
|
2012-03-26 16:29:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_CategorySettings(bool fromGameSet)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-04-30 14:38:35 +02:00
|
|
|
if (m_current_view == COVERFLOW_EMU) return;
|
2012-01-21 21:57:41 +01:00
|
|
|
SetupInput();
|
2012-03-26 16:29:57 +02:00
|
|
|
C_curPage = 1;
|
2012-04-08 16:48:50 +02:00
|
|
|
gameSet = fromGameSet;
|
2012-01-21 21:57:41 +01:00
|
|
|
_showCategorySettings();
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
_mainLoopCommon();
|
2012-04-08 16:48:50 +02:00
|
|
|
if (!m_btnMgr.selected(lastBtn)) m_btnMgr.noHover(false);
|
2012-01-21 21:57:41 +01:00
|
|
|
if (BTN_HOME_PRESSED || BTN_B_PRESSED)
|
|
|
|
break;
|
|
|
|
else if (BTN_UP_PRESSED)
|
|
|
|
m_btnMgr.up();
|
|
|
|
else if (BTN_DOWN_PRESSED)
|
|
|
|
m_btnMgr.down();
|
2012-04-08 16:48:50 +02:00
|
|
|
if (((BTN_MINUS_PRESSED || BTN_LEFT_PRESSED) && m_max_categories>11) || (BTN_A_PRESSED && m_btnMgr.selected(m_categoryBtnPageM)))
|
2012-03-26 16:29:57 +02:00
|
|
|
{
|
2012-04-08 16:48:50 +02:00
|
|
|
lastBtn = m_categoryBtnPageM;
|
|
|
|
m_btnMgr.noHover(true);
|
2012-03-26 16:29:57 +02:00
|
|
|
C_curPage = C_curPage == 1 ? 2 : 1;
|
2012-04-08 16:48:50 +02:00
|
|
|
if (BTN_LEFT_PRESSED || BTN_MINUS_PRESSED) m_btnMgr.click(m_categoryBtnPageM);
|
|
|
|
_updateCheckboxes();
|
2012-03-26 16:29:57 +02:00
|
|
|
}
|
2012-04-08 16:48:50 +02:00
|
|
|
else if (((BTN_PLUS_PRESSED || BTN_RIGHT_PRESSED) && m_max_categories>11) || (BTN_A_PRESSED && m_btnMgr.selected(m_categoryBtnPageP)))
|
2012-03-26 16:29:57 +02:00
|
|
|
{
|
2012-04-08 16:48:50 +02:00
|
|
|
lastBtn = m_categoryBtnPageP;
|
|
|
|
m_btnMgr.noHover(true);
|
2012-03-26 16:29:57 +02:00
|
|
|
C_curPage = C_curPage == 1 ? 2 : 1;
|
|
|
|
if(BTN_RIGHT_PRESSED || BTN_PLUS_PRESSED) m_btnMgr.click(m_categoryBtnPageP);
|
2012-04-08 16:48:50 +02:00
|
|
|
_updateCheckboxes();
|
2012-03-26 16:29:57 +02:00
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
if (BTN_A_PRESSED)
|
|
|
|
{
|
2012-02-12 02:43:31 +01:00
|
|
|
if (m_btnMgr.selected(m_categoryBtnBack))
|
|
|
|
break;
|
2012-04-08 16:48:50 +02:00
|
|
|
for (int i = 0; i < 21; ++i)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-04-08 16:48:50 +02:00
|
|
|
if (m_btnMgr.selected(m_categoryBtn[i]))
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-04-08 16:48:50 +02:00
|
|
|
lastBtn = m_categoryBtn[i];
|
|
|
|
m_btnMgr.noHover(true);
|
2012-03-26 16:29:57 +02:00
|
|
|
m_categories[i] = m_categories[i] == '1' ? '0' : '1';
|
2012-04-08 16:48:50 +02:00
|
|
|
if (i == 0 && m_categories[i] == '1') for (int j=1; j<21; ++j) m_categories[j] = '0';
|
2012-03-26 16:29:57 +02:00
|
|
|
else m_categories[0] = '0';
|
2012-04-08 16:48:50 +02:00
|
|
|
char catflags[22];
|
2012-03-26 16:29:57 +02:00
|
|
|
memset(&catflags, 0, sizeof(catflags));
|
|
|
|
memcpy(&catflags, &m_categories, sizeof(m_categories));
|
|
|
|
string id(m_cf.getId());
|
2012-04-08 16:48:50 +02:00
|
|
|
if (string (catflags) == "000000000000000000000") catflags[0] = '1';
|
2012-03-26 16:29:57 +02:00
|
|
|
if (gameSet) m_cat.setString("CATEGORIES", id, catflags);
|
2012-04-08 16:48:50 +02:00
|
|
|
else m_cat.setString(_domainFromView(), "categories", catflags);
|
|
|
|
_updateCheckboxes();
|
2012-01-21 21:57:41 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_hideCategorySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_initCategorySettingsMenu(CMenu::SThemeData &theme)
|
|
|
|
{
|
|
|
|
_addUserLabels(theme, m_categoryLblUser, ARRAY_SIZE(m_categoryLblUser), "CATEGORY");
|
|
|
|
m_categoryBg = _texture(theme.texSet, "CATEGORY/BG", "texture", theme.bg);
|
2012-03-26 16:29:57 +02:00
|
|
|
m_categoryLblTitle = _addTitle(theme, "CATEGORY/TITLE", theme.titleFont, L"", 20, 30, 600, 60, theme.titleFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_categoryBtnBack = _addButton(theme, "CATEGORY/BACK_BTN", theme.btnFont, L"", 420, 400, 200, 56, theme.btnFontColor);
|
2012-04-08 16:48:50 +02:00
|
|
|
m_categoryLblPage = _addLabel(theme, "CATEGORY/PAGE_BTN", theme.btnFont, L"", 256, 400, 100, 56, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC);
|
|
|
|
m_categoryBtnPageM = _addPicButton(theme, "CATEGORY/PAGE_MINUS", theme.btnTexMinus, theme.btnTexMinusS, 200, 400, 56, 56);
|
|
|
|
m_categoryBtnPageP = _addPicButton(theme, "CATEGORY/PAGE_PLUS", theme.btnTexPlus, theme.btnTexPlusS, 356, 400, 56, 56);
|
|
|
|
m_categoryLblCat[0] = _addLabel(theme, "CATEGORY/CAT_0", theme.lblFont, L"", 85, 390, 100, 48, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_categoryBtnCat[0] = _addPicButton(theme, "CATEGORY/CAT_0_BTN", theme.checkboxoff, theme.checkboxoffs, 30, 390, 44, 48);
|
|
|
|
m_categoryBtnCats[0] = _addPicButton(theme, "CATEGORY/CAT_0_BTNS", theme.checkboxon, theme.checkboxons, 30, 390, 44, 48);
|
2012-04-09 15:07:01 +02:00
|
|
|
for (int i = 1; i < 6; ++i)
|
2012-04-08 16:48:50 +02:00
|
|
|
{ // Page 1
|
2012-04-09 15:07:01 +02:00
|
|
|
m_categoryLblCat[i] = _addLabel(theme, sfmt("CATEGORY/CAT_%i", i).c_str(), theme.lblFont, L"", 85, (42+i*58), 230, 48, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_categoryBtnCat[i] = _addPicButton(theme, sfmt("CATEGORY/CAT_%i_BTN", i).c_str(), theme.checkboxoff, theme.checkboxoffs, 30, (42+i*58), 44, 48);
|
|
|
|
m_categoryBtnCats[i] = _addPicButton(theme, sfmt("CATEGORY/CAT_%i_BTNS", i).c_str(), theme.checkboxon, theme.checkboxons, 30, (42+i*58), 44, 48);
|
2012-04-08 16:48:50 +02:00
|
|
|
// right half
|
2012-04-09 15:07:01 +02:00
|
|
|
m_categoryLblCat[i+5] = _addLabel(theme, sfmt("CATEGORY/CAT_%i", i+5).c_str(), theme.txtFont, L"", 380, (42+i*58), 230, 48, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_categoryBtnCat[i+5] = _addPicButton(theme, sfmt("CATEGORY/CAT_%i_BTN", i+5).c_str(), theme.checkboxoff, theme.checkboxoffs, 325, (42+i*58), 44, 48);
|
|
|
|
m_categoryBtnCats[i+5] = _addPicButton(theme, sfmt("CATEGORY/CAT_%i_BTNS", i+5).c_str(), theme.checkboxon, theme.checkboxons, 325, (42+i*58), 44, 48);
|
2012-04-08 16:48:50 +02:00
|
|
|
// Page 2
|
2012-04-09 15:07:01 +02:00
|
|
|
m_categoryLblCat[i+10] = _addLabel(theme, sfmt("CATEGORY/CAT_%i", i+10).c_str(), theme.lblFont, L"", 85, (42+i*58), 230, 48, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_categoryBtnCat[i+10] = _addPicButton(theme, sfmt("CATEGORY/CAT_%i_BTN", i+10).c_str(), theme.checkboxoff, theme.checkboxoffs, 30, (42+i*58), 44, 48);
|
|
|
|
m_categoryBtnCats[i+10] = _addPicButton(theme, sfmt("CATEGORY/CAT_%i_BTNS", i+10).c_str(), theme.checkboxon, theme.checkboxons, 30, (42+i*58), 44, 48);
|
2012-04-08 16:48:50 +02:00
|
|
|
// right half
|
2012-04-09 15:07:01 +02:00
|
|
|
m_categoryLblCat[i+15] = _addLabel(theme, sfmt("CATEGORY/CAT_%i", i+15).c_str(), theme.txtFont, L"", 380, (42+i*58), 230, 48, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_categoryBtnCat[i+15] = _addPicButton(theme, sfmt("CATEGORY/CAT_%i_BTN", i+15).c_str(), theme.checkboxoff, theme.checkboxoffs, 325, (42+i*58), 44, 48);
|
|
|
|
m_categoryBtnCats[i+15] = _addPicButton(theme, sfmt("CATEGORY/CAT_%i_BTNS", i+15).c_str(), theme.checkboxon, theme.checkboxons, 325, (42+i*58), 44, 48);
|
2012-03-26 16:29:57 +02:00
|
|
|
}
|
|
|
|
_setHideAnim(m_categoryLblTitle, "CATEGORY/TITLE", 0, -200, 0.f, 1.f);
|
|
|
|
_setHideAnim(m_categoryLblPage, "CATEGORY/PAGE_BTN", 0, 200, 1.f, 0.f);
|
|
|
|
_setHideAnim(m_categoryBtnPageM, "CATEGORY/PAGE_MINUS", 0, 200, 1.f, 0.f);
|
|
|
|
_setHideAnim(m_categoryBtnPageP, "CATEGORY/PAGE_PLUS", 0, 200, 1.f, 0.f);
|
|
|
|
_setHideAnim(m_categoryBtnBack, "CATEGORY/BACK_BTN", 0, 200, 1.f, 0.f);
|
2012-04-08 16:48:50 +02:00
|
|
|
for (int i = 0; i < 21; ++i) {
|
2012-03-26 16:29:57 +02:00
|
|
|
_setHideAnim(m_categoryBtnCat[i], sfmt("CATEGORY/CAT_%i_BTN", i).c_str(), 0, 0, 1.f, 0.f);
|
|
|
|
_setHideAnim(m_categoryBtnCats[i], sfmt("CATEGORY/CAT_%i_BTNS", i).c_str(), 0, 0, 1.f, 0.f);
|
|
|
|
_setHideAnim(m_categoryLblCat[i], sfmt("CATEGORY/CAT_%i", i).c_str(), 0, 0, 1.f, 0.f);
|
2012-04-08 16:48:50 +02:00
|
|
|
m_categoryBtn[i] = m_categoryBtnCat[i];
|
2012-03-26 16:29:57 +02:00
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
_hideCategorySettings(true);
|
|
|
|
_textCategorySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_textCategorySettings(void)
|
|
|
|
{
|
2012-04-08 16:48:50 +02:00
|
|
|
m_btnMgr.setText(m_categoryLblTitle, _t("", L"Select Categories"));
|
2012-02-12 02:43:31 +01:00
|
|
|
m_btnMgr.setText(m_categoryBtnBack, _t("cd1", L"Back"));
|
2012-04-08 16:48:50 +02:00
|
|
|
for (int i=0; i<21; ++i)
|
2012-03-26 16:29:57 +02:00
|
|
|
{
|
|
|
|
if (i == 0) m_btnMgr.setText(m_categoryLblCat[i], _t("dl3", L"All"));
|
|
|
|
else m_btnMgr.setText(m_categoryLblCat[i], m_cat.getWString("GENERAL", fmt("cat%d",i), wfmt(L"Category %i",i).c_str()));
|
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|