diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0005189..ddaebdd 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,7 +1,7 @@ trigger: branches: include: ['*'] - exclude: [translation, App-Store, Camera] + exclude: [translation, cleanup] tags: include: ['*'] diff --git a/include/screens/ftpScreen.hpp b/include/screens/ftpScreen.hpp index 87b5003..2609ac8 100644 --- a/include/screens/ftpScreen.hpp +++ b/include/screens/ftpScreen.hpp @@ -28,6 +28,8 @@ #include "utils/structs.hpp" +#include + class FTPScreen : public screen { public: diff --git a/include/screens/mainMenu.hpp b/include/screens/mainMenu.hpp index 4a84486..4cc9627 100644 --- a/include/screens/mainMenu.hpp +++ b/include/screens/mainMenu.hpp @@ -29,7 +29,6 @@ #include "screens/screen.hpp" -#include "utils/fileBrowse.h" #include "utils/structs.hpp" #include @@ -40,17 +39,13 @@ public: void Draw(void) const override; void Logic(u32 hDown, u32 hHeld, touchPosition touch) override; private: - bool returnScriptState(); - bool returnStoreState(); int Selection = 0; - std::vector dirContents; // To return Script/Store state. - std::vector mainButtons = { - {10, 40, 140, 35, -1}, // Scriptlist. - {170, 40, 140, 35, -1}, // ScriptBrowse. - {10, 100, 140, 35, -1}, // TinyDB. - {170, 100, 140, 35, -1}, // ScriptCreator. - {10, 160, 140, 35, -1}, // Language. - {170, 160, 140, 35, -1}, // Colors. + + std::vector mainButtons = { + {10, 70, 140, 40, -1}, // Scripts. + {170, 70, 140, 40, -1}, // UniStore. + {10, 145, 140, 40, -1}, // Settings. + {170, 145, 140, 40, -1}, // FTP. {0, 215, 25, 25, -1}, // Back Arrow. }; }; diff --git a/include/screens/scriptlist.hpp b/include/screens/scriptlist.hpp index cb2c683..96e2409 100644 --- a/include/screens/scriptlist.hpp +++ b/include/screens/scriptlist.hpp @@ -38,16 +38,17 @@ class ScriptList : public screen public: void Draw(void) const override; void Logic(u32 hDown, u32 hHeld, touchPosition touch) override; - ScriptList(); - private: + void DrawSubMenu(void) const; void DrawList(void) const; void DrawSingleObject(void) const; + void SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch); void ListSelection(u32 hDown, u32 hHeld, touchPosition touch); void SelectFunction(u32 hDown, u32 hHeld, touchPosition touch); int mode = 0; + int SubSelection = 0; std::vector dirContents; mutable int screenPos = 0; mutable int screenPosList = 0; @@ -64,6 +65,14 @@ private: {295, 215, 25, 25, -1}, // Arrow Down. {0, 215, 25, 25, -1}, // Back Arrow. {5, 0, 25, 25, -1}, // viewMode Change + {45, 0, 25, 25, -1}, // Search. + }; + + std::vector subPos = { + {10, 70, 140, 40, -1}, // Script list. + {170, 70, 140, 40, -1}, // Get Scripts. + {10, 145, 140, 40, -1}, // Script Creator. + {170, 145, 140, 40, -1}, // Script path change. }; }; diff --git a/include/screens/unistore.hpp b/include/screens/unistore.hpp index 7c1bff6..4a6a8d1 100644 --- a/include/screens/unistore.hpp +++ b/include/screens/unistore.hpp @@ -38,13 +38,13 @@ class UniStore : public screen public: void Draw(void) const override; void Logic(u32 hDown, u32 hHeld, touchPosition touch) override; - UniStore(); - private: + void DrawSubMenu(void) const; void DrawStoreList(void) const; void DrawStore(void) const; void DrawSearch(void) const; + void SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch); void StoreSelectionLogic(u32 hDown, u32 hHeld, touchPosition touch); void StoreLogic(u32 hDown, u32 hHeld, touchPosition touch); void SearchLogic(u32 hDown, u32 hHeld, touchPosition touch); @@ -61,6 +61,7 @@ private: mutable int screenPosList2 = 0; int searchSelection = 0; + int subSelection = 0; int keyRepeatDelay = 0; int fastMode = false; @@ -79,6 +80,12 @@ private: {10, 100, 140, 35, -1}, // FULL URL. {170, 100, 140, 35, -1}, // Github. }; + + std::vector subPos = { + {90, 40, 140, 35, -1}, // StoreList. + {90, 100, 140, 35, -1}, // storeSearch. + {90, 160, 140, 35, -1}, // storePathChange. + }; }; #endif \ No newline at end of file diff --git a/include/utils/fileBrowse.h b/include/utils/fileBrowse.h index 6b7a777..3cef0ba 100644 --- a/include/utils/fileBrowse.h +++ b/include/utils/fileBrowse.h @@ -28,6 +28,8 @@ void getDirectoryContents(std::vector& dirContents, const std::vector< void getDirectoryContents(std::vector& dirContents); std::vector getContents(const std::string &name, const std::vector &extensionList); +bool returnIfExist(const std::string &path, const std::vector &extensionList); + std::string selectFilePath(std::string selectText, const std::vector &extensionList, int selectionMode = 1); #endif //FILE_BROWSE_H \ No newline at end of file diff --git a/romfs/lang/en/app.json b/romfs/lang/en/app.json index e5db832..5a394fc 100644 --- a/romfs/lang/en/app.json +++ b/romfs/lang/en/app.json @@ -9,6 +9,7 @@ "FILES_EXTRACTED": "files extracted.", "SCRIPTLIST": "Script list", + "SCRIPTS": "Scripts", "SETTINGS": "Settings", "LANGUAGE": "Language", "COLORS": "Colors", @@ -81,7 +82,7 @@ "FILEBROWSE_MSG": "Press X to select, Select to refresh.", "SELECT_SCRIPT_PATH": "Select the Script Path.", - "USE_BARS": "Use bar images:", + "CHANGE_BAR_STYLE": "Change bar style", "CHANGE_SCRIPTPATH": "Change Script path", "CHANGE_MUSICFILE": "Change Music file", "SELECT_MUSIC_FILE": "Select the Music file.", @@ -101,5 +102,9 @@ "UNISTORE_SEARCH": "UniStore search", "FULL_URL": "Full URL", "GITHUB": "GitHub", - "ENTER_FULL_URL": "Enter the full URL." + "ENTER_FULL_URL": "Enter the full URL.", + "SCRIPTS_SUBMENU": "Scripts Submenu", + "STORE_LIST": "Store list", + "STORE_SEARCH": "Store search", + "UNISTORE_SUBMENU": "UniStore SubMenu" } diff --git a/source/screens/mainMenu.cpp b/source/screens/mainMenu.cpp index be8a20e..9d4a147 100644 --- a/source/screens/mainMenu.cpp +++ b/source/screens/mainMenu.cpp @@ -24,29 +24,18 @@ * reasonable ways as different from the original version. */ -#include "download/download.hpp" - #include "screens/ftpScreen.hpp" #include "screens/mainMenu.hpp" -#include "screens/scriptBrowse.hpp" -#include "screens/scriptCreator.hpp" #include "screens/scriptlist.hpp" #include "screens/settings.hpp" #include "screens/unistore.hpp" #include "utils/config.hpp" -#include - extern bool exiting; extern bool touching(touchPosition touch, Structs::ButtonPos button); -extern bool checkWifiStatus(void); extern int fadealpha; extern bool fadein; -extern void notImplemented(void); - -// This is for the Script Creator, so no one can access it for now, until it is stable or so. -bool isTesting = false; void MainMenu::Draw(void) const { Gui::DrawTop(); @@ -63,7 +52,7 @@ void MainMenu::Draw(void) const { Gui::DrawBottom(); Gui::DrawArrow(0, 218, 0, 1); - for (int i = 0; i < 6; i++) { + for (int i = 0; i < 4; i++) { if (Selection == i) { Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, Config::SelectedColor); } else { @@ -71,149 +60,58 @@ void MainMenu::Draw(void) const { } } + Gui::DrawString((320-Gui::GetStringWidth(0.6f, "UniStore"))/2-150+70+10, mainButtons[0].y+12, 0.6f, Config::TxtColor, "UniStore", 140); + Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("SCRIPTS")))/2+150-70, mainButtons[1].y+12, 0.6f, Config::TxtColor, Lang::get("SCRIPTS"), 140); + Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("SETTINGS")))/2-150+70, mainButtons[2].y+12, 0.6f, Config::TxtColor, Lang::get("SETTINGS"), 140); + Gui::DrawString((320-Gui::GetStringWidth(0.6f, "FTP"))/2+150-70, mainButtons[3].y+12, 0.6f, Config::TxtColor, "FTP", 140); + // Draw UniStore Icon. ;P - Gui::sprite(sprites_uniStore_idx, 15, 95); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("SCRIPTLIST")))/2-150+70, mainButtons[0].y+10, 0.6f, Config::TxtColor, Lang::get("SCRIPTLIST"), 140); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("GET_SCRIPTS")))/2+150-70, mainButtons[1].y+10, 0.6f, Config::TxtColor, Lang::get("GET_SCRIPTS"), 140); - Gui::DrawString(80, mainButtons[2].y+10, 0.6f, Config::TxtColor, "UniStore", 140); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("SCRIPTCREATOR")))/2+150-70, mainButtons[3].y+10, 0.6f, Config::TxtColor, Lang::get("SCRIPTCREATOR"), 140); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("SETTINGS")))/2-150+70, mainButtons[4].y+10, 0.6f, Config::TxtColor, Lang::get("SETTINGS"), 140); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, "FTP"))/2+150-70, mainButtons[5].y+10, 0.6f, Config::TxtColor, "FTP", 140); + Gui::sprite(sprites_uniStore_idx, 10, 65); if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(0, 0, 0, fadealpha)); // Fade in out effect } -bool MainMenu::returnScriptState() { - dirContents.clear(); - chdir(Config::ScriptPath.c_str()); - std::vector dirContentsTemp; - getDirectoryContents(dirContentsTemp, {"json"}); - for(uint i=0;i dirContentsTemp; - getDirectoryContents(dirContentsTemp, {"unistore"}); - for(uint i=0;i 1) Selection -= 2; - } - if (hDown & KEY_DOWN) { - if(Selection < 4) Selection += 2; - } - if (hDown & KEY_LEFT) { + } else if(hDown & KEY_DOWN) { + if(Selection < 3 && Selection != 2 && Selection != 3) Selection += 2; + } else if (hDown & KEY_LEFT) { if (Selection%2) Selection--; - } - if (hDown & KEY_RIGHT) { + } else if (hDown & KEY_RIGHT) { if (!(Selection%2)) Selection++; } if (hDown & KEY_A) { switch(Selection) { case 0: - if (returnScriptState() == true) { - Screen::set(std::make_unique()); - } else { - Gui::DisplayWarnMsg(Lang::get("GET_SCRIPTS_FIRST")); - } + Screen::set(std::make_unique()); break; case 1: - if (checkWifiStatus() == true) { - Screen::set(std::make_unique()); - } else { - notConnectedMsg(); - } + Screen::set(std::make_unique()); break; case 2: - if (returnStoreState() == true) { - Screen::set(std::make_unique()); - } else { - Gui::DisplayWarnMsg(Lang::get("GET_STORES_FIRST")); - } - break; - case 3: - if (isTesting == true) { - Screen::set(std::make_unique()); - } else { - notImplemented(); - } - break; - case 4: Screen::set(std::make_unique()); break; - case 5: - if (checkWifiStatus() == true) { - Screen::set(std::make_unique()); - } else { - notConnectedMsg(); - } + case 3: + Screen::set(std::make_unique()); break; } } - if (hDown & KEY_X) { - if (checkWifiStatus() == true) { - Screen::set(std::make_unique()); - } - } - - if (hDown & KEY_TOUCH) { if (touching(touch, mainButtons[0])) { - if (returnScriptState() == true) { - Screen::set(std::make_unique()); - } else { - Gui::DisplayWarnMsg(Lang::get("GET_SCRIPTS_FIRST")); - } + Screen::set(std::make_unique()); } else if (touching(touch, mainButtons[1])) { - if (checkWifiStatus() == true) { - Screen::set(std::make_unique()); - } else { - notConnectedMsg(); - } + Screen::set(std::make_unique()); } else if (touching(touch, mainButtons[2])) { - if (returnStoreState() == true) { - Screen::set(std::make_unique()); - } else { - Gui::DisplayWarnMsg(Lang::get("GET_STORES_FIRST")); - } - } else if (touching(touch, mainButtons[3])) { - if (isTesting == true) { - Screen::set(std::make_unique()); - } else { - notImplemented(); - } - } else if (touching(touch, mainButtons[4])) { Screen::set(std::make_unique()); - } else if (touching(touch, mainButtons[5])) { - if (checkWifiStatus() == true) { - Screen::set(std::make_unique()); - } else { - notConnectedMsg(); - } - } else if (touching(touch, mainButtons[6])) { - exiting = true; + } else if (touching(touch, mainButtons[3])) { + Screen::set(std::make_unique()); } } } \ No newline at end of file diff --git a/source/screens/scriptlist.cpp b/source/screens/scriptlist.cpp index 84f54bd..5419ff6 100644 --- a/source/screens/scriptlist.cpp +++ b/source/screens/scriptlist.cpp @@ -26,6 +26,8 @@ #include "download/download.hpp" +#include "screens/scriptBrowse.hpp" +#include "screens/scriptCreator.hpp" #include "screens/scriptlist.hpp" #include "utils/config.hpp" @@ -37,6 +39,11 @@ #include extern bool touching(touchPosition touch, Structs::ButtonPos button); +extern bool checkWifiStatus(void); +extern void notImplemented(void); + +// This is for the Script Creator, so no one can access it for now, until it is stable or so. +bool isTesting = false; bool isScriptSelected = false; @@ -262,15 +269,32 @@ void loadColors(nlohmann::json &json) { progressBar = colorTemp == 0 ? Config::progressbarColor : colorTemp; } -ScriptList::ScriptList() { - dirContents.clear(); - chdir(Config::ScriptPath.c_str()); - getDirectoryContents(dirContents, {"json"}); - for(uint i=0;i 1) SubSelection -= 2; + } else if(hDown & KEY_DOWN) { + if(SubSelection < 3 && SubSelection != 2 && SubSelection != 3) SubSelection += 2; + } else if (hDown & KEY_LEFT) { + if (SubSelection%2) SubSelection--; + } else if (hDown & KEY_RIGHT) { + if (!(SubSelection%2)) SubSelection++; + } + + if (hDown & KEY_A) { + switch(SubSelection) { + case 0: + if (returnIfExist(Config::ScriptPath, {"json"}) == true) { + dirContents.clear(); + chdir(Config::ScriptPath.c_str()); + getDirectoryContents(dirContents, {"json"}); + for(uint i=0;i()); + } else { + notConnectedMsg(); + } + break; + case 2: + if (isTesting == true) { + Screen::set(std::make_unique()); + } else { + notImplemented(); + } + break; + case 3: + std::string tempScript = selectFilePath(Lang::get("SELECT_SCRIPT_PATH"), {}); + if (tempScript != "") { + Config::ScriptPath = tempScript; + } + break; + } + } + + if (hDown & KEY_TOUCH) { + if (touching(touch, subPos[0])) { + if (returnIfExist(Config::ScriptPath, {"json"}) == true) { + dirContents.clear(); + chdir(Config::ScriptPath.c_str()); + getDirectoryContents(dirContents, {"json"}); + for(uint i=0;i()); + } else { + notConnectedMsg(); + } + } else if (touching(touch, subPos[2])) { + if (isTesting == true) { + Screen::set(std::make_unique()); + } else { + notImplemented(); + } + } else if (touching(touch, subPos[3])) { + std::string tempScript = selectFilePath(Lang::get("SELECT_SCRIPT_PATH"), {}); + if (tempScript != "") { + Config::ScriptPath = tempScript; + } + } + } +} + void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) { if (keyRepeatDelay) keyRepeatDelay--; if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) { fileInfo.clear(); - Screen::back(); - return; + mode = 0; } if ((hHeld & KEY_DOWN && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[1]))) { @@ -431,7 +546,7 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) { loadDesc(); isScriptSelected = true; selection = 0; - mode = 1; + mode = 2; } } } @@ -452,7 +567,7 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) { loadDesc(); isScriptSelected = true; selection = 0; - mode = 1; + mode = 2; } } } @@ -474,7 +589,7 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) { loadDesc(); isScriptSelected = true; selection = 0; - mode = 1; + mode = 2; } } } @@ -509,7 +624,7 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld, touchPosition touch) { selection2 = 0; fileInfo2.clear(); isScriptSelected = false; - mode = 0; + mode = 1; } if ((hHeld & KEY_DOWN && !keyRepeatDelay) || (hDown & KEY_TOUCH && touching(touch, arrowPos[1]))) { @@ -603,8 +718,10 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld, touchPosition touch) { void ScriptList::Logic(u32 hDown, u32 hHeld, touchPosition touch) { if (mode == 0) { - ListSelection(hDown, hHeld, touch); + SubMenuLogic(hDown, hHeld, touch); } else if (mode == 1) { + ListSelection(hDown, hHeld, touch); + } else if (mode == 2) { SelectFunction(hDown, hHeld, touch); } diff --git a/source/screens/settings.cpp b/source/screens/settings.cpp index 3fd12fc..2000f4c 100644 --- a/source/screens/settings.cpp +++ b/source/screens/settings.cpp @@ -137,23 +137,19 @@ void Settings::DrawColorChanging(void) const { Gui::DrawArrow(0, 0, 0, 1); Gui::DrawArrow(318, 22, 180.0, 1); - for (int i = 0; i < 8; i++) { + for (int i = 0; i < 7; i++) { if (colorMode == i) { Gui::Draw_Rect(54 + i * 25, 2, 16, 16, C2D_Color32(140, 140, 140, 255)); } } - for (int i = 0; i < 8; i++) { + for (int i = 0; i < 7; i++) { Gui::DrawString(58 + i * 25, 2, 0.5f, WHITE, std::to_string(i+1), 400); } - if (colorMode != 7) { - Gui::Draw_Rect(buttons[0].x, buttons[0].y, 95, 41, C2D_Color32(255, 0, 0, 255)); - Gui::Draw_Rect(buttons[1].x, buttons[1].y, 95, 41, C2D_Color32(0, 255, 0, 255)); - Gui::Draw_Rect(buttons[2].x, buttons[2].y, 95, 41, C2D_Color32(0, 0, 255, 255)); - } else { - Gui::Draw_Rect(buttons[1].x, buttons[1].y, 95, 41, Config::Color1); - } + Gui::Draw_Rect(buttons[0].x, buttons[0].y, 95, 41, C2D_Color32(255, 0, 0, 255)); + Gui::Draw_Rect(buttons[1].x, buttons[1].y, 95, 41, C2D_Color32(0, 255, 0, 255)); + Gui::Draw_Rect(buttons[2].x, buttons[2].y, 95, 41, C2D_Color32(0, 0, 255, 255)); if (colorMode == 0) { Gui::DrawStringCentered(0, 60, 0.7f, Config::TxtColor, Lang::get("BAR_COLOR"), 320); @@ -190,10 +186,6 @@ void Settings::DrawColorChanging(void) const { Gui::DrawString(40, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::progressbarColor, 2).c_str(), 400); Gui::DrawString(140, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::progressbarColor, 1).c_str(), 400); Gui::DrawString(245, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::progressbarColor, 0).c_str(), 400); - } else if (colorMode == 7) { - Gui::DrawStringCentered(0, 60, 0.7f, Config::TxtColor, Lang::get("USE_BARS"), 320); - if (Config::UseBars == true) Gui::DrawString(140, 98, 0.7f, WHITE, Lang::get("YES"), 400); - else if (Config::UseBars == false) Gui::DrawString(140, 98, 0.7f, WHITE, Lang::get("NO"), 400); } } @@ -245,7 +237,7 @@ void Settings::DrawMiscSettings(void) const { Gui::DrawBottom(); Gui::DrawArrow(0, 218, 0, 1); - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 2; i++) { if (Selection == i) { Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, Config::SelectedColor); } else { @@ -253,9 +245,8 @@ void Settings::DrawMiscSettings(void) const { } } - Gui::DrawStringCentered(0, mainButtons[0].y+10, 0.6f, Config::TxtColor, Lang::get("CHANGE_STOREPATH"), 140); - Gui::DrawStringCentered(0, mainButtons[1].y+10, 0.6f, Config::TxtColor, Lang::get("CHANGE_SCRIPTPATH"), 140); - Gui::DrawStringCentered(0, mainButtons[2].y+10, 0.6f, Config::TxtColor, Lang::get("CHANGE_MUSICFILE"), 140); + Gui::DrawStringCentered(0, mainButtons[0].y+10, 0.6f, Config::TxtColor, Lang::get("CHANGE_MUSICFILE"), 140); + Gui::DrawStringCentered(0, mainButtons[1].y+10, 0.6f, Config::TxtColor, Lang::get("CHANGE_BAR_STYLE"), 140); } void Settings::MiscSettingsLogic(u32 hDown, u32 hHeld, touchPosition touch) { @@ -264,44 +255,30 @@ void Settings::MiscSettingsLogic(u32 hDown, u32 hHeld, touchPosition touch) { } if (hDown & KEY_DOWN) { - if (Selection < 2) Selection++; + if (Selection < 1) Selection++; } if (hDown & KEY_A) { if (Selection == 0) { - std::string tempStore = selectFilePath(Lang::get("SELECT_STORE_PATH"), {}); - if (tempStore != "") { - Config::StorePath = tempStore; - } - } else if (Selection == 1) { - std::string tempScript = selectFilePath(Lang::get("SELECT_SCRIPT_PATH"), {}); - if (tempScript != "") { - Config::ScriptPath = tempScript; - } - } else if (Selection == 2) { std::string tempMusic = selectFilePath(Lang::get("SELECT_MUSIC_FILE"), {"wav"}, 2); if (tempMusic != "") { Config::MusicPath = tempMusic; } + } else if (Selection == 1) { + if (Config::UseBars == true) Config::UseBars = false; + else if (Config::UseBars == false) Config::UseBars = true; } } if (hDown & KEY_TOUCH) { if (touching(touch, mainButtons[0])) { - std::string tempStore = selectFilePath(Lang::get("SELECT_STORE_PATH"), {}); - if (tempStore != "") { - Config::StorePath = tempStore; - } - } else if (touching(touch, mainButtons[1])) { - std::string tempScript = selectFilePath(Lang::get("SELECT_SCRIPT_PATH"), {}); - if (tempScript != "") { - Config::ScriptPath = tempScript; - } - } else if (touching(touch, mainButtons[2])) { std::string tempMusic = selectFilePath(Lang::get("SELECT_MUSIC_FILE"), {"wav"}, 2); if (tempMusic != "") { Config::MusicPath = tempMusic; } + } else if (touching(touch, mainButtons[1])) { + if (Config::UseBars == true) Config::UseBars = false; + else if (Config::UseBars == false) Config::UseBars = true; } } @@ -401,7 +378,7 @@ void Settings::colorChanging(u32 hDown, touchPosition touch) { int blue; if (hDown & KEY_TOUCH) { - for (int i = 0; i < 8; i++) { + for (int i = 0; i < 7; i++) { if(touch.px > 54 + i * 25 && touch.px < 54 + i * 25+16 && touch.py > 2 && touch.py < 2+16) { colorMode = i; } @@ -418,7 +395,7 @@ void Settings::colorChanging(u32 hDown, touchPosition touch) { } if ((hDown & KEY_R || hDown & KEY_RIGHT) || (hDown & KEY_TOUCH && touching(touch, arrowPos[1]))) { - if(colorMode < 7) colorMode++; + if(colorMode < 6) colorMode++; } if (hDown & KEY_TOUCH) { @@ -484,9 +461,6 @@ void Settings::colorChanging(u32 hDown, touchPosition touch) { Config::progressbarColor = RGBA8(ColorHelper::getColorValue(Config::progressbarColor, 2), ColorHelper::getColorValue(Config::progressbarColor, 1), blue, 255); } } - } else if (touching(touch, buttons[1]) && colorMode == 7) { - if (Config::UseBars == true) Config::UseBars = false; - else if (Config::UseBars == false) Config::UseBars = true; } } } diff --git a/source/screens/unistore.cpp b/source/screens/unistore.cpp index 72180fb..6c096c5 100644 --- a/source/screens/unistore.cpp +++ b/source/screens/unistore.cpp @@ -147,17 +147,6 @@ void loadStoreDesc(void) { descLines.push_back(storeDesc.substr(0, storeDesc.find('\n'))); } -UniStore::UniStore() { - dirContents.clear(); - chdir(Config::StorePath.c_str()); - getDirectoryContents(dirContents, {"unistore"}); - for(uint i=0;i Storelist. void UniStore::DrawStoreList(void) const { std::string line1; @@ -302,26 +317,101 @@ void UniStore::DrawStore(void) const { void UniStore::Draw(void) const { if (mode == 0) { - DrawStoreList(); + DrawSubMenu(); } else if (mode == 1) { - DrawStore(); + DrawStoreList(); } else if (mode == 2) { + DrawStore(); + } else if (mode == 3) { DrawSearch(); } } +void UniStore::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) { + if ((hDown & KEY_B) || (hDown & KEY_TOUCH && touching(touch, arrowPos[2]))) { + Screen::back(); + return; + } + + if (hDown & KEY_UP) { + if(subSelection > 0) subSelection--; + } + if (hDown & KEY_DOWN) { + if(subSelection < 2) subSelection++; + } + + if (hDown & KEY_A) { + switch(subSelection) { + case 0: + if (returnIfExist(Config::StorePath, {"unistore"}) == true) { + dirContents.clear(); + storeInfo.clear(); + chdir(Config::StorePath.c_str()); + getDirectoryContents(dirContents, {"unistore"}); + for(uint i=0;i dirContents; +std::vector dirContents; extern bool touching(touchPosition touch, Structs::ButtonPos button); extern touchPosition touch; @@ -191,6 +191,21 @@ std::vector getContents(const std::string &name, const std::vector< return dirContents; } +// Directory exist? +bool returnIfExist(const std::string &path, const std::vector &extensionList) { + dirContents.clear(); + chdir(path.c_str()); + std::vector dirContentsTemp; + getDirectoryContents(dirContentsTemp, extensionList); + for(uint i=0;i Path, 2 -> File.