mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-05 00:38:52 +00:00
Fully rewrite config.
This commit is contained in:
+28
-26
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "credits.hpp"
|
||||
|
||||
extern std::unique_ptr<Config> config;
|
||||
extern bool touching(touchPosition touch, Structs::ButtonPos button);
|
||||
// Language Page 1.
|
||||
const std::vector<std::string> Translators = {
|
||||
@@ -83,22 +84,23 @@ void Credits::Draw(void) const {
|
||||
title += Lang::get("CREDITS");
|
||||
GFX::DrawTop();
|
||||
if (creditsPage != 3) {
|
||||
if (Config::UseBars == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, title, 400);
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), title, 400);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, title, 400);
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), title, 400);
|
||||
}
|
||||
Gui::DrawStringCentered(0, 30, 0.7f, Config::TxtColor, Lang::get("DEVELOPED_BY"), 390);
|
||||
Gui::DrawStringCentered(0, 60, 0.7f, Config::TxtColor, Lang::get("MAIN_DEV"), 390);
|
||||
Gui::DrawStringCentered(0, 30, 0.7f, config->textColor(), Lang::get("DEVELOPED_BY"), 390);
|
||||
Gui::DrawStringCentered(0, 60, 0.7f, config->textColor(), Lang::get("MAIN_DEV"), 390);
|
||||
GFX::DrawSprite(sprites_stackie_idx, 5, 85);
|
||||
GFX::DrawSprite(sprites_universal_core_idx, 200, 110);
|
||||
std::string currentVersion = Lang::get("CURRENT_VERSION");
|
||||
currentVersion += V_STRING;
|
||||
Gui::DrawString(395-Gui::GetStringWidth(0.70f, currentVersion), 219, 0.70f, Config::TxtColor, currentVersion, 400);
|
||||
Gui::DrawString(395-Gui::GetStringWidth(0.70f, currentVersion), 219, 0.70f, config->textColor(), currentVersion, 400);
|
||||
} else {
|
||||
Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(0, 0, 0, 190));
|
||||
GFX::DrawSprite(sprites_discord_idx, 115, 35);
|
||||
}
|
||||
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
DrawBottom();
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
@@ -110,41 +112,41 @@ void Credits::DrawBottom(void) const {
|
||||
|
||||
GFX::DrawBottom();
|
||||
if (creditsPage == 0) {
|
||||
Gui::DrawStringCentered(0, -2, 0.7f, Config::TxtColor, Lang::get("TRANSLATORS"), 320);
|
||||
Gui::DrawStringCentered(0, -2, 0.7f, config->textColor(), Lang::get("TRANSLATORS"), 320);
|
||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)Translators.size();i++) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, Config::UnselectedColor);
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, config->unselectedColor());
|
||||
line1 = Translators[screenPos + i];
|
||||
line2 = Languages[screenPos + i];
|
||||
if (screenPos + i == Selection) {
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, TRANSPARENT, Config::SelectedColor);
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, TRANSPARENT, config->selectedColor());
|
||||
}
|
||||
Gui::DrawStringCentered(0, 38+(i*57), 0.7f, Config::TxtColor, line1, 320);
|
||||
Gui::DrawStringCentered(0, 62+(i*57), 0.7f, Config::TxtColor, line2, 320);
|
||||
Gui::DrawStringCentered(0, 38+(i*57), 0.7f, config->textColor(), line1, 320);
|
||||
Gui::DrawStringCentered(0, 62+(i*57), 0.7f, config->textColor(), line2, 320);
|
||||
}
|
||||
} else if (creditsPage == 1) {
|
||||
Gui::DrawStringCentered(0, -2, 0.7f, Config::TxtColor, "Universal-Team", 320);
|
||||
Gui::DrawStringCentered(0, -2, 0.7f, config->textColor(), "Universal-Team", 320);
|
||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)UniversalTeam.size();i++) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, Config::UnselectedColor);
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, config->unselectedColor());
|
||||
line1 = UniversalTeam[screenPos + i];
|
||||
if (screenPos + i == Selection) {
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, TRANSPARENT, Config::SelectedColor);
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, TRANSPARENT, config->selectedColor());
|
||||
}
|
||||
Gui::DrawStringCentered(0, 50+(i*57), 0.7f, WHITE, line1, 320);
|
||||
Gui::DrawStringCentered(0, 50+(i*57), 0.7f, config->textColor(), line1, 320);
|
||||
}
|
||||
} else if (creditsPage == 2) {
|
||||
Gui::DrawStringCentered(0, -2, 0.7f, Config::TxtColor, Lang::get("SCRIPTCREATORS"), 320);
|
||||
Gui::DrawStringCentered(0, -2, 0.7f, config->textColor(), Lang::get("SCRIPTCREATORS"), 320);
|
||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)ScriptCreators.size();i++) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, Config::UnselectedColor);
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, config->unselectedColor());
|
||||
line1 = ScriptCreators[screenPos + i];
|
||||
line2 = ScriptAmount[screenPos + i];
|
||||
if (screenPos + i == Selection) {
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, TRANSPARENT, Config::SelectedColor);
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, TRANSPARENT, config->selectedColor());
|
||||
}
|
||||
Gui::DrawStringCentered(0, 38+(i*57), 0.7f, Config::TxtColor, line1, 320);
|
||||
Gui::DrawStringCentered(0, 62+(i*57), 0.7f, Config::TxtColor, line2, 320);
|
||||
Gui::DrawStringCentered(0, 38+(i*57), 0.7f, config->textColor(), line1, 320);
|
||||
Gui::DrawStringCentered(0, 62+(i*57), 0.7f, config->textColor(), line2, 320);
|
||||
}
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, -2, 0.55f, Config::TxtColor, Lang::get("LINK"), 320);
|
||||
Gui::DrawStringCentered(0, -2, 0.55f, config->textColor(), Lang::get("LINK"), 320);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +162,7 @@ void Credits::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
Selection = 0;
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
} else if (creditsPage == 1) {
|
||||
if ((hHeld & KEY_DOWN && !keyRepeatDelay)) {
|
||||
@@ -170,7 +172,7 @@ void Credits::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
Selection = 0;
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
} else if (creditsPage == 2) {
|
||||
if ((hHeld & KEY_DOWN && !keyRepeatDelay)) {
|
||||
@@ -180,7 +182,7 @@ void Credits::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
Selection = 0;
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +198,7 @@ void Credits::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
Selection = (int)ScriptCreators.size()-1;
|
||||
}
|
||||
}
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +217,7 @@ void Credits::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
|
||||
if (hDown & KEY_B) {
|
||||
Gui::screenBack(Config::fading);
|
||||
Gui::screenBack(config->screenFade());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ extern "C" {
|
||||
#include "ftp.h"
|
||||
}
|
||||
|
||||
extern std::unique_ptr<Config> config;
|
||||
extern bool touching(touchPosition touch, Structs::ButtonPos button);
|
||||
extern touchPosition touch;
|
||||
|
||||
@@ -49,10 +50,10 @@ void FTPScreen::Draw(void) const {
|
||||
Gui::clearTextBufs();
|
||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||
GFX::DrawTop();
|
||||
if (Config::UseBars == true) {
|
||||
Gui::DrawString((400-Gui::GetStringWidth(0.7f, Lang::get("FTP_MODE")))/2, 0, 0.7f, Config::TxtColor, Lang::get("FTP_MODE"), 400);
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawString((400-Gui::GetStringWidth(0.7f, Lang::get("FTP_MODE")))/2, 0, 0.7f, config->textColor(), Lang::get("FTP_MODE"), 400);
|
||||
} else {
|
||||
Gui::DrawString((400-Gui::GetStringWidth(0.7f, Lang::get("FTP_MODE")))/2, 2, 0.7f, Config::TxtColor, Lang::get("FTP_MODE"), 400);
|
||||
Gui::DrawString((400-Gui::GetStringWidth(0.7f, Lang::get("FTP_MODE")))/2, 2, 0.7f, config->textColor(), Lang::get("FTP_MODE"), 400);
|
||||
}
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
GFX::DrawBottom();
|
||||
@@ -60,22 +61,22 @@ void FTPScreen::Draw(void) const {
|
||||
ret = ACU_GetWifiStatus(&wifiStatus);
|
||||
|
||||
if ((wifiStatus != 0) && R_SUCCEEDED(ret)) {
|
||||
Gui::DrawStringCentered(0, 40, 0.48f, Config::TxtColor, Lang::get("FTP_INITIALIZED"), 320);
|
||||
Gui::DrawStringCentered(0, 40, 0.48f, config->textColor(), Lang::get("FTP_INITIALIZED"), 320);
|
||||
snprintf(buf, 137, "IP: %s:5000", R_FAILED(ret)? Lang::get("FAILED_GET_IP").c_str() : hostname);
|
||||
|
||||
if (strlen(ftp_accepted_connection) != 0)
|
||||
Gui::DrawStringCentered(0, 80, 0.45f, Config::TxtColor, ftp_accepted_connection, 320);
|
||||
Gui::DrawStringCentered(0, 80, 0.45f, config->textColor(), ftp_accepted_connection, 320);
|
||||
|
||||
if (strlen(ftp_file_transfer) != 0)
|
||||
Gui::DrawStringCentered(0, 150, 0.45f, Config::TxtColor, ftp_file_transfer, 320);
|
||||
Gui::DrawStringCentered(0, 150, 0.45f, config->textColor(), ftp_file_transfer, 320);
|
||||
}
|
||||
else {
|
||||
Gui::DrawStringCentered(0, 40, 0.48f, Config::TxtColor, Lang::get("FAILED_INITIALIZE_FTP"), 320);
|
||||
Gui::DrawStringCentered(0, 40, 0.48f, config->textColor(), Lang::get("FAILED_INITIALIZE_FTP"), 320);
|
||||
snprintf(buf, 18, Lang::get("WIFI_NOT_ENABLED").c_str());
|
||||
}
|
||||
|
||||
Gui::DrawStringCentered(0, 60, 0.48, Config::TxtColor, buf, 320);
|
||||
Gui::DrawStringCentered(0, 222, 0.48f, Config::TxtColor, Lang::get("B_FTP_EXIT"), 320);
|
||||
Gui::DrawStringCentered(0, 60, 0.48, config->textColor(), buf, 320);
|
||||
Gui::DrawStringCentered(0, 222, 0.48f, config->textColor(), Lang::get("B_FTP_EXIT"), 320);
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
Gui::clearTextBufs();
|
||||
C3D_FrameEnd(0);
|
||||
|
||||
+15
-14
@@ -32,6 +32,7 @@
|
||||
#include "settings.hpp"
|
||||
#include "unistore.hpp"
|
||||
|
||||
extern std::unique_ptr<Config> config;
|
||||
extern bool exiting;
|
||||
extern bool touching(touchPosition touch, Structs::ButtonPos button);
|
||||
extern int fadealpha;
|
||||
@@ -41,12 +42,12 @@ extern u32 TextColor;
|
||||
void MainMenu::Draw(void) const {
|
||||
GFX::DrawTop();
|
||||
|
||||
if (Config::UseBars == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, "Universal-Updater", 400);
|
||||
Gui::DrawString(397-Gui::GetStringWidth(0.5f, V_STRING), 239-Gui::GetStringHeight(0.5f, V_STRING), 0.5f, Config::TxtColor, V_STRING);
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), "Universal-Updater", 400);
|
||||
Gui::DrawString(397-Gui::GetStringWidth(0.5f, V_STRING), 239-Gui::GetStringHeight(0.5f, V_STRING), 0.5f, config->textColor(), V_STRING);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, "Universal-Updater", 400);
|
||||
Gui::DrawString(397-Gui::GetStringWidth(0.5f, V_STRING), 237-Gui::GetStringHeight(0.5f, V_STRING), 0.5f, Config::TxtColor, V_STRING);
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), "Universal-Updater", 400);
|
||||
Gui::DrawString(397-Gui::GetStringWidth(0.5f, V_STRING), 237-Gui::GetStringHeight(0.5f, V_STRING), 0.5f, config->textColor(), V_STRING);
|
||||
}
|
||||
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
@@ -73,10 +74,10 @@ void MainMenu::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
|
||||
// Navigation.
|
||||
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_DOWN) {
|
||||
if (Selection < 3 && Selection != 2 && Selection != 3) Selection += 2;
|
||||
} else if (hDown & KEY_LEFT) {
|
||||
if (Selection%2) Selection--;
|
||||
} else if (hDown & KEY_RIGHT) {
|
||||
@@ -86,13 +87,13 @@ void MainMenu::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
if (hDown & KEY_A) {
|
||||
switch(Selection) {
|
||||
case 0:
|
||||
Gui::setScreen(std::make_unique<UniStore>(false, "NOT_USED"), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<UniStore>(false, "NOT_USED"), config->screenFade(), true);
|
||||
break;
|
||||
case 1:
|
||||
Gui::setScreen(std::make_unique<ScriptList>(), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<ScriptList>(), config->screenFade(), true);
|
||||
break;
|
||||
case 2:
|
||||
Gui::setScreen(std::make_unique<Settings>(), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<Settings>(), config->screenFade(), true);
|
||||
break;
|
||||
case 3:
|
||||
Gui::setScreen(std::make_unique<FTPScreen>(), false, true);
|
||||
@@ -102,11 +103,11 @@ void MainMenu::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
|
||||
if (hDown & KEY_TOUCH) {
|
||||
if (touching(touch, mainButtons[0])) {
|
||||
Gui::setScreen(std::make_unique<UniStore>(false, "NOT_USED"), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<UniStore>(false, "NOT_USED"), config->screenFade(), true);
|
||||
} else if (touching(touch, mainButtons[1])) {
|
||||
Gui::setScreen(std::make_unique<ScriptList>(), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<ScriptList>(), config->screenFade(), true);
|
||||
} else if (touching(touch, mainButtons[2])) {
|
||||
Gui::setScreen(std::make_unique<Settings>(), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<Settings>(), config->screenFade(), true);
|
||||
} else if (touching(touch, mainButtons[3])) {
|
||||
Gui::setScreen(std::make_unique<FTPScreen>(), false, true);
|
||||
}
|
||||
|
||||
+130
-121
@@ -31,17 +31,18 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
extern std::unique_ptr<Config> config;
|
||||
extern bool touching(touchPosition touch, Structs::ButtonPos button);
|
||||
extern void downloadFailed();
|
||||
|
||||
void fixInfo(nlohmann::json &json) {
|
||||
for(uint i=0;i<json.size();i++) {
|
||||
if(!json[i].contains("title")) json[i]["title"] = "TITLE";
|
||||
if(!json[i].contains("author")) json[i]["author"] = "AUTHOR";
|
||||
if(!json[i].contains("shortDesc")) json[i]["shortDesc"] = "SHORTDESC";
|
||||
if(!json[i].contains("revision")) json[i]["revision"] = 0;
|
||||
if(!json[i].contains("curRevision")) json[i]["curRevision"] = -1;
|
||||
if(!json[i].contains("version")) json[i]["revision"] = -1;
|
||||
for(uint i = 0; i < json.size(); i++) {
|
||||
if (!json[i].contains("title")) json[i]["title"] = "TITLE";
|
||||
if (!json[i].contains("author")) json[i]["author"] = "AUTHOR";
|
||||
if (!json[i].contains("shortDesc")) json[i]["shortDesc"] = "SHORTDESC";
|
||||
if (!json[i].contains("revision")) json[i]["revision"] = 0;
|
||||
if (!json[i].contains("curRevision")) json[i]["curRevision"] = -1;
|
||||
if (!json[i].contains("version")) json[i]["revision"] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,18 +50,17 @@ nlohmann::json infoFromScript(const std::string &path) {
|
||||
nlohmann::json in, out;
|
||||
|
||||
FILE* file = fopen(path.c_str(), "r");
|
||||
if(!file) {
|
||||
return out;
|
||||
}
|
||||
if (!file) return out;
|
||||
|
||||
in = nlohmann::json::parse(file, nullptr, false);
|
||||
fclose(file);
|
||||
|
||||
if(in.contains("info")) {
|
||||
if(in["info"].contains("title") && in["info"]["title"].is_string()) out["title"] = in["info"]["title"];
|
||||
if(in["info"].contains("author") && in["info"]["author"].is_string()) out["author"] = in["info"]["author"];
|
||||
if(in["info"].contains("shortDesc") && in["info"]["shortDesc"].is_string()) out["shortDesc"] = in["info"]["shortDesc"];
|
||||
if(in["info"].contains("version") && in["info"]["version"].is_number()) out["version"] = in["info"]["version"];
|
||||
if(in["info"].contains("revision") && in["info"]["revision"].is_number()) out["revision"] = in["info"]["revision"];
|
||||
if (in.contains("info")) {
|
||||
if (in["info"].contains("title") && in["info"]["title"].is_string()) out["title"] = in["info"]["title"];
|
||||
if (in["info"].contains("author") && in["info"]["author"].is_string()) out["author"] = in["info"]["author"];
|
||||
if (in["info"].contains("shortDesc") && in["info"]["shortDesc"].is_string()) out["shortDesc"] = in["info"]["shortDesc"];
|
||||
if (in["info"].contains("version") && in["info"]["version"].is_number()) out["version"] = in["info"]["version"];
|
||||
if (in["info"].contains("revision") && in["info"]["revision"].is_number()) out["revision"] = in["info"]["revision"];
|
||||
}
|
||||
|
||||
return out;
|
||||
@@ -68,17 +68,18 @@ nlohmann::json infoFromScript(const std::string &path) {
|
||||
|
||||
void findExistingFiles(nlohmann::json &json) {
|
||||
nlohmann::json current;
|
||||
chdir(Config::ScriptPath.c_str());
|
||||
chdir(config->scriptPath().c_str());
|
||||
std::vector<DirEntry> dirContents;
|
||||
getDirectoryContents(dirContents);
|
||||
for(uint i=0;i<dirContents.size();i++) {
|
||||
for(uint i = 0; i < dirContents.size(); i++) {
|
||||
current[i] = infoFromScript(dirContents[i].name);
|
||||
}
|
||||
|
||||
fixInfo(current);
|
||||
|
||||
for(uint i=0;i<json.size();i++) {
|
||||
for(uint j=0;j<current.size();j++) {
|
||||
if(current[j]["title"] == json[i]["title"]) {
|
||||
for(uint i = 0; i < json.size(); i++) {
|
||||
for(uint j = 0; j < current.size(); j++) {
|
||||
if (current[j]["title"] == json[i]["title"]) {
|
||||
json[i]["curRevision"] = current[j]["revision"];
|
||||
}
|
||||
}
|
||||
@@ -96,7 +97,7 @@ ScriptBrowse::ScriptBrowse() {
|
||||
}
|
||||
|
||||
FILE* file = fopen(metaFile, "r");
|
||||
if(file) {
|
||||
if (file) {
|
||||
infoJson = nlohmann::json::parse(file, nullptr, false);
|
||||
fclose(file);
|
||||
fixInfo(infoJson);
|
||||
@@ -118,8 +119,9 @@ void ScriptBrowse::refresh() {
|
||||
loaded = false;
|
||||
return;
|
||||
}
|
||||
|
||||
FILE* file = fopen(metaFile, "r");
|
||||
if(file) {
|
||||
if (file) {
|
||||
infoJson = nlohmann::json::parse(file, nullptr, false);
|
||||
fclose(file);
|
||||
fixInfo(infoJson);
|
||||
@@ -135,6 +137,7 @@ void ScriptBrowse::refresh() {
|
||||
notConnectedMsg();
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptBrowse::Draw(void) const {
|
||||
if (mode == 0) {
|
||||
DrawBrowse();
|
||||
@@ -150,24 +153,25 @@ void ScriptBrowse::DrawBrowse(void) const {
|
||||
revision += " | ";
|
||||
revision += std::to_string(int64_t(infoJson[Selection]["revision"]));
|
||||
|
||||
if (Config::UseBars == true) {
|
||||
Gui::DrawString(397-Gui::GetStringWidth(0.6f, revision), 239-Gui::GetStringHeight(0.6f, revision), 0.6f, Config::TxtColor, revision);
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, std::string(infoJson[Selection]["title"]), 400);
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawString(397-Gui::GetStringWidth(0.6f, revision), 239-Gui::GetStringHeight(0.6f, revision), 0.6f, config->textColor(), revision);
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), std::string(infoJson[Selection]["title"]), 400);
|
||||
} else {
|
||||
Gui::DrawString(397-Gui::GetStringWidth(0.6f, revision), 237-Gui::GetStringHeight(0.6f, revision), 0.6f, Config::TxtColor, revision);
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, std::string(infoJson[Selection]["title"]), 400);
|
||||
Gui::DrawString(397-Gui::GetStringWidth(0.6f, revision), 237-Gui::GetStringHeight(0.6f, revision), 0.6f, config->textColor(), revision);
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), std::string(infoJson[Selection]["title"]), 400);
|
||||
}
|
||||
|
||||
Gui::DrawStringCentered(0, 120, 0.6f, Config::TxtColor, std::string(infoJson[Selection]["shortDesc"]), 400);
|
||||
Gui::DrawStringCentered(0, 120, 0.6f, config->textColor(), std::string(infoJson[Selection]["shortDesc"]), 400);
|
||||
if (infoJson[Selection]["curRevision"] == -1) {
|
||||
Gui::DrawStringCentered(0, 219, 0.7f, Config::TxtColor, Lang::get("SCRIPT_NOT_FOUND"), 370);
|
||||
Gui::DrawStringCentered(0, 219, 0.7f, config->textColor(), Lang::get("SCRIPT_NOT_FOUND"), 370);
|
||||
} else if(infoJson[Selection]["curRevision"] < infoJson[Selection]["revision"]) {
|
||||
Gui::DrawStringCentered(0, 219, 0.7f, Config::TxtColor, Lang::get("OUTDATED_SCRIPT"), 370);
|
||||
Gui::DrawStringCentered(0, 219, 0.7f, config->textColor(), Lang::get("OUTDATED_SCRIPT"), 370);
|
||||
} else if(infoJson[Selection]["curRevision"] == infoJson[Selection]["revision"]) {
|
||||
Gui::DrawStringCentered(0, 219, 0.7f, Config::TxtColor, Lang::get("UP-TO-DATE"), 370);
|
||||
Gui::DrawStringCentered(0, 219, 0.7f, config->textColor(), Lang::get("UP-TO-DATE"), 370);
|
||||
} else if(infoJson[Selection]["curRevision"] > infoJson[Selection]["revision"]) {
|
||||
Gui::DrawStringCentered(0, 219, 0.7f, Config::TxtColor, Lang::get("FUTURE_SCRIPT"), 370);
|
||||
Gui::DrawStringCentered(0, 219, 0.7f, config->textColor(), Lang::get("FUTURE_SCRIPT"), 370);
|
||||
}
|
||||
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
GFX::DrawBottom();
|
||||
GFX::DrawArrow(295, -1);
|
||||
@@ -176,65 +180,66 @@ void ScriptBrowse::DrawBrowse(void) const {
|
||||
|
||||
GFX::DrawSpriteBlend(sprites_dropdown_idx, arrowPos[3].x, arrowPos[3].y);
|
||||
|
||||
Gui::DrawStringCentered(0, 1, 0.6f, Config::TxtColor, std::to_string(Selection + 1) + " | " + std::to_string(maxScripts));
|
||||
Gui::DrawStringCentered(0, 1, 0.6f, config->textColor(), std::to_string(Selection + 1) + " | " + std::to_string(maxScripts));
|
||||
|
||||
if (Config::viewMode == 0) {
|
||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)infoJson.size();i++) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, Config::UnselectedColor);
|
||||
if(screenPos + i == Selection) {
|
||||
if (config->viewMode() == 0) {
|
||||
for(int i = 0; i < ENTRIES_PER_SCREEN && i < (int)infoJson.size(); i++) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, config->unselectedColor());
|
||||
if (screenPos + i == Selection) {
|
||||
if (!dropDownMenu) {
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, TRANSPARENT, Config::SelectedColor);
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, TRANSPARENT, config->selectedColor());
|
||||
}
|
||||
}
|
||||
|
||||
if (infoJson[screenPos+i]["curRevision"] == -1) {
|
||||
Gui::Draw_Rect(295, 45+(i*59), 20, 20, Config::notFound);
|
||||
} else if(infoJson[screenPos+i]["curRevision"] < infoJson[screenPos+i]["revision"]) {
|
||||
Gui::Draw_Rect(295, 45+(i*59), 20, 20, Config::outdated);
|
||||
} else if(infoJson[screenPos+i]["curRevision"] == infoJson[screenPos+i]["revision"]) {
|
||||
Gui::Draw_Rect(295, 45+(i*59), 20, 20, Config::uptodate);
|
||||
} else if(infoJson[screenPos+i]["curRevision"] > infoJson[screenPos+i]["revision"]) {
|
||||
Gui::Draw_Rect(295, 45+(i*59), 20, 20, Config::future);
|
||||
Gui::Draw_Rect(295, 45+(i*59), 20, 20, config->notfoundColor());
|
||||
} else if (infoJson[screenPos+i]["curRevision"] < infoJson[screenPos+i]["revision"]) {
|
||||
Gui::Draw_Rect(295, 45+(i*59), 20, 20, config->outdatedColor());
|
||||
} else if (infoJson[screenPos+i]["curRevision"] == infoJson[screenPos+i]["revision"]) {
|
||||
Gui::Draw_Rect(295, 45+(i*59), 20, 20, config->uptodateColor());
|
||||
} else if (infoJson[screenPos+i]["curRevision"] > infoJson[screenPos+i]["revision"]) {
|
||||
Gui::Draw_Rect(295, 45+(i*59), 20, 20, config->futureColor());
|
||||
}
|
||||
|
||||
Gui::DrawStringCentered(0, 38+(i*57), 0.7f, Config::TxtColor, infoJson[screenPos+i]["title"], 317);
|
||||
Gui::DrawStringCentered(0, 62+(i*57), 0.7f, Config::TxtColor, infoJson[screenPos+i]["author"], 317);
|
||||
Gui::DrawStringCentered(0, 38+(i*57), 0.7f, config->textColor(), infoJson[screenPos+i]["title"], 317);
|
||||
Gui::DrawStringCentered(0, 62+(i*57), 0.7f, config->textColor(), infoJson[screenPos+i]["author"], 317);
|
||||
}
|
||||
} else if (Config::viewMode == 1) {
|
||||
for(int i=0;i<ENTRIES_PER_LIST && i<(int)infoJson.size();i++) {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, Config::UnselectedColor);
|
||||
if(screenPosList + i == Selection) {
|
||||
} else if (config->viewMode() == 1) {
|
||||
for(int i = 0; i < ENTRIES_PER_LIST && i < (int)infoJson.size(); i++) {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, config->unselectedColor());
|
||||
if (screenPosList + i == Selection) {
|
||||
if (!dropDownMenu) {
|
||||
Gui::drawAnimatedSelector(0, (i+1)*27, 320, 25, .060, TRANSPARENT, Config::SelectedColor);
|
||||
Gui::drawAnimatedSelector(0, (i+1)*27, 320, 25, .060, TRANSPARENT, config->selectedColor());
|
||||
}
|
||||
}
|
||||
|
||||
// Script not found.
|
||||
if (infoJson[screenPosList+i]["curRevision"] == -1) {
|
||||
Gui::Draw_Rect(302, ((i+1)*27)+7, 11, 11, Config::notFound);
|
||||
Gui::Draw_Rect(302, ((i+1)*27)+7, 11, 11, config->notfoundColor());
|
||||
// Script outdaed.
|
||||
} else if(infoJson[screenPosList+i]["curRevision"] < infoJson[screenPosList+i]["revision"]) {
|
||||
Gui::Draw_Rect(302, ((i+1)*27)+7, 11, 11, Config::outdated);
|
||||
} else if (infoJson[screenPosList+i]["curRevision"] < infoJson[screenPosList+i]["revision"]) {
|
||||
Gui::Draw_Rect(302, ((i+1)*27)+7, 11, 11, config->outdatedColor());
|
||||
// Script up-to-date.
|
||||
} else if(infoJson[screenPosList+i]["curRevision"] == infoJson[screenPosList+i]["revision"]) {
|
||||
Gui::Draw_Rect(302, ((i+1)*27)+7, 11, 11, Config::uptodate);
|
||||
} else if (infoJson[screenPosList+i]["curRevision"] == infoJson[screenPosList+i]["revision"]) {
|
||||
Gui::Draw_Rect(302, ((i+1)*27)+7, 11, 11, config->uptodateColor());
|
||||
// Future script.
|
||||
} else if(infoJson[screenPosList+i]["curRevision"] > infoJson[screenPosList+i]["revision"]) {
|
||||
Gui::Draw_Rect(302, ((i+1)*27)+7, 11, 11, Config::future);
|
||||
} else if (infoJson[screenPosList+i]["curRevision"] > infoJson[screenPosList+i]["revision"]) {
|
||||
Gui::Draw_Rect(302, ((i+1)*27)+7, 11, 11, config->futureColor());
|
||||
}
|
||||
|
||||
Gui::DrawStringCentered(0, ((i+1)*27)+1, 0.7f, Config::TxtColor, infoJson[screenPosList+i]["title"], 317);
|
||||
Gui::DrawStringCentered(0, ((i+1)*27)+1, 0.7f, config->textColor(), infoJson[screenPosList+i]["title"], 317);
|
||||
}
|
||||
}
|
||||
|
||||
// DropDown Menu.
|
||||
if (dropDownMenu) {
|
||||
// Draw Operation Box.
|
||||
Gui::Draw_Rect(0, 25, 140, 130, Config::Color1);
|
||||
Gui::Draw_Rect(0, 25, 140, 130, config->barColor());
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (dropSelection == i) {
|
||||
Gui::drawAnimatedSelector(dropPos2[i].x, dropPos2[i].y, dropPos2[i].w, dropPos2[i].h, .090, TRANSPARENT, Config::SelectedColor);
|
||||
Gui::drawAnimatedSelector(dropPos2[i].x, dropPos2[i].y, dropPos2[i].w, dropPos2[i].h, .090, TRANSPARENT, config->selectedColor());
|
||||
} else {
|
||||
Gui::Draw_Rect(dropPos2[i].x, dropPos2[i].y, dropPos2[i].w, dropPos2[i].h, Config::UnselectedColor);
|
||||
Gui::Draw_Rect(dropPos2[i].x, dropPos2[i].y, dropPos2[i].w, dropPos2[i].h, config->unselectedColor());
|
||||
}
|
||||
}
|
||||
// Draw Dropdown Icons.
|
||||
@@ -242,9 +247,9 @@ void ScriptBrowse::DrawBrowse(void) const {
|
||||
GFX::DrawSpriteBlend(sprites_update_idx, dropPos[1].x, dropPos[1].y);
|
||||
GFX::DrawSpriteBlend(sprites_view_idx, dropPos[2].x, dropPos[2].y);
|
||||
// Dropdown Text.
|
||||
Gui::DrawString(dropPos[0].x+30, dropPos[0].y+5, 0.4f, Config::TxtColor, Lang::get("DOWNLOAD_ALL_DDM"), 100);
|
||||
Gui::DrawString(dropPos[1].x+30, dropPos[1].y+5, 0.4f, Config::TxtColor, Lang::get("REFRESH_BROWSE_DDM"), 100);
|
||||
Gui::DrawString(dropPos[2].x+30, dropPos[2].y+5, 0.4f, Config::TxtColor, Lang::get("VIEW_DDM"), 100);
|
||||
Gui::DrawString(dropPos[0].x+30, dropPos[0].y+5, 0.4f, config->textColor(), Lang::get("DOWNLOAD_ALL_DDM"), 100);
|
||||
Gui::DrawString(dropPos[1].x+30, dropPos[1].y+5, 0.4f, config->textColor(), Lang::get("REFRESH_BROWSE_DDM"), 100);
|
||||
Gui::DrawString(dropPos[2].x+30, dropPos[2].y+5, 0.4f, config->textColor(), Lang::get("VIEW_DDM"), 100);
|
||||
}
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
} else {
|
||||
@@ -257,42 +262,42 @@ void ScriptBrowse::DrawBrowse(void) const {
|
||||
void ScriptBrowse::DrawGlossary(void) const {
|
||||
GFX::DrawTop();
|
||||
if (loaded) {
|
||||
if (Config::UseBars == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, Lang::get("GLOSSARY"), 400);
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), Lang::get("GLOSSARY"), 400);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("GLOSSARY"), 400);
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), Lang::get("GLOSSARY"), 400);
|
||||
}
|
||||
|
||||
Gui::Draw_Rect(20, 30, 30, 30, Config::notFound);
|
||||
Gui::DrawString(65, 35, 0.7f, Config::TxtColor, Lang::get("SCRIPT_NOT_FOUND"), 300);
|
||||
Gui::Draw_Rect(20, 30, 30, 30, config->notfoundColor());
|
||||
Gui::DrawString(65, 35, 0.7f, config->textColor(), Lang::get("SCRIPT_NOT_FOUND"), 300);
|
||||
|
||||
Gui::Draw_Rect(20, 70, 30, 30, Config::outdated);
|
||||
Gui::DrawString(65, 75, 0.7f, Config::TxtColor, Lang::get("OUTDATED_SCRIPT"), 300);
|
||||
Gui::Draw_Rect(20, 70, 30, 30, config->outdatedColor());
|
||||
Gui::DrawString(65, 75, 0.7f, config->textColor(), Lang::get("OUTDATED_SCRIPT"), 300);
|
||||
|
||||
Gui::Draw_Rect(20, 110, 30, 30, Config::uptodate);
|
||||
Gui::DrawString(65, 115, 0.7f, Config::TxtColor, Lang::get("UP-TO-DATE"), 300);
|
||||
Gui::Draw_Rect(20, 110, 30, 30, config->uptodateColor());
|
||||
Gui::DrawString(65, 115, 0.7f, config->textColor(), Lang::get("UP-TO-DATE"), 300);
|
||||
|
||||
Gui::Draw_Rect(20, 150, 30, 30, Config::future);
|
||||
Gui::DrawString(65, 155, 0.7f, Config::TxtColor, Lang::get("FUTURE_SCRIPT"), 300);
|
||||
Gui::Draw_Rect(20, 150, 30, 30, config->futureColor());
|
||||
Gui::DrawString(65, 155, 0.7f, config->textColor(), Lang::get("FUTURE_SCRIPT"), 300);
|
||||
|
||||
Gui::DrawString(15, 185, 0.7f, Config::TxtColor, std::to_string(int64_t(infoJson[Selection]["curRevision"])) + " | " + std::to_string(int64_t(infoJson[Selection]["revision"])), 40);
|
||||
Gui::DrawString(65, 185, 0.7f, Config::TxtColor, Lang::get("REVISION"), 300);
|
||||
Gui::DrawString(15, 185, 0.7f, config->textColor(), std::to_string(int64_t(infoJson[Selection]["curRevision"])) + " | " + std::to_string(int64_t(infoJson[Selection]["revision"])), 40);
|
||||
Gui::DrawString(65, 185, 0.7f, config->textColor(), Lang::get("REVISION"), 300);
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
GFX::DrawBottom();
|
||||
GFX::DrawSpriteBlend(sprites_download_all_idx, 20, 25);
|
||||
Gui::DrawString(50, 27, 0.6f, Config::TxtColor, Lang::get("DOWNLOAD_ALL"), 260);
|
||||
Gui::DrawString(50, 27, 0.6f, config->textColor(), Lang::get("DOWNLOAD_ALL"), 260);
|
||||
GFX::DrawSpriteBlend(sprites_view_idx, 20, 55);
|
||||
Gui::DrawString(50, 57, 0.6f, Config::TxtColor, Lang::get("CHANGE_VIEW_MODE"), 260);
|
||||
Gui::DrawString(50, 57, 0.6f, config->textColor(), Lang::get("CHANGE_VIEW_MODE"), 260);
|
||||
GFX::DrawArrow(20, 85);
|
||||
Gui::DrawString(50, 87, 0.6f, Config::TxtColor, Lang::get("ENTRY_UP"), 260);
|
||||
Gui::DrawString(50, 87, 0.6f, config->textColor(), Lang::get("ENTRY_UP"), 260);
|
||||
GFX::DrawArrow(42, 140, 180.0);
|
||||
Gui::DrawString(50, 117, 0.6f, Config::TxtColor, Lang::get("ENTRY_DOWN"), 260);
|
||||
Gui::DrawString(50, 117, 0.6f, config->textColor(), Lang::get("ENTRY_DOWN"), 260);
|
||||
GFX::DrawArrow(20, 145, 0, 1);
|
||||
Gui::DrawString(50, 147, 0.6f, Config::TxtColor, Lang::get("GO_BACK"), 260);
|
||||
Gui::DrawString(10, 177, 0.6f, Config::TxtColor, std::to_string(Selection + 1) + " | " + std::to_string(maxScripts), 35);
|
||||
Gui::DrawString(50, 177, 0.6f, Config::TxtColor, Lang::get("ENTRY"), 260);
|
||||
Gui::DrawString(50, 147, 0.6f, config->textColor(), Lang::get("GO_BACK"), 260);
|
||||
Gui::DrawString(10, 177, 0.6f, config->textColor(), std::to_string(Selection + 1) + " | " + std::to_string(maxScripts), 35);
|
||||
Gui::DrawString(50, 177, 0.6f, config->textColor(), Lang::get("ENTRY"), 260);
|
||||
GFX::DrawSpriteBlend(sprites_update_idx, 20, 195);
|
||||
Gui::DrawString(50, 197, 0.6f, Config::TxtColor, Lang::get("REFRESH_SCRIPTBROWSE"), 260);
|
||||
Gui::DrawString(50, 197, 0.6f, config->textColor(), Lang::get("REFRESH_SCRIPTBROWSE"), 260);
|
||||
GFX::DrawArrow(0, 218, 0, 1);
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
} else {
|
||||
@@ -325,10 +330,10 @@ void ScriptBrowse::DropDownLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
refresh();
|
||||
break;
|
||||
case 2:
|
||||
if (Config::viewMode == 0) {
|
||||
Config::viewMode = 1;
|
||||
if (config->viewMode() == 0) {
|
||||
config->viewMode(1);
|
||||
} else {
|
||||
Config::viewMode = 0;
|
||||
config->viewMode(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -343,10 +348,10 @@ void ScriptBrowse::DropDownLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
refresh();
|
||||
dropDownMenu = false;
|
||||
} else if (touching(touch, dropPos2[2])) {
|
||||
if (Config::viewMode == 0) {
|
||||
Config::viewMode = 1;
|
||||
if (config->viewMode() == 0) {
|
||||
config->viewMode(1);
|
||||
} else {
|
||||
Config::viewMode = 0;
|
||||
config->viewMode(0);
|
||||
}
|
||||
dropDownMenu = false;
|
||||
}
|
||||
@@ -366,8 +371,9 @@ void ScriptBrowse::downloadAll() {
|
||||
titleFix[l] = '-';
|
||||
}
|
||||
}
|
||||
|
||||
Msg::DisplayMsg(fileName + " " + std::to_string(current) + " / " + std::to_string(total));
|
||||
downloadToFile(infoJson[i]["url"], Config::ScriptPath + titleFix + ".json");
|
||||
downloadToFile(infoJson[i]["url"], config->scriptPath() + titleFix + ".json");
|
||||
infoJson[i]["curRevision"] = infoJson[i]["revision"];
|
||||
}
|
||||
}
|
||||
@@ -380,9 +386,10 @@ void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
DropDownLogic(hDown, hHeld, touch);
|
||||
} else {
|
||||
if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) {
|
||||
Gui::screenBack(Config::fading);
|
||||
Gui::screenBack(config->screenFade());
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode == 0) {
|
||||
if ((hHeld & KEY_DOWN && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[1]))) {
|
||||
if (Selection < (int)infoJson.size()-1) {
|
||||
@@ -391,11 +398,11 @@ void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
Selection = 0;
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
if ((hHeld & KEY_RIGHT && !keyRepeatDelay)) {
|
||||
if (Config::viewMode == 0) {
|
||||
if (config->viewMode() == 0) {
|
||||
if (Selection < (int)infoJson.size()-1-3) {
|
||||
Selection += 3;
|
||||
} else {
|
||||
@@ -409,11 +416,11 @@ void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
if ((hHeld & KEY_LEFT && !keyRepeatDelay)) {
|
||||
if (Config::viewMode == 0) {
|
||||
if (config->viewMode() == 0) {
|
||||
if (Selection > 2) {
|
||||
Selection -= 3;
|
||||
} else {
|
||||
@@ -427,7 +434,7 @@ void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
if ((hDown & KEY_SELECT) || (hDown & KEY_TOUCH && touching(touch, arrowPos[3]))) {
|
||||
@@ -441,13 +448,13 @@ void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
Selection = (int)infoJson.size()-1;
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
if (hDown & KEY_TOUCH) {
|
||||
if (Config::viewMode == 0) {
|
||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)infoJson.size();i++) {
|
||||
if(touch.py > 40+(i*57) && touch.py < 40+(i*57)+45) {
|
||||
if (config->viewMode() == 0) {
|
||||
for(int i = 0; i < ENTRIES_PER_SCREEN && i < (int)infoJson.size(); i++) {
|
||||
if (touch.py > 40+(i*57) && touch.py < 40+(i*57)+45) {
|
||||
if (infoJson.size() != 0) {
|
||||
std::string fileName = Lang::get("DOWNLOADING") + std::string(infoJson[screenPos + i]["title"]);
|
||||
std::string titleFix = infoJson[screenPos + i]["title"];
|
||||
@@ -455,16 +462,17 @@ void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
if (titleFix[l] == '/') {
|
||||
titleFix[l] = '-';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Msg::DisplayMsg(fileName);
|
||||
downloadToFile(infoJson[screenPos + i]["url"], Config::ScriptPath + titleFix + ".json");
|
||||
downloadToFile(infoJson[screenPos + i]["url"], config->scriptPath() + titleFix + ".json");
|
||||
infoJson[screenPos + i]["curRevision"] = infoJson[screenPos + i]["revision"];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (Config::viewMode == 1) {
|
||||
for(int i=0;i<ENTRIES_PER_LIST && i<(int)infoJson.size();i++) {
|
||||
if(touch.py > (i+1)*27 && touch.py < (i+2)*27) {
|
||||
} else if (config->viewMode() == 1) {
|
||||
for(int i = 0; i < ENTRIES_PER_LIST && i < (int)infoJson.size(); i++) {
|
||||
if (touch.py > (i+1)*27 && touch.py < (i+2)*27) {
|
||||
if (infoJson.size() != 0) {
|
||||
std::string fileName = Lang::get("DOWNLOADING") + std::string(infoJson[screenPosList + i]["title"]);
|
||||
std::string titleFix = infoJson[screenPosList + i]["title"];
|
||||
@@ -473,8 +481,9 @@ void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
titleFix[l] = '-';
|
||||
}
|
||||
}
|
||||
|
||||
Msg::DisplayMsg(fileName);
|
||||
downloadToFile(infoJson[screenPosList + i]["url"], Config::ScriptPath + titleFix + ".json");
|
||||
downloadToFile(infoJson[screenPosList + i]["url"], config->scriptPath() + titleFix + ".json");
|
||||
infoJson[screenPosList + i]["curRevision"] = infoJson[screenPosList + i]["revision"];
|
||||
}
|
||||
}
|
||||
@@ -486,26 +495,26 @@ void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
if (infoJson.size() != 0) {
|
||||
std::string fileName = Lang::get("DOWNLOADING") + std::string(infoJson[Selection]["title"]);
|
||||
|
||||
std::string titleFix = infoJson[Selection]["title"];
|
||||
for (int i = 0; i < (int)titleFix.size(); i++) {
|
||||
if (titleFix[i] == '/') {
|
||||
titleFix[i] = '-';
|
||||
std::string titleFix = infoJson[Selection]["title"];
|
||||
for (int i = 0; i < (int)titleFix.size(); i++) {
|
||||
if (titleFix[i] == '/') {
|
||||
titleFix[i] = '-';
|
||||
}
|
||||
}
|
||||
}
|
||||
Msg::DisplayMsg(fileName);
|
||||
|
||||
downloadToFile(infoJson[Selection]["url"], Config::ScriptPath + titleFix + ".json");
|
||||
Msg::DisplayMsg(fileName);
|
||||
downloadToFile(infoJson[Selection]["url"], config->scriptPath() + titleFix + ".json");
|
||||
infoJson[Selection]["curRevision"] = infoJson[Selection]["revision"];
|
||||
}
|
||||
}
|
||||
|
||||
if (Config::viewMode == 0) {
|
||||
if (config->viewMode() == 0) {
|
||||
if(Selection < screenPos) {
|
||||
screenPos = Selection;
|
||||
} else if (Selection > screenPos + ENTRIES_PER_SCREEN - 1) {
|
||||
screenPos = Selection - ENTRIES_PER_SCREEN + 1;
|
||||
}
|
||||
} else if (Config::viewMode == 1) {
|
||||
} else if (config->viewMode() == 1) {
|
||||
if(Selection < screenPosList) {
|
||||
screenPosList = Selection;
|
||||
} else if (Selection > screenPosList + ENTRIES_PER_LIST - 1) {
|
||||
@@ -521,7 +530,7 @@ void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
} else {
|
||||
if (hDown & KEY_B) {
|
||||
Gui::screenBack(Config::fading);
|
||||
Gui::screenBack(config->screenFade());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "utils/fileBrowse.hpp"
|
||||
#include "fileBrowse.hpp"
|
||||
#include "keyboard.hpp"
|
||||
#include "logging.hpp"
|
||||
#include "scriptCreator.hpp"
|
||||
@@ -32,14 +32,15 @@
|
||||
#include <fstream>
|
||||
#include <unistd.h>
|
||||
|
||||
extern std::unique_ptr<Config> config;
|
||||
// The to editing script.
|
||||
nlohmann::json editScript;
|
||||
std::string entryName = ""; // So we can set to *that* entry.
|
||||
|
||||
void ScriptCreator::openJson(std::string fileName) {
|
||||
std::string scriptFile = Config::ScriptPath + fileName;
|
||||
std::string scriptFile = config->scriptPath() + fileName;
|
||||
FILE* file = fopen(scriptFile.c_str(), "r");
|
||||
if(file) editScript = nlohmann::json::parse(file, nullptr, false);
|
||||
if (file) editScript = nlohmann::json::parse(file, nullptr, false);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
@@ -78,71 +79,73 @@ void ScriptCreator::Draw(void) const {
|
||||
|
||||
void ScriptCreator::DrawSubMenu(void) const {
|
||||
GFX::DrawTop();
|
||||
if (Config::UseBars == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, Lang::get("SCRIPTCREATOR"), 400);
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), Lang::get("SCRIPTCREATOR"), 400);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("SCRIPTCREATOR"), 400);
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), Lang::get("SCRIPTCREATOR"), 400);
|
||||
}
|
||||
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
GFX::DrawBottom();
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (Selection == i) {
|
||||
Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, Config::SelectedColor);
|
||||
Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, config->selectedColor());
|
||||
} else {
|
||||
Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, Config::UnselectedColor);
|
||||
Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, config->unselectedColor());
|
||||
}
|
||||
}
|
||||
|
||||
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "New script"))/2, mainButtons[0].y+10, 0.6f, Config::TxtColor, "New script", 140);
|
||||
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "Existing script"))/2, mainButtons[1].y+10, 0.6f, Config::TxtColor, "Existing script", 140);
|
||||
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "New script"))/2, mainButtons[0].y+10, 0.6f, config->textColor(), "New script", 140);
|
||||
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "Existing script"))/2, mainButtons[1].y+10, 0.6f, config->textColor(), "Existing script", 140);
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
}
|
||||
|
||||
void ScriptCreator::DrawScriptScreen(void) const {
|
||||
GFX::DrawTop();
|
||||
if (Config::UseBars == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, "Selected Entry: " + entryName, 400);
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), "Selected Entry: " + entryName, 400);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, "Selected Entry: " + entryName, 400);
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), "Selected Entry: " + entryName, 400);
|
||||
}
|
||||
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
GFX::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);
|
||||
Gui::DrawString(260, 3, 0.6f, config->textColor(), 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);
|
||||
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::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);
|
||||
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "downloadRelease"))/2-150+70, creatorButtons[0].y+10, 0.6f, config->textColor(), "downloadRelease", 140);
|
||||
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "downloadFile"))/2+150-70, creatorButtons[1].y+10, 0.6f, config->textColor(), "downloadFile", 140);
|
||||
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "deleteFile"))/2-150+70, creatorButtons[2].y+10, 0.6f, config->textColor(), "deleteFile", 140);
|
||||
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "extractFile"))/2+150-70, creatorButtons[3].y+10, 0.6f, config->textColor(), "extractFile", 140);
|
||||
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "installCia"))/2-150+70, creatorButtons[4].y+10, 0.6f, config->textColor(), "installCia", 140);
|
||||
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "mkdir"))/2+150-70, creatorButtons[5].y+10, 0.6f, config->textColor(), "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);
|
||||
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::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);
|
||||
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "rmdir"))/2-150+70, creatorButtons[0].y+10, 0.6f, config->textColor(), "rmdir", 140);
|
||||
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "mkfile"))/2+150-70, creatorButtons[1].y+10, 0.6f, config->textColor(), "mkfile", 140);
|
||||
Gui::DrawString((320-Gui::GetStringWidth(0.6f, "TimeMsg"))/2-150+70, creatorButtons[2].y+10, 0.6f, config->textColor(), "TimeMsg", 140);
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
}
|
||||
}
|
||||
@@ -286,14 +289,14 @@ void ScriptCreator::setInfoStuff(void) {
|
||||
|
||||
void ScriptCreator::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
if (hDown & KEY_B) {
|
||||
Gui::screenBack(Config::fading);
|
||||
Gui::screenBack(config->screenFade());
|
||||
return;
|
||||
}
|
||||
|
||||
if (hDown & KEY_A) {
|
||||
switch(Selection) {
|
||||
case 0:
|
||||
jsonFileName = Config::ScriptPath;
|
||||
jsonFileName = config->scriptPath();
|
||||
jsonFileName += Input::getString(20, "Enter the name of the JSON file.");
|
||||
if (jsonFileName != "") {
|
||||
jsonFileName += ".json";
|
||||
@@ -305,7 +308,7 @@ void ScriptCreator::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
std::string tempScript = selectFilePath("Select the Script file.", Config::ScriptPath, {"json"}, 2);
|
||||
std::string tempScript = selectFilePath("Select the Script file.", config->scriptPath(), {"json"}, 2);
|
||||
if (tempScript != "") {
|
||||
jsonFileName = tempScript;
|
||||
if(access(jsonFileName.c_str(), F_OK) != -1 ) {
|
||||
@@ -339,27 +342,34 @@ void ScriptCreator::scriptLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
// Page 1.
|
||||
if (page == 0) {
|
||||
if (hDown & KEY_UP) {
|
||||
if(Selection > 1) Selection -= 2;
|
||||
if (Selection > 1) Selection -= 2;
|
||||
}
|
||||
|
||||
if (hDown & KEY_DOWN) {
|
||||
if(Selection < 4) Selection += 2;
|
||||
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;
|
||||
}
|
||||
|
||||
+221
-208
@@ -35,6 +35,7 @@
|
||||
#include <regex>
|
||||
#include <unistd.h>
|
||||
|
||||
extern std::unique_ptr<Config> config;
|
||||
extern bool touching(touchPosition touch, Structs::ButtonPos button);
|
||||
extern bool checkWifiStatus(void);
|
||||
extern void notImplemented(void);
|
||||
@@ -45,10 +46,11 @@ extern bool changesMade;
|
||||
// Parse the script for the list.
|
||||
ScriptInfo parseInfo(std::string fileName) {
|
||||
FILE* file = fopen(fileName.c_str(), "rt");
|
||||
if(!file) {
|
||||
printf("File not found\n");
|
||||
if (!file) {
|
||||
printf("File not found.\n");
|
||||
return {"", ""};
|
||||
}
|
||||
|
||||
nlohmann::json json = nlohmann::json::parse(file, nullptr, false);
|
||||
fclose(file);
|
||||
|
||||
@@ -74,7 +76,7 @@ void ScriptList::checkForValidate(void) {
|
||||
nlohmann::json ScriptList::openScriptFile() {
|
||||
FILE* file = fopen(currentFile.c_str(), "rt");
|
||||
nlohmann::json jsonFile;
|
||||
if(file) jsonFile = nlohmann::json::parse(file, nullptr, false);
|
||||
if (file) jsonFile = nlohmann::json::parse(file, nullptr, false);
|
||||
fclose(file);
|
||||
return jsonFile;
|
||||
}
|
||||
@@ -82,19 +84,21 @@ nlohmann::json ScriptList::openScriptFile() {
|
||||
// Parse the objects from a script.
|
||||
std::vector<std::string> parseObjects(std::string fileName) {
|
||||
FILE* file = fopen(fileName.c_str(), "rt");
|
||||
if(!file) {
|
||||
printf("File not found\n");
|
||||
if (!file) {
|
||||
printf("File not found.\n");
|
||||
return {{""}};
|
||||
}
|
||||
|
||||
nlohmann::json json = nlohmann::json::parse(file, nullptr, false);
|
||||
fclose(file);
|
||||
|
||||
std::vector<std::string> objs;
|
||||
for(auto it = json.begin();it != json.end(); it++) {
|
||||
if(it.key() != "info") {
|
||||
for(auto it = json.begin(); it != json.end(); it++) {
|
||||
if (it.key() != "info") {
|
||||
objs.push_back(it.key());
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
@@ -109,7 +113,7 @@ std::string Description(nlohmann::json &json) {
|
||||
|
||||
// Return the color for the script.
|
||||
u32 getColor(std::string colorString) {
|
||||
if(colorString.length() < 7 || std::regex_search(colorString.substr(1), std::regex("[^0-9a-f]"))) { // invalid color
|
||||
if (colorString.length() < 7 || std::regex_search(colorString.substr(1), std::regex("[^0-9a-f]"))) { // invalid color
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -132,34 +136,35 @@ u32 progressBar;
|
||||
void loadColors(nlohmann::json &json) {
|
||||
u32 colorTemp;
|
||||
colorTemp = getColor(ScriptHelper::getString(json, "info", "barColor"));
|
||||
barColor = colorTemp == 0 ? Config::Color1 : colorTemp;
|
||||
barColor = colorTemp == 0 ? config->barColor() : colorTemp;
|
||||
|
||||
colorTemp = getColor(ScriptHelper::getString(json, "info", "bgTopColor"));
|
||||
bgTopColor = colorTemp == 0 ? Config::Color2 : colorTemp;
|
||||
bgTopColor = colorTemp == 0 ? config->topBG() : colorTemp;
|
||||
|
||||
colorTemp = getColor(ScriptHelper::getString(json, "info", "bgBottomColor"));
|
||||
bgBottomColor = colorTemp == 0 ? Config::Color3 : colorTemp;
|
||||
bgBottomColor = colorTemp == 0 ? config->bottomBG() : colorTemp;
|
||||
|
||||
colorTemp = getColor(ScriptHelper::getString(json, "info", "textColor"));
|
||||
TextColor = colorTemp == 0 ? Config::TxtColor : colorTemp;
|
||||
TextColor = colorTemp == 0 ? config->textColor() : colorTemp;
|
||||
|
||||
colorTemp = getColor(ScriptHelper::getString(json, "info", "selectedColor"));
|
||||
selected = colorTemp == 0 ? Config::SelectedColor : colorTemp;
|
||||
selected = colorTemp == 0 ? config->selectedColor() : colorTemp;
|
||||
|
||||
colorTemp = getColor(ScriptHelper::getString(json, "info", "unselectedColor"));
|
||||
unselected = colorTemp == 0 ? Config::UnselectedColor : colorTemp;
|
||||
unselected = colorTemp == 0 ? config->unselectedColor() : colorTemp;
|
||||
|
||||
colorTemp = getColor(ScriptHelper::getString(json, "info", "progressbarColor"));
|
||||
progressBar = colorTemp == 0 ? Config::progressbarColor : colorTemp;
|
||||
progressBar = colorTemp == 0 ? config->progressbarColor() : colorTemp;
|
||||
}
|
||||
|
||||
void ScriptList::DrawSubMenu(void) const {
|
||||
GFX::DrawTop();
|
||||
if (Config::UseBars == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, Lang::get("SCRIPTS_SUBMENU"), 400);
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), Lang::get("SCRIPTS_SUBMENU"), 400);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("SCRIPTS_SUBMENU"), 400);
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), Lang::get("SCRIPTS_SUBMENU"), 400);
|
||||
}
|
||||
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
GFX::DrawBottom();
|
||||
GFX::DrawArrow(0, 218, 0, 1);
|
||||
@@ -168,6 +173,7 @@ void ScriptList::DrawSubMenu(void) const {
|
||||
GFX::DrawButton(subPos[1].x, subPos[1].y, Lang::get("GET_SCRIPTS"));
|
||||
GFX::DrawButton(subPos[2].x, subPos[2].y, Lang::get("SCRIPTCREATOR"));
|
||||
GFX::DrawButton(subPos[3].x, subPos[3].y, Lang::get("CHANGE_SCRIPTPATH"));
|
||||
|
||||
// Selector.
|
||||
Animation::Button(subPos[Selection].x, subPos[Selection].y, .060);
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
@@ -180,6 +186,7 @@ void ScriptList::loadDesc(void) {
|
||||
lines.push_back(Desc.substr(0, Desc.find('\n')));
|
||||
Desc = Desc.substr(Desc.find('\n')+1);
|
||||
}
|
||||
|
||||
lines.push_back(Desc.substr(0, Desc.find('\n')));
|
||||
}
|
||||
|
||||
@@ -190,15 +197,15 @@ bool changeBackHandle = false;
|
||||
ScriptList::ScriptList() {
|
||||
if (AutobootWhat == 2) {
|
||||
// If Script isn't found, go to MainMenu.
|
||||
if (access(Config::AutobootFile.c_str(), F_OK) != 0) {
|
||||
if (access(config->autobootFile().c_str(), F_OK) != 0) {
|
||||
AutobootWhat = 0;
|
||||
changeBackHandle = true;
|
||||
Gui::setScreen(std::make_unique<MainMenu>(), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<MainMenu>(), config->screenFade(), true);
|
||||
}
|
||||
|
||||
if (ScriptHelper::checkIfValid(Config::AutobootFile) == true) {
|
||||
ScriptInfo fI = parseInfo(Config::AutobootFile);
|
||||
currentFile = Config::AutobootFile;
|
||||
if (ScriptHelper::checkIfValid(config->autobootFile()) == true) {
|
||||
ScriptInfo fI = parseInfo(config->autobootFile());
|
||||
currentFile = config->autobootFile();
|
||||
selectedTitle = fI.title;
|
||||
jsonFile = openScriptFile();
|
||||
Desc = Description(jsonFile);
|
||||
@@ -214,7 +221,7 @@ ScriptList::ScriptList() {
|
||||
} else {
|
||||
AutobootWhat = 0;
|
||||
changeBackHandle = true;
|
||||
Gui::setScreen(std::make_unique<MainMenu>(), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<MainMenu>(), config->screenFade(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -224,16 +231,17 @@ void ScriptList::DrawList(void) const {
|
||||
std::string line2;
|
||||
std::string scriptAmount = std::to_string(Selection +1) + " | " + std::to_string(fileInfo.size());
|
||||
GFX::DrawTop();
|
||||
if (Config::UseBars == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, "Universal-Updater", 400);
|
||||
Gui::DrawString(397-Gui::GetStringWidth(0.6f, scriptAmount), 239-Gui::GetStringHeight(0.6f, scriptAmount), 0.6f, Config::TxtColor, scriptAmount);
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), "Universal-Updater", 400);
|
||||
Gui::DrawString(397-Gui::GetStringWidth(0.6f, scriptAmount), 239-Gui::GetStringHeight(0.6f, scriptAmount), 0.6f, config->textColor(), scriptAmount);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, "Universal-Updater", 400);
|
||||
Gui::DrawString(397-Gui::GetStringWidth(0.6f, scriptAmount), 237-Gui::GetStringHeight(0.6f, scriptAmount), 0.6f, Config::TxtColor, scriptAmount);
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), "Universal-Updater", 400);
|
||||
Gui::DrawString(397-Gui::GetStringWidth(0.6f, scriptAmount), 237-Gui::GetStringHeight(0.6f, scriptAmount), 0.6f, config->textColor(), scriptAmount);
|
||||
}
|
||||
Gui::DrawStringCentered(0, 80, 0.7f, Config::TxtColor, Lang::get("TITLE") + std::string(fileInfo[Selection].title), 400);
|
||||
Gui::DrawStringCentered(0, 100, 0.7f, Config::TxtColor, Lang::get("AUTHOR") + std::string(fileInfo[Selection].author), 400);
|
||||
Gui::DrawStringCentered(0, 120, 0.6f, Config::TxtColor, std::string(fileInfo[Selection].shortDesc), 400);
|
||||
|
||||
Gui::DrawStringCentered(0, 80, 0.7f, config->textColor(), Lang::get("TITLE") + std::string(fileInfo[Selection].title), 400);
|
||||
Gui::DrawStringCentered(0, 100, 0.7f, config->textColor(), Lang::get("AUTHOR") + std::string(fileInfo[Selection].author), 400);
|
||||
Gui::DrawStringCentered(0, 120, 0.6f, config->textColor(), std::string(fileInfo[Selection].shortDesc), 400);
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
GFX::DrawBottom();
|
||||
GFX::DrawArrow(295, -1);
|
||||
@@ -241,49 +249,49 @@ void ScriptList::DrawList(void) const {
|
||||
GFX::DrawArrow(0, 218, 0, 1);
|
||||
GFX::DrawSpriteBlend(sprites_dropdown_idx, arrowPos[3].x, arrowPos[3].y);
|
||||
|
||||
if (Config::viewMode == 0) {
|
||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)fileInfo.size();i++) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, Config::UnselectedColor);
|
||||
if (config->viewMode() == 0) {
|
||||
for(int i = 0; i < ENTRIES_PER_SCREEN && i < (int)fileInfo.size(); i++) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, config->unselectedColor());
|
||||
line1 = fileInfo[screenPos + i].title;
|
||||
line2 = fileInfo[screenPos + i].author;
|
||||
if(screenPos + i == Selection) {
|
||||
if (screenPos + i == Selection) {
|
||||
if (!dropDownMenu) {
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, TRANSPARENT, Config::SelectedColor);
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, TRANSPARENT, config->selectedColor());
|
||||
}
|
||||
}
|
||||
Gui::DrawStringCentered(0, 38+(i*57), 0.7f, Config::TxtColor, line1, 320);
|
||||
Gui::DrawStringCentered(0, 62+(i*57), 0.7f, Config::TxtColor, line2, 320);
|
||||
Gui::DrawStringCentered(0, 38+(i*57), 0.7f, config->textColor(), line1, 320);
|
||||
Gui::DrawStringCentered(0, 62+(i*57), 0.7f, config->textColor(), line2, 320);
|
||||
}
|
||||
} else if (Config::viewMode == 1) {
|
||||
for(int i=0;i<ENTRIES_PER_LIST && i<(int)fileInfo.size();i++) {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, Config::UnselectedColor);
|
||||
} else if (config->viewMode() == 1) {
|
||||
for(int i = 0; i < ENTRIES_PER_LIST && i < (int)fileInfo.size();i++) {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, config->unselectedColor());
|
||||
line1 = fileInfo[screenPosList + i].title;
|
||||
if(screenPosList + i == Selection) {
|
||||
if (screenPosList + i == Selection) {
|
||||
if (!dropDownMenu) {
|
||||
Gui::drawAnimatedSelector(0, (i+1)*27, 320, 25, .060, TRANSPARENT, Config::SelectedColor);
|
||||
Gui::drawAnimatedSelector(0, (i+1)*27, 320, 25, .060, TRANSPARENT, config->selectedColor());
|
||||
}
|
||||
}
|
||||
Gui::DrawStringCentered(0, ((i+1)*27)+1, 0.7f, Config::TxtColor, line1, 320);
|
||||
Gui::DrawStringCentered(0, ((i+1)*27)+1, 0.7f, config->textColor(), line1, 320);
|
||||
}
|
||||
}
|
||||
|
||||
// DropDown Menu.
|
||||
if (dropDownMenu) {
|
||||
// Draw Operation Box.
|
||||
Gui::Draw_Rect(0, 25, 140, 87, Config::Color1);
|
||||
Gui::Draw_Rect(0, 25, 140, 87, config->barColor());
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (dropSelection == i) {
|
||||
Gui::drawAnimatedSelector(dropPos2[i].x, dropPos2[i].y, dropPos2[i].w, dropPos2[i].h, .090, TRANSPARENT, Config::SelectedColor);
|
||||
Gui::drawAnimatedSelector(dropPos2[i].x, dropPos2[i].y, dropPos2[i].w, dropPos2[i].h, .090, TRANSPARENT, config->selectedColor());
|
||||
} else {
|
||||
Gui::Draw_Rect(dropPos2[i].x, dropPos2[i].y, dropPos2[i].w, dropPos2[i].h, Config::UnselectedColor);
|
||||
Gui::Draw_Rect(dropPos2[i].x, dropPos2[i].y, dropPos2[i].w, dropPos2[i].h, config->unselectedColor());
|
||||
}
|
||||
}
|
||||
// Draw Dropdown Icons.
|
||||
GFX::DrawSpriteBlend(sprites_delete_idx, dropPos[0].x, dropPos[0].y);
|
||||
GFX::DrawSpriteBlend(sprites_view_idx, dropPos[1].x, dropPos[1].y);
|
||||
// Dropdown Text.
|
||||
Gui::DrawString(dropPos[0].x+30, dropPos[0].y+5, 0.4f, Config::TxtColor, Lang::get("DELETE_DDM"), 100);
|
||||
Gui::DrawString(dropPos[1].x+30, dropPos[1].y+5, 0.4f, Config::TxtColor, Lang::get("VIEW_DDM"), 100);
|
||||
Gui::DrawString(dropPos[0].x+30, dropPos[0].y+5, 0.4f, config->textColor(), Lang::get("DELETE_DDM"), 100);
|
||||
Gui::DrawString(dropPos[1].x+30, dropPos[1].y+5, 0.4f, config->textColor(), Lang::get("VIEW_DDM"), 100);
|
||||
}
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
}
|
||||
@@ -304,16 +312,19 @@ void ScriptList::DrawSingleObject(void) const {
|
||||
std::string info;
|
||||
std::string entryAmount = std::to_string(Selection+1) + " | " + std::to_string(fileInfo2.size());
|
||||
GFX::DrawTop();
|
||||
if (Config::UseBars == true) {
|
||||
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, TextColor, selectedTitle, 400);
|
||||
Gui::DrawString(397-Gui::GetStringWidth(0.6f, entryAmount), 239-Gui::GetStringHeight(0.6f, entryAmount), 0.6f, Config::TxtColor, entryAmount);
|
||||
Gui::DrawString(397-Gui::GetStringWidth(0.6f, entryAmount), 239-Gui::GetStringHeight(0.6f, entryAmount), 0.6f, TextColor, entryAmount);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, TextColor, selectedTitle, 400);
|
||||
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, TextColor, entryAmount);
|
||||
}
|
||||
for(uint i=0;i<lines.size();i++) {
|
||||
|
||||
for(uint i = 0; i < lines.size(); i++) {
|
||||
Gui::DrawStringCentered(0, 120-((lines.size()*20)/2)+i*20, 0.6f, TextColor, lines[i], 400);
|
||||
}
|
||||
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
GFX::DrawBottom();
|
||||
GFX::DrawArrow(295, -1);
|
||||
@@ -321,11 +332,11 @@ void ScriptList::DrawSingleObject(void) const {
|
||||
GFX::DrawArrow(0, 218, 0, 1);
|
||||
GFX::DrawSpriteBlend(sprites_dropdown_idx, arrowPos[3].x, arrowPos[3].y);
|
||||
|
||||
if (Config::viewMode == 0) {
|
||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)fileInfo2.size();i++) {
|
||||
if (config->viewMode() == 0) {
|
||||
for(int i = 0; i < ENTRIES_PER_SCREEN && i < (int)fileInfo2.size(); i++) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, unselected);
|
||||
info = fileInfo2[screenPos + i];
|
||||
if(screenPos + i == Selection) {
|
||||
if (screenPos + i == Selection) {
|
||||
if (!dropDownMenu) {
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, TRANSPARENT, selected);
|
||||
}
|
||||
@@ -333,11 +344,11 @@ void ScriptList::DrawSingleObject(void) const {
|
||||
Gui::DrawStringCentered(0, 50+(i*57), 0.7f, TextColor, info, 320);
|
||||
}
|
||||
|
||||
} else if (Config::viewMode == 1) {
|
||||
for(int i=0;i<ENTRIES_PER_LIST && i<(int)fileInfo2.size();i++) {
|
||||
} else if (config->viewMode() == 1) {
|
||||
for(int i = 0; i < ENTRIES_PER_LIST && i < (int)fileInfo2.size(); i++) {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, unselected);
|
||||
info = fileInfo2[screenPosList + i];
|
||||
if(screenPosList + i == Selection) {
|
||||
if (screenPosList + i == Selection) {
|
||||
if (!dropDownMenu) {
|
||||
Gui::drawAnimatedSelector(0, (i+1)*27, 320, 25, .060, TRANSPARENT, selected);
|
||||
}
|
||||
@@ -350,25 +361,27 @@ void ScriptList::DrawSingleObject(void) const {
|
||||
if (dropDownMenu) {
|
||||
// Draw Operation Box.
|
||||
Gui::Draw_Rect(0, 25, 140, 44, barColor);
|
||||
Gui::drawAnimatedSelector(dropPos2[0].x, dropPos2[0].y, dropPos2[0].w, dropPos2[0].h, .090, TRANSPARENT, Config::SelectedColor);
|
||||
Gui::drawAnimatedSelector(dropPos2[0].x, dropPos2[0].y, dropPos2[0].w, dropPos2[0].h, .090, TRANSPARENT, selected);
|
||||
// Draw Dropdown Icons.
|
||||
GFX::DrawSpriteBlend(sprites_view_idx, dropPos[0].x, dropPos[0].y);
|
||||
// Dropdown Text.
|
||||
Gui::DrawString(dropPos[0].x+30, dropPos[0].y+5, 0.4f, Config::TxtColor, Lang::get("VIEW_DDM"), 100);
|
||||
Gui::DrawString(dropPos[0].x+30, dropPos[0].y+5, 0.4f, TextColor, Lang::get("VIEW_DDM"), 100);
|
||||
}
|
||||
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
}
|
||||
|
||||
void ScriptList::refreshList() {
|
||||
if (returnIfExist(Config::ScriptPath, {"json"}) == true) {
|
||||
if (returnIfExist(config->scriptPath(), {"json"}) == true) {
|
||||
Msg::DisplayMsg(Lang::get("REFRESHING_LIST"));
|
||||
dirContents.clear();
|
||||
fileInfo.clear();
|
||||
chdir(Config::ScriptPath.c_str());
|
||||
chdir(config->scriptPath().c_str());
|
||||
getDirectoryContents(dirContents, {"json"});
|
||||
for(uint i=0;i<dirContents.size();i++) {
|
||||
for(uint i = 0; i < dirContents.size(); i++) {
|
||||
fileInfo.push_back(parseInfo(dirContents[i].name));
|
||||
}
|
||||
|
||||
Selection = 0;
|
||||
mode = 1;
|
||||
} else {
|
||||
@@ -381,18 +394,18 @@ void ScriptList::refreshList() {
|
||||
void ScriptList::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) {
|
||||
if (changeBackHandle) {
|
||||
Gui::setScreen(std::make_unique<MainMenu>(), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<MainMenu>(), config->screenFade(), true);
|
||||
} else {
|
||||
Gui::screenBack(Config::fading);
|
||||
Gui::screenBack(config->screenFade());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Navigation.
|
||||
if(hDown & KEY_UP) {
|
||||
if(Selection > 1) Selection -= 2;
|
||||
} else if(hDown & KEY_DOWN) {
|
||||
if(Selection < 3 && Selection != 2 && Selection != 3) Selection += 2;
|
||||
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 (Selection%2) Selection--;
|
||||
} else if (hDown & KEY_RIGHT) {
|
||||
@@ -402,10 +415,10 @@ void ScriptList::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
if (hDown & KEY_A) {
|
||||
switch(Selection) {
|
||||
case 0:
|
||||
if (returnIfExist(Config::ScriptPath, {"json"}) == true) {
|
||||
if (returnIfExist(config->scriptPath(), {"json"}) == true) {
|
||||
Msg::DisplayMsg(Lang::get("REFRESHING_LIST"));
|
||||
dirContents.clear();
|
||||
chdir(Config::ScriptPath.c_str());
|
||||
chdir(config->scriptPath().c_str());
|
||||
getDirectoryContents(dirContents, {"json"});
|
||||
for(uint i=0;i<dirContents.size();i++) {
|
||||
fileInfo.push_back(parseInfo(dirContents[i].name));
|
||||
@@ -417,22 +430,22 @@ void ScriptList::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
break;
|
||||
case 1:
|
||||
if (checkWifiStatus() == true) {
|
||||
Gui::setScreen(std::make_unique<ScriptBrowse>(), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<ScriptBrowse>(), config->screenFade(), true);
|
||||
} else {
|
||||
notConnectedMsg();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (isTesting == true) {
|
||||
Gui::setScreen(std::make_unique<ScriptCreator>(), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<ScriptCreator>(), config->screenFade(), true);
|
||||
} else {
|
||||
notImplemented();
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
std::string tempScript = selectFilePath(Lang::get("SELECT_SCRIPT_PATH"), Config::ScriptPath, {});
|
||||
std::string tempScript = selectFilePath(Lang::get("SELECT_SCRIPT_PATH"), config->scriptPath(), {});
|
||||
if (tempScript != "") {
|
||||
Config::ScriptPath = tempScript;
|
||||
config->scriptPath(tempScript);
|
||||
changesMade = true;
|
||||
}
|
||||
break;
|
||||
@@ -441,12 +454,12 @@ void ScriptList::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
|
||||
if (hDown & KEY_TOUCH) {
|
||||
if (touching(touch, subPos[0])) {
|
||||
if (returnIfExist(Config::ScriptPath, {"json"}) == true) {
|
||||
if (returnIfExist(config->scriptPath(), {"json"}) == true) {
|
||||
Msg::DisplayMsg(Lang::get("REFRESHING_LIST"));
|
||||
dirContents.clear();
|
||||
chdir(Config::ScriptPath.c_str());
|
||||
chdir(config->scriptPath().c_str());
|
||||
getDirectoryContents(dirContents, {"json"});
|
||||
for(uint i=0;i<dirContents.size();i++) {
|
||||
for(uint i = 0; i < dirContents.size(); i++) {
|
||||
fileInfo.push_back(parseInfo(dirContents[i].name));
|
||||
}
|
||||
mode = 1;
|
||||
@@ -455,20 +468,20 @@ void ScriptList::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
} else if (touching(touch, subPos[1])) {
|
||||
if (checkWifiStatus() == true) {
|
||||
Gui::setScreen(std::make_unique<ScriptBrowse>(), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<ScriptBrowse>(), config->screenFade(), true);
|
||||
} else {
|
||||
notConnectedMsg();
|
||||
}
|
||||
} else if (touching(touch, subPos[2])) {
|
||||
if (isTesting == true) {
|
||||
Gui::setScreen(std::make_unique<ScriptCreator>(), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<ScriptCreator>(), config->screenFade(), true);
|
||||
} else {
|
||||
notImplemented();
|
||||
}
|
||||
} else if (touching(touch, subPos[3])) {
|
||||
std::string tempScript = selectFilePath(Lang::get("SELECT_SCRIPT_PATH"), Config::ScriptPath, {});
|
||||
std::string tempScript = selectFilePath(Lang::get("SELECT_SCRIPT_PATH"), config->scriptPath(), {});
|
||||
if (tempScript != "") {
|
||||
Config::ScriptPath = tempScript;
|
||||
config->scriptPath(tempScript);
|
||||
changesMade = true;
|
||||
}
|
||||
}
|
||||
@@ -476,7 +489,7 @@ void ScriptList::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
|
||||
void ScriptList::deleteScript(int selectedScript) {
|
||||
std::string path = Config::ScriptPath;
|
||||
std::string path = config->scriptPath();
|
||||
path += dirContents[selectedScript].name;
|
||||
deleteFile(path.c_str());
|
||||
// Refresh the list.
|
||||
@@ -484,11 +497,12 @@ void ScriptList::deleteScript(int selectedScript) {
|
||||
Selection = 0;
|
||||
dirContents.clear();
|
||||
fileInfo.clear();
|
||||
chdir(Config::ScriptPath.c_str());
|
||||
chdir(config->scriptPath().c_str());
|
||||
getDirectoryContents(dirContents, {"json"});
|
||||
for(uint i=0;i<dirContents.size();i++) {
|
||||
for(uint i = 0; i < dirContents.size(); i++) {
|
||||
fileInfo.push_back(parseInfo(dirContents[i].name));
|
||||
}
|
||||
|
||||
if (dirContents.size() == 0) {
|
||||
dirContents.clear();
|
||||
fileInfo.clear();
|
||||
@@ -518,10 +532,10 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (Config::viewMode == 0) {
|
||||
Config::viewMode = 1;
|
||||
if (config->viewMode() == 0) {
|
||||
config->viewMode(1);
|
||||
} else {
|
||||
Config::viewMode = 0;
|
||||
config->viewMode(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -535,10 +549,10 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
dropDownMenu = false;
|
||||
} else if (touching(touch, dropPos2[1])) {
|
||||
if (Config::viewMode == 0) {
|
||||
Config::viewMode = 1;
|
||||
if (config->viewMode() == 0) {
|
||||
config->viewMode(1);
|
||||
} else {
|
||||
Config::viewMode = 0;
|
||||
config->viewMode(0);
|
||||
}
|
||||
dropDownMenu = false;
|
||||
}
|
||||
@@ -556,10 +570,10 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
|
||||
if (hDown & KEY_START) {
|
||||
if (Config::autoboot == 2) {
|
||||
if (config->autoboot() == 2) {
|
||||
if (Msg::promptMsg(Lang::get("DISABLE_AUTOBOOT"))) {
|
||||
Config::autoboot = 0;
|
||||
Config::AutobootFile = "";
|
||||
config->autoboot(0);
|
||||
config->autobootFile("");
|
||||
changesMade = true;
|
||||
}
|
||||
} else {
|
||||
@@ -567,8 +581,8 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
} else if (fileInfo.size() != 0) {
|
||||
if (ScriptHelper::checkIfValid(dirContents[Selection].name) == true) {
|
||||
if (Msg::promptMsg(Lang::get("AUTOBOOT_SCRIPT"))) {
|
||||
Config::AutobootFile = Config::ScriptPath + dirContents[Selection].name;
|
||||
Config::autoboot = 2;
|
||||
config->autobootFile(config->scriptPath() + dirContents[Selection].name);
|
||||
config->autoboot(2);
|
||||
changesMade = true;
|
||||
}
|
||||
}
|
||||
@@ -583,7 +597,7 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
Selection = 0;
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
if ((hHeld & KEY_UP && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[0]))) {
|
||||
@@ -593,11 +607,11 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
Selection = (int)fileInfo.size()-1;
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
if ((hHeld & KEY_RIGHT && !keyRepeatDelay)) {
|
||||
if (Config::viewMode == 0) {
|
||||
if (config->viewMode() == 0) {
|
||||
if (Selection < (int)fileInfo.size()-1-3) {
|
||||
Selection += 3;
|
||||
} else {
|
||||
@@ -611,11 +625,11 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
if ((hHeld & KEY_LEFT && !keyRepeatDelay)) {
|
||||
if (Config::viewMode == 0) {
|
||||
if (config->viewMode() == 0) {
|
||||
if (Selection > 2) {
|
||||
Selection -= 3;
|
||||
} else {
|
||||
@@ -629,15 +643,14 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
if (hDown & KEY_TOUCH) {
|
||||
if (Config::viewMode == 0) {
|
||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)fileInfo.size(); i++) {
|
||||
if(touch.py > 40+(i*57) && touch.py < 40+(i*57)+45) {
|
||||
if (dirContents[screenPos + i].isDirectory) {
|
||||
} else if (fileInfo.size() != 0) {
|
||||
if (config->viewMode() == 0) {
|
||||
for(int i = 0; i < ENTRIES_PER_SCREEN && i < (int)fileInfo.size(); i++) {
|
||||
if (touch.py > 40+(i*57) && touch.py < 40+(i*57)+45) {
|
||||
if (!dirContents[screenPos + i].isDirectory && fileInfo.size() != 0) {
|
||||
if (ScriptHelper::checkIfValid(dirContents[screenPos + i].name) == true) {
|
||||
currentFile = dirContents[screenPos + i].name;
|
||||
selectedTitle = fileInfo[screenPos + i].title;
|
||||
@@ -654,11 +667,10 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (Config::viewMode == 1) {
|
||||
for(int i=0;i<ENTRIES_PER_LIST && i<(int)fileInfo.size(); i++) {
|
||||
if(touch.py > (i+1)*27 && touch.py < (i+2)*27) {
|
||||
if (dirContents[screenPosList + i].isDirectory) {
|
||||
} else if (fileInfo.size() != 0) {
|
||||
} else if (config->viewMode() == 1) {
|
||||
for(int i = 0; i < ENTRIES_PER_LIST && i < (int)fileInfo.size(); i++) {
|
||||
if (touch.py > (i+1)*27 && touch.py < (i+2)*27) {
|
||||
if (!dirContents[screenPosList + i].isDirectory && fileInfo.size() != 0) {
|
||||
if (ScriptHelper::checkIfValid(dirContents[screenPosList + i].name) == true) {
|
||||
currentFile = dirContents[screenPosList + i].name;
|
||||
selectedTitle = fileInfo[screenPosList + i].title;
|
||||
@@ -697,14 +709,14 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
}
|
||||
|
||||
if (Config::viewMode == 0) {
|
||||
if(Selection < screenPos) {
|
||||
if (config->viewMode() == 0) {
|
||||
if (Selection < screenPos) {
|
||||
screenPos = Selection;
|
||||
} else if (Selection > screenPos + ENTRIES_PER_SCREEN - 1) {
|
||||
screenPos = Selection - ENTRIES_PER_SCREEN + 1;
|
||||
}
|
||||
} else if (Config::viewMode == 1) {
|
||||
if(Selection < screenPosList) {
|
||||
} else if (config->viewMode() == 1) {
|
||||
if (Selection < screenPosList) {
|
||||
screenPosList = Selection;
|
||||
} else if (Selection > screenPosList + ENTRIES_PER_LIST - 1) {
|
||||
screenPosList = Selection - ENTRIES_PER_LIST + 1;
|
||||
@@ -723,20 +735,20 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
|
||||
if (hDown & KEY_A) {
|
||||
if (Config::viewMode == 0) {
|
||||
Config::viewMode = 1;
|
||||
if (config->viewMode() == 0) {
|
||||
config->viewMode(1);
|
||||
} else {
|
||||
Config::viewMode = 0;
|
||||
config->viewMode(0);
|
||||
}
|
||||
dropDownMenu = false;
|
||||
}
|
||||
|
||||
if (hDown & KEY_TOUCH) {
|
||||
if (touching(touch, dropPos2[0])) {
|
||||
if (Config::viewMode == 0) {
|
||||
Config::viewMode = 1;
|
||||
if (config->viewMode() == 0) {
|
||||
config->viewMode(1);
|
||||
} else {
|
||||
Config::viewMode = 0;
|
||||
config->viewMode(0);
|
||||
}
|
||||
dropDownMenu = false;
|
||||
}
|
||||
@@ -761,7 +773,7 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
Selection = 0;
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
if ((hHeld & KEY_UP && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[0]))) {
|
||||
@@ -771,12 +783,12 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
Selection = (int)fileInfo2.size()-1;
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
|
||||
if ((hHeld & KEY_RIGHT && !keyRepeatDelay)) {
|
||||
if (Config::viewMode == 0) {
|
||||
if (config->viewMode() == 0) {
|
||||
if (Selection < (int)fileInfo2.size()-1-3) {
|
||||
Selection += 3;
|
||||
} else {
|
||||
@@ -790,11 +802,11 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
if ((hHeld & KEY_LEFT && !keyRepeatDelay)) {
|
||||
if (Config::viewMode == 0) {
|
||||
if (config->viewMode() == 0) {
|
||||
if (Selection > 2) {
|
||||
Selection -= 3;
|
||||
} else {
|
||||
@@ -808,13 +820,13 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
if (hDown & KEY_TOUCH) {
|
||||
if (Config::viewMode == 0) {
|
||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)fileInfo2.size(); i++) {
|
||||
if(touch.py > 40+(i*57) && touch.py < 40+(i*57)+45) {
|
||||
if (config->viewMode() == 0) {
|
||||
for(int i = 0; i < ENTRIES_PER_SCREEN && i < (int)fileInfo2.size(); i++) {
|
||||
if (touch.py > 40+(i*57) && touch.py < 40+(i*57)+45) {
|
||||
if (fileInfo2.size() != 0) {
|
||||
choice = fileInfo2[screenPos + i];
|
||||
if (Msg::promptMsg(Lang::get("EXECUTE_SCRIPT") + "\n\n" + choice)) {
|
||||
@@ -823,9 +835,9 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (Config::viewMode == 1) {
|
||||
for(int i=0;i<ENTRIES_PER_LIST && i<(int)fileInfo2.size(); i++) {
|
||||
if(touch.py > (i+1)*27 && touch.py < (i+2)*27) {
|
||||
} else if (config->viewMode() == 1) {
|
||||
for(int i = 0; i < ENTRIES_PER_LIST && i < (int)fileInfo2.size(); i++) {
|
||||
if (touch.py > (i+1)*27 && touch.py < (i+2)*27) {
|
||||
if (fileInfo2.size() != 0) {
|
||||
choice = fileInfo2[screenPosList + i];
|
||||
if (Msg::promptMsg(Lang::get("EXECUTE_SCRIPT") + "\n\n" + choice)) {
|
||||
@@ -847,23 +859,23 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
|
||||
if (hDown & KEY_SELECT) {
|
||||
Config::Color1 = barColor;
|
||||
Config::Color2 = bgTopColor;
|
||||
Config::Color3 = bgBottomColor;
|
||||
Config::TxtColor = TextColor;
|
||||
Config::SelectedColor = selected;
|
||||
Config::UnselectedColor = unselected;
|
||||
config->barColor(barColor);
|
||||
config->topBG(bgTopColor);
|
||||
config->bottomBG(bgBottomColor);
|
||||
config->textColor(TextColor);
|
||||
config->selectedColor(selected);
|
||||
config->unselectedColor(unselected);
|
||||
changesMade = true;
|
||||
}
|
||||
|
||||
if (Config::viewMode == 0) {
|
||||
if(Selection < screenPos) {
|
||||
if (config->viewMode() == 0) {
|
||||
if (Selection < screenPos) {
|
||||
screenPos = Selection;
|
||||
} else if (Selection > screenPos + ENTRIES_PER_SCREEN - 1) {
|
||||
screenPos = Selection - ENTRIES_PER_SCREEN + 1;
|
||||
}
|
||||
} else if (Config::viewMode == 1) {
|
||||
if(Selection < screenPosList) {
|
||||
} else if (config->viewMode() == 1) {
|
||||
if (Selection < screenPosList) {
|
||||
screenPosList = Selection;
|
||||
} else if (Selection > screenPosList + ENTRIES_PER_LIST - 1) {
|
||||
screenPosList = Selection - ENTRIES_PER_LIST + 1;
|
||||
@@ -896,121 +908,122 @@ void ScriptList::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
|
||||
void ScriptList::DrawGlossary(void) const {
|
||||
GFX::DrawTop();
|
||||
if (Config::UseBars == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, Lang::get("GLOSSARY"), 400);
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), Lang::get("GLOSSARY"), 400);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("GLOSSARY"), 400);
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), Lang::get("GLOSSARY"), 400);
|
||||
}
|
||||
|
||||
if (lastMode == 1) {
|
||||
Gui::DrawString(15, 35, 0.7f, Config::TxtColor, std::to_string(Selection +1) + " | " + std::to_string(fileInfo.size()), 40);
|
||||
Gui::DrawString(65, 35, 0.7f, Config::TxtColor, Lang::get("ENTRY"), 300);
|
||||
Gui::DrawString(15, 35, 0.7f, config->textColor(), std::to_string(Selection +1) + " | " + std::to_string(fileInfo.size()), 40);
|
||||
Gui::DrawString(65, 35, 0.7f, config->textColor(), Lang::get("ENTRY"), 300);
|
||||
} else if (lastMode == 2) {
|
||||
Gui::DrawString(15, 35, 0.7f, Config::TxtColor, std::to_string(Selection+1) + " | " + std::to_string(fileInfo2.size()), 40);
|
||||
Gui::DrawString(65, 35, 0.7f, Config::TxtColor, Lang::get("ENTRY"), 300);
|
||||
Gui::DrawString(15, 35, 0.7f, config->textColor(), std::to_string(Selection+1) + " | " + std::to_string(fileInfo2.size()), 40);
|
||||
Gui::DrawString(65, 35, 0.7f, config->textColor(), Lang::get("ENTRY"), 300);
|
||||
}
|
||||
GFX::DrawBottom();
|
||||
|
||||
GFX::DrawSpriteBlend(sprites_view_idx, 20, 40);
|
||||
Gui::DrawString(50, 42, 0.6f, Config::TxtColor, Lang::get("CHANGE_VIEW_MODE"), 260);
|
||||
Gui::DrawString(50, 42, 0.6f, config->textColor(), Lang::get("CHANGE_VIEW_MODE"), 260);
|
||||
|
||||
GFX::DrawArrow(20, 70);
|
||||
Gui::DrawString(50, 72, 0.6f, Config::TxtColor, Lang::get("ENTRY_UP"), 260);
|
||||
Gui::DrawString(50, 72, 0.6f, config->textColor(), Lang::get("ENTRY_UP"), 260);
|
||||
GFX::DrawArrow(42, 125, 180.0);
|
||||
Gui::DrawString(50, 102, 0.6f, Config::TxtColor, Lang::get("ENTRY_DOWN"), 260);
|
||||
Gui::DrawString(50, 102, 0.6f, config->textColor(), Lang::get("ENTRY_DOWN"), 260);
|
||||
GFX::DrawArrow(20, 130, 0, 1);
|
||||
Gui::DrawString(50, 132, 0.6f, Config::TxtColor, Lang::get("GO_BACK"), 260);
|
||||
Gui::DrawString(50, 132, 0.6f, config->textColor(), Lang::get("GO_BACK"), 260);
|
||||
if (lastMode == 1) {
|
||||
GFX::DrawSpriteBlend(sprites_delete_idx, 20, 160);
|
||||
Gui::DrawString(50, 162, 0.6f, Config::TxtColor, Lang::get("DELETE_SCRIPT2"), 260);
|
||||
Gui::DrawString(50, 162, 0.6f, config->textColor(), Lang::get("DELETE_SCRIPT2"), 260);
|
||||
}
|
||||
|
||||
GFX::DrawArrow(0, 218, 0, 1);
|
||||
}
|
||||
|
||||
// Execute | run the script.
|
||||
Result ScriptList::runFunctions(nlohmann::json &json) {
|
||||
Result ret = NONE; // No Error as of yet.
|
||||
for(int i=0;i<(int)json.at(choice).size();i++) {
|
||||
for(int i = 0; i < (int)json.at(choice).size(); i++) {
|
||||
if (ret == NONE) {
|
||||
std::string type = json.at(choice).at(i).at("type");
|
||||
|
||||
if(type == "deleteFile") {
|
||||
if (type == "deleteFile") {
|
||||
bool missing = false;
|
||||
std::string file, message;
|
||||
if(json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
|
||||
if (json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
||||
if(!missing) ret = ScriptHelper::removeFile(file, message);
|
||||
if (json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
||||
if (!missing) ret = ScriptHelper::removeFile(file, message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if(type == "downloadFile") {
|
||||
} else if (type == "downloadFile") {
|
||||
bool missing = false;
|
||||
std::string file, output, message;
|
||||
if(json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
|
||||
if (json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("output")) output = json.at(choice).at(i).at("output");
|
||||
if (json.at(choice).at(i).contains("output")) output = json.at(choice).at(i).at("output");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
||||
if(!missing) ret = ScriptHelper::downloadFile(file, output, message);
|
||||
if (json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
||||
if (!missing) ret = ScriptHelper::downloadFile(file, output, message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if(type == "downloadRelease") {
|
||||
} else if (type == "downloadRelease") {
|
||||
bool missing = false, includePrereleases = false, showVersions = false;
|
||||
std::string repo, file, output, message;
|
||||
if(json.at(choice).at(i).contains("repo")) repo = json.at(choice).at(i).at("repo");
|
||||
if (json.at(choice).at(i).contains("repo")) repo = json.at(choice).at(i).at("repo");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
|
||||
if (json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("output")) output = json.at(choice).at(i).at("output");
|
||||
if (json.at(choice).at(i).contains("output")) output = json.at(choice).at(i).at("output");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("includePrereleases") && json.at(choice).at(i).at("includePrereleases").is_boolean())
|
||||
if (json.at(choice).at(i).contains("includePrereleases") && json.at(choice).at(i).at("includePrereleases").is_boolean())
|
||||
includePrereleases = json.at(choice).at(i).at("includePrereleases");
|
||||
if(json.at(choice).at(i).contains("showVersions") && json.at(choice).at(i).at("showVersions").is_boolean())
|
||||
if (json.at(choice).at(i).contains("showVersions") && json.at(choice).at(i).at("showVersions").is_boolean())
|
||||
showVersions = json.at(choice).at(i).at("showVersions");
|
||||
if(json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
||||
if(!missing) ret = ScriptHelper::downloadRelease(repo, file, output, includePrereleases, showVersions, message);
|
||||
if (json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
||||
if (!missing) ret = ScriptHelper::downloadRelease(repo, file, output, includePrereleases, showVersions, message);
|
||||
|
||||
} else if(type == "extractFile") {
|
||||
} else if (type == "extractFile") {
|
||||
bool missing = false;
|
||||
std::string file, input, output, message;
|
||||
if(json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
|
||||
if (json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("input")) input = json.at(choice).at(i).at("input");
|
||||
if (json.at(choice).at(i).contains("input")) input = json.at(choice).at(i).at("input");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("output")) output = json.at(choice).at(i).at("output");
|
||||
if (json.at(choice).at(i).contains("output")) output = json.at(choice).at(i).at("output");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
||||
if(!missing) ScriptHelper::extractFile(file, input, output, message);
|
||||
if (json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
||||
if (!missing) ScriptHelper::extractFile(file, input, output, message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if(type == "installCia") {
|
||||
} else if (type == "installCia") {
|
||||
bool missing = false, updateSelf = false;
|
||||
std::string file, message;
|
||||
if(json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
|
||||
if (json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("updateSelf") && json.at(choice).at(i).at("updateSelf").is_boolean()) {
|
||||
if (json.at(choice).at(i).contains("updateSelf") && json.at(choice).at(i).at("updateSelf").is_boolean()) {
|
||||
updateSelf = json.at(choice).at(i).at("updateSelf");
|
||||
}
|
||||
if(json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
||||
if(!missing) ScriptHelper::installFile(file, updateSelf, message);
|
||||
if (json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
||||
if (!missing) ScriptHelper::installFile(file, updateSelf, message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if (type == "mkdir") {
|
||||
bool missing = false;
|
||||
std::string directory, message;
|
||||
if(json.at(choice).at(i).contains("directory")) directory = json.at(choice).at(i).at("directory");
|
||||
if (json.at(choice).at(i).contains("directory")) directory = json.at(choice).at(i).at("directory");
|
||||
else missing = true;
|
||||
if(!missing) makeDirs(directory.c_str());
|
||||
if (!missing) makeDirs(directory.c_str());
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if (type == "rmdir") {
|
||||
bool missing = false;
|
||||
std::string directory, message, promptmsg;
|
||||
if(json.at(choice).at(i).contains("directory")) directory = json.at(choice).at(i).at("directory");
|
||||
if (json.at(choice).at(i).contains("directory")) directory = json.at(choice).at(i).at("directory");
|
||||
else missing = true;
|
||||
promptmsg = Lang::get("DELETE_PROMPT") + "\n" + directory;
|
||||
if(!missing) {
|
||||
if(access(directory.c_str(), F_OK) != 0 ) {
|
||||
if (!missing) {
|
||||
if (access(directory.c_str(), F_OK) != 0 ) {
|
||||
ret = DELETE_ERROR;
|
||||
} else {
|
||||
if (Msg::promptMsg(promptmsg)) {
|
||||
@@ -1023,63 +1036,63 @@ Result ScriptList::runFunctions(nlohmann::json &json) {
|
||||
} else if (type == "mkfile") {
|
||||
bool missing = false;
|
||||
std::string file;
|
||||
if(json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
|
||||
if (json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
|
||||
else missing = true;
|
||||
if(!missing) ScriptHelper::createFile(file.c_str());
|
||||
if (!missing) ScriptHelper::createFile(file.c_str());
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if (type == "timeMsg") {
|
||||
bool missing = false;
|
||||
std::string message;
|
||||
int seconds;
|
||||
if(json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
||||
if (json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("seconds") && json.at(choice).at(i).at("seconds").is_number())
|
||||
if (json.at(choice).at(i).contains("seconds") && json.at(choice).at(i).at("seconds").is_number())
|
||||
seconds = json.at(choice).at(i).at("seconds");
|
||||
else missing = true;
|
||||
if(!missing) ScriptHelper::displayTimeMsg(message, seconds);
|
||||
if (!missing) ScriptHelper::displayTimeMsg(message, seconds);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if (type == "saveConfig") {
|
||||
Config::save();
|
||||
config->save();
|
||||
|
||||
} else if (type == "bootTitle") {
|
||||
std::string TitleID = "";
|
||||
std::string message = "";
|
||||
bool isNAND = false, missing = false;
|
||||
if(json.at(choice).at(i).contains("TitleID")) TitleID = json.at(choice).at(i).at("TitleID");
|
||||
if (json.at(choice).at(i).contains("TitleID")) TitleID = json.at(choice).at(i).at("TitleID");
|
||||
else missing = true;
|
||||
if (json.at(choice).at(i).contains("NAND") && json.at(choice).at(i).at("NAND").is_boolean()) isNAND = json.at(choice).at(i).at("NAND");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
||||
if (json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
|
||||
else missing = true;
|
||||
if(!missing) ScriptHelper::bootTitle(TitleID, isNAND, message);
|
||||
if (!missing) ScriptHelper::bootTitle(TitleID, isNAND, message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if (type == "promptMessage") {
|
||||
std::string Message = "";
|
||||
if(json.at(choice).at(i).contains("message")) Message = json.at(choice).at(i).at("message");
|
||||
if (json.at(choice).at(i).contains("message")) Message = json.at(choice).at(i).at("message");
|
||||
ret = ScriptHelper::prompt(Message);
|
||||
|
||||
} else if (type == "copy") {
|
||||
std::string Message = "", source = "", destination = "";
|
||||
bool missing = false;
|
||||
if(json.at(choice).at(i).contains("source")) source = json.at(choice).at(i).at("source");
|
||||
if (json.at(choice).at(i).contains("source")) source = json.at(choice).at(i).at("source");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("destination")) destination = json.at(choice).at(i).at("destination");
|
||||
if (json.at(choice).at(i).contains("destination")) destination = json.at(choice).at(i).at("destination");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("message")) Message = json.at(choice).at(i).at("message");
|
||||
if (json.at(choice).at(i).contains("message")) Message = json.at(choice).at(i).at("message");
|
||||
if (!missing) ret = ScriptHelper::copyFile(source, destination, Message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if (type == "move") {
|
||||
std::string Message = "", oldFile = "", newFile = "";
|
||||
bool missing = false;
|
||||
if(json.at(choice).at(i).contains("old")) oldFile = json.at(choice).at(i).at("old");
|
||||
if (json.at(choice).at(i).contains("old")) oldFile = json.at(choice).at(i).at("old");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("new")) newFile = json.at(choice).at(i).at("new");
|
||||
if (json.at(choice).at(i).contains("new")) newFile = json.at(choice).at(i).at("new");
|
||||
else missing = true;
|
||||
if(json.at(choice).at(i).contains("message")) Message = json.at(choice).at(i).at("message");
|
||||
if (json.at(choice).at(i).contains("message")) Message = json.at(choice).at(i).at("message");
|
||||
if (!missing) ret = ScriptHelper::renameFile(oldFile, newFile, Message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
+141
-137
@@ -29,13 +29,12 @@
|
||||
#include "settings.hpp"
|
||||
|
||||
extern bool touching(touchPosition touch, Structs::ButtonPos button);
|
||||
extern std::unique_ptr<Config> config;
|
||||
|
||||
int selectedLang;
|
||||
extern bool changesMade;
|
||||
|
||||
Settings::Settings() {
|
||||
selectedLang = 0;
|
||||
}
|
||||
Settings::Settings() { selectedLang = 0; }
|
||||
|
||||
void Settings::Draw(void) const {
|
||||
if (mode == 0) {
|
||||
@@ -52,11 +51,12 @@ void Settings::Draw(void) const {
|
||||
|
||||
void Settings::DrawSubMenu(void) const {
|
||||
GFX::DrawTop();
|
||||
if (Config::UseBars == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, "Universal-Updater", 400);
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), "Universal-Updater", 400);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, "Universal-Updater", 400);
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), "Universal-Updater", 400);
|
||||
}
|
||||
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
GFX::DrawBottom();
|
||||
GFX::DrawArrow(0, 218, 0, 1);
|
||||
@@ -88,21 +88,23 @@ const std::vector<std::string> languages = {
|
||||
void Settings::DrawLanguageSelection(void) const {
|
||||
std::string line1;
|
||||
GFX::DrawTop();
|
||||
if (Config::UseBars == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, Lang::get("SELECT_LANG"), 400);
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), Lang::get("SELECT_LANG"), 400);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("SELECT_LANG"), 400);
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), Lang::get("SELECT_LANG"), 400);
|
||||
}
|
||||
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
GFX::DrawBottom();
|
||||
|
||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)languages.size();i++) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, Config::UnselectedColor);
|
||||
for(int i = 0; i < ENTRIES_PER_SCREEN && i < (int)languages.size(); i++) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, config->unselectedColor());
|
||||
line1 = languages[screenPos + i];
|
||||
if (screenPos + i == selectedLang) {
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, TRANSPARENT, Config::SelectedColor);
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, TRANSPARENT, config->selectedColor());
|
||||
}
|
||||
Gui::DrawStringCentered(0, 50+(i*57), 0.7f, WHITE, line1, 320);
|
||||
|
||||
Gui::DrawStringCentered(0, 50+(i*57), 0.7f, config->textColor(), line1, 320);
|
||||
}
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
}
|
||||
@@ -126,32 +128,32 @@ const std::vector<std::string> colorList = {
|
||||
void Settings::DrawColorChanging(void) const {
|
||||
std::string line1;
|
||||
GFX::DrawTop();
|
||||
if (Config::UseBars == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, "Universal-Updater", 400);
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), "Universal-Updater", 400);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, "Universal-Updater", 400);
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), "Universal-Updater", 400);
|
||||
}
|
||||
|
||||
if (!dropDownMenu) {
|
||||
if (colorMode == 3) {
|
||||
Gui::Draw_Rect(0, 40, 400, 45, Config::SelectedColor);
|
||||
Gui::DrawStringCentered(0, 45, 0.7f, Config::TxtColor, Lang::get("TEXT_COLOR"), 320);
|
||||
Gui::Draw_Rect(0, 40, 400, 45, config->selectedColor());
|
||||
Gui::DrawStringCentered(0, 45, 0.7f, config->textColor(), Lang::get("TEXT_COLOR"), 320);
|
||||
} else if (colorMode == 4) {
|
||||
Gui::Draw_Rect(0, 40, 400, 45, Config::SelectedColor);
|
||||
Gui::DrawStringCentered(0, 45, 0.7f, Config::TxtColor, Lang::get("SELECTED_COLOR"), 320);
|
||||
Gui::Draw_Rect(0, 40, 400, 45, config->selectedColor());
|
||||
Gui::DrawStringCentered(0, 45, 0.7f, config->textColor(), Lang::get("SELECTED_COLOR"), 320);
|
||||
} else if (colorMode == 5) {
|
||||
Gui::Draw_Rect(0, 40, 400, 45, Config::UnselectedColor);
|
||||
Gui::DrawStringCentered(0, 45, 0.7f, Config::TxtColor, Lang::get("UNSELECTED_COLOR"), 320);
|
||||
Gui::Draw_Rect(0, 40, 400, 45, config->unselectedColor());
|
||||
Gui::DrawStringCentered(0, 45, 0.7f, config->textColor(), Lang::get("UNSELECTED_COLOR"), 320);
|
||||
} else if (colorMode == 6) {
|
||||
Gui::Draw_Rect(31, 121, (int)(((float)100/(float)100) * 338.0f), 28, Config::progressbarColor);
|
||||
Gui::Draw_Rect(31, 121, (int)(((float)100/(float)100) * 338.0f), 28, config->progressbarColor());
|
||||
} else if (colorMode == 7) {
|
||||
Gui::Draw_Rect(31, 121, (int)(((float)100/(float)100) * 338.0f), 28, Config::notFound);
|
||||
Gui::Draw_Rect(31, 121, (int)(((float)100/(float)100) * 338.0f), 28, config->notfoundColor());
|
||||
} else if (colorMode == 8) {
|
||||
Gui::Draw_Rect(31, 121, (int)(((float)100/(float)100) * 338.0f), 28, Config::outdated);
|
||||
Gui::Draw_Rect(31, 121, (int)(((float)100/(float)100) * 338.0f), 28, config->outdatedColor());
|
||||
} else if (colorMode == 9) {
|
||||
Gui::Draw_Rect(31, 121, (int)(((float)100/(float)100) * 338.0f), 28, Config::uptodate);
|
||||
Gui::Draw_Rect(31, 121, (int)(((float)100/(float)100) * 338.0f), 28, config->uptodateColor());
|
||||
} else if (colorMode == 10) {
|
||||
Gui::Draw_Rect(31, 121, (int)(((float)100/(float)100) * 338.0f), 28, Config::future);
|
||||
Gui::Draw_Rect(31, 121, (int)(((float)100/(float)100) * 338.0f), 28, config->futureColor());
|
||||
} else if (colorMode == 11) {
|
||||
GFX::DrawButton(100, 100, "");
|
||||
}
|
||||
@@ -167,63 +169,63 @@ void Settings::DrawColorChanging(void) const {
|
||||
}
|
||||
|
||||
if (dropDownMenu) {
|
||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)colorList.size();i++) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, Config::UnselectedColor);
|
||||
for(int i = 0; i < ENTRIES_PER_SCREEN && i < (int)colorList.size(); i++) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, config->unselectedColor());
|
||||
line1 = Lang::get(colorList[screenPos + i]);
|
||||
if(screenPos + i == colorSelection) {
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, TRANSPARENT, Config::SelectedColor);
|
||||
if (screenPos + i == colorSelection) {
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, TRANSPARENT, config->selectedColor());
|
||||
}
|
||||
Gui::DrawStringCentered(0, 50+(i*57), 0.7f, Config::TxtColor, line1, 320);
|
||||
Gui::DrawStringCentered(0, 50+(i*57), 0.7f, config->textColor(), line1, 320);
|
||||
}
|
||||
} else {
|
||||
if (colorMode == 0) {
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(Config::Color1, 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(Config::Color1, 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(Config::Color1, 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(config->barColor(), 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(config->barColor(), 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(config->barColor(), 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
} else if (colorMode == 1) {
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(Config::Color2, 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(Config::Color2, 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(Config::Color2, 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(config->topBG(), 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(config->topBG(), 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(config->topBG(), 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
} else if (colorMode == 2) {
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(Config::Color3, 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(Config::Color3, 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(Config::Color3, 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(config->bottomBG(), 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(config->bottomBG(), 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(config->bottomBG(), 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
} else if (colorMode == 3) {
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(Config::TxtColor, 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(Config::TxtColor, 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(Config::TxtColor, 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(config->textColor(), 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(config->textColor(), 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(config->textColor(), 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
} else if (colorMode == 4) {
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(Config::SelectedColor, 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(Config::SelectedColor, 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(Config::SelectedColor, 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(config->selectedColor(), 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(config->selectedColor(), 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(config->selectedColor(), 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
} else if (colorMode == 5) {
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(Config::UnselectedColor, 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(Config::UnselectedColor, 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(Config::UnselectedColor, 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(config->unselectedColor(), 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(config->unselectedColor(), 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(config->unselectedColor(), 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
} else if (colorMode == 6) {
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(Config::progressbarColor, 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(Config::progressbarColor, 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(Config::progressbarColor, 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(config->progressbarColor(), 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(config->progressbarColor(), 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(config->progressbarColor(), 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
} else if (colorMode == 7) {
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(Config::notFound, 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(Config::notFound, 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(Config::notFound, 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(config->notfoundColor(), 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(config->notfoundColor(), 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(config->notfoundColor(), 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
} else if (colorMode == 8) {
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(Config::outdated, 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(Config::outdated, 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(Config::outdated, 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(config->outdatedColor(), 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(config->outdatedColor(), 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(config->outdatedColor(), 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
} else if (colorMode == 9) {
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(Config::uptodate, 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(Config::uptodate, 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(Config::uptodate, 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(config->uptodateColor(), 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(config->uptodateColor(), 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(config->uptodateColor(), 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
} else if (colorMode == 10) {
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(Config::future, 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(Config::future, 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(Config::future, 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(config->futureColor(), 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(config->futureColor(), 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(config->futureColor(), 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
} else if (colorMode == 11) {
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(Config::Button, 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(Config::Button, 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(Config::Button, 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
GFX::DrawButton(mainButtons[0].x, mainButtons[0].y, ColorHelper::getColorName(config->buttonColor(), 2).c_str(), C2D_Color32(255, 0, 0, 255));
|
||||
GFX::DrawButton(mainButtons[1].x, mainButtons[1].y, ColorHelper::getColorName(config->buttonColor(), 1).c_str(), C2D_Color32(0, 255, 0, 255));
|
||||
GFX::DrawButton(mainButtons[2].x, mainButtons[2].y, ColorHelper::getColorName(config->buttonColor(), 0).c_str(), C2D_Color32(0, 0, 255, 255));
|
||||
}
|
||||
}
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
@@ -231,11 +233,12 @@ void Settings::DrawColorChanging(void) const {
|
||||
|
||||
void Settings::DrawMiscSettings(void) const {
|
||||
GFX::DrawTop();
|
||||
if (Config::UseBars == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, "Universal-Updater", 400);
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), "Universal-Updater", 400);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, "Universal-Updater", 400);
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), "Universal-Updater", 400);
|
||||
}
|
||||
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
GFX::DrawBottom();
|
||||
GFX::DrawArrow(0, 218, 0, 1);
|
||||
@@ -255,26 +258,26 @@ void Settings::MiscSettingsLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
if (Selection == 0) {
|
||||
std::string tempMusic = selectFilePath(Lang::get("SELECT_MUSIC_FILE"), "sdmc:/", {"wav"}, 2);
|
||||
if (tempMusic != "") {
|
||||
Config::MusicPath = tempMusic;
|
||||
config->musicPath(tempMusic);
|
||||
changesMade = true;
|
||||
}
|
||||
} else if (Selection == 1) {
|
||||
if (Config::UseBars == true) Config::UseBars = false;
|
||||
else if (Config::UseBars == false) Config::UseBars = true;
|
||||
if (config->useBars() == true) config->useBars(false);
|
||||
else if (config->useBars() == false) config->useBars(true);
|
||||
changesMade = true;
|
||||
} else if (Selection == 2) {
|
||||
Config::keyDelay = Input::getUint(255, Lang::get("ENTER_KEY_DELAY"));
|
||||
config->keyDelay(Input::getUint(255, Lang::get("ENTER_KEY_DELAY")));
|
||||
changesMade = true;
|
||||
} else if (Selection == 3) {
|
||||
if (Config::fading) {
|
||||
if (config->screenFade()) {
|
||||
if (Msg::promptMsg(Lang::get("TOGGLE_FADE_DISABLE"))) {
|
||||
Config::fading = false;
|
||||
config->screenFade(false);
|
||||
Msg::DisplayWarnMsg(Lang::get("DISABLED"));
|
||||
changesMade = true;
|
||||
}
|
||||
} else {
|
||||
if (Msg::promptMsg(Lang::get("TOGGLE_FADE_ENABLE"))) {
|
||||
Config::fading = true;
|
||||
config->screenFade(true);
|
||||
Msg::DisplayWarnMsg(Lang::get("ENABLED"));
|
||||
changesMade = true;
|
||||
}
|
||||
@@ -286,26 +289,26 @@ void Settings::MiscSettingsLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
if (touching(touch, mainButtons2[0])) {
|
||||
std::string tempMusic = selectFilePath(Lang::get("SELECT_MUSIC_FILE"), "sdmc:/", {"wav"}, 2);
|
||||
if (tempMusic != "") {
|
||||
Config::MusicPath = tempMusic;
|
||||
config->musicPath(tempMusic);
|
||||
changesMade = true;
|
||||
}
|
||||
} else if (touching(touch, mainButtons2[1])) {
|
||||
if (Config::UseBars == true) Config::UseBars = false;
|
||||
else if (Config::UseBars == false) Config::UseBars = true;
|
||||
if (config->useBars() == true) config->useBars(false);
|
||||
else if (config->useBars() == false) config->useBars(true);
|
||||
changesMade = true;
|
||||
} else if (touching(touch, mainButtons2[2])) {
|
||||
Config::keyDelay = Input::getUint(255, Lang::get("ENTER_KEY_DELAY"));
|
||||
config->keyDelay(Input::getUint(255, Lang::get("ENTER_KEY_DELAY")));
|
||||
changesMade = true;
|
||||
} else if (touching(touch, mainButtons2[3])) {
|
||||
if (Config::fading) {
|
||||
if (config->screenFade()) {
|
||||
if (Msg::promptMsg(Lang::get("TOGGLE_FADE_DISABLE"))) {
|
||||
Config::fading = false;
|
||||
config->screenFade(false);
|
||||
Msg::DisplayWarnMsg(Lang::get("DISABLED"));
|
||||
changesMade = true;
|
||||
}
|
||||
} else {
|
||||
if (Msg::promptMsg(Lang::get("TOGGLE_FADE_ENABLE"))) {
|
||||
Config::fading = true;
|
||||
config->screenFade(true);
|
||||
Msg::DisplayWarnMsg(Lang::get("ENABLED"));
|
||||
changesMade = true;
|
||||
}
|
||||
@@ -320,15 +323,15 @@ void Settings::MiscSettingsLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
|
||||
// No idea where to place the button for it, so do it here for now.
|
||||
if (hDown & KEY_SELECT) {
|
||||
if (Config::progress) {
|
||||
if (config->progressDisplay()) {
|
||||
if (Msg::promptMsg(Lang::get("PROGRESS_BAR_DISABLE"))) {
|
||||
Config::progress = false;
|
||||
config->progressDisplay(false);
|
||||
Msg::DisplayWarnMsg(Lang::get("DISABLED"));
|
||||
changesMade = true;
|
||||
}
|
||||
} else {
|
||||
if (Msg::promptMsg(Lang::get("PROGRESS_BAR_ENABLE"))) {
|
||||
Config::progress = true;
|
||||
config->progressDisplay(true);
|
||||
Msg::DisplayWarnMsg(Lang::get("ENABLED"));
|
||||
changesMade = true;
|
||||
}
|
||||
@@ -350,11 +353,11 @@ void Settings::MiscSettingsLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
|
||||
void Settings::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
if (hDown & KEY_UP) {
|
||||
if(Selection > 0) Selection--;
|
||||
if (Selection > 0) Selection--;
|
||||
}
|
||||
|
||||
if (hDown & KEY_DOWN) {
|
||||
if(Selection < 2) Selection++;
|
||||
if (Selection < 2) Selection++;
|
||||
}
|
||||
|
||||
if (hDown & KEY_A) {
|
||||
@@ -369,7 +372,7 @@ void Settings::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
mode = 2;
|
||||
break;
|
||||
case 2:
|
||||
Gui::setScreen(std::make_unique<Credits>(), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<Credits>(), config->screenFade(), true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -383,12 +386,12 @@ void Settings::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
screenPos = 0;
|
||||
mode = 2;
|
||||
} else if (touching(touch, mainButtons[2])) {
|
||||
Gui::setScreen(std::make_unique<Credits>(), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<Credits>(), config->screenFade(), true);
|
||||
}
|
||||
}
|
||||
|
||||
if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) {
|
||||
Gui::screenBack(Config::fading);
|
||||
Gui::screenBack(config->screenFade());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -409,7 +412,7 @@ void Settings::LanguageSelection(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
selectedLang = 0;
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
if ((hHeld & KEY_UP && !keyRepeatDelay)) {
|
||||
@@ -419,12 +422,12 @@ void Settings::LanguageSelection(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
selectedLang = (int)languages.size()-1;
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
if (hDown & KEY_A) {
|
||||
Config::lang = langsTemp[selectedLang];
|
||||
Lang::load(Config::lang);
|
||||
config->language(langsTemp[selectedLang]);
|
||||
Lang::load(config->language());
|
||||
changesMade = true;
|
||||
mode = 0;
|
||||
}
|
||||
@@ -432,6 +435,7 @@ void Settings::LanguageSelection(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
if ((hDown & KEY_B)) {
|
||||
mode = 0;
|
||||
}
|
||||
|
||||
if (selectedLang < screenPos) {
|
||||
screenPos = selectedLang;
|
||||
} else if (selectedLang > screenPos + ENTRIES_PER_SCREEN - 1) {
|
||||
@@ -459,7 +463,7 @@ void Settings::colorChanging(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
colorSelection = 0;
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
if ((hHeld & KEY_UP && !keyRepeatDelay)) {
|
||||
@@ -469,7 +473,7 @@ void Settings::colorChanging(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
colorSelection = (int)colorList.size()-1;
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -484,11 +488,11 @@ void Settings::colorChanging(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
|
||||
if ((hDown & KEY_L || hDown & KEY_LEFT)) {
|
||||
if(colorMode > 0) colorMode--;
|
||||
if (colorMode > 0) colorMode--;
|
||||
}
|
||||
|
||||
if ((hDown & KEY_R || hDown & KEY_RIGHT)) {
|
||||
if(colorMode < 11) colorMode++;
|
||||
if (colorMode < 11) colorMode++;
|
||||
}
|
||||
|
||||
if (hDown & KEY_TOUCH) {
|
||||
@@ -497,29 +501,29 @@ void Settings::colorChanging(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
if(temp != -1) {
|
||||
red = temp;
|
||||
if (colorMode == 0) {
|
||||
Config::Color1 = RGBA8(red, ColorHelper::getColorValue(Config::Color1, 1), ColorHelper::getColorValue(Config::Color1, 0), 255);
|
||||
config->barColor(RGBA8(red, ColorHelper::getColorValue(config->barColor(), 1), ColorHelper::getColorValue(config->barColor(), 0), 255));
|
||||
} else if (colorMode == 1) {
|
||||
Config::Color2 = RGBA8(red, ColorHelper::getColorValue(Config::Color2, 1), ColorHelper::getColorValue(Config::Color2, 0), 255);
|
||||
config->topBG(RGBA8(red, ColorHelper::getColorValue(config->topBG(), 1), ColorHelper::getColorValue(config->topBG(), 0), 255));
|
||||
} else if (colorMode == 2) {
|
||||
Config::Color3 = RGBA8(red, ColorHelper::getColorValue(Config::Color3, 1), ColorHelper::getColorValue(Config::Color3, 0), 255);
|
||||
config->bottomBG(RGBA8(red, ColorHelper::getColorValue(config->bottomBG(), 1), ColorHelper::getColorValue(config->bottomBG(), 0), 255));
|
||||
} else if (colorMode == 3) {
|
||||
Config::TxtColor = RGBA8(red, ColorHelper::getColorValue(Config::TxtColor, 1), ColorHelper::getColorValue(Config::TxtColor, 0), 255);
|
||||
config->textColor(RGBA8(red, ColorHelper::getColorValue(config->textColor(), 1), ColorHelper::getColorValue(config->textColor(), 0), 255));
|
||||
} else if (colorMode == 4) {
|
||||
Config::SelectedColor = RGBA8(red, ColorHelper::getColorValue(Config::SelectedColor, 1), ColorHelper::getColorValue(Config::SelectedColor, 0), 255);
|
||||
config->selectedColor(RGBA8(red, ColorHelper::getColorValue(config->selectedColor(), 1), ColorHelper::getColorValue(config->selectedColor(), 0), 255));
|
||||
} else if (colorMode == 5) {
|
||||
Config::UnselectedColor = RGBA8(red, ColorHelper::getColorValue(Config::UnselectedColor, 1), ColorHelper::getColorValue(Config::UnselectedColor, 0), 255);
|
||||
config->unselectedColor(RGBA8(red, ColorHelper::getColorValue(config->unselectedColor(), 1), ColorHelper::getColorValue(config->unselectedColor(), 0), 255));
|
||||
} else if (colorMode == 6) {
|
||||
Config::progressbarColor = RGBA8(red, ColorHelper::getColorValue(Config::progressbarColor, 1), ColorHelper::getColorValue(Config::progressbarColor, 0), 255);
|
||||
config->progressbarColor(RGBA8(red, ColorHelper::getColorValue(config->progressbarColor(), 1), ColorHelper::getColorValue(config->progressbarColor(), 0), 255));
|
||||
} else if (colorMode == 7) {
|
||||
Config::notFound = RGBA8(red, ColorHelper::getColorValue(Config::notFound, 1), ColorHelper::getColorValue(Config::notFound, 0), 255);
|
||||
config->notfoundColor(RGBA8(red, ColorHelper::getColorValue(config->notfoundColor(), 1), ColorHelper::getColorValue(config->notfoundColor(), 0), 255));
|
||||
} else if (colorMode == 8) {
|
||||
Config::outdated = RGBA8(red, ColorHelper::getColorValue(Config::outdated, 1), ColorHelper::getColorValue(Config::outdated, 0), 255);
|
||||
config->outdatedColor(RGBA8(red, ColorHelper::getColorValue(config->outdatedColor(), 1), ColorHelper::getColorValue(config->outdatedColor(), 0), 255));
|
||||
} else if (colorMode == 9) {
|
||||
Config::uptodate = RGBA8(red, ColorHelper::getColorValue(Config::uptodate, 1), ColorHelper::getColorValue(Config::uptodate, 0), 255);
|
||||
config->uptodateColor(RGBA8(red, ColorHelper::getColorValue(config->uptodateColor(), 1), ColorHelper::getColorValue(config->uptodateColor(), 0), 255));
|
||||
} else if (colorMode == 10) {
|
||||
Config::future = RGBA8(red, ColorHelper::getColorValue(Config::future, 1), ColorHelper::getColorValue(Config::future, 0), 255);
|
||||
config->futureColor(RGBA8(red, ColorHelper::getColorValue(config->futureColor(), 1), ColorHelper::getColorValue(config->futureColor(), 0), 255));
|
||||
} else if (colorMode == 11) {
|
||||
Config::Button = RGBA8(red, ColorHelper::getColorValue(Config::Button, 1), ColorHelper::getColorValue(Config::Button, 0), 255);
|
||||
config->buttonColor(RGBA8(red, ColorHelper::getColorValue(config->buttonColor(), 1), ColorHelper::getColorValue(config->buttonColor(), 0), 255));
|
||||
}
|
||||
changesMade = true;
|
||||
}
|
||||
@@ -528,29 +532,29 @@ void Settings::colorChanging(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
if(temp != -1) {
|
||||
green = temp;
|
||||
if (colorMode == 0) {
|
||||
Config::Color1 = RGBA8(ColorHelper::getColorValue(Config::Color1, 2), green, ColorHelper::getColorValue(Config::Color1, 0), 255);
|
||||
config->barColor(RGBA8(ColorHelper::getColorValue(config->barColor(), 2), green, ColorHelper::getColorValue(config->barColor(), 0), 255));
|
||||
} else if (colorMode == 1) {
|
||||
Config::Color2 = RGBA8(ColorHelper::getColorValue(Config::Color2, 2), green, ColorHelper::getColorValue(Config::Color2, 0), 255);
|
||||
config->topBG(RGBA8(ColorHelper::getColorValue(config->topBG(), 2), green, ColorHelper::getColorValue(config->topBG(), 0), 255));
|
||||
} else if (colorMode == 2) {
|
||||
Config::Color3 = RGBA8(ColorHelper::getColorValue(Config::Color3, 2), green, ColorHelper::getColorValue(Config::Color3, 0), 255);
|
||||
config->bottomBG(RGBA8(ColorHelper::getColorValue(config->bottomBG(), 2), green, ColorHelper::getColorValue(config->bottomBG(), 0), 255));
|
||||
} else if (colorMode == 3) {
|
||||
Config::TxtColor = RGBA8(ColorHelper::getColorValue(Config::TxtColor, 2), green, ColorHelper::getColorValue(Config::TxtColor, 0), 255);
|
||||
config->textColor(RGBA8(ColorHelper::getColorValue(config->textColor(), 2), green, ColorHelper::getColorValue(config->textColor(), 0), 255));
|
||||
} else if (colorMode == 4) {
|
||||
Config::SelectedColor = RGBA8(ColorHelper::getColorValue(Config::SelectedColor, 2), green, ColorHelper::getColorValue(Config::SelectedColor, 0), 255);
|
||||
config->selectedColor(RGBA8(ColorHelper::getColorValue(config->selectedColor(), 2), green, ColorHelper::getColorValue(config->selectedColor(), 0), 255));
|
||||
} else if (colorMode == 5) {
|
||||
Config::UnselectedColor = RGBA8(ColorHelper::getColorValue(Config::UnselectedColor, 2), green, ColorHelper::getColorValue(Config::UnselectedColor, 0), 255);
|
||||
config->unselectedColor(RGBA8(ColorHelper::getColorValue(config->unselectedColor(), 2), green, ColorHelper::getColorValue(config->unselectedColor(), 0), 255));
|
||||
} else if (colorMode == 6) {
|
||||
Config::progressbarColor = RGBA8(ColorHelper::getColorValue(Config::progressbarColor, 2), green, ColorHelper::getColorValue(Config::progressbarColor, 0), 255);
|
||||
config->progressbarColor(RGBA8(ColorHelper::getColorValue(config->progressbarColor(), 2), green, ColorHelper::getColorValue(config->progressbarColor(), 0), 255));
|
||||
} else if (colorMode == 7) {
|
||||
Config::notFound = RGBA8(ColorHelper::getColorValue(Config::notFound, 2), green, ColorHelper::getColorValue(Config::notFound, 0), 255);
|
||||
config->notfoundColor(RGBA8(ColorHelper::getColorValue(config->notfoundColor(), 2), green, ColorHelper::getColorValue(config->notfoundColor(), 0), 255));
|
||||
} else if (colorMode == 8) {
|
||||
Config::outdated = RGBA8(ColorHelper::getColorValue(Config::outdated, 2), green, ColorHelper::getColorValue(Config::outdated, 0), 255);
|
||||
config->outdatedColor(RGBA8(ColorHelper::getColorValue(config->outdatedColor(), 2), green, ColorHelper::getColorValue(config->outdatedColor(), 0), 255));
|
||||
} else if (colorMode == 9) {
|
||||
Config::uptodate = RGBA8(ColorHelper::getColorValue(Config::uptodate, 2), green, ColorHelper::getColorValue(Config::uptodate, 0), 255);
|
||||
config->uptodateColor(RGBA8(ColorHelper::getColorValue(config->uptodateColor(), 2), green, ColorHelper::getColorValue(config->uptodateColor(), 0), 255));
|
||||
} else if (colorMode == 10) {
|
||||
Config::future = RGBA8(ColorHelper::getColorValue(Config::future, 2), green, ColorHelper::getColorValue(Config::future, 0), 255);
|
||||
config->futureColor(RGBA8(ColorHelper::getColorValue(config->futureColor(), 2), green, ColorHelper::getColorValue(config->futureColor(), 0), 255));
|
||||
} else if (colorMode == 11) {
|
||||
Config::Button = RGBA8(ColorHelper::getColorValue(Config::Button, 2), green, ColorHelper::getColorValue(Config::Button, 0), 255);
|
||||
config->buttonColor(RGBA8(ColorHelper::getColorValue(config->buttonColor(), 2), green, ColorHelper::getColorValue(config->buttonColor(), 0), 255));
|
||||
}
|
||||
changesMade = true;
|
||||
}
|
||||
@@ -559,29 +563,29 @@ void Settings::colorChanging(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
if(temp != -1) {
|
||||
blue = temp;
|
||||
if (colorMode == 0) {
|
||||
Config::Color1 = RGBA8(ColorHelper::getColorValue(Config::Color1, 2), ColorHelper::getColorValue(Config::Color1, 1), blue, 255);
|
||||
config->barColor(RGBA8(ColorHelper::getColorValue(config->barColor(), 2), ColorHelper::getColorValue(config->barColor(), 1), blue, 255));
|
||||
} else if (colorMode == 1) {
|
||||
Config::Color2 = RGBA8(ColorHelper::getColorValue(Config::Color2, 2), ColorHelper::getColorValue(Config::Color2, 1), blue, 255);
|
||||
config->topBG(RGBA8(ColorHelper::getColorValue(config->topBG(), 2), ColorHelper::getColorValue(config->topBG(), 1), blue, 255));
|
||||
} else if (colorMode == 2) {
|
||||
Config::Color3 = RGBA8(ColorHelper::getColorValue(Config::Color3, 2), ColorHelper::getColorValue(Config::Color3, 1), blue, 255);
|
||||
config->bottomBG(RGBA8(ColorHelper::getColorValue(config->bottomBG(), 2), ColorHelper::getColorValue(config->bottomBG(), 1), blue, 255));
|
||||
} else if (colorMode == 3) {
|
||||
Config::TxtColor = RGBA8(ColorHelper::getColorValue(Config::TxtColor, 2), ColorHelper::getColorValue(Config::TxtColor, 1), blue, 255);
|
||||
config->textColor(RGBA8(ColorHelper::getColorValue(config->textColor(), 2), ColorHelper::getColorValue(config->textColor(), 1), blue, 255));
|
||||
} else if (colorMode == 4) {
|
||||
Config::SelectedColor = RGBA8(ColorHelper::getColorValue(Config::SelectedColor, 2), ColorHelper::getColorValue(Config::SelectedColor, 1), blue, 255);
|
||||
config->selectedColor(RGBA8(ColorHelper::getColorValue(config->selectedColor(), 2), ColorHelper::getColorValue(config->selectedColor(), 1), blue, 255));
|
||||
} else if (colorMode == 5) {
|
||||
Config::UnselectedColor = RGBA8(ColorHelper::getColorValue(Config::UnselectedColor, 2), ColorHelper::getColorValue(Config::UnselectedColor, 1), blue, 255);
|
||||
config->unselectedColor(RGBA8(ColorHelper::getColorValue(config->unselectedColor(), 2), ColorHelper::getColorValue(config->unselectedColor(), 1), blue, 255));
|
||||
} else if (colorMode == 6) {
|
||||
Config::progressbarColor = RGBA8(ColorHelper::getColorValue(Config::progressbarColor, 2), ColorHelper::getColorValue(Config::progressbarColor, 1), blue, 255);
|
||||
config->progressbarColor(RGBA8(ColorHelper::getColorValue(config->progressbarColor(), 2), ColorHelper::getColorValue(config->progressbarColor(), 1), blue, 255));
|
||||
} else if (colorMode == 7) {
|
||||
Config::notFound = RGBA8(ColorHelper::getColorValue(Config::notFound, 2), ColorHelper::getColorValue(Config::notFound, 1), blue, 255);
|
||||
config->notfoundColor(RGBA8(ColorHelper::getColorValue(config->notfoundColor(), 2), ColorHelper::getColorValue(config->notfoundColor(), 1), blue, 255));
|
||||
} else if (colorMode == 8) {
|
||||
Config::outdated = RGBA8(ColorHelper::getColorValue(Config::outdated, 2), ColorHelper::getColorValue(Config::outdated, 1), blue, 255);
|
||||
config->outdatedColor(RGBA8(ColorHelper::getColorValue(config->outdatedColor(), 2), ColorHelper::getColorValue(config->outdatedColor(), 1), blue, 255));
|
||||
} else if (colorMode == 9) {
|
||||
Config::uptodate = RGBA8(ColorHelper::getColorValue(Config::uptodate, 2), ColorHelper::getColorValue(Config::uptodate, 1), blue, 255);
|
||||
config->uptodateColor(RGBA8(ColorHelper::getColorValue(config->uptodateColor(), 2), ColorHelper::getColorValue(config->uptodateColor(), 1), blue, 255));
|
||||
} else if (colorMode == 10) {
|
||||
Config::future = RGBA8(ColorHelper::getColorValue(Config::future, 2), ColorHelper::getColorValue(Config::future, 1), blue, 255);
|
||||
config->futureColor(RGBA8(ColorHelper::getColorValue(config->futureColor(), 2), ColorHelper::getColorValue(config->futureColor(), 1), blue, 255));
|
||||
} else if (colorMode == 11) {
|
||||
Config::Button = RGBA8(ColorHelper::getColorValue(Config::Button, 2), ColorHelper::getColorValue(Config::Button, 1), blue, 255);
|
||||
config->buttonColor(RGBA8(ColorHelper::getColorValue(config->buttonColor(), 2), ColorHelper::getColorValue(config->buttonColor(), 1), blue, 255));
|
||||
}
|
||||
changesMade = true;
|
||||
}
|
||||
|
||||
+119
-116
@@ -40,6 +40,7 @@ extern bool touching(touchPosition touch, Structs::ButtonPos button);
|
||||
extern bool changesMade;
|
||||
bool specialHandling = false;
|
||||
bool didAutoboot = false;
|
||||
extern std::unique_ptr<Config> config;
|
||||
|
||||
UniStore::UniStore(bool doAutoboot, std::string file) {
|
||||
this->doAutoboot = doAutoboot;
|
||||
@@ -75,9 +76,9 @@ void UniStore::autobootLogic() {
|
||||
displayInformations = handleIfDisplayText();
|
||||
const std::string sheetURL = storeInfo[0].storeSheet;
|
||||
if (storeInfo[0].version == 0) {
|
||||
Gui::setScreen(std::make_unique<UniStoreV1>(JSON, sheetURL, displayInformations), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<UniStoreV1>(JSON, sheetURL, displayInformations), config->screenFade(), true);
|
||||
} else if (storeInfo[0].version == 1) {
|
||||
Gui::setScreen(std::make_unique<UniStoreV2>(JSON, sheetURL), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<UniStoreV2>(JSON, sheetURL), config->screenFade(), true);
|
||||
} else {
|
||||
Msg::DisplayWarnMsg(Lang::get("UNISTORE_NOT_SUPPORTED"));
|
||||
}
|
||||
@@ -93,7 +94,7 @@ void UniStore::autobootLogic() {
|
||||
StoreInfo UniStore::parseStoreInfo(std::string fileName) {
|
||||
FILE* file = fopen(fileName.c_str(), "rt");
|
||||
if (!file) {
|
||||
printf("File not found\n");
|
||||
printf("File not found.\n");
|
||||
return {"", ""};
|
||||
}
|
||||
|
||||
@@ -141,10 +142,10 @@ void UniStore::loadStoreDesc(void) {
|
||||
|
||||
void UniStore::DrawSubMenu(void) const {
|
||||
GFX::DrawTop();
|
||||
if (Config::UseBars == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, Lang::get("UNISTORE_SUBMENU"), 400);
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), Lang::get("UNISTORE_SUBMENU"), 400);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("UNISTORE_SUBMENU"), 400);
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), Lang::get("UNISTORE_SUBMENU"), 400);
|
||||
}
|
||||
|
||||
GFX::DrawSprite(sprites_uniStore_HD_idx, 140, 50, 0.2, 0.2);
|
||||
@@ -155,6 +156,7 @@ void UniStore::DrawSubMenu(void) const {
|
||||
GFX::DrawButton(subPos[0].x, subPos[0].y,Lang::get("STORE_LIST"));
|
||||
GFX::DrawButton(subPos[1].x, subPos[1].y, Lang::get("STORE_SEARCH"));
|
||||
GFX::DrawButton(subPos[2].x, subPos[2].y, Lang::get("CHANGE_STOREPATH"));
|
||||
|
||||
// Selector.
|
||||
Animation::Button(subPos[Selection].x, subPos[Selection].y, .060);
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
@@ -167,18 +169,18 @@ void UniStore::DrawStoreList(void) const {
|
||||
std::string line2;
|
||||
std::string storeAmount = std::to_string(Selection +1) + " | " + std::to_string(storeInfo.size());
|
||||
GFX::DrawTop();
|
||||
if (Config::UseBars == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, storeInfo[Selection].title, 400);
|
||||
Gui::DrawString(5, 220, 0.6f, Config::TxtColor, Lang::get("UNISTORE_VERSION") + std::to_string(storeInfo[Selection].version + 1), 400);
|
||||
Gui::DrawString(397-Gui::GetStringWidth(0.6f, storeAmount), 239-Gui::GetStringHeight(0.6f, storeAmount), 0.6f, Config::TxtColor, storeAmount);
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), storeInfo[Selection].title, 400);
|
||||
Gui::DrawString(5, 220, 0.6f, config->textColor(), Lang::get("UNISTORE_VERSION") + std::to_string(storeInfo[Selection].version + 1), 400);
|
||||
Gui::DrawString(397-Gui::GetStringWidth(0.6f, storeAmount), 239-Gui::GetStringHeight(0.6f, storeAmount), 0.6f, config->textColor(), storeAmount);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, storeInfo[Selection].title, 400);
|
||||
Gui::DrawString(5, 218, 0.6f, Config::TxtColor, Lang::get("UNISTORE_VERSION") + std::to_string(storeInfo[Selection].version + 1), 400);
|
||||
Gui::DrawString(397-Gui::GetStringWidth(0.6f, storeAmount), 237-Gui::GetStringHeight(0.6f, storeAmount), 0.6f, Config::TxtColor, storeAmount);
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), storeInfo[Selection].title, 400);
|
||||
Gui::DrawString(5, 218, 0.6f, config->textColor(), Lang::get("UNISTORE_VERSION") + std::to_string(storeInfo[Selection].version + 1), 400);
|
||||
Gui::DrawString(397-Gui::GetStringWidth(0.6f, storeAmount), 237-Gui::GetStringHeight(0.6f, storeAmount), 0.6f, config->textColor(), storeAmount);
|
||||
}
|
||||
|
||||
for(uint i = 0; i < descLines.size(); i++) {
|
||||
Gui::DrawStringCentered(0, 120-((descLines.size()*20)/2)+i*20, 0.6f, Config::TxtColor, descLines[i], 400);
|
||||
Gui::DrawStringCentered(0, 120-((descLines.size()*20)/2)+i*20, 0.6f, config->textColor(), descLines[i], 400);
|
||||
}
|
||||
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
@@ -188,43 +190,43 @@ void UniStore::DrawStoreList(void) const {
|
||||
GFX::DrawArrow(0, 218, 0, 1);
|
||||
GFX::DrawSpriteBlend(sprites_dropdown_idx, arrowPos[3].x, arrowPos[3].y);
|
||||
|
||||
if (Config::viewMode == 0) {
|
||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)storeInfo.size();i++) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, Config::UnselectedColor);
|
||||
if (config->viewMode() == 0) {
|
||||
for(int i = 0; i < ENTRIES_PER_SCREEN && i < (int)storeInfo.size(); i++) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, config->unselectedColor());
|
||||
line1 = storeInfo[screenPos + i].title;
|
||||
line2 = storeInfo[screenPos + i].author;
|
||||
if (screenPos + i == Selection) {
|
||||
if (!dropDownMenu) {
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, TRANSPARENT, Config::SelectedColor);
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, TRANSPARENT, config->selectedColor());
|
||||
}
|
||||
}
|
||||
|
||||
Gui::DrawStringCentered(0, 38+(i*57), 0.7f, Config::TxtColor, line1, 320);
|
||||
Gui::DrawStringCentered(0, 62+(i*57), 0.7f, Config::TxtColor, line2, 320);
|
||||
Gui::DrawStringCentered(0, 38+(i*57), 0.7f, config->textColor(), line1, 320);
|
||||
Gui::DrawStringCentered(0, 62+(i*57), 0.7f, config->textColor(), line2, 320);
|
||||
}
|
||||
} else if (Config::viewMode == 1) {
|
||||
for(int i=0;i<ENTRIES_PER_LIST && i<(int)storeInfo.size();i++) {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, Config::UnselectedColor);
|
||||
} else if (config->viewMode() == 1) {
|
||||
for(int i = 0; i < ENTRIES_PER_LIST && i < (int)storeInfo.size(); i++) {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, config->unselectedColor());
|
||||
line1 = storeInfo[screenPosList + i].title;
|
||||
if (screenPosList + i == Selection) {
|
||||
if (!dropDownMenu) {
|
||||
Gui::drawAnimatedSelector(0, (i+1)*27, 320, 25, .060, TRANSPARENT, Config::SelectedColor);
|
||||
Gui::drawAnimatedSelector(0, (i+1)*27, 320, 25, .060, TRANSPARENT, config->selectedColor());
|
||||
}
|
||||
}
|
||||
|
||||
Gui::DrawStringCentered(0, ((i+1)*27)+1, 0.7f, Config::TxtColor, line1, 320);
|
||||
Gui::DrawStringCentered(0, ((i+1)*27)+1, 0.7f, config->textColor(), line1, 320);
|
||||
}
|
||||
}
|
||||
|
||||
// DropDown Menu.
|
||||
if (dropDownMenu) {
|
||||
// Draw Operation Box.
|
||||
Gui::Draw_Rect(0, 25, 140, 130, Config::Color1);
|
||||
Gui::Draw_Rect(0, 25, 140, 130, config->barColor());
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (dropSelection == i) {
|
||||
Gui::drawAnimatedSelector(dropPos2[i].x, dropPos2[i].y, dropPos2[i].w, dropPos2[i].h, .090, TRANSPARENT, Config::SelectedColor);
|
||||
Gui::drawAnimatedSelector(dropPos2[i].x, dropPos2[i].y, dropPos2[i].w, dropPos2[i].h, .090, TRANSPARENT, config->selectedColor());
|
||||
} else {
|
||||
Gui::Draw_Rect(dropPos2[i].x, dropPos2[i].y, dropPos2[i].w, dropPos2[i].h, Config::UnselectedColor);
|
||||
Gui::Draw_Rect(dropPos2[i].x, dropPos2[i].y, dropPos2[i].w, dropPos2[i].h, config->unselectedColor());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,9 +235,9 @@ void UniStore::DrawStoreList(void) const {
|
||||
GFX::DrawSpriteBlend(sprites_update_idx, dropPos[1].x, dropPos[1].y);
|
||||
GFX::DrawSpriteBlend(sprites_view_idx, dropPos[2].x, dropPos[2].y);
|
||||
// Dropdown Text.
|
||||
Gui::DrawString(dropPos[0].x+30, dropPos[0].y+5, 0.4f, Config::TxtColor, Lang::get("DELETE_DDM"), 100);
|
||||
Gui::DrawString(dropPos[1].x+30, dropPos[1].y+5, 0.4f, Config::TxtColor, Lang::get("UPDATE_DDM"), 100);
|
||||
Gui::DrawString(dropPos[2].x+30, dropPos[2].y+5, 0.4f, Config::TxtColor, Lang::get("VIEW_DDM"), 100);
|
||||
Gui::DrawString(dropPos[0].x+30, dropPos[0].y+5, 0.4f, config->textColor(), Lang::get("DELETE_DDM"), 100);
|
||||
Gui::DrawString(dropPos[1].x+30, dropPos[1].y+5, 0.4f, config->textColor(), Lang::get("UPDATE_DDM"), 100);
|
||||
Gui::DrawString(dropPos[2].x+30, dropPos[2].y+5, 0.4f, config->textColor(), Lang::get("VIEW_DDM"), 100);
|
||||
}
|
||||
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
@@ -272,9 +274,9 @@ void UniStore::updateStore(int selectedStore) {
|
||||
Msg::DisplayMsg(Lang::get("REFRESHING_LIST"));
|
||||
dirContents.clear();
|
||||
storeInfo.clear();
|
||||
chdir(Config::StorePath.c_str());
|
||||
chdir(config->storePath().c_str());
|
||||
getDirectoryContents(dirContents, {"unistore"});
|
||||
for(uint i=0;i<dirContents.size();i++) {
|
||||
for(uint i = 0; i < dirContents.size(); i++) {
|
||||
storeInfo.push_back(parseStoreInfo(dirContents[i].name));
|
||||
descript();
|
||||
loadStoreDesc();
|
||||
@@ -284,13 +286,13 @@ void UniStore::updateStore(int selectedStore) {
|
||||
}
|
||||
|
||||
void UniStore::refreshList() {
|
||||
if (returnIfExist(Config::StorePath, {"unistore"}) == true) {
|
||||
if (returnIfExist(config->storePath(), {"unistore"}) == true) {
|
||||
Msg::DisplayMsg(Lang::get("REFRESHING_LIST"));
|
||||
dirContents.clear();
|
||||
storeInfo.clear();
|
||||
chdir(Config::StorePath.c_str());
|
||||
chdir(config->storePath().c_str());
|
||||
getDirectoryContents(dirContents, {"unistore"});
|
||||
for(uint i=0;i<dirContents.size();i++) {
|
||||
for(uint i = 0; i < dirContents.size(); i++) {
|
||||
storeInfo.push_back(parseStoreInfo(dirContents[i].name));
|
||||
descript();
|
||||
loadStoreDesc();
|
||||
@@ -306,9 +308,9 @@ void UniStore::refreshList() {
|
||||
void UniStore::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) {
|
||||
if (specialHandling) {
|
||||
Gui::setScreen(std::make_unique<MainMenu>(), true, true);
|
||||
Gui::setScreen(std::make_unique<MainMenu>(), config->screenFade(), true);
|
||||
} else {
|
||||
Gui::screenBack(Config::fading);
|
||||
Gui::screenBack(config->screenFade());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -323,17 +325,18 @@ void UniStore::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
if (hDown & KEY_A) {
|
||||
switch(Selection) {
|
||||
case 0:
|
||||
if (returnIfExist(Config::StorePath, {"unistore"}) == true) {
|
||||
if (returnIfExist(config->storePath(), {"unistore"}) == true) {
|
||||
Msg::DisplayMsg(Lang::get("REFRESHING_LIST"));
|
||||
dirContents.clear();
|
||||
storeInfo.clear();
|
||||
chdir(Config::StorePath.c_str());
|
||||
chdir(config->storePath().c_str());
|
||||
getDirectoryContents(dirContents, {"unistore"});
|
||||
for(uint i=0;i<dirContents.size();i++) {
|
||||
for(uint i = 0; i < dirContents.size(); i++) {
|
||||
storeInfo.push_back(parseStoreInfo(dirContents[i].name));
|
||||
descript();
|
||||
loadStoreDesc();
|
||||
}
|
||||
|
||||
Selection = 0;
|
||||
mode = 1;
|
||||
} else {
|
||||
@@ -349,9 +352,9 @@ void UniStore::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
std::string tempStore = selectFilePath(Lang::get("SELECT_STORE_PATH"), Config::StorePath, {});
|
||||
std::string tempStore = selectFilePath(Lang::get("SELECT_STORE_PATH"), config->storePath(), {});
|
||||
if (tempStore != "") {
|
||||
Config::StorePath = tempStore;
|
||||
config->storePath(tempStore);
|
||||
changesMade = true;
|
||||
}
|
||||
break;
|
||||
@@ -360,17 +363,18 @@ void UniStore::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
|
||||
if (hDown & KEY_TOUCH) {
|
||||
if (touching(touch, subPos[0])) {
|
||||
if (returnIfExist(Config::StorePath, {"unistore"}) == true) {
|
||||
if (returnIfExist(config->storePath(), {"unistore"}) == true) {
|
||||
Msg::DisplayMsg(Lang::get("REFRESHING_LIST"));
|
||||
dirContents.clear();
|
||||
storeInfo.clear();
|
||||
chdir(Config::StorePath.c_str());
|
||||
chdir(config->storePath().c_str());
|
||||
getDirectoryContents(dirContents, {"unistore"});
|
||||
for(uint i=0;i<dirContents.size();i++) {
|
||||
for(uint i = 0; i < dirContents.size(); i++) {
|
||||
storeInfo.push_back(parseStoreInfo(dirContents[i].name));
|
||||
descript();
|
||||
loadStoreDesc();
|
||||
}
|
||||
|
||||
Selection = 0;
|
||||
mode = 1;
|
||||
} else {
|
||||
@@ -384,9 +388,9 @@ void UniStore::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
notConnectedMsg();
|
||||
}
|
||||
} else if (touching(touch, subPos[2])) {
|
||||
std::string tempStore = selectFilePath(Lang::get("SELECT_STORE_PATH"), Config::StorePath, {});
|
||||
std::string tempStore = selectFilePath(Lang::get("SELECT_STORE_PATH"), config->storePath(), {});
|
||||
if (tempStore != "") {
|
||||
Config::StorePath = tempStore;
|
||||
config->storePath(tempStore);
|
||||
changesMade = true;
|
||||
}
|
||||
}
|
||||
@@ -394,7 +398,7 @@ void UniStore::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
|
||||
void UniStore::deleteStore(int selectedStore) {
|
||||
std::string path = Config::StorePath;
|
||||
std::string path = config->storePath();
|
||||
path += dirContents[selectedStore].name;
|
||||
deleteFile(path.c_str());
|
||||
// Refresh the list.
|
||||
@@ -402,9 +406,9 @@ void UniStore::deleteStore(int selectedStore) {
|
||||
Selection = 0;
|
||||
dirContents.clear();
|
||||
storeInfo.clear();
|
||||
chdir(Config::StorePath.c_str());
|
||||
chdir(config->storePath().c_str());
|
||||
getDirectoryContents(dirContents, {"unistore"});
|
||||
for(uint i=0;i<dirContents.size();i++) {
|
||||
for(uint i = 0; i < dirContents.size(); i++) {
|
||||
storeInfo.push_back(parseStoreInfo(dirContents[i].name));
|
||||
descript();
|
||||
loadStoreDesc();
|
||||
@@ -459,10 +463,10 @@ void UniStore::StoreSelectionLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
updateStore(Selection);
|
||||
break;
|
||||
case 2:
|
||||
if (Config::viewMode == 0) {
|
||||
Config::viewMode = 1;
|
||||
if (config->viewMode() == 0) {
|
||||
config->viewMode(1);
|
||||
} else {
|
||||
Config::viewMode = 0;
|
||||
config->viewMode(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -479,10 +483,10 @@ void UniStore::StoreSelectionLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
updateStore(Selection);
|
||||
dropDownMenu = false;
|
||||
} else if (touching(touch, dropPos2[2])) {
|
||||
if (Config::viewMode == 0) {
|
||||
Config::viewMode = 1;
|
||||
if (config->viewMode() == 0) {
|
||||
config->viewMode(1);
|
||||
} else {
|
||||
Config::viewMode = 0;
|
||||
config->viewMode(0);
|
||||
}
|
||||
dropDownMenu = false;
|
||||
}
|
||||
@@ -510,7 +514,7 @@ void UniStore::StoreSelectionLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
loadStoreDesc();
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
if ((hHeld & KEY_UP && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[0]))) {
|
||||
@@ -524,11 +528,11 @@ void UniStore::StoreSelectionLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
loadStoreDesc();
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
if ((hHeld & KEY_RIGHT && !keyRepeatDelay)) {
|
||||
if (Config::viewMode == 0) {
|
||||
if (config->viewMode() == 0) {
|
||||
if (Selection < (int)storeInfo.size()-1-3) {
|
||||
Selection += 3;
|
||||
descript();
|
||||
@@ -550,11 +554,11 @@ void UniStore::StoreSelectionLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
if ((hHeld & KEY_LEFT && !keyRepeatDelay)) {
|
||||
if (Config::viewMode == 0) {
|
||||
if (config->viewMode() == 0) {
|
||||
if (Selection > 2) {
|
||||
Selection -= 3;
|
||||
descript();
|
||||
@@ -576,12 +580,11 @@ void UniStore::StoreSelectionLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
if (hDown & KEY_A) {
|
||||
if (dirContents[Selection].isDirectory) {
|
||||
} else if (storeInfo.size() != 0) {
|
||||
if (!dirContents[Selection].isDirectory && storeInfo.size() != 0) {
|
||||
if (ScriptHelper::checkIfValid(dirContents[Selection].name, 1) == true) {
|
||||
updateStore(Selection);
|
||||
currentStoreFile = dirContents[Selection].name;
|
||||
@@ -591,9 +594,9 @@ void UniStore::StoreSelectionLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
const std::string sheetURL = storeInfo[Selection].storeSheet;
|
||||
|
||||
if (storeInfo[Selection].version == 0) {
|
||||
Gui::setScreen(std::make_unique<UniStoreV1>(JSON, sheetURL, displayInformations), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<UniStoreV1>(JSON, sheetURL, displayInformations), config->screenFade(), true);
|
||||
} else if (storeInfo[Selection].version == 1) {
|
||||
Gui::setScreen(std::make_unique<UniStoreV2>(JSON, sheetURL), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<UniStoreV2>(JSON, sheetURL), config->screenFade(), true);
|
||||
} else {
|
||||
Msg::DisplayWarnMsg(Lang::get("UNISTORE_NOT_SUPPORTED"));
|
||||
}
|
||||
@@ -601,13 +604,13 @@ void UniStore::StoreSelectionLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
}
|
||||
|
||||
if (Config::viewMode == 0) {
|
||||
if (config->viewMode() == 0) {
|
||||
if(Selection < screenPos) {
|
||||
screenPos = Selection;
|
||||
} else if (Selection > screenPos + ENTRIES_PER_SCREEN - 1) {
|
||||
screenPos = Selection - ENTRIES_PER_SCREEN + 1;
|
||||
}
|
||||
} else if (Config::viewMode == 1) {
|
||||
} else if (config->viewMode() == 1) {
|
||||
if(Selection < screenPosList) {
|
||||
screenPosList = Selection;
|
||||
} else if (Selection > screenPosList + ENTRIES_PER_LIST - 1) {
|
||||
@@ -616,9 +619,9 @@ void UniStore::StoreSelectionLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
|
||||
if (hDown & KEY_TOUCH) {
|
||||
if (Config::viewMode == 0) {
|
||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)storeInfo.size();i++) {
|
||||
if(touch.py > 40+(i*57) && touch.py < 40+(i*57)+45) {
|
||||
if (config->viewMode() == 0) {
|
||||
for(int i = 0; i < ENTRIES_PER_SCREEN && i < (int)storeInfo.size(); i++) {
|
||||
if (touch.py > 40+(i*57) && touch.py < 40+(i*57)+45) {
|
||||
if (ScriptHelper::checkIfValid(dirContents[screenPos + i].name, 1) == true) {
|
||||
updateStore(screenPos + i);
|
||||
currentStoreFile = dirContents[screenPos + i].name;
|
||||
@@ -627,17 +630,17 @@ void UniStore::StoreSelectionLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
displayInformations = handleIfDisplayText();
|
||||
const std::string sheetURL = storeInfo[screenPos + i].storeSheet;
|
||||
if (storeInfo[screenPos + i].version == 0) {
|
||||
Gui::setScreen(std::make_unique<UniStoreV1>(JSON, sheetURL, displayInformations), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<UniStoreV1>(JSON, sheetURL, displayInformations), config->screenFade(), true);
|
||||
} else if (storeInfo[screenPos + i].version == 1) {
|
||||
Gui::setScreen(std::make_unique<UniStoreV2>(JSON, sheetURL), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<UniStoreV2>(JSON, sheetURL), config->screenFade(), true);
|
||||
} else {
|
||||
Msg::DisplayWarnMsg(Lang::get("UNISTORE_NOT_SUPPORTED"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (Config::viewMode == 1) {
|
||||
for(int i=0;i<ENTRIES_PER_LIST && i<(int)storeInfo.size();i++) {
|
||||
} else if (config->viewMode() == 1) {
|
||||
for(int i = 0; i < ENTRIES_PER_LIST && i < (int)storeInfo.size(); i++) {
|
||||
if (touch.py > (i+1)*27 && touch.py < (i+2)*27) {
|
||||
if (ScriptHelper::checkIfValid(dirContents[screenPosList + i].name, 1) == true) {
|
||||
updateStore(screenPosList + i);
|
||||
@@ -648,9 +651,9 @@ void UniStore::StoreSelectionLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
displayInformations = handleIfDisplayText();
|
||||
const std::string sheetURL = storeInfo[screenPosList + i].storeSheet;
|
||||
if (storeInfo[screenPosList + i].version == 0) {
|
||||
Gui::setScreen(std::make_unique<UniStoreV1>(JSON, sheetURL, displayInformations), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<UniStoreV1>(JSON, sheetURL, displayInformations), config->screenFade(), true);
|
||||
} else if (storeInfo[screenPosList + i].version == 1) {
|
||||
Gui::setScreen(std::make_unique<UniStoreV2>(JSON, sheetURL), Config::fading, true);
|
||||
Gui::setScreen(std::make_unique<UniStoreV2>(JSON, sheetURL), config->screenFade(), true);
|
||||
} else {
|
||||
Msg::DisplayWarnMsg(Lang::get("UNISTORE_NOT_SUPPORTED"));
|
||||
}
|
||||
@@ -661,19 +664,18 @@ void UniStore::StoreSelectionLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
|
||||
if (hDown & KEY_START) {
|
||||
if (Config::autoboot == 1) {
|
||||
if (config->autoboot() == 1) {
|
||||
if (Msg::promptMsg(Lang::get("DISABLE_AUTOBOOT"))) {
|
||||
Config::autoboot = 0;
|
||||
Config::AutobootFile = "";
|
||||
config->autoboot(0);
|
||||
config->autobootFile("");
|
||||
changesMade = true;
|
||||
}
|
||||
} else {
|
||||
if (dirContents[Selection].isDirectory) {
|
||||
} else if (storeInfo.size() != 0) {
|
||||
if (!dirContents[Selection].isDirectory && storeInfo.size() != 0) {
|
||||
if (ScriptHelper::checkIfValid(dirContents[Selection].name, 1) == true) {
|
||||
if (Msg::promptMsg(Lang::get("AUTOBOOT_STORE"))) {
|
||||
Config::AutobootFile = Config::StorePath + dirContents[Selection].name;
|
||||
Config::autoboot = 1;
|
||||
config->autoboot(1);
|
||||
config->autobootFile(config->storePath() + dirContents[Selection].name);
|
||||
changesMade = true;
|
||||
}
|
||||
}
|
||||
@@ -701,10 +703,10 @@ void UniStore::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
|
||||
void UniStore::DrawSearch(void) const {
|
||||
GFX::DrawTop();
|
||||
if (Config::UseBars == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, Lang::get("UNISTORE_SEARCH"), 400);
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), Lang::get("UNISTORE_SEARCH"), 400);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("UNISTORE_SEARCH"), 400);
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), Lang::get("UNISTORE_SEARCH"), 400);
|
||||
}
|
||||
|
||||
GFX::DrawSprite(sprites_uniStore_HD_idx, 140, 50, 0.2, 0.2);
|
||||
@@ -715,6 +717,7 @@ void UniStore::DrawSearch(void) const {
|
||||
GFX::DrawButton(URLBtn[1].x, URLBtn[1].y, Lang::get("GITHUB"));
|
||||
GFX::DrawButton(URLBtn[2].x, URLBtn[2].y, "TinyDB");
|
||||
GFX::DrawButton(URLBtn[3].x, URLBtn[3].y, "Universal DB");
|
||||
|
||||
// Selector.
|
||||
Animation::Button(URLBtn[Selection].x, URLBtn[Selection].y, .060);
|
||||
}
|
||||
@@ -752,9 +755,9 @@ void UniStore::SearchLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
Selection = 0;
|
||||
mode = 4;
|
||||
} else if (Selection == 2) {
|
||||
ScriptHelper::downloadFile("https://tinydb.eiphax.tech/api/tinydb.unistore", Config::StorePath + "TinyDB.unistore", Lang::get("DOWNLOADING") + "TinyDB");
|
||||
ScriptHelper::downloadFile("https://tinydb.eiphax.tech/api/tinydb.unistore", config->storePath() + "TinyDB.unistore", Lang::get("DOWNLOADING") + "TinyDB");
|
||||
} else if (Selection == 3) {
|
||||
ScriptHelper::downloadFile("https://db.universal-team.net/unistore/universal-db.unistore", Config::StorePath + "Universal-DB.unistore", Lang::get("DOWNLOADING") + "Universal DB");
|
||||
ScriptHelper::downloadFile("https://db.universal-team.net/unistore/universal-db.unistore", config->storePath() + "Universal-DB.unistore", Lang::get("DOWNLOADING") + "Universal DB");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -765,35 +768,35 @@ void UniStore::SearchLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
Selection = 0;
|
||||
mode = 4;
|
||||
} else if (hDown & KEY_TOUCH && touching(touch, URLBtn[2])) {
|
||||
ScriptHelper::downloadFile("https://tinydb.eiphax.tech/api/tinydb.unistore", Config::StorePath + "TinyDB.unistore", Lang::get("DOWNLOADING") + "TinyDB");
|
||||
ScriptHelper::downloadFile("https://tinydb.eiphax.tech/api/tinydb.unistore", config->storePath() + "TinyDB.unistore", Lang::get("DOWNLOADING") + "TinyDB");
|
||||
} else if (hDown & KEY_TOUCH && touching(touch, URLBtn[3])) {
|
||||
ScriptHelper::downloadFile("https://db.universal-team.net/unistore/universal-db.unistore", Config::StorePath + "Universal-DB.unistore", Lang::get("DOWNLOADING") + "Universal DB");
|
||||
ScriptHelper::downloadFile("https://db.universal-team.net/unistore/universal-db.unistore", config->storePath() + "Universal-DB.unistore", Lang::get("DOWNLOADING") + "Universal DB");
|
||||
}
|
||||
}
|
||||
|
||||
void UniStore::DrawGitHubScreen(void) const {
|
||||
GFX::DrawTop();
|
||||
if (Config::UseBars == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, Lang::get("GITHUB"), 400);
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), Lang::get("GITHUB"), 400);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("GITHUB"), 400);
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), Lang::get("GITHUB"), 400);
|
||||
}
|
||||
|
||||
GFX::DrawSprite(sprites_uniStore_HD_idx, 140, 50, 0.2, 0.2);
|
||||
GFX::DrawBottom();
|
||||
GFX::DrawArrow(0, 218, 0, 1);
|
||||
|
||||
Gui::DrawStringCentered(0, 28, 0.7f, Config::TxtColor, Lang::get("OWNER_AND_REPO"), 300);
|
||||
Gui::DrawStringCentered(0, 108, 0.7f, Config::TxtColor, Lang::get("FILENAME"), 300);
|
||||
Gui::DrawStringCentered(0, 28, 0.7f, config->textColor(), Lang::get("OWNER_AND_REPO"), 300);
|
||||
Gui::DrawStringCentered(0, 108, 0.7f, config->textColor(), Lang::get("FILENAME"), 300);
|
||||
|
||||
Gui::Draw_Rect(GitHubPos[0].x, GitHubPos[0].y, GitHubPos[0].w, GitHubPos[0].h, Config::Color1);
|
||||
Gui::Draw_Rect(GitHubPos[1].x, GitHubPos[1].y, GitHubPos[1].w, GitHubPos[1].h, Config::Color1);
|
||||
Gui::Draw_Rect(GitHubPos[2].x, GitHubPos[2].y, GitHubPos[2].w, GitHubPos[2].h, Config::Color1);
|
||||
Gui::Draw_Rect(GitHubPos[0].x, GitHubPos[0].y, GitHubPos[0].w, GitHubPos[0].h, config->barColor());
|
||||
Gui::Draw_Rect(GitHubPos[1].x, GitHubPos[1].y, GitHubPos[1].w, GitHubPos[1].h, config->barColor());
|
||||
Gui::Draw_Rect(GitHubPos[2].x, GitHubPos[2].y, GitHubPos[2].w, GitHubPos[2].h, config->barColor());
|
||||
|
||||
Gui::DrawStringCentered(0, 185, 0.7f, Config::TxtColor, Lang::get("OK"), 40);
|
||||
Gui::DrawStringCentered(0, 185, 0.7f, config->textColor(), Lang::get("OK"), 40);
|
||||
|
||||
Gui::DrawStringCentered(0, 57, 0.5f, Config::TxtColor, OwnerAndRepo, 250);
|
||||
Gui::DrawStringCentered(0, 137, 0.5f, Config::TxtColor, fileName, 250);
|
||||
Gui::DrawStringCentered(0, 57, 0.5f, config->textColor(), OwnerAndRepo, 250);
|
||||
Gui::DrawStringCentered(0, 137, 0.5f, config->textColor(), fileName, 250);
|
||||
}
|
||||
|
||||
void UniStore::GitHubLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
@@ -811,7 +814,7 @@ void UniStore::GitHubLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
URL += OwnerAndRepo;
|
||||
URL += "/raw/master/unistore/";
|
||||
URL += fileName;
|
||||
ScriptHelper::downloadFile(URL, Config::StorePath + fileName, Lang::get("DOWNLOADING") + fileName);
|
||||
ScriptHelper::downloadFile(URL, config->storePath() + fileName, Lang::get("DOWNLOADING") + fileName);
|
||||
} else {
|
||||
notConnectedMsg();
|
||||
}
|
||||
@@ -828,27 +831,27 @@ void UniStore::GitHubLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
|
||||
void UniStore::DrawFullURLScreen(void) const {
|
||||
GFX::DrawTop();
|
||||
if (Config::UseBars == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, Lang::get("FULL_URL"), 400);
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), Lang::get("FULL_URL"), 400);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("FULL_URL"), 400);
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), Lang::get("FULL_URL"), 400);
|
||||
}
|
||||
|
||||
GFX::DrawSprite(sprites_uniStore_HD_idx, 140, 50, 0.2, 0.2);
|
||||
GFX::DrawBottom();
|
||||
GFX::DrawArrow(0, 218, 0, 1);
|
||||
|
||||
Gui::DrawStringCentered(0, 28, 0.7f, Config::TxtColor, Lang::get("FULL_URL"), 320);
|
||||
Gui::DrawStringCentered(0, 108, 0.7f, Config::TxtColor, Lang::get("FILENAME"), 320);
|
||||
Gui::DrawStringCentered(0, 28, 0.7f, config->textColor(), Lang::get("FULL_URL"), 320);
|
||||
Gui::DrawStringCentered(0, 108, 0.7f, config->textColor(), Lang::get("FILENAME"), 320);
|
||||
|
||||
Gui::Draw_Rect(GitHubPos[0].x, GitHubPos[0].y, GitHubPos[0].w, GitHubPos[0].h, Config::Color1);
|
||||
Gui::Draw_Rect(GitHubPos[1].x, GitHubPos[1].y, GitHubPos[1].w, GitHubPos[1].h, Config::Color1);
|
||||
Gui::Draw_Rect(GitHubPos[2].x, GitHubPos[2].y, GitHubPos[2].w, GitHubPos[2].h, Config::Color1);
|
||||
Gui::Draw_Rect(GitHubPos[0].x, GitHubPos[0].y, GitHubPos[0].w, GitHubPos[0].h, config->barColor());
|
||||
Gui::Draw_Rect(GitHubPos[1].x, GitHubPos[1].y, GitHubPos[1].w, GitHubPos[1].h, config->barColor());
|
||||
Gui::Draw_Rect(GitHubPos[2].x, GitHubPos[2].y, GitHubPos[2].w, GitHubPos[2].h, config->barColor());
|
||||
|
||||
Gui::DrawStringCentered(0, 185, 0.7f, Config::TxtColor, Lang::get("OK"), 40);
|
||||
Gui::DrawStringCentered(0, 185, 0.7f, config->textColor(), Lang::get("OK"), 40);
|
||||
|
||||
Gui::DrawStringCentered(0, 57, 0.45f, Config::TxtColor, FullURL, 250);
|
||||
Gui::DrawStringCentered(0, 137, 0.45f, Config::TxtColor, fileName, 250);
|
||||
Gui::DrawStringCentered(0, 57, 0.45f, config->textColor(), FullURL, 250);
|
||||
Gui::DrawStringCentered(0, 137, 0.45f, config->textColor(), fileName, 250);
|
||||
}
|
||||
|
||||
void UniStore::FullURLLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
@@ -862,7 +865,7 @@ void UniStore::FullURLLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
|
||||
if (hDown & KEY_TOUCH && touching(touch, GitHubPos[2])) {
|
||||
if (checkWifiStatus() == true) {
|
||||
ScriptHelper::downloadFile(FullURL, Config::StorePath + fileName, Lang::get("DOWNLOADING") + fileName);
|
||||
ScriptHelper::downloadFile(FullURL, config->storePath() + fileName, Lang::get("DOWNLOADING") + fileName);
|
||||
} else {
|
||||
notConnectedMsg();
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "unistore_v1.hpp"
|
||||
#include <unistd.h>
|
||||
|
||||
extern std::unique_ptr<Config> config;
|
||||
extern bool touching(touchPosition touch, Structs::ButtonPos button);
|
||||
extern u32 getColor(std::string colorString);
|
||||
extern bool isScriptSelected;
|
||||
@@ -57,25 +58,25 @@ UniStoreV1::UniStoreV1(nlohmann::json &JSON, const std::string sheetPath, bool d
|
||||
|
||||
u32 colorTemp;
|
||||
colorTemp = getColor(ScriptHelper::getString(this->storeJson, "storeInfo", "barColor"));
|
||||
barColor = colorTemp == 0 ? Config::Color1 : colorTemp;
|
||||
barColor = colorTemp == 0 ? config->barColor() : colorTemp;
|
||||
|
||||
colorTemp = getColor(ScriptHelper::getString(this->storeJson, "storeInfo", "bgTopColor"));
|
||||
bgTopColor = colorTemp == 0 ? Config::Color2 : colorTemp;
|
||||
bgTopColor = colorTemp == 0 ? config->topBG() : colorTemp;
|
||||
|
||||
colorTemp = getColor(ScriptHelper::getString(this->storeJson, "storeInfo", "bgBottomColor"));
|
||||
bgBottomColor = colorTemp == 0 ? Config::Color3 : colorTemp;
|
||||
bgBottomColor = colorTemp == 0 ? config->bottomBG() : colorTemp;
|
||||
|
||||
colorTemp = getColor(ScriptHelper::getString(this->storeJson, "storeInfo", "textColor"));
|
||||
TextColor = colorTemp == 0 ? Config::TxtColor : colorTemp;
|
||||
TextColor = colorTemp == 0 ? config->textColor() : colorTemp;
|
||||
|
||||
colorTemp = getColor(ScriptHelper::getString(this->storeJson, "storeInfo", "selectedColor"));
|
||||
selected = colorTemp == 0 ? Config::SelectedColor : colorTemp;
|
||||
selected = colorTemp == 0 ? config->selectedColor() : colorTemp;
|
||||
|
||||
colorTemp = getColor(ScriptHelper::getString(this->storeJson, "storeInfo", "unselectedColor"));
|
||||
unselected = colorTemp == 0 ? Config::UnselectedColor : colorTemp;
|
||||
unselected = colorTemp == 0 ? config->unselectedColor() : colorTemp;
|
||||
|
||||
colorTemp = getColor(ScriptHelper::getString(this->storeJson, "storeInfo", "progressbarColor"));
|
||||
progressBar = colorTemp == 0 ? Config::progressbarColor : colorTemp;
|
||||
progressBar = colorTemp == 0 ? config->progressbarColor() : colorTemp;
|
||||
}
|
||||
|
||||
void UniStoreV1::drawBlend(int key, int x, int y) const {
|
||||
@@ -122,7 +123,7 @@ void UniStoreV1::Draw(void) const {
|
||||
}
|
||||
|
||||
if (displayInformations != false) {
|
||||
if (Config::UseBars == true) {
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, TextColor, std::string(this->storeJson["storeInfo"]["title"]), 400);
|
||||
Gui::DrawString(397-Gui::GetStringWidth(0.6f, entryAmount), 239-Gui::GetStringHeight(0.6f, entryAmount), 0.6f, TextColor, entryAmount);
|
||||
} else {
|
||||
@@ -160,7 +161,7 @@ void UniStoreV1::Draw(void) const {
|
||||
GFX::DrawArrow(0, 218, 0, 1);
|
||||
GFX::DrawSpriteBlend(sprites_dropdown_idx, arrowPos[3].x, arrowPos[3].y);
|
||||
|
||||
if (Config::viewMode == 0) {
|
||||
if (config->viewMode() == 0) {
|
||||
for(int i = 0; i < ENTRIES_PER_SCREEN && i < (int)this->storeJson.at("storeContent").size(); i++) {
|
||||
info = this->storeJson["storeContent"][screenPos + i]["info"]["title"];
|
||||
if (screenPos + i == Selection) {
|
||||
@@ -180,10 +181,10 @@ void UniStoreV1::Draw(void) const {
|
||||
}
|
||||
Gui::DrawStringCentered(0, 50+(i*57), 0.7f, TextColor, info, 320);
|
||||
}
|
||||
} else if (Config::viewMode == 1) {
|
||||
} else if (config->viewMode() == 1) {
|
||||
for(int i = 0; i < ENTRIES_PER_LIST && i < (int)this->storeJson.at("storeContent").size(); i++) {
|
||||
info = this->storeJson["storeContent"][screenPosList + i]["info"]["title"];
|
||||
if(screenPosList + i == Selection) {
|
||||
if (screenPosList + i == Selection) {
|
||||
if (this->storeJson.at("storeInfo").contains("buttonSmall") && sheetHasLoaded == true) {
|
||||
Gui::DrawSprite(this->sheet, this->storeJson["storeInfo"]["buttonSmall"], 0, (i+1)*27);
|
||||
} else {
|
||||
@@ -206,11 +207,11 @@ void UniStoreV1::Draw(void) const {
|
||||
if (dropDownMenu) {
|
||||
// Draw Operation Box.
|
||||
Gui::Draw_Rect(0, 25, 140, 44, barColor);
|
||||
Gui::drawAnimatedSelector(dropPos[0].x, dropPos[0].y, dropPos[0].w, dropPos[0].h, .090, TRANSPARENT, Config::SelectedColor);
|
||||
Gui::drawAnimatedSelector(dropPos[0].x, dropPos[0].y, dropPos[0].w, dropPos[0].h, .090, TRANSPARENT, selected);
|
||||
// Draw Dropdown Icons.
|
||||
GFX::DrawSpriteBlend(sprites_view_idx, dropPos[0].x, dropPos[0].y);
|
||||
// Dropdown Text.
|
||||
Gui::DrawString(dropPos[0].x+30, dropPos[0].y+5, 0.4f, Config::TxtColor, Lang::get("VIEW_DDM"), 100);
|
||||
Gui::DrawString(dropPos[0].x+30, dropPos[0].y+5, 0.4f, TextColor, Lang::get("VIEW_DDM"), 100);
|
||||
}
|
||||
|
||||
if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
|
||||
@@ -230,21 +231,22 @@ void UniStoreV1::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
if (hDown & KEY_UP) {
|
||||
if (dropSelection > 0) dropSelection--;
|
||||
}
|
||||
|
||||
if (hDown & KEY_A) {
|
||||
if (Config::viewMode == 0) {
|
||||
Config::viewMode = 1;
|
||||
if (config->viewMode() == 0) {
|
||||
config->viewMode(1);
|
||||
} else {
|
||||
Config::viewMode = 0;
|
||||
config->viewMode(0);
|
||||
}
|
||||
dropDownMenu = false;
|
||||
}
|
||||
|
||||
if (hDown & KEY_TOUCH) {
|
||||
if (touching(touch, dropPos[0])) {
|
||||
if (Config::viewMode == 0) {
|
||||
Config::viewMode = 1;
|
||||
if (config->viewMode() == 0) {
|
||||
config->viewMode(1);
|
||||
} else {
|
||||
Config::viewMode = 0;
|
||||
config->viewMode(0);
|
||||
}
|
||||
dropDownMenu = false;
|
||||
}
|
||||
@@ -257,7 +259,7 @@ void UniStoreV1::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
|
||||
if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) {
|
||||
if (!didAutoboot) didAutoboot = true;
|
||||
Gui::screenBack(Config::fading);
|
||||
Gui::screenBack(config->screenFade());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -269,7 +271,7 @@ void UniStoreV1::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
Selection = (int)this->storeJson.at("storeContent").size()-1;
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
// Go one entry down.
|
||||
@@ -280,11 +282,11 @@ void UniStoreV1::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
Selection = 0;
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
if ((hHeld & KEY_RIGHT && !keyRepeatDelay)) {
|
||||
if (Config::viewMode == 0) {
|
||||
if (config->viewMode() == 0) {
|
||||
if (Selection < (int)this->storeJson.at("storeContent").size()-1-3) {
|
||||
Selection += 3;
|
||||
} else {
|
||||
@@ -298,11 +300,11 @@ void UniStoreV1::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
if ((hHeld & KEY_LEFT && !keyRepeatDelay)) {
|
||||
if (Config::viewMode == 0) {
|
||||
if (config->viewMode() == 0) {
|
||||
if (Selection > 2) {
|
||||
Selection -= 3;
|
||||
} else {
|
||||
@@ -316,13 +318,13 @@ void UniStoreV1::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
}
|
||||
|
||||
keyRepeatDelay = Config::keyDelay;
|
||||
keyRepeatDelay = config->keyDelay();
|
||||
}
|
||||
|
||||
// Execute touched Entry.
|
||||
if (hDown & KEY_TOUCH) {
|
||||
if (Config::viewMode == 0) {
|
||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)this->storeJson.at("storeContent").size();i++) {
|
||||
if (config->viewMode() == 0) {
|
||||
for(int i = 0; i < ENTRIES_PER_SCREEN && i < (int)this->storeJson.at("storeContent").size(); i++) {
|
||||
if (touch.py > 40+(i*57) && touch.py < 40+(i*57)+45) {
|
||||
Selection = screenPos + i;
|
||||
std::string info = this->storeJson["storeContent"][Selection]["info"]["title"];
|
||||
@@ -331,8 +333,8 @@ void UniStoreV1::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (Config::viewMode == 1) {
|
||||
for(int i=0;i<ENTRIES_PER_LIST && i<(int)this->storeJson.at("storeContent").size();i++) {
|
||||
} else if (config->viewMode() == 1) {
|
||||
for(int i = 0; i < ENTRIES_PER_LIST && i < (int)this->storeJson.at("storeContent").size(); i++) {
|
||||
if (touch.py > (i+1)*27 && touch.py < (i+2)*27) {
|
||||
Selection = screenPosList + i;
|
||||
std::string info = this->storeJson["storeContent"][Selection]["info"]["title"];
|
||||
@@ -351,14 +353,14 @@ void UniStoreV1::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
}
|
||||
}
|
||||
|
||||
if (Config::viewMode == 0) {
|
||||
if(Selection < screenPos) {
|
||||
if (config->viewMode() == 0) {
|
||||
if (Selection < screenPos) {
|
||||
screenPos = Selection;
|
||||
} else if (Selection > screenPos + ENTRIES_PER_SCREEN - 1) {
|
||||
screenPos = Selection - ENTRIES_PER_SCREEN + 1;
|
||||
}
|
||||
} else if (Config::viewMode == 1) {
|
||||
if(Selection < screenPosList) {
|
||||
} else if (config->viewMode() == 1) {
|
||||
if (Selection < screenPosList) {
|
||||
screenPosList = Selection;
|
||||
} else if (Selection > screenPosList + ENTRIES_PER_LIST - 1) {
|
||||
screenPosList = Selection - ENTRIES_PER_LIST + 1;
|
||||
@@ -371,87 +373,87 @@ void UniStoreV1::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
// Execute Entry.
|
||||
Result UniStoreV1::execute() {
|
||||
Result ret = NONE; // No Error has been occured now.
|
||||
for(int i=0;i<(int)this->storeJson.at("storeContent").at(Selection).at("script").size();i++) {
|
||||
for(int i = 0; i < (int)this->storeJson.at("storeContent").at(Selection).at("script").size(); i++) {
|
||||
if (ret == NONE) {
|
||||
std::string type = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("type");
|
||||
if(type == "deleteFile") {
|
||||
if (type == "deleteFile") {
|
||||
bool missing = false;
|
||||
std::string file, message;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("file")) file = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("file");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("file")) file = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("file");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) message = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("message");
|
||||
if(!missing) ret = ScriptHelper::removeFile(file, message);
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) message = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("message");
|
||||
if (!missing) ret = ScriptHelper::removeFile(file, message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if(type == "downloadFile") {
|
||||
} else if (type == "downloadFile") {
|
||||
bool missing = false;
|
||||
std::string file, output, message;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("file")) file = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("file");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("file")) file = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("file");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("output")) output = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("output");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("output")) output = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("output");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) message = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("message");
|
||||
if(!missing) ret = ScriptHelper::downloadFile(file, output, message);
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) message = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("message");
|
||||
if (!missing) ret = ScriptHelper::downloadFile(file, output, message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if(type == "downloadRelease") {
|
||||
} else if (type == "downloadRelease") {
|
||||
bool missing = false, includePrereleases = false, showVersions = false;
|
||||
std::string repo, file, output, message;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("repo")) repo = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("repo");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("repo")) repo = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("repo");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("file")) file = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("file");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("file")) file = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("file");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("output")) output = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("output");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("output")) output = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("output");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("includePrereleases") && this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("includePrereleases").is_boolean())
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("includePrereleases") && this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("includePrereleases").is_boolean())
|
||||
includePrereleases = this->storeJson.at(Selection).at("script").at(i).at("includePrereleases");
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("showVersions") && this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("showVersions").is_boolean())
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("showVersions") && this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("showVersions").is_boolean())
|
||||
showVersions = this->storeJson.at(Selection).at("script").at(i).at("showVersions");
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) message = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("message");
|
||||
if(!missing) ret = ScriptHelper::downloadRelease(repo, file, output, includePrereleases, showVersions, message);
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) message = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("message");
|
||||
if (!missing) ret = ScriptHelper::downloadRelease(repo, file, output, includePrereleases, showVersions, message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if(type == "extractFile") {
|
||||
} else if (type == "extractFile") {
|
||||
bool missing = false;
|
||||
std::string file, input, output, message;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("file")) file = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("file");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("file")) file = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("file");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("input")) input = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("input");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("input")) input = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("input");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("output")) output = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("output");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("output")) output = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("output");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) message = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("message");
|
||||
if(!missing) ScriptHelper::extractFile(file, input, output, message);
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) message = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("message");
|
||||
if (!missing) ScriptHelper::extractFile(file, input, output, message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if(type == "installCia") {
|
||||
} else if (type == "installCia") {
|
||||
bool missing = false, updateSelf = false;
|
||||
std::string file, message;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("file")) file = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("file");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("file")) file = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("file");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("updateSelf") && this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("updateSelf").is_boolean()) {
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("updateSelf") && this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("updateSelf").is_boolean()) {
|
||||
updateSelf = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("updateSelf");
|
||||
}
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) message = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("message");
|
||||
if(!missing) ScriptHelper::installFile(file, updateSelf, message);
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) message = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("message");
|
||||
if (!missing) ScriptHelper::installFile(file, updateSelf, message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if (type == "mkdir") {
|
||||
bool missing = false;
|
||||
std::string directory, message;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("directory")) directory = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("directory");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("directory")) directory = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("directory");
|
||||
else missing = true;
|
||||
if(!missing) makeDirs(directory.c_str());
|
||||
if (!missing) makeDirs(directory.c_str());
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if (type == "rmdir") {
|
||||
bool missing = false;
|
||||
std::string directory, message, promptmsg;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("directory")) directory = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("directory");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("directory")) directory = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("directory");
|
||||
else missing = true;
|
||||
promptmsg = Lang::get("DELETE_PROMPT") + "\n" + directory;
|
||||
if(!missing) {
|
||||
if(access(directory.c_str(), F_OK) != 0 ) {
|
||||
if (!missing) {
|
||||
if (access(directory.c_str(), F_OK) != 0 ) {
|
||||
ret = DELETE_ERROR;
|
||||
} else {
|
||||
if (Msg::promptMsg(promptmsg)) {
|
||||
@@ -464,25 +466,25 @@ Result UniStoreV1::execute() {
|
||||
} else if (type == "mkfile") {
|
||||
bool missing = false;
|
||||
std::string file;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("file")) file = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("file");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("file")) file = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("file");
|
||||
else missing = true;
|
||||
if(!missing) ScriptHelper::createFile(file.c_str());
|
||||
if (!missing) ScriptHelper::createFile(file.c_str());
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if (type == "timeMsg") {
|
||||
bool missing = false;
|
||||
std::string message;
|
||||
int seconds;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) message = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("message");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) message = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("message");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("seconds") && this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("seconds").is_number())
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("seconds") && this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("seconds").is_number())
|
||||
seconds = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("seconds");
|
||||
else missing = true;
|
||||
if(!missing) ScriptHelper::displayTimeMsg(message, seconds);
|
||||
if (!missing) ScriptHelper::displayTimeMsg(message, seconds);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if (type == "saveConfig") {
|
||||
Config::save();
|
||||
config->save();
|
||||
|
||||
} else if (type == "notImplemented") {
|
||||
notImplemented();
|
||||
@@ -491,39 +493,39 @@ Result UniStoreV1::execute() {
|
||||
std::string TitleID = "";
|
||||
std::string message = "";
|
||||
bool isNAND = false, missing = false;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("TitleID")) TitleID = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("TitleID");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("TitleID")) TitleID = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("TitleID");
|
||||
else missing = true;
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("NAND") && this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("NAND").is_boolean()) isNAND = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("NAND");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) message = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("message");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) message = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("message");
|
||||
else missing = true;
|
||||
if(!missing) ScriptHelper::bootTitle(TitleID, isNAND, message);
|
||||
if (!missing) ScriptHelper::bootTitle(TitleID, isNAND, message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if (type == "promptMessage") {
|
||||
std::string Message = "";
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) Message = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("message");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) Message = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("message");
|
||||
ret = ScriptHelper::prompt(Message);
|
||||
|
||||
} else if (type == "copy") {
|
||||
std::string Message = "", source = "", destination = "";
|
||||
bool missing = false;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("source")) source = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("source");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("source")) source = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("source");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("destination")) destination = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("destination");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("destination")) destination = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("destination");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) Message = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("message");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) Message = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("message");
|
||||
if (!missing) ret = ScriptHelper::copyFile(source, destination, Message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if (type == "move") {
|
||||
std::string Message = "", oldFile = "", newFile = "";
|
||||
bool missing = false;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("old")) oldFile = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("old");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("old")) oldFile = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("old");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("new")) newFile = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("new");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("new")) newFile = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("new");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) Message = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("message");
|
||||
if (this->storeJson.at("storeContent").at(Selection).at("script").at(i).contains("message")) Message = this->storeJson.at("storeContent").at(Selection).at("script").at(i).at("message");
|
||||
if (!missing) ret = ScriptHelper::renameFile(oldFile, newFile, Message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
extern std::unique_ptr<Config> config;
|
||||
extern u32 getColor(std::string colorString);
|
||||
extern bool touching(touchPosition touch, Structs::ButtonPos button);
|
||||
#define STORE_ENTRIES 15
|
||||
@@ -92,7 +93,7 @@ void UniStoreV2::DrawBaseTop(void) const {
|
||||
Gui::Draw_Rect(0, 0, 400, 25, this->darkMode ? this->barColorDark : this->barColorLight);
|
||||
Gui::Draw_Rect(0, 25, 400, 190, this->darkMode ? this->bgColorDark : this->bgColorLight);
|
||||
Gui::Draw_Rect(0, 215, 400, 25, this->darkMode ? this->barColorDark : this->barColorLight);
|
||||
if (Config::UseBars == true) {
|
||||
if (config->useBars() == true) {
|
||||
GFX::DrawSprite(sprites_top_screen_top_idx, 0, 0);
|
||||
GFX::DrawSprite(sprites_top_screen_bot_idx, 0, 215);
|
||||
}
|
||||
@@ -103,7 +104,7 @@ void UniStoreV2::DrawBaseBottom(void) const {
|
||||
Gui::Draw_Rect(0, 0, 320, 25, this->darkMode ? this->barColorDark : this->barColorLight);
|
||||
Gui::Draw_Rect(0, 25, 320, 190, this->darkMode ? this->bgColorDark : this->bgColorLight);
|
||||
Gui::Draw_Rect(0, 215, 320, 25, this->darkMode ? this->barColorDark : this->barColorLight);
|
||||
if (Config::UseBars == true) {
|
||||
if (config->useBars() == true) {
|
||||
GFX::DrawSprite(sprites_top_screen_top_idx, 0, 0);
|
||||
GFX::DrawSprite(sprites_top_screen_bot_idx, 0, 215);
|
||||
}
|
||||
@@ -230,7 +231,7 @@ void UniStoreV2::parseObjects(int selection) {
|
||||
|
||||
void UniStoreV2::DrawSearchMenu(void) const {
|
||||
this->DrawBaseTop();
|
||||
if (Config::UseBars == true) {
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, this->returnTextColor(), Lang::get("SEARCH_MENU"), 400);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, this->returnTextColor(), Lang::get("SEARCH_MENU"), 400);
|
||||
@@ -279,13 +280,13 @@ void UniStoreV2::displaySelectedEntry(int selection) const {
|
||||
Gui::DrawStringCentered(0, 218, 0.7f, this->returnTextColor(), std::to_string(this->downloadPage + 1) + " | " + std::to_string(1 + (this->objects.size() / DOWNLOAD_ENTRIES)));
|
||||
|
||||
if (this->storeJson.at("storeContent").at(selection).at("info").contains("title")) {
|
||||
if (Config::UseBars == true) {
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, this->returnTextColor(), (std::string)this->storeJson.at("storeContent").at(selection).at("info").at("title"), 400);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, this->returnTextColor(), (std::string)this->storeJson.at("storeContent").at(selection).at("info").at("title"), 400);
|
||||
}
|
||||
} else {
|
||||
if (Config::UseBars == true) {
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.7f, this->returnTextColor(), "?", 400);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.7f, this->returnTextColor(), "?", 400);
|
||||
@@ -350,7 +351,7 @@ void UniStoreV2::Draw(void) const {
|
||||
if (this->mode == 0) {
|
||||
this->DrawBaseTop();
|
||||
|
||||
if (Config::UseBars == true) {
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.6f, this->returnTextColor(), (std::string)this->storeJson.at("storeInfo").at("title"), 400);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.6f, this->returnTextColor(), (std::string)this->storeJson.at("storeInfo").at("title"), 400);
|
||||
@@ -368,7 +369,7 @@ void UniStoreV2::Draw(void) const {
|
||||
} else if (this->mode == 1) {
|
||||
this->DrawBaseTop();
|
||||
|
||||
if (Config::UseBars == true) {
|
||||
if (config->useBars() == true) {
|
||||
Gui::DrawStringCentered(0, 0, 0.6f, this->returnTextColor(), (std::string)this->storeJson.at("storeInfo").at("title"), 400);
|
||||
} else {
|
||||
Gui::DrawStringCentered(0, 2, 0.6f, this->returnTextColor(), (std::string)this->storeJson.at("storeInfo").at("title"), 400);
|
||||
@@ -470,7 +471,7 @@ void UniStoreV2::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
if (this->mode == 0) {
|
||||
if (hDown & KEY_B) {
|
||||
if (!didAutoboot) didAutoboot = true;
|
||||
Gui::screenBack(Config::fading);
|
||||
Gui::screenBack(config->screenFade());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -554,7 +555,7 @@ void UniStoreV2::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
} else if (this->mode == 1) {
|
||||
if (hDown & KEY_B) {
|
||||
if (!didAutoboot) didAutoboot = true;
|
||||
Gui::screenBack(Config::fading);
|
||||
Gui::screenBack(config->screenFade());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -827,87 +828,87 @@ void UniStoreV2::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
// Execute | run the script.
|
||||
Result UniStoreV2::runFunctions(std::string entry) {
|
||||
Result ret = NONE; // No Error as of yet.
|
||||
for(int i=0;i<(int)this->storeJson.at("storeContent").at(this->selection).at(entry).size();i++) {
|
||||
for(int i = 0; i < (int)this->storeJson.at("storeContent").at(this->selection).at(entry).size(); i++) {
|
||||
if (ret == NONE) {
|
||||
std::string type = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("type");
|
||||
|
||||
if (type == "deleteFile") {
|
||||
bool missing = false;
|
||||
std::string file, message;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("file")) file = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("file");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("file")) file = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("file");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("message")) message = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("message");
|
||||
if(!missing) ret = ScriptHelper::removeFile(file, message);
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("message")) message = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("message");
|
||||
if (!missing) ret = ScriptHelper::removeFile(file, message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if(type == "downloadFile") {
|
||||
} else if (type == "downloadFile") {
|
||||
bool missing = false;
|
||||
std::string file, output, message;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("file")) file = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("file");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("file")) file = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("file");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("output")) output = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("output");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("output")) output = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("output");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("message")) message = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("message");
|
||||
if(!missing) ret = ScriptHelper::downloadFile(file, output, message);
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("message")) message = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("message");
|
||||
if (!missing) ret = ScriptHelper::downloadFile(file, output, message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if(type == "downloadRelease") {
|
||||
} else if (type == "downloadRelease") {
|
||||
bool missing = false, includePrereleases = false, showVersions = false;
|
||||
std::string repo, file, output, message;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("repo")) repo = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("repo");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("repo")) repo = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("repo");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("file")) file = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("file");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("file")) file = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("file");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("output")) output = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("output");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("output")) output = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("output");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("includePrereleases") && this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("includePrereleases").is_boolean())
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("includePrereleases") && this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("includePrereleases").is_boolean())
|
||||
includePrereleases = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("includePrereleases");
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("showVersions") && this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("showVersions").is_boolean())
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("showVersions") && this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("showVersions").is_boolean())
|
||||
showVersions = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("showVersions");
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("message")) message = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("message");
|
||||
if(!missing) ret = ScriptHelper::downloadRelease(repo, file, output, includePrereleases, showVersions, message);
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("message")) message = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("message");
|
||||
if (!missing) ret = ScriptHelper::downloadRelease(repo, file, output, includePrereleases, showVersions, message);
|
||||
|
||||
} else if(type == "extractFile") {
|
||||
} else if (type == "extractFile") {
|
||||
bool missing = false;
|
||||
std::string file, input, output, message;
|
||||
if(this->storeJson.at("storeContent").at("storeContent").at(this->selection).at(entry).at(i).contains("file")) file = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("file");
|
||||
if (this->storeJson.at("storeContent").at("storeContent").at(this->selection).at(entry).at(i).contains("file")) file = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("file");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("input")) input = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("input");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("input")) input = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("input");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("output")) output = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("output");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("output")) output = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("output");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("message")) message = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("message");
|
||||
if(!missing) ScriptHelper::extractFile(file, input, output, message);
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("message")) message = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("message");
|
||||
if (!missing) ScriptHelper::extractFile(file, input, output, message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if(type == "installCia") {
|
||||
} else if (type == "installCia") {
|
||||
bool missing = false, updateSelf = false;
|
||||
std::string file, message;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("file")) file = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("file");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("file")) file = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("file");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("updateSelf") && this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("updateSelf").is_boolean()) {
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("updateSelf") && this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("updateSelf").is_boolean()) {
|
||||
updateSelf = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("updateSelf");
|
||||
}
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("message")) message = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("message");
|
||||
if(!missing) ScriptHelper::installFile(file, updateSelf, message);
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("message")) message = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("message");
|
||||
if (!missing) ScriptHelper::installFile(file, updateSelf, message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if (type == "mkdir") {
|
||||
bool missing = false;
|
||||
std::string directory, message;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("directory")) directory = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("directory");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("directory")) directory = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("directory");
|
||||
else missing = true;
|
||||
if(!missing) makeDirs(directory.c_str());
|
||||
if (!missing) makeDirs(directory.c_str());
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if (type == "rmdir") {
|
||||
bool missing = false;
|
||||
std::string directory, message, promptmsg;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("directory")) directory = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("directory");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("directory")) directory = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("directory");
|
||||
else missing = true;
|
||||
promptmsg = Lang::get("DELETE_PROMPT") + "\n" + directory;
|
||||
if(!missing) {
|
||||
if(access(directory.c_str(), F_OK) != 0 ) {
|
||||
if (!missing) {
|
||||
if (access(directory.c_str(), F_OK) != 0 ) {
|
||||
ret = DELETE_ERROR;
|
||||
} else {
|
||||
if (Msg::promptMsg(promptmsg)) {
|
||||
@@ -920,63 +921,63 @@ Result UniStoreV2::runFunctions(std::string entry) {
|
||||
} else if (type == "mkfile") {
|
||||
bool missing = false;
|
||||
std::string file;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("file")) file = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("file");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("file")) file = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("file");
|
||||
else missing = true;
|
||||
if(!missing) ScriptHelper::createFile(file.c_str());
|
||||
if (!missing) ScriptHelper::createFile(file.c_str());
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if (type == "timeMsg") {
|
||||
bool missing = false;
|
||||
std::string message;
|
||||
int seconds;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("message")) message = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("message");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("message")) message = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("message");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("seconds") && this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("seconds").is_number())
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("seconds") && this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("seconds").is_number())
|
||||
seconds = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("seconds");
|
||||
else missing = true;
|
||||
if(!missing) ScriptHelper::displayTimeMsg(message, seconds);
|
||||
if (!missing) ScriptHelper::displayTimeMsg(message, seconds);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if (type == "saveConfig") {
|
||||
Config::save();
|
||||
config->save();
|
||||
|
||||
} else if (type == "bootTitle") {
|
||||
std::string TitleID = "";
|
||||
std::string message = "";
|
||||
bool isNAND = false, missing = false;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("TitleID")) TitleID = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("TitleID");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("TitleID")) TitleID = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("TitleID");
|
||||
else missing = true;
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("NAND") && this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("NAND").is_boolean()) isNAND = this->storeJson.at(this->selection).at(entry).at(i).at("NAND");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("message")) message = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("message");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("message")) message = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("message");
|
||||
else missing = true;
|
||||
if(!missing) ScriptHelper::bootTitle(TitleID, isNAND, message);
|
||||
if (!missing) ScriptHelper::bootTitle(TitleID, isNAND, message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if (type == "promptMessage") {
|
||||
std::string Message = "";
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("message")) Message = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("message");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("message")) Message = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("message");
|
||||
ret = ScriptHelper::prompt(Message);
|
||||
|
||||
} else if (type == "copy") {
|
||||
std::string Message = "", source = "", destination = "";
|
||||
bool missing = false;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("source")) source = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("source");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("source")) source = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("source");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("destination")) destination = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("destination");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("destination")) destination = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("destination");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("message")) Message = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("message");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("message")) Message = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("message");
|
||||
if (!missing) ret = ScriptHelper::copyFile(source, destination, Message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
|
||||
} else if (type == "move") {
|
||||
std::string Message = "", oldFile = "", newFile = "";
|
||||
bool missing = false;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("old")) oldFile = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("old");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("old")) oldFile = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("old");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("new")) newFile = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("new");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("new")) newFile = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("new");
|
||||
else missing = true;
|
||||
if(this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("message")) Message = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("message");
|
||||
if (this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).contains("message")) Message = this->storeJson.at("storeContent").at(this->selection).at(entry).at(i).at("message");
|
||||
if (!missing) ret = ScriptHelper::renameFile(oldFile, newFile, Message);
|
||||
else ret = SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user