Added signature patches source URL config

This commit is contained in:
Huntereb 2019-10-27 17:16:42 -04:00
parent 64d3ed3ae4
commit 4e737a6f69
5 changed files with 39 additions and 9 deletions

View file

@ -4,6 +4,7 @@
namespace inst::config {
extern const std::string appDir;
extern const std::string configPath;
extern std::string sigPatchesUrl;
extern bool ignoreReqVers;
extern bool gayMode;

View file

@ -12,11 +12,11 @@ namespace sig {
void installSigPatches () {
int ourResult = inst::ui::mainApp->CreateShowDialog("Install signature patches?", "Signature patches are required for installing and playing NSP contents!", {"Install", "Uninstall", "Cancel"}, true);
if (ourResult == 0) {
if (!inst::util::copyFile("sdmc:/bootloader/patches.ini", "sdmc:/bootloader/patches.ini.old")) {
if (!inst::util::copyFile("sdmc:/bootloader/patches.ini", inst::config::appDir + "/patches.ini.old")) {
if (inst::ui::mainApp->CreateShowDialog("Could not back up old Hekate patches.ini! Install anyway?", "", {"Yes", "No"}, false)) return;
}
std::string ourPath = inst::config::appDir + "patches.zip";
bool didDownload = inst::curl::downloadFile("http://github.com/Joonie86/hekate/releases/download/5.0.0J/Kosmos_patches_10_09_2019.zip", ourPath.c_str());
bool didDownload = inst::curl::downloadFile(inst::config::sigPatchesUrl, ourPath.c_str());
bool didExtract = false;
if (didDownload) didExtract = inst::zip::extractFile(ourPath, "sdmc:/");
else {
@ -31,9 +31,9 @@ namespace sig {
}
return;
} else if (ourResult == 1) {
if (!inst::util::copyFile( "sdmc:/bootloader/patches.ini.old", "sdmc:/bootloader/patches.ini")) {
if (!inst::util::copyFile( inst::config::appDir + "/patches.ini.old", "sdmc:/bootloader/patches.ini")) {
if (inst::ui::mainApp->CreateShowDialog("Unable to restore original Hekate patches.ini! Continue uninstalling?", "", {"Yes", "No"}, false)) return;
} else std::filesystem::remove("sdmc:/bootloader/patches.ini.old");
} else std::filesystem::remove(inst::config::appDir + "/patches.ini.old");
if (inst::util::removeDirectory("sdmc:/atmosphere/exefs_patches/es_patches")) inst::ui::mainApp->CreateShowDialog("Uninstall complete", "Restart your console to apply", {"OK"}, true);
else inst::ui::mainApp->CreateShowDialog("Unable to remove signature patches", "Files may have been renamed or deleted", {"OK"}, true);
} else return;

View file

@ -63,7 +63,7 @@ namespace inst::ui {
} else {
mainApp->LoadLayout(mainApp->mainPage);
return;
}
}
}
} else {
this->pageInfoText->SetText("Select a NSP to install!");

View file

@ -11,7 +11,7 @@
namespace inst::ui {
extern MainApplication *mainApp;
std::vector<std::string> ourMenuEntries = {"Ignore Required Firmware Version - ", "Remove Anime - "};
std::vector<std::string> ourMenuEntries = {"Ignore Required Firmware Version: ", "Remove Anime: ", "Signature Patches Source URL: "};
optionsPage::optionsPage() : Layout::Layout() {
this->SetBackgroundColor(COLOR("#670000FF"));
@ -50,6 +50,12 @@ namespace inst::ui {
auto gayModeOption = pu::ui::elm::MenuItem::New(ourMenuEntries[1] + getMenuOptionText(inst::config::gayMode));
gayModeOption->SetColor(COLOR("#FFFFFFFF"));
this->menu->AddItem(gayModeOption);
auto sigPatchesUrlOption = pu::ui::elm::MenuItem::New(ourMenuEntries[2] + inst::config::sigPatchesUrl);
sigPatchesUrlOption->SetColor(COLOR("#FFFFFFFF"));
this->menu->AddItem(sigPatchesUrlOption);
auto creditsOption = pu::ui::elm::MenuItem::New("Credits");
creditsOption->SetColor(COLOR("#FFFFFFFF"));
this->menu->AddItem(creditsOption);
}
void optionsPage::onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos) {
@ -57,6 +63,8 @@ namespace inst::ui {
mainApp->LoadLayout(mainApp->mainPage);
}
if (Down & KEY_A) {
Result rc=0;
char tmpoutstr[128] = {0};
switch (this->menu->GetSelectedIndex()) {
case 0:
if (inst::config::ignoreReqVers) inst::config::ignoreReqVers = false;
@ -78,6 +86,25 @@ namespace inst::ui {
inst::config::setConfig();
optionsPage::setMenuText();
break;
case 2:
SwkbdConfig kbd;
rc = swkbdCreate(&kbd, 0);
if (R_SUCCEEDED(rc)) {
swkbdConfigMakePresetDefault(&kbd);
swkbdConfigSetGuideText(&kbd, "Enter the URL to obtain Signature Patches from");
swkbdConfigSetInitialText(&kbd, inst::config::sigPatchesUrl.c_str());
rc = swkbdShow(&kbd, tmpoutstr, sizeof(tmpoutstr));
swkbdClose(&kbd);
if (R_SUCCEEDED(rc) && tmpoutstr[0] != 0) {
inst::config::sigPatchesUrl = tmpoutstr;
inst::config::setConfig();
optionsPage::setMenuText();
}
}
break;
case 3:
inst::ui::mainApp->CreateShowDialog("Thanks to the following people for helping me!\n\n-HookedBehemoth for screen-nx (A great reference!)\n-Adubbz for Tinfoil\n-XorTroll for Plutonium and Goldleaf\n-The kind folks at the AtlasNX Discuck\n-The also kind folks at the RetroNX Discuck\n-TheXzoron for being a baka", "", {"Close"}, true);
break;
default:
break;
}

View file

@ -6,19 +6,21 @@
namespace inst::config {
const std::string appDir = "sdmc:/switch/Awoo-Installer";
const std::string configPath = appDir + "/config.ini";
std::string sigPatchesUrl = "http://github.com/Joonie86/hekate/releases/download/5.0.0J/Kosmos_patches_10_09_2019.zip";
bool ignoreReqVers = true;
bool gayMode = false;
void parseConfig() {
INIReader reader(inst::config::configPath);
inst::config::ignoreReqVers = reader.GetBoolean("settings", "ignoreReqVers", true);
inst::config::gayMode = reader.GetBoolean("settings", "gayMode", false);
inst::config::ignoreReqVers = reader.GetBoolean("settings", "ignoreReqVers", inst::config::ignoreReqVers);
inst::config::gayMode = reader.GetBoolean("settings", "gayMode", inst::config::gayMode);
inst::config::sigPatchesUrl = reader.GetString("settings", "sigPatchesUrl", inst::config::sigPatchesUrl);
return;
}
void setConfig() {
std::filesystem::remove(inst::config::configPath);
std::string data("[settings]\nignoreReqVers=" + std::to_string(inst::config::ignoreReqVers) + "\ngayMode=" + std::to_string(inst::config::gayMode) + "\n");
std::string data("[settings]\nignoreReqVers=" + std::to_string(inst::config::ignoreReqVers) + "\ngayMode=" + std::to_string(inst::config::gayMode) + "\nsigPatchesUrl=" + inst::config::sigPatchesUrl + "\n");
FILE * configFile = fopen(inst::config::configPath.c_str(), "w");
fwrite(data.c_str(), sizeof(char), data.size(), configFile);
fflush(configFile);