From f3d5706159e43bf5a7889fdc7fce4e989e10aff6 Mon Sep 17 00:00:00 2001 From: StackZ <47382115+SuperSaiyajinStackZ@users.noreply.github.com> Date: Tue, 24 Dec 2019 03:53:02 +0100 Subject: [PATCH] Fix a few problems. --- assets/gfx/sprites.t3s | 1 + assets/gfx/sprites/side_arrow.png | Bin 0 -> 767 bytes include/gui.hpp | 2 +- include/screens/scriptBrowse.hpp | 6 ++-- include/screens/scriptlist.hpp | 2 +- include/screens/settings.hpp | 1 + include/screens/tinyDB.hpp | 4 +-- source/gui.cpp | 8 +++-- source/screens/ftpScreen.cpp | 2 +- source/screens/mainMenu.cpp | 2 +- source/screens/scriptBrowse.cpp | 12 ++++--- source/screens/scriptlist.cpp | 18 +++++----- source/screens/settings.cpp | 55 ++++++++++++++++++++++++++---- source/screens/tinyDB.cpp | 8 ++--- 14 files changed, 86 insertions(+), 35 deletions(-) create mode 100644 assets/gfx/sprites/side_arrow.png diff --git a/assets/gfx/sprites.t3s b/assets/gfx/sprites.t3s index cba0852..8e0fee4 100644 --- a/assets/gfx/sprites.t3s +++ b/assets/gfx/sprites.t3s @@ -7,6 +7,7 @@ sprites/download_all.png sprites/top_screen_bot.png sprites/top_screen_top.png sprites/search.png +sprites/side_arrow.png sprites/view.png sprites/credits/discord.png diff --git a/assets/gfx/sprites/side_arrow.png b/assets/gfx/sprites/side_arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..b9cc7e4b0a2853c9dfef7608c26d8491f6c1053d GIT binary patch literal 767 zcmVWFU8GbZ8()Nlj27VtF7`Z**a7Yb*T z+nfrXOeVS3dNv~7w*7&mi?;juTmtyh_ScfGrFVmL zj}~|c91(+vc*XV>@D^|mcm}Yf0^A2ak@TsgA4a25c~UFW;$d4r4_uUV33zc11qj;@ zZGWCp`nc=5`zJvUf&cIL7c9xZ9&p$8ZQxhn??s-Zvy$G4h--{hQk4#J;!d85&&&1SQQwbsufVi(wwbnv9tBwYqtYi$aA8xea;NoY76 zwo=NYTI-jswLM^bL_%jIy##Ck+miN{*5+U^Xr+|jfm;zViHN@>U9r8;<}bhl;PFxt xIs%VU%1&$T&RjkZfD5)4qW@0PAqhQw@egB7ZGyi{vO)j=002ovPDHLkV1gADRVDxc literal 0 HcmV?d00001 diff --git a/include/gui.hpp b/include/gui.hpp index 1d1e79b..a8b87d1 100644 --- a/include/gui.hpp +++ b/include/gui.hpp @@ -47,7 +47,7 @@ namespace Gui // Draw a Sprite from the sheet. void sprite(int key, int x, int y, float ScaleX = 1, float ScaleY = 1); void spriteBlend(int key, int x, int y, float ScaleX = 1, float ScaleY = 1); - void DrawArrow(int x, int y, float rotation = 0); + void DrawArrow(int x, int y, float rotation = 0, int arrowSprite = 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 1064360..70dbf99 100644 --- a/include/screens/scriptBrowse.hpp +++ b/include/screens/scriptBrowse.hpp @@ -52,9 +52,9 @@ private: {295, 0, 25, 25, -1}, // Arrow Up. {295, 215, 25, 25, -1}, // Arrow Down. {0, 215, 25, 25, -1}, // Back Arrow. - {0, 0, 25, 25, -1}, // Download All. - {40, 0, 25, 25, -1}, // ViewMode Change. - {75, 0, 25, 25, -1}, // Search. + {5, 0, 25, 25, -1}, // Download All. + {45, 0, 25, 25, -1}, // ViewMode Change. + {80, 0, 25, 25, -1}, // Search. }; }; diff --git a/include/screens/scriptlist.hpp b/include/screens/scriptlist.hpp index f5c0099..cb2c683 100644 --- a/include/screens/scriptlist.hpp +++ b/include/screens/scriptlist.hpp @@ -63,7 +63,7 @@ private: {295, 0, 25, 25, -1}, // Arrow Up. {295, 215, 25, 25, -1}, // Arrow Down. {0, 215, 25, 25, -1}, // Back Arrow. - {0, 0, 25, 25, -1}, // viewMode Change + {5, 0, 25, 25, -1}, // viewMode Change }; }; diff --git a/include/screens/settings.hpp b/include/screens/settings.hpp index 11e136e..5889d06 100644 --- a/include/screens/settings.hpp +++ b/include/screens/settings.hpp @@ -39,6 +39,7 @@ class Settings : public screen public: void Draw(void) const override; void Logic(u32 hDown, u32 hHeld, touchPosition touch) override; + Settings(); private: // Credits stuff. int DisplayMode = 1; diff --git a/include/screens/tinyDB.hpp b/include/screens/tinyDB.hpp index d5268c5..627a989 100644 --- a/include/screens/tinyDB.hpp +++ b/include/screens/tinyDB.hpp @@ -50,8 +50,8 @@ private: {295, 0, 25, 25, -1}, // Arrow Up. {295, 215, 25, 25, -1}, // Arrow Down. {0, 215, 25, 25, -1}, // Back Arrow. - {0, 0, 25, 25, -1}, // ViewMode Change. - {40, 0, 25, 25, -1}, // Search. + {5, 0, 25, 25, -1}, // ViewMode Change. + {45, 0, 25, 25, -1}, // Search. }; }; diff --git a/source/gui.cpp b/source/gui.cpp index 87eb774..7283b04 100644 --- a/source/gui.cpp +++ b/source/gui.cpp @@ -109,7 +109,7 @@ void Gui::spriteBlend(int key, int x, int y, float ScaleX, float ScaleY) C2D_DrawImageAt(C2D_SpriteSheetGetImage(sprites, key), x, y, 0.5f, &tint, ScaleX, ScaleY); } -void Gui::DrawArrow(int x, int y, float rotation) { +void Gui::DrawArrow(int x, int y, float rotation, int arrowSprite) { C2D_Sprite sprite; C2D_ImageTint tint; if (isScriptSelected) { @@ -124,7 +124,11 @@ void Gui::DrawArrow(int x, int y, float rotation) { C2D_SetImageTint(&tint, C2D_BotRight, Config::TxtColor, 0.5); } - C2D_SpriteFromSheet(&sprite, sprites, sprites_arrow_idx); + if (arrowSprite == 0) { + C2D_SpriteFromSheet(&sprite, sprites, sprites_arrow_idx); + } else { + C2D_SpriteFromSheet(&sprite, sprites, sprites_side_arrow_idx); + } C2D_SpriteRotateDegrees(&sprite, rotation); C2D_SpriteSetPos(&sprite, x, y); C2D_SpriteSetDepth(&sprite, 0.5); diff --git a/source/screens/ftpScreen.cpp b/source/screens/ftpScreen.cpp index 3db91d2..2fc8789 100644 --- a/source/screens/ftpScreen.cpp +++ b/source/screens/ftpScreen.cpp @@ -57,7 +57,7 @@ void FTPScreen::Draw(void) const Gui::DrawTop(); Gui::DrawString((400-Gui::GetStringWidth(0.8f, Lang::get("FTP_MODE")))/2, 0, 0.8f, Config::TxtColor, Lang::get("FTP_MODE"), 400); Gui::DrawBottom(); - Gui::DrawArrow(0, 242, 270.0); + Gui::DrawArrow(0, 218, 0, 1); ret = ACU_GetWifiStatus(&wifiStatus); if ((wifiStatus != 0) && R_SUCCEEDED(ret)) { diff --git a/source/screens/mainMenu.cpp b/source/screens/mainMenu.cpp index 71ba7c5..b95cb87 100644 --- a/source/screens/mainMenu.cpp +++ b/source/screens/mainMenu.cpp @@ -54,7 +54,7 @@ void MainMenu::Draw(void) const { Gui::DrawString(397-Gui::GetStringWidth(0.5f, V_STRING), 237-Gui::GetStringHeight(0.5f, V_STRING), 0.5f, Config::TxtColor, V_STRING); if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(0, 0, 0, fadealpha)); // Fade in out effect Gui::DrawBottom(); - Gui::DrawArrow(0, 242, 270.0); + Gui::DrawArrow(0, 218, 0, 1); for (int i = 0; i < 6; i++) { if (Selection == i) { diff --git a/source/screens/scriptBrowse.cpp b/source/screens/scriptBrowse.cpp index 7c98ffd..2878828 100644 --- a/source/screens/scriptBrowse.cpp +++ b/source/screens/scriptBrowse.cpp @@ -126,12 +126,14 @@ void ScriptBrowse::Draw(void) const { Gui::DrawStringCentered(0, 217, 0.7f, Config::TxtColor, Lang::get("FUTURE_SCRIPT"), 400); } Gui::DrawBottom(); - Gui::DrawArrow(295, -3); - Gui::DrawArrow(315, 242, 180.0); + Gui::DrawArrow(295, -1); + Gui::DrawArrow(315, 240, 180.0); + Gui::DrawArrow(0, 218, 0, 1); + + Gui::spriteBlend(sprites_download_all_idx, arrowPos[3].x, arrowPos[3].y); Gui::spriteBlend(sprites_view_idx, arrowPos[4].x, arrowPos[4].y); //Gui::spriteBlend(sprites_search_idx, arrowPos[5].x, arrowPos[5].y); - Gui::spriteBlend(sprites_download_all_idx, 0, 0); - Gui::DrawArrow(0, 242, 270.0); + Gui::DrawStringCentered(-23, 3, 0.6f, Config::TxtColor, std::to_string(selection + 1) + " / " + maxScripts); if (Config::viewMode == 0) { @@ -228,7 +230,7 @@ void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) { if (hDown & KEY_TOUCH) { if (Config::viewMode == 0) { for(int i=0;i (i+1)*57 && touch.py < (i+2)*57) { + if(touch.py > 40+(i*57) && touch.py < 40+(i*57)+45) { if (infoJson.size() != 0) { std::string fileName = Lang::get("DOWNLOADING") + std::string(infoJson[screenPos + i]["title"]); std::string titleFix = infoJson[screenPos + i]["title"]; diff --git a/source/screens/scriptlist.cpp b/source/screens/scriptlist.cpp index d21e0d0..7d16b94 100644 --- a/source/screens/scriptlist.cpp +++ b/source/screens/scriptlist.cpp @@ -207,6 +207,8 @@ void runFunctions(nlohmann::json &json) { seconds = json.at(choice).at(i).at("seconds"); else missing = true; if(!missing) ScriptHelper::displayTimeMsg(message, seconds); + } else if (type == "saveConfig") { + Config::save(); } } doneMsg(); @@ -284,9 +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, -3); - Gui::DrawArrow(315, 242, 180.0); - Gui::DrawArrow(0, 242, 270.0); + Gui::DrawArrow(295, -1); + Gui::DrawArrow(315, 240, 180.0); + Gui::DrawArrow(0, 218, 0, 1); Gui::spriteBlend(sprites_view_idx, arrowPos[3].x, arrowPos[3].y); if (Config::viewMode == 0) { @@ -341,9 +343,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, -3); - Gui::DrawArrow(315, 242, 180.0); - Gui::DrawArrow(0, 242, 270.0); + Gui::DrawArrow(295, -1); + Gui::DrawArrow(315, 240, 180.0); + Gui::DrawArrow(0, 218, 0, 1); Gui::spriteBlend(sprites_view_idx, arrowPos[3].x, arrowPos[3].y); if (Config::viewMode == 0) { @@ -404,7 +406,7 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) { if (hDown & KEY_TOUCH) { if (Config::viewMode == 0) { for(int i=0;i (i+1)*57 && touch.py < (i+2)*57) { + if(touch.py > 40+(i*57) && touch.py < 40+(i*57)+45) { if (dirContents[screenPos + i].isDirectory) { } else if (fileInfo.size() != 0) { if (ScriptHelper::checkIfValid(dirContents[screenPos + i].name) == true) { @@ -542,7 +544,7 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld, touchPosition touch) { if (hDown & KEY_TOUCH) { if (Config::viewMode == 0) { for(int i=0;i (i+1)*57 && touch.py < (i+2)*57) { + if(touch.py > 40+(i*57) && touch.py < 40+(i*57)+45) { if (fileInfo2.size() != 0) { choice = fileInfo2[screenPos2 + i]; runFunctions(jsonFile); diff --git a/source/screens/settings.cpp b/source/screens/settings.cpp index 5150713..a522e53 100644 --- a/source/screens/settings.cpp +++ b/source/screens/settings.cpp @@ -32,6 +32,12 @@ extern bool touching(touchPosition touch, Structs::ButtonPos button); +int selectedLang; + +Settings::Settings() { + selectedLang = Config::lang; +} + void Settings::Draw(void) const { if (mode == 0) { DrawSubMenu(); @@ -49,7 +55,7 @@ void Settings::DrawSubMenu(void) const { Gui::DrawTop(); Gui::DrawString((400-Gui::GetStringWidth(0.8f, "Universal-Updater"))/2, 2, 0.8f, Config::TxtColor, "Universal-Updater", 400); Gui::DrawBottom(); - Gui::DrawArrow(0, 242, 270.0); + Gui::DrawArrow(0, 218, 0, 1); for (int i = 0; i < 3; i++) { if (Selection == i) { @@ -68,7 +74,7 @@ void Settings::DrawLanguageSelection(void) const { Gui::DrawTop(); Gui::DrawString((400-Gui::GetStringWidth(0.8f, Lang::get("SELECT_LANG")))/2, 2, 0.8f, Config::TxtColor, Lang::get("SELECT_LANG"), 400); Gui::DrawBottom(); - Gui::DrawArrow(0, 242, 270.0); + Gui::DrawArrow(0, 218, 0, 1); for (int language = 0; language < 10; language++) { if (Config::lang == language) { @@ -111,10 +117,10 @@ void Settings::DrawColorChanging(void) const { Gui::DrawBottom(); - Gui::DrawArrow(0, 242, 270.0); + Gui::DrawArrow(0, 218, 0, 1); - Gui::DrawArrow(0, 21, 270.0); - Gui::DrawArrow(320, -5, 90.0); + Gui::DrawArrow(0, 0, 0, 1); + Gui::DrawArrow(318, 22, 180.0, 1); for (int i = 0; i < 7; i++) { if (colorMode == i) { @@ -186,7 +192,7 @@ void Settings::DrawCreditsScreen(void) const { currentVersion += V_STRING; Gui::DrawString(395-Gui::GetStringWidth(0.72f, currentVersion), 218, 0.72f, Config::TxtColor, currentVersion, 400); Gui::DrawBottom(); - Gui::DrawArrow(0, 242, 270.0); + Gui::DrawArrow(0, 218, 0, 1); Gui::DrawString((320-Gui::GetStringWidth(0.7f, Lang::get("MANY_THANKS")))/2, 1, 0.8f, Config::TxtColor, Lang::get("MANY_THANKS"), 320); Gui::DrawString((320-Gui::GetStringWidth(0.7f, Lang::get("TRANSLATORS")))/2, 40, 0.7f, Config::TxtColor, Lang::get("TRANSLATORS"), 320); Gui::DrawString((320-Gui::GetStringWidth(0.5f, Lang::get("HELP_TRANSLATE")))/2, 70, 0.5f, Config::TxtColor, Lang::get("HELP_TRANSLATE"), 320); @@ -201,7 +207,7 @@ void Settings::DrawCreditsScreen(void) const { Gui::sprite(sprites_discord_idx, 115, 35); Gui::DrawBottom(); Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(0, 0, 0, 190)); - Gui::DrawArrow(0, 242, 270.0); + Gui::DrawArrow(0, 218, 0, 1); } } @@ -251,15 +257,50 @@ void Settings::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) { } void Settings::LanguageSelection(u32 hDown, touchPosition touch) { + if (hDown & KEY_TOUCH) { for (int language = 0; language < 10; language++) { if (touching(touch, langBlocks[language])) { + selectedLang = language; Config::lang = language; Lang::load(Config::lang); } } } + if (hDown & KEY_UP) { + if(selectedLang > 0) { + selectedLang--; + Config::lang = selectedLang; + Lang::load(Config::lang); + } + } + + if (hDown & KEY_DOWN) { + if(selectedLang < 9) { + selectedLang++; + Config::lang = selectedLang; + Lang::load(Config::lang); + } + } + + + if (hDown & KEY_LEFT) { + if (selectedLang > 4) { + selectedLang -= 5; + Config::lang = selectedLang; + Lang::load(Config::lang); + } + } + + if (hDown & KEY_RIGHT) { + if (selectedLang < 5) { + selectedLang += 5; + Config::lang = selectedLang; + Lang::load(Config::lang); + } + } + if (hDown & KEY_B) { mode = 0; } diff --git a/source/screens/tinyDB.cpp b/source/screens/tinyDB.cpp index 6656ea7..521d0f5 100644 --- a/source/screens/tinyDB.cpp +++ b/source/screens/tinyDB.cpp @@ -104,9 +104,9 @@ 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, -3); - Gui::DrawArrow(315, 242, 180.0); - Gui::DrawArrow(0, 242, 270.0); + Gui::DrawArrow(295, -1); + Gui::DrawArrow(315, 240, 180.0); + Gui::DrawArrow(0, 218, 0, 1); Gui::spriteBlend(sprites_view_idx, arrowPos[3].x, arrowPos[3].y); // Gui::spriteBlend(sprites_search_idx, arrowPos[4].x, arrowPos[4].y); @@ -228,7 +228,7 @@ void TinyDB::Logic(u32 hDown, u32 hHeld, touchPosition touch) { if (hDown & KEY_TOUCH) { if (Config::viewMode == 0) { for(int i=0;i (i+1)*57 && touch.py < (i+2)*57) { + if(touch.py > 40+(i*57) && touch.py < 40+(i*57)+45) { selection = screenPos + i; selectedOption = tinyDBList[screenPos + i]; execute();