mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-03 00:39:02 +00:00
Add Arrows for Entry Selection stuff.
This commit is contained in:
@@ -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
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
@@ -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);
|
||||
|
||||
@@ -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<Structs::ButtonPos> arrowPos = {
|
||||
{295, 0, 25, 25, -1}, // Arrow Up.
|
||||
{295, 215, 25, 25, -1}, // Arrow Down.
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -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<DirEntry> dirContents;
|
||||
@@ -57,6 +58,11 @@ private:
|
||||
|
||||
int keyRepeatDelay = 0;
|
||||
int fastMode = false;
|
||||
|
||||
std::vector<Structs::ButtonPos> arrowPos = {
|
||||
{295, 0, 25, 25, -1}, // Arrow Up.
|
||||
{295, 215, 25, 25, -1}, // Arrow Down.
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -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<Structs::ButtonPos> arrowPos = {
|
||||
{295, 0, 25, 25, -1}, // Arrow Up.
|
||||
{295, 215, 25, 25, -1}, // Arrow Down.
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -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();
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
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<ENTRIES_PER_SCREEN && i<(int)infoJson.size();i++) {
|
||||
@@ -173,6 +176,22 @@ void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (hDown & KEY_TOUCH && touching(touch, arrowPos[0])) {
|
||||
if (selection > 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++;
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <regex>
|
||||
#include <unistd.h>
|
||||
|
||||
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<ENTRIES_PER_SCREEN && i<(int)fileInfo.size();i++) {
|
||||
line1 = fileInfo[screenPos + i].title;
|
||||
@@ -337,6 +341,9 @@ void ScriptList::DrawSingleObject(void) const {
|
||||
Gui::DrawStringCentered(0, 120-((lines.size()*20)/2)+i*20, 0.6f, TextColor, lines[i], 400);
|
||||
}
|
||||
Gui::DrawBottom();
|
||||
Gui::DrawArrow(295, 0);
|
||||
Gui::DrawArrow(315, 240, 180.0);
|
||||
|
||||
if (Config::viewMode == 0) {
|
||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)fileInfo2.size();i++) {
|
||||
info = fileInfo2[screenPos2 + i];
|
||||
@@ -347,20 +354,21 @@ void ScriptList::DrawSingleObject(void) const {
|
||||
}
|
||||
Gui::DrawStringCentered(0, 50+(i*57), 0.7f, TextColor, info, 320);
|
||||
}
|
||||
|
||||
} else if (Config::viewMode == 1) {
|
||||
for(int i=0;i<ENTRIES_PER_LIST && i<(int)fileInfo2.size();i++) {
|
||||
info = fileInfo2[screenPosList2 + i];
|
||||
if(screenPosList2 + i == selection2) {
|
||||
Gui::Draw_Rect(0, 30+(i*25), 320, 30, selected);
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, selected);
|
||||
} else {
|
||||
Gui::Draw_Rect(0, 30+(i*25), 320, 30, unselected);
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, unselected);
|
||||
}
|
||||
Gui::DrawStringCentered(0, 35+(i*25), 0.7f, TextColor, info, 320);
|
||||
Gui::DrawStringCentered(0, ((i+1)*27)+1, 0.7f, TextColor, info, 320);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptList::ListSelection(u32 hDown, u32 hHeld) {
|
||||
void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
|
||||
if (keyRepeatDelay) keyRepeatDelay--;
|
||||
|
||||
if (hDown & KEY_B) {
|
||||
@@ -369,6 +377,22 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (hDown & KEY_TOUCH && touching(touch, arrowPos[0])) {
|
||||
if (selection > 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) {
|
||||
|
||||
@@ -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--;
|
||||
|
||||
Reference in New Issue
Block a user