Skip to content

Commit

Permalink
multi mission step 1
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvita committed Oct 13, 2020
1 parent a7f82c9 commit 1842363
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 8 deletions.
3 changes: 2 additions & 1 deletion include/guis/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ enum gui_t {
GUI_TX_WARNING,
GUI_CHEATS,
GUI_GUIDE,
GUI_ABOUT
GUI_ABOUT,
GUI_CHOOSE_MISSION
};

class Gui {
Expand Down
19 changes: 19 additions & 0 deletions include/guis/gui_choose_mission.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include "guis/gui.hpp"

#include <vector>
#include <unordered_map>
#include <stdbool.h>
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);
};
2 changes: 1 addition & 1 deletion include/helpers/memory_dump.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <string>
#include <vector>
extern bool print_details;
extern std::string m_edizon_dir; //
extern std::string m_edizon_dir;
// extern bool m_compress = false;
class MemoryDump
{
Expand Down
84 changes: 84 additions & 0 deletions source/guis/gui_choose_mission.cpp
Original file line number Diff line number Diff line change
@@ -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) {

}
6 changes: 5 additions & 1 deletion source/helpers/memory_dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
49 changes: 44 additions & 5 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;
Expand Down Expand Up @@ -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");
Expand All @@ -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()
Expand Down Expand Up @@ -185,7 +204,6 @@ void redirectStdio()
dup2(debugOutputFile, STDERR_FILENO);
}
}

int main(int argc, char **argv)
{
void *haddr;
Expand All @@ -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)
Expand All @@ -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();

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1842363

Please sign in to comment.