mirror of
https://github.com/yuzu-emu/discord-rpc
synced 2024-11-22 04:53:34 +00:00
[Maintenance PR for Legacy Gamedevs] Add party privacy enum (#306)
* Add party privacy enum * Add party privacy enum * Possible unreal working * Cast to int
This commit is contained in:
parent
e4c0c569ec
commit
963aa9f3e5
7 changed files with 37 additions and 1 deletions
|
@ -31,6 +31,11 @@ public class DiscordController : MonoBehaviour
|
||||||
clickCounter++;
|
clickCounter++;
|
||||||
|
|
||||||
presence.details = string.Format("Button clicked {0} times", clickCounter);
|
presence.details = string.Format("Button clicked {0} times", clickCounter);
|
||||||
|
presence.joinSecret = "aSecret";
|
||||||
|
presence.partyId = "aPartyId";
|
||||||
|
presence.partySize = 1;
|
||||||
|
presence.partyMax = 3;
|
||||||
|
presence.partyPrivacy = DiscordRpc.PartyPrivacy.Public;
|
||||||
|
|
||||||
DiscordRpc.UpdatePresence(presence);
|
DiscordRpc.UpdatePresence(presence);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ public class DiscordRpc
|
||||||
public IntPtr partyId; /* max 128 bytes */
|
public IntPtr partyId; /* max 128 bytes */
|
||||||
public int partySize;
|
public int partySize;
|
||||||
public int partyMax;
|
public int partyMax;
|
||||||
|
public int partyPrivacy;
|
||||||
public IntPtr matchSecret; /* max 128 bytes */
|
public IntPtr matchSecret; /* max 128 bytes */
|
||||||
public IntPtr joinSecret; /* max 128 bytes */
|
public IntPtr joinSecret; /* max 128 bytes */
|
||||||
public IntPtr spectateSecret; /* max 128 bytes */
|
public IntPtr spectateSecret; /* max 128 bytes */
|
||||||
|
@ -78,6 +79,12 @@ public class DiscordRpc
|
||||||
Ignore = 2
|
Ignore = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum PartyPrivacy
|
||||||
|
{
|
||||||
|
Private = 0,
|
||||||
|
Public = 1
|
||||||
|
}
|
||||||
|
|
||||||
public static void Initialize(string applicationId, ref EventHandlers handlers, bool autoRegister, string optionalSteamId)
|
public static void Initialize(string applicationId, ref EventHandlers handlers, bool autoRegister, string optionalSteamId)
|
||||||
{
|
{
|
||||||
Callbacks = handlers;
|
Callbacks = handlers;
|
||||||
|
@ -137,6 +144,7 @@ public class DiscordRpc
|
||||||
public string partyId; /* max 128 bytes */
|
public string partyId; /* max 128 bytes */
|
||||||
public int partySize;
|
public int partySize;
|
||||||
public int partyMax;
|
public int partyMax;
|
||||||
|
public PartyPrivacy partyPrivacy;
|
||||||
public string matchSecret; /* max 128 bytes */
|
public string matchSecret; /* max 128 bytes */
|
||||||
public string joinSecret; /* max 128 bytes */
|
public string joinSecret; /* max 128 bytes */
|
||||||
public string spectateSecret; /* max 128 bytes */
|
public string spectateSecret; /* max 128 bytes */
|
||||||
|
@ -164,6 +172,7 @@ public class DiscordRpc
|
||||||
_presence.partyId = StrToPtr(partyId);
|
_presence.partyId = StrToPtr(partyId);
|
||||||
_presence.partySize = partySize;
|
_presence.partySize = partySize;
|
||||||
_presence.partyMax = partyMax;
|
_presence.partyMax = partyMax;
|
||||||
|
_presence.partyPrivacy = (int)partyPrivacy;
|
||||||
_presence.matchSecret = StrToPtr(matchSecret);
|
_presence.matchSecret = StrToPtr(matchSecret);
|
||||||
_presence.joinSecret = StrToPtr(joinSecret);
|
_presence.joinSecret = StrToPtr(joinSecret);
|
||||||
_presence.spectateSecret = StrToPtr(spectateSecret);
|
_presence.spectateSecret = StrToPtr(spectateSecret);
|
||||||
|
|
|
@ -47,6 +47,7 @@ static void updateDiscordPresence()
|
||||||
discordPresence.partyId = "party1234";
|
discordPresence.partyId = "party1234";
|
||||||
discordPresence.partySize = 1;
|
discordPresence.partySize = 1;
|
||||||
discordPresence.partyMax = 6;
|
discordPresence.partyMax = 6;
|
||||||
|
discordPresence.partyPrivacy = DISCORD_PARTY_PUBLIC;
|
||||||
discordPresence.matchSecret = "xyzzy";
|
discordPresence.matchSecret = "xyzzy";
|
||||||
discordPresence.joinSecret = "join";
|
discordPresence.joinSecret = "join";
|
||||||
discordPresence.spectateSecret = "look";
|
discordPresence.spectateSecret = "look";
|
||||||
|
|
|
@ -153,6 +153,7 @@ void UDiscordRpc::UpdatePresence()
|
||||||
rp.endTimestamp = RichPresence.endTimestamp;
|
rp.endTimestamp = RichPresence.endTimestamp;
|
||||||
rp.partySize = RichPresence.partySize;
|
rp.partySize = RichPresence.partySize;
|
||||||
rp.partyMax = RichPresence.partyMax;
|
rp.partyMax = RichPresence.partyMax;
|
||||||
|
rp.partyPrivacy = (int)RichPresence.partyPrivacy;
|
||||||
rp.instance = RichPresence.instance;
|
rp.instance = RichPresence.instance;
|
||||||
|
|
||||||
Discord_UpdatePresence(&rp);
|
Discord_UpdatePresence(&rp);
|
||||||
|
|
|
@ -35,6 +35,16 @@ enum class EDiscordJoinResponseCodes : uint8
|
||||||
DISCORD_REPLY_IGNORE UMETA(DisplayName="Ignore")
|
DISCORD_REPLY_IGNORE UMETA(DisplayName="Ignore")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valid party privacy values
|
||||||
|
*/
|
||||||
|
UENUM(BlueprintType)
|
||||||
|
enum class EDiscordPartyPrivacy: uint8
|
||||||
|
{
|
||||||
|
DISCORD_PARTY_PRIVATE UMETA(DisplayName="Private"),
|
||||||
|
DISCORD_PARTY_PUBLIC UMETA(DisplayName="Public")
|
||||||
|
};
|
||||||
|
|
||||||
DECLARE_LOG_CATEGORY_EXTERN(Discord, Log, All);
|
DECLARE_LOG_CATEGORY_EXTERN(Discord, Log, All);
|
||||||
|
|
||||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDiscordConnected, const FDiscordUserData&, joinRequest);
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDiscordConnected, const FDiscordUserData&, joinRequest);
|
||||||
|
@ -77,6 +87,8 @@ struct FDiscordRichPresence {
|
||||||
UPROPERTY(BlueprintReadWrite)
|
UPROPERTY(BlueprintReadWrite)
|
||||||
int partyMax;
|
int partyMax;
|
||||||
UPROPERTY(BlueprintReadWrite)
|
UPROPERTY(BlueprintReadWrite)
|
||||||
|
EDiscordPartyPrivacy partyPrivacy;
|
||||||
|
UPROPERTY(BlueprintReadWrite)
|
||||||
FString matchSecret;
|
FString matchSecret;
|
||||||
UPROPERTY(BlueprintReadWrite)
|
UPROPERTY(BlueprintReadWrite)
|
||||||
FString joinSecret;
|
FString joinSecret;
|
||||||
|
|
|
@ -35,6 +35,7 @@ typedef struct DiscordRichPresence {
|
||||||
const char* partyId; /* max 128 bytes */
|
const char* partyId; /* max 128 bytes */
|
||||||
int partySize;
|
int partySize;
|
||||||
int partyMax;
|
int partyMax;
|
||||||
|
int partyPrivacy;
|
||||||
const char* matchSecret; /* max 128 bytes */
|
const char* matchSecret; /* max 128 bytes */
|
||||||
const char* joinSecret; /* max 128 bytes */
|
const char* joinSecret; /* max 128 bytes */
|
||||||
const char* spectateSecret; /* max 128 bytes */
|
const char* spectateSecret; /* max 128 bytes */
|
||||||
|
@ -60,6 +61,8 @@ typedef struct DiscordEventHandlers {
|
||||||
#define DISCORD_REPLY_NO 0
|
#define DISCORD_REPLY_NO 0
|
||||||
#define DISCORD_REPLY_YES 1
|
#define DISCORD_REPLY_YES 1
|
||||||
#define DISCORD_REPLY_IGNORE 2
|
#define DISCORD_REPLY_IGNORE 2
|
||||||
|
#define DISCORD_PARTY_PRIVATE 0
|
||||||
|
#define DISCORD_PARTY_PUBLIC 1
|
||||||
|
|
||||||
DISCORD_EXPORT void Discord_Initialize(const char* applicationId,
|
DISCORD_EXPORT void Discord_Initialize(const char* applicationId,
|
||||||
DiscordEventHandlers* handlers,
|
DiscordEventHandlers* handlers,
|
||||||
|
|
|
@ -134,7 +134,7 @@ size_t JsonWriteRichPresenceObj(char* dest,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((presence->partyId && presence->partyId[0]) || presence->partySize ||
|
if ((presence->partyId && presence->partyId[0]) || presence->partySize ||
|
||||||
presence->partyMax) {
|
presence->partyMax || presence->partyPrivacy) {
|
||||||
WriteObject party(writer, "party");
|
WriteObject party(writer, "party");
|
||||||
WriteOptionalString(writer, "id", presence->partyId);
|
WriteOptionalString(writer, "id", presence->partyId);
|
||||||
if (presence->partySize && presence->partyMax) {
|
if (presence->partySize && presence->partyMax) {
|
||||||
|
@ -142,6 +142,11 @@ size_t JsonWriteRichPresenceObj(char* dest,
|
||||||
writer.Int(presence->partySize);
|
writer.Int(presence->partySize);
|
||||||
writer.Int(presence->partyMax);
|
writer.Int(presence->partyMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (presence->partyPrivacy) {
|
||||||
|
WriteKey(writer, "privacy");
|
||||||
|
writer.Int(presence->partyPrivacy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((presence->matchSecret && presence->matchSecret[0]) ||
|
if ((presence->matchSecret && presence->matchSecret[0]) ||
|
||||||
|
|
Loading…
Reference in a new issue