diff --git a/CMakeLists.txt b/CMakeLists.txt index 5dad9e9f..0e70613c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.2.0) +cmake_minimum_required (VERSION 4.0) project (DiscordRPC) include(GNUInstallDirs) diff --git a/appveyor.yml b/appveyor.yml index 1c328b87..12c39390 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,7 @@ version: '{build}' install: - python -m pip install click + - python -m pip install build.py build_script: - mkdir examples\unrealstatus\Plugins\discordrpc\Binaries\ThirdParty\discordrpcLibrary\Win64 diff --git a/examples/send-presence/send-presence.c b/examples/send-presence/send-presence.c index 1b651f2c..74831d32 100644 --- a/examples/send-presence/send-presence.c +++ b/examples/send-presence/send-presence.c @@ -44,14 +44,20 @@ static void updateDiscordPresence() discordPresence.endTimestamp = time(0) + 5 * 60; discordPresence.largeImageKey = "canary-large"; discordPresence.smallImageKey = "ptb-small"; - discordPresence.partyId = "party1234"; - discordPresence.partySize = 1; - discordPresence.partyMax = 6; - discordPresence.partyPrivacy = DISCORD_PARTY_PUBLIC; - discordPresence.matchSecret = "xyzzy"; - discordPresence.joinSecret = "join"; - discordPresence.spectateSecret = "look"; - discordPresence.instance = 0; + // TEMP DISABLE (Join and Spectate) + //discordPresence.partyId = "party1234"; + //discordPresence.partySize = 1; + //discordPresence.partyMax = 6; + //discordPresence.partyPrivacy = DISCORD_PARTY_PUBLIC; + //discordPresence.matchSecret = "xyzzy"; + //discordPresence.joinSecret = "join"; + //discordPresence.spectateSecret = "look"; + //discordPresence.instance = 0; + // EXAMPLE BUTTONS + discordPresence.button1Label = "Example 1 button"; + discordPresence.button1Url = "https://example.com"; + discordPresence.button2Label = "Example 2 button"; + discordPresence.button2Url = "https://example.com"; Discord_UpdatePresence(&discordPresence); } else { diff --git a/include/discord_rpc.h b/include/discord_rpc.h index 9470434a..f30f63dc 100644 --- a/include/discord_rpc.h +++ b/include/discord_rpc.h @@ -39,6 +39,10 @@ typedef struct DiscordRichPresence { const char* matchSecret; /* max 128 bytes */ const char* joinSecret; /* max 128 bytes */ const char* spectateSecret; /* max 128 bytes */ + const char* button1Label; /* max 32 bytes */ + const char* button1Url; /* max 512 bytes */ + const char* button2Label; /* max 32 bytes */ + const char* button2Url; /* max 512 bytes */ int8_t instance; } DiscordRichPresence; diff --git a/src/serialization.cpp b/src/serialization.cpp index 70efa637..ccc725d6 100644 --- a/src/serialization.cpp +++ b/src/serialization.cpp @@ -157,7 +157,33 @@ size_t JsonWriteRichPresenceObj(char* dest, WriteOptionalString(writer, "join", presence->joinSecret); WriteOptionalString(writer, "spectate", presence->spectateSecret); } + + // Add Custom buttons and links (2 Buttons) + if (((presence->button1Label && presence->button1Label[0]) && + (presence->button1Url && presence->button1Url[0])) || + ((presence->button2Label && presence->button2Label[0]) && + (presence->button2Url && presence->button2Url[0]))) { + WriteArray buttons(writer, "buttons"); + + if ((presence->button1Label && presence->button1Label[0]) && + (presence->button1Url && presence->button1Url[0])) { + WriteObject button1(writer); + writer.Key("label"); + writer.String(presence->button1Label); + writer.Key("url"); + writer.String(presence->button1Url); + } + if ((presence->button2Label && presence->button2Label[0]) && + (presence->button2Url && presence->button2Url[0])) { + WriteObject button2(writer); + writer.Key("label"); + writer.String(presence->button2Label); + writer.Key("url"); + writer.String(presence->button2Url); + } + } + writer.Key("instance"); writer.Bool(presence->instance != 0); }