Skip to content

Commit 963aa9f

Browse files
authored
[Maintenance PR for Legacy Gamedevs] Add party privacy enum (discord#306)
* Add party privacy enum * Add party privacy enum * Possible unreal working * Cast to int
1 parent e4c0c56 commit 963aa9f

File tree

7 files changed

+37
-1
lines changed

7 files changed

+37
-1
lines changed

examples/button-clicker/Assets/DiscordController.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ public void OnClick()
3131
clickCounter++;
3232

3333
presence.details = string.Format("Button clicked {0} times", clickCounter);
34+
presence.joinSecret = "aSecret";
35+
presence.partyId = "aPartyId";
36+
presence.partySize = 1;
37+
presence.partyMax = 3;
38+
presence.partyPrivacy = DiscordRpc.PartyPrivacy.Public;
3439

3540
DiscordRpc.UpdatePresence(presence);
3641
}

examples/button-clicker/Assets/DiscordRpc.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public struct RichPresenceStruct
5656
public IntPtr partyId; /* max 128 bytes */
5757
public int partySize;
5858
public int partyMax;
59+
public int partyPrivacy;
5960
public IntPtr matchSecret; /* max 128 bytes */
6061
public IntPtr joinSecret; /* max 128 bytes */
6162
public IntPtr spectateSecret; /* max 128 bytes */
@@ -78,6 +79,12 @@ public enum Reply
7879
Ignore = 2
7980
}
8081

82+
public enum PartyPrivacy
83+
{
84+
Private = 0,
85+
Public = 1
86+
}
87+
8188
public static void Initialize(string applicationId, ref EventHandlers handlers, bool autoRegister, string optionalSteamId)
8289
{
8390
Callbacks = handlers;
@@ -137,6 +144,7 @@ public class RichPresence
137144
public string partyId; /* max 128 bytes */
138145
public int partySize;
139146
public int partyMax;
147+
public PartyPrivacy partyPrivacy;
140148
public string matchSecret; /* max 128 bytes */
141149
public string joinSecret; /* max 128 bytes */
142150
public string spectateSecret; /* max 128 bytes */
@@ -164,6 +172,7 @@ internal RichPresenceStruct GetStruct()
164172
_presence.partyId = StrToPtr(partyId);
165173
_presence.partySize = partySize;
166174
_presence.partyMax = partyMax;
175+
_presence.partyPrivacy = (int)partyPrivacy;
167176
_presence.matchSecret = StrToPtr(matchSecret);
168177
_presence.joinSecret = StrToPtr(joinSecret);
169178
_presence.spectateSecret = StrToPtr(spectateSecret);

examples/send-presence/send-presence.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static void updateDiscordPresence()
4747
discordPresence.partyId = "party1234";
4848
discordPresence.partySize = 1;
4949
discordPresence.partyMax = 6;
50+
discordPresence.partyPrivacy = DISCORD_PARTY_PUBLIC;
5051
discordPresence.matchSecret = "xyzzy";
5152
discordPresence.joinSecret = "join";
5253
discordPresence.spectateSecret = "look";

examples/unrealstatus/Plugins/discordrpc/Source/DiscordRpc/Private/DiscordRpcBlueprint.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ void UDiscordRpc::UpdatePresence()
153153
rp.endTimestamp = RichPresence.endTimestamp;
154154
rp.partySize = RichPresence.partySize;
155155
rp.partyMax = RichPresence.partyMax;
156+
rp.partyPrivacy = (int)RichPresence.partyPrivacy;
156157
rp.instance = RichPresence.instance;
157158

158159
Discord_UpdatePresence(&rp);

examples/unrealstatus/Plugins/discordrpc/Source/DiscordRpc/Public/DiscordRpcBlueprint.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ enum class EDiscordJoinResponseCodes : uint8
3535
DISCORD_REPLY_IGNORE UMETA(DisplayName="Ignore")
3636
};
3737

38+
/**
39+
* Valid party privacy values
40+
*/
41+
UENUM(BlueprintType)
42+
enum class EDiscordPartyPrivacy: uint8
43+
{
44+
DISCORD_PARTY_PRIVATE UMETA(DisplayName="Private"),
45+
DISCORD_PARTY_PUBLIC UMETA(DisplayName="Public")
46+
};
47+
3848
DECLARE_LOG_CATEGORY_EXTERN(Discord, Log, All);
3949

4050
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDiscordConnected, const FDiscordUserData&, joinRequest);
@@ -77,6 +87,8 @@ struct FDiscordRichPresence {
7787
UPROPERTY(BlueprintReadWrite)
7888
int partyMax;
7989
UPROPERTY(BlueprintReadWrite)
90+
EDiscordPartyPrivacy partyPrivacy;
91+
UPROPERTY(BlueprintReadWrite)
8092
FString matchSecret;
8193
UPROPERTY(BlueprintReadWrite)
8294
FString joinSecret;

include/discord_rpc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ typedef struct DiscordRichPresence {
3535
const char* partyId; /* max 128 bytes */
3636
int partySize;
3737
int partyMax;
38+
int partyPrivacy;
3839
const char* matchSecret; /* max 128 bytes */
3940
const char* joinSecret; /* max 128 bytes */
4041
const char* spectateSecret; /* max 128 bytes */
@@ -60,6 +61,8 @@ typedef struct DiscordEventHandlers {
6061
#define DISCORD_REPLY_NO 0
6162
#define DISCORD_REPLY_YES 1
6263
#define DISCORD_REPLY_IGNORE 2
64+
#define DISCORD_PARTY_PRIVATE 0
65+
#define DISCORD_PARTY_PUBLIC 1
6366

6467
DISCORD_EXPORT void Discord_Initialize(const char* applicationId,
6568
DiscordEventHandlers* handlers,

src/serialization.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,19 @@ size_t JsonWriteRichPresenceObj(char* dest,
134134
}
135135

136136
if ((presence->partyId && presence->partyId[0]) || presence->partySize ||
137-
presence->partyMax) {
137+
presence->partyMax || presence->partyPrivacy) {
138138
WriteObject party(writer, "party");
139139
WriteOptionalString(writer, "id", presence->partyId);
140140
if (presence->partySize && presence->partyMax) {
141141
WriteArray size(writer, "size");
142142
writer.Int(presence->partySize);
143143
writer.Int(presence->partyMax);
144144
}
145+
146+
if (presence->partyPrivacy) {
147+
WriteKey(writer, "privacy");
148+
writer.Int(presence->partyPrivacy);
149+
}
145150
}
146151

147152
if ((presence->matchSecret && presence->matchSecret[0]) ||

0 commit comments

Comments
 (0)