Minor cleanup with GOLD define - only use it in System_GetPropertyInt

This commit is contained in:
Henrik Rydgard 2017-04-05 16:21:08 +02:00
parent 3ae13f3c05
commit cf365bb257
15 changed files with 92 additions and 54 deletions

View File

@ -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;

View File

@ -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");

View File

@ -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");

View File

@ -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();

View File

@ -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;
}

View File

@ -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());
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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) {}

View File

@ -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;
}

View File

@ -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