1
0
Fork 0
mirror of https://github.com/HamletDuFromage/aio-switch-updater.git synced 2024-12-29 10:56:01 +00:00

added ams version display

This commit is contained in:
flb 2021-03-10 21:43:00 +01:00
parent cc95fc66eb
commit 242e93fdca
9 changed files with 36 additions and 32 deletions

View file

@ -1,7 +1,9 @@
#pragma once #pragma once
#include "constants.hpp" #include "constants.hpp"
#include <string>
bool isServiceRunning(const char *serviceName); bool isServiceRunning(const char *serviceName);
CFW getCFW(); CFW getCFW();
std::string getAmsInfo();
const extern CFW running_cfw; const extern CFW running_cfw;

View file

@ -13,5 +13,5 @@ class ListDownloadTab : public brls::List
brls::Label *cheatSlipLabel; brls::Label *cheatSlipLabel;
public: public:
ListDownloadTab(const archiveType type); ListDownloadTab(const archiveType type);
~ListDownloadTab();
}; };

View file

@ -147,7 +147,8 @@
"reboot_rcm": "The Switch will now reboot to a special payload in order to finalise the install.", "reboot_rcm": "The Switch will now reboot to a special payload in order to finalise the install.",
"install_hekate": "Do you want to also download Hekate?\nIf not, the Switch will now launch reboot to a special payload in order to finalise the install.", "install_hekate": "Do you want to also download Hekate?\nIf not, the Switch will now launch reboot to a special payload in order to finalise the install.",
"delete_contents": "Would you like to remove the existing '/atmosphere/contents/' directory? This will prevent crashes if you have sysmodules that do not support the latest Atmosph\u00e8re. Please note that it will delete all your existing sysmodules, mods and cheats.", "delete_contents": "Would you like to remove the existing '/atmosphere/contents/' directory? This will prevent crashes if you have sysmodules that do not support the latest Atmosph\u00e8re. Please note that it will delete all your existing sysmodules, mods and cheats.",
"delete_sysmodules_flags": "Would you like to delete all the custom sysmodules startup flags? This will turn off all your sysmodules and prevent crashes if you have sysmodules that do not support the latest Atmosphère." "delete_sysmodules_flags": "Would you like to delete all the custom sysmodules startup flags? This will turn off all your sysmodules and prevent crashes if you have sysmodules that do not support the latest Atmosphère.",
"current_ams": "\ue016 Current Atmosphère: "
}, },
"net": { "net": {
"title": "Internet settings" "title": "Internet settings"

View file

@ -6,6 +6,7 @@
#include "dialogue_page.hpp" #include "dialogue_page.hpp"
#include "worker_page.hpp" #include "worker_page.hpp"
#include "utils.hpp" #include "utils.hpp"
#include "current_cfw.hpp"
namespace i18n = brls::i18n; namespace i18n = brls::i18n;
using namespace i18n::literals; using namespace i18n::literals;
@ -14,27 +15,24 @@ AmsTab::AmsTab() :
brls::List() brls::List()
{ {
std::vector<std::pair<std::string, std::string>> links; std::vector<std::pair<std::string, std::string>> links;
std::string operation = "menus/main/getting"_i18n ; std::string operation("menus/main/getting"_i18n);
this->description = new brls::Label(brls::LabelStyle::DESCRIPTION, "", true); this->description = new brls::Label(brls::LabelStyle::DESCRIPTION, "", true);
operation += "menus/main/cfw"_i18n;
links = getLinks(AMS_URL); links = getLinks(AMS_URL);
operation += "menus/main/cfw"_i18n ;
this->description->setText( this->description->setText(
"menus/main/ams_text"_i18n "menus/main/ams_text"_i18n + (running_cfw == ams ? "\n" + "menus/ams_update/current_ams"_i18n + getAmsInfo() : "")
); );
this->addView(description); this->addView(description);
int nbLinks = links.size(); int nbLinks = links.size();
if(nbLinks){ if(nbLinks){
auto hekate_link = getLinks(HEKATE_URL); auto hekate_link = getLinks(HEKATE_URL);
std::string hekate_url = hekate_link[0].second; std::string hekate_url = hekate_link[0].second;
std::string text_hekate = "menus/common/download"_i18n + hekate_link[0].first; std::string text_hekate = "menus/common/download"_i18n + hekate_link[0].first;
for (int i = 0; i < nbLinks; i++){ for (int i = 0; i < nbLinks; i++){
std::string url = links[i].second; std::string url = links[i].second;
std::string text("menus/common/download"_i18n + links[i].first + "menus/common/from"_i18n + url); std::string text("menus/common/download"_i18n + links[i].first + "menus/common/from"_i18n + url);
listItem = new brls::ListItem(links[i].first); listItem = new brls::ListItem(links[i].first);
listItem->setHeight(LISTITEM_HEIGHT); listItem->setHeight(LISTITEM_HEIGHT);
listItem->getClickEvent()->subscribe([&, text, text_hekate, url, hekate_url, operation](brls::View* view) { listItem->getClickEvent()->subscribe([&, text, text_hekate, url, hekate_url, operation](brls::View* view) {
@ -44,22 +42,22 @@ AmsTab::AmsTab() :
new ConfirmPage(stagedFrame, text) new ConfirmPage(stagedFrame, text)
); );
stagedFrame->addStage( stagedFrame->addStage(
new WorkerPage(stagedFrame, "menus/common/downloading"_i18n , [url](){downloadArchive(url, ams_cfw);}) new WorkerPage(stagedFrame, "menus/common/downloading"_i18n, [url](){downloadArchive(url, ams_cfw);})
); );
stagedFrame->addStage( stagedFrame->addStage(
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n , [](){extractArchive(ams_cfw);}) new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, [](){extractArchive(ams_cfw);})
); );
stagedFrame->addStage( stagedFrame->addStage(
new DialoguePage(stagedFrame, text_hekate) new DialoguePage(stagedFrame, text_hekate)
); );
stagedFrame->addStage( stagedFrame->addStage(
new WorkerPage(stagedFrame, "menus/common/downloading"_i18n , [hekate_url](){downloadArchive(hekate_url, cfw);}) new WorkerPage(stagedFrame, "menus/common/downloading"_i18n, [hekate_url](){downloadArchive(hekate_url, cfw);})
); );
stagedFrame->addStage( stagedFrame->addStage(
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n , [](){extractArchive(cfw);}) new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, [](){extractArchive(cfw);})
); );
stagedFrame->addStage( stagedFrame->addStage(
new ConfirmPage(stagedFrame, "menus/ams_update/reboot_rcm"_i18n , false, true) new ConfirmPage(stagedFrame, "menus/ams_update/reboot_rcm"_i18n, false, true)
); );
brls::Application::pushView(stagedFrame); brls::Application::pushView(stagedFrame);
}); });
@ -69,11 +67,10 @@ AmsTab::AmsTab() :
else{ else{
notFound = new brls::Label( notFound = new brls::Label(
brls::LabelStyle::DESCRIPTION, brls::LabelStyle::DESCRIPTION,
"menus/main/links_not_found"_i18n , "menus/main/links_not_found"_i18n,
true true
); );
notFound->setHorizontalAlign(NVG_ALIGN_CENTER); notFound->setHorizontalAlign(NVG_ALIGN_CENTER);
this->addView(notFound); this->addView(notFound);
} }
} }

View file

@ -116,7 +116,7 @@ ChangelogPage::ChangelogPage() : AppletFrame(true, true)
changes.push_back("\uE016 Minor fixes, refactored old switch-cheats updater code and changed way to detect CFW"); changes.push_back("\uE016 Minor fixes, refactored old switch-cheats updater code and changed way to detect CFW");
verTitles.push_back("v2.4.0"); verTitles.push_back("v2.4.0");
changes.push_back("\uE016 Added option to extract the entire gbatemp cheats archive.\n\uE016 Shortened load times.\n\uE016 Added German localisation (thanks to github.com/Slluxx).\n\uE016 Added option to disable sysmodules prior to updating.\n\uE016 Improved Japanese localisation (thanks to github.com/yyoossk)."); changes.push_back("\uE016 Added option to extract the entire gbatemp cheats archive.\n\uE016 Shortened load times.\n\uE016 Added German localisation (thanks to github.com/Slluxx).\n\uE016 Added option to disable sysmodules prior to updating.\n\uE016 Improved Japanese localisation (thanks to github.com/yyoossk).\n\uE016 Added current AMS version display.");
for(int i = verTitles.size() -1 ; i >= 0; i--){ for(int i = verTitles.size() -1 ; i >= 0; i--){
listItem = new brls::ListItem(verTitles[i]); listItem = new brls::ListItem(verTitles[i]);

View file

@ -34,4 +34,19 @@ CFW getCFW(){
if(isServiceRunning("tx")) return sxos; if(isServiceRunning("tx")) return sxos;
} }
return ams; return ams;
}
std::string getAmsInfo() {
u64 version;
std::string res;
if(R_SUCCEEDED(splGetConfig((SplConfigItem) 65000, &version))){
res += std::to_string((version >> 56) & ((1 << 8) - 1)) + "." +
std::to_string((version >> 48) & ((1 << 8) - 1)) + "." +
std::to_string((version >> 40) & ((1 << 8) - 1));
if(R_SUCCEEDED(splGetConfig((SplConfigItem) 65007, &version)))
res += version ? "|E" : "|S";
return res;
}
else
return "Couldn't retrieve AMS version";
} }

View file

@ -18,7 +18,7 @@ ListDownloadTab::ListDownloadTab(const archiveType type) :
{ {
std::vector<std::pair<std::string, std::string>> links; std::vector<std::pair<std::string, std::string>> links;
std::vector<std::pair<std::string, std::string>> sxoslinks; std::vector<std::pair<std::string, std::string>> sxoslinks;
std::string operation = "menus/main/getting"_i18n ; std::string operation("menus/main/getting"_i18n);
std::string firmwareText("menus/main/firmware_text"_i18n); std::string firmwareText("menus/main/firmware_text"_i18n);
std::string currentCheatsVer = "menus/main/cheats_text"_i18n ; std::string currentCheatsVer = "menus/main/cheats_text"_i18n ;
@ -182,9 +182,4 @@ ListDownloadTab::ListDownloadTab(const archiveType type) :
}); });
this->addView(cheatslipsItem); this->addView(cheatslipsItem);
} }
}
ListDownloadTab::~ListDownloadTab(){
} }

View file

@ -32,17 +32,14 @@ int main(int argc, char* argv[])
brls::Logger::setLogLevel(brls::LogLevel::DEBUG); brls::Logger::setLogLevel(brls::LogLevel::DEBUG);
#endif #endif
// Initialize services with a PC shim
setsysInitialize(); setsysInitialize();
plInitialize(PlServiceType_User); plInitialize(PlServiceType_User);
nsInitialize(); nsInitialize();
socketInitializeDefault(); socketInitializeDefault();
nxlinkStdio(); nxlinkStdio();
splInitialize(); splInitialize();
romfsInit(); romfsInit();
createTree(CONFIG_PATH); createTree(CONFIG_PATH);
brls::Logger::setLogLevel(brls::LogLevel::DEBUG); brls::Logger::setLogLevel(brls::LogLevel::DEBUG);
@ -55,11 +52,8 @@ int main(int argc, char* argv[])
brls::Application::pushView(new WarningPage("menus/main/launch_warning"_i18n)); brls::Application::pushView(new WarningPage("menus/main/launch_warning"_i18n));
} }
// Run the app
while (brls::Application::mainLoop()); while (brls::Application::mainLoop());
// Exit
romfsExit(); romfsExit();
splExit(); splExit();
socketExit(); socketExit();

View file

@ -6,7 +6,7 @@
#include "json.hpp" #include "json.hpp"
#include <fstream> #include <fstream>
#include "utils.hpp" #include "utils.hpp"
namespace i18n = brls::i18n; namespace i18n = brls::i18n;
using namespace i18n::literals; using namespace i18n::literals;
using json = nlohmann::json; using json = nlohmann::json;