Skip to content

Commit 338935b

Browse files
authored
Implement Discord Social SDK
Implement Discord Social SDK to display rich presence for the user. Enabled by default, includes option to disable. - Split the single .zip to one for each OS. - Use global strings for program name, make the latest GitHub release URL a private member. - Add a new, permanent Discord invite URL for SocialSDK. - Fix erroneous spaces before angle brackets in a couple of places. - Add suggested exception safety.
1 parent 1379399 commit 338935b

File tree

13 files changed

+14107
-3
lines changed

13 files changed

+14107
-3
lines changed

3rdParty/discord_social_sdk/cdiscord.h

Lines changed: 1827 additions & 0 deletions
Large diffs are not rendered by default.

3rdParty/discord_social_sdk/discordpp.h

Lines changed: 12001 additions & 0 deletions
Large diffs are not rendered by default.
43.3 MB
Binary file not shown.
38.2 MB
Binary file not shown.
11.9 MB
Binary file not shown.

SerialPrograms/CMakeLists.txt

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ set(CMAKE_AUTOMOC ON)
1616
set(CMAKE_AUTORCC ON)
1717
set(CMAKE_AUTOUIC ON)
1818

19+
# Set root dir for convenience
20+
set(PROJECT_ROOT_DIR "${CMAKE_SOURCE_DIR}/..")
21+
get_filename_component(PROJECT_ROOT_DIR "${CMAKE_SOURCE_DIR}/.." ABSOLUTE)
22+
1923
add_custom_target(build-time-make-directory ALL
2024
COMMAND ${CMAKE_COMMAND} -E make_directory Assembly/)
2125

@@ -731,6 +735,8 @@ file(GLOB MAIN_SOURCES
731735
Source/Integrations/DiscordWebhookSettings.h
732736
Source/Integrations/DppIntegration/DppClient.cpp
733737
Source/Integrations/DppIntegration/DppClient.h
738+
Source/Integrations/DiscordSocial/DiscordSocial.cpp
739+
Source/Integrations/DiscordSocial/DiscordSocial.h
734740
Source/Integrations/DppIntegration/DppCommandHandler.cpp
735741
Source/Integrations/DppIntegration/DppCommandHandler.h
736742
Source/Integrations/DppIntegration/DppUtility.cpp
@@ -2449,12 +2455,17 @@ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../Internal/SerialPrograms/Internal0.
24492455
target_sources(SerialPrograms PRIVATE ../../Internal/SerialPrograms/Internal1.cpp)
24502456
endif()
24512457

2452-
#extract opencv_world4110d.dll from archive on Windows Debug builds
2458+
#extract opencv_world4110d.dll from archive on Windows Debug build, extract Discord Social SDK
24532459
if (WIN32)
24542460
file(ARCHIVE_EXTRACT
24552461
INPUT ${CMAKE_CURRENT_SOURCE_DIR}/../3rdPartyBinaries/opencv_world4110d.zip
24562462
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/../3rdPartyBinaries/
24572463
)
2464+
2465+
file(ARCHIVE_EXTRACT
2466+
INPUT ${CMAKE_CURRENT_SOURCE_DIR}/../3rdPartyBinaries/discord_social_sdk_win.zip
2467+
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/../3rdPartyBinaries/
2468+
)
24582469
endif()
24592470

24602471
#add include directory
@@ -2503,29 +2514,44 @@ if (WIN32)
25032514

25042515
add_library(dpp_lib IMPORTED UNKNOWN)
25052516
set_target_properties(dpp_lib PROPERTIES
2506-
IMPORTED_LOCATION_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/../3rdPartyBinaries/dpp.lib
2507-
IMPORTED_LOCATION_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/../3rdPartyBinaries/dppd.lib)
2517+
IMPORTED_LOCATION_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/../3rdPartyBinaries/dpp.lib
2518+
IMPORTED_LOCATION_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/../3rdPartyBinaries/dppd.lib)
25082519
set_target_properties(dpp_lib PROPERTIES
25092520
MAP_IMPORTED_CONFIG_DEBUG DEBUG
25102521
MAP_IMPORTED_CONFIG_RELEASE RELEASE
25112522
MAP_IMPORTED_CONFIG_RELWITHDEBINFO RELEASE
25122523
MAP_IMPORTED_CONFIG_MINSIZEREL RELEASE
25132524
)
25142525

2526+
add_library(discord_lib IMPORTED UNKNOWN)
2527+
target_include_directories(SerialPrograms SYSTEM PRIVATE ../3rdParty/discord_social_sdk_win/)
2528+
set_target_properties(discord_lib PROPERTIES
2529+
IMPORTED_LOCATION_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/../3rdPartyBinaries/discord_social_sdk_win/lib/release/discord_partner_sdk.lib
2530+
IMPORTED_LOCATION_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/../3rdPartyBinaries/discord_social_sdk_win/lib/debug/discord_partner_sdk.lib)
2531+
set_target_properties(discord_lib PROPERTIES
2532+
MAP_IMPORTED_CONFIG_DEBUG DEBUG
2533+
MAP_IMPORTED_CONFIG_RELEASE RELEASE
2534+
MAP_IMPORTED_CONFIG_RELWITHDEBINFO RELEASE
2535+
MAP_IMPORTED_CONFIG_MINSIZEREL RELEASE
2536+
)
2537+
25152538
target_link_libraries(
25162539
SerialPrograms PRIVATE
25172540
tesseractPA.lib
25182541
OpenCV_lib
25192542
ONNX_lib
25202543
ONNX_Providers_lib
25212544
dpp_lib
2545+
discord_lib
25222546
)
2547+
25232548
target_compile_definitions(
25242549
SerialPrograms PRIVATE
25252550
_CRT_SECURE_NO_WARNINGS
25262551
_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR
25272552
PA_TESSERACT
25282553
PA_DPP
2554+
PA_SOCIAL_SDK
25292555
)
25302556

25312557
target_compile_options(SerialPrograms PRIVATE /FAs /FaAssembly/ /MP /W4 /WX /external:anglebrackets /external:W0 /utf-8)
@@ -2770,6 +2796,16 @@ file(GLOB MY_DLLS
27702796
"../3rdPartyBinaries/*.dll"
27712797
)
27722798
file(COPY ${MY_DLLS} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
2799+
2800+
# Copy discord_social_sdk DLL based on build type
2801+
add_custom_command(
2802+
TARGET SerialPrograms
2803+
POST_BUILD
2804+
COMMAND ${CMAKE_COMMAND} -E copy
2805+
$<IF:$<CONFIG:Debug>,"${PROJECT_ROOT_DIR}/3rdPartyBinaries/discord_social_sdk_win/bin/debug/discord_partner_sdk.dll","${PROJECT_ROOT_DIR}/3rdPartyBinaries/discord_social_sdk_win/bin/release/discord_partner_sdk.dll">
2806+
$<TARGET_FILE_DIR:SerialPrograms>/Binaries64/discord_partner_sdk.dll
2807+
COMMENT "Copying Discord SDK DLL to Binaries64"
2808+
)
27732809
endif()
27742810

27752811
if (QT_MAJOR GREATER_EQUAL 6)

SerialPrograms/Source/CommonFramework/GlobalSettingsPanel.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ GlobalSettings::GlobalSettings()
157157
"online documentation"
158158
) + ")</font>"
159159
)
160+
, RICH_PRESENCE(
161+
"<b>Enable Rich Presence:</b><br>Will display program activity and status under your Discord user.",
162+
LockMode::UNLOCK_WHILE_RUNNING,
163+
true
164+
)
160165
, ALL_STATS(
161166
"<b>All Stats:</b><br>Include all-time stats for notifications.",
162167
LockMode::UNLOCK_WHILE_RUNNING,
@@ -223,6 +228,7 @@ GlobalSettings::GlobalSettings()
223228
#endif
224229

225230
PA_ADD_STATIC(m_discord_settings);
231+
PA_ADD_OPTION(RICH_PRESENCE);
226232
PA_ADD_OPTION(ALL_STATS);
227233
PA_ADD_OPTION(DISCORD);
228234

SerialPrograms/Source/CommonFramework/GlobalSettingsPanel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class GlobalSettings : public BatchOption, private ConfigOption::Listener{
103103
Pimpl<SleepSuppressOptions> SLEEP_SUPPRESS;
104104

105105
SectionDividerOption m_discord_settings;
106+
BooleanCheckBoxOption RICH_PRESENCE;
106107
BooleanCheckBoxOption ALL_STATS;
107108
Pimpl<Integration::DiscordSettingsOption> DISCORD;
108109

SerialPrograms/Source/CommonFramework/Globals.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ const std::string DISCORD_LINK_URL_PROGRAM = "https://discord.gg/BSjDp27";
7070
// URL to use in the Discord notifications/embeds.
7171
const std::string DISCORD_LINK_URL_EMBED = "https://discord.gg/xMJcveK";
7272

73+
// URL to use in the DiscordSocialSDK integration.
74+
const std::string DISCORD_LINK_URL_SDK = "https://discord.gg/gn9YEyjjAV";
75+
7376

7477

7578
#if 0

SerialPrograms/Source/CommonFramework/Globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ extern const std::string GITHUB_LINK_URL;
3131
extern const std::string DISCORD_LINK_TEXT;
3232
extern const std::string DISCORD_LINK_URL_PROGRAM;
3333
extern const std::string DISCORD_LINK_URL_EMBED;
34+
extern const std::string DISCORD_LINK_URL_SDK;
3435

3536
extern const std::string COMPILER_VERSION;
3637

0 commit comments

Comments
 (0)