Register upgrade (#2)
* Update init to take an optional Steam ID. Add register for steam game. Remove url from cmd line params to launched game. * Start on a build script
This commit is contained in:
1
examples/button-clicker/.gitignore
vendored
1
examples/button-clicker/.gitignore
vendored
@ -3,3 +3,4 @@
|
||||
/obj/
|
||||
*.sln
|
||||
*.csproj
|
||||
*.userprefs
|
@ -5,6 +5,7 @@ using UnityEngine;
|
||||
public class DiscordController : MonoBehaviour {
|
||||
public DiscordRpc.RichPresence presence;
|
||||
public string applicationId;
|
||||
public string optionalSteamId;
|
||||
public int callbackCalls;
|
||||
public int clickCounter;
|
||||
public UnityEngine.Events.UnityEvent onConnect;
|
||||
@ -72,7 +73,7 @@ public class DiscordController : MonoBehaviour {
|
||||
handlers.errorCallback += ErrorCallback;
|
||||
handlers.joinCallback += JoinCallback;
|
||||
handlers.spectateCallback += SpectateCallback;
|
||||
DiscordRpc.Initialize(applicationId, ref handlers, true);
|
||||
DiscordRpc.Initialize(applicationId, ref handlers, true, optionalSteamId);
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
|
@ -47,7 +47,7 @@ public class DiscordRpc
|
||||
}
|
||||
|
||||
[DllImport("discord-rpc", EntryPoint = "Discord_Initialize")]
|
||||
public static extern void Initialize(string applicationId, ref EventHandlers handlers, bool autoRegister);
|
||||
public static extern void Initialize(string applicationId, ref EventHandlers handlers, bool autoRegister, string optionalSteamId);
|
||||
|
||||
[DllImport("discord-rpc", EntryPoint = "Discord_Shutdown")]
|
||||
public static extern void Shutdown();
|
||||
|
Binary file not shown.
@ -668,6 +668,7 @@ MonoBehaviour:
|
||||
spectateSecret:
|
||||
instance: 0
|
||||
applicationId: 345229890980937739
|
||||
optionalSteamId:
|
||||
callbackCalls: 0
|
||||
clickCounter: 0
|
||||
onConnect:
|
||||
|
@ -86,7 +86,7 @@ static void discordInit()
|
||||
handlers.errored = handleDiscordError;
|
||||
handlers.joinGame = handleDiscordJoin;
|
||||
handlers.spectateGame = handleDiscordSpectate;
|
||||
Discord_Initialize(APPLICATION_ID, &handlers, 1);
|
||||
Discord_Initialize(APPLICATION_ID, &handlers, 1, NULL);
|
||||
}
|
||||
|
||||
static void gameLoop()
|
||||
|
Binary file not shown.
@ -53,7 +53,9 @@ static void SpectateGameHandler(const char* spectateSecret)
|
||||
}
|
||||
}
|
||||
|
||||
void UDiscordRpc::Initialize(const FString& applicationId, bool autoRegister)
|
||||
void UDiscordRpc::Initialize(const FString& applicationId,
|
||||
bool autoRegister,
|
||||
const FString& optionalSteamId)
|
||||
{
|
||||
self = this;
|
||||
IsConnected = false;
|
||||
@ -68,7 +70,8 @@ void UDiscordRpc::Initialize(const FString& applicationId, bool autoRegister)
|
||||
handlers.spectateGame = SpectateGameHandler;
|
||||
}
|
||||
auto appId = StringCast<ANSICHAR>(*applicationId);
|
||||
Discord_Initialize((const char*)appId.Get(), &handlers, autoRegister);
|
||||
auto steamId = StringCast<ANSICHAR>(*optionalSteamId);
|
||||
Discord_Initialize((const char*)appId.Get(), &handlers, autoRegister, (const char*)steamId.Get());
|
||||
}
|
||||
|
||||
void UDiscordRpc::Shutdown()
|
||||
|
@ -6,22 +6,19 @@
|
||||
#include "CoreMinimal.h"
|
||||
#include "DiscordRpcBlueprint.generated.h"
|
||||
|
||||
// unreal's header tool hates clang-format
|
||||
// clang-format off
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(Discord, Log, All);
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FDiscordConnected);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FDiscordDisconnected,
|
||||
int,
|
||||
errorCode,
|
||||
const FString&,
|
||||
errorMessage);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FDiscordErrored,
|
||||
int,
|
||||
errorCode,
|
||||
const FString&,
|
||||
errorMessage);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FDiscordDisconnected, int, errorCode, const FString&, errorMessage);
|
||||
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);
|
||||
|
||||
// clang-format on
|
||||
|
||||
/**
|
||||
* Rich presence data
|
||||
*/
|
||||
@ -73,7 +70,7 @@ public:
|
||||
UFUNCTION(BlueprintCallable,
|
||||
meta = (DisplayName = "Initialize connection", Keywords = "Discord rpc"),
|
||||
Category = "Discord")
|
||||
void Initialize(const FString& applicationId, bool autoRegister);
|
||||
void Initialize(const FString& applicationId, bool autoRegister, const FString& optionalSteamId);
|
||||
|
||||
UFUNCTION(BlueprintCallable,
|
||||
meta = (DisplayName = "Shut down connection", Keywords = "Discord rpc"),
|
||||
|
Reference in New Issue
Block a user