Discord Rich Presence CMake integration

I have no idea if this works or not. Hopefully the build bot will tell me.
This commit is contained in:
yourWaifu
2018-06-08 15:56:11 -05:00
committed by Sleepy Flower Girl
parent 57bd13a0ce
commit 63f03455f3
19 changed files with 98 additions and 59 deletions

View File

@ -37,3 +37,8 @@ if(ENABLE_LLVM)
target_include_directories(uicommon PRIVATE ${LLVM_INCLUDE_DIRS})
endif()
endif()
if(USE_DISCORD_PRESENCE)
target_compile_definitions(uicommon PRIVATE -DUSE_DISCORD_PRESENCE)
target_link_libraries(uicommon PRIVATE discord-rpc)
endif()

View File

@ -2,31 +2,28 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#ifdef USE_DISCORD_PRESENCE
#include "UICommon/DiscordPresence.h"
#include "Core/Config/UISettings.h"
#include "Core/ConfigManager.h"
#ifdef USE_DISCORD_PRESENCE
#include <ctime>
#include <discord-rpc/include/discord_rpc.h>
#include "Core/ConfigManager.h"
#endif
const Config::ConfigInfo<bool> MAIN_USE_DISCORD_PRESENCE{
{Config::System::Main, "General", "UseDiscordPresence"}, true};
namespace Discord
{
void Init()
{
#ifdef USE_DISCORD_PRESENCE
if (!Config::Get(MAIN_USE_DISCORD_PRESENCE))
if (!Config::Get(Config::MAIN_USE_DISCORD_PRESENCE))
return;
DiscordEventHandlers handlers = {};
// The number is the client ID for Dolphin, it's used for images and the appication name
Discord_Initialize("450033159212630028", &handlers, 1, nullptr);
Discord_Initialize("455712169795780630", &handlers, 1, nullptr);
UpdateDiscordPresence();
#endif
}
@ -34,7 +31,7 @@ void Init()
void UpdateDiscordPresence()
{
#ifdef USE_DISCORD_PRESENCE
if (!Config::Get(MAIN_USE_DISCORD_PRESENCE))
if (!Config::Get(Config::MAIN_USE_DISCORD_PRESENCE))
return;
const std::string& title = SConfig::GetInstance().GetTitleDescription();
@ -51,7 +48,7 @@ void UpdateDiscordPresence()
void Shutdown()
{
#ifdef USE_DISCORD_PRESENCE
if (!Config::Get(MAIN_USE_DISCORD_PRESENCE))
if (!Config::Get(Config::MAIN_USE_DISCORD_PRESENCE))
return;
Discord_ClearPresence();
@ -61,15 +58,15 @@ void Shutdown()
void SetDiscordPresenceEnabled(bool enabled)
{
if (Config::Get(MAIN_USE_DISCORD_PRESENCE) == enabled)
if (Config::Get(Config::MAIN_USE_DISCORD_PRESENCE) == enabled)
return;
if (Config::Get(MAIN_USE_DISCORD_PRESENCE))
if (Config::Get(Config::MAIN_USE_DISCORD_PRESENCE))
Discord::Shutdown();
Config::SetBase(MAIN_USE_DISCORD_PRESENCE, enabled);
Config::SetBase(Config::MAIN_USE_DISCORD_PRESENCE, enabled);
if (Config::Get(MAIN_USE_DISCORD_PRESENCE))
if (Config::Get(Config::MAIN_USE_DISCORD_PRESENCE))
Discord::Init();
}

View File

@ -4,8 +4,6 @@
#pragma once
#include "Common/Config/Config.h"
namespace Discord
{
void Init();
@ -13,5 +11,3 @@ void UpdateDiscordPresence();
void Shutdown();
void SetDiscordPresenceEnabled(bool enabled);
} // namespace Discord
extern const Config::ConfigInfo<bool> MAIN_USE_DISCORD_PRESENCE;