Merge pull request #6983 from yourWaifu/add-discord-rpc-support

Add Discord Rich Presence support
This commit is contained in:
Pierre Bourdon
2018-06-25 00:06:27 +02:00
committed by GitHub
84 changed files with 18060 additions and 4 deletions

View File

@ -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)