Include discord-rpc

This commit is contained in:
momo5502 2019-01-06 19:02:57 +01:00
parent 8f690690ab
commit 67fc5630f7
6 changed files with 112 additions and 0 deletions

6
.gitmodules vendored
View File

@ -17,3 +17,9 @@
[submodule "deps/GSL"]
path = deps/GSL
url = https://github.com/Microsoft/GSL.git
[submodule "deps/discord-rpc"]
path = deps/discord-rpc
url = https://github.com/discordapp/discord-rpc.git
[submodule "deps/rapidjson"]
path = deps/rapidjson
url = https://github.com/Tencent/rapidjson.git

1
deps/discord-rpc vendored Submodule

@ -0,0 +1 @@
Subproject commit 4e53fa0392bdb7c301abd48b973204e2cacbaede

38
deps/premake/discord-rpc.lua vendored Normal file
View File

@ -0,0 +1,38 @@
discordrpc = {
source = path.join(dependencies.basePath, "discord-rpc"),
}
function discordrpc.import()
links { "discord-rpc" }
discordrpc.includes()
end
function discordrpc.includes()
includedirs {
path.join(discordrpc.source, "include"),
}
end
function discordrpc.project()
project "discord-rpc"
language "C++"
discordrpc.includes()
rapidjson.import();
files {
path.join(discordrpc.source, "src/*.h"),
path.join(discordrpc.source, "src/*.cpp"),
}
removefiles {
path.join(discordrpc.source, "src/*_linux.cpp"),
path.join(discordrpc.source, "src/*_unix.cpp"),
path.join(discordrpc.source, "src/*_osx.cpp"),
}
warnings "Off"
kind "StaticLib"
end
table.insert(dependencies, discordrpc)

19
deps/premake/rapidjson.lua vendored Normal file
View File

@ -0,0 +1,19 @@
rapidjson = {
source = path.join(dependencies.basePath, "rapidjson"),
}
function rapidjson.import()
rapidjson.includes()
end
function rapidjson.includes()
includedirs {
path.join(rapidjson.source, "include"),
}
end
function rapidjson.project()
end
table.insert(dependencies, rapidjson)

1
deps/rapidjson vendored Submodule

@ -0,0 +1 @@
Subproject commit bfdcf4911047688fec49014d575433e2e5eb05be

47
src/module/discord.cpp Normal file
View File

@ -0,0 +1,47 @@
#include <std_include.hpp>
#include <discord_rpc.h>
#include "loader/module_loader.hpp"
#include "scheduler.hpp"
class discord final : public module
{
public:
void post_load() override
{
DiscordEventHandlers handlers;
ZeroMemory(&handlers, sizeof(handlers));
handlers.ready = ready;
handlers.errored = errored;
handlers.disconnected = errored;
handlers.joinGame = nullptr;
handlers.spectateGame = nullptr;
handlers.joinRequest = nullptr;
Discord_Initialize("531526691319971880", &handlers, 1, nullptr);
scheduler::on_frame(Discord_RunCallbacks);
}
void pre_destroy() override
{
Discord_Shutdown();
}
private:
static void ready(const DiscordUser* request)
{
DiscordRichPresence discord_presence;
ZeroMemory(&discord_presence, sizeof(discord_presence));
discord_presence.state = "Cake!";
discord_presence.instance = 1;
Discord_UpdatePresence(&discord_presence);
}
static void errored(int error_code, const char* message)
{
printf("Discord: (%i) %s", error_code, message);
}
};
REGISTER_MODULE(discord)