diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ecd27f..33788d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,16 +10,20 @@ set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_CXX_STANDARD 17) -# Inclui as bibliotecas do Discord RPC -set(DISCORD_RPC_LIB "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/discord-rpc/lib/libdiscord-rpc.so") -set(DISCORD_RPC_LIB_PATH "${CMAKE_SOURCE_DIR}/dependencies/discord-rpc/lib") -include_directories("${CMAKE_CURRENT_SOURCE_DIR}/dependencies/discord-rpc/include") +if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + set(DISCORD_RPC_LIB "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/win64-dynamic/lib/discord-rpc.lib") + set(DISCORD_RPC_LIB_PATH "${CMAKE_SOURCE_DIR}/dependencies/win64-dynamic/lib") +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(DISCORD_RPC_LIB "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/linux-dynamic/lib/libdiscord-rpc.so") + set(DISCORD_RPC_LIB_PATH "${CMAKE_SOURCE_DIR}/dependencies/linux-dynamic/lib") +endif() + +include_directories("${CMAKE_CURRENT_SOURCE_DIR}/dependencies/linux-dynamic/include") find_package(QtCreator REQUIRED COMPONENTS Core ProjectExplorer) find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core5Compat Widgets) set(QtX Qt${QT_VERSION_MAJOR}) -# nao sei dizer # Add a CMake option that enables building your plugin with tests. # You don't want your released plugin binaries to contain tests, # so make that default to 'NO'. diff --git a/dependencies/discord-rpc/lib/discord-rpc.lib b/dependencies/discord-rpc/lib/discord-rpc.lib deleted file mode 100644 index 1f3e825..0000000 Binary files a/dependencies/discord-rpc/lib/discord-rpc.lib and /dev/null differ diff --git a/dependencies/discord-rpc/lib/libdiscord-rpc.a b/dependencies/discord-rpc/lib/libdiscord-rpc.a deleted file mode 100644 index 8b5a2cc..0000000 Binary files a/dependencies/discord-rpc/lib/libdiscord-rpc.a and /dev/null differ diff --git a/dependencies/discord-rpc/include/discord_register.h b/dependencies/linux-dynamic/include/discord_register.h similarity index 100% rename from dependencies/discord-rpc/include/discord_register.h rename to dependencies/linux-dynamic/include/discord_register.h diff --git a/dependencies/discord-rpc/include/discord_rpc.h b/dependencies/linux-dynamic/include/discord_rpc.h similarity index 100% rename from dependencies/discord-rpc/include/discord_rpc.h rename to dependencies/linux-dynamic/include/discord_rpc.h diff --git a/dependencies/discord-rpc/lib/libdiscord-rpc.so b/dependencies/linux-dynamic/lib/libdiscord-rpc.so similarity index 100% rename from dependencies/discord-rpc/lib/libdiscord-rpc.so rename to dependencies/linux-dynamic/lib/libdiscord-rpc.so diff --git a/dependencies/win64-dynamic/bin/discord-rpc.dll b/dependencies/win64-dynamic/bin/discord-rpc.dll new file mode 100644 index 0000000..8493c54 Binary files /dev/null and b/dependencies/win64-dynamic/bin/discord-rpc.dll differ diff --git a/dependencies/win64-dynamic/bin/send-presence.exe b/dependencies/win64-dynamic/bin/send-presence.exe new file mode 100644 index 0000000..91a49b5 Binary files /dev/null and b/dependencies/win64-dynamic/bin/send-presence.exe differ diff --git a/dependencies/win64-dynamic/include/discord_register.h b/dependencies/win64-dynamic/include/discord_register.h new file mode 100644 index 0000000..ae5995a --- /dev/null +++ b/dependencies/win64-dynamic/include/discord_register.h @@ -0,0 +1,26 @@ +#pragma once + +#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 + +#ifdef __cplusplus +extern "C" { +#endif + +DISCORD_EXPORT void Discord_Register(const char* applicationId, const char* command); +DISCORD_EXPORT void Discord_RegisterSteamGame(const char* applicationId, const char* steamId); + +#ifdef __cplusplus +} +#endif diff --git a/dependencies/win64-dynamic/include/discord_rpc.h b/dependencies/win64-dynamic/include/discord_rpc.h new file mode 100644 index 0000000..f508123 --- /dev/null +++ b/dependencies/win64-dynamic/include/discord_rpc.h @@ -0,0 +1,87 @@ +#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 DiscordUser { + const char* userId; + const char* username; + const char* discriminator; + const char* avatar; +} DiscordUser; + +typedef struct DiscordEventHandlers { + void (*ready)(const DiscordUser* request); + 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 DiscordUser* 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_ClearPresence(void); + +DISCORD_EXPORT void Discord_Respond(const char* userid, /* DISCORD_REPLY_ */ int reply); + +DISCORD_EXPORT void Discord_UpdateHandlers(DiscordEventHandlers* handlers); + +#ifdef __cplusplus +} /* extern "C" */ +#endif diff --git a/dependencies/win64-dynamic/lib/discord-rpc.lib b/dependencies/win64-dynamic/lib/discord-rpc.lib new file mode 100644 index 0000000..fcd009d Binary files /dev/null and b/dependencies/win64-dynamic/lib/discord-rpc.lib differ