From fac9452af268159eaa6ec5e24b46c6b579990c71 Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Mon, 8 Apr 2013 21:45:13 +0000 Subject: [PATCH] -removed the press b on channel icon to switch to emu nand and back, this is now done on the fly by just selecting NAND as partition, of course this function is still completely disabled for neek users ;) -removed the ios and force cios load options from the ini so they are only settable in the wiiflow startup menu from now on, that should stop wiiflow with mixing up ini and nand save options -added a ini option to disable the source menu, use_source (enabled by default) -finally added a "Back" button to the startup menu --- source/channel/channels.cpp | 3 +- source/channel/nand_save.cpp | 16 ++++--- source/channel/nand_save.hpp | 4 +- source/menu/menu.cpp | 13 +----- source/menu/menu.hpp | 3 +- source/menu/menu_boot.cpp | 61 ++++++++++++++---------- source/menu/menu_main.cpp | 76 +++++++++++++++--------------- source/menu/menu_nandemu.cpp | 89 +++++++++++++++++++----------------- 8 files changed, 140 insertions(+), 125 deletions(-) diff --git a/source/channel/channels.cpp b/source/channel/channels.cpp index b0e1a7a9..cc1d2f39 100644 --- a/source/channel/channels.cpp +++ b/source/channel/channels.cpp @@ -37,6 +37,7 @@ #include "gecko/gecko.hpp" #include "gui/text.hpp" #include "loader/fs.h" +#include "loader/nk.h" #include "loader/sys.h" #include "memory/mem2.hpp" #include "wstringEx/wstringEx.hpp" @@ -187,7 +188,7 @@ void Channels::Search() { u32 count; u64 *list = NULL; - if(NANDemuView) + if(!neek2o() && NANDemuView) list = NandHandle.GetChannels(&count); else list = GetChannelList(&count); diff --git a/source/channel/nand_save.cpp b/source/channel/nand_save.cpp index 7c1da105..8b14ef27 100644 --- a/source/channel/nand_save.cpp +++ b/source/channel/nand_save.cpp @@ -28,6 +28,8 @@ extern const u8 save_bin[]; extern const u32 save_bin_size; NandSave InternalSave; +bool cur_load = false; +u8 cur_ios = 0; #define BANNER_PATH "/title/00010000/57465346/data/banner.bin" #define IOS_SAVE_PATH "/title/00010000/57465346/data/ios" @@ -161,9 +163,11 @@ void NandSave::LoadSettings() if(file != NULL && size == sizeof(ios_settings_t)) { gprintf("Loading IOS Settings from NAND\n"); - if(file->cios > 0) - mainIOS = file->cios; - useMainIOS = file->use_cios; + cur_ios = file->cios; + if(cur_ios > 0) + mainIOS = cur_ios; + cur_load = file->use_cios; + useMainIOS = cur_load; } if(file != NULL) free(file); @@ -179,13 +183,13 @@ void NandSave::LoadSettings() free(port); } -void NandSave::SaveIOS(u8 ios, bool use_ios) +void NandSave::SaveIOS() { if(loaded == false) return; memset(&ios_settings, 0, sizeof(ios_settings_t)); - ios_settings.cios = ios; - ios_settings.use_cios = use_ios; + ios_settings.cios = cur_ios; + ios_settings.use_cios = cur_load; gprintf("Saving IOS Settings to NAND\n"); WriteFile(IOS_SAVE_PATH, (u8*)&ios_settings, sizeof(ios_settings_t)); } diff --git a/source/channel/nand_save.hpp b/source/channel/nand_save.hpp index 1b350a0a..d67f1039 100644 --- a/source/channel/nand_save.hpp +++ b/source/channel/nand_save.hpp @@ -31,7 +31,7 @@ public: NandSave(); bool CheckSave(); void LoadSettings(); - void SaveIOS(u8 ios, bool use_ios); + void SaveIOS(); void SavePort(u8 port); private: void WriteFile(const char *file_name, u8 *content, u32 size); @@ -43,5 +43,7 @@ private: }; extern NandSave InternalSave; +extern bool cur_load; +extern u8 cur_ios; #endif diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 8a311f42..d3c66ea3 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -125,6 +125,7 @@ CMenu::CMenu() m_use_sd_logging = false; m_use_wifi_gecko = false; init_network = false; + m_use_source = true; } void CMenu::init() @@ -192,18 +193,6 @@ void CMenu::init() /* Init Network if wanted */ init_network = (m_cfg.getBool("GENERAL", "async_network") || has_enabled_providers() || m_use_wifi_gecko); _netInit(); - /* Check if we want a cIOS loaded */ - u8 prevCios = mainIOS; - bool prevForceCIOS = useMainIOS; - u8 ForceIOS = min(m_cfg.getInt("GENERAL", "force_cios_rev", 0), 254); - if(ForceIOS > 0 && mainIOS != ForceIOS) - { - gprintf("Using IOS%i instead of IOS%i as main cIOS.\n", ForceIOS, mainIOS); - mainIOS = ForceIOS; - } - useMainIOS = m_cfg.getBool("GENERAL", "force_cios_load", false); - if(prevCios != mainIOS || prevForceCIOS != useMainIOS) - InternalSave.SaveIOS(mainIOS, useMainIOS); /* Our Wii game dir */ memset(wii_games_dir, 0, 64); strncpy(wii_games_dir, m_cfg.getString("GENERAL", "wii_games_dir", GAMES_DIR).c_str(), 64); diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index 10c3dae6..da320d3a 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -82,6 +82,7 @@ private: bool m_locked; bool m_favorites; bool m_music_info; + bool m_use_source; s16 m_showtimer; string m_curLanguage; @@ -875,7 +876,7 @@ private: void _textExitTo(void); void _textBoot(void); // - void _refreshBoot(u8 port = 0); + void _refreshBoot(); // void _hideCheatSettings(bool instant = false); void _hideError(bool instant = false); diff --git a/source/menu/menu_boot.cpp b/source/menu/menu_boot.cpp index dbe7a112..cc2ab1de 100644 --- a/source/menu/menu_boot.cpp +++ b/source/menu/menu_boot.cpp @@ -31,6 +31,10 @@ s16 m_bootLblCIOSrevP; s16 m_bootLblUSBPort; s16 m_bootBtnUSBPort; +s16 m_bootBtnBack; + +u8 set_port = 0; + static void showBoot(void) { m_btnMgr.show(m_bootLblTitle); @@ -44,6 +48,8 @@ static void showBoot(void) m_btnMgr.show(m_bootLblUSBPort); m_btnMgr.show(m_bootBtnUSBPort); + + m_btnMgr.show(m_bootBtnBack); } static void hideBoot(bool instant) @@ -59,15 +65,17 @@ static void hideBoot(bool instant) m_btnMgr.hide(m_bootLblUSBPort, instant); m_btnMgr.hide(m_bootBtnUSBPort, instant); + + m_btnMgr.hide(m_bootBtnBack, instant); } bool CMenu::_Boot(void) { SetupInput(); - u8 port = currentPort; - bool prev_load = m_cfg.getBool("GENERAL", "force_cios_load", false); - u8 prev_ios = min(m_cfg.getInt("GENERAL", "force_cios_rev", 0), 254); - _refreshBoot(port); + set_port = currentPort; + bool prev_load = cur_load; + u8 prev_ios = cur_ios; + _refreshBoot(); while(!m_exit) { @@ -76,16 +84,17 @@ bool CMenu::_Boot(void) break; else if(BTN_A_PRESSED) { - if(m_btnMgr.selected(m_bootBtnLoadCIOS)) + if(m_btnMgr.selected(m_bootBtnBack)) + break; + else if(m_btnMgr.selected(m_bootBtnLoadCIOS)) { - bool old = m_cfg.getBool("GENERAL", "force_cios_load", false); - m_cfg.setBool("GENERAL", "force_cios_load", !old); - _refreshBoot(port); + cur_load = !cur_load; + _refreshBoot(); } else if(m_btnMgr.selected(m_bootLblCIOSrevM) || m_btnMgr.selected(m_bootLblCIOSrevP)) { bool increase = m_btnMgr.selected(m_bootLblCIOSrevP); - CIOSItr itr = _installed_cios.find(min(m_cfg.getInt("GENERAL", "force_cios_rev", 0), 254)); + CIOSItr itr = _installed_cios.find(cur_ios); if(increase) { itr++; @@ -98,25 +107,23 @@ bool CMenu::_Boot(void) itr = _installed_cios.end(); itr--; } - m_cfg.setInt("GENERAL", "force_cios_rev", itr->first); - _refreshBoot(port); + cur_ios = itr->first; + _refreshBoot(); } else if(m_btnMgr.selected(m_bootBtnUSBPort)) { - port = (port == 0 ? 1 : 0); - _refreshBoot(port); + set_port = !set_port; + _refreshBoot(); } } } - bool cur_load = m_cfg.getBool("GENERAL", "force_cios_load", false); - u8 cur_ios = min(m_cfg.getInt("GENERAL", "force_cios_rev", 0), 254); if(prev_load != cur_load || prev_ios != cur_ios) - InternalSave.SaveIOS(cur_ios, cur_load); - if(port != currentPort) - InternalSave.SavePort(port); + InternalSave.SaveIOS(); + if(set_port != currentPort) + InternalSave.SavePort(set_port); hideBoot(false); - if(prev_load != cur_load || prev_ios != cur_ios || port != currentPort) + if(prev_load != cur_load || prev_ios != cur_ios || set_port != currentPort) { m_exit = true; m_reload = true; @@ -125,13 +132,12 @@ bool CMenu::_Boot(void) return 0; } -void CMenu::_refreshBoot(u8 port) +void CMenu::_refreshBoot() { - m_btnMgr.setText(m_bootBtnLoadCIOS, _optBoolToString(m_cfg.getBool("GENERAL", "force_cios_load", false))); - m_btnMgr.setText(m_bootBtnUSBPort, wfmt(L"%i", port)); - u8 IOS_Revision = min(m_cfg.getInt("GENERAL", "force_cios_rev", 0), 254); - if(IOS_Revision > 0) - m_btnMgr.setText(m_bootLblCurCIOSrev, wfmt(L"%i", IOS_Revision)); + m_btnMgr.setText(m_bootBtnLoadCIOS, _optBoolToString(cur_load)); + m_btnMgr.setText(m_bootBtnUSBPort, wfmt(L"%i", set_port)); + if(cur_ios > 0) + m_btnMgr.setText(m_bootLblCurCIOSrev, wfmt(L"%i", cur_ios)); else m_btnMgr.setText(m_bootLblCurCIOSrev, L"AUTO"); showBoot(); @@ -143,6 +149,7 @@ void CMenu::_textBoot(void) m_btnMgr.setText(m_bootLblLoadCIOS, _t("cfgbt2", L"Force Load cIOS")); m_btnMgr.setText(m_bootLblCIOSrev, _t("cfgbt3", L"Force cIOS Revision")); m_btnMgr.setText(m_bootLblUSBPort, _t("cfgbt4", L"USB Port")); + m_btnMgr.setText(m_bootBtnBack, _t("cfg10", L"Back")); } @@ -161,6 +168,8 @@ void CMenu::_initBoot(void) m_bootLblUSBPort = _addLabel("BOOT/USB_PORT", theme.lblFont, L"", 40, 250, 290, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE); m_bootBtnUSBPort = _addButton("BOOT/USB_PORT_BTN", theme.btnFont, L"", 330, 250, 270, 56, theme.btnFontColor); + m_bootBtnBack = _addButton("BOOT/BACK_BTN", theme.btnFont, L"", 420, 400, 200, 56, theme.btnFontColor); + _setHideAnim(m_bootLblTitle, "BOOT/TITLE", 0, -200, 0.f, 1.f); _setHideAnim(m_bootLblLoadCIOS, "BOOT/LOAD_CIOS", -200, 0, 1.f, 0.f); _setHideAnim(m_bootBtnLoadCIOS, "BOOT/LOAD_CIOS_BTN", 200, 0, 1.f, 0.f); @@ -173,6 +182,8 @@ void CMenu::_initBoot(void) _setHideAnim(m_bootLblUSBPort, "BOOT/USB_PORT", -200, 0, 1.f, 0.f); _setHideAnim(m_bootBtnUSBPort, "BOOT/USB_PORT_BTN", 200, 0, 1.f, 0.f); + _setHideAnim(m_bootBtnBack, "BOOT/BACK_BTN", 0, 0, -2.f, 0.f); + hideBoot(true); _textBoot(); } diff --git a/source/menu/menu_main.cpp b/source/menu/menu_main.cpp index a58afbdc..9b1581b5 100644 --- a/source/menu/menu_main.cpp +++ b/source/menu/menu_main.cpp @@ -156,7 +156,10 @@ void CMenu::_showMain(void) { _hideMain(); if(!_AutoCreateNand()) - m_cfg.setBool(CHANNEL_DOMAIN, "disable", true); + { + while(NANDemuView) + _setPartition(1); + } _loadList(); _showMain(); _initCF(); @@ -226,13 +229,14 @@ int CMenu::main(void) { wstringEx curLetter; string prevTheme = m_cfg.getString("GENERAL", "theme", "default"); - parental_homebrew = m_cfg.getBool(HOMEBREW_DOMAIN, "parental", false); + parental_homebrew = m_cfg.getBool(HOMEBREW_DOMAIN, "parental", false); show_homebrew = !m_cfg.getBool(HOMEBREW_DOMAIN, "disable", false); show_channel = !m_cfg.getBool("GENERAL", "hidechannel", false); show_emu = !m_cfg.getBool(PLUGIN_DOMAIN, "disable", false); bool dpad_mode = m_cfg.getBool("GENERAL", "dpad_mode", false); bool b_lr_mode = m_cfg.getBool("GENERAL", "b_lr_mode", false); bool use_grab = m_cfg.getBool("GENERAL", "use_grab", false); + m_use_source = m_cfg.getBool("GENERAL", "use_source", true); bool bheld = false; bool bUsed = false; @@ -280,7 +284,7 @@ int CMenu::main(void) WDVD_GetCoverStatus(&disc_check); /* Main Loop */ _mainLoopCommon(true); - if(bheld && !BTN_B_HELD) + if(m_use_source && bheld && !BTN_B_HELD) { bheld = false; if(bUsed) @@ -512,14 +516,6 @@ int CMenu::main(void) bUsed = true; continue; } - else if(!neek2o()) - { - bUsed = true; - m_cfg.setBool(CHANNEL_DOMAIN, "disable", !m_cfg.getBool(CHANNEL_DOMAIN, "disable", true)); - gprintf("EmuNand is %s\n", m_cfg.getBool(CHANNEL_DOMAIN, "disable", true) ? "Disabled" : "Enabled"); - m_current_view = COVERFLOW_CHANNEL; - LoadView(); - } } else if(m_btnMgr.selected(m_mainBtnNext) || m_btnMgr.selected(m_mainBtnPrev)) { @@ -690,27 +686,21 @@ int CMenu::main(void) else if(BTN_MINUS_PRESSED && !m_locked) { bUsed = true; - bool block = m_current_view == COVERFLOW_CHANNEL && (m_cfg.getBool(CHANNEL_DOMAIN, "disable", true) || neek2o()); const char *partition = NULL; - if(!block) - { - _showWaitMessage(); - _hideMain(); - _setPartition(1); - partition = DeviceName[currentPartition]; - } - else + _showWaitMessage(); + _hideMain(); + _setPartition(1); + if(m_current_view == COVERFLOW_CHANNEL && (m_cfg.getBool(CHANNEL_DOMAIN, "disable", true) || neek2o())) partition = "NAND"; + else + partition = DeviceName[currentPartition]; //gprintf("Next item: %s\n", partition); m_showtimer = 120; m_btnMgr.setText(m_mainLblNotice, sfmt("%s (%u) [%s]", _domainFromView(), m_gameList.size(), upperCase(partition).c_str())); m_btnMgr.show(m_mainLblNotice); - if(!block) - { - _loadList(); - _showMain(); - _initCF(); - } + _loadList(); + _showMain(); + _initCF(); } } @@ -1115,25 +1105,39 @@ wstringEx CMenu::_getNoticeTranslation(int sorting, wstringEx curLetter) void CMenu::_setPartition(s8 direction) { - if(m_current_view == COVERFLOW_CHANNEL && NANDemuView == false) + if(m_current_view == COVERFLOW_CHANNEL && neek2o()) return; _cfNeedsUpdate(); if(direction != 0) { - u8 limiter = 0; - bool NeedFAT = m_current_view == COVERFLOW_CHANNEL || m_current_view == COVERFLOW_DML; - currentPartition = loopNum(currentPartition + direction, 8); - int FS_Type = DeviceHandle.GetFSType(currentPartition); - while(!DeviceHandle.IsInserted(currentPartition) || - (m_current_view != COVERFLOW_USB && FS_Type == PART_FS_WBFS) || - (NeedFAT && FS_Type != PART_FS_FAT)) + bool switch_to_real = true; + if(m_current_view == COVERFLOW_CHANNEL && !NANDemuView) { - currentPartition = loopNum(currentPartition + direction, 8); + NANDemuView = true; + m_cfg.setBool(CHANNEL_DOMAIN, "disable", false); + switch_to_real = false; + } + bool NeedFAT = m_current_view == COVERFLOW_CHANNEL || m_current_view == COVERFLOW_DML; + + u8 limiter = 0; + int FS_Type = 0; + do + { + currentPartition = loopNum(currentPartition + direction, 10); FS_Type = DeviceHandle.GetFSType(currentPartition); - if(limiter > 10) + if(m_current_view == COVERFLOW_CHANNEL && switch_to_real && FS_Type == -1) break; limiter++; } + while(limiter < 12 && (!DeviceHandle.IsInserted(currentPartition) || + (m_current_view != COVERFLOW_USB && FS_Type == PART_FS_WBFS) || + (NeedFAT && FS_Type != PART_FS_FAT))); + + if(m_current_view == COVERFLOW_CHANNEL && FS_Type == -1) + { + NANDemuView = false; + m_cfg.setBool(CHANNEL_DOMAIN, "disable", true); + } } if(m_tempView) m_cfg.setInt(WII_DOMAIN, "savepartition", currentPartition); diff --git a/source/menu/menu_nandemu.cpp b/source/menu/menu_nandemu.cpp index 59e52397..76d3bee9 100644 --- a/source/menu/menu_nandemu.cpp +++ b/source/menu/menu_nandemu.cpp @@ -533,56 +533,59 @@ int CMenu::_AutoCreateNand(void) while(!m_exit) { _mainLoopCommon(); - if(BTN_A_PRESSED && (m_btnMgr.selected(m_nandemuBtnExtract))) + if(BTN_A_PRESSED) { - m_fulldump = true; - m_btnMgr.hide(m_nandemuBtnExtract); - m_btnMgr.hide(m_nandemuBtnDisable); - m_btnMgr.hide(m_nandemuBtnPartition); - m_btnMgr.hide(m_nandemuLblInit); - m_btnMgr.show(m_nandemuLblTitle); - m_btnMgr.show(m_nandfilePBar); - m_btnMgr.show(m_nandemuPBar); - m_btnMgr.show(m_nandfileLblMessage); - m_btnMgr.show(m_nandemuLblMessage); - m_btnMgr.show(m_nandfileLblDialog); - m_btnMgr.show(m_nandemuLblDialog); - m_btnMgr.setText(m_nandemuLblMessage, L""); - m_btnMgr.setText(m_nandfileLblMessage, L""); - m_btnMgr.setText(m_nandemuLblDialog, _t("cfgne11", L"Overall Progress:")); - m_btnMgr.setText(m_nandemuLblTitle, _t("cfgne12", L"NAND Extractor")); - m_thrdStop = false; - m_thrdProgress = 0.f; - m_thrdWorking = true; - LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_NandDumper, (void *)this, 0, 32768, 40); - } - else if(BTN_A_PRESSED && (m_btnMgr.selected(m_nandemuBtnDisable))) - { - _hideNandEmu(); - return 0; - } - else if(BTN_A_PRESSED && (m_btnMgr.selected(m_nandemuBtnPartition))) - { - if(m_current_view == COVERFLOW_USB) + if(m_btnMgr.selected(m_nandemuBtnExtract)) { - m_tempView = true; - m_current_view = COVERFLOW_CHANNEL; + m_fulldump = true; + m_btnMgr.hide(m_nandemuBtnExtract); + m_btnMgr.hide(m_nandemuBtnDisable); + m_btnMgr.hide(m_nandemuBtnPartition); + m_btnMgr.hide(m_nandemuLblInit); + m_btnMgr.show(m_nandemuLblTitle); + m_btnMgr.show(m_nandfilePBar); + m_btnMgr.show(m_nandemuPBar); + m_btnMgr.show(m_nandfileLblMessage); + m_btnMgr.show(m_nandemuLblMessage); + m_btnMgr.show(m_nandfileLblDialog); + m_btnMgr.show(m_nandemuLblDialog); + m_btnMgr.setText(m_nandemuLblMessage, L""); + m_btnMgr.setText(m_nandfileLblMessage, L""); + m_btnMgr.setText(m_nandemuLblDialog, _t("cfgne11", L"Overall Progress:")); + m_btnMgr.setText(m_nandemuLblTitle, _t("cfgne12", L"NAND Extractor")); + m_thrdStop = false; + m_thrdProgress = 0.f; + m_thrdWorking = true; + LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_NandDumper, (void *)this, 0, 32768, 40); } - _hideNandEmu(); - _config(1); - if(m_tempView) + else if(m_btnMgr.selected(m_nandemuBtnDisable)) { - m_current_view = COVERFLOW_USB; - m_tempView = false; + _hideNandEmu(); return 0; } - return 1; - } - else if(BTN_A_PRESSED && (m_btnMgr.selected(m_nandemuBtnBack))) - { - m_cfg.save(); - _hideNandEmu(); + else if(m_btnMgr.selected(m_nandemuBtnPartition)) + { + if(m_current_view == COVERFLOW_USB) + { + m_tempView = true; + m_current_view = COVERFLOW_CHANNEL; + } + _hideNandEmu(); + _config(1); + if(m_tempView) + { + m_current_view = COVERFLOW_USB; + m_tempView = false; + return 0; + } return 1; + } + else if(m_btnMgr.selected(m_nandemuBtnBack)) + { + m_cfg.save(); + _hideNandEmu(); + return 1; + } } if(m_thrdMessageAdded)