From 1933017e60147a33e5107d50bebc074970d7ab72 Mon Sep 17 00:00:00 2001 From: VoltZ <47382115+SuperSaiyajinVoltZ@users.noreply.github.com> Date: Sun, 10 Nov 2019 13:12:38 +0100 Subject: [PATCH] Add a new mode for the Scriptlist. :P --- include/screens/scriptlist.hpp | 3 + source/screens/scriptlist.cpp | 109 +++++++++++++++++++++++++-------- 2 files changed, 87 insertions(+), 25 deletions(-) diff --git a/include/screens/scriptlist.hpp b/include/screens/scriptlist.hpp index 395fa34..03573e1 100644 --- a/include/screens/scriptlist.hpp +++ b/include/screens/scriptlist.hpp @@ -46,10 +46,13 @@ private: void SelectFunction(u32 hDown, u32 hHeld); int mode = 0; + int listMode = 0; std::vector dirContents; mutable int screenPos = 0; + mutable int screenPosList = 0; mutable int selection = 0; mutable int screenPos2 = 0; + mutable int screenPosList2 = 0; mutable int selection2 = 0; int keyRepeatDelay = 0; diff --git a/source/screens/scriptlist.cpp b/source/screens/scriptlist.cpp index ae01aa2..937a47e 100644 --- a/source/screens/scriptlist.cpp +++ b/source/screens/scriptlist.cpp @@ -37,6 +37,7 @@ #include #define ENTRIES_PER_SCREEN 3 +#define ENTRIES_PER_LIST 7 bool isScriptSelected = false; @@ -44,6 +45,7 @@ bool isScriptSelected = false; struct Info { std::string title; std::string author; + std::string shortDesc; }; std::string choice; @@ -84,6 +86,7 @@ Info parseInfo(std::string fileName) { Info info; info.title = get(json, "info", "title"); info.author = get(json, "info", "author"); + info.shortDesc = get(json, "info", "shortDesc"); return info; } @@ -298,23 +301,41 @@ ScriptList::ScriptList() { void ScriptList::DrawList(void) const { std::string line1; std::string line2; + std::string scriptAmount = std::to_string(selection +1) + " / " + std::to_string(fileInfo.size()); Gui::DrawTop(); 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, 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::DrawBottom(); - for(int i=0;i screenPos + ENTRIES_PER_SCREEN - 1) { - screenPos = selection - ENTRIES_PER_SCREEN + 1; + if (listMode == 0) { + if(selection < screenPos) { + screenPos = selection; + } else if (selection > screenPos + ENTRIES_PER_SCREEN - 1) { + screenPos = selection - ENTRIES_PER_SCREEN + 1; + } + } else if (listMode == 1) { + if(selection < screenPosList) { + screenPosList = selection; + } else if (selection > screenPosList + ENTRIES_PER_LIST - 1) { + screenPosList = selection - ENTRIES_PER_LIST + 1; + } } } @@ -475,10 +518,18 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld) { mode = 0; } - if(selection2 < screenPos2) { - screenPos2 = selection2; - } else if (selection2 > screenPos2 + ENTRIES_PER_SCREEN - 1) { - screenPos2 = selection2 - ENTRIES_PER_SCREEN + 1; + if (listMode == 0) { + if(selection2 < screenPos2) { + screenPos2 = selection2; + } else if (selection2 > screenPos2 + ENTRIES_PER_SCREEN - 1) { + screenPos2 = selection2 - ENTRIES_PER_SCREEN + 1; + } + } else if (listMode == 1) { + if(selection2 < screenPosList2) { + screenPosList2 = selection2; + } else if (selection2 > screenPosList2 + ENTRIES_PER_LIST - 1) { + screenPosList2 = selection2 - ENTRIES_PER_LIST + 1; + } } } @@ -489,4 +540,12 @@ void ScriptList::Logic(u32 hDown, u32 hHeld, touchPosition touch) { } else if (mode == 1) { SelectFunction(hDown, hHeld); } + + if (hDown & KEY_X) { + if (listMode == 0) { + listMode = 1; + } else { + listMode = 0; + } + } } \ No newline at end of file