diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index 3c7da7130f..a90975cfa5 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -464,7 +464,7 @@ void SystemInfoScreen::CreateViews() { #ifdef MOBILE_DEVICE buildConfig->Add(new InfoItem("MOBILE_DEVICE", "")); #endif - if (System_GetPropertyInt(SYSPROP_APP_GOLD)) { + if (System_GetPropertyBool(SYSPROP_APP_GOLD)) { buildConfig->Add(new InfoItem("GOLD", "")); } diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 44f7d35939..f1193ddc26 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -524,7 +524,7 @@ void GameSettingsScreen::CreateViews() { // On non iOS systems, offer to let the user see this button. // Some Windows touch devices don't have a back button or other button to call up the menu. - if (System_GetPropertyInt(SYSPROP_HAS_BACK_BUTTON)) { + if (System_GetPropertyBool(SYSPROP_HAS_BACK_BUTTON)) { CheckBox *enablePauseBtn = controlsSettings->Add(new CheckBox(&g_Config.bShowTouchPause, co->T("Show Touch Pause Menu Button"))); // Don't allow the user to disable it once in-game, so they can't lock themselves out of the menu. @@ -684,7 +684,7 @@ void GameSettingsScreen::CreateViews() { const std::string bgJpg = GetSysDirectory(DIRECTORY_SYSTEM) + "background.jpg"; if (File::Exists(bgPng) || File::Exists(bgJpg)) { backgroundChoice_ = systemSettings->Add(new Choice(sy->T("Clear UI background"))); - } else if (System_GetPropertyInt(SYSPROP_HAS_IMAGE_BROWSER)) { + } else if (System_GetPropertyBool(SYSPROP_HAS_IMAGE_BROWSER)) { backgroundChoice_ = systemSettings->Add(new Choice(sy->T("Set UI background..."))); } else { backgroundChoice_ = nullptr; @@ -947,7 +947,7 @@ UI::EventReturn GameSettingsScreen::OnChangeBackground(UI::EventParams &e) { NativeMessageReceived("bgImage_updated", ""); } else { - if (System_GetPropertyInt(SYSPROP_HAS_IMAGE_BROWSER)) { + if (System_GetPropertyBool(SYSPROP_HAS_IMAGE_BROWSER)) { System_SendMessage("bgImage_browse", ""); } } diff --git a/UI/GamepadEmu.cpp b/UI/GamepadEmu.cpp index f82c1aee2e..42edfa2979 100644 --- a/UI/GamepadEmu.cpp +++ b/UI/GamepadEmu.cpp @@ -628,7 +628,7 @@ UI::ViewGroup *CreatePadLayout(float xres, float yres, bool *pause) { const int stickBg = g_Config.iTouchButtonStyle ? I_STICK_BG_LINE : I_STICK_BG; static const int comboKeyImages[5] = { I_1, I_2, I_3, I_4, I_5 }; - if (!System_GetPropertyInt(SYSPROP_HAS_BACK_BUTTON) || g_Config.bShowTouchPause) { + if (!System_GetPropertyBool(SYSPROP_HAS_BACK_BUTTON) || g_Config.bShowTouchPause) { root->Add(new BoolButton(pause, roundImage, I_ARROW, 1.0f, new AnchorLayoutParams(halfW, 20, NONE, NONE, true)))->SetAngle(90); } diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 259ad59c6e..45b7d04e30 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -837,7 +837,7 @@ void MainScreen::CreateViews() { sprintf(versionString, "%s", PPSSPP_GIT_VERSION); rightColumnItems->SetSpacing(0.0f); LinearLayout *logos = new LinearLayout(ORIENT_HORIZONTAL); - if (System_GetPropertyInt(SYSPROP_APP_GOLD)) { + if (System_GetPropertyBool(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))); @@ -853,7 +853,7 @@ 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); - if (!System_GetPropertyInt(SYSPROP_APP_GOLD)) { + if (!System_GetPropertyBool(SYSPROP_APP_GOLD)) { Choice *gold = rightColumnItems->Add(new Choice(mm->T("Support PPSSPP"))); gold->OnClick.Handle(this, &MainScreen::OnSupport); gold->SetIcon(I_ICONGOLD); @@ -912,7 +912,7 @@ UI::EventReturn MainScreen::OnAllowStorage(UI::EventParams &e) { UI::EventReturn MainScreen::OnDownloadUpgrade(UI::EventParams &e) { #if PPSSPP_PLATFORM(ANDROID) // Go to app store - if (System_GetPropertyInt(SYSPROP_APP_GOLD)) { + if (System_GetPropertyBool(SYSPROP_APP_GOLD)) { LaunchBrowser("market://details?id=org.ppsspp.ppssppgold"); } else { LaunchBrowser("market://details?id=org.ppsspp.ppsspp"); @@ -979,7 +979,7 @@ UI::EventReturn MainScreen::OnLoadFile(UI::EventParams &e) { } #endif - if (System_GetPropertyInt(SYSPROP_HAS_FILE_BROWSER)) { + if (System_GetPropertyBool(SYSPROP_HAS_FILE_BROWSER)) { System_SendMessage("browse_file", ""); } return UI::EVENT_DONE; diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index 106edd12d6..4496af8066 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -495,7 +495,7 @@ void LogoScreen::render() { char temp[256]; // 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); - if (System_GetPropertyInt(SYSPROP_APP_GOLD)) { + if (System_GetPropertyBool(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); @@ -538,7 +538,7 @@ 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 - if (System_GetPropertyInt(SYSPROP_APP_GOLD)) { + if (System_GetPropertyBool(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))); @@ -701,7 +701,7 @@ void CreditsScreen::render() { // TODO: This is kinda ugly, done on every frame... char temp[256]; - if (System_GetPropertyInt(SYSPROP_APP_GOLD)) { + if (System_GetPropertyBool(SYSPROP_APP_GOLD)) { snprintf(temp, sizeof(temp), "PPSSPP Gold %s", PPSSPP_GIT_VERSION); } else { snprintf(temp, sizeof(temp), "PPSSPP %s", PPSSPP_GIT_VERSION); diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index dba15ce5ce..811b8e0ca4 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -1327,7 +1327,7 @@ namespace MainWindow { { W32Util::CenterWindow(hDlg); HWND versionBox = GetDlgItem(hDlg, IDC_VERSION); - std::string windowText = System_GetPropertyInt(SYSPROP_APP_GOLD) ? "PPSSPP Gold " : "PPSSPP "; + std::string windowText = System_GetPropertyBool(SYSPROP_APP_GOLD) ? "PPSSPP Gold " : "PPSSPP "; windowText.append(PPSSPP_GIT_VERSION); SetWindowText(versionBox, ConvertUTF8ToWString(windowText).c_str()); } diff --git a/Windows/main.cpp b/Windows/main.cpp index 84226ef0f7..7107317bcd 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -212,23 +212,30 @@ int System_GetPropertyInt(SystemProperty prop) { return DEVICE_TYPE_DESKTOP; case SYSPROP_DISPLAY_DPI: return ScreenDPI(); - case SYSPROP_HAS_FILE_BROWSER: - return 1; - case SYSPROP_HAS_IMAGE_BROWSER: - return 1; - case SYSPROP_HAS_BACK_BUTTON: - return 1; - case SYSPROP_APP_GOLD: -#ifdef GOLD - return 1; -#else - return 0; -#endif default: return -1; } } +bool System_GetPropertyBool(SystemProperty prop) { + switch (prop) { + case SYSPROP_HAS_FILE_BROWSER: + return true; + case SYSPROP_HAS_IMAGE_BROWSER: + return true; + case SYSPROP_HAS_BACK_BUTTON: + return true; + case SYSPROP_APP_GOLD: +#ifdef GOLD + return true; +#else + return false; +#endif + default: + return false; + } +} + void System_SendMessage(const char *command, const char *parameter) { if (!strcmp(command, "finish")) { if (!NativeIsRestarting()) { diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index f641647e51..3e5d53c41a 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -444,18 +444,27 @@ int System_GetPropertyInt(SystemProperty prop) { return optimalFramesPerBuffer; case SYSPROP_DISPLAY_REFRESH_RATE: return (int)(display_hz * 1000.0); + default: + return -1; + } +} + +bool System_GetPropertyBool(SystemProperty prop) { + switch (prop) { case SYSPROP_SUPPORTS_PERMISSIONS: return androidVersion >= 23; // 6.0 Marshmallow introduced run time permissions. case SYSPROP_HAS_BACK_BUTTON: - return 1; + return true; + case SYSPROP_HAS_IMAGE_BROWSER: + return true; case SYSPROP_APP_GOLD: #ifdef GOLD - return 1; + return true; #else - return 0; + return false; #endif default: - return -1; + return false; } } diff --git a/ext/native/base/NativeApp.h b/ext/native/base/NativeApp.h index 3cea3a4c8d..86994b19de 100644 --- a/ext/native/base/NativeApp.h +++ b/ext/native/base/NativeApp.h @@ -186,4 +186,4 @@ enum SystemProperty { std::string System_GetProperty(SystemProperty prop); int System_GetPropertyInt(SystemProperty prop); - +bool System_GetPropertyBool(SystemProperty prop); diff --git a/ext/native/base/PCMain.cpp b/ext/native/base/PCMain.cpp index 13f51ceecf..f4081e88a6 100644 --- a/ext/native/base/PCMain.cpp +++ b/ext/native/base/PCMain.cpp @@ -338,20 +338,27 @@ int System_GetPropertyInt(SystemProperty prop) { return DEVICE_TYPE_MOBILE; #else return DEVICE_TYPE_DESKTOP; -#endif - case SYSPROP_HAS_BACK_BUTTON: - return 1; - case SYSPROP_APP_GOLD: -#ifdef GOLD - return 1; -#else - return 0; #endif default: return -1; } } +bool System_GetPropertyBool(SystemProperty prop) { + switch (prop) { + case SYSPROP_HAS_BACK_BUTTON: + return true; + case SYSPROP_APP_GOLD: +#ifdef GOLD + return true; +#else + return false; +#endif + default: + return false; + } +} + extern void mixaudio(void *userdata, Uint8 *stream, int len) { NativeMix((short *)stream, len / 4); } diff --git a/ext/native/base/QtMain.cpp b/ext/native/base/QtMain.cpp index 8f1a4cd4dc..586c973965 100644 --- a/ext/native/base/QtMain.cpp +++ b/ext/native/base/QtMain.cpp @@ -60,9 +60,9 @@ std::string System_GetProperty(SystemProperty prop) { } int System_GetPropertyInt(SystemProperty prop) { - switch (prop) { - case SYSPROP_AUDIO_SAMPLE_RATE: - return 44100; + switch (prop) { + case SYSPROP_AUDIO_SAMPLE_RATE: + return 44100; case SYSPROP_DISPLAY_REFRESH_RATE: return 60000; case SYSPROP_DEVICE_TYPE: @@ -77,17 +77,24 @@ int System_GetPropertyInt(SystemProperty prop) { #else return DEVICE_TYPE_DESKTOP; #endif + default: + return -1; + } +} + +bool System_GetPropertyBool(SystemProperty prop) { + switch (prop) { case SYSPROP_HAS_BACK_BUTTON: - return 1; + return true; case SYSPROP_APP_GOLD: #ifdef GOLD - return 1; + return true; #else - return 0; + return false; #endif default: - return -1; - } + return false; + } } void System_SendMessage(const char *command, const char *parameter) { diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 53a29ef666..6f59f23ad6 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -68,12 +68,11 @@ void NativeResized() { } std::string System_GetProperty(SystemProperty prop) { return ""; } int System_GetPropertyInt(SystemProperty prop) { - switch (prop) { - case SYSPROP_APP_GOLD: - return 0; - } return -1; } +bool System_GetPropertyBool(SystemProperty prop) { + return false; +} 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 5a9919f689..052b3773b4 100644 --- a/ios/main.mm +++ b/ios/main.mm @@ -66,19 +66,26 @@ int System_GetPropertyInt(SystemProperty prop) { return 60000; case SYSPROP_DEVICE_TYPE: 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; } } +bool System_GetPropertyBool(SystemProperty prop) { + switch (prop) { + case SYSPROP_HAS_BACK_BUTTON: + return false; + case SYSPROP_APP_GOLD: +#ifdef GOLD + return true; +#else + return false; +#endif + default: + return false; + } +} + void System_SendMessage(const char *command, const char *parameter) { if (!strcmp(command, "finish")) { [[UIApplication sharedApplication] animatedExit]; diff --git a/unittest/UnitTest.cpp b/unittest/UnitTest.cpp index 1ff2d516d9..13f9120f3c 100644 --- a/unittest/UnitTest.cpp +++ b/unittest/UnitTest.cpp @@ -50,12 +50,11 @@ std::string System_GetProperty(SystemProperty prop) { return ""; } int System_GetPropertyInt(SystemProperty prop) { - switch (prop) { - case SYSPROP_APP_GOLD: - return 0; - } return -1; } +bool System_GetPropertyBool(SystemProperty prop) { + return false; +} #ifndef M_PI_2 #define M_PI_2 1.57079632679489661923