Save URLs from previous net installations

This commit is contained in:
Huntereb 2020-09-20 23:22:33 -04:00
parent 447226e955
commit b181a9183c
3 changed files with 9 additions and 4 deletions

View file

@ -9,6 +9,7 @@ namespace inst::config {
extern std::string gAuthKey;
extern std::string sigPatchesUrl;
extern std::string lastNetUrl;
extern std::vector<std::string> updateInfo;
extern int languageSetting;
extern bool ignoreReqVers;

View file

@ -14,7 +14,6 @@
namespace inst::ui {
extern MainApplication *mainApp;
std::string lastUrl = "https://";
std::string lastFileID = "";
std::string sourceString = "";
@ -88,13 +87,14 @@ namespace inst::ui {
std::string keyboardResult;
switch (mainApp->CreateShowDialog("inst.net.src.title"_lang, "common.cancel_desc"_lang, {"inst.net.src.opt0"_lang, "inst.net.src.opt1"_lang}, false)) {
case 0:
keyboardResult = inst::util::softwareKeyboard("inst.net.url.hint"_lang, lastUrl, 500);
keyboardResult = inst::util::softwareKeyboard("inst.net.url.hint"_lang, inst::config::lastNetUrl, 500);
if (keyboardResult.size() > 0) {
lastUrl = keyboardResult;
if (inst::util::formatUrlString(keyboardResult) == "" || keyboardResult == "https://" || keyboardResult == "http://") {
mainApp->CreateShowDialog("inst.net.url.invalid"_lang, "", {"common.ok"_lang}, false);
break;
}
inst::config::lastNetUrl = keyboardResult;
inst::config::setConfig();
sourceString = "inst.net.url.source_string"_lang;
this->selectedUrls = {keyboardResult};
this->startInstall(true);

View file

@ -6,6 +6,7 @@
namespace inst::config {
std::string gAuthKey;
std::string sigPatchesUrl;
std::string lastNetUrl;
std::vector<std::string> updateInfo;
int languageSetting;
bool autoUpdate;
@ -27,7 +28,8 @@ namespace inst::config {
{"overClock", overClock},
{"sigPatchesUrl", sigPatchesUrl},
{"usbAck", usbAck},
{"validateNCAs", validateNCAs}
{"validateNCAs", validateNCAs},
{"lastNetUrl", lastNetUrl}
};
std::ofstream file(inst::config::configPath);
file << std::setw(4) << j << std::endl;
@ -48,6 +50,7 @@ namespace inst::config {
sigPatchesUrl = j["sigPatchesUrl"].get<std::string>();
usbAck = j["usbAck"].get<bool>();
validateNCAs = j["validateNCAs"].get<bool>();
lastNetUrl = j["lastNetUrl"].get<std::string>();
}
catch (...) {
// If loading values from the config fails, we just load the defaults and overwrite the old config
@ -61,6 +64,7 @@ namespace inst::config {
overClock = false;
usbAck = false;
validateNCAs = true;
lastNetUrl = "https://";
setConfig();
}
}