From 6bd6b86c0514151509d04854a6cebf1f11f93b57 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 10 Nov 2018 07:39:27 -0800 Subject: [PATCH 1/3] Discord: Add cmake option to disable. --- CMakeLists.txt | 4 +++- UI/DiscordIntegration.cpp | 4 ++++ ext/CMakeLists.txt | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c15cba0d0..27f4b45720 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,6 +131,7 @@ option(SIMULATOR "Set to ON when targeting an x86 simulator of an ARM platform" option(LIBRETRO "Set to ON to generate the libretro target" OFF) # :: Options option(USE_FFMPEG "Build with FFMPEG support" ${USE_FFMPEG}) +option(USE_DISCORD "Build with Discord support" ON) option(USE_SYSTEM_SNAPPY "Dynamically link against system snappy" ${USE_SYSTEM_SNAPPY}) option(USE_SYSTEM_FFMPEG "Dynamically link against system FFMPEG" ${USE_SYSTEM_FFMPEG}) option(USE_SYSTEM_LIBZIP "Dynamically link against system libzip" ${USE_SYSTEM_LIBZIP}) @@ -1801,7 +1802,8 @@ if(FFmpeg_FOUND) endif() # Discord integration -if(NOT IOS) +if(USE_DISCORD AND NOT IOS) + add_definitions(-DUSE_DISCORD=1) target_link_libraries(${CoreLibName} discord-rpc) endif() diff --git a/UI/DiscordIntegration.cpp b/UI/DiscordIntegration.cpp index 54ee337e3f..b07adf518a 100644 --- a/UI/DiscordIntegration.cpp +++ b/UI/DiscordIntegration.cpp @@ -9,7 +9,11 @@ #if (PPSSPP_PLATFORM(WINDOWS) || PPSSPP_PLATFORM(MAC) || PPSSPP_PLATFORM(LINUX)) && !PPSSPP_PLATFORM(ANDROID) +#ifdef _MSC_VER #define ENABLE_DISCORD +#elif USE_DISCORD +#define ENABLE_DISCORD +#endif #else diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt index ade6594e8f..b259a6f059 100644 --- a/ext/CMakeLists.txt +++ b/ext/CMakeLists.txt @@ -2,7 +2,7 @@ set(ARMIPS_REGEXP OFF CACHE BOOL "" FORCE) add_subdirectory(armips) if(NOT USING_GLES2) - add_subdirectory(glew) + add_subdirectory(glew) endif() set(ENABLE_GLSLANG_BINARIES OFF CACHE BOOL "let's not build binaries we don't need" FORCE) @@ -12,6 +12,6 @@ add_subdirectory(glslang) add_subdirectory(snappy) add_subdirectory(udis86) add_subdirectory(SPIRV-Cross-build) -if(NOT IOS) -add_subdirectory(discord-rpc-build) +if(USE_DISCORD AND NOT IOS) + add_subdirectory(discord-rpc-build) endif() From c96748f0e222c126ea0796af0b0bda6dedfe52a6 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 10 Nov 2018 07:48:04 -0800 Subject: [PATCH 2/3] Discord: Attempt to explicitly cleanup on exit. --- UI/DiscordIntegration.cpp | 9 +++++++++ UI/DiscordIntegration.h | 1 + UI/EmuScreen.cpp | 6 +++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/UI/DiscordIntegration.cpp b/UI/DiscordIntegration.cpp index b07adf518a..34fc4d00b5 100644 --- a/UI/DiscordIntegration.cpp +++ b/UI/DiscordIntegration.cpp @@ -134,3 +134,12 @@ void Discord::SetPresenceMenu() { Discord_UpdatePresence(&discordPresence); #endif } + +void Discord::ClearPresence() { + if (!IsEnabled() || !initialized_) + return; + +#ifdef ENABLE_DISCORD + Discord_ClearPresence(); +#endif +} diff --git a/UI/DiscordIntegration.h b/UI/DiscordIntegration.h index cd700d59ea..a2911d6877 100644 --- a/UI/DiscordIntegration.h +++ b/UI/DiscordIntegration.h @@ -17,6 +17,7 @@ public: void SetPresenceGame(const char *gameTitle); void SetPresenceMenu(); + void ClearPresence(); private: void Init(); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index b638661074..fe82bf2373 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -346,7 +346,11 @@ EmuScreen::~EmuScreen() { startDumping = false; } #endif - g_Discord.SetPresenceMenu(); + + if (GetUIState() == UISTATE_EXIT) + g_Discord.ClearPresence(); + else + g_Discord.SetPresenceMenu(); } void EmuScreen::dialogFinished(const Screen *dialog, DialogResult result) { From ca8681f59cc7579f529192e763ada96c82aa9bfb Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 10 Nov 2018 07:47:50 -0800 Subject: [PATCH 3/3] UI: Fix incorrect 3D API. If the string doesn't exist (e.g. OpenGL ES), the std::string goes out of scope, and we end up with a bad string. Oops. --- UI/DevScreens.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index 11863bd210..a81bc8c60b 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -388,7 +388,8 @@ void SystemInfoScreen::CreateViews() { DrawContext *draw = screenManager()->getDrawContext(); - const char *apiName = gr->T(screenManager()->getDrawContext()->GetInfoString(InfoField::APINAME)); + const std::string apiNameKey = draw->GetInfoString(InfoField::APINAME); + const char *apiName = gr->T(apiNameKey); deviceSpecs->Add(new InfoItem(si->T("3D API"), apiName)); deviceSpecs->Add(new InfoItem(si->T("Vendor"), draw->GetInfoString(InfoField::VENDORSTRING))); std::string vendor = draw->GetInfoString(InfoField::VENDOR);