diff --git a/README.md b/README.md index 8ceb715..8bc979b 100644 --- a/README.md +++ b/README.md @@ -40,4 +40,6 @@ To build Universal-Updater from source, you need devkitPro installed, along with ## Icon Credits -Trash icon icon by Icons8 \ No newline at end of file +Trash icon icon by Icons8 + +Menu icon icon by Icons8 \ No newline at end of file diff --git a/assets/gfx/sprites.t3s b/assets/gfx/sprites.t3s index ae6195d..296bd6b 100644 --- a/assets/gfx/sprites.t3s +++ b/assets/gfx/sprites.t3s @@ -5,6 +5,7 @@ sprites/bottom_screen_bot.png sprites/bottom_screen_top.png sprites/delete.png sprites/download_all.png +sprites/dropdown.png sprites/top_screen_bot.png sprites/top_screen_top.png sprites/search.png diff --git a/assets/gfx/sprites/dropdown.png b/assets/gfx/sprites/dropdown.png new file mode 100644 index 0000000..23d54ce Binary files /dev/null and b/assets/gfx/sprites/dropdown.png differ diff --git a/include/screens/scriptBrowse.hpp b/include/screens/scriptBrowse.hpp index 72702dc..ea760b4 100644 --- a/include/screens/scriptBrowse.hpp +++ b/include/screens/scriptBrowse.hpp @@ -44,12 +44,16 @@ private: mutable int screenPos = 0; mutable int screenPosList = 0; mutable int Selection = 0; + int dropSelection = 0; int mode = 0; + bool dropDownMenu = false; // Draws. void DrawBrowse(void) const; void DrawGlossary(void) const; + void DropDownLogic(u32 hDown, u32 hHeld, touchPosition touch); + nlohmann::json infoJson; int maxScripts; @@ -58,15 +62,26 @@ private: int fastMode = false; std::vector dirContents; void refresh(); + void downloadAll(); // Button | Icon struct. std::vector arrowPos = { {295, 0, 25, 25}, // Arrow Up. {295, 215, 25, 25}, // Arrow Down. {0, 215, 25, 25}, // Back Arrow. - {5, 0, 25, 25}, // Download All. - {45, 0, 25, 25}, // ViewMode Change. - {80, 0, 25, 25}, // Search. + {5, 0, 25, 25} // Dropdown Menu. + }; + + // DropDownMenu. + std::vector dropPos = { + {5, 30, 25, 25}, // Download All. + {5, 70, 25, 25}, // Refresh. + {5, 110, 25, 25} // ViewMode. + }; + std::vector dropPos2 = { + {0, 28, 140, 30}, // Download All. + {0, 68, 140, 30}, // Refresh. + {0, 108, 140, 30} // ViewMode. }; }; diff --git a/include/screens/scriptlist.hpp b/include/screens/scriptlist.hpp index 753a35c..fff0d79 100644 --- a/include/screens/scriptlist.hpp +++ b/include/screens/scriptlist.hpp @@ -80,6 +80,8 @@ private: mutable int screenPos = 0; mutable int screenPosList = 0; mutable int Selection = 0; + int dropSelection = 0; + bool dropDownMenu = false; // Browse stuff. int keyRepeatDelay = 0; @@ -92,14 +94,23 @@ private: {295, 0, 25, 25}, // Arrow Up. {295, 215, 25, 25}, // Arrow Down. {0, 215, 25, 25}, // Back Arrow. - {5, 0, 25, 25}, // viewMode Change - {45, 0, 25, 25}, // Delete. + {5, 0, 25, 25} // Dropdown Menu. }; std::vector subPos = { {10, 70, 140, 40}, // Script list. {170, 70, 140, 40}, // Get Scripts. {10, 145, 140, 40}, // Script Creator. - {170, 145, 140, 40}, // Script path change. + {170, 145, 140, 40} // Script path change. + }; + + // DropDownMenu. + std::vector dropPos = { + {5, 30, 25, 25}, // Delete. + {5, 70, 25, 25} // ViewMode. + }; + std::vector dropPos2 = { + {0, 28, 140, 30}, // Delete. + {0, 68, 140, 30} // ViewMode. }; }; diff --git a/include/screens/unistore.hpp b/include/screens/unistore.hpp index bcc9ab7..fdb0f92 100644 --- a/include/screens/unistore.hpp +++ b/include/screens/unistore.hpp @@ -80,6 +80,8 @@ private: mutable int Selection = 0; int screenPos = 0; mutable int screenPosList = 0; + bool dropDownMenu = false; + int dropSelection = 0; // Browse stuff. int keyRepeatDelay = 0; @@ -99,25 +101,35 @@ private: {295, 0, 25, 25}, // Arrow Up. {295, 215, 25, 25}, // Arrow Down. {0, 215, 25, 25}, // Back Arrow. - {5, 0, 25, 25}, // ViewMode Change. - {45, 0, 25, 25}, // Delete. - {85, 0, 25, 25}, // Update. + {5, 0, 25, 25}, // Dropdown Menu. }; std::vector URLBtn = { {10, 70, 140, 40}, // FULL URL. {170, 70, 140, 40}, // Github. {10, 145, 140, 40}, // TinyDB. - {170, 145, 140, 40}, // QR Code? + {170, 145, 140, 40} // QR Code? }; std::vector GitHubPos = { {30, 50, 260, 30}, // Owner & Repo. {30, 130, 260, 30}, // Filename. - {135, 180, 50, 30}, // OK. + {135, 180, 50, 30} // OK. }; std::vector subPos = { {90, 40, 140, 35}, // StoreList. {90, 100, 140, 35}, // storeSearch. - {90, 160, 140, 35}, // storePathChange. + {90, 160, 140, 35} // storePathChange. + }; + + // DropDownMenu. + std::vector dropPos = { + {5, 30, 25, 25}, // Delete. + {5, 70, 25, 25}, // Update. + {5, 110, 25, 25} // ViewMode. + }; + std::vector dropPos2 = { + {0, 28, 140, 30}, // Delete. + {0, 68, 140, 30}, // Update. + {0, 108, 140, 30} // ViewMode. }; }; diff --git a/romfs/lang/en/app.json b/romfs/lang/en/app.json index 16e58b3..097c610 100644 --- a/romfs/lang/en/app.json +++ b/romfs/lang/en/app.json @@ -152,5 +152,11 @@ "DELETE_SCRIPT2": "Delete the selected Script.", "DELETE_UNISTORE": "Delete the selected UniStore.", "REFRESH_SCRIPTBROWSE_PROMPT": "Would you like to refresh the ScriptBrowse?", - "REFRESH_SCRIPTBROWSE": "Refresh the ScriptBrowse." + "REFRESH_SCRIPTBROWSE": "Refresh the ScriptBrowse.", + + "DOWNLOAD_ALL_DDM": "Download All", + "REFRESH_BROWSE_DDM": "Refresh", + "VIEW_DDM": "Change ViewMode", + "DELETE_DDM": "Delete", + "UPDATE_DDM": "Update" } diff --git a/source/screens/scriptBrowse.cpp b/source/screens/scriptBrowse.cpp index d348ee3..88c318e 100644 --- a/source/screens/scriptBrowse.cpp +++ b/source/screens/scriptBrowse.cpp @@ -152,9 +152,7 @@ void ScriptBrowse::DrawBrowse(void) const { GFX::DrawArrow(315, 240, 180.0); GFX::DrawArrow(0, 218, 0, 1); - GFX::DrawSpriteBlend(sprites_download_all_idx, arrowPos[3].x, arrowPos[3].y); - GFX::DrawSpriteBlend(sprites_view_idx, arrowPos[4].x, arrowPos[4].y); - GFX::DrawSpriteBlend(sprites_update_idx, arrowPos[5].x, arrowPos[5].y); + GFX::DrawSpriteBlend(sprites_dropdown_idx, arrowPos[3].x, arrowPos[3].y); Gui::DrawStringCentered(0, 1, 0.6f, Config::TxtColor, std::to_string(Selection + 1) + " | " + std::to_string(maxScripts)); @@ -162,7 +160,9 @@ void ScriptBrowse::DrawBrowse(void) const { for(int i=0;i 0) { - Selection--; - } else { - Selection = (int)infoJson.size()-1; - } - if (fastMode == true) { - keyRepeatDelay = 3; - } else if (fastMode == false){ - keyRepeatDelay = 6; - } - } + if (hDown & KEY_UP) { + if (dropSelection > 0) dropSelection--; + } - if (hDown & KEY_TOUCH) { - if (Config::viewMode == 0) { - for(int i=0;i 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"]; - for (int l = 0; l < (int)titleFix.size(); l++) { - if (titleFix[l] == '/') { - titleFix[l] = '-'; - } - } - Msg::DisplayMsg(fileName); - downloadToFile(infoJson[screenPos + i]["url"], Config::ScriptPath + titleFix + ".json"); - infoJson[screenPos + i]["curRevision"] = infoJson[screenPos + i]["revision"]; - } - } + if (hDown & KEY_A) { + switch(dropSelection) { + case 0: + downloadAll(); + break; + case 1: + refresh(); + break; + case 2: + if (Config::viewMode == 0) { + Config::viewMode = 1; + } else { + Config::viewMode = 0; } - } else if (Config::viewMode == 1) { - for(int i=0;i (i+1)*27 && touch.py < (i+2)*27) { - if (infoJson.size() != 0) { - std::string fileName = Lang::get("DOWNLOADING") + std::string(infoJson[screenPosList + i]["title"]); - std::string titleFix = infoJson[screenPosList + i]["title"]; - for (int l = 0; l < (int)titleFix.size(); l++) { - if (titleFix[l] == '/') { - titleFix[l] = '-'; - } - } - Msg::DisplayMsg(fileName); - downloadToFile(infoJson[screenPosList + i]["url"], Config::ScriptPath + titleFix + ".json"); - infoJson[screenPosList + i]["curRevision"] = infoJson[screenPosList + i]["revision"]; - } - } - } - } + break; } + dropDownMenu = false; + } - if (hDown & KEY_A) { - if (infoJson.size() != 0) { - std::string fileName = Lang::get("DOWNLOADING") + std::string(infoJson[Selection]["title"]); - - std::string titleFix = infoJson[Selection]["title"]; - for (int i = 0; i < (int)titleFix.size(); i++) { - if (titleFix[i] == '/') { - titleFix[i] = '-'; - } - } - Msg::DisplayMsg(fileName); - - downloadToFile(infoJson[Selection]["url"], Config::ScriptPath + titleFix + ".json"); - infoJson[Selection]["curRevision"] = infoJson[Selection]["revision"]; - } - } - - if (hDown & KEY_R) { - fastMode = true; - } - - if (hDown & KEY_L) { - fastMode = false; - } - - if ((hDown & KEY_X) || (hDown & KEY_TOUCH && touching(touch, arrowPos[4]))) { + if (hDown & KEY_TOUCH) { + if (touching(touch, dropPos2[0])) { + downloadAll(); + dropDownMenu = false; + } else if (touching(touch, dropPos2[1])) { + refresh(); + dropDownMenu = false; + } else if (touching(touch, dropPos2[2])) { if (Config::viewMode == 0) { Config::viewMode = 1; } else { Config::viewMode = 0; } + dropDownMenu = false; } + } +} - if ((hDown & KEY_SELECT) || (hDown & KEY_TOUCH && touching(touch, arrowPos[5]))) { - refresh(); - } - - if (Config::viewMode == 0) { - if(Selection < screenPos) { - screenPos = Selection; - } else if (Selection > screenPos + ENTRIES_PER_SCREEN - 1) { - screenPos = Selection - ENTRIES_PER_SCREEN + 1; - } - } else if (Config::viewMode == 1) { - if(Selection < screenPosList) { - screenPosList = Selection; - } else if (Selection > screenPosList + ENTRIES_PER_LIST - 1) { - screenPosList = Selection - ENTRIES_PER_LIST + 1; +void ScriptBrowse::downloadAll() { + 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] = '-'; + } } + Msg::DisplayMsg(fileName + " " + std::to_string(current) + " / " + std::to_string(total)); + downloadToFile(infoJson[i]["url"], Config::ScriptPath + titleFix + ".json"); + infoJson[i]["curRevision"] = infoJson[i]["revision"]; } + } +} - if ((hDown & KEY_Y) || (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] = '-'; +void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) { + if (keyRepeatDelay) keyRepeatDelay--; + if (dropDownMenu) { + DropDownLogic(hDown, hHeld, touch); + } else { + if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) { + infoJson.clear(); + Gui::screenBack(); + return; + } + if (mode == 0) { + if ((hHeld & KEY_DOWN && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[1]))) { + if (Selection < (int)infoJson.size()-1) { + Selection++; + } else { + Selection = 0; + } + if (fastMode == true) { + keyRepeatDelay = 3; + } else if (fastMode == false){ + keyRepeatDelay = 6; + } + } + + if ((hDown & KEY_SELECT) || (hDown & KEY_TOUCH && touching(touch, arrowPos[3]))) { + dropDownMenu = true; + } + + if ((hHeld & KEY_UP && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[0]))) { + if (Selection > 0) { + Selection--; + } else { + Selection = (int)infoJson.size()-1; + } + if (fastMode == true) { + keyRepeatDelay = 3; + } else if (fastMode == false){ + keyRepeatDelay = 6; + } + } + + if (hDown & KEY_TOUCH) { + if (Config::viewMode == 0) { + for(int i=0;i 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"]; + for (int l = 0; l < (int)titleFix.size(); l++) { + if (titleFix[l] == '/') { + titleFix[l] = '-'; + } + } + Msg::DisplayMsg(fileName); + downloadToFile(infoJson[screenPos + i]["url"], Config::ScriptPath + titleFix + ".json"); + infoJson[screenPos + i]["curRevision"] = infoJson[screenPos + i]["revision"]; + } } } - Msg::DisplayMsg(fileName + " " + std::to_string(current) + " / " + std::to_string(total)); - downloadToFile(infoJson[i]["url"], Config::ScriptPath + titleFix + ".json"); - infoJson[i]["curRevision"] = infoJson[i]["revision"]; + } else if (Config::viewMode == 1) { + for(int i=0;i (i+1)*27 && touch.py < (i+2)*27) { + if (infoJson.size() != 0) { + std::string fileName = Lang::get("DOWNLOADING") + std::string(infoJson[screenPosList + i]["title"]); + std::string titleFix = infoJson[screenPosList + i]["title"]; + for (int l = 0; l < (int)titleFix.size(); l++) { + if (titleFix[l] == '/') { + titleFix[l] = '-'; + } + } + Msg::DisplayMsg(fileName); + downloadToFile(infoJson[screenPosList + i]["url"], Config::ScriptPath + titleFix + ".json"); + infoJson[screenPosList + i]["curRevision"] = infoJson[screenPosList + i]["revision"]; + } + } + } + } + } + + if (hDown & KEY_A) { + if (infoJson.size() != 0) { + std::string fileName = Lang::get("DOWNLOADING") + std::string(infoJson[Selection]["title"]); + + std::string titleFix = infoJson[Selection]["title"]; + for (int i = 0; i < (int)titleFix.size(); i++) { + if (titleFix[i] == '/') { + titleFix[i] = '-'; + } + } + Msg::DisplayMsg(fileName); + + downloadToFile(infoJson[Selection]["url"], Config::ScriptPath + titleFix + ".json"); + infoJson[Selection]["curRevision"] = infoJson[Selection]["revision"]; + } + } + + if (hDown & KEY_R) { + fastMode = true; + } + + if (hDown & KEY_L) { + fastMode = false; + } + + if (Config::viewMode == 0) { + if(Selection < screenPos) { + screenPos = Selection; + } else if (Selection > screenPos + ENTRIES_PER_SCREEN - 1) { + screenPos = Selection - ENTRIES_PER_SCREEN + 1; + } + } else if (Config::viewMode == 1) { + if(Selection < screenPosList) { + screenPosList = Selection; + } else if (Selection > screenPosList + ENTRIES_PER_LIST - 1) { + screenPosList = Selection - ENTRIES_PER_LIST + 1; } } } - } - - // Switch to Glossary and back. - if (hDown & KEY_RIGHT || hDown & KEY_LEFT) { - if (mode == 0) mode = 1; - else mode = 0; + // Switch to Glossary and back. + if (hDown & KEY_RIGHT || hDown & KEY_LEFT) { + if (mode == 0) mode = 1; + else mode = 0; + } } } \ No newline at end of file diff --git a/source/screens/scriptlist.cpp b/source/screens/scriptlist.cpp index 836fbf9..f7ba35e 100644 --- a/source/screens/scriptlist.cpp +++ b/source/screens/scriptlist.cpp @@ -243,8 +243,7 @@ void ScriptList::DrawList(void) const { GFX::DrawArrow(295, -1); GFX::DrawArrow(315, 240, 180.0); GFX::DrawArrow(0, 218, 0, 1); - GFX::DrawSpriteBlend(sprites_view_idx, arrowPos[3].x, arrowPos[3].y); - GFX::DrawSpriteBlend(sprites_delete_idx, arrowPos[4].x, arrowPos[4].y); + GFX::DrawSpriteBlend(sprites_dropdown_idx, arrowPos[3].x, arrowPos[3].y); if (Config::viewMode == 0) { for(int i=0;i 0) dropSelection--; + } + if (hDown & KEY_A) { + switch(dropSelection) { + case 0: + if (Msg::promptMsg(Lang::get("DELETE_SCRIPT"))) { + deleteScript(Selection); + } + break; + case 1: + if (Config::viewMode == 0) { + Config::viewMode = 1; + } else { + Config::viewMode = 0; + } + break; } - } else { + dropDownMenu = false; + } + + if (hDown & KEY_TOUCH) { + if (touching(touch, dropPos2[0])) { + if (Msg::promptMsg(Lang::get("DELETE_SCRIPT"))) { + deleteScript(Selection); + } + dropDownMenu = false; + } else if (touching(touch, dropPos2[1])) { + if (Config::viewMode == 0) { + Config::viewMode = 1; + } else { + Config::viewMode = 0; + } + dropDownMenu = false; + } + } + } else { + if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) { + fileInfo.clear(); + Selection = 0; + mode = 0; + } + + if ((hDown & KEY_SELECT) || (hDown & KEY_TOUCH && touching(touch, arrowPos[3]))) { + dropSelection = 0; + dropDownMenu = true; + } + + if (hDown & KEY_START) { + if (Config::autoboot == 2) { + if (Msg::promptMsg(Lang::get("DISABLE_AUTOBOOT"))) { + Config::autoboot = 0; + Config::AutobootFile = ""; + changesMade = true; + } + } else { + if (dirContents[Selection].isDirectory) { + } else if (fileInfo.size() != 0) { + if (ScriptHelper::checkIfValid(dirContents[Selection].name) == true) { + if (Msg::promptMsg(Lang::get("AUTOBOOT_SCRIPT"))) { + Config::AutobootFile = Config::ScriptPath + dirContents[Selection].name; + Config::autoboot = 2; + changesMade = true; + } + } + } + } + } + + if ((hHeld & KEY_DOWN && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[1]))) { + if (Selection < (int)fileInfo.size()-1) { + Selection++; + } else { + Selection = 0; + } + if (fastMode == true) { + keyRepeatDelay = 3; + } else if (fastMode == false){ + keyRepeatDelay = 6; + } + } + + if ((hHeld & KEY_UP && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[0]))) { + if (Selection > 0) { + Selection--; + } else { + Selection = (int)fileInfo.size()-1; + } + if (fastMode == true) { + keyRepeatDelay = 3; + } else if (fastMode == false){ + keyRepeatDelay = 6; + } + } + + if (hDown & KEY_TOUCH) { + if (Config::viewMode == 0) { + for(int i=0;i 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) { + currentFile = dirContents[screenPos + i].name; + selectedTitle = fileInfo[screenPos + i].title; + jsonFile = openScriptFile(); + Desc = Description(jsonFile); + checkForValidate(); + fileInfo2 = parseObjects(currentFile); + loadColors(jsonFile); + loadDesc(); + isScriptSelected = true; + Selection = 0; + mode = 2; + } + } + } + } + } else if (Config::viewMode == 1) { + 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) { + currentFile = dirContents[screenPosList + i].name; + selectedTitle = fileInfo[screenPosList + i].title; + jsonFile = openScriptFile(); + Desc = Description(jsonFile); + checkForValidate(); + fileInfo2 = parseObjects(currentFile); + loadColors(jsonFile); + loadDesc(); + isScriptSelected = true; + Selection = 0; + mode = 2; + } + } + } + } + } + } + + if (hDown & KEY_A) { if (dirContents[Selection].isDirectory) { } else if (fileInfo.size() != 0) { if (ScriptHelper::checkIfValid(dirContents[Selection].name) == true) { - if (Msg::promptMsg(Lang::get("AUTOBOOT_SCRIPT"))) { - Config::AutobootFile = Config::ScriptPath + dirContents[Selection].name; - Config::autoboot = 2; - changesMade = true; - } + currentFile = dirContents[Selection].name; + selectedTitle = fileInfo[Selection].title; + jsonFile = openScriptFile(); + Desc = Description(jsonFile); + checkForValidate(); + fileInfo2 = parseObjects(currentFile); + loadColors(jsonFile); + loadDesc(); + isScriptSelected = true; + Selection = 0; + mode = 2; } } } - } - if ((hHeld & KEY_DOWN && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[1]))) { - if (Selection < (int)fileInfo.size()-1) { - Selection++; - } else { - Selection = 0; + if (hDown & KEY_R) { + fastMode = true; } - if (fastMode == true) { - keyRepeatDelay = 3; - } else if (fastMode == false){ - keyRepeatDelay = 6; - } - } - if ((hDown & KEY_SELECT) || (hDown & KEY_TOUCH && touching(touch, arrowPos[4]))) { - if (Msg::promptMsg(Lang::get("DELETE_SCRIPT"))) { - deleteScript(Selection); - } - } - if ((hHeld & KEY_UP && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[0]))) { - if (Selection > 0) { - Selection--; - } else { - Selection = (int)fileInfo.size()-1; + if (hDown & KEY_L) { + fastMode = false; } - if (fastMode == true) { - keyRepeatDelay = 3; - } else if (fastMode == false){ - keyRepeatDelay = 6; - } - } - if (hDown & KEY_TOUCH) { if (Config::viewMode == 0) { - for(int i=0;i 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) { - currentFile = dirContents[screenPos + i].name; - selectedTitle = fileInfo[screenPos + i].title; - jsonFile = openScriptFile(); - Desc = Description(jsonFile); - checkForValidate(); - fileInfo2 = parseObjects(currentFile); - loadColors(jsonFile); - loadDesc(); - isScriptSelected = true; - Selection = 0; - mode = 2; - } - } - } + if(Selection < screenPos) { + screenPos = Selection; + } else if (Selection > screenPos + ENTRIES_PER_SCREEN - 1) { + screenPos = Selection - ENTRIES_PER_SCREEN + 1; } } else if (Config::viewMode == 1) { - 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) { - currentFile = dirContents[screenPosList + i].name; - selectedTitle = fileInfo[screenPosList + i].title; - jsonFile = openScriptFile(); - Desc = Description(jsonFile); - checkForValidate(); - fileInfo2 = parseObjects(currentFile); - loadColors(jsonFile); - loadDesc(); - isScriptSelected = true; - Selection = 0; - mode = 2; - } - } - } + if(Selection < screenPosList) { + screenPosList = Selection; + } else if (Selection > screenPosList + ENTRIES_PER_LIST - 1) { + screenPosList = Selection - ENTRIES_PER_LIST + 1; } } } - - if (hDown & KEY_A) { - if (dirContents[Selection].isDirectory) { - } else if (fileInfo.size() != 0) { - if (ScriptHelper::checkIfValid(dirContents[Selection].name) == true) { - currentFile = dirContents[Selection].name; - selectedTitle = fileInfo[Selection].title; - jsonFile = openScriptFile(); - Desc = Description(jsonFile); - checkForValidate(); - fileInfo2 = parseObjects(currentFile); - loadColors(jsonFile); - loadDesc(); - isScriptSelected = true; - Selection = 0; - mode = 2; - } - } - } - - if (hDown & KEY_R) { - fastMode = true; - } - - if (hDown & KEY_L) { - fastMode = false; - } - - if (Config::viewMode == 0) { - if(Selection < screenPos) { - screenPos = Selection; - } else if (Selection > screenPos + ENTRIES_PER_SCREEN - 1) { - screenPos = Selection - ENTRIES_PER_SCREEN + 1; - } - } else if (Config::viewMode == 1) { - if(Selection < screenPosList) { - screenPosList = Selection; - } else if (Selection > screenPosList + ENTRIES_PER_LIST - 1) { - screenPosList = Selection - ENTRIES_PER_LIST + 1; - } - } } void ScriptList::SelectFunction(u32 hDown, u32 hHeld, touchPosition touch) { if (keyRepeatDelay) keyRepeatDelay--; - if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) { - Selection = 0; - fileInfo2.clear(); - isScriptSelected = false; - refreshList(); - } + //DropDown Logic. + if (dropDownMenu) { + if ((hDown & KEY_SELECT) || (hDown & KEY_TOUCH && touching(touch, arrowPos[3]))) { + dropDownMenu = false; + } - if ((hHeld & KEY_DOWN && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[1]))) { - if (Selection < (int)fileInfo2.size()-1) { - Selection++; - } else { + if (hDown & KEY_A) { + if (Config::viewMode == 0) { + Config::viewMode = 1; + } else { + Config::viewMode = 0; + } + dropDownMenu = false; + } + + if (hDown & KEY_TOUCH) { + if (touching(touch, dropPos2[0])) { + if (Config::viewMode == 0) { + Config::viewMode = 1; + } else { + Config::viewMode = 0; + } + dropDownMenu = false; + } + } + } else { + if ((hDown & KEY_SELECT) || (hDown & KEY_TOUCH && touching(touch, arrowPos[3]))) { + dropSelection = 0; + dropDownMenu = true; + } + + if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) { Selection = 0; + fileInfo2.clear(); + isScriptSelected = false; + refreshList(); } - if (fastMode == true) { - keyRepeatDelay = 3; - } else if (fastMode == false){ - keyRepeatDelay = 6; - } - } - if ((hHeld & KEY_UP && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[0]))) { - if (Selection > 0) { - Selection--; - } else { - Selection = (int)fileInfo2.size()-1; + if ((hHeld & KEY_DOWN && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[1]))) { + if (Selection < (int)fileInfo2.size()-1) { + Selection++; + } else { + Selection = 0; + } + if (fastMode == true) { + keyRepeatDelay = 3; + } else if (fastMode == false){ + keyRepeatDelay = 6; + } } - if (fastMode == true) { - keyRepeatDelay = 3; - } else if (fastMode == false){ - keyRepeatDelay = 6; - } - } - if (hDown & KEY_TOUCH) { - if (Config::viewMode == 0) { - for(int i=0;i 40+(i*57) && touch.py < 40+(i*57)+45) { - if (fileInfo2.size() != 0) { - choice = fileInfo2[screenPos + i]; - if (Msg::promptMsg(Lang::get("EXECUTE_SCRIPT") + "\n\n" + choice)) { - runFunctions(jsonFile); + if ((hHeld & KEY_UP && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[0]))) { + if (Selection > 0) { + Selection--; + } else { + Selection = (int)fileInfo2.size()-1; + } + if (fastMode == true) { + keyRepeatDelay = 3; + } else if (fastMode == false){ + keyRepeatDelay = 6; + } + } + + if (hDown & KEY_TOUCH) { + if (Config::viewMode == 0) { + for(int i=0;i 40+(i*57) && touch.py < 40+(i*57)+45) { + if (fileInfo2.size() != 0) { + choice = fileInfo2[screenPos + i]; + if (Msg::promptMsg(Lang::get("EXECUTE_SCRIPT") + "\n\n" + choice)) { + runFunctions(jsonFile); + } } } } + } else if (Config::viewMode == 1) { + for(int i=0;i (i+1)*27 && touch.py < (i+2)*27) { + if (fileInfo2.size() != 0) { + choice = fileInfo2[screenPosList + i]; + if (Msg::promptMsg(Lang::get("EXECUTE_SCRIPT") + "\n\n" + choice)) { + runFunctions(jsonFile); + } + } + } + } + } + } + + if (hDown & KEY_A) { + if (fileInfo2.size() != 0) { + choice = fileInfo2[Selection]; + if (Msg::promptMsg(Lang::get("EXECUTE_SCRIPT") + "\n\n" + choice)) { + runFunctions(jsonFile); + } + } + } + + if (hDown & KEY_R) { + fastMode = true; + } + + if (hDown & KEY_L) { + fastMode = false; + } + + if (hDown & KEY_SELECT) { + Config::Color1 = barColor; + Config::Color2 = bgTopColor; + Config::Color3 = bgBottomColor; + Config::TxtColor = TextColor; + Config::SelectedColor = selected; + Config::UnselectedColor = unselected; + changesMade = true; + } + + if (Config::viewMode == 0) { + if(Selection < screenPos) { + screenPos = Selection; + } else if (Selection > screenPos + ENTRIES_PER_SCREEN - 1) { + screenPos = Selection - ENTRIES_PER_SCREEN + 1; } } else if (Config::viewMode == 1) { - for(int i=0;i (i+1)*27 && touch.py < (i+2)*27) { - if (fileInfo2.size() != 0) { - choice = fileInfo2[screenPosList + i]; - if (Msg::promptMsg(Lang::get("EXECUTE_SCRIPT") + "\n\n" + choice)) { - runFunctions(jsonFile); - } - } - } + if(Selection < screenPosList) { + screenPosList = Selection; + } else if (Selection > screenPosList + ENTRIES_PER_LIST - 1) { + screenPosList = Selection - ENTRIES_PER_LIST + 1; } } } - - if (hDown & KEY_A) { - if (fileInfo2.size() != 0) { - choice = fileInfo2[Selection]; - if (Msg::promptMsg(Lang::get("EXECUTE_SCRIPT") + "\n\n" + choice)) { - runFunctions(jsonFile); - } - } - } - - if (hDown & KEY_R) { - fastMode = true; - } - - if (hDown & KEY_L) { - fastMode = false; - } - - if (hDown & KEY_SELECT) { - Config::Color1 = barColor; - Config::Color2 = bgTopColor; - Config::Color3 = bgBottomColor; - Config::TxtColor = TextColor; - Config::SelectedColor = selected; - Config::UnselectedColor = unselected; - changesMade = true; - } - - if (Config::viewMode == 0) { - if(Selection < screenPos) { - screenPos = Selection; - } else if (Selection > screenPos + ENTRIES_PER_SCREEN - 1) { - screenPos = Selection - ENTRIES_PER_SCREEN + 1; - } - } else if (Config::viewMode == 1) { - if(Selection < screenPosList) { - screenPosList = Selection; - } else if (Selection > screenPosList + ENTRIES_PER_LIST - 1) { - screenPosList = Selection - ENTRIES_PER_LIST + 1; - } - } } void ScriptList::Logic(u32 hDown, u32 hHeld, touchPosition touch) { @@ -722,14 +837,6 @@ void ScriptList::Logic(u32 hDown, u32 hHeld, touchPosition touch) { SelectFunction(hDown, hHeld, touch); } - if ((hDown & KEY_X) || (hDown & KEY_TOUCH && touching(touch, arrowPos[3]))) { - if (Config::viewMode == 0) { - Config::viewMode = 1; - } else { - Config::viewMode = 0; - } - } - if (hDown & KEY_LEFT || hDown & KEY_RIGHT) { if (mode == 3) { mode = lastMode; diff --git a/source/screens/unistore.cpp b/source/screens/unistore.cpp index 82407ce..c72a768 100644 --- a/source/screens/unistore.cpp +++ b/source/screens/unistore.cpp @@ -279,9 +279,7 @@ void UniStore::DrawStoreList(void) const { GFX::DrawArrow(295, -1); GFX::DrawArrow(315, 240, 180.0); GFX::DrawArrow(0, 218, 0, 1); - GFX::DrawSpriteBlend(sprites_view_idx, arrowPos[3].x, arrowPos[3].y); - GFX::DrawSpriteBlend(sprites_delete_idx, arrowPos[4].x, arrowPos[4].y); - GFX::DrawSpriteBlend(sprites_update_idx, arrowPos[5].x, arrowPos[5].y); + GFX::DrawSpriteBlend(sprites_dropdown_idx, arrowPos[3].x, arrowPos[3].y); if (Config::viewMode == 0) { for(int i=0;i 0) { - Selection--; - descript(); - loadStoreDesc(); - } else { - Selection = (int)storeInfo.size()-1; - descript(); - loadStoreDesc(); - } - if (fastMode == true) { - keyRepeatDelay = 3; - } else if (fastMode == false){ - keyRepeatDelay = 6; - } - } - if ((hDown & KEY_Y) || (hDown & KEY_TOUCH && touching(touch, arrowPos[5]))) { - updateStore(Selection); - } + if (hDown & KEY_UP) { + if (dropSelection > 0) dropSelection--; + } - if (hDown & KEY_A) { - if (dirContents[Selection].isDirectory) { - } else if (storeInfo.size() != 0) { - if (ScriptHelper::checkIfValid(dirContents[Selection].name, 1) == true) { + if (hDown & KEY_A) { + switch(dropSelection) { + case 0: + if (Msg::promptMsg(Lang::get("DELETE_STORE"))) { + deleteStore(Selection); + } + break; + case 1: + updateStore(Selection); + break; + case 2: + if (Config::viewMode == 0) { + Config::viewMode = 1; + } else { + Config::viewMode = 0; + } + break; + } + dropDownMenu = false; + } + + if (hDown & KEY_TOUCH) { + if (touching(touch, dropPos2[0])) { + if (Msg::promptMsg(Lang::get("DELETE_STORE"))) { + deleteStore(Selection); + } + dropDownMenu = false; + } else if (touching(touch, dropPos2[1])) { updateStore(Selection); - currentStoreFile = dirContents[Selection].name; - Msg::DisplayMsg(Lang::get("PREPARE_STORE")); - if (storeInfo[Selection].storeSheet != "" || storeInfo[Selection].storeSheet != "MISSING: storeInfo.sheet") { - if(access(storeInfo[Selection].storeSheet.c_str(), F_OK) != -1 ) { - loadStoreSheet(Selection); - } + dropDownMenu = false; + } else if (touching(touch, dropPos2[2])) { + if (Config::viewMode == 0) { + Config::viewMode = 1; + } else { + Config::viewMode = 0; } - appStoreJson = openStoreFile(); - appStoreList = parseStoreObjects(currentStoreFile); - loadStoreColors(appStoreJson); + dropDownMenu = false; + } + } + } else { + if ((hDown & KEY_SELECT) || (hDown & KEY_TOUCH && touching(touch, arrowPos[3]))) { + dropSelection = 0; + dropDownMenu = true; + } + + if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) { + storeInfo.clear(); + Selection = 0; + mode = 0; + } + + if ((hHeld & KEY_DOWN && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[1]))) { + if (Selection < (int)storeInfo.size()-1) { + Selection++; + descript(); + loadStoreDesc(); + } else { Selection = 0; - displayInformations = handleIfDisplayText(); - isScriptSelected = true; - Selection = 0; - mode = 2; + descript(); + loadStoreDesc(); + } + if (fastMode == true) { + keyRepeatDelay = 3; + } else if (fastMode == false){ + keyRepeatDelay = 6; } } - } - - if (hDown & KEY_R) { - fastMode = true; - } - - if (hDown & KEY_L) { - fastMode = false; - } - - if (Config::viewMode == 0) { - if(Selection < screenPos) { - screenPos = Selection; - } else if (Selection > screenPos + ENTRIES_PER_SCREEN - 1) { - screenPos = Selection - ENTRIES_PER_SCREEN + 1; - } - } else if (Config::viewMode == 1) { - if(Selection < screenPosList) { - screenPosList = Selection; - } else if (Selection > screenPosList + ENTRIES_PER_LIST - 1) { - screenPosList = Selection - ENTRIES_PER_LIST + 1; - } - } - - if ((hDown & KEY_SELECT) || (hDown & KEY_TOUCH && touching(touch, arrowPos[4]))) { - if (Msg::promptMsg(Lang::get("DELETE_STORE"))) { - deleteStore(Selection); - } - } - - if (hDown & KEY_TOUCH) { - if (Config::viewMode == 0) { - for(int i=0;i 40+(i*57) && touch.py < 40+(i*57)+45) { - if (ScriptHelper::checkIfValid(dirContents[screenPos + i].name, 1) == true) { - updateStore(screenPos + i); - currentStoreFile = dirContents[screenPos + i].name; - Msg::DisplayMsg(Lang::get("PREPARE_STORE")); - if (storeInfo[screenPos + i].storeSheet != "" || storeInfo[screenPos + i].storeSheet != "MISSING: storeInfo.sheet") { - if(access(storeInfo[screenPos + i].storeSheet.c_str(), F_OK) != -1 ) { - loadStoreSheet(screenPos + i); - } - } - appStoreJson = openStoreFile(); - appStoreList = parseStoreObjects(currentStoreFile); - loadStoreColors(appStoreJson); - Selection = 0; - displayInformations = handleIfDisplayText(); - isScriptSelected = true; - mode = 2; - } - } + if ((hHeld & KEY_UP && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[0]))) { + if (Selection > 0) { + Selection--; + descript(); + loadStoreDesc(); + } else { + Selection = (int)storeInfo.size()-1; + descript(); + loadStoreDesc(); } - } else if (Config::viewMode == 1) { - for(int i=0;i (i+1)*27 && touch.py < (i+2)*27) { - if (ScriptHelper::checkIfValid(dirContents[screenPosList + i].name, 1) == true) { - updateStore(screenPosList + i); - currentStoreFile = dirContents[screenPosList + i].name; - Msg::DisplayMsg(Lang::get("PREPARE_STORE")); - if (storeInfo[screenPosList + i].storeSheet != "" || storeInfo[screenPosList + i].storeSheet != "MISSING: storeInfo.sheet") { - if(access(storeInfo[screenPosList + i].storeSheet.c_str(), F_OK) != -1 ) { - loadStoreSheet(screenPosList + i); - } - } - appStoreJson = openStoreFile(); - appStoreList = parseStoreObjects(currentStoreFile); - loadStoreColors(appStoreJson); - Selection = 0; - displayInformations = handleIfDisplayText(); - isScriptSelected = true; - mode = 2; - } - } + if (fastMode == true) { + keyRepeatDelay = 3; + } else if (fastMode == false){ + keyRepeatDelay = 6; } } - } - if (hDown & KEY_START) { - if (Config::autoboot == 1) { - if (Msg::promptMsg(Lang::get("DISABLE_AUTOBOOT"))) { - Config::autoboot = 0; - Config::AutobootFile = ""; - changesMade = true; - } - } else { + if (hDown & KEY_A) { if (dirContents[Selection].isDirectory) { } else if (storeInfo.size() != 0) { if (ScriptHelper::checkIfValid(dirContents[Selection].name, 1) == true) { - if (Msg::promptMsg(Lang::get("AUTOBOOT_STORE"))) { - Config::AutobootFile = Config::StorePath + dirContents[Selection].name; - Config::autoboot = 1; - changesMade = true; + updateStore(Selection); + currentStoreFile = dirContents[Selection].name; + Msg::DisplayMsg(Lang::get("PREPARE_STORE")); + if (storeInfo[Selection].storeSheet != "" || storeInfo[Selection].storeSheet != "MISSING: storeInfo.sheet") { + if(access(storeInfo[Selection].storeSheet.c_str(), F_OK) != -1 ) { + loadStoreSheet(Selection); + } + } + appStoreJson = openStoreFile(); + appStoreList = parseStoreObjects(currentStoreFile); + loadStoreColors(appStoreJson); + Selection = 0; + displayInformations = handleIfDisplayText(); + isScriptSelected = true; + Selection = 0; + mode = 2; + } + } + } + + if (hDown & KEY_R) { + fastMode = true; + } + + if (hDown & KEY_L) { + fastMode = false; + } + + if (Config::viewMode == 0) { + if(Selection < screenPos) { + screenPos = Selection; + } else if (Selection > screenPos + ENTRIES_PER_SCREEN - 1) { + screenPos = Selection - ENTRIES_PER_SCREEN + 1; + } + } else if (Config::viewMode == 1) { + if(Selection < screenPosList) { + screenPosList = Selection; + } else if (Selection > screenPosList + ENTRIES_PER_LIST - 1) { + screenPosList = Selection - ENTRIES_PER_LIST + 1; + } + } + + if (hDown & KEY_TOUCH) { + if (Config::viewMode == 0) { + for(int i=0;i 40+(i*57) && touch.py < 40+(i*57)+45) { + if (ScriptHelper::checkIfValid(dirContents[screenPos + i].name, 1) == true) { + updateStore(screenPos + i); + currentStoreFile = dirContents[screenPos + i].name; + Msg::DisplayMsg(Lang::get("PREPARE_STORE")); + if (storeInfo[screenPos + i].storeSheet != "" || storeInfo[screenPos + i].storeSheet != "MISSING: storeInfo.sheet") { + if(access(storeInfo[screenPos + i].storeSheet.c_str(), F_OK) != -1 ) { + loadStoreSheet(screenPos + i); + } + } + appStoreJson = openStoreFile(); + appStoreList = parseStoreObjects(currentStoreFile); + loadStoreColors(appStoreJson); + Selection = 0; + displayInformations = handleIfDisplayText(); + isScriptSelected = true; + mode = 2; + } + } + } + } else if (Config::viewMode == 1) { + for(int i=0;i (i+1)*27 && touch.py < (i+2)*27) { + if (ScriptHelper::checkIfValid(dirContents[screenPosList + i].name, 1) == true) { + updateStore(screenPosList + i); + currentStoreFile = dirContents[screenPosList + i].name; + Msg::DisplayMsg(Lang::get("PREPARE_STORE")); + if (storeInfo[screenPosList + i].storeSheet != "" || storeInfo[screenPosList + i].storeSheet != "MISSING: storeInfo.sheet") { + if(access(storeInfo[screenPosList + i].storeSheet.c_str(), F_OK) != -1 ) { + loadStoreSheet(screenPosList + i); + } + } + appStoreJson = openStoreFile(); + appStoreList = parseStoreObjects(currentStoreFile); + loadStoreColors(appStoreJson); + Selection = 0; + displayInformations = handleIfDisplayText(); + isScriptSelected = true; + mode = 2; + } + } + } + } + } + + if (hDown & KEY_START) { + if (Config::autoboot == 1) { + if (Msg::promptMsg(Lang::get("DISABLE_AUTOBOOT"))) { + Config::autoboot = 0; + Config::AutobootFile = ""; + changesMade = true; + } + } else { + if (dirContents[Selection].isDirectory) { + } else if (storeInfo.size() != 0) { + if (ScriptHelper::checkIfValid(dirContents[Selection].name, 1) == true) { + if (Msg::promptMsg(Lang::get("AUTOBOOT_STORE"))) { + Config::AutobootFile = Config::StorePath + dirContents[Selection].name; + Config::autoboot = 1; + changesMade = true; + } } } } @@ -765,96 +851,133 @@ void UniStore::StoreSelectionLogic(u32 hDown, u32 hHeld, touchPosition touch) { void UniStore::StoreLogic(u32 hDown, u32 hHeld, touchPosition touch) { if (keyRepeatDelay) keyRepeatDelay--; - if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) { - Selection = 0; - refreshList(); - mode = 1; - appStoreList.clear(); - isScriptSelected = false; - freeSheet(); - } - - if (hDown & KEY_R) { - fastMode = true; - } - - if (hDown & KEY_L) { - fastMode = false; - } - - // Go one entry up. - if ((hHeld & KEY_UP && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[0]))) { - if (Selection > 0) { - Selection--; - } else { - Selection = (int)appStoreJson.at("storeContent").size()-1; + //DropDown Logic. + if (dropDownMenu) { + if ((hDown & KEY_SELECT) || (hDown & KEY_TOUCH && touching(touch, arrowPos[3]))) { + dropDownMenu = false; } - if (fastMode == true) { - keyRepeatDelay = 3; - } else if (fastMode == false){ - keyRepeatDelay = 6; + if (hDown & KEY_DOWN) { + if (dropSelection < 1) dropSelection++; + } + if (hDown & KEY_UP) { + if (dropSelection > 0) dropSelection--; + } + if (hDown & KEY_A) { + if (Config::viewMode == 0) { + Config::viewMode = 1; + } else { + Config::viewMode = 0; + } + dropDownMenu = false; } - } - // Go one entry down. - if ((hHeld & KEY_DOWN && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[1]))) { - if (Selection < (int)appStoreJson.at("storeContent").size()-1) { - Selection++; - } else { + if (hDown & KEY_TOUCH) { + if (touching(touch, dropPos2[0])) { + if (Config::viewMode == 0) { + Config::viewMode = 1; + } else { + Config::viewMode = 0; + } + dropDownMenu = false; + } + } + } else { + if ((hDown & KEY_SELECT) || (hDown & KEY_TOUCH && touching(touch, arrowPos[3]))) { + dropSelection = 0; + dropDownMenu = true; + } + + if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) { Selection = 0; + refreshList(); + mode = 1; + appStoreList.clear(); + isScriptSelected = false; + freeSheet(); } - if (fastMode == true) { - keyRepeatDelay = 3; - } else if (fastMode == false){ - keyRepeatDelay = 6; - } - } - // Execute touched Entry. - if (hDown & KEY_TOUCH) { - if (Config::viewMode == 0) { - for(int i=0;i 40+(i*57) && touch.py < 40+(i*57)+45) { - Selection = screenPos + i; - std::string info = appStoreJson["storeContent"][Selection]["info"]["title"]; - if (Msg::promptMsg(Lang::get("EXECUTE_STORE") + "\n\n" + info)) { - execute(); + if (hDown & KEY_R) { + fastMode = true; + } + + if (hDown & KEY_L) { + fastMode = false; + } + + // Go one entry up. + if ((hHeld & KEY_UP && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[0]))) { + if (Selection > 0) { + Selection--; + } else { + Selection = (int)appStoreJson.at("storeContent").size()-1; + } + if (fastMode == true) { + keyRepeatDelay = 3; + } else if (fastMode == false){ + keyRepeatDelay = 6; + } + } + + // Go one entry down. + if ((hHeld & KEY_DOWN && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[1]))) { + if (Selection < (int)appStoreJson.at("storeContent").size()-1) { + Selection++; + } else { + Selection = 0; + } + if (fastMode == true) { + keyRepeatDelay = 3; + } else if (fastMode == false){ + keyRepeatDelay = 6; + } + } + + // Execute touched Entry. + if (hDown & KEY_TOUCH) { + if (Config::viewMode == 0) { + for(int i=0;i 40+(i*57) && touch.py < 40+(i*57)+45) { + Selection = screenPos + i; + std::string info = appStoreJson["storeContent"][Selection]["info"]["title"]; + if (Msg::promptMsg(Lang::get("EXECUTE_STORE") + "\n\n" + info)) { + execute(); + } } } + } else if (Config::viewMode == 1) { + for(int i=0;i (i+1)*27 && touch.py < (i+2)*27) { + Selection = screenPosList + i; + std::string info = appStoreJson["storeContent"][Selection]["info"]["title"]; + if (Msg::promptMsg(Lang::get("EXECUTE_STORE") + "\n\n" + info)) { + execute(); + } + } + } + } + } + // Execute that Entry. + if (hDown & KEY_A) { + std::string info = appStoreJson["storeContent"][Selection]["info"]["title"]; + if (Msg::promptMsg(Lang::get("EXECUTE_STORE") + "\n\n" + info)) { + execute(); + } + } + + if (Config::viewMode == 0) { + if(Selection < screenPos) { + screenPos = Selection; + } else if (Selection > screenPos + ENTRIES_PER_SCREEN - 1) { + screenPos = Selection - ENTRIES_PER_SCREEN + 1; } } else if (Config::viewMode == 1) { - for(int i=0;i (i+1)*27 && touch.py < (i+2)*27) { - Selection = screenPosList + i; - std::string info = appStoreJson["storeContent"][Selection]["info"]["title"]; - if (Msg::promptMsg(Lang::get("EXECUTE_STORE") + "\n\n" + info)) { - execute(); - } - } + if(Selection < screenPosList) { + screenPosList = Selection; + } else if (Selection > screenPosList + ENTRIES_PER_LIST - 1) { + screenPosList = Selection - ENTRIES_PER_LIST + 1; } } } - // Execute that Entry. - if (hDown & KEY_A) { - std::string info = appStoreJson["storeContent"][Selection]["info"]["title"]; - if (Msg::promptMsg(Lang::get("EXECUTE_STORE") + "\n\n" + info)) { - execute(); - } - } - - if (Config::viewMode == 0) { - if(Selection < screenPos) { - screenPos = Selection; - } else if (Selection > screenPos + ENTRIES_PER_SCREEN - 1) { - screenPos = Selection - ENTRIES_PER_SCREEN + 1; - } - } else if (Config::viewMode == 1) { - if(Selection < screenPosList) { - screenPosList = Selection; - } else if (Selection > screenPosList + ENTRIES_PER_LIST - 1) { - screenPosList = Selection - ENTRIES_PER_LIST + 1; - } - } } void UniStore::Logic(u32 hDown, u32 hHeld, touchPosition touch) { @@ -872,15 +995,6 @@ void UniStore::Logic(u32 hDown, u32 hHeld, touchPosition touch) { GitHubLogic(hDown, hHeld, touch); } - // Switch ViewMode. - if (((mode != 0 || mode != 3) && (hDown & KEY_X)) || ((mode != 0 || mode != 3) && (hDown & KEY_TOUCH && touching(touch, arrowPos[3])))) { - if (Config::viewMode == 0) { - Config::viewMode = 1; - } else { - Config::viewMode = 0; - } - } - if (hDown & KEY_LEFT || hDown & KEY_RIGHT) { if (mode == 6) { mode = lastMode;