diff --git a/CMakeLists.txt b/CMakeLists.txt index bf43754266..7e5accb780 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ option(ENABLE_HEADLESS "Enables running Dolphin as a headless variant" OFF) option(ENABLE_ALSA "Enables ALSA sound backend" ON) option(ENABLE_PULSEAUDIO "Enables PulseAudio sound backend" ON) option(ENABLE_LLVM "Enables LLVM support, for disassembly" ON) +option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence, show the current game on Discord" ON) # Maintainers: if you consider blanket disabling this for your users, please # consider the following points: @@ -366,6 +367,7 @@ if(ANDROID) set(USE_EGL 1) set(ENABLE_WX 0) set(ENABLE_QT2 0) + set(USE_DISCORD_PRESENCE 0) # We are cross compiling, search only the toolchain for libraries and includes SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) @@ -388,6 +390,7 @@ if(ENABLE_HEADLESS) set(USE_X11 0) set(ENABLE_WX 0) set(ENABLE_QT2 0) + set(USE_DISCORD_PRESENCE 0) add_definitions(-DUSE_HEADLESS) endif() @@ -717,6 +720,11 @@ if(ENABLE_WX) endif() endif() +if(USE_DISCORD_PRESENCE) + message(STATUS "Using static DiscordRPC from Externals") + add_subdirectory(Externals/discord-rpc) +endif() + find_package(Libsystemd) if(SYSTEMD_FOUND) message(STATUS "libsystemd found, enabling traversal server watchdog support") diff --git a/Externals/discord-rpc/CMakeLists.txt b/Externals/discord-rpc/CMakeLists.txt index 5dad9e9f6d..17260360b5 100644 --- a/Externals/discord-rpc/CMakeLists.txt +++ b/Externals/discord-rpc/CMakeLists.txt @@ -3,11 +3,8 @@ project (DiscordRPC) include(GNUInstallDirs) -option(BUILD_EXAMPLES "Build example apps" ON) - # format file(GLOB_RECURSE ALL_SOURCE_FILES - examples/*.cpp examples/*.h examples/*.c include/*.h src/*.cpp src/*.h src/*.c ) @@ -26,31 +23,6 @@ if (CLANG_FORMAT_CMD) ) endif(CLANG_FORMAT_CMD) -# thirdparty stuff -execute_process( - COMMAND mkdir ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty - ERROR_QUIET -) - -find_file(RAPIDJSONTEST NAMES rapidjson rapidjson-1.1.0 PATHS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty CMAKE_FIND_ROOT_PATH_BOTH) -if (NOT RAPIDJSONTEST) - message("no rapidjson, download") - set(RJ_TAR_FILE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/v1.1.0.tar.gz) - file(DOWNLOAD https://github.com/miloyip/rapidjson/archive/v1.1.0.tar.gz ${RJ_TAR_FILE}) - execute_process( - COMMAND ${CMAKE_COMMAND} -E tar xzf ${RJ_TAR_FILE} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty - ) - file(REMOVE ${RJ_TAR_FILE}) -endif(NOT RAPIDJSONTEST) - -find_file(RAPIDJSON NAMES rapidjson rapidjson-1.1.0 PATHS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty CMAKE_FIND_ROOT_PATH_BOTH) - -add_library(rapidjson STATIC IMPORTED ${RAPIDJSON}) - # add subdirs add_subdirectory(src) -if (BUILD_EXAMPLES) - add_subdirectory(examples/send-presence) -endif(BUILD_EXAMPLES) diff --git a/Externals/discord-rpc/src/CMakeLists.txt b/Externals/discord-rpc/src/CMakeLists.txt index f9ec2503d2..67613be78c 100644 --- a/Externals/discord-rpc/src/CMakeLists.txt +++ b/Externals/discord-rpc/src/CMakeLists.txt @@ -1,4 +1,4 @@ -include_directories(${PROJECT_SOURCE_DIR}/include) +include_directories(${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/thirdparty/include) option(ENABLE_IO_THREAD "Start up a separate I/O thread, otherwise I'd need to call an update function" ON) option(USE_STATIC_CRT "Use /MT[d] for dynamic library" OFF) diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index 9b1094dd48..7485829a9f 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 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 MAIN_USE_DISCORD_PRESENCE; + +} // namespace Config diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index 5dd5fcf326..12383361ec 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -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, }; diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj index b84e98dd70..9c620329cf 100644 --- a/Source/Core/Core/Core.vcxproj +++ b/Source/Core/Core/Core.vcxproj @@ -48,6 +48,7 @@ + @@ -316,6 +317,7 @@ + @@ -592,4 +594,4 @@ - \ No newline at end of file + diff --git a/Source/Core/Core/Core.vcxproj.filters b/Source/Core/Core/Core.vcxproj.filters index 1dad1f08f2..5bc6b096e7 100644 --- a/Source/Core/Core/Core.vcxproj.filters +++ b/Source/Core/Core/Core.vcxproj.filters @@ -898,6 +898,9 @@ IOS\Network\NCD + + Config + @@ -1580,8 +1583,11 @@ HW %28Flipper/Hollywood%29\WiimoteCommon + + Config + - \ No newline at end of file + 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 0d7a84137e..3c3beeee5e 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 693bbc2885..78f9a20c66 100644 --- a/Source/Core/DolphinQt2/CMakeLists.txt +++ b/Source/Core/DolphinQt2/CMakeLists.txt @@ -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() diff --git a/Source/Core/DolphinQt2/Settings.cpp b/Source/Core/DolphinQt2/Settings.cpp index bd4a858365..b0f8869a6f 100644 --- a/Source/Core/DolphinQt2/Settings.cpp +++ b/Source/Core/DolphinQt2/Settings.cpp @@ -19,10 +19,6 @@ #include "DolphinQt2/Settings.h" #include "InputCommon/InputConfig.h" -#ifdef USE_DISCORD_PRESENCE -#include "UICommon/DiscordPresence.h" -#endif - Settings::Settings() { qRegisterMetaType(); diff --git a/Source/Core/DolphinQt2/Settings/GeneralPane.cpp b/Source/Core/DolphinQt2/Settings/GeneralPane.cpp index b5dbf0fe99..1a7237b6b6 100644 --- a/Source/Core/DolphinQt2/Settings/GeneralPane.cpp +++ b/Source/Core/DolphinQt2/Settings/GeneralPane.cpp @@ -19,6 +19,7 @@ #include #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()) 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 e742e4588d..6f7c66842c 100644 --- a/Source/Core/DolphinWX/Config/GeneralConfigPane.cpp +++ b/Source/Core/DolphinWX/Config/GeneralConfigPane.cpp @@ -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 diff --git a/Source/Core/UICommon/CMakeLists.txt b/Source/Core/UICommon/CMakeLists.txt index eafc3e1022..b6dde75014 100644 --- a/Source/Core/UICommon/CMakeLists.txt +++ b/Source/Core/UICommon/CMakeLists.txt @@ -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() diff --git a/Source/Core/UICommon/DiscordPresence.cpp b/Source/Core/UICommon/DiscordPresence.cpp index 13fcab69bc..dece60dcbc 100644 --- a/Source/Core/UICommon/DiscordPresence.cpp +++ b/Source/Core/UICommon/DiscordPresence.cpp @@ -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 #include -#include "Core/ConfigManager.h" - #endif -const Config::ConfigInfo 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(); } diff --git a/Source/Core/UICommon/DiscordPresence.h b/Source/Core/UICommon/DiscordPresence.h index ca27698b53..9c4673f885 100644 --- a/Source/Core/UICommon/DiscordPresence.h +++ b/Source/Core/UICommon/DiscordPresence.h @@ -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 MAIN_USE_DISCORD_PRESENCE;