Skip to content

Commit

Permalink
added scrolling to text_source
Browse files Browse the repository at this point in the history
  • Loading branch information
i3sey authored and IrneRacoonovich committed Sep 6, 2024
1 parent b9bff43 commit 3a8e3a1
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::vector<std::string>>& cmds = {}, std::string footer = "")
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -309,15 +310,16 @@ class SelectionOverlay : public tsl::Gui {
}
} else if (cmd[0] == "text_source") {
textPath = preprocessPath(cmd[1]);
useText = true;
this->useText = true;
}
}
}

// 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));
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 3a8e3a1

Please sign in to comment.