Skip to content

Commit b4384ce

Browse files
authored
Merge pull request #19425 from hrydgard/store-update
Homebrew Store: Minor update adding license and website links
2 parents 5fd8fae + 9138272 commit b4384ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+179
-48
lines changed

Common/StringUtils.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,14 @@ std::string IndentString(const std::string &str, const std::string &sep, bool sk
171171
return output.str();
172172
}
173173

174+
std::string_view StripPrefix(std::string_view prefix, std::string_view s) {
175+
if (startsWith(s, prefix)) {
176+
return s.substr(prefix.size(), s.size() - prefix.size());
177+
} else {
178+
return s;
179+
}
180+
}
181+
174182
void SkipSpace(const char **ptr) {
175183
while (**ptr && isspace(**ptr)) {
176184
(*ptr)++;

Common/StringUtils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ std::string StripQuotes(const std::string &s);
8181
std::string_view StripSpaces(std::string_view s);
8282
std::string_view StripQuotes(std::string_view s);
8383

84+
std::string_view StripPrefix(std::string_view prefix, std::string_view s);
85+
8486
// NOTE: str must live at least as long as all uses of output.
8587
void SplitString(std::string_view str, const char delim, std::vector<std::string_view> &output);
8688
// Try to avoid this when possible, in favor of the string_view version.

Tools/langtool/Cargo.lock

Lines changed: 44 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UI/Store.cpp

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,6 @@ void HttpImageFileView::Draw(UIContext &dc) {
233233
}
234234
}
235235

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

334332
float size = entry_.size / (1024.f * 1024.f);
335333
Add(new TextView(StringFromFormat("%s: %.2f %s", st->T_cstr("Size"), size, st->T_cstr("MB"))));
334+
335+
if (!entry_.license.empty()) {
336+
LinearLayout *horiz = Add(new LinearLayout(ORIENT_HORIZONTAL));
337+
horiz->Add(new TextView(StringFromFormat("%s: %s", st->T_cstr("License"), entry_.license.c_str())));
338+
horiz->Add(new Button(st->T("Details")))->OnClick.Add([this](UI::EventParams) {
339+
std::string url = StringFromFormat("https://www.ppsspp.org/docs/reference/homebrew-store-distribution/#%s", entry_.file.c_str());
340+
System_LaunchUrl(LaunchUrlType::BROWSER_URL, url.c_str());
341+
return UI::EVENT_DONE;
342+
});
343+
}
344+
if (!entry_.websiteURL.empty()) {
345+
// Display in a few different ways depending on the URL
346+
size_t slashes = std::count(entry_.websiteURL.begin(), entry_.websiteURL.end(), '/');
347+
std::string buttonText;
348+
if (slashes == 2) {
349+
// Just strip https and show the URL.
350+
std::string_view name = StripPrefix("https://", entry_.websiteURL);
351+
name = StripPrefix("http://", name);
352+
if (name.size() < entry_.websiteURL.size()) {
353+
buttonText = name;
354+
}
355+
}
356+
if (buttonText.empty()) {
357+
// Fall back
358+
buttonText = st->T("Website");
359+
}
360+
Add(new Button(buttonText))->OnClick.Add([this](UI::EventParams) {
361+
System_LaunchUrl(LaunchUrlType::BROWSER_URL, entry_.websiteURL.c_str());
362+
return UI::EVENT_DONE;
363+
});
364+
}
336365
}
337366

338367
void ProductView::Update() {
@@ -460,11 +489,13 @@ void StoreScreen::ParseListing(const std::string &json) {
460489
e.type = ENTRY_PBPZIP;
461490
e.name = GetTranslatedString(game, "name");
462491
e.description = GetTranslatedString(game, "description", "");
463-
e.author = game.getStringOr("author", "?");
492+
e.author = ReplaceAll(game.getStringOr("author", "?"), "&&", "&"); // Can't remove && in the JSON source data due to old app versions
464493
e.size = game.getInt("size");
465494
e.downloadURL = game.getStringOr("download-url", "");
466495
e.iconURL = game.getStringOr("icon-url", "");
467496
e.contentRating = game.getInt("content-rating", 0);
497+
e.websiteURL = game.getStringOr("website-url", "");
498+
e.license = game.getStringOr("license", "");
468499
#if PPSSPP_PLATFORM(IOS_APP_STORE)
469500
if (e.contentRating >= 100) {
470501
continue;

UI/Store.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ struct StoreEntry {
5050
std::string description;
5151
std::string author;
5252
std::string iconURL;
53-
std::string file; // This is the folder name of the installed one too, and hence a "unique-ish" identifier.
53+
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().
5454
std::string category;
5555
std::string downloadURL; // Only set for games that are not hosted on store.ppsspp.org
56+
std::string websiteURL;
57+
std::string license;
5658
bool hidden;
5759
int contentRating; // 100 means to hide it on iOS. No other values defined yet.
5860
u64 size;

assets/lang/ar_AE.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,13 +1180,15 @@ Search term = Search term
11801180

11811181
[Store]
11821182
Connection Error = ‎خطأ في الإتصال
1183+
Details = Details
11831184
Install = ‎تثبيت
11841185
Installed = ‎مثبتة بالفعل
11851186
Launch Game = ‎إبدء اللعبة
11861187
Loading... = ‎تحميل...
11871188
MB = ‎ميجا
11881189
Size = ‎الحجم
11891190
Uninstall = ‎إلغاء التثبيت
1191+
Website = Website
11901192

11911193
[SysInfo]
11921194
%0.2f Hz = %0.2f Hz

assets/lang/az_AZ.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,13 +1172,15 @@ Search term = Search term
11721172

11731173
[Store]
11741174
Connection Error = Connection error
1175+
Details = Details
11751176
Install = Install
11761177
Installed = Installed
11771178
Launch Game = Launch game
11781179
Loading... = Loading...
11791180
MB = MB
11801181
Size = Size
11811182
Uninstall = Uninstall
1183+
Website = Website
11821184

11831185
[SysInfo]
11841186
%0.2f Hz = %0.2f Hz

assets/lang/bg_BG.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,13 +1172,15 @@ Search term = Search term
11721172

11731173
[Store]
11741174
Connection Error = Грешка при свързването
1175+
Details = Details
11751176
Install = Инсталирай
11761177
Installed = Вече е инсталирано
11771178
Launch Game = Launch game
11781179
Loading... = Зареждане...
11791180
MB = MB
11801181
Size = Големина
11811182
Uninstall = Деинсталирай
1183+
Website = Website
11821184

11831185
[SysInfo]
11841186
%0.2f Hz = %0.2f Hz

assets/lang/ca_ES.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,13 +1172,15 @@ Search term = Search term
11721172
11731173
[Store]
11741174
Connection Error = Error de connexió
1175+
Details = Details
11751176
Install = Instal·lar
11761177
Installed = Ja instal·lat
11771178
Launch Game = Iniciar joc
11781179
Loading... = Carregant...
11791180
MB = MB
11801181
Size = Mida
11811182
Uninstall = Desinstal·lar
1183+
Website = Website
11821184
11831185
[SysInfo]
11841186
%0.2f Hz = %0.2f Hz

0 commit comments

Comments
 (0)