mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-03 00:39:02 +00:00
Begin to add variables for 3DSX & NDS.
This commit is contained in:
+25
-5
@@ -30,9 +30,12 @@
|
||||
#include <citro2d.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() {
|
||||
|
||||
if (this->json["VERSION"] < 2) {
|
||||
this->setString("3DSX_PATH", _3DSX_PATH);
|
||||
this->setString("NDS_PATH", _NDS_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
// In case it doesn't exist.
|
||||
@@ -69,10 +72,13 @@ void Config::initialize() {
|
||||
this->setBool("FIRST_STARTUP", true);
|
||||
this->setBool("USE_SCRIPT_COLORS", true);
|
||||
this->setBool("SHOW_SPEED", false);
|
||||
this->setString("3DSX_PATH", _3DSX_PATH);
|
||||
this->setString("NDS_PATH", _NDS_PATH);
|
||||
this->setInt("VERSION", this->configVersion);
|
||||
|
||||
// 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.
|
||||
}
|
||||
|
||||
@@ -93,7 +99,6 @@ Config::Config() {
|
||||
// Here we add the missing things.
|
||||
if (this->json["VERSION"] < this->configVersion) {
|
||||
this->addMissingThings();
|
||||
this->save();
|
||||
}
|
||||
|
||||
if (!this->json.contains("BARCOLOR")) {
|
||||
@@ -265,6 +270,18 @@ Config::Config() {
|
||||
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.
|
||||
}
|
||||
|
||||
@@ -302,8 +319,11 @@ void Config::save() {
|
||||
this->setBool("FIRST_STARTUP", this->firstStartup());
|
||||
this->setBool("USE_SCRIPT_COLORS", this->useScriptColor());
|
||||
this->setBool("SHOW_SPEED", this->showSpeed());
|
||||
this->setString("3DSX_PATH", this->_3dsxpath());
|
||||
this->setString("NDS_PATH", this->ndspath());
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "thread.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <regex>
|
||||
#include <unistd.h>
|
||||
|
||||
extern bool showProgressBar;
|
||||
@@ -67,8 +68,12 @@ int ScriptHelper::getNum(nlohmann::json json, const std::string &key, const std:
|
||||
|
||||
// Download from a Github Release.
|
||||
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;
|
||||
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;
|
||||
downloadFailed();
|
||||
ret = FAILED_DOWNLOAD;
|
||||
@@ -81,12 +86,16 @@ Result ScriptHelper::downloadRelease(std::string repo, std::string file, std::st
|
||||
|
||||
// Download a File from everywhere.
|
||||
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;
|
||||
snprintf(progressBarMsg, sizeof(progressBarMsg), message.c_str());
|
||||
showProgressBar = true;
|
||||
progressbarType = ProgressBar::Downloading;
|
||||
Threads::create((ThreadFunc)displayProgressBar);
|
||||
if (downloadToFile(file, output) != 0) {
|
||||
if (downloadToFile(file, out) != 0) {
|
||||
showProgressBar = false;
|
||||
downloadFailed();
|
||||
ret = FAILED_DOWNLOAD;
|
||||
|
||||
@@ -79,12 +79,12 @@ bool Store::updateAvailable(int index) {
|
||||
if (this->updateJSON.contains(this->updateFile)) {
|
||||
if (this->updateJSON[this->updateFile].contains(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 {
|
||||
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.
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
} else { // Since the Store doesn't have that feature.
|
||||
return false;
|
||||
@@ -97,7 +97,8 @@ bool Store::updateAvailable(int index) {
|
||||
void Store::writeToFile(int index) {
|
||||
FILE *file = fopen("sdmc:/3ds/Universal-Updater/updates.json", "w");
|
||||
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);
|
||||
|
||||
this->sortedStore[index].updateAvailable = false;
|
||||
|
||||
Reference in New Issue
Block a user