mirror of
https://github.com/HamletDuFromage/aio-switch-updater.git
synced 2024-11-09 12:01:44 +00:00
handle quota exceeded for cheatslips
This commit is contained in:
parent
f216393487
commit
4e02841839
5 changed files with 61 additions and 36 deletions
|
@ -5,12 +5,8 @@
|
||||||
![GitHub](https://img.shields.io/github/license/HamletDuFromage/aio-switch-updater)
|
![GitHub](https://img.shields.io/github/license/HamletDuFromage/aio-switch-updater)
|
||||||
|
|
||||||
[![btc](https://img.shields.io/badge/BTC-1CoFc1bY5AHLP6Noe1zmqnJnp7ZWBxyo79-yellow)](https://github.com/HamletDuFromage/aio-switch-updater#like-the-app)
|
[![btc](https://img.shields.io/badge/BTC-1CoFc1bY5AHLP6Noe1zmqnJnp7ZWBxyo79-yellow)](https://github.com/HamletDuFromage/aio-switch-updater#like-the-app)
|
||||||
|
|
||||||
[![eth](https://img.shields.io/badge/ETH-0xf68f568e21a15934e0e9a6949288c3ca009140ba-purple)](https://github.com/HamletDuFromage/aio-switch-updater#like-the-app)
|
[![eth](https://img.shields.io/badge/ETH-0xf68f568e21a15934e0e9a6949288c3ca009140ba-purple)](https://github.com/HamletDuFromage/aio-switch-updater#like-the-app)
|
||||||
|
|
||||||
[![eth](https://img.shields.io/badge/LINK-0xf68f568e21a15934e0e9a6949288c3ca009140ba-lightblue
|
|
||||||
)](https://github.com/HamletDuFromage/aio-switch-updater#like-the-app)
|
|
||||||
|
|
||||||
[//]: ([![ko-fi](https://img.shields.io/badge/ko--fi-buy%20me%20a%20coffee-ff69b4)](https://ko-fi.com/hamletdufromage))
|
[//]: ([![ko-fi](https://img.shields.io/badge/ko--fi-buy%20me%20a%20coffee-ff69b4)](https://ko-fi.com/hamletdufromage))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ class ListDownloadTab : public brls::List
|
||||||
brls::ListItem *cheatslipsItem;
|
brls::ListItem *cheatslipsItem;
|
||||||
brls::Label *notFound;
|
brls::Label *notFound;
|
||||||
brls::Label *description;
|
brls::Label *description;
|
||||||
|
brls::Label *cheatSlipLabel;
|
||||||
public:
|
public:
|
||||||
ListDownloadTab(archiveType type);
|
ListDownloadTab(archiveType type);
|
||||||
~ListDownloadTab();
|
~ListDownloadTab();
|
||||||
|
|
|
@ -77,9 +77,11 @@
|
||||||
"cheat_All_done": "All done!",
|
"cheat_All_done": "All done!",
|
||||||
|
|
||||||
"get_cheatslips": "Download CheatSlips.com cheat sheets",
|
"get_cheatslips": "Download CheatSlips.com cheat sheets",
|
||||||
|
"cheatslips_label": "\uE016 Log into CheatSlips.com and download cheat sheets for your games.",
|
||||||
"download_cheatslips": "Download a selection of cheat sheets from CheatSlips.com.\nThose cheat codes will be added to the end of your existing cheat file.",
|
"download_cheatslips": "Download a selection of cheat sheets from CheatSlips.com.\nThose cheat codes will be added to the end of your existing cheat file.",
|
||||||
"delete_cheat": "Delete existing cheat file",
|
"delete_cheat": "Delete existing cheat file",
|
||||||
"couldnt_dl_cheats": "Could not fetch selected cheat codes/invalid token.\nYou may have reached your daily download quota. Head on to 'https://www.cheatslips.com/subscriptions' to see increase it.\n",
|
"couldnt_dl_cheats": "Could not fetch selected cheat codes/invalid token.",
|
||||||
|
"quota_cheatslips": "Quota exceeded for today!\nHead on to 'https://www.cheatslips.com/subscriptions' to see increase it.",
|
||||||
"cheat_cheat_content": "Cheatsheet content: ",
|
"cheat_cheat_content": "Cheatsheet content: ",
|
||||||
"app_cheatslips_label": "Select a game to download cheats for.",
|
"app_cheatslips_label": "Select a game to download cheats for.",
|
||||||
"/wrong_cheatslips_id": "Couldn't retrieve token, make you enter you login properly",
|
"/wrong_cheatslips_id": "Couldn't retrieve token, make you enter you login properly",
|
||||||
|
|
|
@ -56,6 +56,7 @@ DownloadCheatsPage::DownloadCheatsPage(uint64_t tid) : AppletFrame(true, true)
|
||||||
ids.push_back(e.second);
|
ids.push_back(e.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int error = 0;
|
||||||
if(!ids.empty()) {
|
if(!ids.empty()) {
|
||||||
json token;
|
json token;
|
||||||
std::ifstream tokenFile(TOKEN_PATH);
|
std::ifstream tokenFile(TOKEN_PATH);
|
||||||
|
@ -69,12 +70,29 @@ DownloadCheatsPage::DownloadCheatsPage(uint64_t tid) : AppletFrame(true, true)
|
||||||
if(cheatsInfo.find("cheats") != cheatsInfo.end()) {
|
if(cheatsInfo.find("cheats") != cheatsInfo.end()) {
|
||||||
for (const auto& p : cheatsInfo["cheats"].items()) {
|
for (const auto& p : cheatsInfo["cheats"].items()) {
|
||||||
if(std::find(ids.begin(), ids.end(), p.value()["id"]) != ids.end()) {
|
if(std::find(ids.begin(), ids.end(), p.value()["id"]) != ids.end()) {
|
||||||
WriteCheats(tid, bid, p.value()["content"]);
|
if(p.value()["content"].get<std::string>() == "Quota exceeded for today !"){
|
||||||
|
error = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
WriteCheats(tid, bid, p.value()["content"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
brls::Dialog* dialog = new brls::Dialog("menus/couldnt_dl_cheats"_i18n);
|
error = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(error != 0){
|
||||||
|
brls::Dialog* dialog;
|
||||||
|
switch(error){
|
||||||
|
case 1:
|
||||||
|
dialog = new brls::Dialog("menus/quota_cheatslips"_i18n);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
dialog = new brls::Dialog("menus/couldnt_dl_cheats"_i18n);
|
||||||
|
break;
|
||||||
|
}
|
||||||
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
|
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
|
||||||
dialog->close();
|
dialog->close();
|
||||||
};
|
};
|
||||||
|
@ -83,7 +101,7 @@ DownloadCheatsPage::DownloadCheatsPage(uint64_t tid) : AppletFrame(true, true)
|
||||||
dialog->open();
|
dialog->open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
brls::Application::popView();
|
if(error == 0) brls::Application::popView();
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,43 @@ ListDownloadTab::ListDownloadTab(archiveType type) :
|
||||||
}
|
}
|
||||||
|
|
||||||
this->addView(description);
|
this->addView(description);
|
||||||
|
|
||||||
|
int nbLinks = std::get<0>(links).size();
|
||||||
|
if(nbLinks){
|
||||||
|
for (int i = 0; i<nbLinks; i++){
|
||||||
|
std::string url = std::get<1>(links)[i];
|
||||||
|
std::string text("menus/list_down"_i18n + std::get<0>(links)[i] + "menus/list_from"_i18n + url);
|
||||||
|
listItem = new brls::ListItem(std::get<0>(links)[i]);
|
||||||
|
listItem->setHeight(LISTITEM_HEIGHT);
|
||||||
|
listItem->getClickEvent()->subscribe([&, text, url, type, operation](brls::View* view) {
|
||||||
|
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
||||||
|
stagedFrame->setTitle(operation);
|
||||||
|
stagedFrame->addStage(
|
||||||
|
new ConfirmPage(stagedFrame, text)
|
||||||
|
);
|
||||||
|
stagedFrame->addStage(
|
||||||
|
new WorkerPage(stagedFrame, "menus/list_downing"_i18n , [url, type](){downloadArchive(url, type);})
|
||||||
|
);
|
||||||
|
stagedFrame->addStage(
|
||||||
|
new WorkerPage(stagedFrame, "menus/list_extracting"_i18n , [type](){extractArchive(type);})
|
||||||
|
);
|
||||||
|
stagedFrame->addStage(
|
||||||
|
new ConfirmPage(stagedFrame, "menus/list_All"_i18n , true)
|
||||||
|
);
|
||||||
|
brls::Application::pushView(stagedFrame);
|
||||||
|
});
|
||||||
|
this->addView(listItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if(type == cheats){
|
if(type == cheats){
|
||||||
|
cheatSlipLabel = new brls::Label(
|
||||||
|
brls::LabelStyle::DESCRIPTION,
|
||||||
|
"menus/cheatslips_label"_i18n ,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
this->addView(cheatSlipLabel);
|
||||||
cheatslipsItem = new brls::ListItem("menus/get_cheatslips"_i18n);
|
cheatslipsItem = new brls::ListItem("menus/get_cheatslips"_i18n);
|
||||||
cheatslipsItem->setHeight(LISTITEM_HEIGHT);
|
cheatslipsItem->setHeight(LISTITEM_HEIGHT);
|
||||||
cheatslipsItem->getClickEvent()->subscribe([&](brls::View* view) {
|
cheatslipsItem->getClickEvent()->subscribe([&](brls::View* view) {
|
||||||
|
@ -122,34 +158,6 @@ ListDownloadTab::ListDownloadTab(archiveType type) :
|
||||||
this->addView(cheatslipsItem);
|
this->addView(cheatslipsItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
int nbLinks = std::get<0>(links).size();
|
|
||||||
if(nbLinks){
|
|
||||||
for (int i = 0; i<nbLinks; i++){
|
|
||||||
std::string url = std::get<1>(links)[i];
|
|
||||||
std::string text("menus/list_down"_i18n + std::get<0>(links)[i] + "menus/list_from"_i18n + url);
|
|
||||||
listItem = new brls::ListItem(std::get<0>(links)[i]);
|
|
||||||
listItem->setHeight(LISTITEM_HEIGHT);
|
|
||||||
listItem->getClickEvent()->subscribe([&, text, url, type, operation](brls::View* view) {
|
|
||||||
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
|
||||||
stagedFrame->setTitle(operation);
|
|
||||||
stagedFrame->addStage(
|
|
||||||
new ConfirmPage(stagedFrame, text)
|
|
||||||
);
|
|
||||||
stagedFrame->addStage(
|
|
||||||
new WorkerPage(stagedFrame, "menus/list_downing"_i18n , [url, type](){downloadArchive(url, type);})
|
|
||||||
);
|
|
||||||
stagedFrame->addStage(
|
|
||||||
new WorkerPage(stagedFrame, "menus/list_extracting"_i18n , [type](){extractArchive(type);})
|
|
||||||
);
|
|
||||||
stagedFrame->addStage(
|
|
||||||
new ConfirmPage(stagedFrame, "menus/list_All"_i18n , true)
|
|
||||||
);
|
|
||||||
brls::Application::pushView(stagedFrame);
|
|
||||||
});
|
|
||||||
this->addView(listItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else{
|
else{
|
||||||
notFound = new brls::Label(
|
notFound = new brls::Label(
|
||||||
brls::LabelStyle::DESCRIPTION,
|
brls::LabelStyle::DESCRIPTION,
|
||||||
|
|
Loading…
Reference in a new issue