From f68613ef0658a9492c312fbc4aad97f3be061f34 Mon Sep 17 00:00:00 2001 From: StackZ <47382115+SuperSaiyajinStackZ@users.noreply.github.com> Date: Sat, 27 Jun 2020 09:15:29 +0200 Subject: [PATCH] Some, uhh.. changes? --- include/animation.hpp | 20 ++--- include/download/download.hpp | 8 +- include/gui/gfx.hpp | 6 +- include/gui/keyboard.hpp | 30 ++++++- include/gui/msg.hpp | 6 +- include/init.hpp | 6 +- include/lang/lang.hpp | 30 ++++++- include/logging.hpp | 6 +- include/screens/credits.hpp | 6 +- include/screens/ftpScreen.hpp | 9 ++- include/screens/mainMenu.hpp | 6 +- include/screens/scriptBrowse.hpp | 6 +- include/screens/scriptCreator.hpp | 7 +- include/screens/scriptlist.hpp | 6 +- include/screens/settings.hpp | 6 +- include/screens/startup.hpp | 6 +- include/screens/unistore.hpp | 6 +- include/screens/unistore_v1.hpp | 6 +- include/screens/unistore_v2.hpp | 6 +- include/utils/cia.hpp | 4 +- include/utils/colorHelper.hpp | 6 +- include/utils/common.hpp | 2 +- include/utils/config.hpp | 2 +- include/utils/extract.hpp | 6 +- include/utils/fileBrowse.hpp | 32 +++++++- include/utils/files.h | 9 ++- include/utils/formatting.hpp | 6 +- include/utils/ftp.h | 2 +- include/utils/scriptHelper.hpp | 6 +- include/utils/sound.h | 4 +- include/utils/store.hpp | 6 +- include/utils/stringutils.hpp | 4 +- include/utils/thread.hpp | 4 +- source/animation.cpp | 53 ++----------- source/download/download.cpp | 128 ++++++++++-------------------- source/gui/gfx.cpp | 89 ++++++--------------- source/gui/keyboard.cpp | 36 +++++++-- source/gui/msg.cpp | 49 +++--------- source/init.cpp | 14 ++-- source/lang/lang.cpp | 33 +++++++- source/logging.cpp | 2 +- source/main.cpp | 2 +- source/screens/credits.cpp | 14 ++-- source/screens/ftpScreen.cpp | 18 ++--- source/screens/mainMenu.cpp | 15 +--- source/screens/scriptBrowse.cpp | 20 ++--- source/screens/scriptCreator.cpp | 14 +--- source/screens/scriptlist.cpp | 35 ++------ source/screens/settings.cpp | 28 ++----- source/screens/startup.cpp | 2 +- source/screens/unistore.cpp | 29 +++---- source/screens/unistore_v1.cpp | 22 ++--- source/screens/unistore_v2.cpp | 72 ++++++----------- source/utils/colorHelper.cpp | 8 +- source/utils/config.cpp | 4 +- source/utils/extract.cpp | 2 +- source/utils/fileBrowse.cpp | 43 +++++++--- source/utils/files.c | 7 +- source/utils/formatting.cpp | 13 +-- source/utils/scriptHelper.cpp | 26 +++--- source/utils/sound.cpp | 1 - source/utils/store.cpp | 2 +- source/utils/thread.cpp | 6 +- 63 files changed, 477 insertions(+), 585 deletions(-) diff --git a/include/animation.hpp b/include/animation.hpp index 01d266d..cca4a31 100644 --- a/include/animation.hpp +++ b/include/animation.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,19 +24,21 @@ * reasonable ways as different from the original version. */ -#ifndef ANIMATION_HPP -#define ANIMATION_HPP +#ifndef _UNIVERSAL_UPDATER_ANIMATION_HPP +#define _UNIVERSAL_UPDATER_ANIMATION_HPP #include <3ds.h> #include +enum class ProgressBar { + Downloading, + Extracting, + Installing +}; + namespace Animation { - // Downloading Progressbar. - void DrawProgressBar(float currentProgress, float totalProgress, int mode); - // Extracting progressbar. - void DrawProgressBarExtract(u64 currentProgress, u64 totalProgress, int mode); - // Installing progressbar. - void DrawProgressBarInstall(u64 currentProgress, u64 totalProgress, int mode); + // Progressbar. + void DrawProgressBar(u64 currentProgress, u64 totalProgress); // Draw Button. void Button(int x, int y, float speed = .030); } diff --git a/include/download/download.hpp b/include/download/download.hpp index 61edb6f..4415efe 100644 --- a/include/download/download.hpp +++ b/include/download/download.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,13 +24,13 @@ * reasonable ways as different from the original version. */ -#ifndef DOWNLOAD_HPP -#define DOWNLOAD_HPP +#ifndef _UNIVERSAL_UPDATER_DOWNLOAD_HPP +#define _UNIVERSAL_UPDATER_DOWNLOAD_HPP #include "common.hpp" #define APP_TITLE "Universal-Updater" -#define VERSION_STRING "2.4.0" +#define VERSION_STRING "2.5.0" // The Release Fetch struct. struct ReleaseFetch { diff --git a/include/gui/gfx.hpp b/include/gui/gfx.hpp index 0a1f303..1641c20 100644 --- a/include/gui/gfx.hpp +++ b/include/gui/gfx.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ * reasonable ways as different from the original version. */ -#ifndef GFX_HPP -#define GFX_HPP +#ifndef _UNIVERSAL_UPDATER_GFX_HPP +#define _UNIVERSAL_UPDATER_GFX_HPP #include "colorHelper.hpp" #include "gui.hpp" diff --git a/include/gui/keyboard.hpp b/include/gui/keyboard.hpp index c65238a..ddd814b 100644 --- a/include/gui/keyboard.hpp +++ b/include/gui/keyboard.hpp @@ -1,5 +1,31 @@ -#ifndef KEYBOARD_HPP -#define KEYBOARD_HPP +/* +* This file is part of Universal-Updater +* Copyright (C) 2019-2020 Universal-Team +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* Additional Terms 7.b and 7.c of GPLv3 apply to this file: +* * Requiring preservation of specified reasonable legal notices or +* author attributions in that material or in the Appropriate Legal +* Notices displayed by works containing it. +* * Prohibiting misrepresentation of the origin of that material, +* or requiring that modified versions of such material be marked in +* reasonable ways as different from the original version. +*/ + +#ifndef _UNIVERSAL_UPDATER_KEYBOARD_HPP +#define _UNIVERSAL_UPDATER_KEYBOARD_HPP #include diff --git a/include/gui/msg.hpp b/include/gui/msg.hpp index 8e21794..b013cc1 100644 --- a/include/gui/msg.hpp +++ b/include/gui/msg.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ * reasonable ways as different from the original version. */ -#ifndef MSG_HPP -#define MSG_HPP +#ifndef _UNIVERSAL_UPDATER_MSG_HPP +#define UNIVERSAL_UPDATER_MSG_HPP #include diff --git a/include/init.hpp b/include/init.hpp index 389d70a..9b86583 100644 --- a/include/init.hpp +++ b/include/init.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ * reasonable ways as different from the original version. */ -#ifndef INIT_HPP -#define INIT_HPP +#ifndef _UNIVERSAL_UPDATER_INIT_HPP +#define _UNIVERSAL_UPDATER_INIT_HPP #include <3ds.h> diff --git a/include/lang/lang.hpp b/include/lang/lang.hpp index c64a923..066d2cc 100644 --- a/include/lang/lang.hpp +++ b/include/lang/lang.hpp @@ -1,5 +1,31 @@ -#ifndef LANG_HPP -#define LANG_HPP +/* +* This file is part of Universal-Updater +* Copyright (C) 2019-2020 Universal-Team +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* Additional Terms 7.b and 7.c of GPLv3 apply to this file: +* * Requiring preservation of specified reasonable legal notices or +* author attributions in that material or in the Appropriate Legal +* Notices displayed by works containing it. +* * Prohibiting misrepresentation of the origin of that material, +* or requiring that modified versions of such material be marked in +* reasonable ways as different from the original version. +*/ + +#ifndef _UNIVERSAL_UPDATER_LANG_HPP +#define _UNIVERSAL_UPDATER_LANG_HPP #include "json.hpp" diff --git a/include/logging.hpp b/include/logging.hpp index cc0bda0..435b74b 100644 --- a/include/logging.hpp +++ b/include/logging.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ * reasonable ways as different from the original version. */ -#ifndef LOGGING_HPP -#define LOGGING_HPP +#ifndef _UNIVERSAL_UPDATER_LOGGING_HPP +#define _UNIVERSAL_UPDATER_LOGGING_HPP #include #include diff --git a/include/screens/credits.hpp b/include/screens/credits.hpp index acd5331..25e1d7c 100644 --- a/include/screens/credits.hpp +++ b/include/screens/credits.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ * reasonable ways as different from the original version. */ -#ifndef CREDITS_HPP -#define CREDITS_HPP +#ifndef _UNIVERSAL_UPDATER_CREDITS_HPP +#define _UNIVERSAL_UPDATER_CREDITS_HPP #include "common.hpp" #include "structs.hpp" diff --git a/include/screens/ftpScreen.hpp b/include/screens/ftpScreen.hpp index 68ccc89..f1ea0dc 100644 --- a/include/screens/ftpScreen.hpp +++ b/include/screens/ftpScreen.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,6 +24,9 @@ * reasonable ways as different from the original version. */ +#ifndef _UNIVERSAL_UPDATER_FTP_SCREEN_HPP +#define _UNIVERSAL_UPDATER_FTP_SCREEN_HPP + #include "common.hpp" #include "structs.hpp" @@ -39,4 +42,6 @@ private: const std::vector arrowPos = { {0, 215, 25, 25} // Back Arrow. }; -}; \ No newline at end of file +}; + +#endif \ No newline at end of file diff --git a/include/screens/mainMenu.hpp b/include/screens/mainMenu.hpp index 46b38ec..9f529f2 100644 --- a/include/screens/mainMenu.hpp +++ b/include/screens/mainMenu.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ * reasonable ways as different from the original version. */ -#ifndef MAINMENU_HPP -#define MAINMENU_HPP +#ifndef _UNIVERSAL_UPDATER_MAINMENU_HPP +#define _UNIVERSAL_UPDATER_MAINMENU_HPP #include "common.hpp" #include "structs.hpp" diff --git a/include/screens/scriptBrowse.hpp b/include/screens/scriptBrowse.hpp index 21524b9..a14056a 100644 --- a/include/screens/scriptBrowse.hpp +++ b/include/screens/scriptBrowse.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ * reasonable ways as different from the original version. */ -#ifndef SCRIPTBROWSE_HPP -#define SCRIPTBROWSE_HPP +#ifndef _UNIVERSAL_UPDATER_SCRIPT_BROWSE_HPP +#define _UNIVERSAL_UPDATER_SCRIPT_BROWSE_HPP #include "common.hpp" #include "fileBrowse.hpp" diff --git a/include/screens/scriptCreator.hpp b/include/screens/scriptCreator.hpp index 67cd9bd..474dd5d 100644 --- a/include/screens/scriptCreator.hpp +++ b/include/screens/scriptCreator.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ * reasonable ways as different from the original version. */ -#ifndef SCRIPTCREATOR_HPP -#define SCRIPTCREATOR_HPP +#ifndef _UNIVERSAL_UPDATER_SCRIPT_CREATOR_HPP +#define _UNIVERSAL_UPDATER_SCRIPT_CREATOR_HPP #include "common.hpp" #include "json.hpp" @@ -37,7 +37,6 @@ class ScriptCreator : public Screen { public: void Draw(void) const override; void Logic(u32 hDown, u32 hHeld, touchPosition touch) override; - private: std::string entryName = ""; diff --git a/include/screens/scriptlist.hpp b/include/screens/scriptlist.hpp index b0c15a4..0b6e3ef 100644 --- a/include/screens/scriptlist.hpp +++ b/include/screens/scriptlist.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ * reasonable ways as different from the original version. */ -#ifndef SCRIPTLIST_HPP -#define SCRIPTLIST_HPP +#ifndef _UNIVERSAL_UPDATER_SCRIPT_LIST_HPP +#define _UNIVERSAL_UPDATER_SCRIPT_LIST_HPP #include "common.hpp" #include "fileBrowse.hpp" diff --git a/include/screens/settings.hpp b/include/screens/settings.hpp index 1b93677..77de64f 100644 --- a/include/screens/settings.hpp +++ b/include/screens/settings.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ * reasonable ways as different from the original version. */ -#ifndef SETTINGS_HPP -#define SETTINGS_HPP +#ifndef _UNIVERSAL_UPDATER_SETTINGS_HPP +#define _UNIVERSAL_UPDATER_SETTINGS_HPP #include "common.hpp" #include "fileBrowse.hpp" diff --git a/include/screens/startup.hpp b/include/screens/startup.hpp index 9673d7c..c04780c 100644 --- a/include/screens/startup.hpp +++ b/include/screens/startup.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ * reasonable ways as different from the original version. */ -#ifndef STARTUP_HPP -#define STARTUP_HPP +#ifndef _UNIVERSAL_UPDATER_STARTUP_HPP +#define _UNIVERSAL_UPDATER_STARTUP_HPP #include "common.hpp" diff --git a/include/screens/unistore.hpp b/include/screens/unistore.hpp index 440dc06..719cd51 100644 --- a/include/screens/unistore.hpp +++ b/include/screens/unistore.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ * reasonable ways as different from the original version. */ -#ifndef UNISTORE_HPP -#define UNISTORE_HPP +#ifndef _UNIVERSAL_UPDATER_UNISTORE_HPP +#define _UNIVERSAL_UPDATER_UNISTORE_HPP #include "common.hpp" #include "fileBrowse.hpp" diff --git a/include/screens/unistore_v1.hpp b/include/screens/unistore_v1.hpp index 0bb5317..8a0f09b 100644 --- a/include/screens/unistore_v1.hpp +++ b/include/screens/unistore_v1.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ * reasonable ways as different from the original version. */ -#ifndef UNIVERSAL_STORE_V1_HPP -#define UNIVERSAL_STORE_V1_HPP +#ifndef _UNIVERSAL_UPDATER_UNIVERSAL_STORE_V1_HPP +#define _UNIVERSAL_UPDATER_UNIVERSAL_STORE_V1_HPP #include "common.hpp" #include "json.hpp" diff --git a/include/screens/unistore_v2.hpp b/include/screens/unistore_v2.hpp index 6277f2c..e794f57 100644 --- a/include/screens/unistore_v2.hpp +++ b/include/screens/unistore_v2.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ * reasonable ways as different from the original version. */ -#ifndef UNIVERSAL_STORE_V2_HPP -#define UNIVERSAL_STORE_V2_HPP +#ifndef _UNIVERSAL_UPDATER_UNIVERSAL_STORE_V2_HPP +#define _UNIVERSAL_UPDATER_UNIVERSAL_STORE_V2_HPP #include "common.hpp" #include "json.hpp" diff --git a/include/utils/cia.hpp b/include/utils/cia.hpp index f1da4be..f614aee 100644 --- a/include/utils/cia.hpp +++ b/include/utils/cia.hpp @@ -1,5 +1,5 @@ -#ifndef CIA_HPP -#define CIA_HPP +#ifndef _UNIVERSAL_UPDATER_CIA_HPP +#define _UNIVERSAL_UPDATER_CIA_HPP #include "common.hpp" diff --git a/include/utils/colorHelper.hpp b/include/utils/colorHelper.hpp index 25f8f32..3de2145 100644 --- a/include/utils/colorHelper.hpp +++ b/include/utils/colorHelper.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ * reasonable ways as different from the original version. */ -#ifndef COLORHELPER_HPP -#define COLORHELPER_HPP +#ifndef _UNIVERSAL_UPDATER_COLOR_HELPER_HPP +#define _UNIVERSAL_UPDATER_COLOR_HELPER_HPP #include #include diff --git a/include/utils/common.hpp b/include/utils/common.hpp index 5b18709..ce74db8 100644 --- a/include/utils/common.hpp +++ b/include/utils/common.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/include/utils/config.hpp b/include/utils/config.hpp index f865582..15f39a8 100644 --- a/include/utils/config.hpp +++ b/include/utils/config.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/include/utils/extract.hpp b/include/utils/extract.hpp index ed85f6d..f6ffef3 100644 --- a/include/utils/extract.hpp +++ b/include/utils/extract.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ * reasonable ways as different from the original version. */ -#ifndef EXTRACT_HPP -#define EXTRACT_HPP +#ifndef _UNIVERSAL_UPDATER_EXTRACT_HPP +#define _UNIVERSAL_UPDATER_EXTRACT_HPP #include "common.hpp" diff --git a/include/utils/fileBrowse.hpp b/include/utils/fileBrowse.hpp index 70cbebe..f7e34be 100644 --- a/include/utils/fileBrowse.hpp +++ b/include/utils/fileBrowse.hpp @@ -1,5 +1,31 @@ -#ifndef FILE_BROWSE_HPP -#define FILE_BROWSE_HPP +/* +* This file is part of Universal-Updater +* Copyright (C) 2019-2020 Universal-Team +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* Additional Terms 7.b and 7.c of GPLv3 apply to this file: +* * Requiring preservation of specified reasonable legal notices or +* author attributions in that material or in the Appropriate Legal +* Notices displayed by works containing it. +* * Prohibiting misrepresentation of the origin of that material, +* or requiring that modified versions of such material be marked in +* reasonable ways as different from the original version. +*/ + +#ifndef _UNIVERSAL_UPDATER_FILE_BROWSE_HPP +#define _UNIVERSAL_UPDATER_FILE_BROWSE_HPP #include #include @@ -27,4 +53,4 @@ std::string selectFilePath(std::string selectText, std::string initialPath, cons void dirCopy(DirEntry* entry, int i, const char *destinationPath, const char *sourcePath); int fcopy(const char *sourcePath, const char *destinationPath); -#endif //FILE_BROWSE_HPP \ No newline at end of file +#endif \ No newline at end of file diff --git a/include/utils/files.h b/include/utils/files.h index 1415624..07b68ed 100644 --- a/include/utils/files.h +++ b/include/utils/files.h @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019 VoltZ, Epicpkmn11, Flame, RocketRobz, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +24,8 @@ * reasonable ways as different from the original version. */ -#pragma once +#ifndef _UNIVERSAL_UPDATER_FILES_H +#define _UNIVERSAL_UPDATER_FILES_H #include "common.hpp" @@ -32,4 +33,6 @@ Result makeDirs(const char * path); Result openFile(Handle* fileHandle, const char * path, bool write); Result deleteFile(const char * path); Result removeDir(const char * path); -Result removeDirRecursive(const char * path); \ No newline at end of file +Result removeDirRecursive(const char * path); + +#endif \ No newline at end of file diff --git a/include/utils/formatting.hpp b/include/utils/formatting.hpp index f1e41cd..7bedb93 100644 --- a/include/utils/formatting.hpp +++ b/include/utils/formatting.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ * reasonable ways as different from the original version. */ -#ifndef FORMATTING_HPP -#define FORMATTING_HPP +#ifndef _UNIVERSAL_UPDATER_FORMATTING_HPP +#define _UNIVERSAL_UPDATER_FORMATTING_HPP #include diff --git a/include/utils/ftp.h b/include/utils/ftp.h index 4630aa2..19dcef8 100644 --- a/include/utils/ftp.h +++ b/include/utils/ftp.h @@ -15,4 +15,4 @@ extern char ftp_accepted_connection[50], ftp_file_transfer[100]; int ftp_init(void); loop_status_t ftp_loop(void); -void ftp_exit(void); +void ftp_exit(void); \ No newline at end of file diff --git a/include/utils/scriptHelper.hpp b/include/utils/scriptHelper.hpp index ebeee43..56c9b96 100644 --- a/include/utils/scriptHelper.hpp +++ b/include/utils/scriptHelper.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ * reasonable ways as different from the original version. */ -#ifndef SCRIPTHELPER_HPP -#define SCRIPTHELPER_HPP +#ifndef _UNIVERSAL_UPDATER_SCRIPT_HELPER_HPP +#define _UNIVERSAL_UPDATER_SCRIPT_HELPER_HPP #include diff --git a/include/utils/sound.h b/include/utils/sound.h index 4664392..c9de7dd 100644 --- a/include/utils/sound.h +++ b/include/utils/sound.h @@ -1,5 +1,5 @@ -#ifndef SOUND_H -#define SOUND_H +#ifndef _UNIVERSAL_UPDATER_SOUND_H +#define _UNIVERSAL_UPDATER_SOUND_H #include <3ds.h> #include diff --git a/include/utils/store.hpp b/include/utils/store.hpp index a5e3109..02eb215 100644 --- a/include/utils/store.hpp +++ b/include/utils/store.hpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ * reasonable ways as different from the original version. */ -#ifndef STORE_HPP -#define STORE_HPP +#ifndef _UNIVERSAL_UPDATER_STORE_HPP +#define _UNIVERSAL_UPDATER_STORE_HPP #include "json.hpp" #include <3ds.h> diff --git a/include/utils/stringutils.hpp b/include/utils/stringutils.hpp index fc7a6ec..c50def3 100644 --- a/include/utils/stringutils.hpp +++ b/include/utils/stringutils.hpp @@ -1,5 +1,5 @@ -#ifndef STRINGUTILS_HPP -#define STRINGUTILS_HPP +#ifndef _UNIVERSAL_UPDATER_STRING_UTILS_HPP +#define _UNIVERSAL_UPDATER_STRING_UTILS_HPP #include "common.hpp" diff --git a/include/utils/thread.hpp b/include/utils/thread.hpp index 0f498fd..251feff 100644 --- a/include/utils/thread.hpp +++ b/include/utils/thread.hpp @@ -1,5 +1,5 @@ -#ifndef THREAD_HPP -#define THREAD_HPP +#ifndef _UNIVERSAL_UPDATER_THREAD_HPP +#define _UNIVERSAL_UPDATER_THREAD_HPP #include <3ds.h> #include diff --git a/source/animation.cpp b/source/animation.cpp index 94a3584..dd5b64a 100644 --- a/source/animation.cpp +++ b/source/animation.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,49 +27,18 @@ #include "common.hpp" extern bool isScriptSelected; -extern u32 progressBar; -extern u32 selected; +extern u32 progressBar, selected; +extern ProgressBar progressbarType; extern std::unique_ptr config; extern C2D_SpriteSheet sprites; // Draws a Rectangle as the progressbar. -void Animation::DrawProgressBar(float currentProgress, float totalProgress, int mode) { +void Animation::DrawProgressBar(u64 currentProgress, u64 totalProgress) { if (config->progressDisplay()) { // Outline of progressbar. Gui::Draw_Rect(30, 120, 340, 30, BLACK); - - if (mode == 1) { - Gui::Draw_Rect(31, 121, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, progressBar); - } else { - Gui::Draw_Rect(31, 121, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, config->progressbarColor()); - } - } -} - -void Animation::DrawProgressBarInstall(u64 currentProgress, u64 totalProgress, int mode) { - if (config->progressDisplay()) { - // Outline of progressbar. - Gui::Draw_Rect(30, 120, 340, 30, BLACK); - - if (mode == 1) { - Gui::Draw_Rect(31, 121, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, progressBar); - } else { - Gui::Draw_Rect(31, 121, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, config->progressbarColor()); - } - } -} - -void Animation::DrawProgressBarExtract(u64 currentProgress, u64 totalProgress, int mode) { - if (config->progressDisplay()) { - // Outline of progressbar. - Gui::Draw_Rect(30, 140, 340, 30, BLACK); - - if (mode == 1) { - Gui::Draw_Rect(31, 141, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, progressBar); - } else { - Gui::Draw_Rect(31, 141, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, config->progressbarColor()); - } + Gui::Draw_Rect(31, 121, (int)(((float)currentProgress / (float)totalProgress) * 338.0f), 28, isScriptSelected ? progressBar : config->progressbarColor()); } } @@ -77,15 +46,9 @@ void Animation::Button(int x, int y, float speed) { static float timer = 0.0f; float highlight_multiplier = fmax(0.0, fabs(fmod(timer, 1.0) - 0.5) / 0.5); u8 r, g, b; - if (isScriptSelected) { - r = selected & 0xFF; - g = (selected >> 8) & 0xFF; - b = (selected >> 16) & 0xFF; - } else { - r = config->selectedColor() & 0xFF; - g = (config->selectedColor() >> 8) & 0xFF; - b = (config->selectedColor() >> 16) & 0xFF; - } + r = (isScriptSelected ? selected : config->selectedColor()) & 0xFF; + g = ((isScriptSelected ? selected : config->selectedColor()) >> 8) & 0xFF; + b = ((isScriptSelected ? selected : config->selectedColor()) >> 16) & 0xFF; u32 color = C2D_Color32(r + (255 - r) * highlight_multiplier, g + (255 - g) * highlight_multiplier, b + (255 - b) * highlight_multiplier, 255); diff --git a/source/download/download.cpp b/source/download/download.cpp index b3962d9..89bf984 100644 --- a/source/download/download.cpp +++ b/source/download/download.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -50,7 +50,7 @@ extern int filesExtracted; extern std::string extractingFile; char progressBarMsg[128] = ""; bool showProgressBar = false; -int progressBarType = 0; // 0 = Download | 1 = Extract | 2 = Install +ProgressBar progressbarType = ProgressBar::Downloading; // That are our extract Progressbar variables. extern u64 extractSize, writeOffset; @@ -351,13 +351,8 @@ int SelectRelease(std::vector bruh) { C2D_TargetClear(Top, BLACK); C2D_TargetClear(Bottom, BLACK); GFX::DrawTop(); - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.7f, TextColor, Lang::get("VERSION_SELECT"), 400); - Gui::DrawString(397-Gui::GetStringWidth(0.6f, releaseAmount), 239-Gui::GetStringHeight(0.6f, releaseAmount), 0.6f, TextColor, releaseAmount); - } else { - Gui::DrawStringCentered(0, 2, 0.7f, TextColor, Lang::get("VERSION_SELECT"), 400); - Gui::DrawString(397-Gui::GetStringWidth(0.6f, releaseAmount), 237-Gui::GetStringHeight(0.6f, releaseAmount), 0.6f, TextColor, releaseAmount); - } + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, TextColor, Lang::get("VERSION_SELECT"), 400); + Gui::DrawString(397-Gui::GetStringWidth(0.6f, releaseAmount), (config->useBars() ? 239 : 237)-Gui::GetStringHeight(0.6f, releaseAmount), 0.6f, TextColor, releaseAmount); // Display Informations. Gui::DrawStringCentered(0, 35, 0.7f, TextColor, Lang::get("TAG_NAME") + std::string(bruh[selectedRelease].TagName), 400); Gui::DrawStringCentered(0, 65, 0.7f, TextColor, Lang::get("TARGET") + std::string(bruh[selectedRelease].Target), 400); @@ -570,6 +565,7 @@ Result downloadFromRelease(std::string url, std::string asset, std::string path, } } } + if (parsedAPI.size() == 0) { // All were prereleases and those are being ignored return -2; // TODO: Maybe change this? I'm note sure what good return values are -Pk11 @@ -615,7 +611,7 @@ Result downloadFromRelease(std::string url, std::string asset, std::string path, } else { snprintf(progressBarMsg, sizeof(progressBarMsg), Message.c_str()); showProgressBar = true; - progressBarType = 0; + progressbarType = ProgressBar::Downloading; Threads::create((ThreadFunc)displayProgressBar); ret = downloadToFile(assetUrl, path); } @@ -850,89 +846,53 @@ void displayProgressBar() { downloadTotal = downloadNow; } - if (progressBarType == 0) curl_easy_getinfo(hnd, CURLINFO_SPEED_DOWNLOAD_T, &downloadSpeed); // Get download speed. + if (progressbarType == ProgressBar::Downloading) curl_easy_getinfo(hnd, CURLINFO_SPEED_DOWNLOAD_T, &downloadSpeed); // Get download speed. - // Downloading. - if (progressBarType == 0){ - snprintf(str, sizeof(str), "%s / %s (%.2f%%) \n\n\n\n\n %s %lld %s", - formatBytes(downloadNow).c_str(), - formatBytes(downloadTotal).c_str(), - ((float)downloadNow/(float)downloadTotal) * 100.0f, - Lang::get("DOWNLOAD_SPEED").c_str(), (downloadSpeed / 1000), Lang::get("KB_PER_SECOND").c_str()); - // Extracting. - } else if (progressBarType == 1) { - snprintf(str, sizeof(str), "%s / %s (%.2f%%)", - formatBytes(writeOffset).c_str(), - formatBytes(extractSize).c_str(), - ((float)writeOffset/(float)extractSize) * 100.0f); - // Installing. - } else if (progressBarType == 2){ - snprintf(str, sizeof(str), "%s / %s (%.2f%%)", - formatBytes(installOffset).c_str(), - formatBytes(installSize).c_str(), - ((float)installOffset/(float)installSize) * 100.0f); - }; + switch(progressbarType) { + case ProgressBar::Downloading: + snprintf(str, sizeof(str), "%s / %s (%.2f%%) \n\n\n\n\n %s %lld %s", + formatBytes(downloadNow).c_str(), + formatBytes(downloadTotal).c_str(), + ((float)downloadNow/(float)downloadTotal) * 100.0f, + Lang::get("DOWNLOAD_SPEED").c_str(), (downloadSpeed / 1000), Lang::get("KB_PER_SECOND").c_str()); + break; + case ProgressBar::Extracting: + snprintf(str, sizeof(str), "%s / %s (%.2f%%)", + formatBytes(writeOffset).c_str(), + formatBytes(extractSize).c_str(), + ((float)writeOffset/(float)extractSize) * 100.0f); + break; + case ProgressBar::Installing: + snprintf(str, sizeof(str), "%s / %s (%.2f%%)", + formatBytes(installOffset).c_str(), + formatBytes(installSize).c_str(), + ((float)installOffset/(float)installSize) * 100.0f); + break; + } Gui::clearTextBufs(); C3D_FrameBegin(C3D_FRAME_SYNCDRAW); C2D_TargetClear(Top, BLACK); C2D_TargetClear(Bottom, BLACK); GFX::DrawTop(); - // Display this by all. - if (isScriptSelected == true) { - Gui::DrawStringCentered(0, 1, 0.7f, TextColor, progressBarMsg, 400); - } else { - Gui::DrawStringCentered(0, 1, 0.7f, config->textColor(), progressBarMsg, 400); - } + Gui::DrawStringCentered(0, 1, 0.7f, isScriptSelected ? TextColor : config->textColor(), progressBarMsg, 400); // Only display this by downloading. - if (progressBarType == 0) { - if (isScriptSelected == true) { - Gui::DrawStringCentered(0, 80, 0.6f, TextColor, str, 400); - } else { - Gui::DrawStringCentered(0, 80, 0.6f, config->textColor(), str, 400); - } - - if (isScriptSelected == true) { - Animation::DrawProgressBar(downloadNow, downloadTotal, 1); - } else { - Animation::DrawProgressBar(downloadNow, downloadTotal, 2); - } - } - - // Only Display this by extracting. - if (progressBarType == 1) { - // Text. - if (isScriptSelected == true) { - Gui::DrawStringCentered(0, 180, 0.6f, TextColor, str, 400); - Gui::DrawStringCentered(0, 100, 0.6f, TextColor, std::to_string(filesExtracted) + " " + (filesExtracted == 1 ? (Lang::get("FILE_EXTRACTED")).c_str() :(Lang::get("FILES_EXTRACTED"))), 400); - Gui::DrawStringCentered(0, 40, 0.6f, TextColor, Lang::get("CURRENTLY_EXTRACTING") + "\n" + extractingFile, 400); - } else { - Gui::DrawStringCentered(0, 180, 0.6f, config->textColor(), str, 400); - Gui::DrawStringCentered(0, 100, 0.6f, config->textColor(), std::to_string(filesExtracted) + " " + (filesExtracted == 1 ? (Lang::get("FILE_EXTRACTED")).c_str() :(Lang::get("FILES_EXTRACTED"))), 400); - Gui::DrawStringCentered(0, 40, 0.6f, config->textColor(), Lang::get("CURRENTLY_EXTRACTING") + "\n" + extractingFile, 400); - } - // Progressbar. - if (isScriptSelected == true) { - Animation::DrawProgressBarExtract(writeOffset, extractSize, 1); - } else { - Animation::DrawProgressBarExtract(writeOffset, extractSize, 2); - } - } - - // Only display this by installing. - if (progressBarType == 2) { - if (isScriptSelected == true) { - Gui::DrawStringCentered(0, 80, 0.6f, TextColor, str, 400); - } else { - Gui::DrawStringCentered(0, 80, 0.6f, config->textColor(), str, 400); - } - - if (isScriptSelected == true) { - Animation::DrawProgressBarInstall(installOffset, installSize, 1); - } else { - Animation::DrawProgressBarInstall(installOffset, installSize, 2); - } + switch(progressbarType) { + case ProgressBar::Downloading: + Gui::DrawStringCentered(0, 80, 0.6f, isScriptSelected ? TextColor : config->textColor(), str, 400); + Animation::DrawProgressBar(downloadNow, downloadTotal); + break; + case ProgressBar::Extracting: + Gui::DrawStringCentered(0, 180, 0.6f, isScriptSelected ? TextColor : config->textColor(), str, 400); + Gui::DrawStringCentered(0, 100, 0.6f, isScriptSelected ? TextColor : config->textColor(), std::to_string(filesExtracted) + " " + (filesExtracted == 1 ? (Lang::get("FILE_EXTRACTED")).c_str() :(Lang::get("FILES_EXTRACTED"))), 400); + Gui::DrawStringCentered(0, 40, 0.6f, isScriptSelected ? TextColor : config->textColor(), Lang::get("CURRENTLY_EXTRACTING") + "\n" + extractingFile, 400); + Animation::DrawProgressBar(writeOffset, extractSize); + break; + case ProgressBar::Installing: + Gui::DrawStringCentered(0, 80, 0.6f, isScriptSelected ? TextColor : config->textColor(), str, 400); + Animation::DrawProgressBar(installOffset, installSize); + break; } GFX::DrawBottom(); C3D_FrameEnd(0); diff --git a/source/gui/gfx.cpp b/source/gui/gfx.cpp index ca8f0f7..bd05d94 100644 --- a/source/gui/gfx.cpp +++ b/source/gui/gfx.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,50 +29,27 @@ extern std::unique_ptr config; extern bool isScriptSelected; -extern u32 barColor; -extern u32 bgTopColor; -extern u32 bgBottomColor; -extern u32 TextColor; +extern u32 barColor, bgTopColor, bgBottomColor, TextColor; void GFX::DrawTop(void) { Gui::ScreenDraw(Top); - if (isScriptSelected == false) { - Gui::Draw_Rect(0, 0, 400, 25, config->barColor()); - Gui::Draw_Rect(0, 25, 400, 190, config->topBG()); - Gui::Draw_Rect(0, 215, 400, 25, config->barColor()); - if (config->useBars() == true) { - DrawSprite(sprites_top_screen_top_idx, 0, 0); - DrawSprite(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); - if (config->useBars() == true) { - DrawSprite(sprites_top_screen_top_idx, 0, 0); - DrawSprite(sprites_top_screen_bot_idx, 0, 215); - } + Gui::Draw_Rect(0, 0, 400, 25, isScriptSelected ? barColor : config->barColor()); + Gui::Draw_Rect(0, 25, 400, 190, isScriptSelected ? bgTopColor : config->topBG()); + Gui::Draw_Rect(0, 215, 400, 25, isScriptSelected ? barColor : config->barColor()); + if (config->useBars()) { + DrawSprite(sprites_top_screen_top_idx, 0, 0); + DrawSprite(sprites_top_screen_bot_idx, 0, 215); } } void GFX::DrawBottom(void) { Gui::ScreenDraw(Bottom); - if (isScriptSelected == false) { - Gui::Draw_Rect(0, 0, 320, 25, config->barColor()); - Gui::Draw_Rect(0, 25, 320, 190, config->bottomBG()); - Gui::Draw_Rect(0, 215, 320, 25, config->barColor()); - if (config->useBars() == true) { - DrawSprite(sprites_bottom_screen_top_idx, 0, 0); - DrawSprite(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); - if (config->useBars() == true) { - DrawSprite(sprites_bottom_screen_top_idx, 0, 0); - DrawSprite(sprites_bottom_screen_bot_idx, 0, 215); - } + Gui::Draw_Rect(0, 0, 320, 25, isScriptSelected ? barColor : config->barColor()); + Gui::Draw_Rect(0, 25, 320, 190, isScriptSelected ? bgBottomColor : config->bottomBG()); + Gui::Draw_Rect(0, 215, 320, 25, isScriptSelected ? barColor : config->barColor()); + if (config->useBars()) { + DrawSprite(sprites_bottom_screen_top_idx, 0, 0); + DrawSprite(sprites_bottom_screen_bot_idx, 0, 215); } } @@ -84,17 +61,10 @@ void GFX::DrawSprite(int img, int x, int y, float ScaleX, float ScaleY) { void GFX::DrawSpriteBlend(int img, int x, int y, float ScaleX, float ScaleY) { C2D_ImageTint tint; - if (isScriptSelected) { - C2D_SetImageTint(&tint, C2D_TopLeft, TextColor, 0.5); - C2D_SetImageTint(&tint, C2D_TopRight, TextColor, 0.5); - C2D_SetImageTint(&tint, C2D_BotLeft, TextColor, 0.5); - C2D_SetImageTint(&tint, C2D_BotRight, TextColor, 0.5); - } else { - C2D_SetImageTint(&tint, C2D_TopLeft, config->textColor(), 0.5); - C2D_SetImageTint(&tint, C2D_TopRight, config->textColor(), 0.5); - C2D_SetImageTint(&tint, C2D_BotLeft, config->textColor(), 0.5); - C2D_SetImageTint(&tint, C2D_BotRight, config->textColor(), 0.5); - } + C2D_SetImageTint(&tint, C2D_TopLeft, isScriptSelected ? TextColor : config->textColor(), 0.5); + C2D_SetImageTint(&tint, C2D_TopRight, isScriptSelected ? TextColor : config->textColor(), 0.5); + C2D_SetImageTint(&tint, C2D_BotLeft, isScriptSelected ? TextColor : config->textColor(), 0.5); + C2D_SetImageTint(&tint, C2D_BotRight, isScriptSelected ? TextColor : config->textColor(), 0.5); C2D_DrawImageAt(C2D_SpriteSheetGetImage(sprites, img), x, y, 0.5f, &tint, ScaleX, ScaleY); } @@ -102,17 +72,10 @@ void GFX::DrawSpriteBlend(int img, int x, int y, float ScaleX, float ScaleY) { void GFX::DrawArrow(int x, int y, float rotation, int arrowSprite) { C2D_Sprite sprite; C2D_ImageTint tint; - if (isScriptSelected) { - C2D_SetImageTint(&tint, C2D_TopLeft, TextColor, 0.5); - C2D_SetImageTint(&tint, C2D_TopRight, TextColor, 0.5); - C2D_SetImageTint(&tint, C2D_BotLeft, TextColor, 0.5); - C2D_SetImageTint(&tint, C2D_BotRight, TextColor, 0.5); - } else { - C2D_SetImageTint(&tint, C2D_TopLeft, config->textColor(), 0.5); - C2D_SetImageTint(&tint, C2D_TopRight, config->textColor(), 0.5); - C2D_SetImageTint(&tint, C2D_BotLeft, config->textColor(), 0.5); - C2D_SetImageTint(&tint, C2D_BotRight, config->textColor(), 0.5); - } + C2D_SetImageTint(&tint, C2D_TopLeft, isScriptSelected ? TextColor : config->textColor(), 0.5); + C2D_SetImageTint(&tint, C2D_TopRight, isScriptSelected ? TextColor : config->textColor(), 0.5); + C2D_SetImageTint(&tint, C2D_BotLeft, isScriptSelected ? TextColor : config->textColor(), 0.5); + C2D_SetImageTint(&tint, C2D_BotRight, isScriptSelected ? TextColor : config->textColor(), 0.5); if (arrowSprite == 0) { C2D_SpriteFromSheet(&sprite, sprites, sprites_arrow_idx); @@ -134,11 +97,5 @@ void GFX::DrawButton(int x, int y, std::string ButtonText, u32 color) { C2D_SetImageTint(&tint, C2D_BotLeft, color, 0.5); C2D_SetImageTint(&tint, C2D_BotRight, color, 0.5); C2D_DrawImageAt(C2D_SpriteSheetGetImage(sprites, sprites_button_idx), x, y, 0.5f, &tint); - - // Draw String. TODO: Center. - if (isScriptSelected) { - Gui::DrawStringCentered(- (158/2) + x, y + (61/2) - (Gui::GetStringHeight(0.6f, ButtonText) / 2), 0.6f, TextColor, ButtonText, 145, 30); - } else { - Gui::DrawStringCentered(- (158/2) + x, y + (61/2) - (Gui::GetStringHeight(0.6f, ButtonText) / 2), 0.6f, config->textColor(), ButtonText, 145, 30); - } + Gui::DrawStringCentered(- (158/2) + x, y + (61/2) - (Gui::GetStringHeight(0.6f, ButtonText) / 2), 0.6f, isScriptSelected ? TextColor : config->textColor(), ButtonText, 145, 30); } \ No newline at end of file diff --git a/source/gui/keyboard.cpp b/source/gui/keyboard.cpp index 7216876..9d40694 100644 --- a/source/gui/keyboard.cpp +++ b/source/gui/keyboard.cpp @@ -1,3 +1,29 @@ +/* +* This file is part of Universal-Updater +* Copyright (C) 2019-2020 Universal-Team +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* Additional Terms 7.b and 7.c of GPLv3 apply to this file: +* * Requiring preservation of specified reasonable legal notices or +* author attributions in that material or in the Appropriate Legal +* Notices displayed by works containing it. +* * Prohibiting misrepresentation of the origin of that material, +* or requiring that modified versions of such material be marked in +* reasonable ways as different from the original version. +*/ + #include "config.hpp" #include "gfx.hpp" #include "gui.hpp" @@ -80,7 +106,7 @@ extern bool touching(touchPosition touch, Structs::ButtonPos button); void Input::DrawNumpad() { - for(uint i=0;i<(sizeof(NumpadStruct)/sizeof(NumpadStruct[0]));i++) { + for(uint i = 0; i < (sizeof(NumpadStruct)/sizeof(NumpadStruct[0])); i++) { Gui::Draw_Rect(NumpadStruct[i].x, NumpadStruct[i].y, 60, 50, config->barColor()); char c[2] = {NumpadStruct[i].character[0]}; Gui::DrawString(NumpadStruct[i].x+25, NumpadStruct[i].y+15, 0.72f, config->textColor(), c, 50); @@ -88,7 +114,7 @@ void Input::DrawNumpad() { } void Input::drawKeyboard() { - for(uint i=0;i<(sizeof(keysQWERTY)/sizeof(keysQWERTY[0]));i++) { + for(uint i = 0; i < (sizeof(keysQWERTY)/sizeof(keysQWERTY[0])); i++) { C2D_DrawRectSolid(keysQWERTY[i].x, keysQWERTY[i].y+103, 0.5f, 20, 20, config->barColor() & C2D_Color32(255, 255, 255, 200)); if (shift) { char c[2] = {caps ? (char)toupper(keysQWERTYShift[i].character[0]) : keysQWERTYShift[i].character[0]}; @@ -99,7 +125,7 @@ void Input::drawKeyboard() { } } - for(uint i=0;i<(sizeof(modifierKeys)/sizeof(modifierKeys[0]));i++) { + for(uint i = 0; i < (sizeof(modifierKeys)/sizeof(modifierKeys[0])); i++) { std::string enter = modifierKeys[2].character; std::string arrowUp = modifierKeys[3].character; std::string backSpace = modifierKeys[0].character; @@ -234,7 +260,7 @@ std::string Input::getString(uint maxLength, std::string Text, float inputTextSi touchRead(&touch); if (string.length() < maxLength) { // Check if a regular key was pressed - for(uint i=0;i<(sizeof(keysQWERTY)/sizeof(keysQWERTY[0]));i++) { + for(uint i = 0; i < (sizeof(keysQWERTY)/sizeof(keysQWERTY[0])); i++) { if ((touch.px > keysQWERTY[i].x-2 && touch.px < keysQWERTY[i].x+18) && (touch.py > keysQWERTY[i].y+(103)-2 && touch.py < keysQWERTY[i].y+18+(103))) { char c = (shift ? keysQWERTYShift[i] : keysQWERTY[i]).character[0]; string += (shift || caps ? toupper(c) : c); @@ -244,7 +270,7 @@ std::string Input::getString(uint maxLength, std::string Text, float inputTextSi } } // Check if a modifier key was pressed - for(uint i=0;i<(sizeof(modifierKeys)/sizeof(modifierKeys[0]));i++) { + for(uint i = 0; i < (sizeof(modifierKeys)/sizeof(modifierKeys[0])); i++) { if ((touch.px > modifierKeys[i].x-2 && touch.px < modifierKeys[i].x+modifierKeys[i].w+2) && (touch.py > modifierKeys[i].y+(103)-2 && touch.py < modifierKeys[i].y+18+(103))) { if (modifierKeys[i].character == "\uE071") { string = string.substr(0, string.length()-1); diff --git a/source/gui/msg.cpp b/source/gui/msg.cpp index 06e9665..9e9c392 100644 --- a/source/gui/msg.cpp +++ b/source/gui/msg.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,10 +30,7 @@ extern std::unique_ptr config; extern bool isScriptSelected; -extern u32 barColor; -extern u32 bgTopColor; -extern u32 bgBottomColor; -extern u32 TextColor; +extern u32 barColor, bgTopColor, bgBottomColor, TextColor; // I do not think we need that at all. void Msg::DisplayStartMSG() { @@ -61,12 +58,7 @@ void Msg::DisplayMsg(std::string text) { C2D_TargetClear(Top, BLACK); C2D_TargetClear(Bottom, BLACK); GFX::DrawTop(); - if (isScriptSelected == false) { - Gui::DrawStringCentered(0, (240-Gui::GetStringHeight(0.6f, text))/2, 0.6f, config->textColor(), text, 395, 70); - } else if (isScriptSelected == true) { - Gui::DrawStringCentered(0, (240-Gui::GetStringHeight(0.6f, text))/2, 0.6f, TextColor, text, 395, 70); - } - + Gui::DrawStringCentered(0, (240-Gui::GetStringHeight(0.6f, text))/2, 0.6f, isScriptSelected ? TextColor : config->textColor(), text, 395, 70); GFX::DrawBottom(); C3D_FrameEnd(0); } @@ -77,12 +69,7 @@ void Msg::DisplayWarnMsg(std::string Text) { C2D_TargetClear(Top, BLACK); C2D_TargetClear(Bottom, BLACK); GFX::DrawTop(); - if (isScriptSelected == false) { - Gui::DrawStringCentered(0, 1, 0.6f, config->textColor(), Text, 400); - } else if (isScriptSelected == true) { - Gui::DrawStringCentered(0, 1, 0.6f, TextColor, Text, 400); - } - + Gui::DrawStringCentered(0, 1, 0.6f, isScriptSelected ? TextColor : config->textColor(), Text, 400); GFX::DrawBottom(); C3D_FrameEnd(0); for (int i = 0; i < 60*3; i++) { @@ -91,9 +78,9 @@ void Msg::DisplayWarnMsg(std::string Text) { } -std::vector promptBtn = { +const std::vector promptBtn = { {10, 100, 140, 35}, // Yes. - {170, 100, 140, 35}, // No. + {170, 100, 140, 35} // No. }; extern touchPosition touch; @@ -106,26 +93,14 @@ bool Msg::promptMsg(std::string promptMsg) { C2D_TargetClear(Top, BLACK); C2D_TargetClear(Bottom, BLACK); GFX::DrawTop(); - if (isScriptSelected == false) { - Gui::DrawStringCentered(0, (240-Gui::GetStringHeight(0.6f, promptMsg))/2, 0.6f, config->textColor(), promptMsg, 395, 70); - Gui::DrawStringCentered(0, 217, 0.72f, config->textColor(), Lang::get("CONFIRM_OR_CANCEL"), 400); - } else if (isScriptSelected == true) { - Gui::DrawStringCentered(0, (240-Gui::GetStringHeight(0.6f, promptMsg))/2, 0.6f, TextColor, promptMsg, 395, 70); - Gui::DrawStringCentered(0, 217, 0.72f, TextColor, Lang::get("CONFIRM_OR_CANCEL"), 400); - } + Gui::DrawStringCentered(0, (240-Gui::GetStringHeight(0.6f, promptMsg))/2, 0.6f, isScriptSelected ? TextColor : config->textColor(), promptMsg, 395, 70); + Gui::DrawStringCentered(0, 217, 0.72f, isScriptSelected ? TextColor : config->textColor(), Lang::get("CONFIRM_OR_CANCEL"), 400); GFX::DrawBottom(); - if (isScriptSelected == false) { - Gui::Draw_Rect(10, 100, 140, 35, config->barColor()); - Gui::Draw_Rect(170, 100, 140, 35, config->barColor()); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("YES")))/2-150+70, 110, 0.6f, config->textColor(), Lang::get("YES"), 140); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("NO")))/2+150-70, 110, 0.6f, config->textColor(), Lang::get("NO"), 140); - } else if (isScriptSelected == true) { - Gui::Draw_Rect(10, 100, 140, 35, barColor); - Gui::Draw_Rect(170, 100, 140, 35, barColor); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("YES")))/2-150+70, 110, 0.6f, TextColor, Lang::get("YES"), 140); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("NO")))/2+150-70, 110, 0.6f, TextColor, Lang::get("NO"), 140); - } + Gui::Draw_Rect(10, 100, 140, 35, isScriptSelected ? barColor : config->barColor()); + Gui::Draw_Rect(170, 100, 140, 35, isScriptSelected ? barColor : config->barColor()); + Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("YES")))/2-150+70, 110, 0.6f, isScriptSelected ? TextColor : config->textColor(), Lang::get("YES"), 140); + Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("NO")))/2+150-70, 110, 0.6f, isScriptSelected ? TextColor : config->textColor(), Lang::get("NO"), 140); C3D_FrameEnd(0); while(1) { diff --git a/source/init.cpp b/source/init.cpp index 2363411..61f251b 100644 --- a/source/init.cpp +++ b/source/init.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -63,7 +63,7 @@ bool touching(touchPosition touch, Structs::ButtonPos button) { } void Init::loadSoundEffects(void) { - if (dspFound == true) { + if (dspFound) { if (access(config->musicPath().c_str(), F_OK ) != -1) { bgm = new sound(config->musicPath(), 1, true); songIsFound = true; @@ -72,13 +72,13 @@ void Init::loadSoundEffects(void) { } void Init::playMusic(void) { - if (songIsFound == true) { + if (songIsFound) { bgm->play(); } } void Init::stopMusic(void) { - if (songIsFound == true) { + if (songIsFound) { bgm->stop(); } } @@ -109,7 +109,7 @@ Result Init::Initialize() { // In case it takes a bit longer to autoboot a script or so. Msg::DisplayStartMSG(); - if (config->logging() == true) { + if (config->logging()) { Logging::createLogFile(); } @@ -186,11 +186,11 @@ Result Init::MainLoop() { } Result Init::Exit() { - if (songIsFound == true) { + if (songIsFound) { stopMusic(); } delete bgm; - if (dspFound == true) { + if (dspFound) { ndspExit(); } diff --git a/source/lang/lang.cpp b/source/lang/lang.cpp index 3991f58..77cc888 100644 --- a/source/lang/lang.cpp +++ b/source/lang/lang.cpp @@ -1,3 +1,29 @@ +/* +* This file is part of Universal-Updater +* Copyright (C) 2019-2020 Universal-Team +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* Additional Terms 7.b and 7.c of GPLv3 apply to this file: +* * Requiring preservation of specified reasonable legal notices or +* author attributions in that material or in the Appropriate Legal +* Notices displayed by works containing it. +* * Prohibiting misrepresentation of the origin of that material, +* or requiring that modified versions of such material be marked in +* reasonable ways as different from the original version. +*/ + #include "config.hpp" #include "lang.hpp" @@ -8,9 +34,10 @@ extern std::unique_ptr config; nlohmann::json appJson; std::string Lang::get(const std::string &key) { - if(!appJson.contains(key)) { + if (!appJson.contains(key)) { return "MISSING: " + key; } + return appJson.at(key).get_ref(); } @@ -20,7 +47,7 @@ void Lang::load(const std::string lang) { FILE* values; if (config->langPath() == 1) { // Check if exist. - if (access("sdmc:/3ds/Universal-Updater/app.json", F_OK) == 0 ) { + if (access("sdmc:/3ds/Universal-Updater/app.json", F_OK) == 0) { values = fopen(("sdmc:/3ds/Universal-Updater/app.json"), "rt"); appJson = nlohmann::json::parse(values, nullptr, false); fclose(values); @@ -35,7 +62,7 @@ void Lang::load(const std::string lang) { } else { // Check if exist. - if (access(("romfs:/lang/" + lang + "/app.json").c_str(), F_OK) == 0 ) { + if (access(("romfs:/lang/" + lang + "/app.json").c_str(), F_OK) == 0) { values = fopen(std::string(("romfs:/lang/" + lang + "/app.json")).c_str(), "rt"); appJson = nlohmann::json::parse(values, nullptr, false); fclose(values); diff --git a/source/logging.cpp b/source/logging.cpp index 09ec299..3e8b619 100644 --- a/source/logging.cpp +++ b/source/logging.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source/main.cpp b/source/main.cpp index 8f0849a..886e91e 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source/screens/credits.cpp b/source/screens/credits.cpp index 3d67095..c39346e 100644 --- a/source/screens/credits.cpp +++ b/source/screens/credits.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -84,11 +84,7 @@ void Credits::Draw(void) const { title += Lang::get("CREDITS"); GFX::DrawTop(); if (creditsPage != 3) { - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), title, 400); - } else { - Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), title, 400); - } + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, config->textColor(), title, 400); Gui::DrawStringCentered(0, 30, 0.7f, config->textColor(), Lang::get("DEVELOPED_BY"), 390); Gui::DrawStringCentered(0, 60, 0.7f, config->textColor(), Lang::get("MAIN_DEV"), 390); GFX::DrawSprite(sprites_stackie_idx, 5, 85); @@ -113,7 +109,7 @@ void Credits::DrawBottom(void) const { GFX::DrawBottom(); if (creditsPage == 0) { Gui::DrawStringCentered(0, -2, 0.7f, config->textColor(), Lang::get("TRANSLATORS"), 320); - for(int i=0;iunselectedColor()); line1 = Translators[screenPos + i]; line2 = Languages[screenPos + i]; @@ -125,7 +121,7 @@ void Credits::DrawBottom(void) const { } } else if (creditsPage == 1) { Gui::DrawStringCentered(0, -2, 0.7f, config->textColor(), "Universal-Team", 320); - for(int i=0;iunselectedColor()); line1 = UniversalTeam[screenPos + i]; if (screenPos + i == Selection) { @@ -135,7 +131,7 @@ void Credits::DrawBottom(void) const { } } else if (creditsPage == 2) { Gui::DrawStringCentered(0, -2, 0.7f, config->textColor(), Lang::get("SCRIPTCREATORS"), 320); - for(int i=0;iunselectedColor()); line1 = ScriptCreators[screenPos + i]; line2 = ScriptAmount[screenPos + i]; diff --git a/source/screens/ftpScreen.cpp b/source/screens/ftpScreen.cpp index 5ba5318..386b40d 100644 --- a/source/screens/ftpScreen.cpp +++ b/source/screens/ftpScreen.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -50,11 +50,7 @@ void FTPScreen::Draw(void) const { Gui::clearTextBufs(); C3D_FrameBegin(C3D_FRAME_SYNCDRAW); GFX::DrawTop(); - if (config->useBars() == true) { - Gui::DrawString((400-Gui::GetStringWidth(0.7f, Lang::get("FTP_MODE")))/2, 0, 0.7f, config->textColor(), Lang::get("FTP_MODE"), 400); - } else { - Gui::DrawString((400-Gui::GetStringWidth(0.7f, Lang::get("FTP_MODE")))/2, 2, 0.7f, config->textColor(), Lang::get("FTP_MODE"), 400); - } + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, config->textColor(), Lang::get("FTP_MODE"), 400); if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect GFX::DrawBottom(); GFX::DrawArrow(0, 218, 0, 1); @@ -64,13 +60,15 @@ void FTPScreen::Draw(void) const { Gui::DrawStringCentered(0, 40, 0.48f, config->textColor(), Lang::get("FTP_INITIALIZED"), 320); snprintf(buf, 137, "IP: %s:5000", R_FAILED(ret)? Lang::get("FAILED_GET_IP").c_str() : hostname); - if (strlen(ftp_accepted_connection) != 0) + if (strlen(ftp_accepted_connection) != 0) { Gui::DrawStringCentered(0, 80, 0.45f, config->textColor(), ftp_accepted_connection, 320); + } - if (strlen(ftp_file_transfer) != 0) + if (strlen(ftp_file_transfer) != 0) { Gui::DrawStringCentered(0, 150, 0.45f, config->textColor(), ftp_file_transfer, 320); - } - else { + } + + } else { Gui::DrawStringCentered(0, 40, 0.48f, config->textColor(), Lang::get("FAILED_INITIALIZE_FTP"), 320); snprintf(buf, 18, Lang::get("WIFI_NOT_ENABLED").c_str()); } diff --git a/source/screens/mainMenu.cpp b/source/screens/mainMenu.cpp index 20d80e0..1bee2cd 100644 --- a/source/screens/mainMenu.cpp +++ b/source/screens/mainMenu.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,15 +41,8 @@ extern u32 TextColor; void MainMenu::Draw(void) const { GFX::DrawTop(); - - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), "Universal-Updater", 400); - Gui::DrawString(397-Gui::GetStringWidth(0.5f, V_STRING), 239-Gui::GetStringHeight(0.5f, V_STRING), 0.5f, config->textColor(), V_STRING); - } else { - Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), "Universal-Updater", 400); - Gui::DrawString(397-Gui::GetStringWidth(0.5f, V_STRING), 237-Gui::GetStringHeight(0.5f, V_STRING), 0.5f, config->textColor(), V_STRING); - } - + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, config->textColor(), "Universal-Updater", 400); + Gui::DrawString(397-Gui::GetStringWidth(0.5f, V_STRING), (config->useBars() ? 239 : 237)-Gui::GetStringHeight(0.5f, V_STRING), 0.5f, config->textColor(), V_STRING); GFX::DrawSprite(sprites_universal_updater_idx, 110, 30); if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect GFX::DrawBottom(); @@ -76,7 +69,7 @@ void MainMenu::Logic(u32 hDown, u32 hHeld, touchPosition touch) { // Navigation. if (hDown & KEY_UP) { - if(Selection > 1) Selection -= 2; + if (Selection > 1) Selection -= 2; } else if (hDown & KEY_DOWN) { if (Selection < 3 && Selection != 2 && Selection != 3) Selection += 2; } else if (hDown & KEY_LEFT) { diff --git a/source/screens/scriptBrowse.cpp b/source/screens/scriptBrowse.cpp index 071a358..1b431f6 100644 --- a/source/screens/scriptBrowse.cpp +++ b/source/screens/scriptBrowse.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -152,14 +152,8 @@ void ScriptBrowse::DrawBrowse(void) const { std::string revision = std::to_string(int64_t(infoJson[Selection]["curRevision"])); 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->textColor(), revision); - Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), std::string(infoJson[Selection]["title"]), 400); - } else { - Gui::DrawString(397-Gui::GetStringWidth(0.6f, revision), 237-Gui::GetStringHeight(0.6f, revision), 0.6f, config->textColor(), revision); - Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), std::string(infoJson[Selection]["title"]), 400); - } + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, config->textColor(), std::string(infoJson[Selection]["title"]), 400); + Gui::DrawString(397-Gui::GetStringWidth(0.6f, revision), (config->useBars() ? 239 : 237)-Gui::GetStringHeight(0.6f, revision), 0.6f, config->textColor(), revision); Gui::DrawStringCentered(0, 120, 0.6f, config->textColor(), std::string(infoJson[Selection]["shortDesc"]), 400); if (infoJson[Selection]["curRevision"] == -1) { @@ -262,11 +256,7 @@ void ScriptBrowse::DrawBrowse(void) const { void ScriptBrowse::DrawGlossary(void) const { GFX::DrawTop(); if (loaded) { - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), Lang::get("GLOSSARY"), 400); - } else { - Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), Lang::get("GLOSSARY"), 400); - } + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, config->textColor(), Lang::get("GLOSSARY"), 400); Gui::Draw_Rect(20, 30, 30, 30, config->notfoundColor()); Gui::DrawString(65, 35, 0.7f, config->textColor(), Lang::get("SCRIPT_NOT_FOUND"), 300); @@ -360,7 +350,7 @@ void ScriptBrowse::DropDownLogic(u32 hDown, u32 hHeld, touchPosition touch) { } void ScriptBrowse::downloadAll() { - if (infoJson.size() != 0) { + if (infoJson.size() > 0) { for (int i = 0; i < (int)infoJson.size(); i++) { int current = i+1; int total = infoJson.size(); diff --git a/source/screens/scriptCreator.cpp b/source/screens/scriptCreator.cpp index 1b66b68..f4daeb2 100644 --- a/source/screens/scriptCreator.cpp +++ b/source/screens/scriptCreator.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -83,11 +83,7 @@ void ScriptCreator::Draw(void) const { void ScriptCreator::DrawSubMenu(void) const { GFX::DrawTop(); - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), Lang::get("SCRIPTCREATOR"), 400); - } else { - Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), Lang::get("SCRIPTCREATOR"), 400); - } + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, config->textColor(), Lang::get("SCRIPTCREATOR"), 400); if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect GFX::DrawBottom(); @@ -107,11 +103,7 @@ void ScriptCreator::DrawSubMenu(void) const { void ScriptCreator::DrawScriptScreen(void) const { GFX::DrawTop(); - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), "Selected Entry: " + entryName, 400); - } else { - Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), "Selected Entry: " + entryName, 400); - } + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, config->textColor(), "Selected Entry: " + entryName, 400); if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect GFX::DrawBottom(); diff --git a/source/screens/scriptlist.cpp b/source/screens/scriptlist.cpp index f8eb373..0642152 100644 --- a/source/screens/scriptlist.cpp +++ b/source/screens/scriptlist.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -124,13 +124,7 @@ u32 getColor(std::string colorString) { } // Color listing! -u32 barColor; -u32 bgTopColor; -u32 bgBottomColor; -u32 TextColor; -u32 selected; -u32 unselected; -u32 progressBar; +u32 barColor, bgTopColor, bgBottomColor, TextColor, selected, unselected, progressBar; // Load the colors from the script. void loadColors(nlohmann::json &json) { @@ -159,11 +153,7 @@ void loadColors(nlohmann::json &json) { void ScriptList::DrawSubMenu(void) const { GFX::DrawTop(); - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), Lang::get("SCRIPTS_SUBMENU"), 400); - } else { - Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), Lang::get("SCRIPTS_SUBMENU"), 400); - } + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, config->textColor(), Lang::get("SCRIPTS_SUBMENU"), 400); if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect GFX::DrawBottom(); @@ -231,13 +221,8 @@ void ScriptList::DrawList(void) const { std::string line2; std::string scriptAmount = std::to_string(Selection +1) + " | " + std::to_string(fileInfo.size()); GFX::DrawTop(); - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), "Universal-Updater", 400); - Gui::DrawString(397-Gui::GetStringWidth(0.6f, scriptAmount), 239-Gui::GetStringHeight(0.6f, scriptAmount), 0.6f, config->textColor(), scriptAmount); - } else { - Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), "Universal-Updater", 400); - Gui::DrawString(397-Gui::GetStringWidth(0.6f, scriptAmount), 237-Gui::GetStringHeight(0.6f, scriptAmount), 0.6f, config->textColor(), scriptAmount); - } + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, config->textColor(), "Universal-Updater", 400); + Gui::DrawString(397-Gui::GetStringWidth(0.6f, scriptAmount), (config->useBars() ? 239 : 237)-Gui::GetStringHeight(0.6f, scriptAmount), 0.6f, config->textColor(), scriptAmount); Gui::DrawStringCentered(0, 80, 0.7f, config->textColor(), Lang::get("TITLE") + std::string(fileInfo[Selection].title), 400); Gui::DrawStringCentered(0, 100, 0.7f, config->textColor(), Lang::get("AUTHOR") + std::string(fileInfo[Selection].author), 400); @@ -312,14 +297,8 @@ void ScriptList::DrawSingleObject(void) const { std::string info; std::string entryAmount = std::to_string(Selection+1) + " | " + std::to_string(fileInfo2.size()); GFX::DrawTop(); - - 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, TextColor, 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, TextColor, entryAmount); - } + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, TextColor, selectedTitle, 400); + Gui::DrawString(397-Gui::GetStringWidth(0.6f, entryAmount), (config->useBars() ? 239 : 237)-Gui::GetStringHeight(0.6f, entryAmount), 0.6f, TextColor, entryAmount); for(uint i = 0; i < lines.size(); i++) { Gui::DrawStringCentered(0, 120-((lines.size()*20)/2)+i*20, 0.6f, TextColor, lines[i], 400); diff --git a/source/screens/settings.cpp b/source/screens/settings.cpp index 96586e1..6d115af 100644 --- a/source/screens/settings.cpp +++ b/source/screens/settings.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -51,12 +51,7 @@ void Settings::Draw(void) const { void Settings::DrawSubMenu(void) const { GFX::DrawTop(); - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), "Universal-Updater", 400); - } else { - Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), "Universal-Updater", 400); - } - + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, config->textColor(), "Universal-Updater", 400); if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect GFX::DrawBottom(); GFX::DrawArrow(0, 218, 0, 1); @@ -88,11 +83,7 @@ const std::vector languages = { void Settings::DrawLanguageSelection(void) const { std::string line1; GFX::DrawTop(); - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), Lang::get("SELECT_LANG"), 400); - } else { - Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), Lang::get("SELECT_LANG"), 400); - } + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, config->textColor(), Lang::get("SELECT_LANG"), 400); if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect GFX::DrawBottom(); @@ -128,11 +119,7 @@ const std::vector colorList = { void Settings::DrawColorChanging(void) const { std::string line1; GFX::DrawTop(); - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), "Universal-Updater", 400); - } else { - Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), "Universal-Updater", 400); - } + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, config->textColor(), "Universal-Updater", 400); if (!dropDownMenu) { if (colorMode == 3) { @@ -233,12 +220,7 @@ void Settings::DrawColorChanging(void) const { void Settings::DrawMiscSettings(void) const { GFX::DrawTop(); - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), "Universal-Updater", 400); - } else { - Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), "Universal-Updater", 400); - } - + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, config->textColor(), "Universal-Updater", 400); if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect GFX::DrawBottom(); GFX::DrawArrow(0, 218, 0, 1); diff --git a/source/screens/startup.cpp b/source/screens/startup.cpp index 5ec7a76..9a10e41 100644 --- a/source/screens/startup.cpp +++ b/source/screens/startup.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source/screens/unistore.cpp b/source/screens/unistore.cpp index 5bea6d1..ade64c7 100644 --- a/source/screens/unistore.cpp +++ b/source/screens/unistore.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -142,12 +142,7 @@ void UniStore::loadStoreDesc(void) { void UniStore::DrawSubMenu(void) const { GFX::DrawTop(); - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), Lang::get("UNISTORE_SUBMENU"), 400); - } else { - Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), Lang::get("UNISTORE_SUBMENU"), 400); - } - + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, config->textColor(), Lang::get("UNISTORE_SUBMENU"), 400); GFX::DrawSprite(sprites_uniStore_HD_idx, 140, 50, 0.2, 0.2); if (fadealpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect GFX::DrawBottom(); @@ -169,15 +164,9 @@ void UniStore::DrawStoreList(void) const { std::string line2; std::string storeAmount = std::to_string(Selection +1) + " | " + std::to_string(storeInfo.size()); GFX::DrawTop(); - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.7f, config->textColor(), storeInfo[Selection].title, 400); - Gui::DrawString(5, 220, 0.6f, config->textColor(), Lang::get("UNISTORE_VERSION") + std::to_string(storeInfo[Selection].version), 400); - Gui::DrawString(397-Gui::GetStringWidth(0.6f, storeAmount), 239-Gui::GetStringHeight(0.6f, storeAmount), 0.6f, config->textColor(), storeAmount); - } else { - Gui::DrawStringCentered(0, 2, 0.7f, config->textColor(), storeInfo[Selection].title, 400); - Gui::DrawString(5, 218, 0.6f, config->textColor(), Lang::get("UNISTORE_VERSION") + std::to_string(storeInfo[Selection].version), 400); - Gui::DrawString(397-Gui::GetStringWidth(0.6f, storeAmount), 237-Gui::GetStringHeight(0.6f, storeAmount), 0.6f, config->textColor(), storeAmount); - } + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, config->textColor(), storeInfo[Selection].title, 400); + Gui::DrawString(5, config->useBars() ? 220 : 218, 0.6f, config->textColor(), Lang::get("UNISTORE_VERSION") + std::to_string(storeInfo[Selection].version), 400); + Gui::DrawString(397-Gui::GetStringWidth(0.6f, storeAmount), (config->useBars() ? 239 : 237)-Gui::GetStringHeight(0.6f, storeAmount), 0.6f, config->textColor(), storeAmount); for(uint i = 0; i < descLines.size(); i++) { Gui::DrawStringCentered(0, 120-((descLines.size()*20)/2)+i*20, 0.6f, config->textColor(), descLines[i], 400); @@ -755,7 +744,9 @@ void UniStore::SearchLogic(u32 hDown, u32 hHeld, touchPosition touch) { Selection = 0; mode = 4; } else if (Selection == 2) { - ScriptHelper::downloadFile("https://tinydb.eiphax.tech/api/tinydb.unistore", config->storePath() + "TinyDB.unistore", Lang::get("DOWNLOADING") + "TinyDB"); + if (Msg::promptMsg("TinyDB might be down. This would lead to Download Failed!\nDo you still like to continue?")) { + ScriptHelper::downloadFile("https://tinydb.eiphax.tech/api/tinydb.unistore", config->storePath() + "TinyDB.unistore", Lang::get("DOWNLOADING") + "TinyDB"); + } } else if (Selection == 3) { ScriptHelper::downloadFile("https://db.universal-team.net/unistore/universal-db.unistore", config->storePath() + "Universal-DB.unistore", Lang::get("DOWNLOADING") + "Universal DB"); } @@ -768,7 +759,9 @@ void UniStore::SearchLogic(u32 hDown, u32 hHeld, touchPosition touch) { Selection = 0; mode = 4; } else if (hDown & KEY_TOUCH && touching(touch, URLBtn[2])) { - ScriptHelper::downloadFile("https://tinydb.eiphax.tech/api/tinydb.unistore", config->storePath() + "TinyDB.unistore", Lang::get("DOWNLOADING") + "TinyDB"); + if (Msg::promptMsg("TinyDB might be down. This would lead to Download Failed!\nDo you still like to continue?")) { + ScriptHelper::downloadFile("https://tinydb.eiphax.tech/api/tinydb.unistore", config->storePath() + "TinyDB.unistore", Lang::get("DOWNLOADING") + "TinyDB"); + } } else if (hDown & KEY_TOUCH && touching(touch, URLBtn[3])) { ScriptHelper::downloadFile("https://db.universal-team.net/unistore/universal-db.unistore", config->storePath() + "Universal-DB.unistore", Lang::get("DOWNLOADING") + "Universal DB"); } diff --git a/source/screens/unistore_v1.cpp b/source/screens/unistore_v1.cpp index 21cccc2..3868741 100644 --- a/source/screens/unistore_v1.cpp +++ b/source/screens/unistore_v1.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,16 +34,9 @@ extern std::unique_ptr config; extern bool touching(touchPosition touch, Structs::ButtonPos button); extern u32 getColor(std::string colorString); -extern bool isScriptSelected; -extern u32 barColor; -extern u32 bgTopColor; -extern u32 bgBottomColor; -extern u32 TextColor; -extern u32 progressBar; -extern u32 selected; -extern u32 unselected; -extern bool didAutoboot; +extern u32 barColor, bgTopColor, bgBottomColor, TextColor, progressBar, selected, unselected; +extern bool didAutoboot, isScriptSelected; UniStoreV1::UniStoreV1(nlohmann::json &JSON, const std::string sheetPath, bool displayInf) { this->storeJson = JSON; @@ -123,13 +116,8 @@ void UniStoreV1::Draw(void) const { } if (displayInformations != false) { - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.7f, TextColor, std::string(this->storeJson["storeInfo"]["title"]), 400); - Gui::DrawString(397-Gui::GetStringWidth(0.6f, entryAmount), 239-Gui::GetStringHeight(0.6f, entryAmount), 0.6f, TextColor, entryAmount); - } else { - Gui::DrawStringCentered(0, 2, 0.7f, TextColor, std::string(this->storeJson["storeInfo"]["title"]), 400); - Gui::DrawString(397-Gui::GetStringWidth(0.6f, entryAmount), 237-Gui::GetStringHeight(0.6f, entryAmount), 0.6f, TextColor, entryAmount); - } + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, TextColor, std::string(this->storeJson["storeInfo"]["title"]), 400); + Gui::DrawString(397-Gui::GetStringWidth(0.6f, entryAmount), (config->useBars() ? 239 : 237)-Gui::GetStringHeight(0.6f, entryAmount), 0.6f, TextColor, entryAmount); Gui::DrawStringCentered(0, 32, 0.6f, TextColor, Lang::get("TITLE") + std::string(this->storeJson["storeContent"][Selection]["info"]["title"]), 400); Gui::DrawStringCentered(0, 57, 0.6f, TextColor, Lang::get("AUTHOR") + std::string(this->storeJson["storeContent"][Selection]["info"]["author"]), 400); diff --git a/source/screens/unistore_v2.cpp b/source/screens/unistore_v2.cpp index 761e5a1..3dc2931 100644 --- a/source/screens/unistore_v2.cpp +++ b/source/screens/unistore_v2.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -287,17 +287,9 @@ void UniStoreV2::displaySelectedEntry(int selection, int storeIndex) const { Gui::DrawStringCentered(0, 218, 0.7f, this->returnTextColor(), std::to_string(this->downloadPage + 1) + " | " + std::to_string(1 + (this->objects.size() / DOWNLOAD_ENTRIES))); if (this->storeJson.at("storeContent").at(selection).at("info").contains("title")) { - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.7f, this->returnTextColor(), (std::string)this->storeJson.at("storeContent").at(selection).at("info").at("title"), 400); - } else { - Gui::DrawStringCentered(0, 2, 0.7f, this->returnTextColor(), (std::string)this->storeJson.at("storeContent").at(selection).at("info").at("title"), 400); - } + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, this->returnTextColor(), (std::string)this->storeJson.at("storeContent").at(selection).at("info").at("title"), 400); } else { - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.7f, this->returnTextColor(), "?", 400); - } else { - Gui::DrawStringCentered(0, 2, 0.7f, this->returnTextColor(), "?", 400); - } + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.7f, this->returnTextColor(), "?", 400); } if (this->storeJson.at("storeContent").at(selection).at("info").contains("author")) { @@ -359,12 +351,7 @@ void UniStoreV2::displaySelectedEntry(int selection, int storeIndex) const { void UniStoreV2::Draw(void) const { if (this->mode == 0) { this->DrawBaseTop(); - - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.6f, this->returnTextColor(), (std::string)this->storeJson.at("storeInfo").at("title"), 400); - } else { - Gui::DrawStringCentered(0, 2, 0.6f, this->returnTextColor(), (std::string)this->storeJson.at("storeInfo").at("title"), 400); - } + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.6f, this->returnTextColor(), (std::string)this->storeJson.at("storeInfo").at("title"), 400); this->DrawGrid(); @@ -380,12 +367,7 @@ void UniStoreV2::Draw(void) const { if (fadealpha > 0) Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); } else if (this->mode == 1) { this->DrawBaseTop(); - - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.6f, this->returnTextColor(), (std::string)this->storeJson.at("storeInfo").at("title"), 400); - } else { - Gui::DrawStringCentered(0, 2, 0.6f, this->returnTextColor(), (std::string)this->storeJson.at("storeInfo").at("title"), 400); - } + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.6f, this->returnTextColor(), (std::string)this->storeJson.at("storeInfo").at("title"), 400); this->DrawList(); Gui::DrawStringCentered(0, 218, 0.6f, this->returnTextColor(), std::to_string(this->storePageList + 1) + " | " + std::to_string((this->sortedStore->getSize() / STORE_ENTRIES_LIST)+1)); @@ -421,24 +403,16 @@ void UniStoreV2::DrawSelectMenu(int option) const { this->DrawBaseTop(); - if (option == 0) { - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.6f, this->returnTextColor(), Lang::get("SELECT_AUTHOR"), 400); - } else { - Gui::DrawStringCentered(0, 2, 0.6f, this->returnTextColor(), Lang::get("SELECT_AUTHOR"), 400); - } - } else if (option == 1) { - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.6f, this->returnTextColor(), Lang::get("SELECT_CATEGORY"), 400); - } else { - Gui::DrawStringCentered(0, 2, 0.6f, this->returnTextColor(), Lang::get("SELECT_CATEGORY"), 400); - } - } else if (option == 2) { - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.6f, this->returnTextColor(), Lang::get("SELECT_CONSOLE"), 400); - } else { - Gui::DrawStringCentered(0, 2, 0.6f, this->returnTextColor(), Lang::get("SELECT_CONSOLE"), 400); - } + switch(option) { + case 0: + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.6f, this->returnTextColor(), Lang::get("SELECT_AUTHOR"), 400); + break; + case 1: + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.6f, this->returnTextColor(), Lang::get("SELECT_CATEGORY"), 400); + break; + case 2: + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.6f, this->returnTextColor(), Lang::get("SELECT_CONSOLE"), 400); + break; } Gui::DrawStringCentered(0, 218, 0.6f, this->returnTextColor(), std::to_string(this->categoryPage + 1) + " | " + std::to_string((options.size() / DOWNLOAD_ENTRIES)+1)); @@ -455,12 +429,16 @@ void UniStoreV2::DrawSelectMenu(int option) const { Gui::DrawStringCentered(0, downloadBoxes[i].y+4, 0.5f, this->returnTextColor(), options[i + (this->categoryPage * DOWNLOAD_ENTRIES)], 280); } } else { - if (option == 0) { - Gui::DrawStringCentered(0, downloadBoxes[0].y+4, 0.5f, this->returnTextColor(), Lang::get("NO_AUTHORS_AVAILABLE"), 280); - } else if (option == 1) { - Gui::DrawStringCentered(0, downloadBoxes[0].y+4, 0.5f, this->returnTextColor(), Lang::get("NO_CATEGORIES_AVAILABLE"), 280); - } else if (option == 2) { - Gui::DrawStringCentered(0, downloadBoxes[0].y+4, 0.5f, this->returnTextColor(), Lang::get("NO_CONSOLES_AVAILABLE"), 280); + switch(option) { + case 0: + Gui::DrawStringCentered(0, downloadBoxes[0].y+4, 0.5f, this->returnTextColor(), Lang::get("NO_AUTHORS_AVAILABLE"), 280); + break; + case 1: + Gui::DrawStringCentered(0, downloadBoxes[0].y+4, 0.5f, this->returnTextColor(), Lang::get("NO_CATEGORIES_AVAILABLE"), 280); + break; + case 2: + Gui::DrawStringCentered(0, downloadBoxes[0].y+4, 0.5f, this->returnTextColor(), Lang::get("NO_CONSOLES_AVAILABLE"), 280); + break; } } } diff --git a/source/utils/colorHelper.cpp b/source/utils/colorHelper.cpp index c311312..968eb28 100644 --- a/source/utils/colorHelper.cpp +++ b/source/utils/colorHelper.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,8 +26,7 @@ #include "colorHelper.hpp" -int ColorHelper::getColorValue(int color, int bgr) -{ +int ColorHelper::getColorValue(int color, int bgr) { char colorName[10]; int i; std::stringstream ss; @@ -40,8 +39,7 @@ int ColorHelper::getColorValue(int color, int bgr) return i; } -std::string ColorHelper::getColorName(int color, int bgr) -{ +std::string ColorHelper::getColorName(int color, int bgr) { char colorName[10]; int i = getColorValue(color, bgr); itoa(i, colorName, 10); diff --git a/source/utils/config.cpp b/source/utils/config.cpp index b45cb38..cb21a3d 100644 --- a/source/utils/config.cpp +++ b/source/utils/config.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,9 +24,9 @@ * reasonable ways as different from the original version. */ +#include "colorHelper.hpp" #include "common.hpp" #include "config.hpp" -#include "colorHelper.hpp" #include #include diff --git a/source/utils/extract.cpp b/source/utils/extract.cpp index 9103d4f..cb6cda2 100644 --- a/source/utils/extract.cpp +++ b/source/utils/extract.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source/utils/fileBrowse.cpp b/source/utils/fileBrowse.cpp index 2470099..d279ad8 100644 --- a/source/utils/fileBrowse.cpp +++ b/source/utils/fileBrowse.cpp @@ -1,3 +1,29 @@ +/* +* This file is part of Universal-Updater +* Copyright (C) 2019-2020 Universal-Team +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* Additional Terms 7.b and 7.c of GPLv3 apply to this file: +* * Requiring preservation of specified reasonable legal notices or +* author attributions in that material or in the Appropriate Legal +* Notices displayed by works containing it. +* * Prohibiting misrepresentation of the origin of that material, +* or requiring that modified versions of such material be marked in +* reasonable ways as different from the original version. +*/ + #include "common.hpp" #include "config.hpp" #include "fileBrowse.hpp" @@ -29,7 +55,7 @@ std::vector dirContents; extern bool touching(touchPosition touch, Structs::ButtonPos button); extern touchPosition touch; -std::vector buttonPositions = { +const std::vector buttonPositions = { {295, 0, 25, 25}, // Arrow Up. {295, 215, 25, 25}, // Arrow Down. {15, 220, 50, 15}, // Open. @@ -178,13 +204,8 @@ std::string selectFilePath(std::string selectText, std::string initialPath, cons GFX::DrawTop(); char path[PATH_MAX]; getcwd(path, PATH_MAX); - if (config->useBars() == true) { - Gui::DrawString((400-(Gui::GetStringWidth(0.60f, path)))/2, 2, 0.60f, config->textColor(), path, 390); - Gui::DrawStringCentered(0, 220, 0.60f, config->textColor(), selectText, 390); - } else { - Gui::DrawString((400-(Gui::GetStringWidth(0.60f, path)))/2, 0, 0.60f, config->textColor(), path, 390); - Gui::DrawStringCentered(0, 218, 0.60f, config->textColor(), selectText, 390); - } + Gui::DrawString((400-(Gui::GetStringWidth(0.60f, path)))/2, config->useBars() ? 0 : 2, 0.60f, config->textColor(), path, 390); + Gui::DrawStringCentered(0, config->useBars() ? 220 : 218, 0.60f, config->textColor(), selectText, 390); GFX::DrawBottom(); if (config->viewMode() == 0) { for(int i = 0; i < ENTRIES_PER_SCREEN && i < (int)dirContents.size(); i++) { @@ -206,11 +227,7 @@ std::string selectFilePath(std::string selectText, std::string initialPath, cons } } - if (config->useBars() == true) { - Gui::DrawStringCentered(0, 0, 0.45f, config->textColor(), Lang::get("FILEBROWSE_MSG"), 260); - } else { - Gui::DrawStringCentered(0, 2, 0.45f, config->textColor(), Lang::get("FILEBROWSE_MSG"), 260); - } + Gui::DrawStringCentered(0, config->useBars() ? 0 : 2, 0.45f, config->textColor(), Lang::get("FILEBROWSE_MSG"), 260); GFX::DrawArrow(295, -1); GFX::DrawArrow(315, 240, 180.0); GFX::DrawSpriteBlend(sprites_view_idx, buttonPositions[6].x, buttonPositions[6].y); diff --git a/source/utils/files.c b/source/utils/files.c index 255e076..83bd301 100644 --- a/source/utils/files.c +++ b/source/utils/files.c @@ -1,6 +1,5 @@ #include "files.h" - FS_Path getPathInfo(const char * path, FS_ArchiveID * archive) { *archive = ARCHIVE_SDMC; FS_Path filePath = {0}; @@ -8,8 +7,7 @@ FS_Path getPathInfo(const char * path, FS_ArchiveID * archive) { if (!strncmp(path, "sdmc:/", 6)) { prefixlen = 5; - } - else if (*path != '/') { + } else if (*path != '/') { //if the path is local (doesnt start with a slash), it needs to be appended to the working dir to be valid char * actualPath = NULL; asprintf(&actualPath, "%s%s", WORKING_DIR, path); @@ -18,8 +16,9 @@ FS_Path getPathInfo(const char * path, FS_ArchiveID * archive) { } //if the filePath wasnt set above, set it - if (filePath.size == 0) + if (filePath.size == 0) { filePath = fsMakePath(PATH_ASCII, path+prefixlen); + } return filePath; } diff --git a/source/utils/formatting.cpp b/source/utils/formatting.cpp index fcfb91f..4d0d5a5 100644 --- a/source/utils/formatting.cpp +++ b/source/utils/formatting.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,16 +29,17 @@ // adapted from GM9i's byte parsing. std::string formatBytes(int bytes) { char out[32]; - if (bytes == 1) + if (bytes == 1) { snprintf(out, sizeof(out), "%d Byte", bytes); - else if (bytes < 1024) + } else if (bytes < 1024) { snprintf(out, sizeof(out), "%d Bytes", bytes); - else if (bytes < 1024 * 1024) + } else if (bytes < 1024 * 1024) { snprintf(out, sizeof(out), "%.1f KB", (float)bytes / 1024); - else if (bytes < 1024 * 1024 * 1024) + } else if (bytes < 1024 * 1024 * 1024) { snprintf(out, sizeof(out), "%.1f MB", (float)bytes / 1024 / 1024); - else + } else { snprintf(out, sizeof(out), "%.1f GB", (float)bytes / 1024 / 1024 / 1024); + } return out; } \ No newline at end of file diff --git a/source/utils/scriptHelper.cpp b/source/utils/scriptHelper.cpp index cf9bd18..6e64f2e 100644 --- a/source/utils/scriptHelper.cpp +++ b/source/utils/scriptHelper.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,7 +37,7 @@ #include extern bool showProgressBar; -extern int progressBarType; +extern ProgressBar progressbarType; extern char progressBarMsg[128]; extern int filesExtracted; @@ -61,6 +61,7 @@ int ScriptHelper::getNum(nlohmann::json json, const std::string &key, const std: if (!json.at(key).contains(key2)) return 0; if (!json.at(key).at(key2).is_number()) return 0; + return json.at(key).at(key2).get_ref(); } @@ -83,7 +84,7 @@ Result ScriptHelper::downloadFile(std::string file, std::string output, std::str Result ret = NONE; snprintf(progressBarMsg, sizeof(progressBarMsg), message.c_str()); showProgressBar = true; - progressBarType = 0; + progressbarType = ProgressBar::Downloading; Threads::create((ThreadFunc)displayProgressBar); if (downloadToFile(file, output) != 0) { showProgressBar = false; @@ -112,7 +113,7 @@ Result ScriptHelper::removeFile(std::string file, std::string message) { void ScriptHelper::installFile(std::string file, bool updatingSelf, std::string message) { snprintf(progressBarMsg, sizeof(progressBarMsg), message.c_str()); showProgressBar = true; - progressBarType = 2; + progressbarType = ProgressBar::Installing; Threads::create((ThreadFunc)displayProgressBar); installCia(file.c_str(), updatingSelf); showProgressBar = false; @@ -123,7 +124,7 @@ void ScriptHelper::extractFile(std::string file, std::string input, std::string snprintf(progressBarMsg, sizeof(progressBarMsg), message.c_str()); showProgressBar = true; filesExtracted = 0; - progressBarType = 1; + progressbarType = ProgressBar::Extracting; Threads::create((ThreadFunc)displayProgressBar); extractArchive(file, input, output); showProgressBar = false; @@ -170,13 +171,8 @@ void ScriptHelper::bootTitle(const std::string TitleID, bool isNAND, std::string else MSG += Lang::get("MEDIATYPE_SD") + "\n" + TitleID; u64 ID = std::stoull(TitleID, 0, 16); if (Msg::promptMsg(MSG)) { - if (isNAND == true) { - Msg::DisplayMsg(message); - CIA_LaunchTitle(ID, MEDIATYPE_NAND); - } else { - Msg::DisplayMsg(message); - CIA_LaunchTitle(ID, MEDIATYPE_SD); - } + Msg::DisplayMsg(message); + CIA_LaunchTitle(ID, isNAND ? MEDIATYPE_NAND : MEDIATYPE_SD); } } @@ -191,13 +187,13 @@ Result ScriptHelper::prompt(std::string message) { Result ScriptHelper::copyFile(std::string source, std::string destination, std::string message) { Result ret = NONE; - if (access(source.c_str(), F_OK) != 0 ) { + if (access(source.c_str(), F_OK) != 0) { return COPY_ERROR; } Msg::DisplayMsg(message); // If destination does not exist, create dirs. - if (access(destination.c_str(), F_OK) != 0 ) { + if (access(destination.c_str(), F_OK) != 0) { makeDirs(destination.c_str()); } @@ -207,7 +203,7 @@ Result ScriptHelper::copyFile(std::string source, std::string destination, std:: Result ScriptHelper::renameFile(std::string oldName, std::string newName, std::string message) { Result ret = NONE; - if (access(oldName.c_str(), F_OK) != 0 ) { + if (access(oldName.c_str(), F_OK) != 0) { return MOVE_ERROR; } diff --git a/source/utils/sound.cpp b/source/utils/sound.cpp index e7a8064..68d2258 100644 --- a/source/utils/sound.cpp +++ b/source/utils/sound.cpp @@ -25,7 +25,6 @@ typedef struct _WavHeader { static_assert(sizeof(WavHeader) == 44, "WavHeader size is not 44 bytes."); sound::sound(const string& path, int channel, bool toloop) { - ndspSetOutputMode(NDSP_OUTPUT_STEREO); ndspSetOutputCount(2); // Num of buffers diff --git a/source/utils/store.cpp b/source/utils/store.cpp index a8f456f..b402233 100644 --- a/source/utils/store.cpp +++ b/source/utils/store.cpp @@ -1,6 +1,6 @@ /* * This file is part of Universal-Updater -* Copyright (C) 2019-2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* Copyright (C) 2019-2020 Universal-Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source/utils/thread.cpp b/source/utils/thread.cpp index 019e716..bb7dd14 100644 --- a/source/utils/thread.cpp +++ b/source/utils/thread.cpp @@ -6,16 +6,14 @@ static std::vector threads; -void Threads::create(ThreadFunc entrypoint) -{ +void Threads::create(ThreadFunc entrypoint) { s32 prio = 0; svcGetThreadPriority(&prio, CUR_THREAD_HANDLE); Thread thread = threadCreate((ThreadFunc)entrypoint, NULL, 64 * 1024, prio - 1, -2, false); threads.push_back(thread); } -void Threads::destroy(void) -{ +void Threads::destroy(void) { for (u32 i = 0; i < threads.size(); i++) { threadJoin(threads.at(i), U64_MAX); threadFree(threads.at(i));