The progress which I did.

I continue later.
This commit is contained in:
VoltZ
2019-11-11 19:43:00 +01:00
parent 955b644ad4
commit 67694a5f96
9 changed files with 311 additions and 20 deletions
+2
View File
@@ -9,6 +9,8 @@ namespace Input {
std::string Numpad(uint maxLength, std::string Text);
// -1 if invaild text entered
int getUint(int max, std::string Text);
std::string getString(const std::string &hint, uint maxLength);
}
#endif
+6 -4
View File
@@ -40,10 +40,12 @@ public:
private:
int Selection = 0;
std::vector<Structs::ButtonPos> mainButtons = {
{10, 75, 140, 35, -1}, // ScriptList.
{170, 75, 140, 35, -1}, // ScriptBrowse.
{10, 140, 140, 35, -1}, // Language.
{170, 140, 140, 35, -1}, // Colors.
{10, 40, 140, 35, -1}, // Scriptlist.
{170, 40, 140, 35, -1}, // ScriptBrowse.
{10, 100, 140, 35, -1}, // TinyDB.
{170, 100, 140, 35, -1}, // ScriptCreator.
{10, 160, 140, 35, -1}, // Language.
{170, 160, 140, 35, -1}, // Colors.
};
};
+51
View File
@@ -0,0 +1,51 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019 VoltZ, Epicpkmn11, Flame, RocketRobz, 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 SCRIPTCREATOR_HPP
#define SCRIPTCREATOR_HPP
#include "screens/screen.hpp"
#include "screens/screenCommon.hpp"
#include "utils/json.hpp"
class ScriptCreator : public Screen
{
public:
void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
ScriptCreator();
private:
void openJson();
void save();
void setBool(const std::string &object, const std::string &key, bool v);
void setInt(const std::string &object, const std::string &key, int v);
void setString(const std::string &object, const std::string &key, const std::string &v);
};
#endif
+41
View File
@@ -0,0 +1,41 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019 VoltZ, Epicpkmn11, Flame, RocketRobz, 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 TINYDB_HPP
#define TINYDB_HPP
#include "screens/screen.hpp"
#include "screens/screenCommon.hpp"
class TinyDB : public Screen
{
public:
void Draw(void) const override;
void Logic(u32 hDown, u32 hHeld, touchPosition touch) override;
private:
};
#endif
+3 -1
View File
@@ -51,5 +51,7 @@
"FAILED_GET_IP": "Failed to get IP.",
"FAILED_INITIALIZE_FTP": "Failed to initialize FTP.",
"B_FTP_EXIT": "Press B to exit from FTP.",
"WIFI_NOT_ENABLED": "WiFi not enabled."
"WIFI_NOT_ENABLED": "WiFi not enabled.",
"SCRIPTCREATOR": "Script Creator"
}
+21
View File
@@ -149,4 +149,25 @@ int Input::getUint(int max, std::string Text) {
int i = atoi(s.c_str());
if(i>max) return 255;
return i;
}
std::string Input::getString(const std::string &hint, uint maxLength)
{
std::string string;
C3D_FrameEnd(0);
SwkbdState state;
const char *hintText = hint.c_str();
swkbdInit(&state, SWKBD_TYPE_NORMAL, 2, maxLength);
swkbdSetHintText(&state, hintText);
swkbdSetValidation(&state, SWKBD_NOTBLANK_NOTEMPTY, SWKBD_FILTER_PROFANITY, 0);
char input[maxLength + 1] = {0};
SwkbdButton ret = swkbdInputText(&state, input, sizeof(input));
input[maxLength] = '\0';
if (ret == SWKBD_BUTTON_CONFIRM)
{
string = input;
return string;
} else {
return "";
}
}
+53 -15
View File
@@ -29,15 +29,20 @@
#include "screens/ftpScreen.hpp"
#include "screens/mainMenu.hpp"
#include "screens/scriptBrowse.hpp"
#include "screens/scriptCreator.hpp"
#include "screens/scriptlist.hpp"
#include "screens/settings.hpp"
#include "screens/tinyDB.hpp"
#include "utils/config.hpp"
extern int mode;
extern bool exiting;
extern bool touching(touchPosition touch, Structs::ButtonPos button);
extern bool checkWifiStatus(void);
// This is for the Script Creator, so no one can access it for now, until it is stable or so.
bool isTesting = false;
void MainMenu::Draw(void) const {
Gui::DrawTop();
@@ -45,7 +50,7 @@ void MainMenu::Draw(void) const {
Gui::DrawString(397-Gui::GetStringWidth(0.5f, VERSION_STRING), 237-Gui::GetStringHeight(0.5f, VERSION_STRING), 0.5f, Config::TxtColor, VERSION_STRING);
Gui::DrawBottom();
for (int i = 0; i < 4; i++) {
for (int i = 0; i < 6; i++) {
if (Selection == i) {
Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, Config::SelectedColor);
} else {
@@ -55,8 +60,10 @@ void MainMenu::Draw(void) const {
Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("SCRIPTLIST")))/2-150+70, mainButtons[0].y+10, 0.6f, Config::TxtColor, Lang::get("SCRIPTLIST"), 140);
Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("GET_SCRIPTS")))/2+150-70, mainButtons[1].y+10, 0.6f, Config::TxtColor, Lang::get("GET_SCRIPTS"), 140);
Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("LANGUAGE")))/2-150+70, mainButtons[2].y+10, 0.6f, Config::TxtColor, Lang::get("LANGUAGE"), 140);
Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("COLORS")))/2+150-70, mainButtons[3].y+10, 0.6f, Config::TxtColor, Lang::get("COLORS"), 140);
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "TinyDB"))/2-150+70, mainButtons[2].y+10, 0.6f, Config::TxtColor, "TinyDB", 140);
Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("SCRIPTCREATOR")))/2+150-70, mainButtons[3].y+10, 0.6f, Config::TxtColor, Lang::get("SCRIPTCREATOR"), 140);
Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("LANGUAGE")))/2-150+70, mainButtons[4].y+10, 0.6f, Config::TxtColor, Lang::get("LANGUAGE"), 140);
Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("COLORS")))/2+150-70, mainButtons[5].y+10, 0.6f, Config::TxtColor, Lang::get("COLORS"), 140);
}
void MainMenu::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
@@ -64,13 +71,19 @@ void MainMenu::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
exiting = true;
}
if(hDown & KEY_UP) {
if (hDown & KEY_UP) {
if(Selection > 1) Selection -= 2;
} else if(hDown & KEY_DOWN) {
if(Selection < 3 && Selection != 2 && Selection != 3) Selection += 2;
} else if (hDown & KEY_LEFT) {
}
if (hDown & KEY_DOWN) {
if(Selection < 4) Selection += 2;
}
if (hDown & KEY_LEFT) {
if (Selection%2) Selection--;
} else if (hDown & KEY_RIGHT) {
}
if (hDown & KEY_RIGHT) {
if (!(Selection%2)) Selection++;
}
@@ -80,13 +93,25 @@ void MainMenu::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
Gui::setScreen(std::make_unique<ScriptList>());
break;
case 1:
Gui::setScreen(std::make_unique<ScriptBrowse>());
if (checkWifiStatus() == true) {
Gui::setScreen(std::make_unique<ScriptBrowse>());
} else {
notConnectedMsg();
}
break;
case 2:
Gui::setScreen(std::make_unique<TinyDB>());
break;
case 3:
if (isTesting == true) {
Gui::setScreen(std::make_unique<ScriptCreator>());
}
break;
case 4:
mode = 0;
Gui::setScreen(std::make_unique<Settings>());
break;
case 3:
case 5:
mode = 1;
Gui::setScreen(std::make_unique<Settings>());
break;
@@ -94,18 +119,31 @@ void MainMenu::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
}
if (hDown & KEY_X) {
Gui::setScreen(std::make_unique<FTPScreen>());
if (checkWifiStatus() == true) {
Gui::setScreen(std::make_unique<FTPScreen>());
}
}
if (hDown & KEY_TOUCH) {
if (touching(touch, mainButtons[0])) {
Gui::setScreen(std::make_unique<ScriptList>());
} else if (touching(touch, mainButtons[1])) {
Gui::setScreen(std::make_unique<ScriptBrowse>());
} else if (touching(touch, mainButtons[2])) {
if (checkWifiStatus() == true) {
Gui::setScreen(std::make_unique<ScriptBrowse>());
} else {
notConnectedMsg();
}
} else if (touching(touch, mainButtons[2])) {
Gui::setScreen(std::make_unique<TinyDB>());
} else if (touching(touch, mainButtons[3])) {
if (isTesting == true) {
Gui::setScreen(std::make_unique<ScriptCreator>());
}
} else if (touching(touch, mainButtons[4])) {
mode = 0;
Gui::setScreen(std::make_unique<Settings>());
} else if (touching(touch, mainButtons[3])) {
} else if (touching(touch, mainButtons[5])) {
mode = 1;
Gui::setScreen(std::make_unique<Settings>());
}
+91
View File
@@ -0,0 +1,91 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019 VoltZ, Epicpkmn11, Flame, RocketRobz, 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 "keyboard.hpp"
#include "screens/scriptCreator.hpp"
#include "utils/config.hpp"
// The to editing script.
nlohmann::json editScript;
void ScriptCreator::openJson() {
FILE* file = fopen("sdmc:/3ds/Universal-Updater/Test.json", "r");
if(file) editScript = nlohmann::json::parse(file, nullptr, false);
fclose(file);
}
void ScriptCreator::setBool(const std::string &object, const std::string &key, bool v) {
editScript[object][key] = v;
}
void ScriptCreator::setInt(const std::string &object, const std::string &key, int v) {
editScript[object][key] = v;
}
void ScriptCreator::setString(const std::string &object, const std::string &key, const std::string &v) {
editScript[object][key] = v;
}
void ScriptCreator::Draw(void) const {
Gui::DrawTop();
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("SCRIPTCREATOR"), 400);
Gui::DrawBottom();
}
// Testing purpose for now.
ScriptCreator::ScriptCreator() {
openJson();
}
void ScriptCreator::save() {
FILE* file = fopen("sdmc:/3ds/Universal-Updater/Test.json", "w");
if(file) fwrite(editScript.dump(1, '\t').c_str(), 1, editScript.dump(1, '\t').size(), file);
fclose(file);
}
void ScriptCreator::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
if (hDown & KEY_B) {
save();
Gui::screenBack();
return;
}
if (hDown & KEY_X) {
const std::string &test = Input::getString("Enter the Title of the Script.", 50);
const std::string &test2 = Input::getString("Enter the Author name of the Script.", 50);
const std::string &test3 = Input::getString("Enter the short description of the Script.", 80);
const std::string &test4 = Input::getString("Enter the long description of the Script.", 300);
setString("info", "title", test);
setString("info", "author", test2);
setString("info", "shortDesc", test3);
setString("info", "description", test4);
setInt("info", "version", 2);
setInt("info", "revision", 1);
}
}
+43
View File
@@ -0,0 +1,43 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019 VoltZ, Epicpkmn11, Flame, RocketRobz, 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/tinyDB.hpp"
#include "utils/config.hpp"
// To-Do.
void TinyDB::Draw(void) const {
Gui::DrawTop();
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, "TinyDB", 400);
Gui::DrawBottom();
}
void TinyDB::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
if (hDown & KEY_B) {
Gui::screenBack();
return;
}
}