From 903d3fba504f25089dc8771fee15ad8f61f44d11 Mon Sep 17 00:00:00 2001 From: fledge68 Date: Tue, 25 Dec 2012 19:09:41 +0000 Subject: [PATCH] -Added plugin partition saves. now when you have plugin roms on different partitions wiiflow will automatically change to that partition when you use a source menu button to select a plugin. --- source/menu/menu.cpp | 44 ++++++++++++++++++++----------------- source/menu/menu.hpp | 4 ++++ source/menu/menu_main.cpp | 5 +++++ source/menu/menu_source.cpp | 6 +++++ 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 24b19525..e1213904 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -1611,6 +1611,25 @@ void CMenu::_addUserLabels(s16 *ids, u32 start, u32 size, const char *domain) } } +void CMenu::_checkForSinglePlugin(void) +{ + enabledPluginPos = 0; + enabledPluginsCount = 0; + const vector &EnabledPlugins = m_plugin.GetEnabledPlugins(m_cfg); + if(m_current_view == COVERFLOW_PLUGIN && EnabledPlugins.size() != 0) + { + for(u8 i = 0; i < EnabledPlugins.size(); i++) + { + if(EnabledPlugins.at(i)) + { + enabledPluginPos = i; + enabledPluginsCount++; + } + } + snprintf(PluginMagicWord, sizeof(PluginMagicWord), "%08x", m_plugin.getPluginMagic(enabledPluginPos)); + } +} + void CMenu::_initCF(void) { Config dump, gameAgeList; @@ -1619,8 +1638,6 @@ void CMenu::_initCF(void) CoverFlow.clear(); CoverFlow.reserve(m_gameList.size()); - - const vector &EnabledPlugins = m_plugin.GetEnabledPlugins(m_cfg); bool dumpGameLst = m_cfg.getBool(domain, "dump_list", true); if(dumpGameLst) dump.load(fmt("%s/" TITLES_DUMP_FILENAME, m_settingsDir.c_str())); @@ -1639,22 +1656,9 @@ void CMenu::_initCF(void) gametdb.SetLanguageCode(m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str()); } } - // check for single plugin selected - u8 pos = 0; - u8 enabledPluginsCount = 0; - if(m_current_view == COVERFLOW_PLUGIN && EnabledPlugins.size() != 0) - { - char PluginMagicWord[9]; - for(u8 i = 0; i < EnabledPlugins.size(); i++) - { - snprintf(PluginMagicWord, sizeof(PluginMagicWord), "%08x", m_plugin.getPluginMagic(i)); - if(m_cfg.getBool("PLUGIN", PluginMagicWord, true)) - { - pos = i; - enabledPluginsCount++; - } - } - } + _checkForSinglePlugin(); + const vector &EnabledPlugins = m_plugin.GetEnabledPlugins(m_cfg); + for(vector::iterator element = m_gameList.begin(); element != m_gameList.end(); ++element) { string id; @@ -1789,8 +1793,8 @@ void CMenu::_initCF(void) } if(enabledPluginsCount == 1) { - catDomain = (m_plugin.GetPluginName(pos)).toUTF8(); - if(element->settings[0] != m_plugin.getPluginMagic(pos)) + catDomain = (m_plugin.GetPluginName(enabledPluginPos)).toUTF8(); + if(element->settings[0] != m_plugin.getPluginMagic(enabledPluginPos)) continue; } const char *requiredCats = m_cat.getString(fmt("%s/GENERAL", catDomain.c_str()), "required_categories").c_str(); diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index 1645497b..6884d117 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -43,6 +43,9 @@ public: void loadDefaultFont(void); void TempLoadIOS(int IOS = 0); u8 m_current_view; + u8 enabledPluginPos; + u8 enabledPluginsCount; + char PluginMagicWord[9]; private: struct SZone { @@ -923,6 +926,7 @@ private: void _updatePluginText(void); void _updatePluginCheckboxes(void); void _updateCheckboxes(void); + void _checkForSinglePlugin(void); void _getIDCats(void); void _setIDCats(void); void _setBg(const STexture &tex, const STexture &lqTex); diff --git a/source/menu/menu_main.cpp b/source/menu/menu_main.cpp index 4881677f..3b4d32e7 100644 --- a/source/menu/menu_main.cpp +++ b/source/menu/menu_main.cpp @@ -1061,5 +1061,10 @@ void CMenu::_setPartition(s8 direction) if(m_tempView) m_cfg.setInt(WII_DOMAIN, "savepartition", currentPartition); else + { m_cfg.setInt(_domainFromView(), "partition", currentPartition); + _checkForSinglePlugin(); + if(enabledPluginsCount == 1) + m_cfg.setInt("PLUGINS/PARTITION", PluginMagicWord, currentPartition); + } } diff --git a/source/menu/menu_source.cpp b/source/menu/menu_source.cpp index f7ad4cdc..49b5ae67 100644 --- a/source/menu/menu_source.cpp +++ b/source/menu/menu_source.cpp @@ -356,6 +356,12 @@ bool CMenu::_Source() } } } + _checkForSinglePlugin(); + if(enabledPluginsCount == 1) + { + currentPartition = m_cfg.getInt("PLUGINS/PARTITION", PluginMagicWord, 1) + 1; + _setPartition(-1); + } int layout = m_source.getInt(fmt("BUTTON_%i", i + j), "emuflow", 0); if(layout != 0) m_cfg.setInt(PLUGIN_DOMAIN, "last_cf_mode", layout);