diff --git a/include/screens/settings.hpp b/include/screens/settings.hpp index cd5bd00..fcff5c7 100644 --- a/include/screens/settings.hpp +++ b/include/screens/settings.hpp @@ -55,10 +55,12 @@ private: void DrawLanguageSelection(void) const; void DrawColorChanging(void) const; void DrawCreditsScreen(void) const; + void DrawMiscSettings(void) const; void SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch); void LanguageSelection(u32 hDown, touchPosition touch); void colorChanging(u32 hDown, touchPosition touch); void CreditsLogic(u32 hDown, touchPosition touch); + void MiscSettingsLogic(u32 hDown, u32 hHeld, touchPosition touch); std::vector mainButtons = { {90, 40, 140, 35, -1}, // Language. @@ -94,6 +96,7 @@ private: {295, 0, 25, 25, -1}, // Next Arrow. {0, 215, 25, 25, -1}, // Back Arrow. {0, 0, 25, 25, -1}, // Back Arrow top left. + {295, 215, 25, 25, -1}, // Next Page / Misc Arrow. }; }; diff --git a/include/utils/config.hpp b/include/utils/config.hpp index 65ba280..846d329 100644 --- a/include/utils/config.hpp +++ b/include/utils/config.hpp @@ -32,7 +32,7 @@ namespace Config { extern int lang, Color1, Color2, Color3, TxtColor, SelectedColor, UnselectedColor, viewMode, ColorKeys, progressbarColor; extern std::string ScriptPath, MusicPath; - extern bool Logging; + extern bool Logging, UseBars; void load(); void save(); diff --git a/include/utils/fileBrowse.h b/include/utils/fileBrowse.h index 50eeffd..6b7a777 100644 --- a/include/utils/fileBrowse.h +++ b/include/utils/fileBrowse.h @@ -28,6 +28,6 @@ void getDirectoryContents(std::vector& dirContents, const std::vector< void getDirectoryContents(std::vector& dirContents); std::vector getContents(const std::string &name, const std::vector &extensionList); -std::string selectFilePath(std::string selectText, int selectionMode = 1); +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 f85b871..22fcfac 100644 --- a/romfs/lang/en/app.json +++ b/romfs/lang/en/app.json @@ -84,5 +84,10 @@ "REFRESH": "Refresh", "BACK": "Back", "FILEBROWSE_MSG": "Press X to select, Select to refresh.", - "SELECT_SCRIPT_PATH": "Select the Script Path." + "SELECT_SCRIPT_PATH": "Select the Script Path.", + + "CHANGE_BARS": "Change Bars", + "CHANGE_SCRIPTPATH": "Change Scriptpath", + "CHANGE_MUSICFILE": "Change Musicfile", + "SELECT_MUSIC_FILE": "Select the Musicfile." } diff --git a/source/gui.cpp b/source/gui.cpp index 7283b04..8d3d8bd 100644 --- a/source/gui.cpp +++ b/source/gui.cpp @@ -211,14 +211,18 @@ void Gui::DrawTop(void) { Gui::Draw_Rect(0, 0, 400, 25, Config::Color1); Gui::Draw_Rect(0, 25, 400, 190, Config::Color2); Gui::Draw_Rect(0, 215, 400, 25, Config::Color1); - Gui::sprite(sprites_top_screen_top_idx, 0, 0); - Gui::sprite(sprites_top_screen_bot_idx, 0, 215); + if (Config::UseBars == true) { + Gui::sprite(sprites_top_screen_top_idx, 0, 0); + Gui::sprite(sprites_top_screen_bot_idx, 0, 215); + } } else if (isScriptSelected == true) { Gui::Draw_Rect(0, 0, 400, 30, barColor); Gui::Draw_Rect(0, 25, 400, 190, bgBottomColor); Gui::Draw_Rect(0, 215, 400, 25, barColor); - Gui::sprite(sprites_top_screen_top_idx, 0, 0); - Gui::sprite(sprites_top_screen_bot_idx, 0, 215); + if (Config::UseBars == true) { + Gui::sprite(sprites_top_screen_top_idx, 0, 0); + Gui::sprite(sprites_top_screen_bot_idx, 0, 215); + } } } @@ -228,14 +232,18 @@ void Gui::DrawBottom(void) { Gui::Draw_Rect(0, 0, 320, 25, Config::Color1); Gui::Draw_Rect(0, 25, 320, 190, Config::Color3); Gui::Draw_Rect(0, 215, 320, 25, Config::Color1); - Gui::sprite(sprites_bottom_screen_top_idx, 0, 0); - Gui::sprite(sprites_bottom_screen_bot_idx, 0, 215); + if (Config::UseBars == true) { + Gui::sprite(sprites_bottom_screen_top_idx, 0, 0); + Gui::sprite(sprites_bottom_screen_bot_idx, 0, 215); + } } else if (isScriptSelected == true) { Gui::Draw_Rect(0, 0, 320, 30, barColor); Gui::Draw_Rect(0, 25, 320, 190, bgBottomColor); Gui::Draw_Rect(0, 215, 320, 25, barColor); - Gui::sprite(sprites_bottom_screen_top_idx, 0, 0); - Gui::sprite(sprites_bottom_screen_bot_idx, 0, 215); + if (Config::UseBars == true) { + Gui::sprite(sprites_bottom_screen_top_idx, 0, 0); + Gui::sprite(sprites_bottom_screen_bot_idx, 0, 215); + } } } diff --git a/source/screens/ftpScreen.cpp b/source/screens/ftpScreen.cpp index 7985802..0f8374a 100644 --- a/source/screens/ftpScreen.cpp +++ b/source/screens/ftpScreen.cpp @@ -55,7 +55,11 @@ void FTPScreen::Draw(void) const Gui::clearTextBufs(); C3D_FrameBegin(C3D_FRAME_SYNCDRAW); Gui::DrawTop(); - Gui::DrawString((400-Gui::GetStringWidth(0.7f, Lang::get("FTP_MODE")))/2, 0, 0.7f, Config::TxtColor, Lang::get("FTP_MODE"), 400); + if (Config::UseBars == true) { + Gui::DrawString((400-Gui::GetStringWidth(0.7f, Lang::get("FTP_MODE")))/2, 0, 0.7f, Config::TxtColor, Lang::get("FTP_MODE"), 400); + } else { + Gui::DrawString((400-Gui::GetStringWidth(0.7f, Lang::get("FTP_MODE")))/2, 2, 0.7f, Config::TxtColor, Lang::get("FTP_MODE"), 400); + } Gui::DrawBottom(); Gui::DrawArrow(0, 218, 0, 1); ret = ACU_GetWifiStatus(&wifiStatus); diff --git a/source/screens/mainMenu.cpp b/source/screens/mainMenu.cpp index 7249db8..38b1e41 100644 --- a/source/screens/mainMenu.cpp +++ b/source/screens/mainMenu.cpp @@ -50,8 +50,15 @@ bool isTesting = false; void MainMenu::Draw(void) const { Gui::DrawTop(); - Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, "Universal-Updater", 400); - Gui::DrawString(397-Gui::GetStringWidth(0.5f, V_STRING), 239-Gui::GetStringHeight(0.5f, V_STRING), 0.5f, Config::TxtColor, V_STRING); + + if (Config::UseBars == true) { + Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, "Universal-Updater", 400); + Gui::DrawString(397-Gui::GetStringWidth(0.5f, V_STRING), 239-Gui::GetStringHeight(0.5f, V_STRING), 0.5f, Config::TxtColor, V_STRING); + } else { + Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, "Universal-Updater", 400); + 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, 218, 0, 1); diff --git a/source/screens/scriptBrowse.cpp b/source/screens/scriptBrowse.cpp index 31489d1..83d7ba7 100644 --- a/source/screens/scriptBrowse.cpp +++ b/source/screens/scriptBrowse.cpp @@ -114,8 +114,13 @@ void ScriptBrowse::Draw(void) const { revision += " / "; revision += std::to_string(int64_t(infoJson[selection]["revision"])); - Gui::DrawString(397-Gui::GetStringWidth(0.6f, revision), 239-Gui::GetStringHeight(0.6f, revision), 0.6f, Config::TxtColor, revision); - Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, std::string(infoJson[selection]["title"]), 400); + if (Config::UseBars == true) { + Gui::DrawString(397-Gui::GetStringWidth(0.6f, revision), 239-Gui::GetStringHeight(0.6f, revision), 0.6f, Config::TxtColor, revision); + Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, std::string(infoJson[selection]["title"]), 400); + } else { + Gui::DrawString(397-Gui::GetStringWidth(0.6f, revision), 237-Gui::GetStringHeight(0.6f, revision), 0.6f, Config::TxtColor, revision); + Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, std::string(infoJson[selection]["title"]), 400); + } Gui::DrawStringCentered(0, 120, 0.6f, Config::TxtColor, std::string(infoJson[selection]["shortDesc"]), 400); if(infoJson[selection]["curRevision"] < infoJson[selection]["revision"]) { diff --git a/source/screens/scriptlist.cpp b/source/screens/scriptlist.cpp index d8d2421..9957aba 100644 --- a/source/screens/scriptlist.cpp +++ b/source/screens/scriptlist.cpp @@ -278,9 +278,13 @@ void ScriptList::DrawList(void) const { std::string line2; std::string scriptAmount = std::to_string(selection +1) + " / " + std::to_string(fileInfo.size()); Gui::DrawTop(); - Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, "Universal-Updater", 400); - Gui::DrawString(397-Gui::GetStringWidth(0.6f, scriptAmount), 239-Gui::GetStringHeight(0.6f, scriptAmount), 0.6f, Config::TxtColor, scriptAmount); - + if (Config::UseBars == true) { + Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, "Universal-Updater", 400); + Gui::DrawString(397-Gui::GetStringWidth(0.6f, scriptAmount), 239-Gui::GetStringHeight(0.6f, scriptAmount), 0.6f, Config::TxtColor, scriptAmount); + } else { + Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, "Universal-Updater", 400); + Gui::DrawString(397-Gui::GetStringWidth(0.6f, scriptAmount), 237-Gui::GetStringHeight(0.6f, scriptAmount), 0.6f, Config::TxtColor, scriptAmount); + } Gui::DrawStringCentered(0, 80, 0.7f, Config::TxtColor, Lang::get("TITLE") + std::string(fileInfo[selection].title), 400); Gui::DrawStringCentered(0, 100, 0.7f, Config::TxtColor, Lang::get("AUTHOR") + std::string(fileInfo[selection].author), 400); Gui::DrawStringCentered(0, 120, 0.6f, Config::TxtColor, std::string(fileInfo[selection].shortDesc), 400); @@ -337,8 +341,13 @@ void ScriptList::DrawSingleObject(void) const { std::string info; std::string entryAmount = std::to_string(selection2+1) + " / " + std::to_string(fileInfo2.size()); Gui::DrawTop(); - Gui::DrawStringCentered(0, 0, 0.7f, TextColor, selectedTitle, 400); - Gui::DrawString(397-Gui::GetStringWidth(0.6f, entryAmount), 239-Gui::GetStringHeight(0.6f, entryAmount), 0.6f, Config::TxtColor, entryAmount); + if (Config::UseBars == true) { + Gui::DrawStringCentered(0, 0, 0.7f, TextColor, selectedTitle, 400); + Gui::DrawString(397-Gui::GetStringWidth(0.6f, entryAmount), 239-Gui::GetStringHeight(0.6f, entryAmount), 0.6f, Config::TxtColor, entryAmount); + } else { + Gui::DrawStringCentered(0, 2, 0.7f, TextColor, selectedTitle, 400); + Gui::DrawString(397-Gui::GetStringWidth(0.6f, entryAmount), 237-Gui::GetStringHeight(0.6f, entryAmount), 0.6f, Config::TxtColor, entryAmount); + } for(uint i=0;i 0) Selection--; } - if (hDown & KEY_Y) { - Config::ScriptPath = selectFilePath(Lang::get("SELECT_SCRIPT_PATH")); + if (hDown & KEY_DOWN) { + if(Selection < 2) Selection++; + } + + if (hDown & KEY_A) { + if (Selection == 0) { + if (Config::UseBars == true) { + Config::UseBars = false; + } else if (Config::UseBars == false) { + Config::UseBars = true; + } + } 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; + } + } + } + + if (hDown & KEY_TOUCH) { + if (touching(touch, mainButtons[0])) { + if (Config::UseBars == true) { + Config::UseBars = false; + } else if (Config::UseBars == false) { + Config::UseBars = true; + } + } 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; + } + } + } + + if (hDown & KEY_B || hDown & KEY_L) { + mode = 0; + } + + if (hDown & KEY_TOUCH && touching(touch, arrowPos[2])) { + mode = 0; + } +} + + +void Settings::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) { + if (hDown & KEY_UP) { + if(Selection > 0) Selection--; } if (hDown & KEY_DOWN) { @@ -258,6 +355,14 @@ void Settings::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) { Screen::back(); return; } + + if (hDown & KEY_TOUCH && touching(touch, arrowPos[4])) { + mode = 4; + } + + if (hDown & KEY_R) { + mode = 4; + } } void Settings::LanguageSelection(u32 hDown, touchPosition touch) { @@ -457,5 +562,7 @@ void Settings::Logic(u32 hDown, u32 hHeld, touchPosition touch) { colorChanging(hDown, touch); } else if (mode == 3) { CreditsLogic(hDown, touch); + } else if (mode == 4) { + MiscSettingsLogic(hDown, hHeld, touch); } } \ No newline at end of file diff --git a/source/screens/tinyDB.cpp b/source/screens/tinyDB.cpp index 8304721..ae59cb0 100644 --- a/source/screens/tinyDB.cpp +++ b/source/screens/tinyDB.cpp @@ -78,13 +78,22 @@ TinyDB::TinyDB() { } void TinyDB::Draw(void) const { + std::string entryAmount = std::to_string(selection+1) + " / " + std::to_string(tinyDBList.size()); 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)); - Gui::sprite(sprites_top_screen_top_idx, 0, 0); - Gui::sprite(sprites_top_screen_bot_idx, 0, 215); + + if (Config::UseBars == true) { + Gui::sprite(sprites_top_screen_top_idx, 0, 0); + Gui::sprite(sprites_top_screen_bot_idx, 0, 215); + Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, "TinyDB", 400); + Gui::DrawString(397-Gui::GetStringWidth(0.6f, entryAmount), 239-Gui::GetStringHeight(0.6f, entryAmount), 0.6f, Config::TxtColor, entryAmount); + } else { + Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, "TinyDB", 400); + Gui::DrawString(397-Gui::GetStringWidth(0.6f, entryAmount), 237-Gui::GetStringHeight(0.6f, entryAmount), 0.6f, Config::TxtColor, entryAmount); + } Gui::DrawStringCentered(0, 35, 0.6f, Config::TxtColor, Lang::get("AUTHOR") + std::string(tinyDBJson[selectedOption]["info"]["author"]), 400); Gui::DrawStringCentered(0, 65, 0.6f, Config::TxtColor, Lang::get("DESC") + std::string(tinyDBJson[selectedOption]["info"]["description"]), 400); @@ -92,17 +101,16 @@ 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, 0, 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), 239-Gui::GetStringHeight(0.6f, entryAmount), 0.6f, Config::TxtColor, entryAmount); 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); + if (Config::UseBars == true) { + Gui::sprite(sprites_bottom_screen_top_idx, 0, 0); + Gui::sprite(sprites_bottom_screen_bot_idx, 0, 215); + } Gui::DrawArrow(295, -1); Gui::DrawArrow(315, 240, 180.0); diff --git a/source/utils/config.cpp b/source/utils/config.cpp index 303be65..51d45c7 100644 --- a/source/utils/config.cpp +++ b/source/utils/config.cpp @@ -46,6 +46,7 @@ int Config::progressbarColor; std::string Config::ScriptPath; std::string Config::MusicPath; bool Config::Logging; +bool Config::UseBars; nlohmann::json configJson; void Config::load() { @@ -131,6 +132,12 @@ void Config::load() { Config::Logging = getBool("LOGGING"); } + if(!configJson.contains("BARS")) { + Config::UseBars = true; + } else { + Config::UseBars = getBool("BARS"); + } + fclose(file); } else { Config::Color1 = BarColor; @@ -146,6 +153,7 @@ void Config::load() { Config::progressbarColor = WHITE; Config::MusicPath = MUSIC_PATH; Config::Logging = false; + Config::UseBars = true; } } @@ -163,6 +171,7 @@ void Config::save() { Config::setInt("PROGRESSBARCOLOR", Config::progressbarColor); Config::setString("MUSICPATH", Config::MusicPath); Config::setBool("LOGGING", Config::Logging); + Config::setBool("BARS", Config::UseBars); FILE* file = fopen("sdmc:/3ds/Universal-Updater/Settings.json", "w"); if(file) fwrite(configJson.dump(1, '\t').c_str(), 1, configJson.dump(1, '\t').size(), file); fclose(file); @@ -184,6 +193,7 @@ void Config::initializeNewConfig() { Config::setInt("PROGRESSBARCOLOR", WHITE); Config::setString("MUSICPATH", MUSIC_PATH); Config::setBool("LOGGING", false); + Config::setBool("BARS", true); if(file) fwrite(configJson.dump(1, '\t').c_str(), 1, configJson.dump(1, '\t').size(), file); fclose(file); diff --git a/source/utils/fileBrowse.cpp b/source/utils/fileBrowse.cpp index da31121..ef590f9 100644 --- a/source/utils/fileBrowse.cpp +++ b/source/utils/fileBrowse.cpp @@ -192,7 +192,7 @@ std::vector getContents(const std::string &name, const std::vector< // returns a Path or file to 'std::string'. // selectText is the Text which is displayed on the bottom bar of the top screen. // selectionMode is how you select it. 1 -> Path, 2 -> File. -std::string selectFilePath(std::string selectText, int selectionMode) { +std::string selectFilePath(std::string selectText, const std::vector &extensionList, int selectionMode) { static uint selectedFile = 0; std::string selectedPath = ""; static int keyRepeatDelay = 4; @@ -208,8 +208,14 @@ std::string selectFilePath(std::string selectText, int selectionMode) { Gui::DrawTop(); char path[PATH_MAX]; getcwd(path, PATH_MAX); - Gui::DrawString((400-(Gui::GetStringWidth(0.60f, path)))/2, 0, 0.60f, Config::TxtColor, path); - Gui::DrawStringCentered(0, 218, 0.60f, Config::TxtColor, selectText, 400); + if (Config::UseBars == true) { + Gui::DrawString((400-(Gui::GetStringWidth(0.60f, path)))/2, 2, 0.60f, Config::TxtColor, path); + Gui::DrawStringCentered(0, 220, 0.60f, Config::TxtColor, selectText, 400); + } else { + Gui::DrawString((400-(Gui::GetStringWidth(0.60f, path)))/2, 0, 0.60f, Config::TxtColor, path); + Gui::DrawStringCentered(0, 218, 0.60f, Config::TxtColor, selectText, 400); + } + std::string dirs; for (uint i=(selectedFile<5) ? 0 : selectedFile-5;i dirContentsTemp; - getDirectoryContents(dirContentsTemp); + getDirectoryContents(dirContentsTemp, extensionList); for(uint i=0;i