From 6c3b5fc31a1673831e0e383310e1b851a8bc8043 Mon Sep 17 00:00:00 2001 From: StackZ <47382115+SuperSaiyajinStackZ@users.noreply.github.com> Date: Wed, 1 Jan 2020 03:45:14 +0100 Subject: [PATCH] WIP Credits Screen Rewrite. --- include/screens/settings.hpp | 12 ++--- source/screens/scriptCreator.cpp | 43 ++++++----------- source/screens/settings.cpp | 82 ++++++++++++++++---------------- 3 files changed, 58 insertions(+), 79 deletions(-) diff --git a/include/screens/settings.hpp b/include/screens/settings.hpp index fcff5c7..30d4911 100644 --- a/include/screens/settings.hpp +++ b/include/screens/settings.hpp @@ -42,20 +42,18 @@ public: void Logic(u32 hDown, u32 hHeld, touchPosition touch) override; Settings(); private: - // Credits stuff. - int DisplayMode = 1; - int delay = 120; - bool discordText = false; - int colorMode = 0; int mode = 0; int Selection = 0; + int creditsPage = 1; + // Draws. void DrawSubMenu(void) const; void DrawLanguageSelection(void) const; void DrawColorChanging(void) const; void DrawCreditsScreen(void) const; void DrawMiscSettings(void) const; + // Logic's. void SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch); void LanguageSelection(u32 hDown, touchPosition touch); void colorChanging(u32 hDown, touchPosition touch); @@ -87,10 +85,6 @@ private: {220, 85, 95, 41, -1}, }; - std::vector barPos = { - {0, 215, 320, 25, -1}, - }; - std::vector arrowPos = { {0, 0, 25, 25, -1}, // Previous Arrow. {295, 0, 25, 25, -1}, // Next Arrow. diff --git a/source/screens/scriptCreator.cpp b/source/screens/scriptCreator.cpp index faae4b4..43e641b 100644 --- a/source/screens/scriptCreator.cpp +++ b/source/screens/scriptCreator.cpp @@ -37,6 +37,7 @@ // 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; @@ -103,9 +104,9 @@ void ScriptCreator::DrawSubMenu(void) const { void ScriptCreator::DrawScriptScreen(void) const { Gui::DrawTop(); if (Config::UseBars == true) { - Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, Lang::get("SCRIPTCREATOR"), 400); + Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, "Selected Entry: " + entryName, 400); } else { - Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("SCRIPTCREATOR"), 400); + Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, "Selected Entry: " + entryName, 400); } Gui::DrawBottom(); @@ -155,8 +156,6 @@ void ScriptCreator::createNewJson(std::string fileName) { // Test. void ScriptCreator::createDownloadRelease() { - // Entry name. - std::string entryname = Input::getString(50, "Enter the name of the Entry."); // Repo. std::string repo = Input::getString(50, "Enter the name of the Owner."); repo += "/"; @@ -170,15 +169,13 @@ void ScriptCreator::createDownloadRelease() { // Message. std::string message = Input::getString(50, "Enter the Message."); - editScript[entryname] = { {{"type", "downloadRelease"}, {"repo", repo}, {"file", file}, {"output", output}, {"includePrerelease", prerelease}, {"message", message}} }; + editScript[entryName] = { {{"type", "downloadRelease"}, {"repo", repo}, {"file", file}, {"output", output}, {"includePrerelease", prerelease}, {"message", message}} }; Logging::writeToLog("Execute 'ScriptCreator::createDownloadRelease();'."); } // To-Do. void ScriptCreator::createDownloadFile() { - // Entry name. - std::string entryname = Input::getString(50, "Enter the name of the Entry."); // URL of the file. std::string file = Input::getString(50, "Enter the URL of the file."); // Output. @@ -186,27 +183,23 @@ void ScriptCreator::createDownloadFile() { // Message. std::string message = Input::getString(50, "Enter the Message."); - editScript[entryname] = { {{"type", "downloadFile"}, {"file", file}, {"output", output}, {"message", message}} }; + editScript[entryName] = { {{"type", "downloadFile"}, {"file", file}, {"output", output}, {"message", message}} }; Logging::writeToLog("Execute 'ScriptCreator::createDownloadFile();'."); } void ScriptCreator::createDeleteFile() { - // Entry name. - std::string entryname = Input::getString(50, "Enter the name of the Entry."); // URL of the file. std::string file = Input::getString(50, "Enter the path to the file."); // Message. std::string message = Input::getString(50, "Enter the Message."); - editScript[entryname] = { {{"type", "deleteFile"}, {"file", file}, {"message", message}} }; + editScript[entryName] = { {{"type", "deleteFile"}, {"file", file}, {"message", message}} }; Logging::writeToLog("Execute 'ScriptCreator::createDeleteFile();'."); } void ScriptCreator::createExtractFile() { - // Entry name. - std::string entryname = Input::getString(50, "Enter the name of the Entry."); // File path. std::string file = Input::getString(50, "Enter the path to the file."); // Input of the archive. @@ -216,63 +209,53 @@ void ScriptCreator::createExtractFile() { // Message. std::string message = Input::getString(50, "Enter the Message."); - editScript[entryname] = { {{"type", "extractFile"}, {"file", file}, {"input", input}, {"output", output}, {"message", message}} }; + editScript[entryName] = { {{"type", "extractFile"}, {"file", file}, {"input", input}, {"output", output}, {"message", message}} }; Logging::writeToLog("Execute 'ScriptCreator::createExtractFile();'."); } void ScriptCreator::createInstallCia() { - // Entry name. - std::string entryname = Input::getString(50, "Enter the name of the Entry."); // File path. std::string file = Input::getString(50, "Enter the path to the CIA File."); // Message. std::string message = Input::getString(50, "Enter the Message."); - editScript[entryname] = { {{"type", "installCia"}, {"file", file}, {"message", message}} }; + editScript[entryName] = { {{"type", "installCia"}, {"file", file}, {"message", message}} }; Logging::writeToLog("Execute 'ScriptCreator::createInstallCia();'."); } void ScriptCreator::createMkDir() { - // Entry name. - std::string entryname = Input::getString(50, "Enter the name of the Entry."); // Directory path. std::string directory = Input::getString(50, "Enter the directory path."); - editScript[entryname] = { {{"type", "mkdir"}, {"directory", directory}} }; + editScript[entryName] = { {{"type", "mkdir"}, {"directory", directory}} }; Logging::writeToLog("Execute 'ScriptCreator::createMkDir();'."); } void ScriptCreator::createRmDir() { - // Entry name. - std::string entryname = Input::getString(50, "Enter the name of the Entry."); // Directory path. std::string directory = Input::getString(50, "Enter the directory path."); - editScript[entryname] = { {{"type", "rmdir"}, {"directory", directory}} }; + editScript[entryName] = { {{"type", "rmdir"}, {"directory", directory}} }; Logging::writeToLog("Execute 'ScriptCreator::createRmDir();'."); } void ScriptCreator::createMkFile() { - // Entry name. - std::string entryname = Input::getString(50, "Enter the name of the Entry."); // File path. std::string file = Input::getString(50, "Enter the path to the new File."); - editScript[entryname] = { {{"type", "mkfile"}, {"file", file}} }; + editScript[entryName] = { {{"type", "mkfile"}, {"file", file}} }; Logging::writeToLog("Execute 'ScriptCreator::createMkFile();'."); } void ScriptCreator::createTimeMsg() { - // Entry name. - std::string entryname = Input::getString(50, "Enter the name of the Entry."); // Message. std::string message = Input::getString(50, "Enter the Message."); // Seconds. int seconds = Input::getUint(999, "Enter the Seconds for the Message to display."); - editScript[entryname] = { {{"type", "timeMsg"}, {"message", message}, {"seconds", seconds}} }; + editScript[entryName] = { {{"type", "timeMsg"}, {"message", message}, {"seconds", seconds}} }; Logging::writeToLog("Execute 'ScriptCreator::createTimeMsg();'."); } @@ -317,6 +300,7 @@ void ScriptCreator::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) { jsonFileName += ".json"; createNewJson(jsonFileName); openJson(jsonFileName); + entryName = Input::getString(50, "Enter the EntryName."); Selection = 0; mode = 1; } @@ -327,6 +311,7 @@ void ScriptCreator::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) { jsonFileName = tempScript; if(access(jsonFileName.c_str(), F_OK) != -1 ) { openJson(jsonFileName); + entryName = Input::getString(50, "Enter the EntryName."); Selection = 0; mode = 1; } diff --git a/source/screens/settings.cpp b/source/screens/settings.cpp index 2000f4c..684d1cb 100644 --- a/source/screens/settings.cpp +++ b/source/screens/settings.cpp @@ -190,11 +190,10 @@ void Settings::DrawColorChanging(void) const { } void Settings::DrawCreditsScreen(void) const { - if (DisplayMode == 1) { - Gui::DrawTop(); - std::string title = "Universal-Updater - "; - title += Lang::get("CREDITS"); - + std::string title = "Universal-Updater - "; + title += Lang::get("CREDITS"); + Gui::DrawTop(); + if (creditsPage != 4) { if (Config::UseBars == true) { Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, title, 400); } else { @@ -206,22 +205,37 @@ void Settings::DrawCreditsScreen(void) const { 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::DrawBottom(); - Gui::DrawArrow(0, 0, 0, 1); - Gui::DrawStringCentered(0, -2, 0.7f, Config::TxtColor, Lang::get("MANY_THANKS"), 320); - Gui::DrawStringCentered(0, 40, 0.7f, Config::TxtColor, Lang::get("TRANSLATORS"), 320); - Gui::DrawStringCentered(0, 70, 0.5f, Config::TxtColor, Lang::get("HELP_TRANSLATE"), 320); - Gui::DrawStringCentered(0, 100, 0.7f, Config::TxtColor, "Pk11", 320); - Gui::DrawStringCentered(0, 130, 0.5f, Config::TxtColor, Lang::get("HELP_OUT"), 320); - Gui::DrawStringCentered(0, 160, 0.7f, Config::TxtColor, Lang::get("SCRIPTCREATORS"), 320); - Gui::DrawStringCentered(0, 190, 0.5f, Config::TxtColor, Lang::get("CREATING_SCRIPTS"), 320); - Gui::DrawString((320-Gui::GetStringWidth(0.55, discordText ? Lang::get("SHOW_QR") : Lang::get("LINK")))/2, 220, 0.55, Config::TxtColor, discordText ? Lang::get("SHOW_QR") : Lang::get("LINK"), 320); - } else if (DisplayMode == 2) { - Gui::DrawTop(); + } else { Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(0, 0, 0, 190)); Gui::sprite(sprites_discord_idx, 115, 35); - Gui::DrawBottom(); + } + + Gui::DrawBottom(); + + if (creditsPage != 4) { + Gui::DrawArrow(0, 218, 0, 1); + Gui::DrawArrow(318, 240, 180.0, 1); + } + + if (creditsPage == 1) { + Gui::DrawStringCentered(0, -2, 0.7f, Config::TxtColor, Lang::get("TRANSLATORS"), 320); + Gui::DrawString(5, 30, 0.6f, Config::TxtColor, "- _mapple²\n- antoine62\n- Chips\n- David Pires\n- Flame\n- lemonnade0\n- Pk11\n- Roby Spia\n- StackZ\n- YoSoy"); + Gui::DrawString(180, 30, 0.6f, Config::TxtColor, "Русский\nFrançais\nPortuguês\nPortuguês\nBruh\nLietuvių\n日本語\nItaliano\nDeutsch, English\nEspañol"); + } else if (creditsPage == 2) { + Gui::DrawStringCentered(0, -2, 0.7f, Config::TxtColor, "Universal-Team", 320); + Gui::DrawStringCentered(-65, 35, 0.7f, Config::TxtColor, "DeadPhoenix"); + Gui::DrawStringCentered(-40, 65, 0.7f, Config::TxtColor, "Flame"); + Gui::DrawStringCentered(-38, 95, 0.7f, Config::TxtColor, "Pk11"); + Gui::DrawStringCentered(-60, 125, 0.7f, Config::TxtColor, "RocketRobz"); + Gui::DrawStringCentered(-42, 155, 0.7f, Config::TxtColor, "StackZ"); + Gui::DrawStringCentered(-65, 185, 0.7f, Config::TxtColor, "TotallyNotGuy"); + } else if (creditsPage == 3) { + Gui::DrawStringCentered(0, -2, 0.7f, Config::TxtColor, Lang::get("SCRIPTCREATORS"), 320); + Gui::DrawString(5, 27, 0.55f, Config::TxtColor, "- DualBladedKirito\n\n- Glazed_Belmont\n\n- Pk11\n\n- StackZ\n\n- The Conceptionist\n\n- YoSoy"); + Gui::DrawString(180, 27, 0.55f, Config::TxtColor, "1\n\n1\n\n1\n\n5\n\n10\n\n1/2"); + } else if (creditsPage == 4) { Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(0, 0, 0, 190)); + Gui::DrawStringCentered(0, -2, 0.55f, Config::TxtColor, Lang::get("LINK"), 320); Gui::DrawArrow(0, 218, 0, 1); } } @@ -466,30 +480,16 @@ void Settings::colorChanging(u32 hDown, touchPosition touch) { } void Settings::CreditsLogic(u32 hDown, touchPosition touch) { - gspWaitForVBlank(); - if(delay > 0) { - delay--; - } else { - delay = 120; - discordText = !discordText; + if ((hDown & KEY_LEFT || hDown & KEY_L) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) { + if (creditsPage == 1) mode = 0; + else if (creditsPage > 1) creditsPage--; + + } else if ((hDown & KEY_R || hDown & KEY_RIGHT) || (hDown & KEY_TOUCH && touching(touch, arrowPos[4]))) { + if (creditsPage < 4) creditsPage++; } - if (DisplayMode == 1) { - if (hDown & KEY_TOUCH) { - if (touching(touch, barPos[0])) { - DisplayMode = 2; - } else if (touching(touch, arrowPos[3])) { - mode = 0; - } - } - if (hDown & KEY_B) { - mode = 0; - } - } else if (DisplayMode == 2) { - if (hDown & KEY_B) { - DisplayMode = 1; - } else if (hDown & KEY_TOUCH && touching(touch, arrowPos[2])) { - DisplayMode = 1; - } + + if (hDown & KEY_B) { + mode = 0; } }