diff --git a/assets/gfx/sprites.t3s b/assets/gfx/sprites.t3s index 152579a..5115888 100644 --- a/assets/gfx/sprites.t3s +++ b/assets/gfx/sprites.t3s @@ -3,6 +3,7 @@ sprites/arrow.png sprites/bottom_screen_bot.png sprites/bottom_screen_top.png +sprites/download_all.png sprites/top_screen_bot.png sprites/top_screen_top.png sprites/search.png diff --git a/assets/gfx/sprites/arrow.png b/assets/gfx/sprites/arrow.png index e7bbf05..fa910f8 100644 Binary files a/assets/gfx/sprites/arrow.png and b/assets/gfx/sprites/arrow.png differ diff --git a/assets/gfx/sprites/download_all.png b/assets/gfx/sprites/download_all.png new file mode 100644 index 0000000..8592c1e Binary files /dev/null and b/assets/gfx/sprites/download_all.png differ diff --git a/assets/gfx/sprites/search.png b/assets/gfx/sprites/search.png index 0b2a2ef..6728de6 100644 Binary files a/assets/gfx/sprites/search.png and b/assets/gfx/sprites/search.png differ diff --git a/include/gui.hpp b/include/gui.hpp index 21f25cc..1d1e79b 100644 --- a/include/gui.hpp +++ b/include/gui.hpp @@ -46,7 +46,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); // Misc. diff --git a/include/screens/scriptBrowse.hpp b/include/screens/scriptBrowse.hpp index 090e20f..99b5464 100644 --- a/include/screens/scriptBrowse.hpp +++ b/include/screens/scriptBrowse.hpp @@ -52,6 +52,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}, // Download All. }; }; diff --git a/source/gui.cpp b/source/gui.cpp index 8bd1a34..87eb774 100644 --- a/source/gui.cpp +++ b/source/gui.cpp @@ -91,13 +91,44 @@ 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::spriteBlend(int key, int x, int y, float ScaleX, float ScaleY) +{ + C2D_ImageTint tint; + if (isScriptSelected) { + C2D_SetImageTint(&tint, C2D_TopLeft, TextColor, 0.5); + C2D_SetImageTint(&tint, C2D_TopRight, TextColor, 0.5); + C2D_SetImageTint(&tint, C2D_BotLeft, TextColor, 0.5); + C2D_SetImageTint(&tint, C2D_BotRight, TextColor, 0.5); + } else { + C2D_SetImageTint(&tint, C2D_TopLeft, Config::TxtColor, 0.5); + C2D_SetImageTint(&tint, C2D_TopRight, Config::TxtColor, 0.5); + C2D_SetImageTint(&tint, C2D_BotLeft, Config::TxtColor, 0.5); + C2D_SetImageTint(&tint, C2D_BotRight, Config::TxtColor, 0.5); + } + + C2D_DrawImageAt(C2D_SpriteSheetGetImage(sprites, key), x, y, 0.5f, &tint, ScaleX, ScaleY); +} + void Gui::DrawArrow(int x, int y, float rotation) { C2D_Sprite sprite; + C2D_ImageTint tint; + if (isScriptSelected) { + C2D_SetImageTint(&tint, C2D_TopLeft, TextColor, 0.5); + C2D_SetImageTint(&tint, C2D_TopRight, TextColor, 0.5); + C2D_SetImageTint(&tint, C2D_BotLeft, TextColor, 0.5); + C2D_SetImageTint(&tint, C2D_BotRight, TextColor, 0.5); + } else { + C2D_SetImageTint(&tint, C2D_TopLeft, Config::TxtColor, 0.5); + C2D_SetImageTint(&tint, C2D_TopRight, Config::TxtColor, 0.5); + C2D_SetImageTint(&tint, C2D_BotLeft, Config::TxtColor, 0.5); + C2D_SetImageTint(&tint, C2D_BotRight, Config::TxtColor, 0.5); + } + C2D_SpriteFromSheet(&sprite, sprites, sprites_arrow_idx); C2D_SpriteRotateDegrees(&sprite, rotation); C2D_SpriteSetPos(&sprite, x, y); C2D_SpriteSetDepth(&sprite, 0.5); - C2D_DrawSprite(&sprite); + C2D_DrawSpriteTinted(&sprite, &tint); } void Gui::DisplayWarnMsg(std::string Text) diff --git a/source/keyboard.cpp b/source/keyboard.cpp index 0f32e0e..a4bbd6b 100644 --- a/source/keyboard.cpp +++ b/source/keyboard.cpp @@ -122,7 +122,7 @@ std::string Input::Numpad(uint maxLength, std::string Text) C2D_TargetClear(bottom, BLACK); Gui::DrawTop(); Gui::DrawString((400-Gui::GetStringWidth(0.55f, Text))/2, 2, 0.55f, WHITE, Text, 400); - Gui::DrawString(180, 212, 0.8, WHITE, (string+(cursorBlink-- > 0 ? "_" : "")).c_str(), 400); + Gui::DrawString(180, 217, 0.8, WHITE, (string+(cursorBlink-- > 0 ? "_" : "")).c_str(), 400); if(cursorBlink < -20) cursorBlink = 20; Gui::setDraw(bottom); Gui::Draw_Rect(0, 0, 320, 240, Config::Color3); diff --git a/source/screens/scriptBrowse.cpp b/source/screens/scriptBrowse.cpp index e5b9270..6fd1f30 100644 --- a/source/screens/scriptBrowse.cpp +++ b/source/screens/scriptBrowse.cpp @@ -126,11 +126,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::DrawArrow(295, -3); + Gui::DrawArrow(315, 242, 180.0); +// Gui::spriteBlend(sprites_search_idx, -3, 0, Config::TxtColor); +// Gui::DrawString(7.5, 1.5, 0.72f, Config::TxtColor, "\uE003"); + 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); @@ -228,11 +228,11 @@ 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 > (i+1)*57 && touch.py < (i+2)*57) { if (infoJson.size() != 0) { std::string fileName = Lang::get("DOWNLOADING") + std::string(infoJson[screenPos + i]["title"]); std::string titleFix = infoJson[screenPos + i]["title"]; - for (int l = 0; i < (int)titleFix.size(); l++) { + for (int l = 0; l < (int)titleFix.size(); l++) { if (titleFix[l] == '/') { titleFix[l] = '-'; } @@ -328,4 +328,23 @@ void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) { } } } + + if (hDown & KEY_TOUCH && touching(touch, arrowPos[3])) { + if (infoJson.size() != 0) { + for (int i = 0; i < (int)infoJson.size(); i++) { + int current = i+1; + int total = infoJson.size(); + std::string fileName = Lang::get("DOWNLOADING") + std::string(infoJson[i]["title"]); + std::string titleFix = infoJson[i]["title"]; + for (int l = 0; l < (int)titleFix.size(); l++) { + if (titleFix[l] == '/') { + titleFix[l] = '-'; + } + } + DisplayMsg(fileName + " " + std::to_string(current) + " / " + std::to_string(total)); + downloadToFile(infoJson[i]["url"], Config::ScriptPath + titleFix + ".json"); + infoJson[i]["curRevision"] = infoJson[i]["revision"]; + } + } + } } \ No newline at end of file diff --git a/source/screens/scriptlist.cpp b/source/screens/scriptlist.cpp index 1a88d89..f6931bf 100644 --- a/source/screens/scriptlist.cpp +++ b/source/screens/scriptlist.cpp @@ -284,8 +284,8 @@ 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); + Gui::DrawArrow(295, -3); + Gui::DrawArrow(315, 242, 180.0); Gui::DrawArrow(0, 242, 270.0); if (Config::viewMode == 0) { for(int i=0;i (i+1)*57 && touch.py < (i+2)*57) { + for(int i=0;i (i+1)*57 && touch.py < (i+2)*57) { if (dirContents[screenPos + i].isDirectory) { } else if (fileInfo.size() != 0) { if (ScriptHelper::checkIfValid(dirContents[screenPos + i].name) == true) { @@ -418,11 +418,11 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) { mode = 1; } } - } + } } } else if (Config::viewMode == 1) { - for(int i=0;i (i+1)*27 && touch.py < (i+2)*27) { + for(int i=0;i (i+1)*27 && touch.py < (i+2)*27) { if (dirContents[screenPosList + i].isDirectory) { } else if (fileInfo.size() != 0) { if (ScriptHelper::checkIfValid(dirContents[screenPosList + i].name) == true) { @@ -439,7 +439,7 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) { mode = 1; } } - } + } } } } @@ -538,22 +538,22 @@ 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) { + for(int i=0;i (i+1)*57 && touch.py < (i+2)*57) { if (fileInfo2.size() != 0) { choice = fileInfo2[screenPos2 + i]; runFunctions(jsonFile); } - } + } } } else if (Config::viewMode == 1) { - for(int i=0;i (i+1)*27 && touch.py < (i+2)*27) { + for(int i=0;i (i+1)*27 && touch.py < (i+2)*27) { if (fileInfo2.size() != 0) { choice = fileInfo2[screenPosList2 + i]; runFunctions(jsonFile); } - } + } } } } diff --git a/source/screens/tinyDB.cpp b/source/screens/tinyDB.cpp index b4de89a..51d08ee 100644 --- a/source/screens/tinyDB.cpp +++ b/source/screens/tinyDB.cpp @@ -73,14 +73,14 @@ std::vector tinyDBList; TinyDB::TinyDB() { DisplayMsg(Lang::get("TINYDB_DOWNLOADING")); downloadToFile("https://tinydb.eiphax.tech/api/universal-updater.json?raw=true", tinyDBFile); - tinyDBList = parseObjects(); + tinyDBList = parseObjects(); selectedOption = tinyDBList[0]; } // To-Do. void TinyDB::Draw(void) const { - std::string info; - Gui::setDraw(top); + std::string info; + Gui::setDraw(top); Gui::Draw_Rect(0, 0, 400, 25, C2D_Color32(63, 81, 181, 255)); Gui::Draw_Rect(0, 25, 400, 190, C2D_Color32(140, 140, 140, 255)); Gui::Draw_Rect(0, 215, 400, 25, C2D_Color32(63, 81, 181, 255)); @@ -93,40 +93,42 @@ void TinyDB::Draw(void) const { Gui::DrawStringCentered(0, 125, 0.6f, Config::TxtColor, Lang::get("RELEASE_ID") + std::string(tinyDBJson[selectedOption]["info"]["releaseId"]), 400); Gui::DrawStringCentered(0, 155, 0.6f, Config::TxtColor, Lang::get("TITLE_ID") + std::string(tinyDBJson[selectedOption]["info"]["titleid"]), 400); Gui::DrawStringCentered(0, 185, 0.6f, Config::TxtColor, Lang::get("FILE_SIZE") + formatBytes(int64_t(tinyDBJson[selectedOption]["info"]["fileSize"])), 400); - Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, "TinyDB", 400); - std::string entryAmount = std::to_string(selection+1) + " / " + std::to_string(tinyDBList.size()); - Gui::DrawString(397-Gui::GetStringWidth(0.6f, entryAmount), 237-Gui::GetStringHeight(0.6f, entryAmount), 0.6f, Config::TxtColor, entryAmount); + Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, "TinyDB", 400); + std::string entryAmount = std::to_string(selection+1) + " / " + std::to_string(tinyDBList.size()); + Gui::DrawString(397-Gui::GetStringWidth(0.6f, entryAmount), 237-Gui::GetStringHeight(0.6f, entryAmount), 0.6f, Config::TxtColor, entryAmount); - Gui::setDraw(bottom); + Gui::setDraw(bottom); Gui::Draw_Rect(0, 0, 320, 25, C2D_Color32(63, 81, 181, 255)); Gui::Draw_Rect(0, 25, 320, 190, C2D_Color32(140, 140, 140, 255)); Gui::Draw_Rect(0, 215, 320, 25, C2D_Color32(63, 81, 181, 255)); 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); + Gui::DrawArrow(295, -3); + Gui::DrawArrow(315, 242, 180.0); Gui::DrawArrow(0, 242, 270.0); - // Search Icon. + // Search Icon. // Gui::sprite(sprites_search_idx, -3, 0); // Gui::DrawString(7.5, 1.5, 0.72f, BLACK, "\uE003"); - if (Config::viewMode == 0) { - for(int i=0;i (i+1)*57 && touch.py < (i+2)*57) { + if(touch.py > (i+1)*57 && touch.py < (i+2)*57) { selection = screenPos + i; selectedOption = tinyDBList[screenPos + i]; execute(); - } + } } } else if (Config::viewMode == 1) { for(int i=0;i (i+1)*27 && touch.py < (i+2)*27) { + if(touch.py > (i+1)*27 && touch.py < (i+2)*27) { selection = screenPosList + i; selectedOption = tinyDBList[screenPosList + i]; execute(); - } + } } } } - if (hDown & KEY_A) { - execute(); - } + if (hDown & KEY_A) { + execute(); + } } void TinyDB::execute() {