From 3a8e3a10bc39326bccb9ecf509d359c7a505a02a Mon Sep 17 00:00:00 2001 From: i3sey <86531179+i3sey@users.noreply.github.com> Date: Fri, 6 Sep 2024 16:27:35 +0500 Subject: [PATCH] added scrolling to text_source --- source/main.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/source/main.cpp b/source/main.cpp index 99d58c75..936bf251 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -200,6 +200,8 @@ class SelectionOverlay : public tsl::Gui { bool toggleState = false; bool searchCurrent; tsl::elm::ListItem* savedItem = nullptr; + tsl::elm::List* p_list; + bool useText = false; public: SelectionOverlay(const std::string& file, const std::string& key = "", const std::vector>& cmds = {}, std::string footer = "") @@ -240,7 +242,6 @@ class SelectionOverlay : public tsl::Gui { bool useFilter = false; bool useSource = false; bool useJson = false; - bool useText = false; bool useToggle = false; bool useSplitHeader = false; bool markCurKip = false; @@ -309,7 +310,7 @@ class SelectionOverlay : public tsl::Gui { } } else if (cmd[0] == "text_source") { textPath = preprocessPath(cmd[1]); - useText = true; + this->useText = true; } } } @@ -317,7 +318,8 @@ class SelectionOverlay : public tsl::Gui { // Get the list of files matching the pattern if (!useToggle) { - if (useText) { + if (this->useText) { + p_list = list; if (!isFileOrDirectory(textPath)) { list->addItem(new tsl::elm::CustomDrawer([lineHeight, fontSize](tsl::gfx::Renderer* renderer, s32 x, s32 y, s32 w, s32 h) { renderer->drawString("Text file not found.\nContact the package dev.", false, x, y + lineHeight, fontSize, a(tsl::style::color::ColorText)); @@ -755,6 +757,17 @@ class SelectionOverlay : public tsl::Gui { scrollListItems(this, ShiftFocusMode::DownMax); return true; } + if (this->useText) { + // process right stick scrolling + if ((keysHeld | keysDown) & (HidNpadButton_StickRDown)) { + this->p_list->handleInput(HidNpadButton_StickRDown, 0,{},{},{}); + return true; + } + if ((keysHeld | keysDown) & (HidNpadButton_StickRUp)) { + this->p_list->handleInput(HidNpadButton_StickRUp, 0,{},{},{}); + return true; + } + } if (keysDown & KEY_B) { if (!Mtrun) { tsl::goBack();