diff --git a/source/defines.h b/source/defines.h index fbf95e24..2a25978e 100644 --- a/source/defines.h +++ b/source/defines.h @@ -11,6 +11,7 @@ #define CFG_FILENAME "wiiflow.ini" #define LANG_FILENAME "languages.ini" #define CAT_FILENAME "categories.ini" +#define STARTUP_FILENAME "startup_menu.ini" #define TITLES_FILENAME "titles.ini" #define CTITLES_FILENAME "custom_titles.ini" #define AGE_LOCK_FILENAME "age_lock.ini" diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index b23fed42..a07ec5aa 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -346,10 +346,10 @@ void CMenu::init(void) // INI files m_cat.load(fmt("%s/" CAT_FILENAME, m_settingsDir.c_str())); + m_startup.load(fmt("%s/" STARTUP_FILENAME, m_settingsDir.c_str())); string themeName = m_cfg.getString("GENERAL", "theme", "DEFAULT"); m_themeDataDir = sfmt("%s/%s", m_themeDir.c_str(), themeName.c_str()); m_theme.load(fmt("%s.ini", m_themeDataDir.c_str())); - m_plugin.init(m_pluginsDir); u8 defaultMenuLanguage = 7; //English @@ -1231,14 +1231,17 @@ u16 CMenu::_textStyle(const char *domain, const char *key, u16 def) return textStyle; } -u32 CMenu::_addButton(CMenu::SThemeData &theme, const char *domain, SFont font, const wstringEx &text, int x, int y, u32 width, u32 height, const CColor &color) +u32 CMenu::_addButton(CMenu::SThemeData &theme, const char *domain, SFont font, const wstringEx &text, int x, int y, u32 width, u32 height, const CColor &color, bool skipTheme) { SButtonTextureSet btnTexSet; CColor c(color); c = m_theme.getColor(domain, "color", c); - x = m_theme.getInt(domain, "x", x); - y = m_theme.getInt(domain, "y", y); + if (!skipTheme) + { + x = m_theme.getInt(domain, "x", x); + y = m_theme.getInt(domain, "y", y); + } width = m_theme.getInt(domain, "width", width); height = m_theme.getInt(domain, "height", height); btnTexSet.left = _texture(theme.texSet, domain, "texture_left", theme.btnTexL); diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index 11cbadc5..0c0aea12 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -63,6 +63,7 @@ private: CachedList m_gameList; Config m_cfg; Config m_loc; + Config m_startup; Config m_cat; Config m_gcfg1; Config m_gcfg2; @@ -1034,7 +1035,7 @@ private: SmartGuiSound _sound(CMenu::SoundSet &soundSet, const char *domain, const char *key, const u8 * snd, u32 len, string name, bool isAllocated); SmartGuiSound _sound(CMenu::SoundSet &soundSet, const char *domain, const char *key, string name); u16 _textStyle(const char *domain, const char *key, u16 def); - u32 _addButton(SThemeData &theme, const char *domain, SFont font, const wstringEx &text, int x, int y, u32 width, u32 height, const CColor &color); + u32 _addButton(SThemeData &theme, const char *domain, SFont font, const wstringEx &text, int x, int y, u32 width, u32 height, const CColor &color, bool skipTheme = false); u32 _addSelButton(SThemeData &theme, const char *domain, SFont font, const wstringEx &text, int x, int y, u32 width, u32 height, const CColor &color); u32 _addPicButton(SThemeData &theme, const char *domain, STexture &texNormal, STexture &texSelected, int x, int y, u32 width, u32 height); u32 _addTitle(SThemeData &theme, const char *domain, SFont font, const wstringEx &text, int x, int y, u32 width, u32 height, const CColor &color, u16 style); diff --git a/source/menu/menu_startup.cpp b/source/menu/menu_startup.cpp index bb6701bd..1df8297c 100644 --- a/source/menu/menu_startup.cpp +++ b/source/menu/menu_startup.cpp @@ -3,7 +3,7 @@ #include #include -u32 Startup_curPage; +int Startup_curPage; u8 numPlugins; // Startup menu @@ -53,22 +53,22 @@ void CMenu::_showStartup(void) void CMenu::_updateStartupBtns(void) { - _textStartup(); - if (numPlugins > 4) + if (numPlugins > 6) { m_btnMgr.setText(m_startupLblPage, wfmt(L"%i / 2", Startup_curPage)); m_btnMgr.show(m_startupLblPage); m_btnMgr.show(m_startupBtnPageM); m_btnMgr.show(m_startupBtnPageP); } - - for (u8 i = 0; i < 10; ++i) - m_btnMgr.hide(m_startupBtnSource[i]); - - u8 j = 6 + min((int) numPlugins, 4); - if (Startup_curPage != 1) j = numPlugins - 4; - for (u8 i = 0; i < j; ++i) - m_btnMgr.show(m_startupBtnSource[i]); + for (int i = 0; i < 20; ++i) + m_btnMgr.hide(m_startupBtnSource[i]); + + for (int i = 0; i < (numPlugins + 4); ++i) + { + int page = m_startup.getInt("BUTTONS", fmt("button_%i_page", i), (i < 10 ? 1 : 2)); + if (page == Startup_curPage) + m_btnMgr.show(m_startupBtnSource[i]); + } } void CMenu::_showStartupNotice(void) @@ -79,17 +79,15 @@ void CMenu::_showStartupNotice(void) void CMenu::_Startup() { - //_loadEmuList(); - _showStartup(); DIR *pdir; struct dirent *pent; pdir = opendir(m_pluginsDir.c_str()); Config m_plugin_cfg; - + u8 i = 0; + while ((pent = readdir(pdir)) != NULL) { - // Skip it if (strcmp(pent->d_name, ".") == 0 || strcmp(pent->d_name, "..") == 0 || strcasecmp(pent->d_name, "plugins.ini") == 0 || strcasecmp(pent->d_name, "scummvm.ini") == 0) continue; @@ -98,6 +96,7 @@ void CMenu::_Startup() m_plugin_cfg.load(fmt("%s/%s", m_pluginsDir.c_str(), pent->d_name)); if (m_plugin_cfg.loaded()) { + i++; m_plugin.AddPlugin(m_plugin_cfg); } m_plugin_cfg.unload(); @@ -105,17 +104,8 @@ void CMenu::_Startup() } closedir(pdir); m_plugin.EndAdd(); - u8 i = 0; - while(true) - { - if (m_plugin.PluginExist(i)) - i++; - else - { - numPlugins = i; - break; - } - } + numPlugins = i; + SetupInput(); bool show_homebrew = !m_cfg.getBool("HOMEBREW", "disable", false); bool show_channel = !m_cfg.getBool("GENERAL", "hidechannel", false); @@ -124,24 +114,37 @@ void CMenu::_Startup() bool pluginSelected = false; m_showtimer = 0; Startup_curPage = 1; + _textStartup(); + _showStartup(); _updateStartupBtns(); + while(true) { _mainLoopCommon(); + if (BTN_B_PRESSED && m_btnMgr.selected(m_startupBtnSource[1])) + { + if (!show_channel) _showStartupNotice(); + else + { + m_current_view = COVERFLOW_CHANNEL; + m_cfg.setBool("NAND", "disable", true); + break; + } + } if (BTN_HOME_PRESSED || BTN_B_PRESSED) break; else if(BTN_UP_PRESSED) m_btnMgr.up(); else if(BTN_DOWN_PRESSED) m_btnMgr.down(); - if(((BTN_MINUS_PRESSED || BTN_LEFT_PRESSED) && (numPlugins + 6) > 11) || (BTN_A_PRESSED && m_btnMgr.selected(m_startupBtnPageM))) + if(((BTN_MINUS_PRESSED || BTN_LEFT_PRESSED) && (numPlugins + 4) > 10) || (BTN_A_PRESSED && m_btnMgr.selected(m_startupBtnPageM))) { Startup_curPage = Startup_curPage == 1 ? 2 : 1; if(BTN_LEFT_PRESSED || BTN_MINUS_PRESSED) m_btnMgr.click(m_startupBtnPageM); _updateStartupBtns(); } - else if(((BTN_PLUS_PRESSED || BTN_RIGHT_PRESSED) && (numPlugins + 6) > 11) || (BTN_A_PRESSED && m_btnMgr.selected(m_startupBtnPageP))) + else if(((BTN_PLUS_PRESSED || BTN_RIGHT_PRESSED) && (numPlugins + 4) > 10) || (BTN_A_PRESSED && m_btnMgr.selected(m_startupBtnPageP))) { Startup_curPage = Startup_curPage == 1 ? 2 : 1; if (BTN_RIGHT_PRESSED || BTN_PLUS_PRESSED) @@ -152,95 +155,57 @@ void CMenu::_Startup() { if (m_btnMgr.selected(m_startupBtnBack)) break; - if (Startup_curPage == 1) + if (m_btnMgr.selected(m_startupBtnSource[0])) { - if (m_btnMgr.selected(m_startupBtnSource[0])) + m_current_view = COVERFLOW_USB; + break; + } + if (m_btnMgr.selected(m_startupBtnSource[2])) + { + if (!m_show_dml) _showStartupNotice(); + else { - m_current_view = COVERFLOW_USB; + m_current_view = COVERFLOW_DML; break; } - if (m_btnMgr.selected(m_startupBtnSource[2])) + } + if (m_btnMgr.selected(m_startupBtnSource[1])) + { + if (!show_channel) _showStartupNotice(); + else { - if (!m_show_dml) _showStartupNotice(); - else - { - m_current_view = COVERFLOW_DML; - break; - } - } - if (m_btnMgr.selected(m_startupBtnSource[5])) - { - if (!show_emu) _showStartupNotice(); - else - { - m_current_view = COVERFLOW_EMU; - for (u8 j = 0; j < numPlugins; ++j) - m_plugin.SetEnablePlugin(m_cfg, j, 2); - break; - } - } - if (m_btnMgr.selected(m_startupBtnSource[1])) - { - if (!show_channel) _showStartupNotice(); - else - { - m_current_view = COVERFLOW_CHANNEL; - m_cfg.setBool("NAND", "disable", true); - break; - } - } - if (m_btnMgr.selected(m_startupBtnSource[3])) - { - if (!show_channel) _showStartupNotice(); - else - { - m_current_view = COVERFLOW_CHANNEL; - m_cfg.setBool("NAND", "disable", false); - break; - } - } - if (m_btnMgr.selected(m_startupBtnSource[4])) - { - if (!show_homebrew || (!parental_homebrew && m_locked)) _showStartupNotice(); - else - { - m_current_view = COVERFLOW_HOMEBREW; - break; - } - } - for (u8 i = 6; i < (6 + min((int) numPlugins, 4)); ++i) - { - if (m_btnMgr.selected(m_startupBtnSource[i])) - { - if (!show_emu) _showStartupNotice(); - else - { - m_current_view = COVERFLOW_EMU; - pluginSelected = true; - for (u8 j = 0; j < numPlugins; ++j) - m_plugin.SetEnablePlugin(m_cfg, j, 1); - m_plugin.SetEnablePlugin(m_cfg, i - 6, 2); - break; - } - } + m_current_view = COVERFLOW_CHANNEL; + m_cfg.setBool("NAND", "disable", false); + break; } } - else + if (m_btnMgr.selected(m_startupBtnSource[3])) { - for (u8 i = 0; i < (numPlugins - 4); ++i) + if (!show_homebrew || (!parental_homebrew && m_locked)) _showStartupNotice(); + else { - if (m_btnMgr.selected(m_startupBtnSource[i])) + m_current_view = COVERFLOW_HOMEBREW; + break; + } + } + for (u8 i = 0; i < numPlugins; ++i) + { + if (m_btnMgr.selected(m_startupBtnSource[i + 4])) + { + if (!show_emu) _showStartupNotice(); + else { - if (!show_emu) _showStartupNotice(); - else - { - m_current_view = COVERFLOW_EMU; - pluginSelected = true; - for (u8 j = 0; j < numPlugins; ++j) - m_plugin.SetEnablePlugin(m_cfg, j, 1); - m_plugin.SetEnablePlugin(m_cfg, i + 4, 2); - break; - } + m_current_view = COVERFLOW_EMU; + pluginSelected = true; + for (u8 j = 0; j < numPlugins; ++j) + m_plugin.SetEnablePlugin(m_cfg, j, 1); + m_plugin.SetEnablePlugin(m_cfg, i, 2); + string domain = m_plugin.GetDolName(m_plugin.getPluginMagic(i)); + domain.erase(domain.end() - 4, domain.end()); + int layout = m_startup.getInt(domain, m_cfg.getString("GENERAL", "theme", "default"), 0); + if (layout != 0) + m_cfg.setInt("EMULATOR", "last_cf_mode", layout); + break; } } } @@ -261,23 +226,42 @@ void CMenu::_initStartupMenu(CMenu::SThemeData &theme) _addUserLabels(theme, m_startupLblUser, ARRAY_SIZE(m_startupLblUser), "STARTUP"); m_startupBg = _texture(theme.texSet, "STARTUP/BG", "texture", theme.bg); m_startupLblTitle = _addTitle(theme, "STARTUP/TITLE", theme.titleFont, L"", 20, 30, 600, 60, theme.titleFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE); - m_startupBtnBack = _addButton(theme, "STARTUP/BACK_BTN", theme.btnFont, L"", 420, 400, 200, 56, theme.btnFontColor); + m_startupBtnBack = _addButton(theme, "STARTUP/BACK_BTN", theme.btnFont, L"", 424, 400, 210, 56, theme.btnFontColor); m_startupLblNotice = _addLabel(theme, "STARTUP/NOTICE", theme.btnFont, L"", 20, 400, 600, 56, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_TOP); - m_startupLblPage = _addLabel(theme, "STARTUP/PAGE_BTN", theme.btnFont, L"", 76, 400, 80, 56, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC); - m_startupBtnPageM = _addPicButton(theme, "STARTUP/PAGE_MINUS", theme.btnTexMinus, theme.btnTexMinusS, 20, 400, 56, 56); - m_startupBtnPageP = _addPicButton(theme, "STARTUP/PAGE_PLUS", theme.btnTexPlus, theme.btnTexPlusS, 156, 400, 56, 56); - for(int i = 0; i < 10; i += 2) + m_startupLblPage = _addLabel(theme, "STARTUP/PAGE_BTN", theme.btnFont, L"", 62, 400, 98, 56, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC); + m_startupBtnPageM = _addPicButton(theme, "STARTUP/PAGE_MINUS", theme.btnTexMinus, theme.btnTexMinusS, 10, 400, 52, 56); + m_startupBtnPageP = _addPicButton(theme, "STARTUP/PAGE_PLUS", theme.btnTexPlus, theme.btnTexPlusS, 160, 400, 52, 56); + + int row; + int col; + + int i = 0; + while (i < 10) { - m_startupBtnSource[i] = _addButton(theme, fmt("STARTUP/SOURCE_BTN_%i", i), theme.btnFont, L"", 110, (100 + 58 * (i / 2)), 200, 56, theme.btnFontColor); - m_startupBtnSource[i +1] = _addButton(theme, fmt("STARTUP/SOURCE_BTN_%i", i + 1), theme.btnFont, L"", 330, (100 + 58 * (i / 2)), 200, 56, theme.btnFontColor); + row = m_startup.getInt("BUTTONS", fmt("button_%i_row", i), i / 2); + col = m_startup.getInt("BUTTONS", fmt("button_%i_col", i), 0); + m_startupBtnSource[i] = _addButton(theme, fmt("STARTUP/SOURCE_BTN_%i", i), theme.btnFont, L"", (30 + 300 * col), (100 + 58 * row), 280, 56, theme.btnFontColor, true); + row = m_startup.getInt("BUTTONS", fmt("button_%i_row", i + 10), i / 2); + col = m_startup.getInt("BUTTONS", fmt("button_%i_col", i + 10), 0); + m_startupBtnSource[i + 10] = _addButton(theme, fmt("STARTUP/SOURCE_BTN_%i", i + 10), theme.btnFont, L"", (30 + 300 * col), (100 + 58 * row), 280, 56, theme.btnFontColor, true); + i++; + row = m_startup.getInt("BUTTONS", fmt("button_%i_row", i), (i - 1) / 2); + col = m_startup.getInt("BUTTONS", fmt("button_%i_col", i), 1); + m_startupBtnSource[i] = _addButton(theme, fmt("STARTUP/SOURCE_BTN_%i", i), theme.btnFont, L"", (30 + 300 * col), (100 + 58 * row), 280, 56, theme.btnFontColor, true); + row = m_startup.getInt("BUTTONS", fmt("button_%i_row", i + 10), (i - 1) /2); + col = m_startup.getInt("BUTTONS", fmt("button_%i_col", i + 10), 1); + m_startupBtnSource[i + 10] = _addButton(theme, fmt("STARTUP/SOURCE_BTN_%i", i + 10), theme.btnFont, L"", (30 + 300 * col), (100 + 58 * row), 280, 56, theme.btnFontColor, true); + i++; } + _setHideAnim(m_startupLblTitle, "STARTUP/TITLE", 0, -200, 0.f, 1.f); _setHideAnim(m_startupLblNotice, "STARTUP/NOTICE", 0, 0, 1.f, 0.f); _setHideAnim(m_startupLblPage, "STARTUP/PAGE_BTN", 0, 200, 1.f, 0.f); _setHideAnim(m_startupBtnPageM, "STARTUP/PAGE_MINUS", 0, 200, 1.f, 0.f); _setHideAnim(m_startupBtnPageP, "STARTUP/PAGE_PLUS", 0, 200, 1.f, 0.f); _setHideAnim(m_startupBtnBack, "STARTUP/BACK_BTN", 0, 200, 1.f, 0.f); - for(int i = 0; i < 10; ++i) + + for(int i = 0; i < 20; ++i) { _setHideAnim(m_startupBtnSource[i], fmt("STARTUP/SOURCE_BTN_%i", i), 0, 0, 1.f, 0.f); } @@ -289,25 +273,15 @@ void CMenu::_textStartup(void) m_btnMgr.setText(m_startupLblTitle, _t("", L"Select Source")); m_btnMgr.setText(m_startupBtnBack, _t("", L"Exit")); m_btnMgr.setText(m_startupLblNotice, _t("", L"** DISABLED **")); - if(Startup_curPage == 1) - { - m_btnMgr.setText(m_startupBtnSource[0], _t("", L"Wii Games")); - m_btnMgr.setText(m_startupBtnSource[1], _t("", L"Real NAND")); - m_btnMgr.setText(m_startupBtnSource[2], _t("", L"GC Games")); - m_btnMgr.setText(m_startupBtnSource[3], _t("", L"Emu NAND")); - m_btnMgr.setText(m_startupBtnSource[4], _t("", L"Homebrew")); - m_btnMgr.setText(m_startupBtnSource[5], _t("", L"Emulators")); + m_btnMgr.setText(m_startupBtnSource[0], _t("", L"Wii Games")); + m_btnMgr.setText(m_startupBtnSource[1], _t("", L"VC/WiiWare")); + m_btnMgr.setText(m_startupBtnSource[2], _t("", L"GC Games")); + m_btnMgr.setText(m_startupBtnSource[3], _t("", L"Homebrew")); - if (numPlugins != 0) - { - for(u8 i = 0; i < min((int) numPlugins, 4); ++i) - m_btnMgr.setText(m_startupBtnSource[i + 6], m_plugin.GetPluginName(i)); - } - } - else + if (numPlugins != 0) { - for( u8 i = 0; i < (numPlugins - 4); ++i) - m_btnMgr.setText(m_startupBtnSource[i], m_plugin.GetPluginName(i + 4)); + for(u8 i = 0; i < numPlugins; ++i) + m_btnMgr.setText(m_startupBtnSource[i + 4], m_plugin.GetPluginName(i)); } }