diff --git a/examples/unrealstatus/Plugins/discordrpc/Resources/Icon128.png b/examples/unrealstatus/Plugins/discordrpc/Resources/Icon128.png new file mode 100644 index 0000000..8b7f8e1 Binary files /dev/null and b/examples/unrealstatus/Plugins/discordrpc/Resources/Icon128.png differ diff --git a/examples/unrealstatus/Plugins/discordrpc/Resources/discord.png b/examples/unrealstatus/Plugins/discordrpc/Resources/discord.png new file mode 100644 index 0000000..8b7f8e1 Binary files /dev/null and b/examples/unrealstatus/Plugins/discordrpc/Resources/discord.png differ diff --git a/examples/unrealstatus/Plugins/discordrpc/Source/ThirdParty/discordrpcLibrary/discordrpcLibrary.Build.cs b/examples/unrealstatus/Plugins/discordrpc/Source/ThirdParty/discordrpcLibrary/discordrpcLibrary.Build.cs new file mode 100644 index 0000000..0e0159a --- /dev/null +++ b/examples/unrealstatus/Plugins/discordrpc/Source/ThirdParty/discordrpcLibrary/discordrpcLibrary.Build.cs @@ -0,0 +1,26 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +using System.IO; +using UnrealBuildTool; + +public class discordrpcLibrary : ModuleRules +{ + public discordrpcLibrary(ReadOnlyTargetRules Target) : base(Target) + { + Type = ModuleType.External; + + if (Target.Platform == UnrealTargetPlatform.Win64) + { + // Add the import library + PublicLibraryPaths.Add(Path.Combine(ModuleDirectory, "x64", "Release")); + PublicAdditionalLibraries.Add("discord-rpc.lib"); + + // Delay-load the DLL, so we can load it from the right place first + PublicDelayLoadDLLs.Add("discord-rpc.dll"); + } + else if (Target.Platform == UnrealTargetPlatform.Mac) + { + PublicDelayLoadDLLs.Add(Path.Combine(ModuleDirectory, "Mac", "Release", "libdiscord-rpc.dylib")); + } + } +} diff --git a/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Private/discordrpc.cpp b/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Private/discordrpc.cpp new file mode 100644 index 0000000..7721f7f --- /dev/null +++ b/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Private/discordrpc.cpp @@ -0,0 +1,53 @@ +// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. + +#include "discordrpc.h" +#include "Core.h" +#include "ModuleManager.h" +#include "IPluginManager.h" + +#define DISCORD_DYNAMIC_LIB +//#include "../../../../../../../include/discord-rpc.h" +#include "discord-rpc.h" + +#define LOCTEXT_NAMESPACE "FdiscordrpcModule" + +void FdiscordrpcModule::StartupModule() +{ + // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module + + // Get the base directory of this plugin + FString BaseDir = IPluginManager::Get().FindPlugin("discordrpc")->GetBaseDir(); + + // Add on the relative location of the third party dll and load it + FString LibraryPath; +#if PLATFORM_WINDOWS + LibraryPath = FPaths::Combine(*BaseDir, TEXT("Binaries/ThirdParty/discordrpcLibrary/Win64/discord-rpc.dll")); +#elif PLATFORM_MAC + LibraryPath = FPaths::Combine(*BaseDir, TEXT("Source/ThirdParty/discordrpcLibrary/Mac/Release/libdiscord-rpc.dylib")); +#endif // PLATFORM_WINDOWS + + ExampleLibraryHandle = !LibraryPath.IsEmpty() ? FPlatformProcess::GetDllHandle(*LibraryPath) : nullptr; + + if (ExampleLibraryHandle) + { + Discord_Initialize("344609418631053312", nullptr, false); + } + else + { + FMessageDialog::Open(EAppMsgType::Ok, LOCTEXT("ThirdPartyLibraryError", "Failed to load example third party library")); + } +} + +void FdiscordrpcModule::ShutdownModule() +{ + // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, + // we call this function before unloading the module. + + // Free the dll handle + FPlatformProcess::FreeDllHandle(ExampleLibraryHandle); + ExampleLibraryHandle = nullptr; +} + +#undef LOCTEXT_NAMESPACE + +IMPLEMENT_MODULE(FdiscordrpcModule, discordrpc) \ No newline at end of file diff --git a/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Public/discordrpc.h b/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Public/discordrpc.h new file mode 100644 index 0000000..f9a7af3 --- /dev/null +++ b/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/Public/discordrpc.h @@ -0,0 +1,18 @@ +// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. + +#pragma once + +#include "ModuleManager.h" + +class FdiscordrpcModule : public IModuleInterface +{ +public: + + /** IModuleInterface implementation */ + virtual void StartupModule() override; + virtual void ShutdownModule() override; + +private: + /** Handle to the test dll we will load */ + void* ExampleLibraryHandle; +}; \ No newline at end of file diff --git a/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/discordrpc.Build.cs b/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/discordrpc.Build.cs new file mode 100644 index 0000000..698b809 --- /dev/null +++ b/examples/unrealstatus/Plugins/discordrpc/Source/discordrpc/discordrpc.Build.cs @@ -0,0 +1,60 @@ +// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. + +using UnrealBuildTool; + +public class discordrpc : ModuleRules +{ + public discordrpc(ReadOnlyTargetRules Target) : base(Target) + { + PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; + + PublicIncludePaths.AddRange( + new string[] { + "discordrpc/Public" + // ... add public include paths required here ... + } + ); + + + PrivateIncludePaths.AddRange( + new string[] { + "discordrpc/Private", + "../../../../../include" + // ... add other private include paths required here ... + } + ); + + PublicLibraryPaths.AddRange( + new string[] { + "Binaries/ThirdParty/discordrpcLibrary/Win64", + } + ); + + + PublicDependencyModuleNames.AddRange( + new string[] + { + "Core", + "discordrpcLibrary", + "Projects" + // ... add other public dependencies that you statically link with here ... + } + ); + + + PrivateDependencyModuleNames.AddRange( + new string[] + { + // ... add private dependencies that you statically link with here ... + } + ); + + + DynamicallyLoadedModuleNames.AddRange( + new string[] + { + // ... add any modules that your module loads dynamically here ... + } + ); + } +} diff --git a/examples/unrealstatus/Plugins/discordrpc/discordrpc.uplugin b/examples/unrealstatus/Plugins/discordrpc/discordrpc.uplugin new file mode 100644 index 0000000..ca77578 --- /dev/null +++ b/examples/unrealstatus/Plugins/discordrpc/discordrpc.uplugin @@ -0,0 +1,23 @@ +{ + "FileVersion": 3, + "Version": 1, + "VersionName": "1.0", + "FriendlyName": "Discord RPC", + "Description": "Wrap the Discord RPC library.", + "Category": "Messaging", + "CreatedBy": "Chris Marsh ", + "CreatedByURL": "https://discordapp.com/", + "DocsURL": "", + "MarketplaceURL": "", + "SupportURL": "", + "CanContainContent": true, + "IsBetaVersion": true, + "Installed": false, + "Modules": [ + { + "Name": "discordrpc", + "Type": "Developer", + "LoadingPhase": "Default" + } + ] +} \ No newline at end of file