mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-12-26 02:48:31 +01:00
Added basic rich presence
This commit is contained in:
parent
dc65ff3a05
commit
6420553ae9
@ -4,9 +4,9 @@ project(discord)
|
||||
if (MSVC)
|
||||
set(CMAKE_CXX_FLAGS "-O2 /std:c++17 /EHsc")
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(CMAKE_CXX_FLAGS "-O3 -std=c++17 -Wno-unused-command-line-argument -undefined dynamic_lookup")
|
||||
set(CMAKE_CXX_FLAGS "-O3 -std=c++17 -Wno-unused-command-line-argument -undefined dynamic_lookup -fPIC")
|
||||
else ()
|
||||
set(CMAKE_CXX_FLAGS "-O3 -std=c++17")
|
||||
set(CMAKE_CXX_FLAGS "-O3 -std=c++17 -fPIC")
|
||||
endif ()
|
||||
|
||||
file(GLOB SRC "src/*.cpp")
|
||||
@ -16,7 +16,7 @@ include_directories("src/" "discord-rpc/include")
|
||||
add_subdirectory("discord-rpc")
|
||||
|
||||
add_library(discord SHARED ${SRC})
|
||||
target_link_libraries(discord PRIVATE sdrpp_core)
|
||||
target_link_libraries(discord PUBLIC sdrpp_core discord-rpc)
|
||||
set_target_properties(discord PROPERTIES PREFIX "")
|
||||
|
||||
# Install directives
|
||||
|
@ -15,11 +15,28 @@ SDRPP_MOD_INFO {
|
||||
/* Max instances */ -1
|
||||
};
|
||||
|
||||
static DiscordRichPresence presence;
|
||||
|
||||
class PresenceModule : public ModuleManager::Instance {
|
||||
public:
|
||||
PresenceModule(std::string name) {
|
||||
this->name = name;
|
||||
gui::menu.registerEntry(name, menuHandler, this, this);
|
||||
|
||||
// Discord initialization
|
||||
DiscordEventHandlers handlers;
|
||||
memset(&handlers, 0, sizeof(handlers));
|
||||
memset(&presence, 0, sizeof(presence));
|
||||
Discord_Initialize("833485588954742864", &handlers, 1, "");
|
||||
|
||||
// Set the first presence
|
||||
presence.state = "Loading...";
|
||||
presence.details = "Initializing rich presence...";
|
||||
presence.partySize = 1;
|
||||
presence.partyMax = 1;
|
||||
presence.startTimestamp = time(0);
|
||||
presence.largeImageKey = "image_large";
|
||||
Discord_UpdatePresence(&presence);
|
||||
}
|
||||
|
||||
~PresenceModule() {
|
||||
|
Loading…
Reference in New Issue
Block a user