-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added GUI option to disable cheat updates
- Loading branch information
1 parent
cce7d21
commit 42ac921
Showing
15 changed files
with
199 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
|
||
#include <borealis.hpp> | ||
#include "app_page.hpp" | ||
#include "exclude_page.hpp" | ||
|
||
class CheatsPage : public brls::AppletFrame | ||
{ | ||
private: | ||
brls::List* list; | ||
brls::ListItem* view; | ||
brls::ListItem* deleteCheats; | ||
brls::ListItem* exclude; | ||
brls::StagedAppletFrame* stagedFrame; | ||
|
||
public: | ||
CheatsPage(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
#include <borealis.hpp> | ||
#include <switch.h> | ||
#include <cstring> | ||
#include "utils.hpp" | ||
#include <filesystem> | ||
#include <fstream> | ||
#include <iostream> | ||
#include <algorithm> | ||
#include <tuple> | ||
#include <vector> | ||
#include <string> | ||
|
||
typedef struct app App; | ||
|
||
class ExcludePage : public brls::AppletFrame | ||
{ | ||
private: | ||
brls::List* list; | ||
brls::Label* label; | ||
brls::ListItem* save; | ||
std::vector<App*> apps; | ||
std::set<std::string> titles; | ||
//std::vector<brls::ToggleListItem*> items; | ||
std::tuple<std::vector<brls::ToggleListItem*>, std::vector<std::string>> items; | ||
|
||
public: | ||
ExcludePage(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,5 +95,4 @@ AppPage::AppPage() : AppletFrame(true, true) | |
}); | ||
list->addView(download); | ||
this->setContentView(list); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "cheats_page.hpp" | ||
|
||
CheatsPage::CheatsPage() : AppletFrame(true, true) | ||
{ | ||
this->setTitle("Cheats menu"); | ||
list = new brls::List(); | ||
|
||
view = new brls::ListItem("View installed cheats"); | ||
view->getClickEvent()->subscribe([&](brls::View* view){ | ||
brls::Application::pushView(new AppPage()); | ||
}); | ||
list->addView(view); | ||
|
||
exclude = new brls::ListItem("Exclude games from recieving cheat updates"); | ||
exclude->getClickEvent()->subscribe([&](brls::View* view){ | ||
brls::Application::pushView(new ExcludePage()); | ||
}); | ||
list->addView(exclude); | ||
|
||
|
||
deleteCheats = new brls::ListItem("Delete all existing cheat codes"); | ||
deleteCheats->getClickEvent()->subscribe([&](brls::View* view){ | ||
stagedFrame = new brls::StagedAppletFrame(); | ||
stagedFrame->setTitle("Delete all cheats"); | ||
stagedFrame->addStage( | ||
new WorkerPage(stagedFrame, "Deleting", [](){removeCheats(getCFW());}) | ||
); | ||
stagedFrame->addStage( | ||
new ConfirmPage(stagedFrame, "All done!", true) | ||
); | ||
brls::Application::pushView(stagedFrame); | ||
}); | ||
list->addView(deleteCheats); | ||
|
||
this->setContentView(list); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#include "exclude_page.hpp" | ||
|
||
ExcludePage::ExcludePage() : AppletFrame(true, true) | ||
{ | ||
this->setTitle("Exclude titles"); | ||
list = new brls::List(); | ||
label = new brls::Label( | ||
brls::LabelStyle::DESCRIPTION, | ||
"You can turn off cheat updates with this menu", | ||
true | ||
); | ||
list->addView(label); | ||
|
||
NsApplicationRecord record; | ||
uint64_t tid; | ||
NsApplicationControlData controlData; | ||
NacpLanguageEntry* langEntry = NULL; | ||
|
||
Result rc; | ||
size_t i = 0; | ||
int recordCount = 0; | ||
size_t controlSize = 0; | ||
|
||
titles = readLineByLine(CHEATS_EXCLUDE); | ||
|
||
//std::tuple<std::vector<brls::ToggleListItem*>, std::vector<std::string>> items; | ||
|
||
while (true) | ||
{ | ||
rc = nsListApplicationRecord(&record, sizeof(record), i, &recordCount); | ||
if (R_FAILED(rc)) break; | ||
|
||
if(recordCount <= 0) | ||
break; | ||
|
||
tid = record.application_id; | ||
rc = nsGetApplicationControlData(NsApplicationControlSource_Storage, tid, &controlData, sizeof(controlData), &controlSize); | ||
if (R_FAILED(rc)) break; | ||
rc = nacpGetLanguageEntry(&controlData.nacp, &langEntry); | ||
if (R_FAILED(rc)) break; | ||
if (!langEntry->name) | ||
{ | ||
i++; | ||
continue; | ||
} | ||
App* app = (App*) malloc(sizeof(App)); | ||
app->tid = tid; | ||
|
||
memset(app->name, 0, sizeof(app->name)); | ||
strncpy(app->name, langEntry->name, sizeof(app->name)-1); | ||
|
||
memcpy(app->icon, controlData.icon, sizeof(app->icon)); | ||
|
||
// Add the ListItem | ||
brls::ToggleListItem *listItem; | ||
if(titles.find(formatApplicationId(tid)) != titles.end()) | ||
listItem = new brls::ToggleListItem(formatListItemTitle(std::string(app->name)), 0); | ||
else | ||
listItem = new brls::ToggleListItem(formatListItemTitle(std::string(app->name)), 1); | ||
|
||
listItem->setThumbnail(app->icon, sizeof(app->icon)); | ||
std::get<0>(items).push_back(listItem); | ||
std::get<1>(items).push_back(formatApplicationId(app->tid)); | ||
list->addView(listItem); | ||
i++; | ||
} | ||
|
||
list->registerAction("Save choice and return", brls::Key::B, [this] { | ||
std::set<std::string> exclude{}; | ||
for(int i = 0; i < (int) std::get<1>(items).size(); i++){ | ||
if(!std::get<0>(items)[i]->getToggleState()){ | ||
exclude.insert(std::get<1>(items)[i]); | ||
} | ||
} | ||
writeTitlesToFile(exclude, CHEATS_EXCLUDE); | ||
brls::Application::popView(); | ||
return true; | ||
}); | ||
this->setContentView(list); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters