summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2018-06-25 00:06:27 +0200
committerGitHub <noreply@github.com>2018-06-25 00:06:27 +0200
commit2cfdf89898c4689884fbffb1c693ec24a7083f66 (patch)
treeea6424aa322c4df3c86efe8b62326c8e6ac28740 /Source
parent7388094e837dc2da9288769db689cd386c7f05bb (diff)
parent63f03455f32ab938806216e218342fe8921eaf27 (diff)
Merge pull request #6983 from yourWaifu/add-discord-rpc-support
Add Discord Rich Presence support
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/CMakeLists.txt1
-rw-r--r--Source/Core/Core/Config/UISettings.cpp14
-rw-r--r--Source/Core/Core/Config/UISettings.h21
-rw-r--r--Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp5
-rw-r--r--Source/Core/Core/Core.vcxproj2
-rw-r--r--Source/Core/Core/Core.vcxproj.filters6
-rw-r--r--Source/Core/DolphinNoGUI/CMakeLists.txt4
-rw-r--r--Source/Core/DolphinNoGUI/MainNoGUI.cpp7
-rw-r--r--Source/Core/DolphinQt2/CMakeLists.txt4
-rw-r--r--Source/Core/DolphinQt2/DolphinQt2.vcxproj4
-rw-r--r--Source/Core/DolphinQt2/MainWindow.cpp7
-rw-r--r--Source/Core/DolphinQt2/Settings/GeneralPane.cpp19
-rw-r--r--Source/Core/DolphinQt2/Settings/GeneralPane.h3
-rw-r--r--Source/Core/DolphinWX/CMakeLists.txt4
-rw-r--r--Source/Core/DolphinWX/Config/GeneralConfigPane.cpp32
-rw-r--r--Source/Core/DolphinWX/Config/GeneralConfigPane.h6
-rw-r--r--Source/Core/DolphinWX/DolphinWX.vcxproj4
-rw-r--r--Source/Core/DolphinWX/FrameTools.cpp7
-rw-r--r--Source/Core/UICommon/CMakeLists.txt6
-rw-r--r--Source/Core/UICommon/DiscordPresence.cpp73
-rw-r--r--Source/Core/UICommon/DiscordPresence.h13
-rw-r--r--Source/Core/UICommon/UICommon.cpp3
-rw-r--r--Source/Core/UICommon/UICommon.vcxproj5
-rw-r--r--Source/VSProps/Base.props1
-rw-r--r--Source/dolphin-emu.sln7
25 files changed, 254 insertions, 4 deletions
diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt
index 77e09873fd..0fecda7e8b 100644
--- a/Source/Core/Core/CMakeLists.txt
+++ b/Source/Core/Core/CMakeLists.txt
@@ -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
diff --git a/Source/Core/Core/Config/UISettings.cpp b/Source/Core/Core/Config/UISettings.cpp
new file mode 100644
index 0000000000..889c215f36
--- /dev/null
+++ b/Source/Core/Core/Config/UISettings.cpp
@@ -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
diff --git a/Source/Core/Core/Config/UISettings.h b/Source/Core/Core/Config/UISettings.h
new file mode 100644
index 0000000000..e515c2472d
--- /dev/null
+++ b/Source/Core/Core/Config/UISettings.h
@@ -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
diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp
index 23a6cf5f4f..932a1f03a2 100644
--- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp
+++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp
@@ -9,6 +9,7 @@
#include "Common/Config/Config.h"
#include "Core/Config/GraphicsSettings.h"
+#include "Core/Config/UISettings.h"
namespace ConfigLoaders
{
@@ -118,6 +119,10 @@ bool IsSettingSaveable(const Config::ConfigLocation& config_location)
Config::GFX_PERF_QUERIES_ENABLE.location,
+ // UI.General
+
+ Config::MAIN_USE_DISCORD_PRESENCE.location,
+
};
return std::find(s_setting_saveable.begin(), s_setting_saveable.end(), config_location) !=
diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj
index 2045848739..9039da4443 100644
--- a/Source/Core/Core/Core.vcxproj
+++ b/Source/Core/Core/Core.vcxproj
@@ -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" />
@@ -319,6 +320,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" />
diff --git a/Source/Core/Core/Core.vcxproj.filters b/Source/Core/Core/Core.vcxproj.filters
index 5f561a8a44..b9a979df78 100644
--- a/Source/Core/Core/Core.vcxproj.filters
+++ b/Source/Core/Core/Core.vcxproj.filters
@@ -907,6 +907,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" />
@@ -1598,6 +1601,9 @@
<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" />
diff --git a/Source/Core/DolphinNoGUI/CMakeLists.txt b/Source/Core/DolphinNoGUI/CMakeLists.txt
index 9dbbe040e1..2f7761789a 100644
--- a/Source/Core/DolphinNoGUI/CMakeLists.txt
+++ b/Source/Core/DolphinNoGUI/CMakeLists.txt
@@ -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})
diff --git a/Source/Core/DolphinNoGUI/MainNoGUI.cpp b/Source/Core/DolphinNoGUI/MainNoGUI.cpp
index af27952ca0..23a502e8f6 100644
--- a/Source/Core/DolphinNoGUI/MainNoGUI.cpp
+++ b/Source/Core/DolphinNoGUI/MainNoGUI.cpp
@@ -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();
diff --git a/Source/Core/DolphinQt2/CMakeLists.txt b/Source/Core/DolphinQt2/CMakeLists.txt
index e78fe5f628..ebd98f7e95 100644
--- a/Source/Core/DolphinQt2/CMakeLists.txt
+++ b/Source/Core/DolphinQt2/CMakeLists.txt
@@ -220,3 +220,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()
diff --git a/Source/Core/DolphinQt2/DolphinQt2.vcxproj b/Source/Core/DolphinQt2/DolphinQt2.vcxproj
index 9f6311f423..2ea3ef872e 100644
--- a/Source/Core/DolphinQt2/DolphinQt2.vcxproj
+++ b/Source/Core/DolphinQt2/DolphinQt2.vcxproj
@@ -40,8 +40,8 @@
</PropertyGroup>
<ItemDefinitionGroup>
<Link>
- <AdditionalLibraryDirectories>$(ExternalsDir)ffmpeg\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>avrt.lib;iphlpapi.lib;winmm.lib;setupapi.lib;opengl32.lib;glu32.lib;rpcrt4.lib;comctl32.lib;avcodec.lib;avformat.lib;avutil.lib;swresample.lib;swscale.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>$(ExternalsDir)ffmpeg\lib;$(IntDir)..\discord-rpc\bin;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>avrt.lib;iphlpapi.lib;winmm.lib;setupapi.lib;opengl32.lib;glu32.lib;rpcrt4.lib;comctl32.lib;avcodec.lib;avformat.lib;avutil.lib;swresample.lib;swscale.lib;Shlwapi.lib;discord-rpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<ClCompile>
<AdditionalIncludeDirectories>$(ProjectDir)VideoInterface;$(ProjectDir)GameList;$(ProjectDir)Debugger;$(ProjectDir)Settings;$(ProjectDir)Config;$(ProjectDir)Config\Mapping;$(ProjectDir)Config\Graphics;$(ProjectDir)NetPlay;$(ProjectDir)QtUtils;$(ProjectDir)TAS;$(ProjectDir)FIFO;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
diff --git a/Source/Core/DolphinQt2/MainWindow.cpp b/Source/Core/DolphinQt2/MainWindow.cpp
index fabe0c0f34..762ef125f7 100644
--- a/Source/Core/DolphinQt2/MainWindow.cpp
+++ b/Source/Core/DolphinQt2/MainWindow.cpp
@@ -84,6 +84,7 @@
#include "InputCommon/ControllerInterface/ControllerInterface.h"
+#include "UICommon/DiscordPresence.h"
#include "UICommon/UICommon.h"
#include "VideoCommon/VideoConfig.h"
@@ -632,6 +633,9 @@ void MainWindow::OnStopComplete()
m_stop_requested = false;
HideRenderWidget();
EnableScreenSaver(true);
+#ifdef USE_DISCORD_PRESENCE
+ Discord::UpdateDiscordPresence();
+#endif
SetFullScreenResolution(false);
@@ -783,6 +787,9 @@ void MainWindow::StartGame(std::unique_ptr<BootParameters>&& parameters)
}
ShowRenderWidget();
+#ifdef USE_DISCORD_PRESENCE
+ Discord::UpdateDiscordPresence();
+#endif
if (SConfig::GetInstance().bFullscreen)
m_fullscreen_requested = true;
diff --git a/Source/Core/DolphinQt2/Settings/GeneralPane.cpp b/Source/Core/DolphinQt2/Settings/GeneralPane.cpp
index 5384233569..46e29732a5 100644
--- a/Source/Core/DolphinQt2/Settings/GeneralPane.cpp
+++ b/Source/Core/DolphinQt2/Settings/GeneralPane.cpp
@@ -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"
@@ -26,6 +27,9 @@
#include "DolphinQt2/Settings.h"
#include "UICommon/AutoUpdate.h"
+#ifdef USE_DISCORD_PRESENCE
+#include "UICommon/DiscordPresence.h"
+#endif
constexpr int AUTO_UPDATE_DISABLE_INDEX = 0;
constexpr int AUTO_UPDATE_STABLE_INDEX = 1;
@@ -87,6 +91,9 @@ void GeneralPane::ConnectLayout()
{
connect(m_checkbox_dualcore, &QCheckBox::toggled, this, &GeneralPane::OnSaveConfig);
connect(m_checkbox_cheats, &QCheckBox::toggled, this, &GeneralPane::OnSaveConfig);
+#ifdef USE_DISCORD_PRESENCE
+ connect(m_checkbox_discord_presence, &QCheckBox::toggled, this, &GeneralPane::OnSaveConfig);
+#endif
if (AutoUpdateChecker::SystemSupportsAutoUpdates())
{
@@ -125,6 +132,11 @@ void GeneralPane::CreateBasic()
m_checkbox_cheats = new QCheckBox(tr("Enable Cheats"));
basic_group_layout->addWidget(m_checkbox_cheats);
+#ifdef USE_DISCORD_PRESENCE
+ m_checkbox_discord_presence = new QCheckBox(tr("Show Current Game on Discord"));
+ basic_group_layout->addWidget(m_checkbox_discord_presence);
+#endif
+
auto* speed_limit_layout = new QFormLayout;
speed_limit_layout->setFormAlignment(Qt::AlignLeft | Qt::AlignTop);
speed_limit_layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
@@ -219,6 +231,9 @@ void GeneralPane::LoadConfig()
#endif
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(Config::MAIN_USE_DISCORD_PRESENCE));
+#endif
int selection = qRound(SConfig::GetInstance().m_EmulationSpeed * 10);
if (selection < m_combobox_speedlimit->count())
m_combobox_speedlimit->setCurrentIndex(selection);
@@ -264,6 +279,10 @@ void GeneralPane::OnSaveConfig()
UpdateTrackFromIndex(m_combobox_update_track->currentIndex()));
}
+#ifdef USE_DISCORD_PRESENCE
+ Discord::SetDiscordPresenceEnabled(m_checkbox_discord_presence->isChecked());
+#endif
+
#if defined(USE_ANALYTICS) && USE_ANALYTICS
Settings::Instance().SetAnalyticsEnabled(m_checkbox_enable_analytics->isChecked());
#endif
diff --git a/Source/Core/DolphinQt2/Settings/GeneralPane.h b/Source/Core/DolphinQt2/Settings/GeneralPane.h
index d98cb76c16..90d53838e7 100644
--- a/Source/Core/DolphinQt2/Settings/GeneralPane.h
+++ b/Source/Core/DolphinQt2/Settings/GeneralPane.h
@@ -44,6 +44,9 @@ private:
QComboBox* m_combobox_update_track;
QCheckBox* m_checkbox_dualcore;
QCheckBox* m_checkbox_cheats;
+#ifdef USE_DISCORD_PRESENCE
+ QCheckBox* m_checkbox_discord_presence;
+#endif
QLabel* m_label_speedlimit;
std::vector<QRadioButton*> m_cpu_cores;
diff --git a/Source/Core/DolphinWX/CMakeLists.txt b/Source/Core/DolphinWX/CMakeLists.txt
index 46360d332f..105cef9170 100644
--- a/Source/Core/DolphinWX/CMakeLists.txt
+++ b/Source/Core/DolphinWX/CMakeLists.txt
@@ -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)
diff --git a/Source/Core/DolphinWX/Config/GeneralConfigPane.cpp b/Source/Core/DolphinWX/Config/GeneralConfigPane.cpp
index da3f97f88f..3a4dfed817 100644
--- a/Source/Core/DolphinWX/Config/GeneralConfigPane.cpp
+++ b/Source/Core/DolphinWX/Config/GeneralConfigPane.cpp
@@ -20,10 +20,14 @@
#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"
#include "DolphinWX/WxEventUtils.h"
+#ifdef USE_DISCORD_PRESENCE
+#include "UICommon/DiscordPresence.h"
+#endif
static const std::map<PowerPC::CPUCore, std::string> CPU_CORE_NAMES = {
{PowerPC::CPUCore::Interpreter, _trans("Interpreter (slowest)")},
@@ -55,6 +59,9 @@ void GeneralConfigPane::InitializeGUI()
m_dual_core_checkbox = new wxCheckBox(this, wxID_ANY, _("Enable Dual Core (speedup)"));
m_cheats_checkbox = new wxCheckBox(this, wxID_ANY, _("Enable Cheats"));
+#ifdef USE_DISCORD_PRESENCE
+ m_discord_presence_checkbox = new wxCheckBox(this, wxID_ANY, _("Show Current Game on Discord"));
+#endif
#if defined(USE_ANALYTICS) && USE_ANALYTICS
m_analytics_checkbox = new wxCheckBox(this, wxID_ANY, _("Enable Usage Statistics Reporting"));
#ifdef __APPLE__
@@ -74,6 +81,11 @@ void GeneralConfigPane::InitializeGUI()
_("Splits the CPU and GPU threads so they can be run on separate cores.\nProvides major "
"speed improvements on most modern PCs, but can cause occasional crashes/glitches."));
m_cheats_checkbox->SetToolTip(_("Enables the use of Action Replay and Gecko cheats."));
+#ifdef USE_DISCORD_PRESENCE
+ m_discord_presence_checkbox->SetToolTip(
+ _("Allow other people on Discord to see the current activity in Dolphin. Activities such as "
+ "the game being played, and for how long"));
+#endif
#if defined(USE_ANALYTICS) && USE_ANALYTICS
m_analytics_checkbox->SetToolTip(
_("Enables the collection and sharing of usage statistics data with the Dolphin development "
@@ -106,6 +118,10 @@ void GeneralConfigPane::InitializeGUI()
basic_settings_sizer->AddSpacer(space5);
basic_settings_sizer->Add(m_cheats_checkbox, 0, wxLEFT | wxRIGHT, space5);
basic_settings_sizer->AddSpacer(space5);
+#ifdef USE_DISCORD_PRESENCE
+ basic_settings_sizer->Add(m_discord_presence_checkbox, 0, wxLEFT | wxRIGHT, space5);
+ basic_settings_sizer->AddSpacer(space5);
+#endif
basic_settings_sizer->Add(throttler_sizer);
#if defined(USE_ANALYTICS) && USE_ANALYTICS
@@ -145,6 +161,10 @@ void GeneralConfigPane::LoadGUIValues()
m_dual_core_checkbox->SetValue(startup_params.bCPUThread);
m_cheats_checkbox->SetValue(startup_params.bEnableCheats);
+#ifdef USE_DISCORD_PRESENCE
+ m_discord_presence_checkbox->SetValue(Config::Get(Config::MAIN_USE_DISCORD_PRESENCE));
+#endif
+
#if defined(USE_ANALYTICS) && USE_ANALYTICS
m_analytics_checkbox->SetValue(startup_params.m_analytics_enabled);
#endif
@@ -169,6 +189,11 @@ void GeneralConfigPane::BindEvents()
m_cheats_checkbox->Bind(wxEVT_CHECKBOX, &GeneralConfigPane::OnCheatCheckBoxChanged, this);
m_cheats_checkbox->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning);
+#ifdef USE_DISCORD_PRESENCE
+ m_discord_presence_checkbox->Bind(wxEVT_CHECKBOX,
+ &GeneralConfigPane::OnDiscordPresenceCheckBoxChanged, this);
+#endif
+
#if defined(USE_ANALYTICS) && USE_ANALYTICS
m_analytics_checkbox->Bind(wxEVT_CHECKBOX, &GeneralConfigPane::OnAnalyticsCheckBoxChanged, this);
@@ -194,6 +219,13 @@ void GeneralConfigPane::OnCheatCheckBoxChanged(wxCommandEvent& event)
SConfig::GetInstance().bEnableCheats = m_cheats_checkbox->IsChecked();
}
+#ifdef USE_DISCORD_PRESENCE
+void GeneralConfigPane::OnDiscordPresenceCheckBoxChanged(wxCommandEvent& event)
+{
+ Discord::SetDiscordPresenceEnabled(m_discord_presence_checkbox->IsChecked());
+}
+#endif
+
void GeneralConfigPane::OnThrottlerChoiceChanged(wxCommandEvent& event)
{
if (m_throttler_choice->GetSelection() != wxNOT_FOUND)
diff --git a/Source/Core/DolphinWX/Config/GeneralConfigPane.h b/Source/Core/DolphinWX/Config/GeneralConfigPane.h
index ea8f86267b..af1b4434a9 100644
--- a/Source/Core/DolphinWX/Config/GeneralConfigPane.h
+++ b/Source/Core/DolphinWX/Config/GeneralConfigPane.h
@@ -25,6 +25,9 @@ private:
void OnDualCoreCheckBoxChanged(wxCommandEvent&);
void OnCheatCheckBoxChanged(wxCommandEvent&);
+#ifdef USE_DISCORD_PRESENCE
+ void OnDiscordPresenceCheckBoxChanged(wxCommandEvent&);
+#endif
void OnThrottlerChoiceChanged(wxCommandEvent&);
void OnCPUEngineRadioBoxChanged(wxCommandEvent&);
void OnAnalyticsCheckBoxChanged(wxCommandEvent&);
@@ -35,6 +38,9 @@ private:
wxCheckBox* m_dual_core_checkbox;
wxCheckBox* m_cheats_checkbox;
+#ifdef USE_DISCORD_PRESENCE
+ wxCheckBox* m_discord_presence_checkbox;
+#endif
wxCheckBox* m_analytics_checkbox;
wxButton* m_analytics_new_id;
diff --git a/Source/Core/DolphinWX/DolphinWX.vcxproj b/Source/Core/DolphinWX/DolphinWX.vcxproj
index d7d7519f16..1038bea539 100644
--- a/Source/Core/DolphinWX/DolphinWX.vcxproj
+++ b/Source/Core/DolphinWX/DolphinWX.vcxproj
@@ -38,8 +38,8 @@
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<Link>
- <AdditionalLibraryDirectories>$(ExternalsDir)ffmpeg\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>avrt.lib;iphlpapi.lib;winmm.lib;setupapi.lib;opengl32.lib;glu32.lib;rpcrt4.lib;comctl32.lib;avcodec.lib;avformat.lib;avutil.lib;swresample.lib;swscale.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>$(ExternalsDir)ffmpeg\lib;$(IntDir)..\discord-rpc\bin;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>avrt.lib;iphlpapi.lib;winmm.lib;setupapi.lib;opengl32.lib;glu32.lib;rpcrt4.lib;comctl32.lib;avcodec.lib;avformat.lib;avutil.lib;swresample.lib;swscale.lib;Shlwapi.lib;discord-rpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<ResourceCompile>
<AdditionalIncludeDirectories>$(ExternalsDir)wxWidgets3\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp
index 496a6e1065..f54952c405 100644
--- a/Source/Core/DolphinWX/FrameTools.cpp
+++ b/Source/Core/DolphinWX/FrameTools.cpp
@@ -93,6 +93,7 @@
#include "InputCommon/ControllerInterface/ControllerInterface.h"
+#include "UICommon/DiscordPresence.h"
#include "UICommon/GameFile.h"
#include "UICommon/UICommon.h"
@@ -821,6 +822,9 @@ void CFrame::StartGame(std::unique_ptr<BootParameters> boot)
else
{
EnableScreenSaver(false);
+#ifdef USE_DISCORD_PRESENCE
+ Discord::UpdateDiscordPresence();
+#endif
// We need this specifically to support setting the focus properly when using
// the 'render to main window' feature on Windows
@@ -1007,6 +1011,9 @@ void CFrame::OnStopped()
wxPostEvent(GetMenuBar(), wxCommandEvent{DOLPHIN_EVT_UPDATE_LOAD_WII_MENU_ITEM});
EnableScreenSaver(true);
+#ifdef USE_DISCORD_PRESENCE
+ Discord::UpdateDiscordPresence();
+#endif
m_render_frame->SetTitle(StrToWxStr(Common::scm_rev_str));
diff --git a/Source/Core/UICommon/CMakeLists.txt b/Source/Core/UICommon/CMakeLists.txt
index ed94341182..b6dde75014 100644
--- a/Source/Core/UICommon/CMakeLists.txt
+++ b/Source/Core/UICommon/CMakeLists.txt
@@ -2,6 +2,7 @@ add_library(uicommon
AutoUpdate.cpp
CommandLineParse.cpp
Disassembler.cpp
+ DiscordPresence.cpp
GameFile.cpp
GameFileCache.cpp
UICommon.cpp
@@ -36,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()
diff --git a/Source/Core/UICommon/DiscordPresence.cpp b/Source/Core/UICommon/DiscordPresence.cpp
new file mode 100644
index 0000000000..dece60dcbc
--- /dev/null
+++ b/Source/Core/UICommon/DiscordPresence.cpp
@@ -0,0 +1,73 @@
+// Copyright 2018 Dolphin Emulator Project
+// Licensed under GPLv2+
+// Refer to the license.txt file included.
+
+#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>
+
+#endif
+
+namespace Discord
+{
+void Init()
+{
+#ifdef 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("455712169795780630", &handlers, 1, nullptr);
+ UpdateDiscordPresence();
+#endif
+}
+
+void UpdateDiscordPresence()
+{
+#ifdef USE_DISCORD_PRESENCE
+ if (!Config::Get(Config::MAIN_USE_DISCORD_PRESENCE))
+ return;
+
+ const std::string& title = SConfig::GetInstance().GetTitleDescription();
+
+ DiscordRichPresence discord_presence = {};
+ discord_presence.largeImageKey = "dolphin_logo";
+ discord_presence.largeImageText = "Dolphin is an emulator for the GameCube and the Wii.";
+ discord_presence.details = title.empty() ? "Not in-game" : title.c_str();
+ discord_presence.startTimestamp = std::time(nullptr);
+ Discord_UpdatePresence(&discord_presence);
+#endif
+}
+
+void Shutdown()
+{
+#ifdef USE_DISCORD_PRESENCE
+ if (!Config::Get(Config::MAIN_USE_DISCORD_PRESENCE))
+ return;
+
+ Discord_ClearPresence();
+ Discord_Shutdown();
+#endif
+}
+
+void SetDiscordPresenceEnabled(bool enabled)
+{
+ if (Config::Get(Config::MAIN_USE_DISCORD_PRESENCE) == enabled)
+ return;
+
+ if (Config::Get(Config::MAIN_USE_DISCORD_PRESENCE))
+ Discord::Shutdown();
+
+ Config::SetBase(Config::MAIN_USE_DISCORD_PRESENCE, enabled);
+
+ if (Config::Get(Config::MAIN_USE_DISCORD_PRESENCE))
+ Discord::Init();
+}
+
+} // namespace Discord
diff --git a/Source/Core/UICommon/DiscordPresence.h b/Source/Core/UICommon/DiscordPresence.h
new file mode 100644
index 0000000000..9c4673f885
--- /dev/null
+++ b/Source/Core/UICommon/DiscordPresence.h
@@ -0,0 +1,13 @@
+// Copyright 2018 Dolphin Emulator Project
+// Licensed under GPLv2+
+// Refer to the license.txt file included.
+
+#pragma once
+
+namespace Discord
+{
+void Init();
+void UpdateDiscordPresence();
+void Shutdown();
+void SetDiscordPresenceEnabled(bool enabled);
+} // namespace Discord
diff --git a/Source/Core/UICommon/UICommon.cpp b/Source/Core/UICommon/UICommon.cpp
index a9453882dc..c84d4af04b 100644
--- a/Source/Core/UICommon/UICommon.cpp
+++ b/Source/Core/UICommon/UICommon.cpp
@@ -33,6 +33,7 @@
#include "InputCommon/GCAdapter.h"
+#include "UICommon/DiscordPresence.h"
#include "UICommon/UICommon.h"
#include "UICommon/USBUtils.h"
@@ -75,6 +76,7 @@ void Init()
Config::AddConfigChangedCallback(InitCustomPaths);
Config::AddLayer(ConfigLoaders::GenerateBaseConfigLoader());
SConfig::Init();
+ Discord::Init();
LogManager::Init();
VideoBackendBase::PopulateList();
WiimoteReal::LoadSettings();
@@ -90,6 +92,7 @@ void Shutdown()
WiimoteReal::Shutdown();
VideoBackendBase::ClearList();
LogManager::Shutdown();
+ Discord::Shutdown();
SConfig::Shutdown();
Config::Shutdown();
}
diff --git a/Source/Core/UICommon/UICommon.vcxproj b/Source/Core/UICommon/UICommon.vcxproj
index 4ee5a357c0..9f7158e97c 100644
--- a/Source/Core/UICommon/UICommon.vcxproj
+++ b/Source/Core/UICommon/UICommon.vcxproj
@@ -45,10 +45,14 @@
<ProjectReference Include="..\..\..\Externals\picojson\picojson.vcxproj">
<Project>{2c0d058e-de35-4471-ad99-e68a2caf9e18}</Project>
</ProjectReference>
+ <ProjectReference Include="$(ExternalsDir)discord-rpc\src\discord-rpc.vcxproj">
+ <Project>{4482FD2A-EC43-3FFB-AC20-2E5C54B05EAD}</Project>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="AutoUpdate.cpp" />
<ClCompile Include="CommandLineParse.cpp" />
+ <ClCompile Include="DiscordPresence.cpp" />
<ClCompile Include="UICommon.cpp" />
<ClCompile Include="Disassembler.cpp" />
<ClCompile Include="USBUtils.cpp">
@@ -61,6 +65,7 @@
<ItemGroup>
<ClInclude Include="AutoUpdate.h" />
<ClInclude Include="CommandLineParse.h" />
+ <ClInclude Include="DiscordPresence.h" />
<ClInclude Include="UICommon.h" />
<ClInclude Include="Disassembler.h" />
<ClInclude Include="USBUtils.h" />
diff --git a/Source/VSProps/Base.props b/Source/VSProps/Base.props
index 6449222367..568d1d28b2 100644
--- a/Source/VSProps/Base.props
+++ b/Source/VSProps/Base.props
@@ -59,6 +59,7 @@
<PreprocessorDefinitions>_M_X86=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>SFML_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>USE_ANALYTICS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>USE_DISCORD_PRESENCE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>CURL_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Platform)'=='x64'">_ARCH_64=1;_M_X86_64=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<!--
diff --git a/Source/dolphin-emu.sln b/Source/dolphin-emu.sln
index 9a5f68cc93..91fee8d4e1 100644
--- a/Source/dolphin-emu.sln
+++ b/Source/dolphin-emu.sln
@@ -87,6 +87,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ed25519", "..\externals\ed2
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Updater", "Core\Updater\Updater.vcxproj", "{E4BECBAB-9C6E-41AB-BB56-F9D70AB6BE03}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "discord-rpc", "..\Externals\discord-rpc\src\discord-rpc.vcxproj", "{4482FD2A-EC43-3FFB-AC20-2E5C54B05EAD}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -249,6 +251,10 @@ Global
{E4BECBAB-9C6E-41AB-BB56-F9D70AB6BE03}.Debug|x64.Build.0 = Debug|x64
{E4BECBAB-9C6E-41AB-BB56-F9D70AB6BE03}.Release|x64.ActiveCfg = Release|x64
{E4BECBAB-9C6E-41AB-BB56-F9D70AB6BE03}.Release|x64.Build.0 = Release|x64
+ {4482FD2A-EC43-3FFB-AC20-2E5C54B05EAD}.Debug|x64.ActiveCfg = Debug|x64
+ {4482FD2A-EC43-3FFB-AC20-2E5C54B05EAD}.Debug|x64.Build.0 = Debug|x64
+ {4482FD2A-EC43-3FFB-AC20-2E5C54B05EAD}.Release|x64.ActiveCfg = Release|x64
+ {4482FD2A-EC43-3FFB-AC20-2E5C54B05EAD}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -287,5 +293,6 @@ Global
{38FEE76F-F347-484B-949C-B4649381CFFB} = {87ADDFF9-5768-4DA2-A33B-2477593D6677}
{2C0D058E-DE35-4471-AD99-E68A2CAF9E18} = {87ADDFF9-5768-4DA2-A33B-2477593D6677}
{5BDF4B91-1491-4FB0-BC27-78E9A8E97DC3} = {87ADDFF9-5768-4DA2-A33B-2477593D6677}
+ {4482FD2A-EC43-3FFB-AC20-2E5C54B05EAD} = {87ADDFF9-5768-4DA2-A33B-2477593D6677}
EndGlobalSection
EndGlobal