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

@ -29,6 +29,7 @@ add_library(core
Config/MainSettings.cpp
Config/NetplaySettings.cpp
Config/SYSCONFSettings.cpp
Config/UISettings.cpp
ConfigLoaders/BaseConfigLoader.cpp
ConfigLoaders/GameConfigLoader.cpp
ConfigLoaders/IsSettingSaveable.cpp

View File

@ -0,0 +1,14 @@
// Copyright 2018 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included
#include "Core/Config/UISettings.h"
namespace Config
{
// UI.General
const ConfigInfo<bool> MAIN_USE_DISCORD_PRESENCE{{System::Main, "General", "UseDiscordPresence"},
true};
} // namespace Config

View File

@ -0,0 +1,21 @@
// Copyright 2018 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "Common/Config/Config.h"
// This is a temporary soluation, although they should be in their repected cpp file in UICommon.
// However, in order for IsSettingSaveable to commpile without some issues, this needs to be here.
// Once IsSettingSaveable is removed, then you should able to move these back to UICommon.
namespace Config
{
// Configuration Information
// UI.General
extern const ConfigInfo<bool> MAIN_USE_DISCORD_PRESENCE;
} // namespace Config

View File

@ -9,7 +9,7 @@
#include "Common/Config/Config.h"
#include "Core/Config/GraphicsSettings.h"
#include "UICommon/DiscordPresence.h"
#include "Core/Config/UISettings.h"
namespace ConfigLoaders
{
@ -116,9 +116,9 @@ bool IsSettingSaveable(const Config::ConfigLocation& config_location)
Config::GFX_PERF_QUERIES_ENABLE.location,
// Main.General
// UI.General
MAIN_USE_DISCORD_PRESENCE.location,
Config::MAIN_USE_DISCORD_PRESENCE.location,
};

View File

@ -48,6 +48,7 @@
<ClCompile Include="Config\GraphicsSettings.cpp" />
<ClCompile Include="Config\MainSettings.cpp" />
<ClCompile Include="Config\NetplaySettings.cpp" />
<ClCompile Include="Config\UISettings.cpp" />
<ClCompile Include="Config\SYSCONFSettings.cpp" />
<ClCompile Include="ConfigLoaders\BaseConfigLoader.cpp" />
<ClCompile Include="ConfigLoaders\GameConfigLoader.cpp" />
@ -316,6 +317,7 @@
<ClInclude Include="ConfigLoaders\MovieConfigLoader.h" />
<ClInclude Include="ConfigLoaders\NetPlayConfigLoader.h" />
<ClInclude Include="ConfigManager.h" />
<ClInclude Include="Config\UISettings.h" />
<ClInclude Include="Core.h" />
<ClInclude Include="CoreTiming.h" />
<ClInclude Include="Debugger\Debugger_SymbolMap.h" />
@ -592,4 +594,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -898,6 +898,9 @@
<ClCompile Include="IOS\Network\NCD\WiiNetConfig.cpp">
<Filter>IOS\Network\NCD</Filter>
</ClCompile>
<ClCompile Include="Config\UISettings.cpp">
<Filter>Config</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="BootManager.h" />
@ -1580,8 +1583,11 @@
<ClInclude Include="HW\WiimoteCommon\WiimoteReport.h">
<Filter>HW %28Flipper/Hollywood%29\WiimoteCommon</Filter>
</ClInclude>
<ClInclude Include="Config\UISettings.h">
<Filter>Config</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
</Project>
</Project>

View File

@ -15,6 +15,10 @@ PRIVATE
cpp-optparse
)
if(USE_DISCORD_PRESENCE)
target_compile_definitions(dolphin-nogui PRIVATE -DUSE_DISCORD_PRESENCE)
endif()
set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} dolphin-nogui)
install(TARGETS dolphin-nogui RUNTIME DESTINATION ${bindir})

View File

@ -28,6 +28,9 @@
#include "Core/State.h"
#include "UICommon/CommandLineParse.h"
#ifdef USE_DISCORD_PRESENCE
#include "UICommon/DiscordPresence.h"
#endif
#include "UICommon/UICommon.h"
#include "VideoCommon/RenderBase.h"
@ -440,6 +443,10 @@ int main(int argc, char* argv[])
return 1;
}
#ifdef USE_DISCORD_PRESENCE
Discord::UpdateDiscordPresence();
#endif
while (!Core::IsRunning() && s_running.IsSet())
{
Core::HostDispatchJobs();

View File

@ -218,3 +218,7 @@ if(APPLE)
else()
install(TARGETS dolphin-emu RUNTIME DESTINATION ${bindir})
endif()
if(USE_DISCORD_PRESENCE)
target_compile_definitions(dolphin-emu PRIVATE -DUSE_DISCORD_PRESENCE)
endif()

View File

@ -19,10 +19,6 @@
#include "DolphinQt2/Settings.h"
#include "InputCommon/InputConfig.h"
#ifdef USE_DISCORD_PRESENCE
#include "UICommon/DiscordPresence.h"
#endif
Settings::Settings()
{
qRegisterMetaType<Core::State>();

View File

@ -19,6 +19,7 @@
#include <QWidget>
#include "Core/Analytics.h"
#include "Core/Config/UISettings.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/PowerPC/PowerPC.h"
@ -227,7 +228,7 @@ void GeneralPane::LoadConfig()
m_checkbox_dualcore->setChecked(SConfig::GetInstance().bCPUThread);
m_checkbox_cheats->setChecked(Settings::Instance().GetCheatsEnabled());
#ifdef USE_DISCORD_PRESENCE
m_checkbox_discord_presence->setChecked(Config::Get(MAIN_USE_DISCORD_PRESENCE));
m_checkbox_discord_presence->setChecked(Config::Get(Config::MAIN_USE_DISCORD_PRESENCE));
#endif
int selection = qRound(SConfig::GetInstance().m_EmulationSpeed * 10);
if (selection < m_combobox_speedlimit->count())

View File

@ -187,4 +187,8 @@ else()
install(TARGETS dolphin-emu-wx RUNTIME DESTINATION ${bindir})
endif()
if(USE_DISCORD_PRESENCE)
target_compile_definitions(dolphin-emu-wx PRIVATE -DUSE_DISCORD_PRESENCE)
endif()
set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} dolphin-emu-wx)

View File

@ -20,6 +20,7 @@
#include "Common/Common.h"
#include "Core/Analytics.h"
#include "Core/Config/UISettings.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/PowerPC/PowerPC.h"
@ -161,7 +162,7 @@ void GeneralConfigPane::LoadGUIValues()
m_cheats_checkbox->SetValue(startup_params.bEnableCheats);
#ifdef USE_DISCORD_PRESENCE
m_discord_presence_checkbox->SetValue(Config::Get(MAIN_USE_DISCORD_PRESENCE));
m_discord_presence_checkbox->SetValue(Config::Get(Config::MAIN_USE_DISCORD_PRESENCE));
#endif
#if defined(USE_ANALYTICS) && USE_ANALYTICS

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;