wip make plugin do stuff

This commit is contained in:
Chris Marsh 2017-08-09 16:17:26 -07:00
parent 9c6495ab3e
commit 63b467f81d
5 changed files with 62 additions and 3 deletions

View file

@ -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<ANSICHAR>(*applicationId);
Discord_Initialize((const char*)appId.Get(), &handlers, autoRegister);
}
/*static*/ void UDiscordRpcBlueprint::Shutdown()
{
Discord_Shutdown();
}
/*static*/ void UDiscordRpcBlueprint::RunCallbacks()
{
Discord_RunCallbacks();
}

View file

@ -5,8 +5,6 @@
#include "ModuleManager.h" #include "ModuleManager.h"
#include "IPluginManager.h" #include "IPluginManager.h"
#include "discord-rpc.h"
#define LOCTEXT_NAMESPACE "FdiscordrpcModule" #define LOCTEXT_NAMESPACE "FdiscordrpcModule"
void FdiscordrpcModule::StartupModule() void FdiscordrpcModule::StartupModule()

View file

@ -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();
};

View file

@ -35,6 +35,10 @@ public class discordrpc : ModuleRules
PublicDependencyModuleNames.AddRange( PublicDependencyModuleNames.AddRange(
new string[] new string[]
{ {
"CoreUObject",
"Engine",
"Slate",
"SlateCore",
"Core", "Core",
"discordrpcLibrary", "discordrpcLibrary",
"Projects" "Projects"