Universal-Updater Full Rewrite based of UniStore v3.0.0. (#51)

* No Nightlies for the Full-Rewrite.

* Initial push, i guess.

* Forgot to push the Test UniStore + T3X...

* Use C2D flags for wrapping and centering

* gitignore t3x correctly

* Remove Test Store and hardcode to `sdmc:/3ds/Universal-Updater/stores/Universal-DB.unistore` for now.

* Is functional now.

* *More special checks and work.*

* const <typename T> &.

* Universal-DB, not Universal DB.

* Derp.

* Make 3DSX, NDS & Archive path configurable.

* Last fixes + Fade out screen on exit.

* See Desc. for more.

- Add QR Code scan for downloading UniStores.
- Add new Graphics.
- Some fixes + improvements.

* Fix search filtering, re-sort after search

* Fix update check

* Clear search items with X, not just reset results

* The next progress.

* PLEASE tell me, this is the only error..

Co-authored-by: Pk11 <epicpkmn11@outlook.com>
This commit is contained in:
StackZ
2020-10-30 03:31:20 +01:00
committed by GitHub
parent 5d38c98698
commit 913475eabf
142 changed files with 13937 additions and 14588 deletions
@@ -24,37 +24,20 @@
* reasonable ways as different from the original version.
*/
#ifndef _UNIVERSAL_UPDATER_COLOR_HELPER_HPP
#define _UNIVERSAL_UPDATER_COLOR_HELPER_HPP
#ifndef _UNIVERSAL_UPDATER_ANIMATION_HPP
#define _UNIVERSAL_UPDATER_ANIMATION_HPP
#include <citro2d.h>
#include <citro3d.h>
#include <sstream>
#include <3ds.h>
#include <string>
/**
* @brief Creates a 8 byte RGBA color
* @param r red component of the color
* @param g green component of the color
* @param b blue component of the color
* @param a alpha component of the color
*/
#define RGBA8(r, g, b, a) ((((r)&0xFF)<<0) | (((g)&0xFF)<<8) | (((b)&0xFF)<<16) | (((a)&0xFF)<<24))
enum class ProgressBar {
Downloading,
Extracting,
Installing
};
#define BarColor C2D_Color32(57, 84, 114, 255)
#define TopBGColor C2D_Color32(96, 168, 192, 255)
#define BottomBGColor C2D_Color32(38, 44, 77, 255)
#define SelectedColordefault C2D_Color32(120, 192, 216, 255)
#define UnselectedColordefault C2D_Color32(77, 118, 132, 255)
#define BLACK C2D_Color32(0, 0, 0, 255)
#define WHITE C2D_Color32(255, 255, 255, 255)
#define TRANSPARENT C2D_Color32(0, 0, 0, 0)
typedef u32 Color;
namespace ColorHelper {
int getColorValue(int color, int bgr);
std::string getColorName(int color, int bgr);
}
namespace Animation {
void DrawProgressBar(const u64 &currentProgress, const u64 &totalProgress);
};
#endif
+29 -3
View File
@@ -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 <http://www.gnu.org/licenses/>.
*
* 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_CIA_HPP
#define _UNIVERSAL_UPDATER_CIA_HPP
@@ -5,8 +31,8 @@
#include <3ds.h>
Result CIA_LaunchTitle(u64 titleId, FS_MediaType mediaType);
Result deletePrevious(u64 titleid, FS_MediaType media);
Result installCia(const char * ciaPath, bool updateSelf);
Result CIA_LaunchTitle(const u64 &titleId, const FS_MediaType &mediaType);
Result deletePrevious(const u64 &titleid, const FS_MediaType &media);
Result installCia(const char *ciaPath, const bool &updateSelf);
#endif
+91 -161
View File
@@ -1,161 +1,91 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
* 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_CONFIG_HPP
#define _UNIVERSAL_UPDATER_CONFIG_HPP
#include "json.hpp"
#include <3ds.h>
#include <string>
class Config {
public:
Config();
void save();
void initialize();
void addMissingThings();
void sysLang();
// Bar Color.
u32 barColor() { return this->v_barColor; }
void barColor(u32 v) { this->v_barColor = v; if (!this->changesMade) this->changesMade = true; }
// Top BG Color.
u32 topBG() { return this->v_topBG; }
void topBG(u32 v) { this->v_topBG = v; if (!this->changesMade) this->changesMade = true; }
// Bottom BG Color.
u32 bottomBG() { return this->v_bottomBG; }
void bottomBG(u32 v) { this->v_bottomBG = v; if (!this->changesMade) this->changesMade = true; }
// Text Color.
u32 textColor() { return this->v_textColor; }
void textColor(u32 v) { this->v_textColor = v; if (!this->changesMade) this->changesMade = true; }
// Button Color.
u32 buttonColor() { return this->v_buttonColor; }
void buttonColor(u32 v) { this->v_buttonColor = v; if (!this->changesMade) this->changesMade = true; }
// Selected Color.
u32 selectedColor() { return this->v_selectedColor; }
void selectedColor(u32 v) { this->v_selectedColor = v; if (!this->changesMade) this->changesMade = true; }
// Unselected Color.
u32 unselectedColor() { return this->v_unselectedColor; }
void unselectedColor(u32 v) { this->v_unselectedColor = v; if (!this->changesMade) this->changesMade = true; }
// Script Path.
std::string scriptPath() { return this->v_scriptPath; }
void scriptPath(std::string v) { this->v_scriptPath = v; if (!this->changesMade) this->changesMade = true; }
// Lang Path.
int langPath() { return this->v_langPath; }
void langPath(int v) { this->v_langPath = v; if (!this->changesMade) this->changesMade = true; }
// View Mode.
int viewMode() { return this->v_viewMode; }
void viewMode(int v) { this->v_viewMode = v; if (!this->changesMade) this->changesMade = true; }
// Progressbar Color.
u32 progressbarColor() { return this->v_progressbarColor; }
void progressbarColor(u32 v) { this->v_progressbarColor = v; if (!this->changesMade) this->changesMade = true; }
// Music Path.
std::string musicPath() { return this->v_musicPath; }
void musicPath(std::string v) { this->v_musicPath = v; if (!this->changesMade) this->changesMade = true; }
// Logging.
bool logging() { return this->v_logging; }
void logging(bool v) { this->v_logging = v; if (!this->changesMade) this->changesMade = true; }
// Use bars.
bool useBars() { return this->v_useBars; }
void useBars(bool v) { this->v_useBars = v; if (!this->changesMade) this->changesMade = true; }
// Autoboot.
int autoboot() { return this->v_autoboot; }
void autoboot(int v) { this->v_autoboot = v; if (!this->changesMade) this->changesMade = true; }
// Store Path.
std::string storePath() { return this->v_storePath; }
void storePath(std::string v) { this->v_storePath = v; if (!this->changesMade) this->changesMade = true; }
// Autoboto file.
std::string autobootFile() { return this->v_autobootFile; }
void autobootFile(std::string v) { this->v_autobootFile = v; if (!this->changesMade) this->changesMade = true; }
// Outdated Script Color.
u32 outdatedColor() { return this->v_outdatedColor; }
void outdatedColor(u32 v) { this->v_outdatedColor = v; if (!this->changesMade) this->changesMade = true; }
// Uptodate Script Color.
u32 uptodateColor() { return this->v_uptodateColor; }
void uptodateColor(u32 v) { this->v_uptodateColor = v; if (!this->changesMade) this->changesMade = true; }
// Not found Script Color.
u32 notfoundColor() { return this->v_notfoundColor; }
void notfoundColor(u32 v) { this->v_notfoundColor = v; if (!this->changesMade) this->changesMade = true; }
// Future Script Color.
u32 futureColor() { return this->v_futureColor; }
void futureColor(u32 v) { this->v_futureColor = v; if (!this->changesMade) this->changesMade = true; }
// Keydelay.
int keyDelay() { return this->v_keyDelay; }
void keyDelay(int v) { this->v_keyDelay = v; if (!this->changesMade) this->changesMade = true; }
// Screen Fade.
bool screenFade() { return this->v_screenFade; }
void screenFade(bool v) { this->v_screenFade = v; if (!this->changesMade) this->changesMade = true; }
// Progressbar Display.
bool progressDisplay() { return this->v_progressDisplay; }
void progressDisplay(bool v) { this->v_progressDisplay = v; if (!this->changesMade) this->changesMade = true; }
// Language.
std::string language() { return this->v_language; }
void language(std::string v) { this->v_language = v; if (!this->changesMade) this->changesMade = true; }
// First startup.
bool firstStartup() { return this->v_firstStartup; }
void firstStartup(bool v) { this->v_firstStartup = v; if (!this->changesMade) this->changesMade = true; }
// Use ScriptColors.
bool useScriptColor() { return this->v_useScriptColor; }
void useScriptColor(bool v) { this->v_useScriptColor = v; if (!this->changesMade) this->changesMade = true; }
// Show Downloadspeed.
bool showSpeed() { return this->v_showSpeed; }
void showSpeed(bool v) { this->v_showSpeed = v; if (!this->changesMade) this->changesMade = true; }
// Citra stuff.
bool citra() { return this->v_citra; }
void citra(bool v) { this->v_citra = v; if (!this->changesMade) this->changesMade = true; }
// Variables.
std::string _3dsxpath() { return this->v_3dsx_install_path; }
void _3dsxpath(std::string v) { this->v_3dsx_install_path = v; if (!this->changesMade) this->changesMade = true; }
std::string ndspath() { return this->v_nds_install_path; }
void ndspath(std::string v) { this->v_nds_install_path = v; if (!this->changesMade) this->changesMade = true; }
std::string archivepath() { return this->v_archive_path; }
void archivepath(std::string v) { this->v_archive_path = v; if (!this->changesMade) this->changesMade = true; }
// Mainly helper.
bool getBool(const std::string &key);
void setBool(const std::string &key, bool v);
int getInt(const std::string &key);
void setInt(const std::string &key, int v);
std::string getString(const std::string &key);
void setString(const std::string &key, const std::string &v);
private:
nlohmann::json json; // Our private JSON file.
bool changesMade = false, initialChanges = false;
int configVersion = 2;
// Color variables and more.
u32 v_barColor, v_topBG, v_bottomBG, v_textColor, v_buttonColor, v_selectedColor, v_unselectedColor, v_progressbarColor,
v_outdatedColor, v_uptodateColor, v_notfoundColor, v_futureColor;
std::string v_scriptPath, v_musicPath, v_storePath, v_autobootFile, v_language;
int v_langPath, v_viewMode, v_autoboot, v_keyDelay;
bool v_logging, v_useBars, v_screenFade, v_progressDisplay, v_firstStartup, v_useScriptColor, v_showSpeed, v_citra;
// Some variables.
std::string v_3dsx_install_path, v_nds_install_path, v_archive_path;
};
#endif
/*
* 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 <http://www.gnu.org/licenses/>.
*
* 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_CONFIG_HPP
#define _UNIVERSAL_UPDATER_CONFIG_HPP
#include "json.hpp"
#include <3ds.h>
#include <string>
class Config {
public:
Config();
void save();
void initialize();
void sysLang();
/* Language. */
std::string language() const { return this->v_language; };
void language(const std::string &v) { this->v_language = v; if (!this->changesMade) this->changesMade = true; };
/* Last Store. */
std::string lastStore() const { return this->v_lastStore; };
void lastStore(const std::string &v) { this->v_lastStore = v; if (!this->changesMade) this->changesMade = true; };
/* Using Top List. */
bool list() const { return this->v_list; };
void list(bool v) { this->v_list = v; if (!this->changesMade) this->changesMade = true; };
/* Auto update on boot. */
bool autoupdate() const { return this->v_autoUpdate; };
void autoupdate(bool v) { this->v_autoUpdate = v; if (!this->changesMade) this->changesMade = true; };
std::string _3dsxPath() const { return this->v_3dsxPath; };
void _3dsxPath(const std::string &v) { this->v_3dsxPath = v; if (!this->changesMade) this->changesMade = true; };
std::string ndsPath() const { return this->v_ndsPath; };
void ndsPath(const std::string &v) { this->v_ndsPath = v; if (!this->changesMade) this->changesMade = true; };
std::string archPath() const { return this->v_archivePath; };
void archPath(const std::string &v) { this->v_archivePath = v; if (!this->changesMade) this->changesMade = true; };
/* Fetching old metadata. */
bool metadata() const { return this->v_metadata; };
void metadata(bool v) { this->v_metadata = v; if (!this->changesMade) this->changesMade = true; };
/* U-U Update check on startup. */
bool updatecheck() const { return this->v_updateCheck; };
void updatecheck(bool v) { this->v_updateCheck = v; if (!this->changesMade) this->changesMade = true; };
private:
/* Mainly helper. */
bool getBool(const std::string &key);
void setBool(const std::string &key, bool v);
int getInt(const std::string &key);
void setInt(const std::string &key, int v);
std::string getString(const std::string &key);
void setString(const std::string &key, const std::string &v);
nlohmann::json json;
bool changesMade = false;
std::string v_language = "en", v_lastStore = "universal-db-beta.unistore",
v_3dsxPath = "sdmc:/3ds", v_ndsPath = "sdmc:", v_archivePath = "sdmc:";
bool v_list = false, v_autoUpdate = true, v_metadata = true, v_updateCheck = true;
};
#endif
@@ -1,76 +1,75 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
* 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.
*/
#pragma once
#include <3ds.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "files.h"
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#ifdef __cplusplus
}
#include "animation.hpp"
#include "config.hpp"
#include "gfx.hpp"
#include "gui.hpp"
#include "json.hpp"
#include "lang.hpp"
#include "msg.hpp"
#include "screenCommon.hpp"
#include "stringutils.hpp"
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <regex>
#include <curl/curl.h>
using json = nlohmann::json;
#endif
#define WORKING_DIR "/"
#define SCRIPTS_PATH "sdmc:/3ds/Universal-Updater/scripts/" // The Scripts will be here.
#define MUSIC_PATH "sdmc:/3ds/Universal-Updater/Music.wav" // Default Music File / Path.
#define SCRIPT_VERSION 4
#define STORE_PATH "sdmc:/3ds/Universal-Updater/stores/" // Default Store path.
#define ENTRIES_PER_SCREEN 3
#define ENTRIES_PER_LIST 7
#define metaFile "sdmc:/3ds/Universal-Updater/ScriptInfo.json"
#define _3DSX_PATH "sdmc:/3ds"
#define _NDS_PATH "sdmc:"
#define ARCHIVES_DEFAULT "sdmc:"
/*
* 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 <http://www.gnu.org/licenses/>.
*
* 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_DOWNLOAD_HPP
#define _UNIVERSAL_UPDATER_DOWNLOAD_HPP
#include "common.hpp"
#define APP_TITLE "Universal-Updater"
#define VERSION_STRING "3.0.0"
enum DownloadError {
DL_ERROR_NONE = 0,
DL_ERROR_WRITEFILE,
DL_ERROR_ALLOC,
DL_ERROR_STATUSCODE,
DL_ERROR_GIT,
DL_CANCEL, // No clue if that's needed tho.
};
Result downloadToFile(const std::string &url, const std::string &path);
Result downloadFromRelease(const std::string &url, const std::string &asset, const std::string &path, const bool &includePrereleases);
/*
Check Wi-Fi status.
@return True if Wi-Fi is connected; false if not.
*/
bool checkWifiStatus(void);
/*
Display "Please connect to Wi-Fi" for 2s.
*/
void notConnectedMsg(void);
/*
Display "Not Implemented Yet" for 2s.
*/
void notImplemented(void);
/*
Display the done msg.
*/
void doneMsg(void);
void displayProgressBar();
bool IsUpdateAvailable(const std::string &URL, const int &revCurrent);
bool DownloadUniStore(const std::string &URL, const int &currentRev, std::string &fl, const bool &isDownload = false, const bool &isUDB = false);
bool DownloadSpriteSheet(const std::string &URL, const std::string &file);
bool IsUUUpdateAvailable();
void UpdateAction();
#endif
+43 -43
View File
@@ -1,44 +1,44 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
* 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_EXTRACT_HPP
#define _UNIVERSAL_UPDATER_EXTRACT_HPP
#include "common.hpp"
enum ExtractError {
EXTRACT_ERROR_NONE = 0,
EXTRACT_ERROR_ARCHIVE,
EXTRACT_ERROR_ALLOC,
EXTRACT_ERROR_FIND,
EXTRACT_ERROR_READFILE,
EXTRACT_ERROR_OPENFILE,
EXTRACT_ERROR_WRITEFILE,
};
Result extractArchive(std::string archivePath, std::string wantedFile, std::string outputPath);
/*
* 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 <http://www.gnu.org/licenses/>.
*
* 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_EXTRACT_HPP
#define _UNIVERSAL_UPDATER_EXTRACT_HPP
#include "common.hpp"
enum ExtractError {
EXTRACT_ERROR_NONE = 0,
EXTRACT_ERROR_ARCHIVE,
EXTRACT_ERROR_ALLOC,
EXTRACT_ERROR_FIND,
EXTRACT_ERROR_READFILE,
EXTRACT_ERROR_OPENFILE,
EXTRACT_ERROR_WRITEFILE,
};
Result extractArchive(const std::string &archivePath, const std::string &wantedFile, const std::string &outputPath);
#endif
+19 -10
View File
@@ -32,25 +32,34 @@
#include <sys/stat.h>
#include <vector>
using namespace std;
struct DirEntry {
std::string name;
std::string path;
bool isDirectory;
off_t size;
};
bool nameEndsWith(const std::string& name, const std::vector<std::string> extensionList);
void getDirectoryContents(std::vector<DirEntry>& dirContents, const std::vector<std::string> extensionList);
void getDirectoryContents(std::vector<DirEntry>& dirContents);
/*
UniStore Info struct.
*/
struct UniStoreInfo {
std::string Title;
std::string Author;
std::string URL;
std::string FileName;
std::string Description;
int Version;
int Revision;
int StoreSize;
};
bool nameEndsWith(const std::string &name, const std::vector<std::string> &extensionList);
void getDirectoryContents(std::vector<DirEntry> &dirContents, const std::vector<std::string> &extensionList);
void getDirectoryContents(std::vector<DirEntry> &dirContents);
std::vector<std::string> getContents(const std::string &name, const std::vector<std::string> &extensionList);
bool returnIfExist(const std::string &path, const std::vector<std::string> &extensionList);
std::vector<UniStoreInfo> GetUniStoreInfo(const std::string &path);
std::string selectFilePath(std::string selectText, std::string initialPath, const std::vector<std::string> &extensionList, int selectionMode = 1);
void dirCopy(DirEntry* entry, int i, const char *destinationPath, const char *sourcePath);
void dirCopy(DirEntry *entry, const char *destinationPath, const char *sourcePath);
int fcopy(const char *sourcePath, const char *destinationPath);
#endif
@@ -1,38 +1,38 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
* 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_FILES_H
#define _UNIVERSAL_UPDATER_FILES_H
#include "common.hpp"
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);
/*
* 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 <http://www.gnu.org/licenses/>.
*
* 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_FILES_HPP
#define _UNIVERSAL_UPDATER_FILES_HPP
#include "common.hpp"
Result makeDirs(const char *path);
Result openFile(Handle *fileHandle, const char *path, const bool &write);
Result deleteFile(const char *path);
Result removeDir(const char *path);
Result removeDirRecursive(const char *path);
#endif
+4028 -3246
View File
File diff suppressed because it is too large Load Diff
@@ -1,34 +1,38 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
* 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_FORMATTING_HPP
#define _UNIVERSAL_UPDATER_FORMATTING_HPP
#include <string>
std::string formatBytes(int bytes);
/*
* 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 <http://www.gnu.org/licenses/>.
*
* 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"
#include <string>
namespace Lang {
std::string get(const std::string &key);
void load(const std::string &lang);
};
#endif
-86
View File
@@ -1,86 +0,0 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
* 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_SCRIPT_HELPER_HPP
#define _UNIVERSAL_UPDATER_SCRIPT_HELPER_HPP
#include <string>
// Information like Title and Author.
struct ScriptInfo {
std::string title;
std::string author;
std::string shortDesc;
};
// Store Information.
struct StoreInfo {
std::string title;
std::string author;
std::string description;
std::string url;
std::string file;
std::string storeSheet;
std::string sheetURL;
int version;
};
enum ScriptState {
NONE = 0,
FAILED_DOWNLOAD,
SCRIPT_CANCELED,
SYNTAX_ERROR,
COPY_ERROR,
MOVE_ERROR,
DELETE_ERROR,
};
namespace ScriptHelper {
// Get stuff from a JSON.
std::string getString(nlohmann::json json, const std::string &key, const std::string &key2);
int getNum(nlohmann::json json, const std::string &key, const std::string &key2);
// Script Functions.
Result downloadRelease(std::string repo, std::string file, std::string output, bool includePrereleases, bool showVersions, std::string message);
Result downloadFile(std::string file, std::string output, std::string message);
Result removeFile(std::string file, std::string message);
void installFile(std::string file, bool updateSelf, std::string message);
void extractFile(std::string file, std::string input, std::string output, std::string message);
Result createFile(const char * path);
void displayTimeMsg(std::string message, int seconds);
bool checkIfValid(std::string scriptFile, int mode = 0);
void bootTitle(const std::string TitleID, bool isNAND, std::string message);
Result prompt(std::string message);
Result copyFile(std::string source, std::string destination, std::string message);
Result renameFile(std::string oldName, std::string newName, std::string message);
}
#endif
+60
View File
@@ -0,0 +1,60 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
* 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_SCRIPT_UTILS_HPP
#define _UNIVERSAL_UPDATER_SCRIPT_UTILS_HPP
#include "json.hpp"
#include <3ds.h>
#include <string>
enum ScriptState {
NONE = 0,
FAILED_DOWNLOAD,
SCRIPT_CANCELED,
SYNTAX_ERROR,
COPY_ERROR,
MOVE_ERROR,
DELETE_ERROR
};
namespace ScriptUtils {
bool matchPattern(const std::string &pattern, const std::string &tested);
Result removeFile(const std::string &file, const std::string &message);
void bootTitle(const std::string &TitleID, const bool &isNAND, const std::string &message);
Result prompt(const std::string &message);
Result copyFile(const std::string &source, const std::string &destination, const std::string &message);
Result renameFile(const std::string &oldName, const std::string &newName, const std::string &message);
Result downloadRelease(const std::string &repo, const std::string &file, const std::string &output, const bool &includePrereleases, const std::string &message);
Result downloadFile(const std::string &file, const std::string &output, const std::string &message);
void installFile(const std::string &file, const bool &updatingSelf, const std::string &message);
void extractFile(const std::string &file, const std::string &input, const std::string &output, const std::string &message);
Result runFunctions(const nlohmann::json &storeJson, const int &selection, const std::string &entry);
};
#endif
-21
View File
@@ -1,21 +0,0 @@
#ifndef _UNIVERSAL_UPDATER_SOUND_H
#define _UNIVERSAL_UPDATER_SOUND_H
#include <3ds.h>
#include <string>
class sound {
public:
sound(const std::string& path, int channel = 1, bool toloop = true);
~sound();
void play();
void stop();
private:
u32 dataSize;
ndspWaveBuf waveBuf;
u8* data = NULL;
int chnl;
};
#endif
-99
View File
@@ -1,99 +0,0 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
* 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_STORE_HPP
#define _UNIVERSAL_UPDATER_STORE_HPP
#include "json.hpp"
#include <3ds.h>
#include <string>
#include <vector>
struct UniStoreV2Struct {
std::string title;
std::string author;
std::string description;
std::string version;
std::string category;
std::string console;
std::string last_updated;
int icon_index;
int JSONIndex;
bool updateAvailable;
};
enum class SortType {
TITLE,
AUTHOR,
LAST_UPDATED
};
class Store {
public:
Store(nlohmann::json &JS, std::string updateJSON = "NOT_FOUND");
void writeToFile(int index);
void sorting(bool Ascending, SortType sorttype);
std::string returnTitle(const int index);
std::string returnAuthor(const int index);
std::string returnDescription(const int index);
int returnIconIndex(const int index);
int returnJSONIndex(const int index);
int getSize();
bool getAscending() { return this->ascending; }
bool isUpdateAvailable(int index) { return this->sortedStore[index].updateAvailable; }
// Searching stuff.
int searchForEntries(const std::string searchResult);
int searchForAuthor(const std::string searchResult);
int searchForCategory(const std::string searchResult);
int searchForConsole(const std::string searchResult);
bool updateAvailable(int index);
void reset() { this->sortedStore = this->unsortedStore; }
const int getSortType() {
if (this->sorttype == SortType::TITLE) return 0;
else if (this->sorttype == SortType::AUTHOR) return 1;
else if (this->sorttype == SortType::LAST_UPDATED) return 2;
else return -1; // Should not happen.
}
const std::vector<std::string> getCategories() { return this->availableCategories; }
const std::vector<std::string> getAuthors() { return this->availableAuthors; }
const std::vector<std::string> getSystems() { return this->availableSystems; }
private:
std::vector<UniStoreV2Struct> sortedStore, unsortedStore;
std::vector<std::string> availableCategories, availableAuthors, availableSystems;
std::string updateFile;
bool ascending = false;
nlohmann::json storeJson, updateJSON;
SortType sorttype = SortType::TITLE;
UniStoreV2Struct getData(const int index);
};
#endif
+35 -5
View File
@@ -1,12 +1,42 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
* 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_STRING_UTILS_HPP
#define _UNIVERSAL_UPDATER_STRING_UTILS_HPP
#include "common.hpp"
bool matchPattern(std::string pattern, std::string tested);
#include "meta.hpp"
#include <string>
#include <vector>
namespace StringUtils {
std::string format(const std::string& fmt_str, ...);
}
std::string lower_case(const std::string &str);
std::string FetchStringsFromVector(const std::vector<std::string> &fetch);
std::string formatBytes(const int bytes);
std::string GetMarkString(int marks);
std::vector<std::string> GetMarks(int marks);
};
#endif
-12
View File
@@ -1,12 +0,0 @@
#ifndef _UNIVERSAL_UPDATER_THREAD_HPP
#define _UNIVERSAL_UPDATER_THREAD_HPP
#include <3ds.h>
#include <vector>
namespace Threads {
void create(ThreadFunc entrypoint);
void destroy(void);
}
#endif