From c1bfa9195bdec2cfdd10b6578ce456db0d79e2a0 Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Sat, 10 Mar 2012 19:02:59 +0000 Subject: [PATCH] -fixed incorrect url which was displayed if no cheat file found -added possibility to cheat in gamecube games, currently wiiflow gct cheats folder needs to be on sd card for this, otherwise DML cant find them --- source/menu/menu.cpp | 4 ++-- source/menu/menu_cheat.cpp | 33 +++++++++++++++++--------------- source/menu/menu_config_game.cpp | 24 ++++++++++++++--------- source/menu/menu_game.cpp | 16 ++++++++++++++-- 4 files changed, 49 insertions(+), 28 deletions(-) diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 43210304..8b0d4000 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -260,7 +260,7 @@ void CMenu::init(void) m_dataDir = sfmt("%s:/%s", drive, APPDATA_DIR); gprintf("Data Directory: %s\n", m_dataDir.c_str()); - + m_dol = sfmt("%s/boot.dol", m_appDir.c_str()); m_ver = sfmt("%s/versions", m_appDir.c_str()); m_app_update_zip = sfmt("%s/update.zip", m_appDir.c_str()); @@ -285,7 +285,7 @@ void CMenu::init(void) const char *domain = _domainFromView(); const char *checkDir = m_current_view == COVERFLOW_HOMEBREW ? HOMEBREW_DIR : GAMES_DIR; - + u8 partition = m_cfg.getInt(domain, "partition", 0); //Auto find a valid partition and fix old ini partition settings. if(m_current_view != COVERFLOW_CHANNEL && (partition > USB8 || !DeviceHandler::Instance()->IsInserted(partition))) { diff --git a/source/menu/menu_cheat.cpp b/source/menu/menu_cheat.cpp index 4ee4a56f..a2d053d3 100644 --- a/source/menu/menu_cheat.cpp +++ b/source/menu/menu_cheat.cpp @@ -59,7 +59,7 @@ u32 CMenu::_downloadCheatFileAsync(void *obj) if (cheatfile.data != NULL && cheatfile.size > 65 && cheatfile.data[0] != '<') { FILE *file = fopen(fmt("%s/%s.txt", m->m_txtCheatDir.c_str(), id.c_str()), "wb"); - + if (file != NULL) { fwrite(cheatfile.data, 1, cheatfile.size, file); @@ -77,8 +77,10 @@ void CMenu::_CheatSettings() { SetupInput(); + string id = m_cf.getId(); + m_cheatSettingsPage = 1; - int txtavailable = m_cheatfile.openTxtfile(fmt("%s/%s.txt", m_txtCheatDir.c_str(), m_cf.getId().c_str())); + int txtavailable = m_cheatfile.openTxtfile(fmt("%s/%s.txt", m_txtCheatDir.c_str(), id.c_str())); _showCheatSettings(); _textCheatSettings(); @@ -119,10 +121,10 @@ void CMenu::_CheatSettings() } else if ((WBTN_2_HELD && WBTN_1_PRESSED) || (WBTN_1_HELD && WBTN_2_PRESSED)) { - remove(fmt("%s/%s.gct", m_cheatDir.c_str(), m_cf.getId().c_str())); - remove(fmt("%s/%s.txt", m_txtCheatDir.c_str(), m_cf.getId().c_str())); - m_gcfg2.remove(m_cf.getId(), "cheat"); - m_gcfg2.remove(m_cf.getId(), "hooktype"); + remove(fmt("%s/%s.gct", m_cheatDir.c_str(), id.c_str())); + remove(fmt("%s/%s.txt", m_txtCheatDir.c_str(), id.c_str())); + m_gcfg2.remove(id, "cheat"); + m_gcfg2.remove(id, "hooktype"); break; } else if (BTN_A_PRESSED) @@ -152,17 +154,17 @@ void CMenu::_CheatSettings() if (selected) { - m_cheatfile.createGCT(fmt("%s/%s.gct", m_cheatDir.c_str(), m_cf.getId().c_str())); - m_gcfg2.setOptBool(m_cf.getId(), "cheat", 1); - m_gcfg2.setInt(m_cf.getId(), "hooktype", m_gcfg2.getInt(m_cf.getId(), "hooktype", 1)); + m_cheatfile.createGCT(fmt("%s/%s.gct", m_cheatDir.c_str(), id.c_str())); + m_gcfg2.setOptBool(id, "cheat", 1); + m_gcfg2.setInt(id, "hooktype", m_gcfg2.getInt(id, "hooktype", 1)); } else { - remove(fmt("%s/%s.gct", m_cheatDir.c_str(), m_cf.getId().c_str())); - m_gcfg2.remove(m_cf.getId(), "cheat"); - m_gcfg2.remove(m_cf.getId(), "hooktype"); + remove(fmt("%s/%s.gct", m_cheatDir.c_str(), id.c_str())); + m_gcfg2.remove(id, "cheat"); + m_gcfg2.remove(id, "hooktype"); } - m_cheatfile.createTXT(fmt("%s/%s.txt", m_txtCheatDir.c_str(), m_cf.getId().c_str())); + m_cheatfile.createTXT(fmt("%s/%s.txt", m_txtCheatDir.c_str(), id.c_str())); break; } else if (m_btnMgr.selected(m_cheatBtnDownload)) @@ -234,7 +236,7 @@ void CMenu::_CheatSettings() } _hideCheatDownload(); - txtavailable = m_cheatfile.openTxtfile(fmt("%s/%s.txt", m_txtCheatDir.c_str(), m_cf.getId().c_str())); + txtavailable = m_cheatfile.openTxtfile(fmt("%s/%s.txt", m_txtCheatDir.c_str(), id.c_str())); _showCheatSettings(); if (txtavailable) @@ -245,8 +247,9 @@ void CMenu::_CheatSettings() if (m_cheatfile.getCnt() == 0) { // cheat code not found, show result + char type = id[0] == 'S' ? 'R' : id[0]; m_btnMgr.setText(m_cheatLblItem[0], _t("cheat4", L"Download not found.")); - m_btnMgr.setText(m_cheatLblItem[1], sfmt(GECKOURL, m_cf.getId().c_str())); + m_btnMgr.setText(m_cheatLblItem[1], sfmt(GECKOURL, type, id.c_str())); m_btnMgr.show(m_cheatLblItem[1]); } } diff --git a/source/menu/menu_config_game.cpp b/source/menu/menu_config_game.cpp index f4502ea0..cf38ed36 100644 --- a/source/menu/menu_config_game.cpp +++ b/source/menu/menu_config_game.cpp @@ -119,7 +119,7 @@ void CMenu::_showGameSettings(void) if(m_current_view != COVERFLOW_DML) g_numGCfPages = 4; else - g_numGCfPages = 1; + g_numGCfPages = 2; if (m_gameSettingsPage == 1) { @@ -194,10 +194,13 @@ void CMenu::_showGameSettings(void) m_btnMgr.show(m_gameSettingsBtnDebuggerP); m_btnMgr.show(m_gameSettingsBtnDebuggerM); - m_btnMgr.show(m_gameSettingsLblHooktype); - m_btnMgr.show(m_gameSettingsLblHooktypeVal); - m_btnMgr.show(m_gameSettingsBtnHooktypeM); - m_btnMgr.show(m_gameSettingsBtnHooktypeP); + if(m_current_view != COVERFLOW_DML) + { + m_btnMgr.show(m_gameSettingsLblHooktype); + m_btnMgr.show(m_gameSettingsLblHooktypeVal); + m_btnMgr.show(m_gameSettingsBtnHooktypeM); + m_btnMgr.show(m_gameSettingsBtnHooktypeP); + } m_btnMgr.show(m_gameSettingsLblOcarina); m_btnMgr.show(m_gameSettingsBtnOcarina); @@ -212,10 +215,13 @@ void CMenu::_showGameSettings(void) m_btnMgr.hide(m_gameSettingsBtnDebuggerP); m_btnMgr.hide(m_gameSettingsBtnDebuggerM); - m_btnMgr.hide(m_gameSettingsLblHooktype); - m_btnMgr.hide(m_gameSettingsLblHooktypeVal); - m_btnMgr.hide(m_gameSettingsBtnHooktypeM); - m_btnMgr.hide(m_gameSettingsBtnHooktypeP); + if(m_current_view != COVERFLOW_DML) + { + m_btnMgr.hide(m_gameSettingsLblHooktype); + m_btnMgr.hide(m_gameSettingsLblHooktypeVal); + m_btnMgr.hide(m_gameSettingsBtnHooktypeM); + m_btnMgr.hide(m_gameSettingsBtnHooktypeP); + } m_btnMgr.hide(m_gameSettingsLblOcarina); m_btnMgr.hide(m_gameSettingsBtnOcarina); diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index c07653b9..d9dec999 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -639,9 +639,21 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool DML) memset(DMLCfg, 0, sizeof(DML_CFG)); DMLCfg->Magicbytes = 0xD1050CF6; DMLCfg->CfgVersion = 0x00000001; - DMLCfg->VideoMode = DML_VID_NONE; - DMLCfg->Config = DML_CFG_GAME_PATH; + DMLCfg->VideoMode |= DML_VID_NONE; + DMLCfg->Config |= DML_CFG_GAME_PATH; snprintf(DMLCfg->GamePath, sizeof(DMLCfg->GamePath), "/games/%s/game.iso", hdr->path); + if(m_gcfg2.testOptBool((char *)hdr->hdr.id, "cheat", m_cfg.getBool("GAMES", "cheat", false))) + { + DMLCfg->Config |= DML_CFG_CHEATS; + DMLCfg->Config |= DML_CFG_CHEAT_PATH; + const char *ptr; + if(strstr(m_cheatDir.c_str(), "sd:/") != NULL) + { + ptr = &m_cheatDir.c_str()[3]; + snprintf(DMLCfg->CheatPath, sizeof(DMLCfg->CheatPath), "%s/%s", ptr, fmt("%s.gct", hdr->hdr.id)); + } + gprintf("Cheat dir: %s\n", DMLCfg->CheatPath); + } memcpy((void *)0xC0001700, DMLCfg, sizeof(DML_CFG)); MEM2_free(DMLCfg); }