mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
Merge pull request #6983 from yourWaifu/add-discord-rpc-support
Add Discord Rich Presence support
This commit is contained in:
@ -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
|
||||
|
14
Source/Core/Core/Config/UISettings.cpp
Normal file
14
Source/Core/Core/Config/UISettings.cpp
Normal 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
|
21
Source/Core/Core/Config/UISettings.h
Normal file
21
Source/Core/Core/Config/UISettings.h
Normal 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
|
@ -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) !=
|
||||
|
@ -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" />
|
||||
|
@ -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" />
|
||||
|
@ -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})
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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()
|
||||
|
@ -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>
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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>
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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()
|
||||
|
73
Source/Core/UICommon/DiscordPresence.cpp
Normal file
73
Source/Core/UICommon/DiscordPresence.cpp
Normal file
@ -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
|
13
Source/Core/UICommon/DiscordPresence.h
Normal file
13
Source/Core/UICommon/DiscordPresence.h
Normal file
@ -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
|
@ -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();
|
||||
}
|
||||
|
@ -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" />
|
||||
|
Reference in New Issue
Block a user