Skip to content

Commit 8cd0897

Browse files
authored
Add the ability to open wikis in the browser (#77)
* 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. * Don't quit UU on browser load NOTE: This now freezes on returning to UU * Probably fix loading browser This uses the new aptLaunchSystemApplet from libctru v2.5.0. It's failing to download from pacman for me so I can't test at the moment. * Fix browser launch * Add Wiki icon * Allocate buffer on heap * paramSize needs to include the null terminator
1 parent 5449c4e commit 8cd0897

File tree

7 files changed

+33
-1
lines changed

7 files changed

+33
-1
lines changed

assets/gfx/sprites.t3s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ sprites/universal-core.png
4747
sprites/update.png
4848
sprites/update_app.png
4949
sprites/update_filter.png
50+
sprites/wiki.png

assets/gfx/sprites/wiki.png

238 Bytes
Loading

include/store/store.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class Store {
5353
std::vector<std::string> GetConsoleEntry(int index) const;
5454
std::string GetLastUpdatedEntry(int index) const;
5555
std::string GetLicenseEntry(int index) const;
56+
std::string GetWikiEntry(int index) const;
5657
C2D_Image GetIconEntry(int index) const;
5758
std::string GetFileSizes(int index, const std::string &entry) const;
5859
std::string GetFileTypes(int index, const std::string &entry) const;

include/store/storeEntry.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class StoreEntry {
4343
std::string GetConsole() const { return this->Console; };
4444
std::string GetLastUpdated() const { return this->LastUpdated; };
4545
std::string GetLicense() const { return this->License; };
46+
std::string GetWiki() const { return this->Wiki; };
4647
int GetMarks() const { return this->Marks; };
4748

4849
C2D_Image GetIcon() const { return this->Icon; };
@@ -67,7 +68,7 @@ class StoreEntry {
6768
};
6869

6970
private:
70-
std::string Title, Author, Description, Category, Version, Console, LastUpdated, License, MarkString, ReleaseNotes;
71+
std::string Title, Author, Description, Category, Version, Console, LastUpdated, License, MarkString, ReleaseNotes, Wiki;
7172
C2D_Image Icon;
7273
int SheetIndex, EntryIndex, Marks;
7374
std::vector<std::string> FullCategory, FullConsole, Sizes, Types, Screenshots, ScreenshotNames;

source/menu/entryInfo.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ extern bool touching(touchPosition touch, Structs::ButtonPos button);
3333
static const Structs::ButtonPos btn = { 45, 215, 24, 24 };
3434
static const Structs::ButtonPos sshot = { 75, 215, 24, 24 };
3535
static const Structs::ButtonPos notes = { 105, 215, 24, 24 };
36+
static const Structs::ButtonPos wiki = { 135, 215, 24, 24 };
3637
extern bool checkWifiStatus();
3738
extern bool exiting, QueueRuns;
3839

@@ -59,6 +60,7 @@ void StoreUtils::DrawEntryInfo(const std::unique_ptr<StoreEntry> &entry) {
5960
GFX::DrawBox(btn.x, btn.y, btn.w, btn.h, false);
6061
if (!entry->GetScreenshots().empty()) GFX::DrawIcon(sprites_screenshot_idx, sshot.x, sshot.y, UIThemes->TextColor());
6162
if (entry->GetReleaseNotes() != "") GFX::DrawIcon(sprites_notes_idx, notes.x, notes.y, UIThemes->TextColor());
63+
if (entry->GetWiki() != "") GFX::DrawIcon(sprites_wiki_idx, wiki.x, wiki.y, UIThemes->TextColor());
6264
Gui::DrawString(btn.x + 5, btn.y + 2, 0.6f, UIThemes->TextColor(), "", 0, 0, font);
6365
}
6466
}
@@ -102,6 +104,16 @@ void StoreUtils::EntryHandle(bool &showMark, bool &fetch, bool &sFetch, int &mod
102104
mode = 7;
103105
}
104106
}
107+
108+
if (touching(touch, wiki) && entry->GetWiki() != "") {
109+
char *buf = new char[0x1000]; // Needs to be this size size it gets memcpy'd to
110+
int length = entry->GetWiki().size();
111+
memcpy(buf, entry->GetWiki().c_str(), length);
112+
buf[length] = 0;
113+
aptLaunchSystemApplet(APPID_WEB, buf, length + 1, 0);
114+
115+
delete[] buf;
116+
}
105117
}
106118

107119
/* Quit UU. */

source/store/store.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,22 @@ std::string Store::GetLicenseEntry(int index) const {
404404
return Lang::get("NO_LICENSE");
405405
}
406406

407+
/*
408+
Return the Wiki of an index.
409+
410+
int index: The index.
411+
*/
412+
std::string Store::GetWikiEntry(int index) const {
413+
if (!this->valid) return "";
414+
if (index > (int)this->storeJson["storeContent"].size() - 1) return ""; // Empty.
415+
416+
if (this->storeJson["storeContent"][index]["info"].contains("wiki") && this->storeJson["storeContent"][index]["info"]["wiki"].is_string()) {
417+
return this->storeJson["storeContent"][index]["info"]["wiki"];
418+
}
419+
420+
return "";
421+
}
422+
407423
/*
408424
Return a C2D_Image of an index.
409425

source/store/storeEntry.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ StoreEntry::StoreEntry(const std::unique_ptr<Store> &store, const std::unique_pt
4444
this->Console = StringUtils::FetchStringsFromVector(store->GetConsoleEntry(index));
4545
this->LastUpdated = store->GetLastUpdatedEntry(index);
4646
this->License = store->GetLicenseEntry(index);
47+
this->Wiki = store->GetWikiEntry(index);
4748
this->MarkString = StringUtils::GetMarkString(meta->GetMarks(store->GetUniStoreTitle(), this->Title));
4849

4950
this->Icon = store->GetIconEntry(index);

0 commit comments

Comments
 (0)