WIP: Argument | Shortcut support.

This commit is contained in:
StackZ
2020-11-16 13:28:45 +01:00
parent 24a7b90dea
commit f08bed5813
15 changed files with 294 additions and 20 deletions
+5 -1
View File
@@ -33,7 +33,7 @@
class Store {
public:
Store(const std::string &file);
Store(const std::string &file, const std::string &file2, bool ARGMode = false);
~Store();
void LoadFromFile(const std::string &file);
void loadSheets();
@@ -80,6 +80,9 @@ public:
/* Both of these things are used for custom BG support. */
C2D_Image GetStoreImg() const { return this->storeBG; };
bool customBG() const { return this->hasCustomBG; };
/* Return filename of the UniStore. */
std::string GetFileName() const { return this->fileName; };
private:
void SetC2DBGImage();
nlohmann::json storeJson = nullptr;
@@ -87,6 +90,7 @@ private:
C2D_Image storeBG = { nullptr };
bool valid = false, hasSheet = false, hasCustomBG = false;
int screenIndex = 0, entry = 0, box = 0, downEntry = 0, downIndex = 0;
std::string fileName = "";
};
#endif
+47
View File
@@ -0,0 +1,47 @@
/*
* 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_ARGUMENT_PARSER_HPP
#define _UNIVERSAL_UPDATER_ARGUMENT_PARSER_HPP
#include "json.hpp"
#include "store.hpp"
#include <string>
class ArgumentParser {
public:
ArgumentParser(const std::string &file, const std::string &entry, int dlIndex);
void Load();
void Execute();
bool GetValid() const { return this->isValid; };
private:
std::unique_ptr<Store> store = nullptr;
bool isValid = false;
std::string file = "", executeEntry = "", entry = "";
int dlIndex = -1, entryIndex = -1;
};
#endif
+6 -1
View File
@@ -79,6 +79,10 @@ public:
/* If using custom Font. */
bool customfont() const { return this->v_customFont; };
void customfont(bool v) { this->v_customFont = v; if (!this->changesMade) this->changesMade = true; };
/* The shortcut path. */
std::string shortcut() const { return this->v_shortcutPath; };
void shortcut(const std::string &v) { this->v_shortcutPath = v; if (!this->changesMade) this->changesMade = true; };
private:
/* Mainly helper. */
bool getBool(const std::string &key);
@@ -92,7 +96,8 @@ private:
bool changesMade = false;
std::string v_language = "en", v_lastStore = "universal-db.unistore",
v_3dsxPath = "sdmc:/3ds", v_ndsPath = "sdmc:", v_archivePath = "sdmc:";
v_3dsxPath = "sdmc:/3ds", v_ndsPath = "sdmc:", v_archivePath = "sdmc:",
v_shortcutPath = "sdmc:/3ds/Universal-Updater/shortcuts";
bool v_list = false, v_autoUpdate = true, v_metadata = true, v_updateCheck = true, v_showBg = false, v_customFont = false;
};