A little Script Creator work and little checks. (#9)

* No builds allowed here.

* Try something.

* Next work.

* Add some Logging stuff for testing purpose.

* Ok, this should log it priperly.

* Replace MainMenu with Screen Selection.

* Redo Screen Logic.

* Switch back to old MainMenu.

* Only access Scriptlist, when Scripts are found.

Hopefully avoid crashes with that.

* Remove unused String, because we use the MainMenu again.
This commit is contained in:
StackZ
2019-12-17 19:22:39 +01:00
committed by GitHub
parent 5d80ec6111
commit 0a308c43e8
27 changed files with 847 additions and 361 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
trigger: trigger:
branches: branches:
include: ['*'] include: ['*']
exclude: [translation] exclude: [translation, script-creator-experimental]
tags: tags:
include: ['*'] include: ['*']
+1 -14
View File
@@ -32,27 +32,14 @@
#include "screens/screen.hpp" #include "screens/screen.hpp"
#include <3ds.h>
#include <citro2d.h>
#include <citro3d.h>
#include <random>
#include <stack>
#include <string.h>
#include <unordered_map>
#include <wchar.h>
namespace Gui namespace Gui
{ {
// Init and Exit of the GUI. // Init and Exit of the GUI.
Result init(void); Result init(void);
void exit(void); void exit(void);
// Screen and MainLoops.
void mainLoop(u32 hDown, u32 hHeld, touchPosition touch);
void setScreen(std::unique_ptr<Screen> screen);
void screenBack(void);
C3D_RenderTarget* target(gfxScreen_t t); C3D_RenderTarget* target(gfxScreen_t t);
void ScreenDraw(C3D_RenderTarget * screen); void setDraw(C3D_RenderTarget * screen);
// Clear Text. // Clear Text.
void clearTextBufs(void); void clearTextBufs(void);
+48
View File
@@ -0,0 +1,48 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef LOGGING_HPP
#define LOGGING_HPP
#include <fstream>
#include <stdarg.h>
#include <string>
#include <time.h>
#include <unistd.h>
namespace Logging {
// Create the Log File.
void createLogFile(void);
// Write to the Log.
void writeToLog(std::string debugText);
// Other needed stuff. ;P
std::string logDate(void);
std::string format(const std::string& fmt_str, ...);
}
#endif
+1 -1
View File
@@ -26,7 +26,7 @@
#include "screens/screen.hpp" #include "screens/screen.hpp"
class FTPScreen : public Screen class FTPScreen : public screen
{ {
public: public:
void Draw(void) const override; void Draw(void) const override;
+4 -2
View File
@@ -29,18 +29,20 @@
#include "screens/screen.hpp" #include "screens/screen.hpp"
#include "utils/fileBrowse.h"
#include "utils/structs.hpp" #include "utils/structs.hpp"
#include <vector> #include <vector>
class MainMenu : public Screen class MainMenu : public screen
{ {
public: public:
void Draw(void) const override; void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override; void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
private: private:
bool returnScriptState();
int Selection = 0; int Selection = 0;
std::vector<DirEntry> dirContents; // To return Script state.
std::vector<Structs::ButtonPos> mainButtons = { std::vector<Structs::ButtonPos> mainButtons = {
{10, 40, 140, 35, -1}, // Scriptlist. {10, 40, 140, 35, -1}, // Scriptlist.
{170, 40, 140, 35, -1}, // ScriptBrowse. {170, 40, 140, 35, -1}, // ScriptBrowse.
+35 -2
View File
@@ -1,16 +1,49 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SCREEN_HPP #ifndef SCREEN_HPP
#define SCREEN_HPP #define SCREEN_HPP
#include <3ds.h> #include <3ds.h>
#include <memory> #include <memory>
class Screen class screen
{ {
public: public:
virtual ~Screen() {} virtual ~screen() {}
virtual void Logic(u32 hDown, u32 hHeld, touchPosition touch) = 0; virtual void Logic(u32 hDown, u32 hHeld, touchPosition touch) = 0;
virtual void Draw() const = 0; virtual void Draw() const = 0;
private: private:
}; };
namespace Screen {
void set(std::unique_ptr<screen> screen2);
void fade(std::unique_ptr<screen> screen2, bool fadeout = true);
void back(void);
void loop(u32 hDown, u32 hHeld, touchPosition touch);
}
#endif #endif
+1 -1
View File
@@ -33,7 +33,7 @@
#include "utils/config.hpp" #include "utils/config.hpp"
#include "utils/fileBrowse.h" #include "utils/fileBrowse.h"
class ScriptBrowse : public Screen class ScriptBrowse : public screen
{ {
public: public:
void Draw(void) const override; void Draw(void) const override;
+40 -3
View File
@@ -35,21 +35,45 @@
#include <vector> #include <vector>
class ScriptCreator : public Screen class ScriptCreator : public screen
{ {
public: public:
void Draw(void) const override; void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override; void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
ScriptCreator();
private: private:
// Screen draws.
void DrawSubMenu(void) const;
void DrawScriptScreen(void) const;
void SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch);
void scriptLogic(u32 hDown, u32 hHeld, touchPosition touch);
// Selection + Mode.
int Selection = 0; int Selection = 0;
int mode = 0;
int page = 0;
// Functions.
void openJson(std::string fileName); void openJson(std::string fileName);
void createNewJson(std::string fileName); void createNewJson(std::string fileName);
void save(); void save();
void setInfoStuff(void); void setInfoStuff(void);
void createDownloadRelease();
// Creating Functions. -> Page 1.
void createDownloadRelease();
void createDownloadFile();
void createDeleteFile();
void createExtractFile();
void createInstallCia();
void createMkDir();
// Creating Functions. -> Page 2.
void createRmDir();
void createMkFile();
void createTimeMsg();
//
void setBool(const std::string &object, const std::string &key, bool v); void setBool(const std::string &object, const std::string &key, bool v);
void setBool2(const std::string &object, const std::string &key, const std::string &key2, bool v); void setBool2(const std::string &object, const std::string &key, const std::string &key2, bool v);
@@ -61,10 +85,23 @@ private:
void createEntry(const std::string &Entryname); void createEntry(const std::string &Entryname);
std::string jsonFileName;
// Main Pos.
std::vector<Structs::ButtonPos> mainButtons = { std::vector<Structs::ButtonPos> mainButtons = {
{90, 40, 140, 35, -1}, // New Script. {90, 40, 140, 35, -1}, // New Script.
{90, 100, 140, 35, -1}, // Existing Script. {90, 100, 140, 35, -1}, // Existing Script.
}; };
// Creator Button Pos.
std::vector<Structs::ButtonPos> creatorButtons = {
{10, 40, 140, 35, -1},
{170, 40, 140, 35, -1},
{10, 100, 140, 35, -1},
{170, 100, 140, 35, -1},
{10, 160, 140, 35, -1},
{170, 160, 140, 35, -1},
};
}; };
#endif #endif
+1 -1
View File
@@ -32,7 +32,7 @@
#include "utils/fileBrowse.h" #include "utils/fileBrowse.h"
class ScriptList : public Screen class ScriptList : public screen
{ {
public: public:
void Draw(void) const override; void Draw(void) const override;
+1 -1
View File
@@ -34,7 +34,7 @@
#include <vector> #include <vector>
class Settings : public Screen class Settings : public screen
{ {
public: public:
void Draw(void) const override; void Draw(void) const override;
+1 -1
View File
@@ -30,7 +30,7 @@
#include "screens/screen.hpp" #include "screens/screen.hpp"
#include "screens/screenCommon.hpp" #include "screens/screenCommon.hpp"
class TinyDB : public Screen class TinyDB : public screen
{ {
public: public:
void Draw(void) const override; void Draw(void) const override;
+1
View File
@@ -32,6 +32,7 @@
namespace Config { namespace Config {
extern int lang, Color1, Color2, Color3, TxtColor, SelectedColor, UnselectedColor, viewMode, ColorKeys, progressbarColor; extern int lang, Color1, Color2, Color3, TxtColor, SelectedColor, UnselectedColor, viewMode, ColorKeys, progressbarColor;
extern std::string ScriptPath, MusicPath; extern std::string ScriptPath, MusicPath;
extern bool Logging;
void load(); void load();
void save(); void save();
+3 -1
View File
@@ -75,5 +75,7 @@
"DESC": "Desc: ", "DESC": "Desc: ",
"RELEASE_ID": "Release ID: ", "RELEASE_ID": "Release ID: ",
"TITLE_ID": "Title ID: ", "TITLE_ID": "Title ID: ",
"FILE_SIZE": "File size: " "FILE_SIZE": "File size: ",
"GET_SCRIPTS_FIRST": "Get some Scripts first!"
} }
+15 -15
View File
@@ -119,13 +119,13 @@ curl_off_t downloadTotal = 1; //Dont initialize with 0 to avoid division by zero
curl_off_t downloadNow = 0; curl_off_t downloadNow = 0;
static int curlProgress(CURL *hnd, static int curlProgress(CURL *hnd,
curl_off_t dltotal, curl_off_t dlnow, curl_off_t dltotal, curl_off_t dlnow,
curl_off_t ultotal, curl_off_t ulnow) curl_off_t ultotal, curl_off_t ulnow)
{ {
downloadTotal = dltotal; downloadTotal = dltotal;
downloadNow = dlnow; downloadNow = dlnow;
return 0; return 0;
} }
static Result setupContext(CURL *hnd, const char * url) static Result setupContext(CURL *hnd, const char * url)
@@ -673,21 +673,21 @@ void displayProgressBar() {
} }
Gui::clearTextBufs(); Gui::clearTextBufs();
C3D_FrameBegin(C3D_FRAME_SYNCDRAW); C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
C2D_TargetClear(top, BLACK); C2D_TargetClear(top, BLACK);
C2D_TargetClear(bottom, BLACK); C2D_TargetClear(bottom, BLACK);
Gui::DrawTop(); Gui::DrawTop();
Gui::DrawStringCentered(0, 1, 0.7f, Config::TxtColor, progressBarMsg, 400); Gui::DrawStringCentered(0, 1, 0.7f, Config::TxtColor, progressBarMsg, 400);
Gui::DrawStringCentered(0, 80, 0.6f, Config::TxtColor, str, 400); Gui::DrawStringCentered(0, 80, 0.6f, Config::TxtColor, str, 400);
Gui::Draw_Rect(30, 120, 340, 30, BLACK); Gui::Draw_Rect(30, 120, 340, 30, BLACK);
if (isScriptSelected == true) { if (isScriptSelected == true) {
Gui::Draw_Rect(31, 121, (int)(((float)downloadNow/(float)downloadTotal) * 338.0f), 28, progressBar); Gui::Draw_Rect(31, 121, (int)(((float)downloadNow/(float)downloadTotal) * 338.0f), 28, progressBar);
} else { } else {
Gui::Draw_Rect(31, 121, (int)(((float)downloadNow/(float)downloadTotal) * 338.0f), 28, Config::progressbarColor); Gui::Draw_Rect(31, 121, (int)(((float)downloadNow/(float)downloadTotal) * 338.0f), 28, Config::progressbarColor);
} }
Gui::DrawBottom(); Gui::DrawBottom();
C3D_FrameEnd(0); C3D_FrameEnd(0);
gspWaitForVBlank(); gspWaitForVBlank();
} }
} }
+3 -29
View File
@@ -30,18 +30,10 @@
#include "utils/config.hpp" #include "utils/config.hpp"
#include <3ds.h>
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <unistd.h>
#include <stack>
C3D_RenderTarget* top; C3D_RenderTarget* top;
C3D_RenderTarget* bottom; C3D_RenderTarget* bottom;
C2D_TextBuf sizeBuf; C2D_TextBuf sizeBuf;
std::stack<std::unique_ptr<Screen>> screens;
C2D_SpriteSheet sprites; C2D_SpriteSheet sprites;
bool currentScreen = false; bool currentScreen = false;
extern bool isScriptSelected; extern bool isScriptSelected;
@@ -162,33 +154,15 @@ bool Gui::Draw_Rect(float x, float y, float w, float h, u32 color) {
return C2D_DrawRectSolid(x, y, 0.5f, w, h, color); return C2D_DrawRectSolid(x, y, 0.5f, w, h, color);
} }
// Mainloop the GUI.
void Gui::mainLoop(u32 hDown, u32 hHeld, touchPosition touch) {
screens.top()->Draw();
screens.top()->Logic(hDown, hHeld, touch);
}
// Set the current Screen.
void Gui::setScreen(std::unique_ptr<Screen> screen)
{
screens.push(std::move(screen));
}
// Go a Screen back.
void Gui::screenBack()
{
screens.pop();
}
// Select, on which Screen should be drawn. // Select, on which Screen should be drawn.
void Gui::ScreenDraw(C3D_RenderTarget * screen) void Gui::setDraw(C3D_RenderTarget * screen)
{ {
C2D_SceneBegin(screen); C2D_SceneBegin(screen);
currentScreen = screen == top ? 1 : 0; currentScreen = screen == top ? 1 : 0;
} }
void Gui::DrawTop(void) { void Gui::DrawTop(void) {
Gui::ScreenDraw(top); Gui::setDraw(top);
if (isScriptSelected == false) { if (isScriptSelected == false) {
Gui::Draw_Rect(0, 0, 400, 25, Config::Color1); Gui::Draw_Rect(0, 0, 400, 25, Config::Color1);
Gui::Draw_Rect(0, 25, 400, 190, Config::Color2); Gui::Draw_Rect(0, 25, 400, 190, Config::Color2);
@@ -205,7 +179,7 @@ void Gui::DrawTop(void) {
} }
void Gui::DrawBottom(void) { void Gui::DrawBottom(void) {
Gui::ScreenDraw(bottom); Gui::setDraw(bottom);
if (isScriptSelected == false) { if (isScriptSelected == false) {
Gui::Draw_Rect(0, 0, 320, 25, Config::Color1); Gui::Draw_Rect(0, 0, 320, 25, Config::Color1);
Gui::Draw_Rect(0, 25, 320, 190, Config::Color3); Gui::Draw_Rect(0, 25, 320, 190, Config::Color3);
+2 -2
View File
@@ -121,10 +121,10 @@ std::string Input::Numpad(uint maxLength, std::string Text)
C2D_TargetClear(top, BLACK); C2D_TargetClear(top, BLACK);
C2D_TargetClear(bottom, BLACK); C2D_TargetClear(bottom, BLACK);
Gui::DrawTop(); Gui::DrawTop();
Gui::DrawString((400-Gui::GetStringWidth(0.8f, Text))/2, 2, 0.8f, WHITE, Text, 400); Gui::DrawString((400-Gui::GetStringWidth(0.55f, Text))/2, 2, 0.55f, WHITE, Text, 400);
Gui::DrawString(180, 212, 0.8, WHITE, (string+(cursorBlink-- > 0 ? "_" : "")).c_str(), 400); Gui::DrawString(180, 212, 0.8, WHITE, (string+(cursorBlink-- > 0 ? "_" : "")).c_str(), 400);
if(cursorBlink < -20) cursorBlink = 20; if(cursorBlink < -20) cursorBlink = 20;
Gui::ScreenDraw(bottom); Gui::setDraw(bottom);
Gui::Draw_Rect(0, 0, 320, 240, Config::Color3); Gui::Draw_Rect(0, 0, 320, 240, Config::Color3);
DrawNumpad(); DrawNumpad();
scanKeys(); scanKeys();
+72
View File
@@ -0,0 +1,72 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "logging.hpp"
#include "utils/config.hpp"
#include <memory>
std::string Logging::format(const std::string& fmt_str, ...)
{
va_list ap;
char* fp = NULL;
va_start(ap, fmt_str);
vasprintf(&fp, fmt_str.c_str(), ap);
va_end(ap);
std::unique_ptr<char, decltype(free)*> formatted(fp, free);
return std::string(formatted.get());
}
std::string Logging::logDate(void)
{
time_t unixTime;
struct tm timeStruct;
time(&unixTime);
localtime_r(&unixTime, &timeStruct);
return format("%04i-%02i-%02i %02i:%02i:%02i", timeStruct.tm_year + 1900, timeStruct.tm_mon + 1, timeStruct.tm_mday, timeStruct.tm_hour, timeStruct.tm_min, timeStruct.tm_sec);
}
void Logging::createLogFile(void) {
if((access("sdmc:/3ds/Universal-Updater/Log.log", F_OK) != 0)) {
FILE* logFile = fopen(("sdmc:/3ds/Universal-Updater/Log.log"), "w");
fclose(logFile);
}
}
// Only write to the Log, if it is enabled in the Settings File!
void Logging::writeToLog(std::string debugText) {
if (Config::getBool("LOGGING") == true) {
std::ofstream logFile;
logFile.open(("sdmc:/3ds/Universal-Updater/Log.log"), std::ofstream::app);
std::string writeDebug = "[ ";
writeDebug += logDate();
writeDebug += " ] ";
writeDebug += debugText.c_str();
logFile << writeDebug << std::endl;
logFile.close();
}
}
+8 -14
View File
@@ -25,6 +25,7 @@
*/ */
#include "gui.hpp" #include "gui.hpp"
#include "logging.hpp"
#include "lang/lang.hpp" #include "lang/lang.hpp"
@@ -45,9 +46,6 @@ touchPosition touch;
sound *bgm = NULL; sound *bgm = NULL;
bool songIsFound = false; bool songIsFound = false;
int fadealpha = 255;
bool fadein = true;
// If button Position pressed -> Do something. // If button Position pressed -> Do something.
bool touching(touchPosition touch, Structs::ButtonPos button) { bool touching(touchPosition touch, Structs::ButtonPos button) {
if (touch.px >= button.x && touch.px <= (button.x + button.w) && touch.py >= button.y && touch.py <= (button.y + button.h)) if (touch.px >= button.x && touch.px <= (button.x + button.w) && touch.py >= button.y && touch.py <= (button.y + button.h))
@@ -97,7 +95,12 @@ int main()
} }
Config::load(); Config::load();
Lang::load(Config::lang); Lang::load(Config::lang);
Gui::setScreen(std::make_unique<MainMenu>());
if (Config::Logging == true) {
Logging::createLogFile();
}
Screen::set(std::make_unique<MainMenu>());
osSetSpeedupEnable(true); // Enable speed-up for New 3DS users osSetSpeedupEnable(true); // Enable speed-up for New 3DS users
if( access( "sdmc:/3ds/dspfirm.cdc", F_OK ) != -1 ) { if( access( "sdmc:/3ds/dspfirm.cdc", F_OK ) != -1 ) {
@@ -107,7 +110,6 @@ int main()
playMusic(); playMusic();
} }
// Loop as long as the status is not exit // Loop as long as the status is not exit
while (aptMainLoop() && !exiting) while (aptMainLoop() && !exiting)
{ {
@@ -119,17 +121,9 @@ int main()
C2D_TargetClear(top, BLACK); C2D_TargetClear(top, BLACK);
C2D_TargetClear(bottom, BLACK); C2D_TargetClear(bottom, BLACK);
Gui::clearTextBufs(); Gui::clearTextBufs();
Gui::mainLoop(hDown, hHeld, touch); Screen::loop(hDown, hHeld, touch);
C3D_FrameEnd(0); C3D_FrameEnd(0);
gspWaitForVBlank(); gspWaitForVBlank();
if (fadein == true) {
fadealpha -= 3;
if (fadealpha < 0) {
fadealpha = 0;
fadein = false;
}
}
} }
if (songIsFound == true) { if (songIsFound == true) {
+1 -1
View File
@@ -86,7 +86,7 @@ void FTPScreen::Draw(void) const
memset(ftp_file_transfer, 0, 50); // Empty transfer status. memset(ftp_file_transfer, 0, 50); // Empty transfer status.
ftp_exit(); ftp_exit();
Gui::screenBack(); Screen::back();
return; return;
} }
+37 -13
View File
@@ -36,6 +36,8 @@
#include "utils/config.hpp" #include "utils/config.hpp"
#include <unistd.h>
extern bool exiting; extern bool exiting;
extern bool touching(touchPosition touch, Structs::ButtonPos button); extern bool touching(touchPosition touch, Structs::ButtonPos button);
extern bool checkWifiStatus(void); extern bool checkWifiStatus(void);
@@ -70,6 +72,20 @@ void MainMenu::Draw(void) const {
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(0, 0, 0, fadealpha)); // Fade in out effect if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(0, 0, 0, fadealpha)); // Fade in out effect
} }
bool MainMenu::returnScriptState() {
dirContents.clear();
chdir(Config::ScriptPath.c_str());
std::vector<DirEntry> dirContentsTemp;
getDirectoryContents(dirContentsTemp, {"json"});
for(uint i=0;i<dirContentsTemp.size();i++) {
dirContents.push_back(dirContentsTemp[i]);
}
if (dirContents.size() == 0) {
return false;
}
return true;
}
void MainMenu::Logic(u32 hDown, u32 hHeld, touchPosition touch) { void MainMenu::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
if (hDown & KEY_START) { if (hDown & KEY_START) {
@@ -91,35 +107,39 @@ void MainMenu::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
if (hDown & KEY_A) { if (hDown & KEY_A) {
switch(Selection) { switch(Selection) {
case 0: case 0:
Gui::setScreen(std::make_unique<ScriptList>()); if (returnScriptState() == true) {
Screen::set(std::make_unique<ScriptList>());
} else {
Gui::DisplayWarnMsg(Lang::get("GET_SCRIPTS_FIRST"));
}
break; break;
case 1: case 1:
if (checkWifiStatus() == true) { if (checkWifiStatus() == true) {
Gui::setScreen(std::make_unique<ScriptBrowse>()); Screen::set(std::make_unique<ScriptBrowse>());
} else { } else {
notConnectedMsg(); notConnectedMsg();
} }
break; break;
case 2: case 2:
if (checkWifiStatus() == true) { if (checkWifiStatus() == true) {
Gui::setScreen(std::make_unique<TinyDB>()); Screen::set(std::make_unique<TinyDB>());
} else { } else {
notConnectedMsg(); notConnectedMsg();
} }
break; break;
case 3: case 3:
if (isTesting == true) { if (isTesting == true) {
Gui::setScreen(std::make_unique<ScriptCreator>()); Screen::set(std::make_unique<ScriptCreator>());
} else { } else {
notImplemented(); notImplemented();
} }
break; break;
case 4: case 4:
Gui::setScreen(std::make_unique<Settings>()); Screen::set(std::make_unique<Settings>());
break; break;
case 5: case 5:
if (checkWifiStatus() == true) { if (checkWifiStatus() == true) {
Gui::setScreen(std::make_unique<FTPScreen>()); Screen::set(std::make_unique<FTPScreen>());
} else { } else {
notConnectedMsg(); notConnectedMsg();
} }
@@ -129,36 +149,40 @@ void MainMenu::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
if (hDown & KEY_X) { if (hDown & KEY_X) {
if (checkWifiStatus() == true) { if (checkWifiStatus() == true) {
Gui::setScreen(std::make_unique<FTPScreen>()); Screen::set(std::make_unique<FTPScreen>());
} }
} }
if (hDown & KEY_TOUCH) { if (hDown & KEY_TOUCH) {
if (touching(touch, mainButtons[0])) { if (touching(touch, mainButtons[0])) {
Gui::setScreen(std::make_unique<ScriptList>()); if (returnScriptState() == true) {
Screen::set(std::make_unique<ScriptList>());
} else {
Gui::DisplayWarnMsg(Lang::get("GET_SCRIPTS_FIRST"));
}
} else if (touching(touch, mainButtons[1])) { } else if (touching(touch, mainButtons[1])) {
if (checkWifiStatus() == true) { if (checkWifiStatus() == true) {
Gui::setScreen(std::make_unique<ScriptBrowse>()); Screen::set(std::make_unique<ScriptBrowse>());
} else { } else {
notConnectedMsg(); notConnectedMsg();
} }
} else if (touching(touch, mainButtons[2])) { } else if (touching(touch, mainButtons[2])) {
if (checkWifiStatus() == true) { if (checkWifiStatus() == true) {
Gui::setScreen(std::make_unique<TinyDB>()); Screen::set(std::make_unique<TinyDB>());
} else { } else {
notConnectedMsg(); notConnectedMsg();
} }
} else if (touching(touch, mainButtons[3])) { } else if (touching(touch, mainButtons[3])) {
if (isTesting == true) { if (isTesting == true) {
Gui::setScreen(std::make_unique<ScriptCreator>()); Screen::set(std::make_unique<ScriptCreator>());
} else { } else {
notImplemented(); notImplemented();
} }
} else if (touching(touch, mainButtons[4])) { } else if (touching(touch, mainButtons[4])) {
Gui::setScreen(std::make_unique<Settings>()); Screen::set(std::make_unique<Settings>());
} else if (touching(touch, mainButtons[5])) { } else if (touching(touch, mainButtons[5])) {
if (checkWifiStatus() == true) { if (checkWifiStatus() == true) {
Gui::setScreen(std::make_unique<FTPScreen>()); Screen::set(std::make_unique<FTPScreen>());
} else { } else {
notConnectedMsg(); notConnectedMsg();
} }
+73
View File
@@ -0,0 +1,73 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "screens/screen.hpp"
#include <stack>
// Fade stuff.
int fadealpha = 255;
bool fadein = true;
std::stack<std::unique_ptr<screen>> screens;
// Set a specific Screen.
void Screen::set(std::unique_ptr<screen> screen2)
{
screens.push(std::move(screen2));
}
// Fade into another Screen, but first do a fadeout.
void Screen::fade(std::unique_ptr<screen> screen2, bool fadeout) {
if (fadeout) {
fadealpha += 6;
if (fadealpha > 255) {
fadealpha = 255;
screens.push(std::move(screen2));
fadein = true;
fadeout = false;
}
}
}
// Go a Screen back.
void Screen::back()
{
screens.pop();
}
// For the Mainloop.
void Screen::loop(u32 hDown, u32 hHeld, touchPosition touch) {
screens.top()->Draw();
screens.top()->Logic(hDown, hHeld, touch);
if (fadein == true) {
fadealpha -= 6;
if (fadealpha < 0) {
fadealpha = 0;
fadein = false;
}
}
}
+11 -11
View File
@@ -43,14 +43,14 @@ nlohmann::json infoJson;
std::string maxScripts; std::string maxScripts;
void fixInfo(nlohmann::json &json) { void fixInfo(nlohmann::json &json) {
for(uint i=0;i<json.size();i++) { for(uint i=0;i<json.size();i++) {
if(!json[i].contains("title")) json[i]["title"] = "TITLE"; if(!json[i].contains("title")) json[i]["title"] = "TITLE";
if(!json[i].contains("author")) json[i]["author"] = "AUTHOR"; if(!json[i].contains("author")) json[i]["author"] = "AUTHOR";
if(!json[i].contains("shortDesc")) json[i]["shortDesc"] = "SHORTDESC"; if(!json[i].contains("shortDesc")) json[i]["shortDesc"] = "SHORTDESC";
if(!json[i].contains("revision")) json[i]["revision"] = 0; if(!json[i].contains("revision")) json[i]["revision"] = 0;
if(!json[i].contains("curRevision")) json[i]["curRevision"] = 0; if(!json[i].contains("curRevision")) json[i]["curRevision"] = 0;
if(!json[i].contains("version")) json[i]["revision"] = 0; if(!json[i].contains("version")) json[i]["revision"] = 0;
} }
} }
nlohmann::json infoFromScript(const std::string &path) { nlohmann::json infoFromScript(const std::string &path) {
@@ -169,7 +169,7 @@ void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
if (keyRepeatDelay) keyRepeatDelay--; if (keyRepeatDelay) keyRepeatDelay--;
if (hDown & KEY_B) { if (hDown & KEY_B) {
infoJson.clear(); infoJson.clear();
Gui::screenBack(); Screen::back();
return; return;
} }
@@ -205,9 +205,9 @@ void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
std::string titleFix = infoJson[selection]["title"]; std::string titleFix = infoJson[selection]["title"];
for (int i = 0; i < (int)titleFix.size(); i++) { for (int i = 0; i < (int)titleFix.size(); i++) {
if (titleFix[i] == '/') { if (titleFix[i] == '/') {
titleFix[i] = '-'; titleFix[i] = '-';
} }
} }
DisplayMsg(fileName); DisplayMsg(fileName);
+267 -38
View File
@@ -25,12 +25,14 @@
*/ */
#include "keyboard.hpp" #include "keyboard.hpp"
#include "logging.hpp"
#include "screens/scriptCreator.hpp" #include "screens/scriptCreator.hpp"
#include "utils/config.hpp" #include "utils/config.hpp"
#include <fstream> #include <fstream>
#include <unistd.h>
// The to editing script. // The to editing script.
nlohmann::json editScript; nlohmann::json editScript;
@@ -68,6 +70,14 @@ void ScriptCreator::setString2(const std::string &object, const std::string &key
} }
void ScriptCreator::Draw(void) const { void ScriptCreator::Draw(void) const {
if (mode == 0) {
DrawSubMenu();
} else if (mode == 1) {
DrawScriptScreen();
}
}
void ScriptCreator::DrawSubMenu(void) const {
Gui::DrawTop(); Gui::DrawTop();
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("SCRIPTCREATOR"), 400); Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("SCRIPTCREATOR"), 400);
Gui::DrawBottom(); Gui::DrawBottom();
@@ -84,7 +94,47 @@ void ScriptCreator::Draw(void) const {
Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("EXISTING_SCRIPT")))/2, mainButtons[1].y+10, 0.6f, Config::TxtColor, Lang::get("EXISTING_SCRIPT"), 140); Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("EXISTING_SCRIPT")))/2, mainButtons[1].y+10, 0.6f, Config::TxtColor, Lang::get("EXISTING_SCRIPT"), 140);
} }
std::string jsonFileName; void ScriptCreator::DrawScriptScreen(void) const {
Gui::DrawTop();
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("SCRIPTCREATOR"), 400);
Gui::DrawBottom();
// Draw Page.
for (int i = 0; i < 2; i++) {
if (i == page) {
Gui::DrawString(260, 3, 0.6f, Config::TxtColor, std::to_string(i+1) + " / 2", 140);
}
}
if (page == 0) {
for (int i = 0; i < 6; i++) {
if (Selection == i) {
Gui::Draw_Rect(creatorButtons[i].x, creatorButtons[i].y, creatorButtons[i].w, creatorButtons[i].h, Config::SelectedColor);
} else {
Gui::Draw_Rect(creatorButtons[i].x, creatorButtons[i].y, creatorButtons[i].w, creatorButtons[i].h, Config::UnselectedColor);
}
}
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "downloadRelease"))/2-150+70, creatorButtons[0].y+10, 0.6f, Config::TxtColor, "downloadRelease", 140);
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "downloadFile"))/2+150-70, creatorButtons[1].y+10, 0.6f, Config::TxtColor, "downloadFile", 140);
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "deleteFile"))/2-150+70, creatorButtons[2].y+10, 0.6f, Config::TxtColor, "deleteFile", 140);
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "extractFile"))/2+150-70, creatorButtons[3].y+10, 0.6f, Config::TxtColor, "extractFile", 140);
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "installCia"))/2-150+70, creatorButtons[4].y+10, 0.6f, Config::TxtColor, "installCia", 140);
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "mkdir"))/2+150-70, creatorButtons[5].y+10, 0.6f, Config::TxtColor, "mkdir", 140);
} else if (page == 1) {
for (int i = 0; i < 3; i++) {
if (Selection == i) {
Gui::Draw_Rect(creatorButtons[i].x, creatorButtons[i].y, creatorButtons[i].w, creatorButtons[i].h, Config::SelectedColor);
} else {
Gui::Draw_Rect(creatorButtons[i].x, creatorButtons[i].y, creatorButtons[i].w, creatorButtons[i].h, Config::UnselectedColor);
}
}
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "rmdir"))/2-150+70, creatorButtons[0].y+10, 0.6f, Config::TxtColor, "rmdir", 140);
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "mkfile"))/2+150-70, creatorButtons[1].y+10, 0.6f, Config::TxtColor, "mkfile", 140);
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "TimeMsg"))/2-150+70, creatorButtons[2].y+10, 0.6f, Config::TxtColor, "TimeMsg", 140);
}
}
void ScriptCreator::createNewJson(std::string fileName) { void ScriptCreator::createNewJson(std::string fileName) {
std::ofstream ofstream; std::ofstream ofstream;
@@ -94,6 +144,8 @@ void ScriptCreator::createNewJson(std::string fileName) {
// Test. // Test.
void ScriptCreator::createDownloadRelease() { void ScriptCreator::createDownloadRelease() {
// Entry name.
std::string entryname = Input::getString(50, "Enter the name of the Entry.");
// Repo. // Repo.
std::string repo = Input::getString(50, "Enter the name of the Owner."); std::string repo = Input::getString(50, "Enter the name of the Owner.");
repo += "/"; repo += "/";
@@ -107,62 +159,121 @@ void ScriptCreator::createDownloadRelease() {
// Message. // Message.
std::string message = Input::getString(50, "Enter the Message."); std::string message = Input::getString(50, "Enter the Message.");
editScript["Test"] = { {{"type", "downloadRelease"}, {"repo", repo}, {"file", file}, {"output", output}, {"includePrerelease", prerelease}, {"message", message}} }; editScript[entryname] = { {{"type", "downloadRelease"}, {"repo", repo}, {"file", file}, {"output", output}, {"includePrerelease", prerelease}, {"message", message}} };
Logging::writeToLog("Execute 'ScriptCreator::createDownloadRelease();'.");
} }
// To-Do. // To-Do.
/*
void ScriptCreator::createDownloadFile(const std::string &Entryname, const std::string &file, const std::string output, const std::string &message) { void ScriptCreator::createDownloadFile() {
editScript[Entryname] = { {{"type", "downloadFile"}, {"file", file}, {"output", output}, {"message", message}} }; // Entry name.
std::string entryname = Input::getString(50, "Enter the name of the Entry.");
// URL of the file.
std::string file = Input::getString(50, "Enter the URL of the file.");
// Output.
std::string output = Input::getString(50, "Enter the name of the Output path.");
// Message.
std::string message = Input::getString(50, "Enter the Message.");
editScript[entryname] = { {{"type", "downloadFile"}, {"file", file}, {"output", output}, {"message", message}} };
Logging::writeToLog("Execute 'ScriptCreator::createDownloadFile();'.");
} }
void ScriptCreator::createDeleteFile(const std::string &Entryname, const std::string &file, const std::string &message) {
editScript[Entryname] = { {{"type", "deleteFile"}, {"file", file}, {"message", message}} }; void ScriptCreator::createDeleteFile() {
// Entry name.
std::string entryname = Input::getString(50, "Enter the name of the Entry.");
// URL of the file.
std::string file = Input::getString(50, "Enter the path to the file.");
// Message.
std::string message = Input::getString(50, "Enter the Message.");
editScript[entryname] = { {{"type", "deleteFile"}, {"file", file}, {"message", message}} };
Logging::writeToLog("Execute 'ScriptCreator::createDeleteFile();'.");
} }
void ScriptCreator::createExtractFile(const std::string &Entryname, const std::string &file, const std::string &input, const std::string &output, const std::string &message) {
editScript[Entryname] = { {{"type", "extractFile"}, {"file", file}, {"input", input}, {"output", output}, {"message", message}} }; void ScriptCreator::createExtractFile() {
// Entry name.
std::string entryname = Input::getString(50, "Enter the name of the Entry.");
// File path.
std::string file = Input::getString(50, "Enter the path to the file.");
// Input of the archive.
std::string input = Input::getString(50, "Enter the Input of what should be extracted.");
// Output path.
std::string output = Input::getString(50, "Enter the output path.");
// Message.
std::string message = Input::getString(50, "Enter the Message.");
editScript[entryname] = { {{"type", "extractFile"}, {"file", file}, {"input", input}, {"output", output}, {"message", message}} };
Logging::writeToLog("Execute 'ScriptCreator::createExtractFile();'.");
} }
void ScriptCreator::createInstallCia(const std::string &Entryname, const std::string &file, const std::string &message) {
editScript[Entryname] = { {{"type", "installCia"}, {"file", file}, {"message", message}} }; void ScriptCreator::createInstallCia() {
// Entry name.
std::string entryname = Input::getString(50, "Enter the name of the Entry.");
// File path.
std::string file = Input::getString(50, "Enter the path to the CIA File.");
// Message.
std::string message = Input::getString(50, "Enter the Message.");
editScript[entryname] = { {{"type", "installCia"}, {"file", file}, {"message", message}} };
Logging::writeToLog("Execute 'ScriptCreator::createInstallCia();'.");
} }
void ScriptCreator::createMkDir(const std::string &Entryname, const std::string &directory) {
editScript[Entryname] = { {{"type", "mkdir"}, {"directory", directory}} }; void ScriptCreator::createMkDir() {
// Entry name.
std::string entryname = Input::getString(50, "Enter the name of the Entry.");
// Directory path.
std::string directory = Input::getString(50, "Enter the directory path.");
editScript[entryname] = { {{"type", "mkdir"}, {"directory", directory}} };
Logging::writeToLog("Execute 'ScriptCreator::createMkDir();'.");
} }
void ScriptCreator::createRmDir(const std::string &Entryname, const std::string &directory) { void ScriptCreator::createRmDir() {
editScript[Entryname] = { {{"type", "rmdir"}, {"directory", directory}} }; // Entry name.
std::string entryname = Input::getString(50, "Enter the name of the Entry.");
// Directory path.
std::string directory = Input::getString(50, "Enter the directory path.");
editScript[entryname] = { {{"type", "rmdir"}, {"directory", directory}} };
Logging::writeToLog("Execute 'ScriptCreator::createRmDir();'.");
} }
void ScriptCreator::createMkFile(const std::string &Entryname, const std::string &file) { void ScriptCreator::createMkFile() {
editScript[Entryname] = { {{"type", "mkfile"}, {"file", file}} }; // Entry name.
std::string entryname = Input::getString(50, "Enter the name of the Entry.");
// File path.
std::string file = Input::getString(50, "Enter the path to the new File.");
editScript[entryname] = { {{"type", "mkfile"}, {"file", file}} };
Logging::writeToLog("Execute 'ScriptCreator::createMkFile();'.");
} }
void ScriptCreator::createTimeMsg(const std::string &Entryname, const std::string &message, int seconds) { void ScriptCreator::createTimeMsg() {
editScript[Entryname] = { {{"type", "rmdir"}, {"message", message}, {"seconds", seconds}} }; // Entry name.
} std::string entryname = Input::getString(50, "Enter the name of the Entry.");
*/ // Message.
std::string message = Input::getString(50, "Enter the Message.");
// Seconds.
int seconds = Input::getUint(999, "Enter the Seconds for the Message to display.");
// Testing purpose for now. editScript[entryname] = { {{"type", "timeMsg"}, {"message", message}, {"seconds", seconds}} };
ScriptCreator::ScriptCreator() { Logging::writeToLog("Execute 'ScriptCreator::createTimeMsg();'.");
jsonFileName = Config::ScriptPath;
jsonFileName += Input::getString(20, "Enter the name of the JSON file.");
if (jsonFileName != "") {
jsonFileName += ".json";
createNewJson(jsonFileName);
openJson(jsonFileName);
}
} }
void ScriptCreator::save() { void ScriptCreator::save() {
FILE* file = fopen(jsonFileName.c_str(), "w"); FILE* file = fopen(jsonFileName.c_str(), "w");
if(file) fwrite(editScript.dump(1, '\t').c_str(), 1, editScript.dump(1, '\t').size(), file); if(file) fwrite(editScript.dump(1, '\t').c_str(), 1, editScript.dump(1, '\t').size(), file);
fclose(file); fclose(file);
Logging::writeToLog("Execute 'ScriptCreator::save();'.");
} }
// Importaant to make Scripts valid. // Important to make Scripts valid.
void ScriptCreator::setInfoStuff(void) { void ScriptCreator::setInfoStuff(void) {
// Get needed things. // Get needed things.
const std::string &test = Input::getString(50, "Enter the Title of the script."); const std::string &test = Input::getString(50, "Enter the Title of the script.");
@@ -180,14 +291,38 @@ void ScriptCreator::setInfoStuff(void) {
} }
void ScriptCreator::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
void ScriptCreator::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
if (hDown & KEY_B) { if (hDown & KEY_B) {
save(); Screen::back();
Gui::screenBack();
return; return;
} }
if (hDown & KEY_A) {
switch(Selection) {
case 0:
jsonFileName = Config::ScriptPath;
jsonFileName += Input::getString(20, "Enter the name of the JSON file.");
if (jsonFileName != "") {
jsonFileName += ".json";
createNewJson(jsonFileName);
openJson(jsonFileName);
Selection = 0;
mode = 1;
}
break;
case 1:
jsonFileName = Config::ScriptPath;
jsonFileName += Input::getString(20, "Enter the name of the JSON file.");
if(access(jsonFileName.c_str(), F_OK) != -1 ) {
openJson(jsonFileName);
Selection = 0;
mode = 1;
}
break;
}
}
if (hDown & KEY_UP) { if (hDown & KEY_UP) {
if(Selection == 1) Selection = 0; if(Selection == 1) Selection = 0;
} }
@@ -195,12 +330,106 @@ void ScriptCreator::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
if (hDown & KEY_DOWN) { if (hDown & KEY_DOWN) {
if(Selection == 0) Selection = 1; if(Selection == 0) Selection = 1;
} }
}
if (hDown & KEY_Y) { void ScriptCreator::scriptLogic(u32 hDown, u32 hHeld, touchPosition touch) {
setInfoStuff(); if (hDown & KEY_B) {
save();
Selection = 0;
mode = 0;
}
// Page 1.
if (page == 0) {
if (hDown & KEY_UP) {
if(Selection > 1) Selection -= 2;
}
if (hDown & KEY_DOWN) {
if(Selection < 4) Selection += 2;
}
if (hDown & KEY_LEFT) {
if (Selection%2) Selection--;
}
if (hDown & KEY_RIGHT) {
if (!(Selection%2)) Selection++;
}
} else if (page == 1) {
if (hDown & KEY_UP) {
if (Selection == 2) Selection = 0;
}
if (hDown & KEY_RIGHT) {
if (Selection == 0) Selection = 1;
}
if (hDown & KEY_LEFT) {
if (Selection == 1) Selection = 0;
}
if (hDown & KEY_DOWN) {
if (Selection == 0) Selection = 2;
}
}
// Page 2.
if (hDown & KEY_R) {
if (page == 0) {
page = 1;
Selection = 0;
}
}
if (hDown & KEY_L) {
if (page == 1) {
page = 0;
Selection = 0;
}
}
if (hDown & KEY_A) {
if (page == 0) {
switch(Selection) {
case 0:
createDownloadRelease();
break;
case 1:
createDownloadFile();
break;
case 2:
createDeleteFile();
break;
case 3:
createExtractFile();
break;
case 4:
createInstallCia();
break;
case 5:
createMkDir();
break;
}
} else if (page == 1) {
switch(Selection) {
case 0:
createRmDir();
break;
case 1:
createMkFile();
break;
case 2:
createTimeMsg();
break;
}
}
} }
if (hDown & KEY_X) { if (hDown & KEY_X) {
createDownloadRelease(); setInfoStuff();
}
}
void ScriptCreator::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
if (mode == 0) {
SubMenuLogic(hDown, hHeld, touch);
} else if (mode == 1) {
scriptLogic(hDown, hHeld, touch);
} }
} }
+1 -1
View File
@@ -365,7 +365,7 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld) {
if (hDown & KEY_B) { if (hDown & KEY_B) {
fileInfo.clear(); fileInfo.clear();
Gui::screenBack(); Screen::back();
return; return;
} }
+1 -1
View File
@@ -232,7 +232,7 @@ void Settings::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
} }
if (hDown & KEY_B) { if (hDown & KEY_B) {
Gui::screenBack(); Screen::back();
return; return;
} }
} }
+3 -3
View File
@@ -80,7 +80,7 @@ TinyDB::TinyDB() {
// To-Do. // To-Do.
void TinyDB::Draw(void) const { void TinyDB::Draw(void) const {
std::string info; std::string info;
Gui::ScreenDraw(top); Gui::setDraw(top);
Gui::Draw_Rect(0, 0, 400, 25, C2D_Color32(63, 81, 181, 255)); Gui::Draw_Rect(0, 0, 400, 25, C2D_Color32(63, 81, 181, 255));
Gui::Draw_Rect(0, 25, 400, 190, C2D_Color32(140, 140, 140, 255)); Gui::Draw_Rect(0, 25, 400, 190, C2D_Color32(140, 140, 140, 255));
Gui::Draw_Rect(0, 215, 400, 25, C2D_Color32(63, 81, 181, 255)); Gui::Draw_Rect(0, 215, 400, 25, C2D_Color32(63, 81, 181, 255));
@@ -98,7 +98,7 @@ void TinyDB::Draw(void) const {
Gui::DrawString(397-Gui::GetStringWidth(0.6f, entryAmount), 237-Gui::GetStringHeight(0.6f, entryAmount), 0.6f, Config::TxtColor, entryAmount); Gui::DrawString(397-Gui::GetStringWidth(0.6f, entryAmount), 237-Gui::GetStringHeight(0.6f, entryAmount), 0.6f, Config::TxtColor, entryAmount);
Gui::ScreenDraw(bottom); Gui::setDraw(bottom);
Gui::Draw_Rect(0, 0, 320, 25, C2D_Color32(63, 81, 181, 255)); Gui::Draw_Rect(0, 0, 320, 25, C2D_Color32(63, 81, 181, 255));
Gui::Draw_Rect(0, 25, 320, 190, C2D_Color32(140, 140, 140, 255)); Gui::Draw_Rect(0, 25, 320, 190, C2D_Color32(140, 140, 140, 255));
Gui::Draw_Rect(0, 215, 320, 25, C2D_Color32(63, 81, 181, 255)); Gui::Draw_Rect(0, 215, 320, 25, C2D_Color32(63, 81, 181, 255));
@@ -133,7 +133,7 @@ void TinyDB::Draw(void) const {
void TinyDB::Logic(u32 hDown, u32 hHeld, touchPosition touch) { void TinyDB::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
if (keyRepeatDelay) keyRepeatDelay--; if (keyRepeatDelay) keyRepeatDelay--;
if (hDown & KEY_B) { if (hDown & KEY_B) {
Gui::screenBack(); Screen::back();
return; return;
} }
+10
View File
@@ -45,6 +45,7 @@ int Config::ColorKeys;
int Config::progressbarColor; int Config::progressbarColor;
std::string Config::ScriptPath; std::string Config::ScriptPath;
std::string Config::MusicPath; std::string Config::MusicPath;
bool Config::Logging;
nlohmann::json configJson; nlohmann::json configJson;
void Config::load() { void Config::load() {
@@ -124,6 +125,12 @@ void Config::load() {
Config::MusicPath = getString("MUSICPATH"); Config::MusicPath = getString("MUSICPATH");
} }
if(!configJson.contains("LOGGING")) {
Config::Logging = false;
} else {
Config::Logging = getBool("LOGGING");
}
fclose(file); fclose(file);
} else { } else {
Config::Color1 = BarColor; Config::Color1 = BarColor;
@@ -138,6 +145,7 @@ void Config::load() {
Config::ColorKeys = C2D_Color32(0, 0, 200, 255); Config::ColorKeys = C2D_Color32(0, 0, 200, 255);
Config::progressbarColor = WHITE; Config::progressbarColor = WHITE;
Config::MusicPath = MUSIC_PATH; Config::MusicPath = MUSIC_PATH;
Config::Logging = false;
} }
} }
@@ -154,6 +162,7 @@ void Config::save() {
Config::setInt("COLORKEYS", Config::ColorKeys); Config::setInt("COLORKEYS", Config::ColorKeys);
Config::setInt("PROGRESSBARCOLOR", Config::progressbarColor); Config::setInt("PROGRESSBARCOLOR", Config::progressbarColor);
Config::setString("MUSICPATH", Config::MusicPath); Config::setString("MUSICPATH", Config::MusicPath);
Config::setBool("LOGGING", Config::Logging);
FILE* file = fopen("sdmc:/3ds/Universal-Updater/Settings.json", "w"); FILE* file = fopen("sdmc:/3ds/Universal-Updater/Settings.json", "w");
if(file) fwrite(configJson.dump(1, '\t').c_str(), 1, configJson.dump(1, '\t').size(), file); if(file) fwrite(configJson.dump(1, '\t').c_str(), 1, configJson.dump(1, '\t').size(), file);
fclose(file); fclose(file);
@@ -174,6 +183,7 @@ void Config::initializeNewConfig() {
Config::setInt("COLORKEYS", C2D_Color32(0, 0, 200, 255)); Config::setInt("COLORKEYS", C2D_Color32(0, 0, 200, 255));
Config::setInt("PROGRESSBARCOLOR", WHITE); Config::setInt("PROGRESSBARCOLOR", WHITE);
Config::setString("MUSICPATH", MUSIC_PATH); Config::setString("MUSICPATH", MUSIC_PATH);
Config::setBool("LOGGING", false);
if(file) fwrite(configJson.dump(1, '\t').c_str(), 1, configJson.dump(1, '\t').size(), file); if(file) fwrite(configJson.dump(1, '\t').c_str(), 1, configJson.dump(1, '\t').size(), file);
fclose(file); fclose(file);