From 899d6b8c9bc0ae4d0603353fc96e466ed702e317 Mon Sep 17 00:00:00 2001 From: MrKuBu Date: Sun, 3 Dec 2023 17:09:36 +0300 Subject: [PATCH 1/4] Add custom buttons (2 buttons) --- src/serialization.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/serialization.cpp b/src/serialization.cpp index 70efa63..ccc725d 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); } From cec56647066f4e9d7aacb1a98be377729bb1d0d1 Mon Sep 17 00:00:00 2001 From: MrKuBu Date: Sun, 3 Dec 2023 17:10:18 +0300 Subject: [PATCH 2/4] Const buttons (2 buttons) --- include/discord_rpc.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/discord_rpc.h b/include/discord_rpc.h index 9470434..f30f63d 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; From f6a74b6768453caee970f125e37c2d3cdb367a02 Mon Sep 17 00:00:00 2001 From: MrKuBu Date: Sun, 3 Dec 2023 17:10:56 +0300 Subject: [PATCH 3/4] Example 2 buttons links --- examples/send-presence/send-presence.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/examples/send-presence/send-presence.c b/examples/send-presence/send-presence.c index 1b651f2..74831d3 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 { From d23dd4fdbc17292f513103e83c1c203210e38d98 Mon Sep 17 00:00:00 2001 From: MrKuBu Date: Mon, 4 Dec 2023 02:03:18 +0300 Subject: [PATCH 4/4] Add pip build.py --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index 1c328b8..12c3939 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