Added boilerplate code for Discord module

pull/102/head
Cam K 2021-04-19 20:58:47 -04:00
rodzic bdce551a50
commit 3a142b0d85
3 zmienionych plików z 98 dodań i 0 usunięć

Wyświetl plik

@ -22,6 +22,7 @@ option(OPT_BUILD_AUDIO_SINK "Build Audio Sink Module (Depedencies: rtaudio)" ON)
option(OPT_BUILD_FALCON9_DECODER "Build the falcon9 live decoder (Dependencies: ffplay)" OFF)
option(OPT_BUILD_METEOR_DEMODULATOR "Build the meteor demodulator module (no dependencies required)" ON)
option(OPT_BUILD_WEATHER_SAT_DECODER "Build the HRPT decoder module (no dependencies required)" ON)
option(OPT_BUILD_DISCORD_PRESENCE "Build the Discord Rich Presence module" ON)
# Core of SDR++
add_subdirectory("core")
@ -87,6 +88,10 @@ if (OPT_BUILD_WEATHER_SAT_DECODER)
add_subdirectory("weather_sat_decoder")
endif (OPT_BUILD_WEATHER_SAT_DECODER)
if (OPT_BUILD_DISCORD_PRESENCE)
add_subdirectory("discord")
endif (OPT_BUILD_DISCORD_PRESENCE)
if (MSVC)
set(CMAKE_CXX_FLAGS "-O2 /std:c++17 /EHsc")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")

Wyświetl plik

@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.13)
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")
else ()
set(CMAKE_CXX_FLAGS "-O3 -std=c++17")
endif ()
file(GLOB SRC "src/*.cpp")
include_directories("src/")
add_library(discord SHARED ${SRC})
target_link_libraries(discord PRIVATE sdrpp_core)
set_target_properties(discord PROPERTIES PREFIX "")
# Install directives
install(TARGETS discord DESTINATION lib/sdrpp/plugins)

Wyświetl plik

@ -0,0 +1,72 @@
#include <imgui.h>
#include <spdlog/spdlog.h>
#include <module.h>
#include <gui/gui.h>
#include <gui/style.h>
#include <core.h>
SDRPP_MOD_INFO {
/* Name: */ "discord",
/* Description: */ "Discord Rich Presence module for SDR++",
/* Author: */ "Starman0620",
/* Version: */ 0, 0, 1,
/* Max instances */ -1
};
class PresenceModule : public ModuleManager::Instance {
public:
PresenceModule(std::string name) {
this->name = name;
gui::menu.registerEntry(name, menuHandler, this, this);
}
~PresenceModule() {
}
void enable() {
enabled = true;
}
void disable() {
enabled = false;
}
bool isEnabled() {
return enabled;
}
private:
static void menuHandler(void* ctx) {
PresenceModule* _this = (PresenceModule*)ctx;
if(!_this->enabled) { style::beginDisabled(); }
float menuWidth = ImGui::GetContentRegionAvailWidth();
ImGui::BeginGroup();
ImGui::Text("Hello, SDR++ world! - Starman0620");
ImGui::EndGroup();
if(!_this->enabled) { style::endDisabled(); }
}
std::string name;
bool enabled = true;
};
MOD_EXPORT void _INIT_() {
}
MOD_EXPORT ModuleManager::Instance* _CREATE_INSTANCE_(std::string name) {
return new PresenceModule(name);
}
MOD_EXPORT void _DELETE_INSTANCE_(void* instance) {
delete (PresenceModule*)instance;
}
MOD_EXPORT void _END_() {
}