diff --git a/examples/unrealstatus/Content/ShowTheUILevel.umap b/examples/unrealstatus/Content/ShowTheUILevel.umap index 39b23e2..d99a0aa 100644 Binary files a/examples/unrealstatus/Content/ShowTheUILevel.umap and b/examples/unrealstatus/Content/ShowTheUILevel.umap differ diff --git a/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Private/DiscordRpcBlueprint.cpp b/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Private/DiscordRpcBlueprint.cpp new file mode 100644 index 0000000..9635288 --- /dev/null +++ b/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Private/DiscordRpcBlueprint.cpp @@ -0,0 +1,30 @@ + + +#include "DiscordRpcBlueprint.h" + +#include "discord-rpc.h" + +DEFINE_LOG_CATEGORY(DiscordLogCategory) + +/*static*/ void UDiscordRpcBlueprint::Initialize(const FString& applicationId, bool autoRegister) +{ + DiscordEventHandlers handlers{}; + handlers.ready = []() { + UE_LOG(DiscordLogCategory, Log, TEXT("Discord connected")); + }; + handlers.disconnected = [](int errorCode, const char* message) { + UE_LOG(DiscordLogCategory, Log, TEXT("Discord disconnected (%d): %s"), errorCode, message); + }; + auto appId = StringCast(*applicationId); + Discord_Initialize((const char*)appId.Get(), &handlers, autoRegister); +} + +/*static*/ void UDiscordRpcBlueprint::Shutdown() +{ + Discord_Shutdown(); +} + +/*static*/ void UDiscordRpcBlueprint::RunCallbacks() +{ + Discord_RunCallbacks(); +} diff --git a/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Private/discordrpc.cpp b/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Private/discordrpc.cpp index 132fa23..13e1380 100644 --- a/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Private/discordrpc.cpp +++ b/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Private/discordrpc.cpp @@ -5,8 +5,6 @@ #include "ModuleManager.h" #include "IPluginManager.h" -#include "discord-rpc.h" - #define LOCTEXT_NAMESPACE "FdiscordrpcModule" void FdiscordrpcModule::StartupModule() diff --git a/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Public/DiscordRpcBlueprint.h b/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Public/DiscordRpcBlueprint.h new file mode 100644 index 0000000..0141256 --- /dev/null +++ b/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Public/DiscordRpcBlueprint.h @@ -0,0 +1,27 @@ + + +#pragma once + +#include "Engine.h" +#include "CoreMinimal.h" +#include "DiscordRpcBlueprint.generated.h" + +DECLARE_LOG_CATEGORY_EXTERN(DiscordLogCategory, Log, All); + +/** + * + */ +UCLASS() +class DISCORDRPC_API UDiscordRpcBlueprint : public UBlueprintFunctionLibrary +{ + GENERATED_BODY() + + UFUNCTION(BlueprintCallable, meta = (DisplayName = "Discord Initialize connection", Keywords = "Discord rpc"), Category = "Discord") + static void Initialize(const FString& applicationId, bool autoRegister); + + UFUNCTION(BlueprintCallable, meta = (DisplayName = "Discord shut down connection", Keywords = "Discord rpc"), Category = "Discord") + static void Shutdown(); + + UFUNCTION(BlueprintCallable, meta = (DisplayName = "Discord check for callbacks", Keywords = "Discord rpc"), Category = "Discord") + static void RunCallbacks(); +}; diff --git a/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/discordrpc.Build.cs b/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/discordrpc.Build.cs index 7d9af83..d34e809 100644 --- a/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/discordrpc.Build.cs +++ b/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/discordrpc.Build.cs @@ -35,7 +35,11 @@ public class discordrpc : ModuleRules PublicDependencyModuleNames.AddRange( new string[] { - "Core", + "CoreUObject", + "Engine", + "Slate", + "SlateCore", + "Core", "discordrpcLibrary", "Projects" // ... add other public dependencies that you statically link with here ...