Share the "launch buy gold" code between MainScreen and CreditsScreen

This commit is contained in:
Henrik Rydgård committed 2025-05-19 18:38:19 +02:00
1 parent 44d279ec6f
commit 056c4024f2
4 files changed
+9 -15

No files matched your search

+7 -4
View File
@@ -1090,7 +1090,7 @@ void MainScreen::CreateViews() {
// Scrolling action menu to the right.
using namespace UI;
bool vertical = UseVerticalLayout();
const bool vertical = UseVerticalLayout();
auto mm = GetI18NCategory(I18NCat::MAINMENU);
@@ -1309,7 +1309,11 @@ void MainScreen::CreateViews() {
rightColumnChoices->Add(new Choice(mm->T("www.ppsspp.org")))->OnClick.Handle(this, &MainScreen::OnPPSSPPOrg);
if (!System_GetPropertyBool(SYSPROP_APP_GOLD) && (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) != DEVICE_TYPE_VR)) {
Choice *gold = rightColumnChoices->Add(new Choice(mm->T("Buy PPSSPP Gold")));
gold->OnClick.Handle(this, &MainScreen::OnSupport);
ScreenManager *sm = screenManager();
gold->OnClick.Add([sm](UI::EventParams &) {
LaunchBuyGold(sm);
return UI::EVENT_DONE;
});
gold->SetIcon(ImageID("I_ICONGOLD"), 0.5f);
}
}
@@ -1575,7 +1579,7 @@ UI::EventReturn MainScreen::OnCredits(UI::EventParams &e) {
return UI::EVENT_DONE;
}
UI::EventReturn MainScreen::OnSupport(UI::EventParams &e) {
void LaunchBuyGold(ScreenManager *screenManager) {
#if PPSSPP_PLATFORM(IOS_APP_STORE)
System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://apps.apple.com/us/app/ppsspp-gold-psp-emulator/id6502287918");
#elif PPSSPP_PLATFORM(ANDROID)
@@ -1583,7 +1587,6 @@ UI::EventReturn MainScreen::OnSupport(UI::EventParams &e) {
#else
System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://www.ppsspp.org/buygold");
#endif
return UI::EVENT_DONE;
}
UI::EventReturn MainScreen::OnPPSSPPOrg(UI::EventParams &e) {
+2 -1
View File
@@ -146,7 +146,6 @@ protected:
UI::EventReturn OnLoadFile(UI::EventParams &e);
UI::EventReturn OnGameSettings(UI::EventParams &e);
UI::EventReturn OnCredits(UI::EventParams &e);
UI::EventReturn OnSupport(UI::EventParams &e);
UI::EventReturn OnPPSSPPOrg(UI::EventParams &e);
UI::EventReturn OnForums(UI::EventParams &e);
UI::EventReturn OnExit(UI::EventParams &e);
@@ -206,3 +205,5 @@ private:
const float MAX_GAME_GRID_SCALE = 3.0f;
const float MIN_GAME_GRID_SCALE = 0.8f;
};
void LaunchBuyGold(ScreenManager *screenManager);
-9
View File
@@ -943,15 +943,6 @@ void CreditsScreen::CreateViews() {
}
}
UI::EventReturn CreditsScreen::OnSupport(UI::EventParams &e) {
#ifdef __ANDROID__
System_LaunchUrl(LaunchUrlType::BROWSER_URL, "market://details?id=org.ppsspp.ppssppgold");
#else
System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://www.ppsspp.org/buygold");
#endif
return UI::EVENT_DONE;
}
UI::EventReturn CreditsScreen::OnX(UI::EventParams &e) {
// Not sure we should change to x.com here, given various platform URL handlers etc. We can probably change it soon.
System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://twitter.com/PPSSPP_emu");
-1
View File
@@ -167,7 +167,6 @@ public:
const char *tag() const override { return "Credits"; }
private:
UI::EventReturn OnSupport(UI::EventParams &e);
UI::EventReturn OnPPSSPPOrg(UI::EventParams &e);
UI::EventReturn OnPrivacy(UI::EventParams &e);
UI::EventReturn OnForums(UI::EventParams &e);