From dee8de29da7b72b5a1b2566311402933bacf007f Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Mon, 8 Jan 2018 01:13:56 -0600 Subject: [PATCH] Just switch to DLLs. --- Attorney_Online_remake.pro | 5 ++- discord-rpc.h | 84 ++++++++++++++++++++++++++++++++++++++ discord_rich_presence.cpp | 1 + 3 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 discord-rpc.h diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro index 40355c5..1c5ba4e 100644 --- a/Attorney_Online_remake.pro +++ b/Attorney_Online_remake.pro @@ -78,7 +78,8 @@ HEADERS += lobby.h \ aolineedit.h \ aotextedit.h \ aoevidencedisplay.h \ - discord_rich_presence.h + discord_rich_presence.h \ + discord-rpc.h # 1. You need to get BASS and put the x86 bass DLL/headers in the project root folder # AND the compilation output folder. If you want a static link, you'll probably @@ -87,7 +88,7 @@ HEADERS += lobby.h \ # in the same way as BASS. Discord RPC uses CMake, which does not play nicely with # QMake, so this step must be manual. unix:LIBS += -L$$PWD -lbass -ldiscord-rpc -win32:LIBS += "$$PWD/bass.dll" +win32:LIBS += -L$$PWD "$$PWD/bass.dll" -ldiscord-rpc #"$$PWD/discord-rpc.dll" android:LIBS += -L$$PWD\android\libs\armeabi-v7a\ -lbass CONFIG += c++11 diff --git a/discord-rpc.h b/discord-rpc.h new file mode 100644 index 0000000..8c117ac --- /dev/null +++ b/discord-rpc.h @@ -0,0 +1,84 @@ +#pragma once +#include + +// clang-format off + +#if defined(DISCORD_DYNAMIC_LIB) +# if defined(_WIN32) +# if defined(DISCORD_BUILDING_SDK) +# define DISCORD_EXPORT __declspec(dllexport) +# else +# define DISCORD_EXPORT __declspec(dllimport) +# endif +# else +# define DISCORD_EXPORT __attribute__((visibility("default"))) +# endif +#else +# define DISCORD_EXPORT +#endif + +// clang-format on + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct DiscordRichPresence { + const char* state; /* max 128 bytes */ + const char* details; /* max 128 bytes */ + int64_t startTimestamp; + int64_t endTimestamp; + const char* largeImageKey; /* max 32 bytes */ + const char* largeImageText; /* max 128 bytes */ + const char* smallImageKey; /* max 32 bytes */ + const char* smallImageText; /* max 128 bytes */ + const char* partyId; /* max 128 bytes */ + int partySize; + int partyMax; + const char* matchSecret; /* max 128 bytes */ + const char* joinSecret; /* max 128 bytes */ + const char* spectateSecret; /* max 128 bytes */ + int8_t instance; +} DiscordRichPresence; + +typedef struct DiscordJoinRequest { + const char* userId; + const char* username; + const char* discriminator; + const char* avatar; +} DiscordJoinRequest; + +typedef struct DiscordEventHandlers { + void (*ready)(); + void (*disconnected)(int errorCode, const char* message); + void (*errored)(int errorCode, const char* message); + void (*joinGame)(const char* joinSecret); + void (*spectateGame)(const char* spectateSecret); + void (*joinRequest)(const DiscordJoinRequest* request); +} DiscordEventHandlers; + +#define DISCORD_REPLY_NO 0 +#define DISCORD_REPLY_YES 1 +#define DISCORD_REPLY_IGNORE 2 + +DISCORD_EXPORT void Discord_Initialize(const char* applicationId, + DiscordEventHandlers* handlers, + int autoRegister, + const char* optionalSteamId); +DISCORD_EXPORT void Discord_Shutdown(void); + +/* checks for incoming messages, dispatches callbacks */ +DISCORD_EXPORT void Discord_RunCallbacks(void); + +/* If you disable the lib starting its own io thread, you'll need to call this from your own */ +#ifdef DISCORD_DISABLE_IO_THREAD +DISCORD_EXPORT void Discord_UpdateConnection(void); +#endif + +DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence* presence); + +DISCORD_EXPORT void Discord_Respond(const char* userid, /* DISCORD_REPLY_ */ int reply); + +#ifdef __cplusplus +} /* extern "C" */ +#endif diff --git a/discord_rich_presence.cpp b/discord_rich_presence.cpp index 5d64c10..f5f6c11 100644 --- a/discord_rich_presence.cpp +++ b/discord_rich_presence.cpp @@ -53,6 +53,7 @@ void Discord::state_server(const char* name, const char* server_id) presence.largeImageText = "Objection!"; presence.instance = 1; presence.matchSecret = server_id; + Discord_UpdatePresence(&presence); } }