diff --git a/assets/gfx/sprites.t3s b/assets/gfx/sprites.t3s index 55e714e..152579a 100644 --- a/assets/gfx/sprites.t3s +++ b/assets/gfx/sprites.t3s @@ -1,5 +1,6 @@ --atlas -f rgba -z auto +sprites/arrow.png sprites/bottom_screen_bot.png sprites/bottom_screen_top.png sprites/top_screen_bot.png diff --git a/assets/gfx/sprites/arrow.png b/assets/gfx/sprites/arrow.png new file mode 100644 index 0000000..e7bbf05 Binary files /dev/null and b/assets/gfx/sprites/arrow.png differ diff --git a/include/gui.hpp b/include/gui.hpp index 804e9c1..21f25cc 100644 --- a/include/gui.hpp +++ b/include/gui.hpp @@ -46,6 +46,8 @@ namespace Gui // Draw a Sprite from the sheet. void sprite(int key, int x, int y, float ScaleX = 1, float ScaleY = 1); + + void DrawArrow(int x, int y, float rotation = 0); // Misc. bool Draw_Rect(float x, float y, float w, float h, u32 color); diff --git a/include/screens/scriptBrowse.hpp b/include/screens/scriptBrowse.hpp index 7206282..0f8385f 100644 --- a/include/screens/scriptBrowse.hpp +++ b/include/screens/scriptBrowse.hpp @@ -32,6 +32,7 @@ #include "utils/config.hpp" #include "utils/fileBrowse.h" +#include "utils/structs.hpp" class ScriptBrowse : public screen { @@ -47,6 +48,10 @@ private: mutable int selection = 0; int keyRepeatDelay = 0; int fastMode = false; + std::vector arrowPos = { + {295, 0, 25, 25, -1}, // Arrow Up. + {295, 215, 25, 25, -1}, // Arrow Down. + }; }; #endif \ No newline at end of file diff --git a/include/screens/scriptlist.hpp b/include/screens/scriptlist.hpp index 4914444..ea01aa2 100644 --- a/include/screens/scriptlist.hpp +++ b/include/screens/scriptlist.hpp @@ -31,6 +31,7 @@ #include "screens/screenCommon.hpp" #include "utils/fileBrowse.h" +#include "utils/structs.hpp" class ScriptList : public screen { @@ -43,8 +44,8 @@ private: void DrawList(void) const; void DrawSingleObject(void) const; - void ListSelection(u32 hDown, u32 hHeld); - void SelectFunction(u32 hDown, u32 hHeld); + void ListSelection(u32 hDown, u32 hHeld, touchPosition touch); + void SelectFunction(u32 hDown, u32 hHeld, touchPosition touch); int mode = 0; std::vector dirContents; @@ -57,6 +58,11 @@ private: int keyRepeatDelay = 0; int fastMode = false; + + std::vector arrowPos = { + {295, 0, 25, 25, -1}, // Arrow Up. + {295, 215, 25, 25, -1}, // Arrow Down. + }; }; #endif \ No newline at end of file diff --git a/include/screens/tinyDB.hpp b/include/screens/tinyDB.hpp index d79660a..26e01b7 100644 --- a/include/screens/tinyDB.hpp +++ b/include/screens/tinyDB.hpp @@ -30,6 +30,8 @@ #include "screens/screen.hpp" #include "screens/screenCommon.hpp" +#include "utils/structs.hpp" + class TinyDB : public screen { public: @@ -44,6 +46,10 @@ private: mutable int screenPosList = 0; int keyRepeatDelay = 0; int fastMode = false; + std::vector arrowPos = { + {295, 0, 25, 25, -1}, // Arrow Up. + {295, 215, 25, 25, -1}, // Arrow Down. + }; }; #endif \ No newline at end of file diff --git a/source/gui.cpp b/source/gui.cpp index 4d8af4e..8bd1a34 100644 --- a/source/gui.cpp +++ b/source/gui.cpp @@ -91,6 +91,15 @@ void Gui::sprite(int key, int x, int y, float ScaleX, float ScaleY) C2D_DrawImageAt(C2D_SpriteSheetGetImage(sprites, key), x, y, 0.5f, NULL, ScaleX, ScaleY); } +void Gui::DrawArrow(int x, int y, float rotation) { + C2D_Sprite sprite; + C2D_SpriteFromSheet(&sprite, sprites, sprites_arrow_idx); + C2D_SpriteRotateDegrees(&sprite, rotation); + C2D_SpriteSetPos(&sprite, x, y); + C2D_SpriteSetDepth(&sprite, 0.5); + C2D_DrawSprite(&sprite); +} + void Gui::DisplayWarnMsg(std::string Text) { Gui::clearTextBufs(); diff --git a/source/screens/scriptBrowse.cpp b/source/screens/scriptBrowse.cpp index 94b120d..62dea8f 100644 --- a/source/screens/scriptBrowse.cpp +++ b/source/screens/scriptBrowse.cpp @@ -33,6 +33,7 @@ #include +extern bool touching(touchPosition touch, Structs::ButtonPos button); #define ENTRIES_PER_SCREEN 3 #define ENTRIES_PER_LIST 7 @@ -126,9 +127,11 @@ void ScriptBrowse::Draw(void) const { Gui::DrawStringCentered(0, 217, 0.7f, Config::TxtColor, Lang::get("FUTURE_SCRIPT"), 400); } Gui::DrawBottom(); + Gui::DrawArrow(295, 0); + Gui::DrawArrow(315, 240, 180.0); Gui::sprite(sprites_search_idx, -3, 0); Gui::DrawString(7.5, 1.5, 0.72f, BLACK, "\uE003"); - Gui::DrawString(317-Gui::GetStringWidth(0.6f, std::to_string(selection + 1) + " / " + maxScripts), 3, 0.6f, Config::TxtColor, std::to_string(selection + 1) + " / " + maxScripts); + Gui::DrawStringCentered(-23, 3, 0.6f, Config::TxtColor, std::to_string(selection + 1) + " / " + maxScripts); if (Config::viewMode == 0) { for(int i=0;i 0) { + selection--; + } else { + selection = (int)infoJson.size()-1; + } + } + + if (hDown & KEY_TOUCH && touching(touch, arrowPos[1])) { + if (selection < (int)infoJson.size()-1) { + selection++; + } else { + selection = 0; + } + } + if (hHeld & KEY_DOWN && !keyRepeatDelay) { if (selection < (int)infoJson.size()-1) { selection++; diff --git a/source/screens/scriptlist.cpp b/source/screens/scriptlist.cpp index 1514c06..7fedf06 100644 --- a/source/screens/scriptlist.cpp +++ b/source/screens/scriptlist.cpp @@ -36,6 +36,7 @@ #include #include +extern bool touching(touchPosition touch, Structs::ButtonPos button); #define ENTRIES_PER_SCREEN 3 #define ENTRIES_PER_LIST 7 @@ -285,6 +286,9 @@ void ScriptList::DrawList(void) const { Gui::DrawStringCentered(0, 120, 0.6f, Config::TxtColor, std::string(fileInfo[selection].shortDesc), 400); Gui::DrawBottom(); + Gui::DrawArrow(295, 0); + Gui::DrawArrow(315, 240, 180.0); + if (Config::viewMode == 0) { for(int i=0;i 0) { + selection--; + } else { + selection = (int)fileInfo.size()-1; + } + } + + if (hDown & KEY_TOUCH && touching(touch, arrowPos[1])) { + if (selection < (int)fileInfo.size()-1) { + selection++; + } else { + selection = 0; + } + } + if (hHeld & KEY_DOWN && !keyRepeatDelay) { if (selection < (int)fileInfo.size()-1) { selection++; @@ -434,8 +458,24 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld) { } } -void ScriptList::SelectFunction(u32 hDown, u32 hHeld) { +void ScriptList::SelectFunction(u32 hDown, u32 hHeld, touchPosition touch) { if (keyRepeatDelay) keyRepeatDelay--; + if (hDown & KEY_TOUCH && touching(touch, arrowPos[0])) { + if (selection2 > 0) { + selection2--; + } else { + selection2 = (int)fileInfo2.size()-1; + } + } + + if (hDown & KEY_TOUCH && touching(touch, arrowPos[1])) { + if (selection2 < (int)fileInfo2.size()-1) { + selection2++; + } else { + selection2 = 0; + } + } + if (hHeld & KEY_DOWN && !keyRepeatDelay) { if (selection2 < (int)fileInfo2.size()-1) { selection2++; @@ -448,6 +488,7 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld) { keyRepeatDelay = 6; } } + if (hHeld & KEY_UP && !keyRepeatDelay) { if (selection2 > 0) { selection2--; @@ -460,6 +501,7 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld) { keyRepeatDelay = 6; } } + if (hDown & KEY_A) { if (fileInfo2.size() != 0) { choice = fileInfo2[selection2]; @@ -510,9 +552,9 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld) { void ScriptList::Logic(u32 hDown, u32 hHeld, touchPosition touch) { if (mode == 0) { - ListSelection(hDown, hHeld); + ListSelection(hDown, hHeld, touch); } else if (mode == 1) { - SelectFunction(hDown, hHeld); + SelectFunction(hDown, hHeld, touch); } if (hDown & KEY_X) { diff --git a/source/screens/tinyDB.cpp b/source/screens/tinyDB.cpp index 0d7f516..87b4fd5 100644 --- a/source/screens/tinyDB.cpp +++ b/source/screens/tinyDB.cpp @@ -34,6 +34,7 @@ #include "utils/formatting.hpp" #include "utils/scriptHelper.hpp" +extern bool touching(touchPosition touch, Structs::ButtonPos button); #define ENTRIES_PER_SCREEN 3 #define ENTRIES_PER_LIST 7 @@ -105,6 +106,8 @@ void TinyDB::Draw(void) const { Gui::sprite(sprites_bottom_screen_top_idx, 0, 0); Gui::sprite(sprites_bottom_screen_bot_idx, 0, 215); + Gui::DrawArrow(295, 0); + Gui::DrawArrow(315, 240, 180.0); // Search Icon. Gui::sprite(sprites_search_idx, -3, 0); Gui::DrawString(7.5, 1.5, 0.72f, BLACK, "\uE003"); @@ -145,6 +148,26 @@ void TinyDB::Logic(u32 hDown, u32 hHeld, touchPosition touch) { fastMode = false; } + if (hDown & KEY_TOUCH && touching(touch, arrowPos[0])) { + if (selection > 0) { + selection--; + selectedOption = tinyDBList[selection]; + } else { + selection = (int)tinyDBList.size()-1; + selectedOption = tinyDBList[selection]; + } + } + + if (hDown & KEY_TOUCH && touching(touch, arrowPos[1])) { + if (selection < (int)tinyDBList.size()-1) { + selection++; + selectedOption = tinyDBList[selection]; + } else { + selection = 0; + selectedOption = tinyDBList[selection]; + } + } + if (hHeld & KEY_UP && !keyRepeatDelay) { if (selection > 0) { selection--;