Increase Script version, add citra to config.

The Citra entry allows to skip the wifi check.
This commit is contained in:
StackZ
2020-07-01 15:07:29 +02:00
parent 54c426032b
commit 80afbbe19f
6 changed files with 76 additions and 49 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ private:
void deleteScript(int selectedScript); void deleteScript(int selectedScript);
void refreshList(); void refreshList();
nlohmann::json openScriptFile(); nlohmann::json openScriptFile();
void checkForValidate(void); bool checkForValidate(void);
void loadDesc(void); void loadDesc(void);
Result runFunctions(nlohmann::json &json); Result runFunctions(nlohmann::json &json);
+1 -1
View File
@@ -66,7 +66,7 @@ using json = nlohmann::json;
#define WORKING_DIR "/" #define WORKING_DIR "/"
#define SCRIPTS_PATH "sdmc:/3ds/Universal-Updater/scripts/" // The Scripts will be here. #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 MUSIC_PATH "sdmc:/3ds/Universal-Updater/Music.wav" // Default Music File / Path.
#define SCRIPT_VERSION 3 #define SCRIPT_VERSION 4
#define STORE_PATH "sdmc:/3ds/Universal-Updater/stores/" // Default Store path. #define STORE_PATH "sdmc:/3ds/Universal-Updater/stores/" // Default Store path.
#define ENTRIES_PER_SCREEN 3 #define ENTRIES_PER_SCREEN 3
#define ENTRIES_PER_LIST 7 #define ENTRIES_PER_LIST 7
+4 -2
View File
@@ -123,7 +123,9 @@ public:
// Show Downloadspeed. // Show Downloadspeed.
bool showSpeed() { return this->v_showSpeed; } bool showSpeed() { return this->v_showSpeed; }
void showSpeed(bool v) { this->v_showSpeed = v; if (!this->changesMade) this->changesMade = true; } 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. // Variables.
std::string _3dsxpath() { return this->v_3dsx_install_path; } 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; } void _3dsxpath(std::string v) { this->v_3dsx_install_path = v; if (!this->changesMade) this->changesMade = true; }
@@ -149,7 +151,7 @@ private:
v_outdatedColor, v_uptodateColor, v_notfoundColor, v_futureColor; v_outdatedColor, v_uptodateColor, v_notfoundColor, v_futureColor;
std::string v_scriptPath, v_musicPath, v_storePath, v_autobootFile, v_language; std::string v_scriptPath, v_musicPath, v_storePath, v_autobootFile, v_language;
int v_langPath, v_viewMode, v_autoboot, v_keyDelay; int v_langPath, v_viewMode, v_autoboot, v_keyDelay;
bool v_logging, v_useBars, v_screenFade, v_progressDisplay, v_firstStartup, v_useScriptColor, v_showSpeed; bool v_logging, v_useBars, v_screenFade, v_progressDisplay, v_firstStartup, v_useScriptColor, v_showSpeed, v_citra;
// Some variables. // Some variables.
std::string v_3dsx_install_path, v_nds_install_path, v_archive_path; std::string v_3dsx_install_path, v_nds_install_path, v_archive_path;
+1
View File
@@ -626,6 +626,7 @@ Result downloadFromRelease(std::string url, std::string asset, std::string path,
* @return True if Wi-Fi is connected; false if not. * @return True if Wi-Fi is connected; false if not.
*/ */
bool checkWifiStatus(void) { bool checkWifiStatus(void) {
if (config->citra()) return true;
u32 wifiStatus; u32 wifiStatus;
bool res = false; bool res = false;
+60 -44
View File
@@ -62,14 +62,19 @@ ScriptInfo parseInfo(std::string fileName) {
} }
// Check if Script version has the current version. // Check if Script version has the current version.
void ScriptList::checkForValidate(void) { bool ScriptList::checkForValidate(void) {
FILE* file = fopen(currentFile.c_str(), "rt"); FILE* file = fopen(currentFile.c_str(), "rt");
nlohmann::json json = nlohmann::json::parse(file, nullptr, false); nlohmann::json json = nlohmann::json::parse(file, nullptr, false);
fclose(file); fclose(file);
int ver = ScriptHelper::getNum(json, "info", "version"); int ver = ScriptHelper::getNum(json, "info", "version");
if (ver < SCRIPT_VERSION || ver > SCRIPT_VERSION) { if (ver == 3 || ver == 4) {
return true;
} else {
Msg::DisplayWarnMsg(Lang::get("INCOMPATIBLE_SCRIPT")); Msg::DisplayWarnMsg(Lang::get("INCOMPATIBLE_SCRIPT"));
return false;
} }
return false;
} }
// Open a script file and return it to a JSON. // Open a script file and return it to a JSON.
@@ -206,18 +211,23 @@ ScriptList::ScriptList() {
if (ScriptHelper::checkIfValid(config->autobootFile()) == true) { if (ScriptHelper::checkIfValid(config->autobootFile()) == true) {
ScriptInfo fI = parseInfo(config->autobootFile()); ScriptInfo fI = parseInfo(config->autobootFile());
currentFile = config->autobootFile(); currentFile = config->autobootFile();
selectedTitle = fI.title; if (checkForValidate()) {
jsonFile = openScriptFile(); selectedTitle = fI.title;
Desc = Description(jsonFile); jsonFile = openScriptFile();
checkForValidate(); Desc = Description(jsonFile);
fileInfo2 = parseObjects(currentFile); fileInfo2 = parseObjects(currentFile);
loadColors(jsonFile); loadColors(jsonFile);
loadDesc(); loadDesc();
isScriptSelected = true; isScriptSelected = true;
Selection = 0; Selection = 0;
mode = 2; mode = 2;
changeBackHandle = true; changeBackHandle = true;
AutobootWhat = 0; AutobootWhat = 0;
} else {
AutobootWhat = 0;
changeBackHandle = true;
Gui::setScreen(std::make_unique<MainMenu>(), config->screenFade(), true);
}
} else { } else {
AutobootWhat = 0; AutobootWhat = 0;
changeBackHandle = true; changeBackHandle = true;
@@ -642,16 +652,18 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
if (!dirContents[screenPos + i].isDirectory && fileInfo.size() != 0) { if (!dirContents[screenPos + i].isDirectory && fileInfo.size() != 0) {
if (ScriptHelper::checkIfValid(dirContents[screenPos + i].name) == true) { if (ScriptHelper::checkIfValid(dirContents[screenPos + i].name) == true) {
currentFile = dirContents[screenPos + i].name; currentFile = dirContents[screenPos + i].name;
selectedTitle = fileInfo[screenPos + i].title; if (checkForValidate()) {
jsonFile = openScriptFile(); selectedTitle = fileInfo[screenPos + i].title;
Desc = Description(jsonFile); jsonFile = openScriptFile();
checkForValidate(); Desc = Description(jsonFile);
fileInfo2 = parseObjects(currentFile); checkForValidate();
loadColors(jsonFile); fileInfo2 = parseObjects(currentFile);
loadDesc(); loadColors(jsonFile);
isScriptSelected = true; loadDesc();
Selection = 0; isScriptSelected = true;
mode = 2; Selection = 0;
mode = 2;
}
} }
} }
} }
@@ -662,16 +674,18 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
if (!dirContents[screenPosList + i].isDirectory && fileInfo.size() != 0) { if (!dirContents[screenPosList + i].isDirectory && fileInfo.size() != 0) {
if (ScriptHelper::checkIfValid(dirContents[screenPosList + i].name) == true) { if (ScriptHelper::checkIfValid(dirContents[screenPosList + i].name) == true) {
currentFile = dirContents[screenPosList + i].name; currentFile = dirContents[screenPosList + i].name;
selectedTitle = fileInfo[screenPosList + i].title; if (checkForValidate()) {
jsonFile = openScriptFile(); selectedTitle = fileInfo[screenPosList + i].title;
Desc = Description(jsonFile); jsonFile = openScriptFile();
checkForValidate(); Desc = Description(jsonFile);
fileInfo2 = parseObjects(currentFile); checkForValidate();
loadColors(jsonFile); fileInfo2 = parseObjects(currentFile);
loadDesc(); loadColors(jsonFile);
isScriptSelected = true; loadDesc();
Selection = 0; isScriptSelected = true;
mode = 2; Selection = 0;
mode = 2;
}
} }
} }
} }
@@ -684,16 +698,18 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld, touchPosition touch) {
} else if (fileInfo.size() != 0) { } else if (fileInfo.size() != 0) {
if (ScriptHelper::checkIfValid(dirContents[Selection].name) == true) { if (ScriptHelper::checkIfValid(dirContents[Selection].name) == true) {
currentFile = dirContents[Selection].name; currentFile = dirContents[Selection].name;
selectedTitle = fileInfo[Selection].title; if (checkForValidate()) {
jsonFile = openScriptFile(); selectedTitle = fileInfo[Selection].title;
Desc = Description(jsonFile); jsonFile = openScriptFile();
checkForValidate(); Desc = Description(jsonFile);
fileInfo2 = parseObjects(currentFile); checkForValidate();
loadColors(jsonFile); fileInfo2 = parseObjects(currentFile);
loadDesc(); loadColors(jsonFile);
isScriptSelected = true; loadDesc();
Selection = 0; isScriptSelected = true;
mode = 2; Selection = 0;
mode = 2;
}
} }
} }
} }
+9 -1
View File
@@ -36,6 +36,7 @@ void Config::addMissingThings() {
this->setString("3DSX_PATH", _3DSX_PATH); this->setString("3DSX_PATH", _3DSX_PATH);
this->setString("NDS_PATH", _NDS_PATH); this->setString("NDS_PATH", _NDS_PATH);
this->setString("ARCHIVE_PATH", ARCHIVES_DEFAULT); this->setString("ARCHIVE_PATH", ARCHIVES_DEFAULT);
this->setBool("CITRA", false);
} }
} }
@@ -76,6 +77,7 @@ void Config::initialize() {
this->setString("3DSX_PATH", _3DSX_PATH); this->setString("3DSX_PATH", _3DSX_PATH);
this->setString("NDS_PATH", _NDS_PATH); this->setString("NDS_PATH", _NDS_PATH);
this->setString("ARCHIVE_PATH", ARCHIVES_DEFAULT); this->setString("ARCHIVE_PATH", ARCHIVES_DEFAULT);
this->setBool("CITRA", false);
this->setInt("VERSION", this->configVersion); this->setInt("VERSION", this->configVersion);
// Write to file. // Write to file.
@@ -290,6 +292,12 @@ Config::Config() {
this->archivepath(this->getString("ARCHIVE_PATH")); this->archivepath(this->getString("ARCHIVE_PATH"));
} }
if (!this->json.contains("CITRA")) {
this->citra(false);
} else {
this->citra(this->getBool("CITRA"));
}
this->changesMade = false; // No changes made yet. this->changesMade = false; // No changes made yet.
} }
@@ -330,7 +338,7 @@ void Config::save() {
this->setString("3DSX_PATH", this->_3dsxpath()); this->setString("3DSX_PATH", this->_3dsxpath());
this->setString("NDS_PATH", this->ndspath()); this->setString("NDS_PATH", this->ndspath());
this->setString("ARCHIVE_PATH", this->archivepath()); this->setString("ARCHIVE_PATH", this->archivepath());
this->setBool("CITRA", this->citra());
// Write changes to file. // Write changes to file.
const std::string dump = this->json.dump(1, '\t'); const std::string dump = this->json.dump(1, '\t');
fwrite(dump.c_str(), 1, this->json.dump(1, '\t').size(), file); fwrite(dump.c_str(), 1, this->json.dump(1, '\t').size(), file);