From e7cae7cf243f8e14b14c325a6742fc108d8cba23 Mon Sep 17 00:00:00 2001 From: tomvita <68505331+tomvita@users.noreply.github.com> Date: Sun, 20 Dec 2020 16:32:40 +0800 Subject: [PATCH] Auto import cheats when in database if there were no cheats before otherwise need overwrite flag --- source/guis/gui_cheats.cpp | 30 ++++++++++++++++++++---------- source/guis/gui_choose_mission.cpp | 2 +- source/main.cpp | 1 + 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/source/guis/gui_cheats.cpp b/source/guis/gui_cheats.cpp index 7cc8ff8b..7b8f9e34 100644 --- a/source/guis/gui_cheats.cpp +++ b/source/guis/gui_cheats.cpp @@ -5811,15 +5811,21 @@ void GuiCheats::_moveLonelyCheats(u8 *buildID, u64 titleID) realCheatPath << buildIDStr.str() << ".txt"; REPLACEFILE(lonelyCheatPath.str().c_str(), realCheatPath.str().c_str()); - (new MessageBox("A new cheat has been added for this title. \n Please restart the game to start using it.", MessageBox::OKAY))->show(); + if (!(m_debugger->m_dmnt)) + { + m_debugger->detatch(); + dmntchtForceOpenCheatProcess(); + printf("force open called\n"); + } + else + (new MessageBox("A new cheat has been added for this title. \n Please restart the game to start using it.", MessageBox::OKAY))->show(); } // Move cheat from code database if exist std::stringstream zipPath; zipPath << EDIZON_DIR "/cheats/" << "titles.zip"; Config::readConfig(); - if (access(zipPath.str().c_str(), F_OK) == 0 && Config::getConfig()->enablecheats) + if (access(zipPath.str().c_str(), F_OK) == 0)// && Config::getConfig()->enablecheats) { - Config::getConfig()->enablecheats = false; Config::writeConfig(); realCheatPath.str(""); realCheatPath << "/atmosphere/contents/" << std::uppercase << std::hex << std::setfill('0') << std::setw(sizeof(u64) * 2) << titleID; @@ -5835,16 +5841,20 @@ void GuiCheats::_moveLonelyCheats(u8 *buildID, u64 titleID) // zipCheatPath << "titles\\" << std::uppercase << std::hex << std::setfill('0') << std::setw(sizeof(u64) * 2) << titleID << "\\cheats\\" << buildIDStr.str() << ".txt"; // zipCheatPath << buildIDStr.str() << ".txt"; zipper::Unzipper cheatzip(zipPath.str().c_str()); // cheatzip; - if (cheatzip.extractEntry(zipCheatPath.str().c_str(),realCheatPath.str().c_str())) + if (!(access(realCheatPath.str().c_str(), F_OK) == 0) || Config::getConfig()->enablecheats) { - if (!(m_debugger->m_dmnt)) + Config::getConfig()->enablecheats = false; + if (cheatzip.extractEntry(zipCheatPath.str().c_str(), realCheatPath.str().c_str())) { - m_debugger->detatch(); - dmntchtForceOpenCheatProcess(); - printf("force open called\n"); + if (!(m_debugger->m_dmnt)) + { + m_debugger->detatch(); + dmntchtForceOpenCheatProcess(); + printf("force open called\n"); + } + else + (new MessageBox("A new cheat has been added for this title from database. \n Please reload dmnt or restart the game.", MessageBox::OKAY))->show(); } - else - (new MessageBox("A new cheat has been added for this title from database. \n Please reload dmnt or restart the game.", MessageBox::OKAY))->show(); } }// // else diff --git a/source/guis/gui_choose_mission.cpp b/source/guis/gui_choose_mission.cpp index 9e2ac2e8..4a627d4e 100644 --- a/source/guis/gui_choose_mission.cpp +++ b/source/guis/gui_choose_mission.cpp @@ -19,7 +19,7 @@ void GuiChooseMission::draw() { Gui::drawTextAligned(font20, Gui::g_framebuffer_width / 2, Gui::g_framebuffer_height / 2+60, COLOR_WHITE, "Use X, Y, - to toggle options, if you disable this screen use R+B to exit will show this on next launch", ALIGNED_CENTER); Gui::drawTextAligned(font20, Gui::g_framebuffer_width / 5, Gui::g_framebuffer_height / 2+200, Config::getConfig()->disablerangeonunknown ? COLOR_WHITE : COLOR_BLACK, "\uE0AF Disable Range on Unknown", ALIGNED_CENTER); Gui::drawTextAligned(font20, Gui::g_framebuffer_width / 5, Gui::g_framebuffer_height / 2+150, Config::getConfig()->separatebookmark ? COLOR_WHITE : COLOR_BLACK, "\uE0B1 Separate bookmark", ALIGNED_CENTER); - Gui::drawTextAligned(font20, Gui::g_framebuffer_width / 2, Gui::g_framebuffer_height / 2+200, Config::getConfig()->enablecheats ? COLOR_WHITE : COLOR_BLACK, "\uE0B2 Enable cheats import", ALIGNED_CENTER); + Gui::drawTextAligned(font20, Gui::g_framebuffer_width / 2, Gui::g_framebuffer_height / 2+200, Config::getConfig()->enablecheats ? COLOR_WHITE : COLOR_BLACK, "\uE0B2 Enable cheats overwrite", ALIGNED_CENTER); Gui::drawTextAligned(font20, Gui::g_framebuffer_width *4 / 5, Gui::g_framebuffer_height / 2+200, COLOR_BLACK, "\uE0B0 Update cheats database", ALIGNED_CENTER); Gui::drawTextAligned(font20, Gui::g_framebuffer_width / 5, Gui::g_framebuffer_height / 2+250, Config::getConfig()->deletebookmark ? COLOR_WHITE : COLOR_BLACK, "\uE0C4 clear all bookmarks", ALIGNED_CENTER); Gui::drawTextAligned(font20, Gui::g_framebuffer_width * 4 / 5, Gui::g_framebuffer_height / 2+250, (Config::getConfig()->freeze || Config::getConfig()->enabletargetedscan ) ? COLOR_WHITE : COLOR_BLACK, "\uE0C5 More options", ALIGNED_CENTER); diff --git a/source/main.cpp b/source/main.cpp index 3f0572a2..83d0ab87 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -130,6 +130,7 @@ bool firstruncheck() if (!Config::getConfig()->not_first_run) { Config::getConfig()->not_first_run = true; + Config::getConfig()->options[0] = true; // No Auto Attach for fetching of game code Config::writeConfig(); return true; }