-now source menu only uses 12 buttons instead of 36. Just changes textures when changing pages. The source_menu.ini will still have up to 36 buttons.

-now source menu looks for images in current theme folder first, then source_menu folder.  All images must be named the same as what's in the source_menu.ini. If not found in either folder uses wiiflow's favorite star image.
-removed source menu exit button.
This commit is contained in:
fledge68 2012-08-06 13:48:57 +00:00
parent 2b06e90fb4
commit 1d6b882f0d
3 changed files with 79 additions and 38 deletions

View File

@ -505,6 +505,21 @@ void CButtonsMgr::setText(u16 id, const wstringEx &text, u32 startline,bool unwr
} }
} }
void CButtonsMgr::setBtnTexture(u16 id, STexture &texNormal, STexture &texSelected)
{
SButtonTextureSet texSet;
texSet.center = texNormal;
texSet.centerSel = texSelected;
if (id < m_elts.size())
{
CButtonsMgr::SButton *b;
b = (CButtonsMgr::SButton *)m_elts[id].get();
b->tex = texSet;//change texture
}
}
void CButtonsMgr::setTexture(u16 id, STexture &bg) void CButtonsMgr::setTexture(u16 id, STexture &bg)
{ {
if (id < m_elts.size()) if (id < m_elts.size())

View File

@ -40,6 +40,7 @@ public:
u16 addProgressBar(int x, int y, u32 width, u32 height, SButtonTextureSet &texSet); u16 addProgressBar(int x, int y, u32 width, u32 height, SButtonTextureSet &texSet);
void setText(u16 id, const wstringEx &text, bool unwrap = false); void setText(u16 id, const wstringEx &text, bool unwrap = false);
void setText(u16 id, const wstringEx &text, u32 startline, bool unwrap = false); void setText(u16 id, const wstringEx &text, u32 startline, bool unwrap = false);
void setBtnTexture(u16 id, STexture &texNormal, STexture &texSelected);
void setTexture(u16 id ,STexture &bg); void setTexture(u16 id ,STexture &bg);
void setTexture(u16 id, STexture &bg, int width, int height); void setTexture(u16 id, STexture &bg, int width, int height);
void setProgress(u16 id, float f, bool instant = false); void setProgress(u16 id, float f, bool instant = false);

View File

@ -14,6 +14,8 @@ extern const u8 btnemu_png[];
extern const u8 btnemus_png[]; extern const u8 btnemus_png[];
extern const u8 btnhomebrew_png[]; extern const u8 btnhomebrew_png[];
extern const u8 btnhomebrews_png[]; extern const u8 btnhomebrews_png[];
extern const u8 favoriteson_png[];
extern const u8 favoritesons_png[];
int Source_curPage; int Source_curPage;
int pages; int pages;
@ -26,9 +28,8 @@ u16 m_sourceLblNotice;
u16 m_sourceLblPage; u16 m_sourceLblPage;
u16 m_sourceBtnPageM; u16 m_sourceBtnPageM;
u16 m_sourceBtnPageP; u16 m_sourceBtnPageP;
u16 m_sourceBtnBack;
u16 m_sourceLblTitle; u16 m_sourceLblTitle;
u16 m_sourceBtnSource[36]; u16 m_sourceBtnSource[12];
u16 m_sourceLblUser[4]; u16 m_sourceLblUser[4];
STexture m_sourceBg; STexture m_sourceBg;
u16 m_sourceBtnDML; u16 m_sourceBtnDML;
@ -40,7 +41,6 @@ u16 m_sourceBtnHomebrew;
void CMenu::_hideSource(bool instant) void CMenu::_hideSource(bool instant)
{ {
m_btnMgr.hide(m_sourceLblTitle, instant); m_btnMgr.hide(m_sourceLblTitle, instant);
m_btnMgr.hide(m_sourceBtnBack, instant);
m_btnMgr.hide(m_sourceLblNotice, instant); m_btnMgr.hide(m_sourceLblNotice, instant);
m_btnMgr.hide(m_sourceLblPage, instant); m_btnMgr.hide(m_sourceLblPage, instant);
m_btnMgr.hide(m_sourceBtnPageM, instant); m_btnMgr.hide(m_sourceBtnPageM, instant);
@ -58,7 +58,7 @@ void CMenu::_hideSource(bool instant)
m_btnMgr.hide(m_sourceLblUser[i], instant); m_btnMgr.hide(m_sourceLblUser[i], instant);
} }
for(i = 0; i < 36; ++i) for(i = 0; i < 12; ++i)
m_btnMgr.hide(m_sourceBtnSource[i]); m_btnMgr.hide(m_sourceBtnSource[i]);
} }
@ -74,7 +74,6 @@ void CMenu::_showSource(void)
} }
m_btnMgr.show(m_sourceLblTitle); m_btnMgr.show(m_sourceLblTitle);
m_btnMgr.show(m_sourceBtnBack);
for(i = 12; i < 36; ++i) for(i = 12; i < 36; ++i)
{ {
@ -96,14 +95,37 @@ void CMenu::_updateSourceBtns(void)
m_btnMgr.show(m_sourceBtnPageM); m_btnMgr.show(m_sourceBtnPageM);
m_btnMgr.show(m_sourceBtnPageP); m_btnMgr.show(m_sourceBtnPageP);
} }
for (u8 i = 0; i < 36; ++i) for (u8 i = 0; i < 12; ++i)
m_btnMgr.hide(m_sourceBtnSource[i]); m_btnMgr.hide(m_sourceBtnSource[i], true);
string ImgName;
u8 j = (Source_curPage - 1) * 12; u8 j = (Source_curPage - 1) * 12;
for (u8 i = j; i < (j + 12); ++i) for (u8 i = 0; i < 12; ++i)
{ {
string source = m_source.getString(fmt("BUTTON_%i", i), "source", ""); STexture texConsoleImg;
STexture texConsoleImgs;
ImgName = m_source.getString(fmt("BUTTON_%i", i + j),"image", "");
if(!STexture::TE_OK == texConsoleImg.fromImageFile(fmt("%s/%s", m_themeDataDir.c_str(), ImgName.c_str()), GX_TF_RGBA8, ALLOC_MEM2))
{
if(!STexture::TE_OK == texConsoleImg.fromImageFile(fmt("%s/%s", m_sourceDir.c_str(), ImgName.c_str()), GX_TF_RGBA8, ALLOC_MEM2))
{
texConsoleImg.fromPNG(favoriteson_png);
}
}
ImgName = m_source.getString(fmt("BUTTON_%i", i + j),"image_s", "");
if(!STexture::TE_OK == texConsoleImgs.fromImageFile(fmt("%s/%s", m_themeDataDir.c_str(), ImgName.c_str()), GX_TF_RGBA8, ALLOC_MEM2))
{
if(!STexture::TE_OK == texConsoleImgs.fromImageFile(fmt("%s/%s", m_sourceDir.c_str(), ImgName.c_str()), GX_TF_RGBA8, ALLOC_MEM2))
{
texConsoleImgs.fromPNG(favoritesons_png);
}
}
m_btnMgr.setBtnTexture(m_sourceBtnSource[i], texConsoleImg, texConsoleImgs);
string source = m_source.getString(fmt("BUTTON_%i", i + j), "source", "");
if (!source.empty()) if (!source.empty())
m_btnMgr.show(m_sourceBtnSource[i]); m_btnMgr.show(m_sourceBtnSource[i]);
} }
@ -199,11 +221,6 @@ bool CMenu::_Source()
} }
if(BTN_A_PRESSED) if(BTN_A_PRESSED)
{ {
if(m_btnMgr.selected(m_sourceBtnBack))
{
back = true;
break;
}
if(m_btnMgr.selected(m_sourceBtnUsb)) if(m_btnMgr.selected(m_sourceBtnUsb))
{ {
m_current_view = COVERFLOW_USB; m_current_view = COVERFLOW_USB;
@ -245,11 +262,12 @@ bool CMenu::_Source()
break; break;
} }
} }
for(int i = 0; i < 36; ++i) u8 j = (Source_curPage - 1) * 12;
for(int i = 0; i < 12; ++i)
{ {
if(m_btnMgr.selected(m_sourceBtnSource[i])) if(m_btnMgr.selected(m_sourceBtnSource[i]))
{ {
string source = m_source.getString(fmt("BUTTON_%i", i), "source", ""); string source = m_source.getString(fmt("BUTTON_%i", i + j), "source", "");
if (source == "wii") if (source == "wii")
{ {
m_current_view = COVERFLOW_USB; m_current_view = COVERFLOW_USB;
@ -322,21 +340,21 @@ bool CMenu::_Source()
imgSelected = true; imgSelected = true;
u32 sourceMagic; u32 sourceMagic;
sscanf(m_source.getString(fmt("BUTTON_%i", i), "magic","").c_str(), "%08x", &sourceMagic); sscanf(m_source.getString(fmt("BUTTON_%i", i + j), "magic","").c_str(), "%08x", &sourceMagic);
for (u8 j = 0; j < numPlugins; ++j) for (u8 k = 0; k < numPlugins; ++k)
{ {
if (sourceMagic == m_plugin.getPluginMagic(j)) if (sourceMagic == m_plugin.getPluginMagic(k))
{ {
m_plugin.SetEnablePlugin(m_cfg, j, 2); m_plugin.SetEnablePlugin(m_cfg, k, 2);
} }
else else
{ {
m_plugin.SetEnablePlugin(m_cfg, j, 1); m_plugin.SetEnablePlugin(m_cfg, k, 1);
} }
} }
int layout = m_source.getInt(fmt("BUTTON_%i", i), "emuflow", 0); int layout = m_source.getInt(fmt("BUTTON_%i", i + j), "emuflow", 0);
if(layout != 0) if(layout != 0)
m_cfg.setInt("EMULATOR", "last_cf_mode", layout); m_cfg.setInt("EMULATOR", "last_cf_mode", layout);
break; break;
@ -390,7 +408,6 @@ void CMenu::_initSourceMenu(CMenu::SThemeData &theme)
_addUserLabels(theme, m_sourceLblUser, ARRAY_SIZE(m_sourceLblUser), "SOURCE"); _addUserLabels(theme, m_sourceLblUser, ARRAY_SIZE(m_sourceLblUser), "SOURCE");
m_sourceBg = _texture(theme.texSet, "SOURCE/BG", "texture", theme.bg); m_sourceBg = _texture(theme.texSet, "SOURCE/BG", "texture", theme.bg);
m_sourceLblTitle = _addTitle(theme, "SOURCE/TITLE", theme.titleFont, L"", 20, 20, 600, 60, theme.titleFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE); m_sourceLblTitle = _addTitle(theme, "SOURCE/TITLE", theme.titleFont, L"", 20, 20, 600, 60, theme.titleFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE);
m_sourceBtnBack = _addButton(theme, "SOURCE/BACK_BTN", theme.btnFont, L"", 424, 400, 210, 56, theme.btnFontColor);
m_sourceLblNotice = _addLabel(theme, "SOURCE/NOTICE", theme.btnFont, L"", 20, 400, 600, 56, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_TOP); m_sourceLblNotice = _addLabel(theme, "SOURCE/NOTICE", theme.btnFont, L"", 20, 400, 600, 56, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_TOP);
m_sourceLblPage = _addLabel(theme, "SOURCE/PAGE_BTN", theme.btnFont, L"", 62, 400, 98, 56, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC); m_sourceLblPage = _addLabel(theme, "SOURCE/PAGE_BTN", theme.btnFont, L"", 62, 400, 98, 56, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC);
m_sourceBtnPageM = _addPicButton(theme, "SOURCE/PAGE_MINUS", theme.btnTexMinus, theme.btnTexMinusS, 10, 400, 52, 56); m_sourceBtnPageM = _addPicButton(theme, "SOURCE/PAGE_MINUS", theme.btnTexMinus, theme.btnTexMinusS, 10, 400, 52, 56);
@ -400,27 +417,37 @@ void CMenu::_initSourceMenu(CMenu::SThemeData &theme)
if(!m_source.loaded()) if(!m_source.loaded())
m_source.load(fmt("%s/%s", m_sourceDir.c_str(), SOURCE_FILENAME)); m_source.load(fmt("%s/%s", m_sourceDir.c_str(), SOURCE_FILENAME));
int page;
int row; int row;
int col; int col;
string ImgName; string ImgName;
for ( int i = 0; i < 36; ++i) for ( int i = 0; i < 12; ++i)
{ {
STexture texConsoleImg; STexture texConsoleImg;
STexture texConsoleImgs; STexture texConsoleImgs;
ImgName = m_source.getString(fmt("BUTTON_%i", i),"image", "default.png"); ImgName = m_source.getString(fmt("BUTTON_%i", i),"image", "");
texConsoleImg.fromImageFile(fmt("%s/%s", m_sourceDir.c_str(), ImgName.c_str())); if(!STexture::TE_OK == texConsoleImg.fromImageFile(fmt("%s/%s", m_themeDataDir.c_str(), ImgName.c_str()), GX_TF_RGBA8, ALLOC_MEM2))
ImgName = m_source.getString(fmt("BUTTON_%i", i),"image_s", "default.png"); {
texConsoleImgs.fromImageFile(fmt("%s/%s", m_sourceDir.c_str(), ImgName.c_str())); if(!STexture::TE_OK == texConsoleImg.fromImageFile(fmt("%s/%s", m_sourceDir.c_str(), ImgName.c_str()), GX_TF_RGBA8, ALLOC_MEM2))
{
page = i / 12; texConsoleImg.fromPNG(favoriteson_png);
row = (i / 4 ) - (page * 3); }
col = (i - (page * 12)) - (row * 4); }
m_sourceBtnSource[i] = _addPicButton(theme, fmt("SOURCE/SOURCE_BTN_%i", i), texConsoleImg, texConsoleImgs, (30 + 150 * col), (90 + 100 * row), 120, 90); ImgName = m_source.getString(fmt("BUTTON_%i", i),"image_s", "");
if(!STexture::TE_OK == texConsoleImgs.fromImageFile(fmt("%s/%s", m_themeDataDir.c_str(), ImgName.c_str()), GX_TF_RGBA8, ALLOC_MEM2))
{
if(!STexture::TE_OK == texConsoleImgs.fromImageFile(fmt("%s/%s", m_sourceDir.c_str(), ImgName.c_str()), GX_TF_RGBA8, ALLOC_MEM2))
{
texConsoleImgs.fromPNG(favoritesons_png);
}
} }
row = i / 4;
col = i - (row * 4);
m_sourceBtnSource[i] = _addPicButton(theme, fmt("SOURCE/SOURCE_BTN_%i", i), texConsoleImg, texConsoleImgs, (30 + 150 * col), (90 + 100 * row), 120, 90);
}
_setHideAnim(m_sourceBtnChannel, "SOURCE/CHANNEL_BTN", 0, 40, 0.f, 0.f); _setHideAnim(m_sourceBtnChannel, "SOURCE/CHANNEL_BTN", 0, 40, 0.f, 0.f);
_setHideAnim(m_sourceBtnHomebrew, "SOURCE/HOMEBREW_BTN", 0, 40, 0.f, 0.f); _setHideAnim(m_sourceBtnHomebrew, "SOURCE/HOMEBREW_BTN", 0, 40, 0.f, 0.f);
_setHideAnim(m_sourceBtnUsb, "SOURCE/USB_BTN", 0, 40, 0.f, 0.f); _setHideAnim(m_sourceBtnUsb, "SOURCE/USB_BTN", 0, 40, 0.f, 0.f);
@ -431,9 +458,8 @@ void CMenu::_initSourceMenu(CMenu::SThemeData &theme)
_setHideAnim(m_sourceLblPage, "SOURCE/PAGE_BTN", 0, 200, 1.f, 0.f); _setHideAnim(m_sourceLblPage, "SOURCE/PAGE_BTN", 0, 200, 1.f, 0.f);
_setHideAnim(m_sourceBtnPageM, "SOURCE/PAGE_MINUS", 0, 200, 1.f, 0.f); _setHideAnim(m_sourceBtnPageM, "SOURCE/PAGE_MINUS", 0, 200, 1.f, 0.f);
_setHideAnim(m_sourceBtnPageP, "SOURCE/PAGE_PLUS", 0, 200, 1.f, 0.f); _setHideAnim(m_sourceBtnPageP, "SOURCE/PAGE_PLUS", 0, 200, 1.f, 0.f);
_setHideAnim(m_sourceBtnBack, "SOURCE/BACK_BTN", 0, 200, 1.f, 0.f);
for(int i = 0; i < 36; ++i) for(int i = 0; i < 12; ++i)
{ {
_setHideAnim(m_sourceBtnSource[i], fmt("SOURCE/SOURCE_BTN_%i", i), 0, 0, 1.f, 0.f); _setHideAnim(m_sourceBtnSource[i], fmt("SOURCE/SOURCE_BTN_%i", i), 0, 0, 1.f, 0.f);
} }
@ -444,6 +470,5 @@ void CMenu::_initSourceMenu(CMenu::SThemeData &theme)
void CMenu::_textSource(void) void CMenu::_textSource(void)
{ {
m_btnMgr.setText(m_sourceLblTitle, _t("stup1", L"Select Source")); m_btnMgr.setText(m_sourceLblTitle, _t("stup1", L"Select Source"));
m_btnMgr.setText(m_sourceBtnBack, _t("stup2", L"Exit"));
m_btnMgr.setText(m_sourceLblNotice, _t("NMMOff", L"** DISABLED **")); m_btnMgr.setText(m_sourceLblNotice, _t("NMMOff", L"** DISABLED **"));
} }