Skip to content

Commit

Permalink
Merge pull request #19425 from hrydgard/store-update
Browse files Browse the repository at this point in the history
Homebrew Store: Minor update adding license and website links
  • Loading branch information
hrydgard authored Sep 2, 2024
2 parents 5fd8fae + 9138272 commit b4384ce
Show file tree
Hide file tree
Showing 49 changed files with 179 additions and 48 deletions.
8 changes: 8 additions & 0 deletions Common/StringUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ std::string IndentString(const std::string &str, const std::string &sep, bool sk
return output.str();
}

std::string_view StripPrefix(std::string_view prefix, std::string_view s) {
if (startsWith(s, prefix)) {
return s.substr(prefix.size(), s.size() - prefix.size());
} else {
return s;
}
}

void SkipSpace(const char **ptr) {
while (**ptr && isspace(**ptr)) {
(*ptr)++;
Expand Down
2 changes: 2 additions & 0 deletions Common/StringUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ std::string StripQuotes(const std::string &s);
std::string_view StripSpaces(std::string_view s);
std::string_view StripQuotes(std::string_view s);

std::string_view StripPrefix(std::string_view prefix, std::string_view s);

// NOTE: str must live at least as long as all uses of output.
void SplitString(std::string_view str, const char delim, std::vector<std::string_view> &output);
// Try to avoid this when possible, in favor of the string_view version.
Expand Down
88 changes: 44 additions & 44 deletions Tools/langtool/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 34 additions & 3 deletions UI/Store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ void HttpImageFileView::Draw(UIContext &dc) {
}
}



// This is the entry in a list. Does not have install buttons and so on.
class ProductItemView : public UI::StickyChoice {
public:
Expand Down Expand Up @@ -333,6 +331,37 @@ void ProductView::CreateViews() {

float size = entry_.size / (1024.f * 1024.f);
Add(new TextView(StringFromFormat("%s: %.2f %s", st->T_cstr("Size"), size, st->T_cstr("MB"))));

if (!entry_.license.empty()) {
LinearLayout *horiz = Add(new LinearLayout(ORIENT_HORIZONTAL));
horiz->Add(new TextView(StringFromFormat("%s: %s", st->T_cstr("License"), entry_.license.c_str())));
horiz->Add(new Button(st->T("Details")))->OnClick.Add([this](UI::EventParams) {
std::string url = StringFromFormat("https://www.ppsspp.org/docs/reference/homebrew-store-distribution/#%s", entry_.file.c_str());
System_LaunchUrl(LaunchUrlType::BROWSER_URL, url.c_str());
return UI::EVENT_DONE;
});
}
if (!entry_.websiteURL.empty()) {
// Display in a few different ways depending on the URL
size_t slashes = std::count(entry_.websiteURL.begin(), entry_.websiteURL.end(), '/');
std::string buttonText;
if (slashes == 2) {
// Just strip https and show the URL.
std::string_view name = StripPrefix("https://", entry_.websiteURL);
name = StripPrefix("http://", name);
if (name.size() < entry_.websiteURL.size()) {
buttonText = name;
}
}
if (buttonText.empty()) {
// Fall back
buttonText = st->T("Website");
}
Add(new Button(buttonText))->OnClick.Add([this](UI::EventParams) {
System_LaunchUrl(LaunchUrlType::BROWSER_URL, entry_.websiteURL.c_str());
return UI::EVENT_DONE;
});
}
}

void ProductView::Update() {
Expand Down Expand Up @@ -460,11 +489,13 @@ void StoreScreen::ParseListing(const std::string &json) {
e.type = ENTRY_PBPZIP;
e.name = GetTranslatedString(game, "name");
e.description = GetTranslatedString(game, "description", "");
e.author = game.getStringOr("author", "?");
e.author = ReplaceAll(game.getStringOr("author", "?"), "&&", "&"); // Can't remove && in the JSON source data due to old app versions
e.size = game.getInt("size");
e.downloadURL = game.getStringOr("download-url", "");
e.iconURL = game.getStringOr("icon-url", "");
e.contentRating = game.getInt("content-rating", 0);
e.websiteURL = game.getStringOr("website-url", "");
e.license = game.getStringOr("license", "");
#if PPSSPP_PLATFORM(IOS_APP_STORE)
if (e.contentRating >= 100) {
continue;
Expand Down
4 changes: 3 additions & 1 deletion UI/Store.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ struct StoreEntry {
std::string description;
std::string author;
std::string iconURL;
std::string file; // This is the folder name of the installed one too, and hence a "unique-ish" identifier.
std::string file; // This is the folder name of the installed one too, and hence a "unique-ish" identifier. Also used as a-link on the license website, if !license.empty().
std::string category;
std::string downloadURL; // Only set for games that are not hosted on store.ppsspp.org
std::string websiteURL;
std::string license;
bool hidden;
int contentRating; // 100 means to hide it on iOS. No other values defined yet.
u64 size;
Expand Down
2 changes: 2 additions & 0 deletions assets/lang/ar_AE.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1180,13 +1180,15 @@ Search term = Search term

[Store]
Connection Error = ‎خطأ في الإتصال
Details = Details
Install = ‎تثبيت
Installed = ‎مثبتة بالفعل
Launch Game = ‎إبدء اللعبة
Loading... = ‎تحميل...
MB = ‎ميجا
Size = ‎الحجم
Uninstall = ‎إلغاء التثبيت
Website = Website

[SysInfo]
%0.2f Hz = %0.2f Hz
Expand Down
2 changes: 2 additions & 0 deletions assets/lang/az_AZ.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1172,13 +1172,15 @@ Search term = Search term

[Store]
Connection Error = Connection error
Details = Details
Install = Install
Installed = Installed
Launch Game = Launch game
Loading... = Loading...
MB = MB
Size = Size
Uninstall = Uninstall
Website = Website

[SysInfo]
%0.2f Hz = %0.2f Hz
Expand Down
2 changes: 2 additions & 0 deletions assets/lang/bg_BG.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1172,13 +1172,15 @@ Search term = Search term

[Store]
Connection Error = Грешка при свързването
Details = Details
Install = Инсталирай
Installed = Вече е инсталирано
Launch Game = Launch game
Loading... = Зареждане...
MB = MB
Size = Големина
Uninstall = Деинсталирай
Website = Website

[SysInfo]
%0.2f Hz = %0.2f Hz
Expand Down
2 changes: 2 additions & 0 deletions assets/lang/ca_ES.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1172,13 +1172,15 @@ Search term = Search term
[Store]
Connection Error = Error de connexió
Details = Details
Install = Instal·lar
Installed = Ja instal·lat
Launch Game = Iniciar joc
Loading... = Carregant...
MB = MB
Size = Mida
Uninstall = Desinstal·lar
Website = Website
[SysInfo]
%0.2f Hz = %0.2f Hz
Expand Down
Loading

0 comments on commit b4384ce

Please sign in to comment.