From 5f5fcc3f24c9a47a046c88f0f946f72e6095025c Mon Sep 17 00:00:00 2001 From: SuperSaiyajinStackZ <47382115+SuperSaiyajinStackZ@users.noreply.github.com> Date: Sun, 22 Dec 2019 00:21:53 +0100 Subject: [PATCH] Add Arrows for Entry Selection stuff. --- assets/gfx/sprites.t3s | 1 + assets/gfx/sprites/arrow.png | Bin 0 -> 5785 bytes include/gui.hpp | 2 ++ include/screens/scriptBrowse.hpp | 5 +++ include/screens/scriptlist.hpp | 10 ++++-- include/screens/tinyDB.hpp | 6 ++++ source/gui.cpp | 9 +++++ source/screens/scriptBrowse.cpp | 21 +++++++++++- source/screens/scriptlist.cpp | 56 +++++++++++++++++++++++++++---- source/screens/tinyDB.cpp | 23 +++++++++++++ 10 files changed, 123 insertions(+), 10 deletions(-) create mode 100644 assets/gfx/sprites/arrow.png 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 0000000000000000000000000000000000000000..e7bbf053c21f03158e9204bc18cd2311e7e4d6d7 GIT binary patch literal 5785 zcmV;K7G~**P)P000>X1^@s6#OZ}&000sldQ@0+Qek%> zaB^>EX>4U6ba`-PAZ2)IW&i+q+U1#BlH{nCMgJK^4?(7JA)p6uZ=vTGPA1k zW?A2#wvMoHdC27g&SO82+yDKqkx_mkv&c+dOv zxl!Nmo6=kTeya0xBl}!r4h&O-vfzLmk zk6*)t?+1=wGYUU`aFX|bTF&S1oYl_R@9IV>M6`S=>IVB;gmmE~B7%5+mJ(FMa-3PLAoKJrF;g8?Y8aNb9&_} z65`J%Z}|rJ+wUj+&v*4hsgl8b!`xWlc;pv+*JX}x3wc-9=LUp`u``qL zk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XkOn7OQ!8U&COk=s5-X(D=CS6BC?P$-=21Ay`IarE}~_Gqn_g8)R- zzqPehAfkR|E?<-rks1+MP9~Fy*4EY&!_yX>8Po&;T-V*5o}R}1{5&knifXOjXsz%1 zwC)=b4FGtj+S=OgX{}!e88CC-`ucixZf*_$u(Gm(#>U2jSS)4}(V$Q33;-j{yiB=V z?zxCO4FaT6sjAz4rT0Qkhrk2W_qtJ!Qe^vu}V*+H>bZ16lU2OusYpOsRN zhlhtt1OWMb9*2jAe0+R-BNB=14-E|=?5sHdnHLuqVVY*GVHgLoSWI_ybzM*GD_B1P X0EQ|SEDV&%00000NkvXXu0mjf1)M1H literal 0 HcmV?d00001 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--;