Add second Settingspage and make bars changeable.

This commit is contained in:
StackZ
2019-12-25 23:18:09 +01:00
parent 0fb5d03a87
commit b6d6e6357a
13 changed files with 217 additions and 40 deletions
+3
View File
@@ -55,10 +55,12 @@ private:
void DrawLanguageSelection(void) const; void DrawLanguageSelection(void) const;
void DrawColorChanging(void) const; void DrawColorChanging(void) const;
void DrawCreditsScreen(void) const; void DrawCreditsScreen(void) const;
void DrawMiscSettings(void) const;
void SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch); void SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch);
void LanguageSelection(u32 hDown, touchPosition touch); void LanguageSelection(u32 hDown, touchPosition touch);
void colorChanging(u32 hDown, touchPosition touch); void colorChanging(u32 hDown, touchPosition touch);
void CreditsLogic(u32 hDown, touchPosition touch); void CreditsLogic(u32 hDown, touchPosition touch);
void MiscSettingsLogic(u32 hDown, u32 hHeld, touchPosition touch);
std::vector<Structs::ButtonPos> mainButtons = { std::vector<Structs::ButtonPos> mainButtons = {
{90, 40, 140, 35, -1}, // Language. {90, 40, 140, 35, -1}, // Language.
@@ -94,6 +96,7 @@ private:
{295, 0, 25, 25, -1}, // Next Arrow. {295, 0, 25, 25, -1}, // Next Arrow.
{0, 215, 25, 25, -1}, // Back Arrow. {0, 215, 25, 25, -1}, // Back Arrow.
{0, 0, 25, 25, -1}, // Back Arrow top left. {0, 0, 25, 25, -1}, // Back Arrow top left.
{295, 215, 25, 25, -1}, // Next Page / Misc Arrow.
}; };
}; };
+1 -1
View File
@@ -32,7 +32,7 @@
namespace Config { namespace Config {
extern int lang, Color1, Color2, Color3, TxtColor, SelectedColor, UnselectedColor, viewMode, ColorKeys, progressbarColor; extern int lang, Color1, Color2, Color3, TxtColor, SelectedColor, UnselectedColor, viewMode, ColorKeys, progressbarColor;
extern std::string ScriptPath, MusicPath; extern std::string ScriptPath, MusicPath;
extern bool Logging; extern bool Logging, UseBars;
void load(); void load();
void save(); void save();
+1 -1
View File
@@ -28,6 +28,6 @@ void getDirectoryContents(std::vector<DirEntry>& dirContents, const std::vector<
void getDirectoryContents(std::vector<DirEntry>& dirContents); void getDirectoryContents(std::vector<DirEntry>& dirContents);
std::vector<std::string> getContents(const std::string &name, const std::vector<std::string> &extensionList); std::vector<std::string> getContents(const std::string &name, const std::vector<std::string> &extensionList);
std::string selectFilePath(std::string selectText, int selectionMode = 1); std::string selectFilePath(std::string selectText, const std::vector<std::string> &extensionList, int selectionMode = 1);
#endif //FILE_BROWSE_H #endif //FILE_BROWSE_H
+6 -1
View File
@@ -84,5 +84,10 @@
"REFRESH": "Refresh", "REFRESH": "Refresh",
"BACK": "Back", "BACK": "Back",
"FILEBROWSE_MSG": "Press X to select, Select to refresh.", "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."
} }
+8
View File
@@ -211,16 +211,20 @@ void Gui::DrawTop(void) {
Gui::Draw_Rect(0, 0, 400, 25, Config::Color1); Gui::Draw_Rect(0, 0, 400, 25, Config::Color1);
Gui::Draw_Rect(0, 25, 400, 190, Config::Color2); Gui::Draw_Rect(0, 25, 400, 190, Config::Color2);
Gui::Draw_Rect(0, 215, 400, 25, Config::Color1); Gui::Draw_Rect(0, 215, 400, 25, Config::Color1);
if (Config::UseBars == true) {
Gui::sprite(sprites_top_screen_top_idx, 0, 0); Gui::sprite(sprites_top_screen_top_idx, 0, 0);
Gui::sprite(sprites_top_screen_bot_idx, 0, 215); Gui::sprite(sprites_top_screen_bot_idx, 0, 215);
}
} else if (isScriptSelected == true) { } else if (isScriptSelected == true) {
Gui::Draw_Rect(0, 0, 400, 30, barColor); Gui::Draw_Rect(0, 0, 400, 30, barColor);
Gui::Draw_Rect(0, 25, 400, 190, bgBottomColor); Gui::Draw_Rect(0, 25, 400, 190, bgBottomColor);
Gui::Draw_Rect(0, 215, 400, 25, barColor); Gui::Draw_Rect(0, 215, 400, 25, barColor);
if (Config::UseBars == true) {
Gui::sprite(sprites_top_screen_top_idx, 0, 0); Gui::sprite(sprites_top_screen_top_idx, 0, 0);
Gui::sprite(sprites_top_screen_bot_idx, 0, 215); Gui::sprite(sprites_top_screen_bot_idx, 0, 215);
} }
} }
}
void Gui::DrawBottom(void) { void Gui::DrawBottom(void) {
Gui::setDraw(bottom); Gui::setDraw(bottom);
@@ -228,16 +232,20 @@ void Gui::DrawBottom(void) {
Gui::Draw_Rect(0, 0, 320, 25, Config::Color1); Gui::Draw_Rect(0, 0, 320, 25, Config::Color1);
Gui::Draw_Rect(0, 25, 320, 190, Config::Color3); Gui::Draw_Rect(0, 25, 320, 190, Config::Color3);
Gui::Draw_Rect(0, 215, 320, 25, Config::Color1); Gui::Draw_Rect(0, 215, 320, 25, Config::Color1);
if (Config::UseBars == true) {
Gui::sprite(sprites_bottom_screen_top_idx, 0, 0); Gui::sprite(sprites_bottom_screen_top_idx, 0, 0);
Gui::sprite(sprites_bottom_screen_bot_idx, 0, 215); Gui::sprite(sprites_bottom_screen_bot_idx, 0, 215);
}
} else if (isScriptSelected == true) { } else if (isScriptSelected == true) {
Gui::Draw_Rect(0, 0, 320, 30, barColor); Gui::Draw_Rect(0, 0, 320, 30, barColor);
Gui::Draw_Rect(0, 25, 320, 190, bgBottomColor); Gui::Draw_Rect(0, 25, 320, 190, bgBottomColor);
Gui::Draw_Rect(0, 215, 320, 25, barColor); Gui::Draw_Rect(0, 215, 320, 25, barColor);
if (Config::UseBars == true) {
Gui::sprite(sprites_bottom_screen_top_idx, 0, 0); Gui::sprite(sprites_bottom_screen_top_idx, 0, 0);
Gui::sprite(sprites_bottom_screen_bot_idx, 0, 215); Gui::sprite(sprites_bottom_screen_bot_idx, 0, 215);
} }
} }
}
// Display a Message, which needs to be confirmed with A/B. // Display a Message, which needs to be confirmed with A/B.
bool Gui::promptMsg(std::string promptMsg) bool Gui::promptMsg(std::string promptMsg)
+4
View File
@@ -55,7 +55,11 @@ void FTPScreen::Draw(void) const
Gui::clearTextBufs(); Gui::clearTextBufs();
C3D_FrameBegin(C3D_FRAME_SYNCDRAW); C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
Gui::DrawTop(); Gui::DrawTop();
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); 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::DrawBottom();
Gui::DrawArrow(0, 218, 0, 1); Gui::DrawArrow(0, 218, 0, 1);
ret = ACU_GetWifiStatus(&wifiStatus); ret = ACU_GetWifiStatus(&wifiStatus);
+7
View File
@@ -50,8 +50,15 @@ bool isTesting = false;
void MainMenu::Draw(void) const { void MainMenu::Draw(void) const {
Gui::DrawTop(); Gui::DrawTop();
if (Config::UseBars == true) {
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, "Universal-Updater", 400); 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); 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 if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(0, 0, 0, fadealpha)); // Fade in out effect
Gui::DrawBottom(); Gui::DrawBottom();
Gui::DrawArrow(0, 218, 0, 1); Gui::DrawArrow(0, 218, 0, 1);
+5
View File
@@ -114,8 +114,13 @@ void ScriptBrowse::Draw(void) const {
revision += " / "; revision += " / ";
revision += std::to_string(int64_t(infoJson[selection]["revision"])); revision += std::to_string(int64_t(infoJson[selection]["revision"]));
if (Config::UseBars == true) {
Gui::DrawString(397-Gui::GetStringWidth(0.6f, revision), 239-Gui::GetStringHeight(0.6f, revision), 0.6f, Config::TxtColor, 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); 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); Gui::DrawStringCentered(0, 120, 0.6f, Config::TxtColor, std::string(infoJson[selection]["shortDesc"]), 400);
if(infoJson[selection]["curRevision"] < infoJson[selection]["revision"]) { if(infoJson[selection]["curRevision"] < infoJson[selection]["revision"]) {
+10 -1
View File
@@ -278,9 +278,13 @@ void ScriptList::DrawList(void) const {
std::string line2; std::string line2;
std::string scriptAmount = std::to_string(selection +1) + " / " + std::to_string(fileInfo.size()); std::string scriptAmount = std::to_string(selection +1) + " / " + std::to_string(fileInfo.size());
Gui::DrawTop(); Gui::DrawTop();
if (Config::UseBars == true) {
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, "Universal-Updater", 400); 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); 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, 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, 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); 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 info;
std::string entryAmount = std::to_string(selection2+1) + " / " + std::to_string(fileInfo2.size()); std::string entryAmount = std::to_string(selection2+1) + " / " + std::to_string(fileInfo2.size());
Gui::DrawTop(); Gui::DrawTop();
if (Config::UseBars == true) {
Gui::DrawStringCentered(0, 0, 0.7f, TextColor, selectedTitle, 400); 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); 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<lines.size();i++) { for(uint i=0;i<lines.size();i++) {
Gui::DrawStringCentered(0, 120-((lines.size()*20)/2)+i*20, 0.6f, TextColor, lines[i], 400); Gui::DrawStringCentered(0, 120-((lines.size()*20)/2)+i*20, 0.6f, TextColor, lines[i], 400);
} }
+110 -3
View File
@@ -47,15 +47,22 @@ void Settings::Draw(void) const {
DrawColorChanging(); DrawColorChanging();
} else if (mode == 3) { } else if (mode == 3) {
DrawCreditsScreen(); DrawCreditsScreen();
} else if (mode == 4) {
DrawMiscSettings();
} }
} }
void Settings::DrawSubMenu(void) const { void Settings::DrawSubMenu(void) const {
Gui::DrawTop(); Gui::DrawTop();
if (Config::UseBars == true) {
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, "Universal-Updater", 400); Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, "Universal-Updater", 400);
} else {
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, "Universal-Updater", 400);
}
Gui::DrawBottom(); Gui::DrawBottom();
Gui::DrawArrow(0, 218, 0, 1); Gui::DrawArrow(0, 218, 0, 1);
Gui::DrawArrow(318, 240, 180.0, 1);
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
if (Selection == i) { if (Selection == i) {
@@ -72,7 +79,11 @@ void Settings::DrawSubMenu(void) const {
void Settings::DrawLanguageSelection(void) const { void Settings::DrawLanguageSelection(void) const {
Gui::DrawTop(); Gui::DrawTop();
if (Config::UseBars == true) {
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, Lang::get("SELECT_LANG"), 400); Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, Lang::get("SELECT_LANG"), 400);
} else {
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("SELECT_LANG"), 400);
}
Gui::DrawBottom(); Gui::DrawBottom();
Gui::DrawArrow(0, 218, 0, 1); Gui::DrawArrow(0, 218, 0, 1);
@@ -99,7 +110,11 @@ void Settings::DrawLanguageSelection(void) const {
void Settings::DrawColorChanging(void) const { void Settings::DrawColorChanging(void) const {
Gui::DrawTop(); Gui::DrawTop();
if (Config::UseBars == true) {
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, "Universal-Updater", 400); Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, "Universal-Updater", 400);
} else {
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, "Universal-Updater", 400);
}
if (colorMode == 3) { if (colorMode == 3) {
Gui::Draw_Rect(0, 40, 400, 45, Config::SelectedColor); Gui::Draw_Rect(0, 40, 400, 45, Config::SelectedColor);
@@ -184,7 +199,11 @@ void Settings::DrawCreditsScreen(void) const {
std::string title = "Universal-Updater - "; std::string title = "Universal-Updater - ";
title += Lang::get("CREDITS"); title += Lang::get("CREDITS");
if (Config::UseBars == true) {
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, title, 400); Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, title, 400);
} else {
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, title, 400);
}
Gui::DrawStringCentered(0, 40, 0.8f, Config::TxtColor, Lang::get("DEVELOPED_BY"), 400); Gui::DrawStringCentered(0, 40, 0.8f, Config::TxtColor, Lang::get("DEVELOPED_BY"), 400);
Gui::DrawStringCentered(0, 70, 0.8f, Config::TxtColor, Lang::get("MAIN_DEV"), 400); Gui::DrawStringCentered(0, 70, 0.8f, Config::TxtColor, Lang::get("MAIN_DEV"), 400);
Gui::sprite(sprites_voltZ_idx, 150, 115); Gui::sprite(sprites_voltZ_idx, 150, 115);
@@ -211,14 +230,92 @@ void Settings::DrawCreditsScreen(void) const {
} }
} }
void Settings::DrawMiscSettings(void) const {
Gui::DrawTop();
if (Config::UseBars == true) {
Gui::DrawStringCentered(0, 0, 0.7f, Config::TxtColor, "Universal-Updater", 400);
} else {
Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, "Universal-Updater", 400);
}
void Settings::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) { Gui::DrawBottom();
Gui::DrawArrow(0, 218, 0, 1);
for (int i = 0; i < 3; i++) {
if (Selection == i) {
Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, Config::SelectedColor);
} else {
Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, Config::UnselectedColor);
}
}
Gui::DrawStringCentered(0, mainButtons[0].y+10, 0.6f, Config::TxtColor, Lang::get("CHANGE_BARS"), 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);
}
void Settings::MiscSettingsLogic(u32 hDown, u32 hHeld, touchPosition touch) {
if (hDown & KEY_UP) { if (hDown & KEY_UP) {
if(Selection > 0) Selection--; if(Selection > 0) Selection--;
} }
if (hDown & KEY_Y) { if (hDown & KEY_DOWN) {
Config::ScriptPath = selectFilePath(Lang::get("SELECT_SCRIPT_PATH")); 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) { if (hDown & KEY_DOWN) {
@@ -258,6 +355,14 @@ void Settings::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) {
Screen::back(); Screen::back();
return; return;
} }
if (hDown & KEY_TOUCH && touching(touch, arrowPos[4])) {
mode = 4;
}
if (hDown & KEY_R) {
mode = 4;
}
} }
void Settings::LanguageSelection(u32 hDown, touchPosition touch) { void Settings::LanguageSelection(u32 hDown, touchPosition touch) {
@@ -457,5 +562,7 @@ void Settings::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
colorChanging(hDown, touch); colorChanging(hDown, touch);
} else if (mode == 3) { } else if (mode == 3) {
CreditsLogic(hDown, touch); CreditsLogic(hDown, touch);
} else if (mode == 4) {
MiscSettingsLogic(hDown, hHeld, touch);
} }
} }
+11 -3
View File
@@ -78,13 +78,22 @@ TinyDB::TinyDB() {
} }
void TinyDB::Draw(void) const { void TinyDB::Draw(void) const {
std::string entryAmount = std::to_string(selection+1) + " / " + std::to_string(tinyDBList.size());
std::string info; std::string info;
Gui::setDraw(top); Gui::setDraw(top);
Gui::Draw_Rect(0, 0, 400, 25, C2D_Color32(63, 81, 181, 255)); 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, 25, 400, 190, C2D_Color32(140, 140, 140, 255));
Gui::Draw_Rect(0, 215, 400, 25, C2D_Color32(63, 81, 181, 255)); Gui::Draw_Rect(0, 215, 400, 25, C2D_Color32(63, 81, 181, 255));
if (Config::UseBars == true) {
Gui::sprite(sprites_top_screen_top_idx, 0, 0); Gui::sprite(sprites_top_screen_top_idx, 0, 0);
Gui::sprite(sprites_top_screen_bot_idx, 0, 215); 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, 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); 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, 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, 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, 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::setDraw(bottom);
Gui::Draw_Rect(0, 0, 320, 25, C2D_Color32(63, 81, 181, 255)); 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, 25, 320, 190, C2D_Color32(140, 140, 140, 255));
Gui::Draw_Rect(0, 215, 320, 25, C2D_Color32(63, 81, 181, 255)); Gui::Draw_Rect(0, 215, 320, 25, C2D_Color32(63, 81, 181, 255));
if (Config::UseBars == true) {
Gui::sprite(sprites_bottom_screen_top_idx, 0, 0); Gui::sprite(sprites_bottom_screen_top_idx, 0, 0);
Gui::sprite(sprites_bottom_screen_bot_idx, 0, 215); Gui::sprite(sprites_bottom_screen_bot_idx, 0, 215);
}
Gui::DrawArrow(295, -1); Gui::DrawArrow(295, -1);
Gui::DrawArrow(315, 240, 180.0); Gui::DrawArrow(315, 240, 180.0);
+10
View File
@@ -46,6 +46,7 @@ int Config::progressbarColor;
std::string Config::ScriptPath; std::string Config::ScriptPath;
std::string Config::MusicPath; std::string Config::MusicPath;
bool Config::Logging; bool Config::Logging;
bool Config::UseBars;
nlohmann::json configJson; nlohmann::json configJson;
void Config::load() { void Config::load() {
@@ -131,6 +132,12 @@ void Config::load() {
Config::Logging = getBool("LOGGING"); Config::Logging = getBool("LOGGING");
} }
if(!configJson.contains("BARS")) {
Config::UseBars = true;
} else {
Config::UseBars = getBool("BARS");
}
fclose(file); fclose(file);
} else { } else {
Config::Color1 = BarColor; Config::Color1 = BarColor;
@@ -146,6 +153,7 @@ void Config::load() {
Config::progressbarColor = WHITE; Config::progressbarColor = WHITE;
Config::MusicPath = MUSIC_PATH; Config::MusicPath = MUSIC_PATH;
Config::Logging = false; Config::Logging = false;
Config::UseBars = true;
} }
} }
@@ -163,6 +171,7 @@ void Config::save() {
Config::setInt("PROGRESSBARCOLOR", Config::progressbarColor); Config::setInt("PROGRESSBARCOLOR", Config::progressbarColor);
Config::setString("MUSICPATH", Config::MusicPath); Config::setString("MUSICPATH", Config::MusicPath);
Config::setBool("LOGGING", Config::Logging); Config::setBool("LOGGING", Config::Logging);
Config::setBool("BARS", Config::UseBars);
FILE* file = fopen("sdmc:/3ds/Universal-Updater/Settings.json", "w"); 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); if(file) fwrite(configJson.dump(1, '\t').c_str(), 1, configJson.dump(1, '\t').size(), file);
fclose(file); fclose(file);
@@ -184,6 +193,7 @@ void Config::initializeNewConfig() {
Config::setInt("PROGRESSBARCOLOR", WHITE); Config::setInt("PROGRESSBARCOLOR", WHITE);
Config::setString("MUSICPATH", MUSIC_PATH); Config::setString("MUSICPATH", MUSIC_PATH);
Config::setBool("LOGGING", false); Config::setBool("LOGGING", false);
Config::setBool("BARS", true);
if(file) fwrite(configJson.dump(1, '\t').c_str(), 1, configJson.dump(1, '\t').size(), file); if(file) fwrite(configJson.dump(1, '\t').c_str(), 1, configJson.dump(1, '\t').size(), file);
fclose(file); fclose(file);
+13 -2
View File
@@ -192,7 +192,7 @@ std::vector<std::string> getContents(const std::string &name, const std::vector<
// returns a Path or file to 'std::string'. // returns a Path or file to 'std::string'.
// selectText is the Text which is displayed on the bottom bar of the top screen. // 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. // 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<std::string> &extensionList, int selectionMode) {
static uint selectedFile = 0; static uint selectedFile = 0;
std::string selectedPath = ""; std::string selectedPath = "";
static int keyRepeatDelay = 4; static int keyRepeatDelay = 4;
@@ -208,8 +208,14 @@ std::string selectFilePath(std::string selectText, int selectionMode) {
Gui::DrawTop(); Gui::DrawTop();
char path[PATH_MAX]; char path[PATH_MAX];
getcwd(path, PATH_MAX); getcwd(path, PATH_MAX);
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::DrawString((400-(Gui::GetStringWidth(0.60f, path)))/2, 0, 0.60f, Config::TxtColor, path);
Gui::DrawStringCentered(0, 218, 0.60f, Config::TxtColor, selectText, 400); Gui::DrawStringCentered(0, 218, 0.60f, Config::TxtColor, selectText, 400);
}
std::string dirs; std::string dirs;
for (uint i=(selectedFile<5) ? 0 : selectedFile-5;i<dirContents.size()&&i<((selectedFile<5) ? 6 : selectedFile+1);i++) { for (uint i=(selectedFile<5) ? 0 : selectedFile-5;i<dirContents.size()&&i<((selectedFile<5) ? 6 : selectedFile+1);i++) {
if (i == selectedFile) { if (i == selectedFile) {
@@ -225,7 +231,11 @@ std::string selectFilePath(std::string selectText, int selectionMode) {
Gui::DrawString(26, 32, 0.53f, Config::TxtColor, dirs.c_str()); Gui::DrawString(26, 32, 0.53f, Config::TxtColor, dirs.c_str());
Gui::DrawBottom(); Gui::DrawBottom();
if (Config::UseBars == true) {
Gui::DrawStringCentered(0, 0, 0.5f, Config::TxtColor, Lang::get("FILEBROWSE_MSG"), 320); Gui::DrawStringCentered(0, 0, 0.5f, Config::TxtColor, Lang::get("FILEBROWSE_MSG"), 320);
} else {
Gui::DrawStringCentered(0, 2, 0.5f, Config::TxtColor, Lang::get("FILEBROWSE_MSG"), 320);
}
Gui::DrawArrow(295, -1); Gui::DrawArrow(295, -1);
Gui::DrawArrow(315, 240, 180.0); Gui::DrawArrow(315, 240, 180.0);
@@ -250,7 +260,7 @@ std::string selectFilePath(std::string selectText, int selectionMode) {
if (dirChanged) { if (dirChanged) {
dirContents.clear(); dirContents.clear();
std::vector<DirEntry> dirContentsTemp; std::vector<DirEntry> dirContentsTemp;
getDirectoryContents(dirContentsTemp); getDirectoryContents(dirContentsTemp, extensionList);
for(uint i=0;i<dirContentsTemp.size();i++) { for(uint i=0;i<dirContentsTemp.size();i++) {
dirContents.push_back(dirContentsTemp[i]); dirContents.push_back(dirContentsTemp[i]);
} }
@@ -304,6 +314,7 @@ std::string selectFilePath(std::string selectText, int selectionMode) {
char path[PATH_MAX]; char path[PATH_MAX];
getcwd(path, PATH_MAX); getcwd(path, PATH_MAX);
if(strcmp(path, "sdmc:/") == 0 || strcmp(path, "/") == 0) { if(strcmp(path, "sdmc:/") == 0 || strcmp(path, "/") == 0) {
return "";
} else { } else {
chdir(".."); chdir("..");
selectedFile = 0; selectedFile = 0;