mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-07 08:49:08 +00:00
Begin to add variables for 3DSX & NDS.
This commit is contained in:
@@ -73,3 +73,5 @@ extern char * arg0;
|
|||||||
#define ENTRIES_PER_SCREEN 3
|
#define ENTRIES_PER_SCREEN 3
|
||||||
#define ENTRIES_PER_LIST 7
|
#define ENTRIES_PER_LIST 7
|
||||||
#define metaFile "sdmc:/3ds/Universal-Updater/ScriptInfo.json"
|
#define metaFile "sdmc:/3ds/Universal-Updater/ScriptInfo.json"
|
||||||
|
#define _3DSX_PATH "sdmc:/3ds"
|
||||||
|
#define _NDS_PATH "sdmc:"
|
||||||
@@ -124,6 +124,12 @@ public:
|
|||||||
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; }
|
||||||
|
|
||||||
|
// 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; }
|
||||||
|
|
||||||
// Mainly helper.
|
// Mainly helper.
|
||||||
bool getBool(const std::string &key);
|
bool getBool(const std::string &key);
|
||||||
void setBool(const std::string &key, bool v);
|
void setBool(const std::string &key, bool v);
|
||||||
@@ -134,7 +140,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
nlohmann::json json; // Our private JSON file.
|
nlohmann::json json; // Our private JSON file.
|
||||||
bool changesMade = false, initialChanges = false;
|
bool changesMade = false, initialChanges = false;
|
||||||
int configVersion = 1;
|
int configVersion = 2;
|
||||||
|
|
||||||
// Color variables and more.
|
// Color variables and more.
|
||||||
u32 v_barColor, v_topBG, v_bottomBG, v_textColor, v_buttonColor, v_selectedColor, v_unselectedColor, v_progressbarColor,
|
u32 v_barColor, v_topBG, v_bottomBG, v_textColor, v_buttonColor, v_selectedColor, v_unselectedColor, v_progressbarColor,
|
||||||
@@ -142,6 +148,9 @@ private:
|
|||||||
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;
|
||||||
|
|
||||||
|
// Some variables.
|
||||||
|
std::string v_3dsx_install_path, v_nds_install_path;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+25
-5
@@ -30,9 +30,12 @@
|
|||||||
#include <citro2d.h>
|
#include <citro2d.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
// Used to add missing stuff for the JSON. No new things for now.
|
// Used to add missing stuff for the JSON.
|
||||||
void Config::addMissingThings() {
|
void Config::addMissingThings() {
|
||||||
|
if (this->json["VERSION"] < 2) {
|
||||||
|
this->setString("3DSX_PATH", _3DSX_PATH);
|
||||||
|
this->setString("NDS_PATH", _NDS_PATH);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// In case it doesn't exist.
|
// In case it doesn't exist.
|
||||||
@@ -69,10 +72,13 @@ void Config::initialize() {
|
|||||||
this->setBool("FIRST_STARTUP", true);
|
this->setBool("FIRST_STARTUP", true);
|
||||||
this->setBool("USE_SCRIPT_COLORS", true);
|
this->setBool("USE_SCRIPT_COLORS", true);
|
||||||
this->setBool("SHOW_SPEED", false);
|
this->setBool("SHOW_SPEED", false);
|
||||||
|
this->setString("3DSX_PATH", _3DSX_PATH);
|
||||||
|
this->setString("NDS_PATH", _NDS_PATH);
|
||||||
this->setInt("VERSION", this->configVersion);
|
this->setInt("VERSION", this->configVersion);
|
||||||
|
|
||||||
// Write to file.
|
// Write to file.
|
||||||
fwrite(this->json.dump(1, '\t').c_str(), 1, this->json.dump(1, '\t').size(), file);
|
const std::string dump = this->json.dump(1, '\t');
|
||||||
|
fwrite(dump.c_str(), 1, this->json.dump(1, '\t').size(), file);
|
||||||
fclose(file); // Now we have the file and can properly access it.
|
fclose(file); // Now we have the file and can properly access it.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +99,6 @@ Config::Config() {
|
|||||||
// Here we add the missing things.
|
// Here we add the missing things.
|
||||||
if (this->json["VERSION"] < this->configVersion) {
|
if (this->json["VERSION"] < this->configVersion) {
|
||||||
this->addMissingThings();
|
this->addMissingThings();
|
||||||
this->save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->json.contains("BARCOLOR")) {
|
if (!this->json.contains("BARCOLOR")) {
|
||||||
@@ -265,6 +270,18 @@ Config::Config() {
|
|||||||
this->showSpeed(this->getBool("SHOW_SPEED"));
|
this->showSpeed(this->getBool("SHOW_SPEED"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this->json.contains("3DSX_PATH")) {
|
||||||
|
this->_3dsxpath(_3DSX_PATH);
|
||||||
|
} else {
|
||||||
|
this->_3dsxpath(this->getString("3DSX_PATH"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this->json.contains("NDS_PATH")) {
|
||||||
|
this->ndspath(_NDS_PATH);
|
||||||
|
} else {
|
||||||
|
this->ndspath(this->getString("NDS_PATH"));
|
||||||
|
}
|
||||||
|
|
||||||
this->changesMade = false; // No changes made yet.
|
this->changesMade = false; // No changes made yet.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,8 +319,11 @@ void Config::save() {
|
|||||||
this->setBool("FIRST_STARTUP", this->firstStartup());
|
this->setBool("FIRST_STARTUP", this->firstStartup());
|
||||||
this->setBool("USE_SCRIPT_COLORS", this->useScriptColor());
|
this->setBool("USE_SCRIPT_COLORS", this->useScriptColor());
|
||||||
this->setBool("SHOW_SPEED", this->showSpeed());
|
this->setBool("SHOW_SPEED", this->showSpeed());
|
||||||
|
this->setString("3DSX_PATH", this->_3dsxpath());
|
||||||
|
this->setString("NDS_PATH", this->ndspath());
|
||||||
// Write changes to file.
|
// Write changes to file.
|
||||||
fwrite(this->json.dump(1, '\t').c_str(), 1, this->json.dump(1, '\t').size(), file);
|
const std::string dump = this->json.dump(1, '\t');
|
||||||
|
fwrite(dump.c_str(), 1, this->json.dump(1, '\t').size(), file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include "thread.hpp"
|
#include "thread.hpp"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <regex>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
extern bool showProgressBar;
|
extern bool showProgressBar;
|
||||||
@@ -67,8 +68,12 @@ int ScriptHelper::getNum(nlohmann::json json, const std::string &key, const std:
|
|||||||
|
|
||||||
// Download from a Github Release.
|
// Download from a Github Release.
|
||||||
Result ScriptHelper::downloadRelease(std::string repo, std::string file, std::string output, bool includePrereleases, bool showVersions, std::string message) {
|
Result ScriptHelper::downloadRelease(std::string repo, std::string file, std::string output, bool includePrereleases, bool showVersions, std::string message) {
|
||||||
|
std::string out;
|
||||||
|
out = std::regex_replace(output, std::regex("%3DSX%"), config->_3dsxpath().c_str());
|
||||||
|
out = std::regex_replace(out, std::regex("%NDS%"), config->ndspath().c_str());
|
||||||
|
|
||||||
Result ret = NONE;
|
Result ret = NONE;
|
||||||
if (downloadFromRelease("https://github.com/" + repo, file, output, message, includePrereleases, showVersions) != 0) {
|
if (downloadFromRelease("https://github.com/" + repo, file, out, message, includePrereleases, showVersions) != 0) {
|
||||||
showProgressBar = false;
|
showProgressBar = false;
|
||||||
downloadFailed();
|
downloadFailed();
|
||||||
ret = FAILED_DOWNLOAD;
|
ret = FAILED_DOWNLOAD;
|
||||||
@@ -81,12 +86,16 @@ Result ScriptHelper::downloadRelease(std::string repo, std::string file, std::st
|
|||||||
|
|
||||||
// Download a File from everywhere.
|
// Download a File from everywhere.
|
||||||
Result ScriptHelper::downloadFile(std::string file, std::string output, std::string message) {
|
Result ScriptHelper::downloadFile(std::string file, std::string output, std::string message) {
|
||||||
|
std::string out;
|
||||||
|
out = std::regex_replace(output, std::regex("%3DSX%"), config->_3dsxpath().c_str());
|
||||||
|
out = std::regex_replace(out, std::regex("%NDS%"), config->ndspath().c_str());
|
||||||
|
|
||||||
Result ret = NONE;
|
Result ret = NONE;
|
||||||
snprintf(progressBarMsg, sizeof(progressBarMsg), message.c_str());
|
snprintf(progressBarMsg, sizeof(progressBarMsg), message.c_str());
|
||||||
showProgressBar = true;
|
showProgressBar = true;
|
||||||
progressbarType = ProgressBar::Downloading;
|
progressbarType = ProgressBar::Downloading;
|
||||||
Threads::create((ThreadFunc)displayProgressBar);
|
Threads::create((ThreadFunc)displayProgressBar);
|
||||||
if (downloadToFile(file, output) != 0) {
|
if (downloadToFile(file, out) != 0) {
|
||||||
showProgressBar = false;
|
showProgressBar = false;
|
||||||
downloadFailed();
|
downloadFailed();
|
||||||
ret = FAILED_DOWNLOAD;
|
ret = FAILED_DOWNLOAD;
|
||||||
|
|||||||
@@ -81,10 +81,10 @@ bool Store::updateAvailable(int index) {
|
|||||||
const std::string updateEntry2 = (std::string)this->updateJSON[this->updateFile][entry];
|
const std::string updateEntry2 = (std::string)this->updateJSON[this->updateFile][entry];
|
||||||
return strcasecmp(updateEntry.c_str(), updateEntry2.c_str()) > 0;
|
return strcasecmp(updateEntry.c_str(), updateEntry2.c_str()) > 0;
|
||||||
} else {
|
} else {
|
||||||
return true; // Since we do not have this entry there yet.
|
return false; // Since we do not have this entry there yet.
|
||||||
}
|
}
|
||||||
} else { // Our update json don't have that yet.. so display available.
|
} else { // Our update json don't have that yet.. so display available.
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
} else { // Since the Store doesn't have that feature.
|
} else { // Since the Store doesn't have that feature.
|
||||||
return false;
|
return false;
|
||||||
@@ -97,7 +97,8 @@ bool Store::updateAvailable(int index) {
|
|||||||
void Store::writeToFile(int index) {
|
void Store::writeToFile(int index) {
|
||||||
FILE *file = fopen("sdmc:/3ds/Universal-Updater/updates.json", "w");
|
FILE *file = fopen("sdmc:/3ds/Universal-Updater/updates.json", "w");
|
||||||
this->updateJSON[this->updateFile][this->sortedStore[index].title] = this->sortedStore[index].last_updated;
|
this->updateJSON[this->updateFile][this->sortedStore[index].title] = this->sortedStore[index].last_updated;
|
||||||
fwrite(this->updateJSON.dump(1, '\t').c_str(), 1, this->updateJSON.dump(1, '\t').size(), file);
|
const std::string dump = this->updateJSON.dump(1, '\t');
|
||||||
|
fwrite(dump.c_str(), 1, this->updateJSON.dump(1, '\t').size(), file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
this->sortedStore[index].updateAvailable = false;
|
this->sortedStore[index].updateAvailable = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user