mirror of
https://github.com/yuzu-emu/discord-rpc.git
synced 2024-12-22 23:35:38 +00:00
Update Unreal example (register more callbacks, still mostly debug prints)
This commit is contained in:
parent
c053b72f58
commit
79eea99d19
Binary file not shown.
|
@ -7,6 +7,7 @@
|
|||
DEFINE_LOG_CATEGORY(Discord)
|
||||
|
||||
static UDiscordRpc* self = nullptr;
|
||||
|
||||
static void ReadyHandler()
|
||||
{
|
||||
UE_LOG(Discord, Log, TEXT("Discord connected"));
|
||||
|
@ -53,6 +54,19 @@ static void SpectateGameHandler(const char* spectateSecret)
|
|||
}
|
||||
}
|
||||
|
||||
static void JoinRequestHandler(const DiscordJoinRequest* request)
|
||||
{
|
||||
FDiscordJoinRequestData jr;
|
||||
jr.userId = ANSI_TO_TCHAR(request->userId);
|
||||
jr.username = ANSI_TO_TCHAR(request->username);
|
||||
jr.discriminator = ANSI_TO_TCHAR(request->discriminator);
|
||||
jr.avatar = ANSI_TO_TCHAR(request->avatar);
|
||||
UE_LOG(Discord, Log, TEXT("Discord join request from %s#%s"), *jr.username, *jr.discriminator);
|
||||
if (self) {
|
||||
self->OnJoinRequest.Broadcast(jr);
|
||||
}
|
||||
}
|
||||
|
||||
void UDiscordRpc::Initialize(const FString& applicationId,
|
||||
bool autoRegister,
|
||||
const FString& optionalSteamId)
|
||||
|
@ -69,6 +83,9 @@ void UDiscordRpc::Initialize(const FString& applicationId,
|
|||
if (OnSpectate.IsBound()) {
|
||||
handlers.spectateGame = SpectateGameHandler;
|
||||
}
|
||||
if (OnJoinRequest.IsBound()) {
|
||||
handlers.joinRequest = JoinRequestHandler;
|
||||
}
|
||||
auto appId = StringCast<ANSICHAR>(*applicationId);
|
||||
auto steamId = StringCast<ANSICHAR>(*optionalSteamId);
|
||||
Discord_Initialize(
|
||||
|
|
|
@ -9,6 +9,24 @@
|
|||
// unreal's header tool hates clang-format
|
||||
// clang-format off
|
||||
|
||||
/**
|
||||
* Ask to join callback data
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct FDiscordJoinRequestData {
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
FString userId;
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
FString username;
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
FString discriminator;
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
FString avatar;
|
||||
};
|
||||
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(Discord, Log, All);
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FDiscordConnected);
|
||||
|
@ -16,6 +34,7 @@ DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FDiscordDisconnected, int, errorCod
|
|||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FDiscordErrored, int, errorCode, const FString&, errorMessage);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDiscordJoin, const FString&, joinSecret);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDiscordSpectate, const FString&, spectateSecret);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDiscordJoinRequest, const FDiscordJoinRequestData&, joinRequest);
|
||||
|
||||
// clang-format on
|
||||
|
||||
|
@ -119,6 +138,12 @@ public:
|
|||
Category = "Discord")
|
||||
FDiscordSpectate OnSpectate;
|
||||
|
||||
UPROPERTY(BlueprintAssignable,
|
||||
meta = (DisplayName = "When Discord another user sends a join request",
|
||||
Keywords = "Discord rpc"),
|
||||
Category = "Discord")
|
||||
FDiscordJoinRequest OnJoinRequest;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite,
|
||||
meta = (DisplayName = "Rich presence info", Keywords = "Discord rpc"),
|
||||
Category = "Discord")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"FileVersion": 3,
|
||||
"EngineAssociation": "4.16",
|
||||
"EngineAssociation": "4.18",
|
||||
"Category": "",
|
||||
"Description": "",
|
||||
"Modules": [
|
||||
|
|
Loading…
Reference in a new issue