mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-10-07 19:03:29 +00:00
System: Use a separate API for bool props.
This simplifies defaulting, instead of -1 being "true".
This commit is contained in:
parent
ee68f09be5
commit
3b4103cb3b
@ -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", ""));
|
||||
}
|
||||
|
||||
|
@ -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", "");
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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()) {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,4 +186,4 @@ enum SystemProperty {
|
||||
|
||||
std::string System_GetProperty(SystemProperty prop);
|
||||
int System_GetPropertyInt(SystemProperty prop);
|
||||
|
||||
bool System_GetPropertyBool(SystemProperty prop);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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) {}
|
||||
|
23
ios/main.mm
23
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];
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user