From cd5dd73bcf4901bcc7cf1552f6b3eae95f476554 Mon Sep 17 00:00:00 2001 From: Pk11 Date: Tue, 23 Mar 2021 03:15:50 -0500 Subject: [PATCH 1/2] WIP: Add the ability to open wikis in the browser Currently press SELECT and if the app has one it'll *quit UU* and open the browser I feel like it should be possible to launch the browser without quitting UU as you can launch it from the home menu while the app is running, but that wasn't working. --- include/store/store.hpp | 1 + include/store/storeEntry.hpp | 3 ++- source/menu/entryInfo.cpp | 7 +++++++ source/store/store.cpp | 16 ++++++++++++++++ source/store/storeEntry.cpp | 1 + 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/include/store/store.hpp b/include/store/store.hpp index 95ba52050..6a9d5f224 100644 --- a/include/store/store.hpp +++ b/include/store/store.hpp @@ -53,6 +53,7 @@ class Store { std::vector GetConsoleEntry(int index) const; std::string GetLastUpdatedEntry(int index) const; std::string GetLicenseEntry(int index) const; + std::string GetWikiEntry(int index) const; C2D_Image GetIconEntry(int index) const; std::string GetFileSizes(int index, const std::string &entry) const; std::string GetFileTypes(int index, const std::string &entry) const; diff --git a/include/store/storeEntry.hpp b/include/store/storeEntry.hpp index 2a5469934..37b7b6c89 100644 --- a/include/store/storeEntry.hpp +++ b/include/store/storeEntry.hpp @@ -43,6 +43,7 @@ class StoreEntry { std::string GetConsole() const { return this->Console; }; std::string GetLastUpdated() const { return this->LastUpdated; }; std::string GetLicense() const { return this->License; }; + std::string GetWiki() const { return this->Wiki; }; int GetMarks() const { return this->Marks; }; C2D_Image GetIcon() const { return this->Icon; }; @@ -67,7 +68,7 @@ class StoreEntry { }; private: - std::string Title, Author, Description, Category, Version, Console, LastUpdated, License, MarkString, ReleaseNotes; + std::string Title, Author, Description, Category, Version, Console, LastUpdated, License, MarkString, ReleaseNotes, Wiki; C2D_Image Icon; int SheetIndex, EntryIndex, Marks; std::vector FullCategory, FullConsole, Sizes, Types, Screenshots, ScreenshotNames; diff --git a/source/menu/entryInfo.cpp b/source/menu/entryInfo.cpp index 82410836f..9c754d186 100644 --- a/source/menu/entryInfo.cpp +++ b/source/menu/entryInfo.cpp @@ -102,6 +102,13 @@ void StoreUtils::EntryHandle(bool &showMark, bool &fetch, bool &sFetch, int &mod mode = 7; } } + + if (hDown & KEY_SELECT && entry->GetWiki() != "") { + APT_PrepareToStartSystemApplet(APPID_WEB); + APT_StartSystemApplet(APPID_WEB, entry->GetWiki().c_str(), entry->GetWiki().size(), 0); + aptClearChainloader(); + exiting = true; + } } /* Quit UU. */ diff --git a/source/store/store.cpp b/source/store/store.cpp index e0e1d7da5..35161df84 100644 --- a/source/store/store.cpp +++ b/source/store/store.cpp @@ -404,6 +404,22 @@ std::string Store::GetLicenseEntry(int index) const { return Lang::get("NO_LICENSE"); } +/* + Return the Wiki of an index. + + int index: The index. +*/ +std::string Store::GetWikiEntry(int index) const { + if (!this->valid) return ""; + if (index > (int)this->storeJson["storeContent"].size() - 1) return ""; // Empty. + + if (this->storeJson["storeContent"][index]["info"].contains("wiki") && this->storeJson["storeContent"][index]["info"]["wiki"].is_string()) { + return this->storeJson["storeContent"][index]["info"]["wiki"]; + } + + return ""; +} + /* Return a C2D_Image of an index. diff --git a/source/store/storeEntry.cpp b/source/store/storeEntry.cpp index 1fad23a5b..6e54446d1 100644 --- a/source/store/storeEntry.cpp +++ b/source/store/storeEntry.cpp @@ -44,6 +44,7 @@ StoreEntry::StoreEntry(const std::unique_ptr &store, const std::unique_pt this->Console = StringUtils::FetchStringsFromVector(store->GetConsoleEntry(index)); this->LastUpdated = store->GetLastUpdatedEntry(index); this->License = store->GetLicenseEntry(index); + this->Wiki = store->GetWikiEntry(index); this->MarkString = StringUtils::GetMarkString(meta->GetMarks(store->GetUniStoreTitle(), this->Title)); this->Icon = store->GetIconEntry(index); From 685cedd4279fa91c88bddb39f08f77b6535c490e Mon Sep 17 00:00:00 2001 From: Pk11 Date: Tue, 23 Mar 2021 18:37:29 -0500 Subject: [PATCH 2/2] Don't quit UU on browser load NOTE: This now freezes on returning to UU --- source/menu/entryInfo.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/menu/entryInfo.cpp b/source/menu/entryInfo.cpp index 9c754d186..6c949e370 100644 --- a/source/menu/entryInfo.cpp +++ b/source/menu/entryInfo.cpp @@ -104,10 +104,9 @@ void StoreUtils::EntryHandle(bool &showMark, bool &fetch, bool &sFetch, int &mod } if (hDown & KEY_SELECT && entry->GetWiki() != "") { + GSPGPU_ReleaseRight(); APT_PrepareToStartSystemApplet(APPID_WEB); APT_StartSystemApplet(APPID_WEB, entry->GetWiki().c_str(), entry->GetWiki().size(), 0); - aptClearChainloader(); - exiting = true; } }