From da49c38c9fb84ef2a6db0e519b030a82252ca6ea Mon Sep 17 00:00:00 2001 From: VoltZ <47382115+SuperSaiyajinVoltZ@users.noreply.github.com> Date: Fri, 1 Nov 2019 20:50:00 +0100 Subject: [PATCH] Add Scrolling. --- include/gui.hpp | 2 ++ include/screens/scriptlist.hpp | 4 ++- source/screens/scriptlist.cpp | 45 ++++++++++++++++++++++++++++++++-- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/include/gui.hpp b/include/gui.hpp index 7ef2dd7..920a61a 100644 --- a/include/gui.hpp +++ b/include/gui.hpp @@ -41,6 +41,8 @@ #define BarColor C2D_Color32(57, 84, 114, 255) #define TopBGColor C2D_Color32(96, 168, 192, 255) #define BottomBGColor C2D_Color32(38, 44, 77, 255) +#define SelectedColor C2D_Color32(120, 192, 216, 255) +#define UnselectedColor C2D_Color32(77, 118, 132, 255) #define BLACK C2D_Color32(0, 0, 0, 255) #define WHITE C2D_Color32(255, 255, 255, 255) #define TextColor C2D_Color32(102, 179, 255, 255) diff --git a/include/screens/scriptlist.hpp b/include/screens/scriptlist.hpp index 2685949..12f1cab 100644 --- a/include/screens/scriptlist.hpp +++ b/include/screens/scriptlist.hpp @@ -37,10 +37,12 @@ public: void Draw(void) const override; void Logic(u32 hDown, u32 hHeld, touchPosition touch) override; ScriptList(); + void showParsedObjects(void) const; private: std::vector dirContents; - uint selectedFile = 0; + mutable int screenPos = 0; + mutable int selection = 0; int keyRepeatDelay = 0; int fastMode = false; bool dirChanged = true; diff --git a/source/screens/scriptlist.cpp b/source/screens/scriptlist.cpp index 33aff38..adfeeea 100644 --- a/source/screens/scriptlist.cpp +++ b/source/screens/scriptlist.cpp @@ -58,6 +58,7 @@ Info parseInfo(std::string fileName) { return info; } + std::vector fileInfo; ScriptList::ScriptList() { @@ -69,21 +70,61 @@ ScriptList::ScriptList() { } } + void ScriptList::Draw(void) const { std::string titleinfo; Gui::DrawTop(); Gui::DrawStringCentered(0, 2, 0.7f, TextColor, "Universal-Updater", 400); Gui::DrawBottom(); for(int i=0;i 0) { + selection--; + } else { + selection = (int)fileInfo.size()-1; + } + if (fastMode == true) { + keyRepeatDelay = 3; + } else if (fastMode == false){ + keyRepeatDelay = 6; + } + } + + if(selection < screenPos) { + screenPos = selection; + } else if (selection > screenPos + ENTRIES_PER_SCREEN - 1) { + screenPos = selection - ENTRIES_PER_SCREEN + 1; + } } \ No newline at end of file