mirror of
https://github.com/HamletDuFromage/aio-switch-updater.git
synced 2024-11-28 12:22:02 +00:00
Added ability to view existing cheats when downloading cheat codes/sheets. Fixed wrong tid for theme detection.
This commit is contained in:
parent
29238448bc
commit
13cc1ff4e2
8 changed files with 81 additions and 60 deletions
2
Makefile
2
Makefile
|
@ -22,7 +22,7 @@ DATA := data
|
|||
INCLUDES := include lib/zipper/include /lib/borealis/library/include/borealis/extern/nlohmann
|
||||
APP_TITLE := All-in-One Switch Updater
|
||||
APP_AUTHOR := HamletDuFromage
|
||||
APP_VERSION := 2.11.0
|
||||
APP_VERSION := 2.11.1
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
|
||||
ROMFS := resources
|
||||
|
|
|
@ -73,8 +73,6 @@ class AppPage_DownloadedCheats : public AppPage
|
|||
void CreateLabel() override;
|
||||
void DeclareGameListItem(const std::string& name, uint64_t tid, NsApplicationControlData **controlData) override;
|
||||
void GetExistingCheatsTids();
|
||||
void ShowCheatFiles(uint64_t tid, const std::string& name);
|
||||
bool CreateCheatList(const std::filesystem::path& path, brls::TabFrame** appView);
|
||||
|
||||
public:
|
||||
AppPage_DownloadedCheats();
|
||||
|
|
|
@ -3,6 +3,14 @@
|
|||
#include <borealis.hpp>
|
||||
#include <switch.h>
|
||||
#include <json.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
namespace show_cheats {
|
||||
|
||||
void ShowCheatFiles(uint64_t tid, const std::string& name);
|
||||
bool CreateCheatList(const std::filesystem::path& path, brls::TabFrame** appView);
|
||||
|
||||
}
|
||||
|
||||
class DownloadCheatsPage : public brls::AppletFrame
|
||||
{
|
||||
|
|
|
@ -42,7 +42,8 @@
|
|||
"gbatemp_dl_successful_dl": "Successfully downloaded the following cheat code:\n{}",
|
||||
"applet_mode_not_supported": "Due to memory constraints, in applet mode you may only fetch cheat codes for the game you're currently playing. Please launch aio-switch-updater through title redirection to download cheat codes for any game you own.",
|
||||
"cheatfile_label": "Here are the cheat codes listed in file {}",
|
||||
"not_found": "No proper cheat codes could be found for this game"
|
||||
"not_found": "No proper cheat codes could be found for this game",
|
||||
"show_existing": "Show existing"
|
||||
},
|
||||
"common": {
|
||||
"downloading": "Downloading...",
|
||||
|
|
|
@ -277,7 +277,7 @@ void AppPage_DownloadedCheats::CreateLabel()
|
|||
void AppPage_DownloadedCheats::DeclareGameListItem(const std::string& name, u64 tid, NsApplicationControlData **controlData)
|
||||
{
|
||||
if (titles.find(util::formatApplicationId(tid)) != titles.end()) {
|
||||
listItem->getClickEvent()->subscribe([this, tid, name](brls::View* view) { ShowCheatFiles(tid, name); });
|
||||
listItem->getClickEvent()->subscribe([this, tid, name](brls::View* view) { show_cheats::ShowCheatFiles(tid, name); });
|
||||
AppPage::DeclareGameListItem(name, tid, controlData);
|
||||
}
|
||||
}
|
||||
|
@ -297,53 +297,3 @@ void AppPage_DownloadedCheats::GetExistingCheatsTids() {
|
|||
}
|
||||
}
|
||||
|
||||
void AppPage_DownloadedCheats::ShowCheatFiles(u64 tid, const std::string& name) {
|
||||
std::string path = util::getContentsPath();
|
||||
path += util::formatApplicationId(tid) + "/cheats/";
|
||||
|
||||
brls::TabFrame* appView = new brls::TabFrame();
|
||||
bool is_populated = false;
|
||||
if(std::filesystem::exists(path)) {
|
||||
for(const auto& cheatFile : std::filesystem::directory_iterator(path)){
|
||||
is_populated |= CreateCheatList(cheatFile.path(), &appView);
|
||||
}
|
||||
}
|
||||
if(is_populated) {
|
||||
brls::PopupFrame::open(name, appView, "");
|
||||
}
|
||||
else {
|
||||
brls::Dialog* dialog = new brls::Dialog("menus/cheats/not_found"_i18n);
|
||||
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
|
||||
dialog->close();
|
||||
};
|
||||
dialog->addButton("menus/common/ok"_i18n, callback);
|
||||
dialog->setCancelable(true);
|
||||
dialog->open();
|
||||
}
|
||||
}
|
||||
|
||||
bool AppPage_DownloadedCheats::CreateCheatList(const std::filesystem::path& path, brls::TabFrame** appView) {
|
||||
bool res = false;
|
||||
brls::List* cheatsList = new brls::List();
|
||||
if(extract::isBID(path.filename().stem())) {
|
||||
cheatsList->addView(new brls::Label(brls::LabelStyle::DESCRIPTION, fmt::format("menus/cheats/cheatfile_label"_i18n, path.filename().string()), true));
|
||||
|
||||
std::string str;
|
||||
std::regex cheats_expr(R"(\[.+\])");
|
||||
std::ifstream in(path);
|
||||
if(in) {
|
||||
while (std::getline(in, str)) {
|
||||
if(str.size() > 0) {
|
||||
if(std::regex_search(str, cheats_expr)) {
|
||||
cheatsList->addView(new brls::ListItem(str));
|
||||
res = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(res) {
|
||||
(*appView)->addTab(util::upperCase(path.filename().stem()), cheatsList);
|
||||
}
|
||||
return res;
|
||||
}
|
|
@ -181,6 +181,9 @@ ChangelogPage::ChangelogPage() : AppletFrame(true, true)
|
|||
verTitles.push_back("v2.11.0");
|
||||
changes.push_back("\uE016 Borealis changes for visual tweaks (tickering labels, scroll bar etc).\n\uE016 When needed, issue a warning about custom themes after downloading a new firmware.\n\uE016 Abort AMS update process for Mariko Switches when payload.bin cannot be found.");
|
||||
|
||||
verTitles.push_back("v2.11.1");
|
||||
changes.push_back("\uE016 Added ability to view existing cheats when downloading cheat codes/sheets.\n\uE016 Fixed wrong tid for theme detection.");
|
||||
|
||||
for(int i = verTitles.size() -1 ; i >= 0; i--){
|
||||
listItem = new brls::ListItem(verTitles[i]);
|
||||
change = changes[i];
|
||||
|
|
|
@ -12,13 +12,71 @@ namespace i18n = brls::i18n;
|
|||
using namespace i18n::literals;
|
||||
using json = nlohmann::json;
|
||||
|
||||
namespace show_cheats {
|
||||
|
||||
void ShowCheatFiles(u64 tid, const std::string& name) {
|
||||
std::string path = util::getContentsPath();
|
||||
path += util::formatApplicationId(tid) + "/cheats/";
|
||||
|
||||
brls::TabFrame* appView = new brls::TabFrame();
|
||||
bool is_populated = false;
|
||||
if(std::filesystem::exists(path)) {
|
||||
for(const auto& cheatFile : std::filesystem::directory_iterator(path)){
|
||||
is_populated |= CreateCheatList(cheatFile.path(), &appView);
|
||||
}
|
||||
}
|
||||
if(is_populated) {
|
||||
brls::PopupFrame::open(name, appView, "");
|
||||
}
|
||||
else {
|
||||
brls::Dialog* dialog = new brls::Dialog("menus/cheats/not_found"_i18n);
|
||||
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
|
||||
dialog->close();
|
||||
};
|
||||
dialog->addButton("menus/common/ok"_i18n, callback);
|
||||
dialog->setCancelable(true);
|
||||
dialog->open();
|
||||
}
|
||||
}
|
||||
|
||||
bool CreateCheatList(const std::filesystem::path& path, brls::TabFrame** appView) {
|
||||
bool res = false;
|
||||
brls::List* cheatsList = new brls::List();
|
||||
if(extract::isBID(path.filename().stem())) {
|
||||
cheatsList->addView(new brls::Label(brls::LabelStyle::DESCRIPTION, fmt::format("menus/cheats/cheatfile_label"_i18n, path.filename().string()), true));
|
||||
|
||||
std::string str;
|
||||
std::regex cheats_expr(R"(\[.+\])");
|
||||
std::ifstream in(path);
|
||||
if(in) {
|
||||
while (std::getline(in, str)) {
|
||||
if(str.size() > 0) {
|
||||
if(std::regex_search(str, cheats_expr)) {
|
||||
cheatsList->addView(new brls::ListItem(str));
|
||||
res = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(res) {
|
||||
(*appView)->addTab(util::upperCase(path.filename().stem()), cheatsList);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
DownloadCheatsPage::DownloadCheatsPage(uint64_t tid, const std::string& name) : AppletFrame(true, true), tid(tid)
|
||||
{
|
||||
list = new brls::List();
|
||||
GetVersion();
|
||||
GetBuildID();
|
||||
this->setTitle(name);
|
||||
this->setFooterText("Game version: v" + std::to_string(this->version / 0x10000));
|
||||
this->setFooterText("v" + std::to_string(this->version / 0x10000));
|
||||
this->registerAction("menus/cheats/show_existing"_i18n , brls::Key::X, [this, tid, name] {
|
||||
show_cheats::ShowCheatFiles(tid, name);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
void DownloadCheatsPage::GetBuildID() {
|
||||
|
|
|
@ -99,16 +99,19 @@ ListDownloadTab::ListDownloadTab(const archiveType type) :
|
|||
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, [type](){util::extractArchive(type);})
|
||||
);
|
||||
std::string doneMsg = "menus/common/all_done"_i18n;
|
||||
std::string themePath;
|
||||
std::string contentsPath;
|
||||
switch(type){
|
||||
case archiveType::ams_cfw:
|
||||
case archiveType::app:
|
||||
case archiveType::cfw:
|
||||
case archiveType::cheats:
|
||||
case archiveType::fw:
|
||||
themePath = util::getContentsPath() + "0100000000010000";
|
||||
if(std::filesystem::exists(themePath) && !std::filesystem::is_empty(themePath)) {
|
||||
doneMsg += "\n" + "menus/main/theme_warning"_i18n;
|
||||
contentsPath = util::getContentsPath();
|
||||
for (const auto& tid : {"0100000000001000", "0100000000001007", "0100000000001013"}) {
|
||||
if(std::filesystem::exists(contentsPath + tid) && !std::filesystem::is_empty(contentsPath + tid)) {
|
||||
doneMsg += "\n" + "menus/main/theme_warning"_i18n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case archiveType::sigpatches:
|
||||
|
|
Loading…
Reference in a new issue