mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-01-13 11:47:13 +01:00
Added basic rich presence
This commit is contained in:
parent
dc65ff3a05
commit
6420553ae9
@ -4,9 +4,9 @@ project(discord)
|
|||||||
if (MSVC)
|
if (MSVC)
|
||||||
set(CMAKE_CXX_FLAGS "-O2 /std:c++17 /EHsc")
|
set(CMAKE_CXX_FLAGS "-O2 /std:c++17 /EHsc")
|
||||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
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 ()
|
else ()
|
||||||
set(CMAKE_CXX_FLAGS "-O3 -std=c++17")
|
set(CMAKE_CXX_FLAGS "-O3 -std=c++17 -fPIC")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
file(GLOB SRC "src/*.cpp")
|
file(GLOB SRC "src/*.cpp")
|
||||||
@ -16,7 +16,7 @@ include_directories("src/" "discord-rpc/include")
|
|||||||
add_subdirectory("discord-rpc")
|
add_subdirectory("discord-rpc")
|
||||||
|
|
||||||
add_library(discord SHARED ${SRC})
|
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 "")
|
set_target_properties(discord PROPERTIES PREFIX "")
|
||||||
|
|
||||||
# Install directives
|
# Install directives
|
||||||
|
@ -15,11 +15,28 @@ SDRPP_MOD_INFO {
|
|||||||
/* Max instances */ -1
|
/* Max instances */ -1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static DiscordRichPresence presence;
|
||||||
|
|
||||||
class PresenceModule : public ModuleManager::Instance {
|
class PresenceModule : public ModuleManager::Instance {
|
||||||
public:
|
public:
|
||||||
PresenceModule(std::string name) {
|
PresenceModule(std::string name) {
|
||||||
this->name = name;
|
this->name = name;
|
||||||
gui::menu.registerEntry(name, menuHandler, this, this);
|
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() {
|
~PresenceModule() {
|
||||||
|
Loading…
Reference in New Issue
Block a user