diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 7ca968fd..f861d81d 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -1034,6 +1034,7 @@ void CMenu::_buildMenus(void) _initCFThemeMenu(theme); _initGameSettingsMenu(theme); _initCheatSettingsMenu(theme); + _initStartupMenu(theme); _initPluginSettingsMenu(theme); _initCategorySettingsMenu(theme); _initSystemMenu(theme); diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index 00a1b902..43c1ba79 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -864,12 +864,14 @@ private: void _initGameSettingsMenu(SThemeData &theme); void _initCheatSettingsMenu(SThemeData &theme); void _initCheatButtons(); + void _initStartupMenu(SThemeData &theme); void _initPluginSettingsMenu(SThemeData &theme); void _initCategorySettingsMenu(SThemeData &theme); void _initSystemMenu(SThemeData &theme); void _initGameInfoMenu(SThemeData &theme); void _initNandEmuMenu(CMenu::SThemeData &theme); // + void _textStartup(void); void _textPluginSettings(void); void _textCategorySettings(void); void _textCheatSettings(void); @@ -910,6 +912,7 @@ private: void _hideWBFS(bool instant = false); void _hideCFTheme(bool instant = false); void _hideGameSettings(bool instant = false); + void _hideStartup(bool instant = false); void _hidePluginSettings(bool instant = false); void _hideCategorySettings(bool instant = false); void _hideSystem(bool instant = false); @@ -932,6 +935,8 @@ private: void _showSettings(); void _showCode(void); void _showAbout(void); + void _showStartup(void); + void _showStartupNotice(void); void _showPluginSettings(void); void _showCategorySettings(void); void _showCheatSettings(void); @@ -941,6 +946,7 @@ private: void _showCFTheme(u32 curParam, int version, bool wide); void _showGameSettings(void); void _showCheatDownload(void); + void _updateStartupBtns(void); void _updatePluginCheckboxes(void); void _updateCheckboxes(void); void _setBg(const STexture &tex, const STexture &lqTex); @@ -979,6 +985,7 @@ private: void _gameinfo(void); void _gameSettings(void); void _CheatSettings(); + void _Startup(); void _PluginSettings(); void _CategorySettings(bool fromGameSet=false); // diff --git a/source/menu/menu_main.cpp b/source/menu/menu_main.cpp index a4a79357..36b9a870 100644 --- a/source/menu/menu_main.cpp +++ b/source/menu/menu_main.cpp @@ -245,7 +245,11 @@ int CMenu::main(void) m_GameTDBLoaded=true; m_gametdb.CloseFile(); } - + if (m_cfg.getBool("GENERAL", "startup_menu", false)) + { + m_vid.hideWaitMessage(); + _Startup(); + } if (m_cfg.getBool("GENERAL", "update_cache", false)) { UpdateCache(); @@ -311,6 +315,13 @@ int CMenu::main(void) } break; } + if (BTN_PLUS_PRESSED && (m_btnMgr.selected(m_mainBtnChannel) || m_btnMgr.selected(m_mainBtnUsb) || m_btnMgr.selected(m_mainBtnDML) || m_btnMgr.selected(m_mainBtnHomebrew) || m_btnMgr.selected(m_mainBtnEmu))) + { + _hideMain(true); + _Startup(); + LoadView(); + continue; + } if ((BTN_UP_PRESSED || BTN_DOWN_PRESSED || BTN_LEFT_PRESSED || BTN_RIGHT_PRESSED) && dpad_mode && (m_btnMgr.selected(m_mainBtnChannel) || m_btnMgr.selected(m_mainBtnUsb) || m_btnMgr.selected(m_mainBtnDML) || m_btnMgr.selected(m_mainBtnHomebrew) || m_btnMgr.selected(m_mainBtnEmu))) { u32 lastView = m_current_view; diff --git a/source/menu/menu_startup.cpp b/source/menu/menu_startup.cpp new file mode 100644 index 00000000..bb6701bd --- /dev/null +++ b/source/menu/menu_startup.cpp @@ -0,0 +1,313 @@ +#include "menu.hpp" + +#include +#include + +u32 Startup_curPage; +u8 numPlugins; + +// Startup menu +u32 m_startupLblNotice; +u32 m_startupLblPage; +u32 m_startupBtnPageM; +u32 m_startupBtnPageP; +u32 m_startupBtnBack; +u32 m_startupLblTitle; +u32 m_startupBtnSource[20]; +u32 m_startupLblUser[4]; +STexture m_startupBg; + +void CMenu::_hideStartup(bool instant) +{ + m_btnMgr.hide(m_startupLblTitle, instant); + m_btnMgr.hide(m_startupBtnBack, instant); + m_btnMgr.hide(m_startupLblNotice, instant); + m_btnMgr.hide(m_startupLblPage, instant); + m_btnMgr.hide(m_startupBtnPageM, instant); + m_btnMgr.hide(m_startupBtnPageP, instant); + for (u32 i = 0; i < ARRAY_SIZE(m_startupLblUser); ++i) + { + if (m_startupLblUser[i] != -1u) + m_btnMgr.hide(m_startupLblUser[i], instant); + } + + for (int i = 0; i < 20; ++i) + { + m_btnMgr.hide(m_startupBtnSource[i]); + } +} + +void CMenu::_showStartup(void) +{ + _setBg(m_startupBg, m_startupBg); + + for (u32 i = 0; i < ARRAY_SIZE(m_startupLblUser); ++i) + { + if (m_startupLblUser[i] != -1u) + m_btnMgr.show(m_startupLblUser[i]); + } + + m_btnMgr.show(m_startupLblTitle); + m_btnMgr.show(m_startupBtnBack); +} + +void CMenu::_updateStartupBtns(void) +{ + _textStartup(); + if (numPlugins > 4) + { + 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]); +} + +void CMenu::_showStartupNotice(void) +{ + m_showtimer = 90; + m_btnMgr.show(m_startupLblNotice); +} + +void CMenu::_Startup() +{ + //_loadEmuList(); + _showStartup(); + DIR *pdir; + struct dirent *pent; + + pdir = opendir(m_pluginsDir.c_str()); + Config m_plugin_cfg; + + 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; + if (strcasestr(pent->d_name, ".ini") != NULL) + { + m_plugin_cfg.load(fmt("%s/%s", m_pluginsDir.c_str(), pent->d_name)); + if (m_plugin_cfg.loaded()) + { + m_plugin.AddPlugin(m_plugin_cfg); + } + m_plugin_cfg.unload(); + } + } + closedir(pdir); + m_plugin.EndAdd(); + u8 i = 0; + while(true) + { + if (m_plugin.PluginExist(i)) + i++; + else + { + numPlugins = i; + break; + } + } + SetupInput(); + bool show_homebrew = !m_cfg.getBool("HOMEBREW", "disable", false); + bool show_channel = !m_cfg.getBool("GENERAL", "hidechannel", false); + bool show_emu = !m_cfg.getBool("EMULATOR", "disable", false); + bool parental_homebrew = m_cfg.getBool("HOMEBREW", "parental", false); + bool pluginSelected = false; + m_showtimer = 0; + Startup_curPage = 1; + _updateStartupBtns(); + while(true) + { + _mainLoopCommon(); + 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))) + { + 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))) + { + Startup_curPage = Startup_curPage == 1 ? 2 : 1; + if (BTN_RIGHT_PRESSED || BTN_PLUS_PRESSED) + m_btnMgr.click(m_startupBtnPageP); + _updateStartupBtns(); + } + if (BTN_A_PRESSED) + { + if (m_btnMgr.selected(m_startupBtnBack)) + break; + if (Startup_curPage == 1) + { + 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_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; + } + } + } + } + else + { + for (u8 i = 0; i < (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 + 4, 2); + break; + } + } + } + } + if (pluginSelected) + { + break; + } + } + if (m_showtimer > 0) + if (--m_showtimer == 0) + m_btnMgr.hide(m_startupLblNotice); + } + _hideStartup(true); +} + +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_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_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); + } + _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) + { + _setHideAnim(m_startupBtnSource[i], fmt("STARTUP/SOURCE_BTN_%i", i), 0, 0, 1.f, 0.f); + } + _hideStartup(true); +} + +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")); + + 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 + { + for( u8 i = 0; i < (numPlugins - 4); ++i) + m_btnMgr.setText(m_startupBtnSource[i], m_plugin.GetPluginName(i + 4)); + } +} +