Add nightly/prerelease warnings

This commit is contained in:
Pk11
2022-02-21 04:26:35 -06:00
committed by Dark98
parent c91372f66b
commit 0a2848158c
9 changed files with 41 additions and 8 deletions
+9 -3
View File
@@ -169,7 +169,7 @@ void StoreUtils::DrawDownList(const std::vector<std::string> &entries, bool fetc
int &smallDelay: Reference to the small delay. This helps to not directly press A.
std::vector<bool> &installs: Reference to the installed states.
*/
void StoreUtils::DownloadHandle(const std::unique_ptr<StoreEntry> &entry, const std::vector<std::string> &entries, int &currentMenu, const int &lastMode, int &smallDelay, std::vector<bool> &installs) {
void StoreUtils::DownloadHandle(const std::unique_ptr<StoreEntry> &entry, const std::vector<std::string> &entries, int &currentMenu, const int &lastMode, int &smallDelay, std::vector<bool> &installs, const std::vector<std::string> &types) {
if (StoreUtils::store && entry) { // Ensure, store & entry is not a nullptr.
if (smallDelay > 0) {
smallDelay--;
@@ -212,7 +212,10 @@ void StoreUtils::DownloadHandle(const std::unique_ptr<StoreEntry> &entry, const
for (int i = 0; i < DOWNLOAD_ENTRIES; i++) {
if (touching(touch, downloadBoxes[i])) {
if (i + StoreUtils::store->GetDownloadSIndex() < (int)entries.size()) {
if (Msg::promptMsg(Lang::get("EXECUTE_ENTRY") + "\n\n" + entries[i + StoreUtils::store->GetDownloadSIndex()])) {
std::string Msg = Lang::get("EXECUTE_ENTRY") + "\n\n" + entries[i + StoreUtils::store->GetDownloadSIndex()];
if (types[i + StoreUtils::store->GetDownloadSIndex()] == "nightly") Msg += "\n\n" + Lang::get("NOTE_NIGHTLY");
else if (types[i + StoreUtils::store->GetDownloadSIndex()] == "prerelease") Msg += "\n\n" + Lang::get("NOTE_PRERELEASE");
if (Msg::promptMsg(Msg)) {
StoreUtils::AddToQueue(entry->GetEntryIndex(), entries[i + StoreUtils::store->GetDownloadSIndex()], entry->GetTitle(), entry->GetLastUpdated());
}
}
@@ -234,7 +237,10 @@ void StoreUtils::DownloadHandle(const std::unique_ptr<StoreEntry> &entry, const
}
if (smallDelay == 0 && hDown & KEY_A && !entries.empty()) {
if (Msg::promptMsg(Lang::get("EXECUTE_ENTRY") + "\n\n" + entries[StoreUtils::store->GetDownloadIndex()])) {
std::string Msg = Lang::get("EXECUTE_ENTRY") + "\n\n" + entries[StoreUtils::store->GetDownloadIndex()];
if (types[StoreUtils::store->GetDownloadIndex()] == "nightly") Msg += "\n\n" + Lang::get("NOTE_NIGHTLY");
else if (types[StoreUtils::store->GetDownloadIndex()] == "prerelease") Msg += "\n\n" + Lang::get("NOTE_PRERELEASE");
if (Msg::promptMsg(Msg)) {
StoreUtils::AddToQueue(entry->GetEntryIndex(), entries[StoreUtils::store->GetDownloadIndex()], entry->GetTitle(), entry->GetLastUpdated());
}
}
+3 -1
View File
@@ -235,6 +235,7 @@ void MainScreen::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
this->installs.clear();
this->dwnldList.clear();
this->dwnldSizes.clear();
this->dwnldTypes.clear();
if (StoreUtils::store && StoreUtils::store->GetValid()) {
const std::vector<std::string> installedNames = StoreUtils::meta->GetInstalled(StoreUtils::store->GetStoreTitle(), StoreUtils::entries[StoreUtils::store->GetEntry()]->GetTitle());
@@ -244,6 +245,7 @@ void MainScreen::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
if ((int)StoreUtils::entries.size() > StoreUtils::store->GetEntry()) {
this->dwnldList = StoreUtils::store->GetDownloadList(StoreUtils::entries[StoreUtils::store->GetEntry()]->GetEntryIndex());
this->dwnldSizes = StoreUtils::entries[StoreUtils::store->GetEntry()]->GetSizes();
this->dwnldTypes = StoreUtils::entries[StoreUtils::store->GetEntry()]->GetTypes();
for (int i = 0; i < (int)this->dwnldList.size(); i++) {
bool good = false;
@@ -269,7 +271,7 @@ void MainScreen::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
break;
case 1:
if (StoreUtils::store && StoreUtils::store->GetValid() && StoreUtils::entries.size() > 0) StoreUtils::DownloadHandle(StoreUtils::entries[StoreUtils::store->GetEntry()], this->dwnldList, storeMode, this->lastMode, this->smallDelay, this->installs);
if (StoreUtils::store && StoreUtils::store->GetValid() && StoreUtils::entries.size() > 0) StoreUtils::DownloadHandle(StoreUtils::entries[StoreUtils::store->GetEntry()], this->dwnldList, storeMode, this->lastMode, this->smallDelay, this->installs, this->dwnldTypes);
break;
case 2:
+20
View File
@@ -506,6 +506,26 @@ std::string Store::GetFileSizes(int index, const std::string &entry) const {
return "";
}
/*
Get file script type for each download entry.
int index: The index.
const std::string &entry: The entry name.
*/
std::string Store::GetFileTypes(int index, const std::string &entry) const {
if (!this->valid) return "";
if (index > (int)this->storeJson["storeContent"].size() - 1) return "";
if (this->storeJson["storeContent"][index].contains(entry) && this->storeJson["storeContent"][index][entry].type() == nlohmann::json::value_t::object) {
if (this->storeJson["storeContent"][index][entry].contains("type") && this->storeJson["storeContent"][index][entry]["type"].is_string()) {
return this->storeJson["storeContent"][index][entry]["type"];
}
}
return "";
}
/*
Get Screenshot URL list.
+1
View File
@@ -61,6 +61,7 @@ StoreEntry::StoreEntry(const std::unique_ptr<Store> &store, const std::unique_pt
if (!entries.empty()) {
for (int i = 0; i < (int)entries.size(); i++) {
this->Sizes.push_back( store->GetFileSizes(index, entries[i]) );
this->Types.push_back( store->GetFileTypes(index, entries[i]) );
}
}