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

Added a way to see current cheat update and available app updates

This commit is contained in:
flb 2020-09-29 16:41:43 +02:00
parent 244fd1c8c4
commit dc43c0cf6b
9 changed files with 50 additions and 18 deletions

View file

@ -27,6 +27,7 @@
#define CHEATS_FILENAME "/config/aio-switch-updater/cheats.zip"
#define CHEATS_EXCLUDE "/config/aio-switch-updater/exclude.txt"
#define UPDATED_TITLES_PATH "/config/aio-switch-updater/updated.dat"
#define CHEATS_VERSION "/config/aio-switch-updater/cheats_version.dat"
#define AMS_CONTENTS "/atmosphere/contents/"
#define REINX_CONTENTS "/ReiNX/contents/"
#define SXOS_TITLES "/sxos/titles/"

View file

@ -23,6 +23,6 @@ class ToolsTab : public brls::List
brls::StagedAppletFrame* stagedFrame;
public:
ToolsTab();
ToolsTab(std::string tag);
};

View file

@ -41,3 +41,5 @@ int showDialogBox(std::string text, std::string opt);
int showDialogBox(std::string text, std::string opt1, std::string opt2);
std::string getLatestTag(const char *url);
Result CopyFile(const char src_path[FS_MAX_PATH], const char dest_path[FS_MAX_PATH]);
void saveVersion(std::string version, const char* path);
std::string readVersion(const char* path);

View file

@ -31,6 +31,10 @@ ChangelogPage::ChangelogPage() : AppletFrame(true, true)
verTitles.push_back("v1.1.2");
changes.push_back("\uE016 Added GUI to disable cheat updates for specific titles.");
verTitles.push_back("v1.1.3");
changes.push_back("\uE016 Now displays the latest installed cheat version.\n"\
"\uE016 Now warns if in the app title if a new update is available.");
int nbVersions = verTitles.size();
items.reserve(nbVersions);
for(int i = nbVersions -1 ; i >= 0; i--){

View file

@ -1,4 +1,6 @@
#include "extract.hpp"
#include "utils.hpp"
#include "download.hpp"
void extract(const char * filename, const char* workingPath, int overwriteInis){
ProgressEvent::instance().reset();
@ -269,6 +271,7 @@ void extractCheats(const char * zipPath, std::vector<Title> titles, CFW cfw, boo
}
unzipper.close();
writeTitlesToFile(extractedTitles, UPDATED_TITLES_PATH);
saveVersion(fetchTitle(CHEATS_RELEASE_URL), CHEATS_VERSION);
ProgressEvent::instance().setStep(ProgressEvent::instance().getMax());
}

View file

@ -9,9 +9,13 @@ ListDownloadTab::ListDownloadTab(archiveType type) :
"Once downloaded, it will be extracted in '/firmware'. You can then install the update through Daybreak or ChoiDuJour.\n"\
"\uE016 Current FW: "
);
SetSysFirmwareVersion ver;
if (R_SUCCEEDED(setsysGetFirmwareVersion(&ver))) firmwareText += ver.display_version;
else firmwareText += "not found";
std::string currentCheatsVer =
"\uE016 This will download a daily updated archive of cheat codes from 'gbatemp.net'. "\
"Cheat codes for games you don't have installed won't be extracted to your SD card. "\
"You can turn off cheat updated in 'Tools->Cheat menu'.\n"\
"\uE016 Current cheats version: ";
this->description = new brls::Label(brls::LabelStyle::DESCRIPTION, "", true);
switch(type){
case sigpatches:
@ -25,6 +29,9 @@ ListDownloadTab::ListDownloadTab(archiveType type) :
case fw:
links = fetchLinks(FIRMWARE_URL);
operation += "firmware";
SetSysFirmwareVersion ver;
if (R_SUCCEEDED(setsysGetFirmwareVersion(&ver))) firmwareText += ver.display_version;
else firmwareText += "not found";
this->description->setText(firmwareText);
break;
case app:
@ -56,11 +63,8 @@ ListDownloadTab::ListDownloadTab(archiveType type) :
}
}
operation += "cheats";
this->description->setText(
"\uE016 This will download a daily updated archive of cheat codes from 'gbatemp.net'. "\
"Cheat codes for games you don't have installed won't be extracted to your SD card. "\
"You can turn off cheat updated in 'Tools->Cheat menu'."
);
currentCheatsVer += readVersion(CHEATS_VERSION);
this->description->setText(currentCheatsVer);
break;
}
/* std::get<0>(links).push_back("Test");

View file

@ -2,9 +2,10 @@
MainFrame::MainFrame() : TabFrame()
{
//this->setIcon(new Logo(LogoStyle::HEADER));
brls::Logger::debug("MainFrame");
std::string tag = getLatestTag(TAGS_INFO);
if(!tag.empty() && tag != APP_VERSION)
setTitle(std::string(APP_TITLE) + " - New app update available");
else
setTitle(std::string(APP_TITLE) + " v" + std::string(APP_VERSION));
this->addTab("About", new AboutTab());
@ -18,5 +19,5 @@ MainFrame::MainFrame() : TabFrame()
this->addSeparator();
this->addTab("Tools", new ToolsTab());
this->addTab("Tools", new ToolsTab(tag));
}

View file

@ -1,6 +1,6 @@
#include "tools_tab.hpp"
ToolsTab::ToolsTab() : brls::List()
ToolsTab::ToolsTab(std::string tag) : brls::List()
{
cheats = new brls::ListItem("Cheats menu");
cheats->getClickEvent()->subscribe([&](brls::View* view){
@ -26,7 +26,6 @@ ToolsTab::ToolsTab() : brls::List()
});
this->addView(rebootPayload);
std::string tag = getLatestTag(TAGS_INFO);
if(!tag.empty() && tag != APP_VERSION){
updateApp = new brls::ListItem("Update the app (v" + tag +")");
std::string text("Downloading:\nAIO-switch-updater\n\nFrom:\n" + std::string(APP_URL));

View file

@ -328,3 +328,21 @@ Result CopyFile(const char src_path[FS_MAX_PATH], const char dest_path[FS_MAX_PA
fsFileClose(&dest_handle);
return 0;
}
void saveVersion(std::string version, const char* path){
std::fstream newVersion;
newVersion.open(path, std::fstream::out | std::fstream::trunc);
newVersion << version << std::endl;
newVersion.close();
}
std::string readVersion(const char* path){
std::fstream versionFile;
std::string version = "0";
if(std::filesystem::exists(path)){
versionFile.open(path, std::fstream::in);
versionFile >> version;
versionFile.close();
}
return version;
}