From 1842363e0232ecdbef63bb947b7792f645db8f8a Mon Sep 17 00:00:00 2001 From: tomvita <68505331+tomvita@users.noreply.github.com> Date: Tue, 13 Oct 2020 18:15:39 +0800 Subject: [PATCH] multi mission step 1 --- include/guis/gui.hpp | 3 +- include/guis/gui_choose_mission.hpp | 19 +++++++ include/helpers/memory_dump.hpp | 2 +- source/guis/gui_choose_mission.cpp | 84 +++++++++++++++++++++++++++++ source/helpers/memory_dump.cpp | 6 ++- source/main.cpp | 49 +++++++++++++++-- 6 files changed, 155 insertions(+), 8 deletions(-) create mode 100644 include/guis/gui_choose_mission.hpp create mode 100644 source/guis/gui_choose_mission.cpp diff --git a/include/guis/gui.hpp b/include/guis/gui.hpp index 4a3a3e31..e11814cb 100644 --- a/include/guis/gui.hpp +++ b/include/guis/gui.hpp @@ -31,7 +31,8 @@ enum gui_t { GUI_TX_WARNING, GUI_CHEATS, GUI_GUIDE, - GUI_ABOUT + GUI_ABOUT, + GUI_CHOOSE_MISSION }; class Gui { diff --git a/include/guis/gui_choose_mission.hpp b/include/guis/gui_choose_mission.hpp new file mode 100644 index 00000000..3842ff3c --- /dev/null +++ b/include/guis/gui_choose_mission.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include "guis/gui.hpp" + +#include +#include +#include +extern std::string m_edizon_dir; +class GuiChooseMission : public Gui { +public: + GuiChooseMission(); + ~GuiChooseMission(); + + void update(); + void draw(); + void onInput(u32 kdown); + void onTouch(touchPosition &touch); + void onGesture(touchPosition startPosition, touchPosition endPosition, bool finish); +}; diff --git a/include/helpers/memory_dump.hpp b/include/helpers/memory_dump.hpp index 9999fe44..7c3d780e 100644 --- a/include/helpers/memory_dump.hpp +++ b/include/helpers/memory_dump.hpp @@ -5,7 +5,7 @@ #include #include extern bool print_details; -extern std::string m_edizon_dir; // +extern std::string m_edizon_dir; // extern bool m_compress = false; class MemoryDump { diff --git a/source/guis/gui_choose_mission.cpp b/source/guis/gui_choose_mission.cpp new file mode 100644 index 00000000..eea7af8c --- /dev/null +++ b/source/guis/gui_choose_mission.cpp @@ -0,0 +1,84 @@ +#include "guis/gui_choose_mission.hpp" + +#include "helpers/config.hpp" + +GuiChooseMission::GuiChooseMission() : Gui() { + Config::getConfig()->hideSX = false; +} + +GuiChooseMission::~GuiChooseMission() { + +} + +void GuiChooseMission::update() { + Gui::update(); +} + +void GuiChooseMission::draw() { + Gui::beginDraw(); + + Gui::drawRectangle(0, 0, Gui::g_framebuffer_width, Gui::g_framebuffer_height, Gui::makeColor(0x00, 0x39, 0x29, 0xFF)); + Gui::drawTextAligned(fontHuge, Gui::g_framebuffer_width / 2, Gui::g_framebuffer_height / 2 - 100, COLOR_WHITE, "\uE150", ALIGNED_CENTER); + + // Gui::drawTextAligned(font20, Gui::g_framebuffer_width / 2, Gui::g_framebuffer_height / 2, COLOR_WHITE, "EdiZon detected that you're running the 'SX OS' CFW. Please note that this CFW has erroneously\n implemented services that can cause unexpected failures, corruption of save data\n or backups, the editor failing to load save files or configs, RAM editing not being\n supported and other issues. For the safety of your Switch, use a free open\n source CFW instead. \n To continue anyway press \uE0E0, otherwise press \uE0E1 to exit.", ALIGNED_CENTER); + Gui::drawTextAligned(font20, Gui::g_framebuffer_width / 2, Gui::g_framebuffer_height / 2, currTheme.textColor, "Use L, R, ZL, ZR and B to choose storage directory for your search press A to continue", ALIGNED_CENTER); + Gui::drawTextAligned(font20, Gui::g_framebuffer_width / 2, Gui::g_framebuffer_height / 2 + 250, COLOR_WHITE, m_edizon_dir.c_str() , ALIGNED_CENTER);//"\uE070 Don't show this warning anymore" + + // if (!Config::getConfig()->hideSX) + // Gui::drawRectangle(Gui::g_framebuffer_width / 2 - 228, Gui::g_framebuffer_height / 2 + 258, 14, 16, Gui::makeColor(0xC5, 0x39, 0x29, 0xFF)); + + Gui::endDraw(); +} + // while (!(kheld & KEY_ZL)) + // { + // hidScanInput(); + // kheld = hidKeysHeld(CONTROLLER_PLAYER_1) | hidKeysHeld(CONTROLLER_HANDHELD); + // kdown = hidKeysDown(CONTROLLER_PLAYER_1)|hidKeysDown(CONTROLLER_HANDHELD); + // Gui::beginDraw(); + // Gui::drawRectangle(0, 0, Gui::g_framebuffer_width, Gui::g_framebuffer_height, currTheme.backgroundColor); + // Gui::drawTextAligned(fontHuge, Gui::g_framebuffer_width / 2, Gui::g_framebuffer_height / 2 - 100, currTheme.textColor, "\uE12C", ALIGNED_CENTER); + // Gui::drawTextAligned(font20, Gui::g_framebuffer_width / 2, Gui::g_framebuffer_height / 2, currTheme.textColor, "Use L, R and B to choose your sessoin directory press A to continue", ALIGNED_CENTER); + // Gui::drawTextAligned(font20, Gui::g_framebuffer_width - 50, Gui::g_framebuffer_height - 50, currTheme.textColor, "\uE0E1 Back", ALIGNED_RIGHT); + // Gui::endDraw(); + // } + // if (kheld & KEY_ZR) + // m_edizon_dir = "/switch/EdiZon1"; + // if (kheld & KEY_L) + // m_edizon_dir = "/switch/EdiZon2"; + // printf("%s\n", m_edizon_dir.c_str()); +void GuiChooseMission::onInput(u32 kdown) +{ + if (kdown & KEY_L) + { + m_edizon_dir = "/switch/EdiZon/1"; + } + else if (kdown & KEY_R) + { + m_edizon_dir = "/switch/EdiZon/2"; + } + if (kdown & KEY_ZL) + { + m_edizon_dir = "/switch/EdiZon/3"; + } + else if (kdown & KEY_ZR) + { + m_edizon_dir = "/switch/EdiZon/4"; + } + else if (kdown & KEY_B) + { + m_edizon_dir = "/switch/EdiZon"; + } + else if (kdown & KEY_A) + Gui::g_nextGui = GUI_CHEATS; +} + +void GuiChooseMission::onTouch(touchPosition &touch) { + if (touch.px > 400 && touch.px < 900 && touch.py > 600 && touch.py < 660) { + Config::getConfig()->hideSX = !Config::getConfig()->hideSX; + Config::writeConfig(); + } +} + +void GuiChooseMission::onGesture(touchPosition startPosition, touchPosition endPosition, bool finish) { + +} diff --git a/source/helpers/memory_dump.cpp b/source/helpers/memory_dump.cpp index 063295b6..2e962272 100644 --- a/source/helpers/memory_dump.cpp +++ b/source/helpers/memory_dump.cpp @@ -31,7 +31,11 @@ MemoryDump::MemoryDump(std::string filePath, DumpType dumpType, bool discardFile m_dataHeader.searchDataType = SEARCH_TYPE_NONE; m_dataHeader.searchMode = SEARCH_MODE_NONE; m_dataHeader.searchRegion = SEARCH_REGION_NONE; - + if (filePath.compare("/switch/EdiZon/memdump1.dat") == 0 || filePath.compare("/switch/EdiZon/memdump1a.dat") == 0 || filePath.compare("/switch/EdiZon/datadump2.dat") == 0) + { + filePath.replace(0, sizeof(EDIZON_DIR)-1, m_edizon_dir); + printf("%s\n", filePath.c_str()); + }; m_dumpFile = fopen(filePath.c_str(), "r"); if (m_dumpFile == nullptr) diff --git a/source/main.cpp b/source/main.cpp index 8c869b7a..19273b85 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -14,6 +14,7 @@ #include "guis/gui_main.hpp" #include "guis/gui_editor.hpp" #include "guis/gui_tx_warning.hpp" +#include "guis/gui_choose_mission.hpp" #include "guis/gui_cheats.hpp" #include "guis/gui_about.hpp" #include "guis/gui_guide.hpp" @@ -30,7 +31,7 @@ char *g_edizonPath; static int debugOutputFile; - +std::string m_edizon_dir = "/switch/EdiZon"; static bool updateThreadRunning = false; static Mutex mutexCurrGui; static Gui *currGui = nullptr; @@ -104,6 +105,17 @@ void update() } } +bool multimissioncheck() +{ + std::stringstream filenoiconStr; + filenoiconStr << EDIZON_DIR "/nomultimission.txt"; + if (access(filenoiconStr.str().c_str(), F_OK) != 0) + { + return true; + } + else + return false; +} void createFolders() { printf(EDIZON_DIR "/saves\n"); @@ -116,6 +128,13 @@ void createFolders() mkdir(EDIZON_DIR "/editor/scripts", 0777); mkdir(EDIZON_DIR "/editor/scripts/lib", 0777); mkdir(EDIZON_DIR "/editor/scripts/lib/python3.5", 0777); + if (multimissioncheck()) + { + mkdir(EDIZON_DIR "/1", 0777); + mkdir(EDIZON_DIR "/2", 0777); + mkdir(EDIZON_DIR "/3", 0777); + mkdir(EDIZON_DIR "/4", 0777); + }; } void requestDraw() @@ -185,7 +204,6 @@ void redirectStdio() dup2(debugOutputFile, STDERR_FILENO); } } - int main(int argc, char **argv) { void *haddr; @@ -205,7 +223,10 @@ int main(int argc, char **argv) if (l_debugger->getRunningApplicationPID() != 0) { Gui::g_splashDisplayed = true; - Gui::g_nextGui = GUI_CHEATS; + if (multimissioncheck()) + Gui::g_nextGui = GUI_CHOOSE_MISSION; + else + Gui::g_nextGui = GUI_CHEATS; } if (!Gui::g_splashDisplayed) @@ -216,8 +237,23 @@ int main(int argc, char **argv) Config::readConfig(); initTitles(); - - printf("%s\n", EDIZON_DIR); + // while (!(kheld & KEY_ZL)) + // { + // hidScanInput(); + // kheld = hidKeysHeld(CONTROLLER_PLAYER_1) | hidKeysHeld(CONTROLLER_HANDHELD); + // kdown = hidKeysDown(CONTROLLER_PLAYER_1)|hidKeysDown(CONTROLLER_HANDHELD); + // Gui::beginDraw(); + // Gui::drawRectangle(0, 0, Gui::g_framebuffer_width, Gui::g_framebuffer_height, currTheme.backgroundColor); + // Gui::drawTextAligned(fontHuge, Gui::g_framebuffer_width / 2, Gui::g_framebuffer_height / 2 - 100, currTheme.textColor, "\uE12C", ALIGNED_CENTER); + // Gui::drawTextAligned(font20, Gui::g_framebuffer_width / 2, Gui::g_framebuffer_height / 2, currTheme.textColor, "Use L and R to choose your sessoin press ZL to continue", ALIGNED_CENTER); + // Gui::drawTextAligned(font20, Gui::g_framebuffer_width - 50, Gui::g_framebuffer_height - 50, currTheme.textColor, "\uE0E1 Back", ALIGNED_RIGHT); + // Gui::endDraw(); + // } + // if (kheld & KEY_ZR) + // m_edizon_dir = "/switch/EdiZon1"; + // if (kheld & KEY_L) + // m_edizon_dir = "/switch/EdiZon2"; + // printf("%s\n", m_edizon_dir.c_str()); createFolders(); @@ -272,6 +308,9 @@ int main(int argc, char **argv) case GUI_ABOUT: currGui = new GuiAbout(); break; + case GUI_CHOOSE_MISSION: + currGui = new GuiChooseMission(); + break; case GUI_INVALID: [[fallthrough]] default : break;