Don't forget to update the other build systems and try to fix the

builds.
This commit is contained in:
Henrik Rydgård 2018-08-13 00:25:08 +02:00
parent 785858dbf8
commit 9c22f6ed55
5 changed files with 27 additions and 9 deletions

View File

@ -822,6 +822,7 @@ endif()
list(APPEND NativeAppSource
android/jni/TestRunner.cpp
UI/DiscordIntegration.cpp
UI/NativeApp.cpp
UI/BackgroundAudio.cpp
UI/DevScreens.cpp

View File

@ -6,21 +6,23 @@
#include "Core/Config.h"
#include "DiscordIntegration.h"
#include "ext/discord-rpc/include/discord_rpc.h"
// TODO: Enable on more platforms. Make optional.
#ifdef _WIN32
const bool g_DiscordEnabled = true;
#define ENABLE_DISCORD
#else
const bool g_DiscordEnabled = true;
#endif
#ifdef ENABLE_DISCORD
#include "ext/discord-rpc/include/discord_rpc.h"
#endif
// TODO: Enable on more platforms. Make optional.
Discord g_Discord;
static const char *ppsspp_app_id = "423397985041383434";
@ -35,23 +37,27 @@ Discord::~Discord() {
}
bool Discord::IsEnabled() const {
return g_DiscordEnabled && g_Config.bDiscordPresence;
return g_Config.bDiscordPresence;
}
void Discord::Init() {
assert(IsEnabled());
assert(!initialized_);
#ifdef ENABLE_DISCORD
DiscordEventHandlers eventHandlers{};
eventHandlers.errored = &handleDiscordError;
Discord_Initialize(ppsspp_app_id, &eventHandlers, 0, nullptr);
#endif
initialized_ = true;
}
void Discord::Shutdown() {
assert(initialized_);
#ifdef ENABLE_DISCORD
Discord_Shutdown();
#endif
initialized_ = false;
}
@ -67,10 +73,12 @@ void Discord::Update() {
}
}
#ifdef ENABLE_DISCORD
#ifdef DISCORD_DISABLE_IO_THREAD
Discord_UpdateConnection();
#endif
Discord_RunCallbacks();
#endif
}
void Discord::SetPresenceGame(const char *gameTitle) {
@ -81,6 +89,7 @@ void Discord::SetPresenceGame(const char *gameTitle) {
Init();
}
#ifdef ENABLE_DISCORD
DiscordRichPresence discordPresence{};
discordPresence.state = gameTitle;
discordPresence.details = "Playing";
@ -91,6 +100,7 @@ void Discord::SetPresenceGame(const char *gameTitle) {
discordPresence.largeImageKey = "icon_regular_png";
#endif
Discord_UpdatePresence(&discordPresence);
#endif
}
void Discord::SetPresenceMenu() {
@ -101,6 +111,7 @@ void Discord::SetPresenceMenu() {
Init();
}
#ifdef ENABLE_DISCORD
DiscordRichPresence discordPresence{};
discordPresence.state = "In menu";
discordPresence.details = "";
@ -111,4 +122,5 @@ void Discord::SetPresenceMenu() {
discordPresence.largeImageKey = "icon_regular_png";
#endif
Discord_UpdatePresence(&discordPresence);
#endif
}

View File

@ -304,6 +304,7 @@
<ClInclude Include="..\..\UI\ControlMappingScreen.h" />
<ClInclude Include="..\..\UI\CwCheatScreen.h" />
<ClInclude Include="..\..\UI\DevScreens.h" />
<ClInclude Include="..\..\UI\DiscordIntegration.h" />
<ClInclude Include="..\..\UI\DisplayLayoutEditor.h" />
<ClInclude Include="..\..\UI\DisplayLayoutScreen.h" />
<ClInclude Include="..\..\UI\EmuScreen.h" />
@ -337,6 +338,7 @@
<ClCompile Include="..\..\UI\ControlMappingScreen.cpp" />
<ClCompile Include="..\..\UI\CwCheatScreen.cpp" />
<ClCompile Include="..\..\UI\DevScreens.cpp" />
<ClCompile Include="..\..\UI\DiscordIntegration.cpp" />
<ClCompile Include="..\..\UI\DisplayLayoutEditor.cpp" />
<ClCompile Include="..\..\UI\DisplayLayoutScreen.cpp" />
<ClCompile Include="..\..\UI\EmuScreen.cpp" />
@ -376,4 +378,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -7,6 +7,7 @@
<ClCompile Include="..\..\UI\ControlMappingScreen.cpp" />
<ClCompile Include="..\..\UI\CwCheatScreen.cpp" />
<ClCompile Include="..\..\UI\DevScreens.cpp" />
<ClCompile Include="..\..\UI\DiscordIntegration.cpp" />
<ClCompile Include="..\..\UI\DisplayLayoutEditor.cpp" />
<ClCompile Include="..\..\UI\DisplayLayoutScreen.cpp" />
<ClCompile Include="..\..\UI\EmuScreen.cpp" />
@ -40,6 +41,7 @@
<ClInclude Include="..\..\UI\ControlMappingScreen.h" />
<ClInclude Include="..\..\UI\CwCheatScreen.h" />
<ClInclude Include="..\..\UI\DevScreens.h" />
<ClInclude Include="..\..\UI\DiscordIntegration.h" />
<ClInclude Include="..\..\UI\DisplayLayoutEditor.h" />
<ClInclude Include="..\..\UI\DisplayLayoutScreen.h" />
<ClInclude Include="..\..\UI\EmuScreen.h" />
@ -65,4 +67,4 @@
<ClInclude Include="..\..\UI\TouchControlVisibilityScreen.h" />
<ClInclude Include="..\..\UI\ui_atlas.h" />
</ItemGroup>
</Project>
</Project>

View File

@ -485,6 +485,7 @@ LOCAL_SRC_FILES := \
$(SRC)/android/jni/native_audio.cpp \
$(SRC)/android/jni/native-audio-so.cpp \
$(SRC)/UI/BackgroundAudio.cpp \
$(SRC)/UI/DiscordIntegration.cpp \
$(SRC)/UI/DevScreens.cpp \
$(SRC)/UI/DisplayLayoutEditor.cpp \
$(SRC)/UI/DisplayLayoutScreen.cpp \