From cf365bb257581a59c7cc56f693aac149707b429f Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Wed, 5 Apr 2017 16:21:08 +0200 Subject: [PATCH] Minor cleanup with GOLD define - only use it in System_GetPropertyInt --- Core/System.cpp | 14 ++++---------- UI/DevScreens.cpp | 6 +++--- UI/MainScreen.cpp | 32 ++++++++++++++++---------------- UI/MiscScreens.cpp | 32 ++++++++++++++++---------------- UWP/PPSSPP_UWPMain.cpp | 6 ++++++ Windows/MainWindowMenu.cpp | 6 +----- Windows/TouchInputHandler.cpp | 1 - Windows/main.cpp | 6 ++++++ android/jni/app-android.cpp | 6 ++++++ ext/native/base/NativeApp.h | 1 + ext/native/base/PCMain.cpp | 6 ++++++ ext/native/base/QtMain.cpp | 8 +++++++- headless/Headless.cpp | 8 +++++++- ios/main.mm | 6 ++++++ unittest/UnitTest.cpp | 8 +++++++- 15 files changed, 92 insertions(+), 54 deletions(-) diff --git a/Core/System.cpp b/Core/System.cpp index ee02549713..715a13312c 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -388,28 +388,22 @@ void System_Wake() { } } +// Ugly! static bool pspIsInited = false; static bool pspIsIniting = false; static bool pspIsQuiting = false; -// Ugly! bool PSP_InitStart(const CoreParameter &coreParam, std::string *error_string) { if (pspIsIniting || pspIsQuiting) { return false; } -#ifdef GOLD - const char *gold = " Gold"; -#else - const char *gold = ""; -#endif - #if defined(_WIN32) && defined(_M_X64) - INFO_LOG(BOOT, "PPSSPP%s %s Windows 64 bit", gold, PPSSPP_GIT_VERSION); + INFO_LOG(BOOT, "PPSSPP %s Windows 64 bit", PPSSPP_GIT_VERSION); #elif defined(_WIN32) && !defined(_M_X64) - INFO_LOG(BOOT, "PPSSPP%s %s Windows 32 bit", gold, PPSSPP_GIT_VERSION); + INFO_LOG(BOOT, "PPSSPP %s Windows 32 bit", PPSSPP_GIT_VERSION); #else - INFO_LOG(BOOT, "PPSSPP%s %s", gold, PPSSPP_GIT_VERSION); + INFO_LOG(BOOT, "PPSSPP %s", PPSSPP_GIT_VERSION); #endif GraphicsContext *temp = coreParameter.graphicsContext; diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index b822256ceb..3c7da7130f 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -464,9 +464,9 @@ void SystemInfoScreen::CreateViews() { #ifdef MOBILE_DEVICE buildConfig->Add(new InfoItem("MOBILE_DEVICE", "")); #endif -#ifdef GOLD - buildConfig->Add(new InfoItem("GOLD", "")); -#endif + if (System_GetPropertyInt(SYSPROP_APP_GOLD)) { + buildConfig->Add(new InfoItem("GOLD", "")); + } ViewGroup *cpuExtensionsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); cpuExtensionsScroll->SetTag("DevSystemInfoCPUExt"); diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index eed5eeada3..85f20e5c41 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -837,11 +837,11 @@ void MainScreen::CreateViews() { sprintf(versionString, "%s", PPSSPP_GIT_VERSION); rightColumnItems->SetSpacing(0.0f); LinearLayout *logos = new LinearLayout(ORIENT_HORIZONTAL); -#ifdef GOLD - logos->Add(new ImageView(I_ICONGOLD, IS_DEFAULT, new AnchorLayoutParams(64, 64, 10, 10, NONE, NONE, false))); -#else - logos->Add(new ImageView(I_ICON, IS_DEFAULT, new AnchorLayoutParams(64, 64, 10, 10, NONE, NONE, false))); -#endif + if (System_GetPropertyInt(SYSPROP_APP_GOLD)) { + logos->Add(new ImageView(I_ICONGOLD, IS_DEFAULT, new AnchorLayoutParams(64, 64, 10, 10, NONE, NONE, false))); + } else { + logos->Add(new ImageView(I_ICON, IS_DEFAULT, new AnchorLayoutParams(64, 64, 10, 10, NONE, NONE, false))); + } logos->Add(new ImageView(I_LOGO, IS_DEFAULT, new LinearLayoutParams(Margins(-12, 0, 0, 0)))); rightColumnItems->Add(logos); TextView *ver = rightColumnItems->Add(new TextView(versionString, new LinearLayoutParams(Margins(70, -6, 0, 0)))); @@ -853,11 +853,11 @@ void MainScreen::CreateViews() { rightColumnItems->Add(new Choice(mm->T("Game Settings", "Settings")))->OnClick.Handle(this, &MainScreen::OnGameSettings); rightColumnItems->Add(new Choice(mm->T("Credits")))->OnClick.Handle(this, &MainScreen::OnCredits); rightColumnItems->Add(new Choice(mm->T("www.ppsspp.org")))->OnClick.Handle(this, &MainScreen::OnPPSSPPOrg); -#ifndef GOLD - Choice *gold = rightColumnItems->Add(new Choice(mm->T("Support PPSSPP"))); - gold->OnClick.Handle(this, &MainScreen::OnSupport); - gold->SetIcon(I_ICONGOLD); -#endif + if (!System_GetPropertyInt(SYSPROP_APP_GOLD)) { + Choice *gold = rightColumnItems->Add(new Choice(mm->T("Support PPSSPP"))); + gold->OnClick.Handle(this, &MainScreen::OnSupport); + gold->SetIcon(I_ICONGOLD); + } #if !PPSSPP_PLATFORM(UWP) // Having an exit button is against UWP guidelines. @@ -910,13 +910,13 @@ UI::EventReturn MainScreen::OnAllowStorage(UI::EventParams &e) { } UI::EventReturn MainScreen::OnDownloadUpgrade(UI::EventParams &e) { -#ifdef __ANDROID__ +#if PPSSPP_PLATFORM(ANDROID) // Go to app store -#ifdef GOLD - LaunchBrowser("market://details?id=org.ppsspp.ppssppgold"); -#else - LaunchBrowser("market://details?id=org.ppsspp.ppsspp"); -#endif + if (System_GetPropertyInt(SYSPROP_APP_GOLD)) { + LaunchBrowser("market://details?id=org.ppsspp.ppssppgold"); + } else { + LaunchBrowser("market://details?id=org.ppsspp.ppsspp"); + } #else // Go directly to ppsspp.org and let the user sort it out LaunchBrowser("http://www.ppsspp.org/downloads.html"); diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index a823c6a20d..106edd12d6 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -493,13 +493,13 @@ void LogoScreen::render() { I18NCategory *cr = GetI18NCategory("PSPCredits"); char temp[256]; - // Manually formatting utf-8 is fun. \xXX doesn't work everywhere. + // Manually formatting UTF-8 is fun. \xXX doesn't work everywhere. snprintf(temp, sizeof(temp), "%s Henrik Rydg%c%crd", cr->T("created", "Created by"), 0xC3, 0xA5); -#ifdef GOLD - dc.Draw()->DrawImage(I_ICONGOLD, bounds.centerX() - 120, bounds.centerY() - 30, 1.2f, textColor, ALIGN_CENTER); -#else - dc.Draw()->DrawImage(I_ICON, bounds.centerX() - 120, bounds.centerY() - 30, 1.2f, textColor, ALIGN_CENTER); -#endif + if (System_GetPropertyInt(SYSPROP_APP_GOLD)) { + dc.Draw()->DrawImage(I_ICONGOLD, bounds.centerX() - 120, bounds.centerY() - 30, 1.2f, textColor, ALIGN_CENTER); + } else { + dc.Draw()->DrawImage(I_ICON, bounds.centerX() - 120, bounds.centerY() - 30, 1.2f, textColor, ALIGN_CENTER); + } dc.Draw()->DrawImage(I_LOGO, bounds.centerX() + 40, bounds.centerY() - 30, 1.5f, textColor, ALIGN_CENTER); //dc.Draw()->DrawTextShadow(UBUNTU48, "PPSSPP", xres / 2, yres / 2 - 30, textColor, ALIGN_CENTER); dc.SetFontScale(1.0f, 1.0f); @@ -538,11 +538,11 @@ void CreditsScreen::CreateViews() { root_->Add(new Button(cr->T("Share PPSSPP"), new AnchorLayoutParams(260, 64, NONE, NONE, 10, 84, false)))->OnClick.Handle(this, &CreditsScreen::OnShare); root_->Add(new Button(cr->T("Twitter @PPSSPP_emu"), new AnchorLayoutParams(260, 64, NONE, NONE, 10, 154, false)))->OnClick.Handle(this, &CreditsScreen::OnTwitter); #endif -#ifdef GOLD - root_->Add(new ImageView(I_ICONGOLD, IS_DEFAULT, new AnchorLayoutParams(100, 64, 10, 10, NONE, NONE, false))); -#else - root_->Add(new ImageView(I_ICON, IS_DEFAULT, new AnchorLayoutParams(100, 64, 10, 10, NONE, NONE, false))); -#endif + if (System_GetPropertyInt(SYSPROP_APP_GOLD)) { + root_->Add(new ImageView(I_ICONGOLD, IS_DEFAULT, new AnchorLayoutParams(100, 64, 10, 10, NONE, NONE, false))); + } else { + root_->Add(new ImageView(I_ICON, IS_DEFAULT, new AnchorLayoutParams(100, 64, 10, 10, NONE, NONE, false))); + } } UI::EventReturn CreditsScreen::OnSupport(UI::EventParams &e) { @@ -701,11 +701,11 @@ void CreditsScreen::render() { // TODO: This is kinda ugly, done on every frame... char temp[256]; -#ifdef GOLD - snprintf(temp, sizeof(temp), "PPSSPP Gold %s", PPSSPP_GIT_VERSION); -#else - snprintf(temp, sizeof(temp), "PPSSPP %s", PPSSPP_GIT_VERSION); -#endif + if (System_GetPropertyInt(SYSPROP_APP_GOLD)) { + snprintf(temp, sizeof(temp), "PPSSPP Gold %s", PPSSPP_GIT_VERSION); + } else { + snprintf(temp, sizeof(temp), "PPSSPP %s", PPSSPP_GIT_VERSION); + } credits[0] = (const char *)temp; UIContext &dc = *screenManager()->getUIContext(); diff --git a/UWP/PPSSPP_UWPMain.cpp b/UWP/PPSSPP_UWPMain.cpp index a622b8af3d..255d8e1a6c 100644 --- a/UWP/PPSSPP_UWPMain.cpp +++ b/UWP/PPSSPP_UWPMain.cpp @@ -370,6 +370,12 @@ int System_GetPropertyInt(SystemProperty prop) { return 1; case SYSPROP_HAS_FILE_BROWSER: return 1; + case SYSPROP_APP_GOLD: +#ifdef GOLD + return 1; +#else + return 0; +#endif default: return -1; } diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index eca65c3d93..24e01e7b40 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -1331,11 +1331,7 @@ namespace MainWindow { { W32Util::CenterWindow(hDlg); HWND versionBox = GetDlgItem(hDlg, IDC_VERSION); -#ifdef GOLD - std::string windowText = "PPSSPP Gold "; -#else - std::string windowText = "PPSSPP "; -#endif + std::string windowText = System_GetPropertyInt(SYSPROP_APP_GOLD) ? "PPSSPP Gold " : "PPSSPP "; windowText.append(PPSSPP_GIT_VERSION); SetWindowText(versionBox, ConvertUTF8ToWString(windowText).c_str()); } diff --git a/Windows/TouchInputHandler.cpp b/Windows/TouchInputHandler.cpp index 2fd2af3588..766364987c 100644 --- a/Windows/TouchInputHandler.cpp +++ b/Windows/TouchInputHandler.cpp @@ -62,7 +62,6 @@ void TouchInputHandler::handleTouchEvent(HWND hWnd, UINT message, WPARAM wParam, POINT point; point.x = (float)(TOUCH_COORD_TO_PIXEL(inputs[i].x)); point.y = (float)(TOUCH_COORD_TO_PIXEL(inputs[i].y)); - if (ScreenToClient(hWnd, &point)) { point.x *= g_dpi_scale; point.y *= g_dpi_scale; diff --git a/Windows/main.cpp b/Windows/main.cpp index c84275e0a4..b7f6724828 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -218,6 +218,12 @@ int System_GetPropertyInt(SystemProperty prop) { return 1; case SYSPROP_HAS_BACK_BUTTON: return 1; + case SYSPROP_APP_GOLD: +#ifdef GOLD + return 1; +#else + return 0; +#endif default: return -1; } diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 8296b1acce..16831201fe 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -445,6 +445,12 @@ int System_GetPropertyInt(SystemProperty prop) { return androidVersion >= 23; // 6.0 Marshmallow introduced run time permissions. case SYSPROP_HAS_BACK_BUTTON: return 1; + case SYSPROP_APP_GOLD: +#ifdef GOLD + return 1; +#else + return 0; +#endif default: return -1; } diff --git a/ext/native/base/NativeApp.h b/ext/native/base/NativeApp.h index 1b1191a4a4..e598e31677 100644 --- a/ext/native/base/NativeApp.h +++ b/ext/native/base/NativeApp.h @@ -165,6 +165,7 @@ enum SystemProperty { SYSPROP_MOGA_VERSION, SYSPROP_DEVICE_TYPE, + SYSPROP_APP_GOLD, // To avoid having #ifdef GOLD other than in main.cpp and similar. // Exposed on Android. Choosing the optimal sample rate for audio // will result in lower latencies. Buffer size is automatically matched diff --git a/ext/native/base/PCMain.cpp b/ext/native/base/PCMain.cpp index ad856bf75b..13f51ceecf 100644 --- a/ext/native/base/PCMain.cpp +++ b/ext/native/base/PCMain.cpp @@ -341,6 +341,12 @@ int System_GetPropertyInt(SystemProperty prop) { #endif case SYSPROP_HAS_BACK_BUTTON: return 1; + case SYSPROP_APP_GOLD: +#ifdef GOLD + return 1; +#else + return 0; +#endif default: return -1; } diff --git a/ext/native/base/QtMain.cpp b/ext/native/base/QtMain.cpp index d59e18b251..73e09eef1a 100644 --- a/ext/native/base/QtMain.cpp +++ b/ext/native/base/QtMain.cpp @@ -79,7 +79,13 @@ int System_GetPropertyInt(SystemProperty prop) { #endif case SYSPROP_HAS_BACK_BUTTON: return 1; - default: + case SYSPROP_APP_GOLD: +#ifdef GOLD + return 1; +#else + return 0; +#endif + default: return -1; } } diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 888bcc735a..264973bea7 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -66,7 +66,13 @@ void NativeRender(GraphicsContext *graphicsContext) { } void NativeResized() { } std::string System_GetProperty(SystemProperty prop) { return ""; } -int System_GetPropertyInt(SystemProperty prop) { return -1; } +int System_GetPropertyInt(SystemProperty prop) { + switch (prop) { + case SYSPROP_APP_GOLD: + return 0; + } + return -1; +} void System_SendMessage(const char *command, const char *parameter) {} bool System_InputBoxGetWString(const wchar_t *title, const std::wstring &defaultvalue, std::wstring &outvalue) { return false; } void System_AskForPermission(SystemPermission permission) {} diff --git a/ios/main.mm b/ios/main.mm index 97a99d2d0b..5a9919f689 100644 --- a/ios/main.mm +++ b/ios/main.mm @@ -68,6 +68,12 @@ int System_GetPropertyInt(SystemProperty prop) { return DEVICE_TYPE_MOBILE; case SYSPROP_HAS_BACK_BUTTON: return 0; + case SYSPROP_APP_GOLD: +#ifdef GOLD + return 1; +#else + return 0; +#endif default: return -1; } diff --git a/unittest/UnitTest.cpp b/unittest/UnitTest.cpp index 715525a672..1ff2d516d9 100644 --- a/unittest/UnitTest.cpp +++ b/unittest/UnitTest.cpp @@ -49,7 +49,13 @@ #include "unittest/UnitTest.h" std::string System_GetProperty(SystemProperty prop) { return ""; } -int System_GetPropertyInt(SystemProperty prop) { return -1; } +int System_GetPropertyInt(SystemProperty prop) { + switch (prop) { + case SYSPROP_APP_GOLD: + return 0; + } + return -1; +} #ifndef M_PI_2 #define M_PI_2 1.57079632679489661923