From ae53adfec9c020988d525e1f7447b7ee2aaf4ddd Mon Sep 17 00:00:00 2001 From: fledge68 Date: Tue, 13 Aug 2013 13:12:40 +0000 Subject: [PATCH] - Fix for HQ covers and source menu.cpp - Fix for combined view to work properly now - Fix for last_view to work properly - Fixed little mistake in explorer when switching emu nands - removed elmstyle --- source/menu/menu.cpp | 103 +++++++++------------------------- source/menu/menu.hpp | 5 +- source/menu/menu_explorer.cpp | 9 ++- source/menu/menu_game.cpp | 6 +- source/menu/menu_main.cpp | 57 +++++++++---------- source/menu/menu_nandemu.cpp | 3 + source/menu/menu_source.cpp | 8 +++ 7 files changed, 75 insertions(+), 116 deletions(-) diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 1df86cb7..d7bae0ad 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -127,6 +127,7 @@ CMenu::CMenu() m_use_source = true; m_clearCats = true; m_catStartPage = 1; + m_combined_view = false; /* Explorer stuff */ m_txt_view = false; m_txt_path = NULL; @@ -1371,18 +1372,9 @@ s16 CMenu::_addButton(const char *domain, SFont font, const wstringEx &text, int btnTexSet.leftSel = _texture(domain, "texture_left_selected", theme.btnTexLS, false); btnTexSet.rightSel = _texture(domain, "texture_right_selected", theme.btnTexRS, false); btnTexSet.centerSel = _texture(domain, "texture_center_selected", theme.btnTexCS, false); - font = _font(theme.fontSet, domain, "font", BUTTONFONT); - GuiSound *clickSound = _sound(theme.soundSet, domain, "click_sound", theme.clickSound->GetName()); GuiSound *hoverSound = _sound(theme.soundSet, domain, "hover_sound", theme.hoverSound->GetName()); - - u16 btnPos = _textStyle(domain, "elmstyle", FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP); - if (btnPos & FTGX_JUSTIFY_RIGHT) - x = m_vid.width() - x - width; - if (btnPos & FTGX_ALIGN_BOTTOM) - y = m_vid.height() - y - height; - return m_btnMgr.addButton(font, text, x, y, width, height, c, btnTexSet, clickSound, hoverSound); } @@ -1396,13 +1388,6 @@ s16 CMenu::_addPicButton(const char *domain, TexData &texNormal, TexData &texSel TexData tex2 = _texture(domain, "texture_selected", texSelected, false); GuiSound *clickSound = _sound(theme.soundSet, domain, "click_sound", theme.clickSound->GetName()); GuiSound *hoverSound = _sound(theme.soundSet, domain, "hover_sound", theme.hoverSound->GetName()); - - u16 btnPos = _textStyle(domain, "elmstyle", FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP); - if (btnPos & FTGX_JUSTIFY_RIGHT) - x = m_vid.width() - x - width; - if (btnPos & FTGX_ALIGN_BOTTOM) - y = m_vid.height() - y - height; - return m_btnMgr.addPicButton(tex1, tex2, x, y, width, height, clickSound, hoverSound); } @@ -1417,13 +1402,6 @@ s16 CMenu::_addTitle(const char *domain, SFont font, const wstringEx &text, int height = m_theme.getInt(domain, "height", height); font = _font(theme.fontSet, domain, "font", TITLEFONT); style = _textStyle(domain, "style", style); - - u16 btnPos = _textStyle(domain, "elmstyle", FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP); - if (btnPos & FTGX_JUSTIFY_RIGHT) - x = m_vid.width() - x - width; - if (btnPos & FTGX_ALIGN_BOTTOM) - y = m_vid.height() - y - height; - return m_btnMgr.addLabel(font, text, x, y, width, height, c, style); } @@ -1438,13 +1416,6 @@ s16 CMenu::_addText(const char *domain, SFont font, const wstringEx &text, int x height = m_theme.getInt(domain, "height", height); font = _font(theme.fontSet, domain, "font", TEXTFONT); style = _textStyle(domain, "style", style); - - u16 btnPos = _textStyle(domain, "elmstyle", FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP); - if (btnPos & FTGX_JUSTIFY_RIGHT) - x = m_vid.width() - x - width; - if (btnPos & FTGX_ALIGN_BOTTOM) - y = m_vid.height() - y - height; - return m_btnMgr.addLabel(font, text, x, y, width, height, c, style); } @@ -1459,13 +1430,6 @@ s16 CMenu::_addLabel(const char *domain, SFont font, const wstringEx &text, int height = m_theme.getInt(domain, "height", height); font = _font(theme.fontSet, domain, "font", LABELFONT); style = _textStyle(domain, "style", style); - - u16 btnPos = _textStyle(domain, "elmstyle", FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP); - if (btnPos & FTGX_JUSTIFY_RIGHT) - x = m_vid.width() - x - width; - if (btnPos & FTGX_ALIGN_BOTTOM) - y = m_vid.height() - y - height; - return m_btnMgr.addLabel(font, text, x, y, width, height, c, style); } @@ -1481,13 +1445,6 @@ s16 CMenu::_addLabel(const char *domain, SFont font, const wstringEx &text, int font = _font(theme.fontSet, domain, "font", BUTTONFONT); TexData texBg = _texture(domain, "background_texture", bg, false); style = _textStyle(domain, "style", style); - - u16 btnPos = _textStyle(domain, "elmstyle", FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP); - if (btnPos & FTGX_JUSTIFY_RIGHT) - x = m_vid.width() - x - width; - if (btnPos & FTGX_ALIGN_BOTTOM) - y = m_vid.height() - y - height; - return m_btnMgr.addLabel(font, text, x, y, width, height, c, style, texBg); } @@ -1505,13 +1462,6 @@ s16 CMenu::_addProgressBar(const char *domain, int x, int y, u32 width, u32 heig btnTexSet.leftSel = _texture(domain, "texture_left_selected", theme.pbarTexLS, false); btnTexSet.rightSel = _texture(domain, "texture_right_selected", theme.pbarTexRS, false); btnTexSet.centerSel = _texture(domain, "texture_center_selected", theme.pbarTexCS, false); - - u16 btnPos = _textStyle(domain, "elmstyle", FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP); - if (btnPos & FTGX_JUSTIFY_RIGHT) - x = m_vid.width() - x - width; - if (btnPos & FTGX_ALIGN_BOTTOM) - y = m_vid.height() - y - height; - return m_btnMgr.addProgressBar(x, y, width, height, btnTexSet); } @@ -1521,23 +1471,6 @@ void CMenu::_setHideAnim(s16 id, const char *domain, int dx, int dy, float scale dy = m_theme.getInt(domain, "effect_y", dy); scaleX = m_theme.getFloat(domain, "effect_scale_x", scaleX); scaleY = m_theme.getFloat(domain, "effect_scale_y", scaleY); - - int x, y; - u32 width, height; - m_btnMgr.getDimensions(id, x, y, width, height); - - u16 btnPos = _textStyle(domain, "elmstyle", FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP); - if (btnPos & FTGX_JUSTIFY_RIGHT) - { - dx = m_vid.width() - dx - width; - scaleX = m_vid.width() - scaleX - width; - } - if (btnPos & FTGX_ALIGN_BOTTOM) - { - dy = m_vid.height() - dy - height; - scaleY = m_vid.height() - scaleY - height; - } - m_btnMgr.hide(id, dx, dy, scaleX, scaleY, true); } @@ -2150,6 +2083,7 @@ const wstringEx CMenu::_fmt(const char *key, const wchar_t *def) bool CMenu::_loadChannelList(void) { + m_gameList.clear(); string emuPath; string cacheDir; int emuPartition = -1; @@ -2178,8 +2112,8 @@ bool CMenu::_loadList(void) { CoverFlow.clear(); m_gameList.clear(); + vector combinedList; NANDemuView = false; - u8 sources = 0; gprintf("Creating Gamelist\n"); if((m_current_view == COVERFLOW_PLUGIN && !m_cfg.has(PLUGIN_DOMAIN, "source")) || @@ -2187,38 +2121,54 @@ bool CMenu::_loadList(void) { m_current_view = COVERFLOW_PLUGIN; _loadEmuList(); - sources++; + if(m_combined_view) + for(vector::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++) + combinedList.push_back(*tmp_itr); } if((m_current_view == COVERFLOW_USB && !m_cfg.has(WII_DOMAIN, "source")) || m_cfg.getBool(WII_DOMAIN, "source")) { m_current_view = COVERFLOW_USB; _loadGameList(); - sources++; + if(m_combined_view) + for(vector::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++) + combinedList.push_back(*tmp_itr); } if((m_current_view == COVERFLOW_CHANNEL && !m_cfg.has(CHANNEL_DOMAIN, "source")) || m_cfg.getBool(CHANNEL_DOMAIN, "source")) { m_current_view = COVERFLOW_CHANNEL; _loadChannelList(); - sources++; + if(m_combined_view) + for(vector::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++) + combinedList.push_back(*tmp_itr); } if((m_current_view == COVERFLOW_DML && !m_cfg.has(GC_DOMAIN, "source")) || m_cfg.getBool(GC_DOMAIN, "source")) { m_current_view = COVERFLOW_DML; _loadDmlList(); - sources++; + if(m_combined_view) + for(vector::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++) + combinedList.push_back(*tmp_itr); } if((m_current_view == COVERFLOW_HOMEBREW && !m_cfg.has(HOMEBREW_DOMAIN, "source")) || m_cfg.getBool(HOMEBREW_DOMAIN, "source")) { m_current_view = COVERFLOW_HOMEBREW; _loadHomebrewList(); - sources++; + if(m_combined_view) + for(vector::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++) + combinedList.push_back(*tmp_itr); } - if(sources > 1) + if(m_combined_view) + { m_current_view = COVERFLOW_MAX; + m_gameList.clear(); + for(vector::iterator tmp_itr = combinedList.begin(); tmp_itr != combinedList.end(); tmp_itr++) + m_gameList.push_back(*tmp_itr); + combinedList.clear(); + } gprintf("Games found: %i\n", m_gameList.size()); return m_gameList.size() > 0 ? true : false; @@ -2230,6 +2180,7 @@ bool CMenu::_loadGameList(void) if(!DeviceHandle.IsInserted(currentPartition)) return false; + m_gameList.clear(); DeviceHandle.OpenWBFS(currentPartition); string gameDir(fmt(wii_games_dir, DeviceName[currentPartition])); string cacheDir(fmt("%s/%s_wii.db", m_listCacheDir.c_str(), DeviceName[currentPartition])); @@ -2246,6 +2197,7 @@ bool CMenu::_loadHomebrewList() if(!DeviceHandle.IsInserted(currentPartition)) return false; + m_gameList.clear(); string gameDir(fmt(HOMEBREW_DIR, DeviceName[currentPartition])); string cacheDir(fmt("%s/%s_homebrew.db", m_listCacheDir.c_str(), DeviceName[currentPartition])); bool updateCache = m_cfg.getBool(HOMEBREW_DOMAIN, "update_cache"); @@ -2260,6 +2212,7 @@ bool CMenu::_loadDmlList() if(!DeviceHandle.IsInserted(currentPartition)) return false; + m_gameList.clear(); string gameDir(fmt(currentPartition == SD ? DML_DIR : m_DMLgameDir.c_str(), DeviceName[currentPartition])); string cacheDir(fmt("%s/%s_gamecube.db", m_listCacheDir.c_str(), DeviceName[currentPartition])); bool updateCache = m_cfg.getBool(GC_DOMAIN, "update_cache"); diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index 152efdea..16a7cfc8 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -49,7 +49,8 @@ public: const char *getBlankCoverPath(const dir_discHdr *element); u8 m_current_view; - int m_last_view; + u8 m_last_view; + bool m_combined_view; u8 enabledPluginPos; u8 enabledPluginsCount; char PluginMagicWord[9]; @@ -89,6 +90,7 @@ private: bool m_favorites; bool m_music_info; bool m_use_source; + bool m_load_view; s16 m_showtimer; string m_curLanguage; @@ -624,7 +626,6 @@ private: bool enable_wmote_roll; bool m_cfNeedsUpdate; - bool LastViewRequested(void); void SetupInput(bool reset_pos = false); void ScanInput(void); diff --git a/source/menu/menu_explorer.cpp b/source/menu/menu_explorer.cpp index 8e875d28..f8c65936 100644 --- a/source/menu/menu_explorer.cpp +++ b/source/menu/menu_explorer.cpp @@ -99,7 +99,10 @@ void CMenu::_Explorer(void) { _mainLoopCommon(); if(BTN_HOME_PRESSED || BTN_B_PRESSED) + { + memset(folderPath, 0, MAX_FAT_PATH); break; + } else if(BTN_PLUS_PRESSED) { _refreshExplorer(1); @@ -120,12 +123,14 @@ void CMenu::_Explorer(void) } else if(m_btnMgr.selected(m_explorerBtnSet)) { - //only when set is clicked do we set folderPath to dir - strcpy(folderPath, dir); + strcpy(folderPath, dir); break; } else if(m_btnMgr.selected(m_explorerBtnBack)) + { + memset(folderPath, 0, MAX_FAT_PATH); break; + } //if "..." is selected and path is not empty then go up(back) one folder else if(m_btnMgr.selected(entries_sel[0]) && dir[0] != '\0') { diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index 831bbdd0..3901dc1a 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -538,26 +538,22 @@ void CMenu::_game(bool launch) memcpy(hdr, CoverFlow.getHdr(), sizeof(dir_discHdr)); m_gcfg2.load(fmt("%s/" GAME_SETTINGS2_FILENAME, m_settingsDir.c_str())); // change to current games partition and set last_view for recall later + m_cfg.setInt("GENERAL", "last_view", m_current_view); switch(hdr->type) { case TYPE_CHANNEL: - m_cfg.setInt("GENERAL", "last_view", COVERFLOW_CHANNEL); currentPartition = m_cfg.getInt(CHANNEL_DOMAIN, "partition", 1); break; case TYPE_HOMEBREW: - m_cfg.setInt("GENERAL", "last_view", COVERFLOW_HOMEBREW); currentPartition = m_cfg.getInt(HOMEBREW_DOMAIN, "partition", 1); break; case TYPE_GC_GAME: - m_cfg.setInt("GENERAL", "last_view", COVERFLOW_DML); currentPartition = m_cfg.getInt(GC_DOMAIN, "partition", 1); break; case TYPE_WII_GAME: - m_cfg.setInt("GENERAL", "last_view", COVERFLOW_USB); currentPartition = m_cfg.getInt(WII_DOMAIN, "partition", 1); break; default: - m_cfg.setInt("GENERAL", "last_view", COVERFLOW_PLUGIN); _checkForSinglePlugin(); if(enabledPluginsCount == 1) { diff --git a/source/menu/menu_main.cpp b/source/menu/menu_main.cpp index 2f76325d..e5296d92 100644 --- a/source/menu/menu_main.cpp +++ b/source/menu/menu_main.cpp @@ -181,6 +181,7 @@ void CMenu::_showMain(void) void CMenu::LoadView(void) { + m_load_view = false; _hideMain(true); CoverFlow.clear(); if(!m_vid.showingWaitMessage()) @@ -223,14 +224,6 @@ void CMenu::exitHandler(int ExitTo) Sys_ExitTo(ExitTo); } -bool CMenu::LastViewRequested(void) -{ - int view = m_cfg.getInt("GENERAL", "last_view", COVERFLOW_MAX); - if(view < COVERFLOW_USB || view >= COVERFLOW_MAX) - return false; - return true; -} - int CMenu::main(void) { wstringEx curLetter; @@ -259,17 +252,21 @@ int CMenu::main(void) m_GameTDBLoaded = true; m_gametdb.CloseFile(); } - m_last_view = m_cfg.getInt("GENERAL", "last_view"); - if(!(m_last_view < COVERFLOW_USB || m_last_view >= COVERFLOW_MAX)) - m_current_view = m_last_view; - else if(m_Emulator_boot) - m_current_view = COVERFLOW_PLUGIN; - m_cfg.remove("GENERAL", "last_view"); - if(m_cfg.getBool("GENERAL", "update_cache", false)) + m_last_view = max(0, min(m_cfg.getInt("GENERAL", "last_view", 6), 6)); + if(m_last_view == 6 || m_last_view == 0) { - UpdateCache(); - //m_gameList.Update(); + m_last_view = 0; + _clearSources(); + m_cfg.setBool(WII_DOMAIN, "source", true); } + m_current_view = m_last_view; + m_cfg.remove("GENERAL", "last_view"); + m_cfg.save(); + if(m_current_view == COVERFLOW_MAX) + m_combined_view = true; + + if(m_cfg.getBool("GENERAL", "update_cache", false)) + UpdateCache(); LoadView(); if(m_cfg.getBool("GENERAL", "startup_menu", false)) { @@ -278,9 +275,10 @@ int CMenu::main(void) LoadView(); else { - _showMain(); if(BTN_B_HELD) bUsed = true; + _initCF(); + _showMain(); } } @@ -304,9 +302,10 @@ int CMenu::main(void) LoadView(); else { - _showMain(); if(BTN_B_HELD) bUsed = true; + _initCF(); + _showMain(); } continue; } @@ -324,11 +323,7 @@ int CMenu::main(void) m_current_view = COVERFLOW_CHANNEL; if(lastView == m_current_view) m_current_view = COVERFLOW_HOMEBREW; - m_cfg.setBool(WII_DOMAIN, "source", false); - m_cfg.setBool(GC_DOMAIN, "source", false); - m_cfg.setBool(CHANNEL_DOMAIN, "source", false); - m_cfg.setBool(HOMEBREW_DOMAIN, "source", false); - m_cfg.setBool(PLUGIN_DOMAIN, "source", false); + _clearSources(); switch(m_current_view) { case COVERFLOW_USB: @@ -347,6 +342,7 @@ int CMenu::main(void) m_cfg.setBool(PLUGIN_DOMAIN, "source", true); } m_catStartPage = 1; + m_combined_view = false; LoadView(); continue; } @@ -386,11 +382,7 @@ int CMenu::main(void) m_current_view = (show_homebrew && (parental_homebrew || !m_locked)) ? COVERFLOW_HOMEBREW : COVERFLOW_USB; else if(m_current_view == COVERFLOW_HOMEBREW || m_current_view == COVERFLOW_MAX) m_current_view = COVERFLOW_USB; - m_cfg.setBool(WII_DOMAIN, "source", false); - m_cfg.setBool(GC_DOMAIN, "source", false); - m_cfg.setBool(CHANNEL_DOMAIN, "source", false); - m_cfg.setBool(HOMEBREW_DOMAIN, "source", false); - m_cfg.setBool(PLUGIN_DOMAIN, "source", false); + _clearSources(); switch(m_current_view) { case COVERFLOW_USB: @@ -409,6 +401,7 @@ int CMenu::main(void) m_cfg.setBool(PLUGIN_DOMAIN, "source", true); } m_catStartPage = 1; + m_combined_view = false; LoadView(); } else if(m_btnMgr.selected(m_mainBtnInit)) @@ -442,7 +435,6 @@ int CMenu::main(void) } else if(m_btnMgr.selected(m_mainBtnConfig)) { - string prevNand = m_cfg.getString(CHANNEL_DOMAIN, "path"); _hideMain(); _config(1); if(prevTheme != m_cfg.getString("GENERAL", "theme")) @@ -450,11 +442,12 @@ int CMenu::main(void) m_reload = true; break; } - _showMain(); if(BTN_B_HELD) bUsed = true; - if(prevNand != m_cfg.getString(CHANNEL_DOMAIN, "path") && m_cfg.getBool(CHANNEL_DOMAIN, "source")) + if(m_load_view) LoadView(); + else + _showMain(); } else if(m_btnMgr.selected(m_mainBtnInfo)) { diff --git a/source/menu/menu_nandemu.cpp b/source/menu/menu_nandemu.cpp index 0f2df461..c99a83c7 100644 --- a/source/menu/menu_nandemu.cpp +++ b/source/menu/menu_nandemu.cpp @@ -388,6 +388,9 @@ int CMenu::_NandEmuCfg(void) strncpy(tmpPath, strchr(path, '/'), MAX_FAT_PATH-1); m_cfg.setString(CHANNEL_DOMAIN, "path", tmpPath); m_cfg.setBool(CHANNEL_DOMAIN, "update_cache", true); + if(m_cfg.getBool(CHANNEL_DOMAIN, "source")) + m_load_view = true; + } _showNandEmu(); } diff --git a/source/menu/menu_source.cpp b/source/menu/menu_source.cpp index 6abc96a8..edefdbcb 100644 --- a/source/menu/menu_source.cpp +++ b/source/menu/menu_source.cpp @@ -141,7 +141,11 @@ void CMenu::_updateSourceBtns(void) ImgName = m_source.getString(fmt("BUTTON_%i", i + j),"image_s", "").c_str(); } else if(m_cfg.getBool(CHANNEL_DOMAIN, "source", false) && !m_cfg.getBool(CHANNEL_DOMAIN, "disable") && btnSource == "emunand") + { + sourceBtn = i + j; + selectedBtns++; ImgName = m_source.getString(fmt("BUTTON_%i", i + j),"image_s", "").c_str(); + } } else if(btnSource != "realnand" && btnSource != "emunand" && btnSource != "plugin" && btnSource != "allplugins") { @@ -183,6 +187,7 @@ void CMenu::_showSourceNotice(void) bool CMenu::_Source() { + CoverFlow.clear(); u8 i, j, k; bool show_homebrew = !m_cfg.getBool(HOMEBREW_DOMAIN, "disable", false); bool show_channel = !m_cfg.getBool("GENERAL", "hidechannel", false); @@ -273,6 +278,8 @@ bool CMenu::_Source() } if(selectedBtns == 0) m_cfg.setBool(WII_DOMAIN, "source", true); + if(selectedBtns > 1) + m_combined_view = true; break; } else if(BTN_UP_PRESSED) @@ -546,6 +553,7 @@ bool CMenu::_Source() } if(exitSource) { + m_combined_view = false; noChanges = false; break; }