Platform whitelist, mac support, compilation fix.
This commit is contained in:
parent
5a28e652df
commit
6cbbd3b5c2
@ -17,7 +17,13 @@
|
|||||||
{
|
{
|
||||||
"Name": "DiscordRpc",
|
"Name": "DiscordRpc",
|
||||||
"Type": "Runtime",
|
"Type": "Runtime",
|
||||||
"LoadingPhase": "PreDefault"
|
"LoadingPhase": "PreDefault",
|
||||||
|
"WhitelistPlatforms" :
|
||||||
|
[
|
||||||
|
"Win64",
|
||||||
|
"Linux",
|
||||||
|
"Mac"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -1,10 +1,15 @@
|
|||||||
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
|
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
using UnrealBuildTool;
|
using UnrealBuildTool;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
public class discordrpc : ModuleRules
|
public class DiscordRpc : ModuleRules
|
||||||
{
|
{
|
||||||
public discordrpc(ReadOnlyTargetRules Target) : base(Target)
|
#if WITH_FORWARDED_MODULE_RULES_CTOR
|
||||||
|
public DiscordRpc(ReadOnlyTargetRules Target) : base(Target)
|
||||||
|
#else
|
||||||
|
public DiscordRpc(TargetInfo Target)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
Definitions.Add("DISCORD_DYNAMIC_LIB=1");
|
Definitions.Add("DISCORD_DYNAMIC_LIB=1");
|
||||||
|
|
||||||
@ -24,6 +29,7 @@ public class discordrpc : ModuleRules
|
|||||||
new string[]
|
new string[]
|
||||||
{
|
{
|
||||||
"Core",
|
"Core",
|
||||||
|
"DiscordRpcLibrary"
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -45,7 +51,7 @@ public class discordrpc : ModuleRules
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
string BaseDirectory = Path.GetFullPath(Path.Combine(ModuleDirectory, "..", "..", "ThirdParty", "DiscordRpcLibrary"));
|
string BaseDirectory = Path.GetFullPath(Path.Combine(ModuleDirectory, "..", "..", "Source", "ThirdParty", "DiscordRpcLibrary"));
|
||||||
PublicIncludePaths.Add(Path.Combine(BaseDirectory, "Include"));
|
PublicIncludePaths.Add(Path.Combine(BaseDirectory, "Include"));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,7 +12,7 @@ void FDiscordRpcModule::StartupModule()
|
|||||||
#if defined(DISCORD_DYNAMIC_LIB)
|
#if defined(DISCORD_DYNAMIC_LIB)
|
||||||
// Get the base directory of this plugin
|
// Get the base directory of this plugin
|
||||||
FString BaseDir = IPluginManager::Get().FindPlugin("DiscordRpc")->GetBaseDir();
|
FString BaseDir = IPluginManager::Get().FindPlugin("DiscordRpc")->GetBaseDir();
|
||||||
const FString SDKDir = FPaths::Combine(*BaseDir, TEXT("ThirdParty"), TEXT("DiscordRpcLibrary"));
|
const FString SDKDir = FPaths::Combine(*BaseDir, TEXT("Source"), TEXT("ThirdParty"), TEXT("DiscordRpcLibrary"));
|
||||||
#if PLATFORM_WINDOWS
|
#if PLATFORM_WINDOWS
|
||||||
const FString LibName = TEXT("discord-rpc");
|
const FString LibName = TEXT("discord-rpc");
|
||||||
const FString LibDir = FPaths::Combine(*SDKDir, TEXT("Win64"));
|
const FString LibDir = FPaths::Combine(*SDKDir, TEXT("Win64"));
|
||||||
@ -42,7 +42,7 @@ void FDiscordRpcModule::ShutdownModule()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FDiscordAPIModule::LoadDependency(const FString& Dir, const FString& Name, void*& Handle)
|
bool FDiscordRpcModule::LoadDependency(const FString& Dir, const FString& Name, void*& Handle)
|
||||||
{
|
{
|
||||||
FString Lib = Name + TEXT(".") + FPlatformProcess::GetModuleExtension();
|
FString Lib = Name + TEXT(".") + FPlatformProcess::GetModuleExtension();
|
||||||
FString Path = Dir.IsEmpty() ? *Lib : FPaths::Combine(*Dir, *Lib);
|
FString Path = Dir.IsEmpty() ? *Lib : FPaths::Combine(*Dir, *Lib);
|
||||||
@ -57,7 +57,7 @@ bool FDiscordAPIModule::LoadDependency(const FString& Dir, const FString& Name,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FDiscordAPIModule::FreeDependency(void*& Handle)
|
void FDiscordRpcModule::FreeDependency(void*& Handle)
|
||||||
{
|
{
|
||||||
if (Handle != nullptr)
|
if (Handle != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "DicordRpcPrivatePCH"
|
#include "DiscordRpcPrivatePCH.h"
|
||||||
#include "DiscordRpcBlueprint.h"
|
#include "DiscordRpcBlueprint.h"
|
||||||
#include "discord-rpc.h"
|
#include "discord-rpc.h"
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/** Handle to the test dll we will load */
|
/** Handle to the test dll we will load */
|
||||||
void* DiscordLibraryHandle;
|
void* DiscordRpcLibraryHandle;
|
||||||
|
|
||||||
/** StartupModule is covered with defines, these functions are the place to put breakpoints */
|
/** StartupModule is covered with defines, these functions are the place to put breakpoints */
|
||||||
static bool LoadDependency(const FString& Dir, const FString& Name, void*& Handle);
|
static bool LoadDependency(const FString& Dir, const FString& Name, void*& Handle);
|
||||||
|
@ -3,14 +3,18 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using UnrealBuildTool;
|
using UnrealBuildTool;
|
||||||
|
|
||||||
public class discordrpcLibrary : ModuleRules
|
public class DiscordRpcLibrary : ModuleRules
|
||||||
{
|
{
|
||||||
public discordrpcLibrary(ReadOnlyTargetRules Target) : base(Target)
|
#if WITH_FORWARDED_MODULE_RULES_CTOR
|
||||||
|
public DiscordRpcLibrary(ReadOnlyTargetRules Target) : base(Target)
|
||||||
|
#else
|
||||||
|
public DiscordRpcLibrary(TargetInfo Target)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
Type = ModuleType.External;
|
Type = ModuleType.External;
|
||||||
Definitions.Add("DISCORD_DYNAMIC_LIB=1");
|
Definitions.Add("DISCORD_DYNAMIC_LIB=1");
|
||||||
|
|
||||||
string BaseDirectory = Path.GetFullPath(Path.Combine(ModuleDirectory, "..", "..", "ThirdParty", "discordrpc"));
|
string BaseDirectory = Path.GetFullPath(Path.Combine(ModuleDirectory, "..", "..", "ThirdParty", "DiscordRpcLibrary"));
|
||||||
|
|
||||||
if (Target.Platform == UnrealTargetPlatform.Win64)
|
if (Target.Platform == UnrealTargetPlatform.Win64)
|
||||||
{
|
{
|
||||||
@ -39,5 +43,17 @@ public class discordrpcLibrary : ModuleRules
|
|||||||
PublicAdditionalLibraries.Add(Path.Combine(lib, "libdiscord-rpc.so"));
|
PublicAdditionalLibraries.Add(Path.Combine(lib, "libdiscord-rpc.so"));
|
||||||
RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(lib, "libdiscord-rpc.so")));
|
RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(lib, "libdiscord-rpc.so")));
|
||||||
}
|
}
|
||||||
|
else if (Target.Platform == UnrealTargetPlatform.Mac)
|
||||||
|
{
|
||||||
|
string lib = Path.Combine(BaseDirectory, "Mac");
|
||||||
|
|
||||||
|
// Include headers
|
||||||
|
PublicIncludePaths.Add(Path.Combine(BaseDirectory, "Include"));
|
||||||
|
|
||||||
|
// Add the import library
|
||||||
|
PublicLibraryPaths.Add(lib);
|
||||||
|
PublicAdditionalLibraries.Add(Path.Combine(lib, "libdiscord-rpc.dylib"));
|
||||||
|
RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(lib, "libdiscord-rpc.dylib")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,84 +1,85 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
|
||||||
#if defined(DISCORD_DYNAMIC_LIB)
|
#if defined(DISCORD_DYNAMIC_LIB)
|
||||||
# if defined(_WIN32)
|
# if defined(_WIN32)
|
||||||
# if defined(DISCORD_BUILDING_SDK)
|
# if defined(DISCORD_BUILDING_SDK)
|
||||||
# define DISCORD_EXPORT __declspec(dllexport)
|
# define DISCORD_EXPORT __declspec(dllexport)
|
||||||
# else
|
# else
|
||||||
# define DISCORD_EXPORT __declspec(dllimport)
|
# define DISCORD_EXPORT __declspec(dllimport)
|
||||||
# endif
|
# endif
|
||||||
# else
|
# else
|
||||||
# define DISCORD_EXPORT __attribute__((visibility("default")))
|
# define DISCORD_EXPORT __attribute__((visibility("default")))
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# define DISCORD_EXPORT
|
# define DISCORD_EXPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct DiscordRichPresence {
|
typedef struct DiscordRichPresence {
|
||||||
const char* state; /* max 128 bytes */
|
const char* state; /* max 128 bytes */
|
||||||
const char* details; /* max 128 bytes */
|
const char* details; /* max 128 bytes */
|
||||||
int64_t startTimestamp;
|
int64_t startTimestamp;
|
||||||
int64_t endTimestamp;
|
int64_t endTimestamp;
|
||||||
const char* largeImageKey; /* max 32 bytes */
|
const char* largeImageKey; /* max 32 bytes */
|
||||||
const char* largeImageText; /* max 128 bytes */
|
const char* largeImageText; /* max 128 bytes */
|
||||||
const char* smallImageKey; /* max 32 bytes */
|
const char* smallImageKey; /* max 32 bytes */
|
||||||
const char* smallImageText; /* max 128 bytes */
|
const char* smallImageText; /* max 128 bytes */
|
||||||
const char* partyId; /* max 128 bytes */
|
const char* partyId; /* max 128 bytes */
|
||||||
int partySize;
|
int partySize;
|
||||||
int partyMax;
|
int partyMax;
|
||||||
const char* matchSecret; /* max 128 bytes */
|
const char* matchSecret; /* max 128 bytes */
|
||||||
const char* joinSecret; /* max 128 bytes */
|
const char* joinSecret; /* max 128 bytes */
|
||||||
const char* spectateSecret; /* max 128 bytes */
|
const char* spectateSecret; /* max 128 bytes */
|
||||||
int8_t instance;
|
int8_t instance;
|
||||||
} DiscordRichPresence;
|
} DiscordRichPresence;
|
||||||
|
|
||||||
typedef struct DiscordJoinRequest {
|
typedef struct DiscordJoinRequest {
|
||||||
const char* userId;
|
const char* userId;
|
||||||
const char* username;
|
const char* username;
|
||||||
const char* discriminator;
|
const char* discriminator;
|
||||||
const char* avatar;
|
const char* avatar;
|
||||||
} DiscordJoinRequest;
|
} DiscordJoinRequest;
|
||||||
|
|
||||||
typedef struct DiscordEventHandlers {
|
typedef struct DiscordEventHandlers {
|
||||||
void (*ready)();
|
void (*ready)(void);
|
||||||
void (*disconnected)(int errorCode, const char* message);
|
void (*disconnected)(int errorCode, const char* message);
|
||||||
void (*errored)(int errorCode, const char* message);
|
void (*errored)(int errorCode, const char* message);
|
||||||
void (*joinGame)(const char* joinSecret);
|
void (*joinGame)(const char* joinSecret);
|
||||||
void (*spectateGame)(const char* spectateSecret);
|
void (*spectateGame)(const char* spectateSecret);
|
||||||
void (*joinRequest)(const DiscordJoinRequest* request);
|
void (*joinRequest)(const DiscordJoinRequest* request);
|
||||||
} DiscordEventHandlers;
|
} DiscordEventHandlers;
|
||||||
|
|
||||||
#define DISCORD_REPLY_NO 0
|
#define DISCORD_REPLY_NO 0
|
||||||
#define DISCORD_REPLY_YES 1
|
#define DISCORD_REPLY_YES 1
|
||||||
#define DISCORD_REPLY_IGNORE 2
|
#define DISCORD_REPLY_IGNORE 2
|
||||||
|
|
||||||
DISCORD_EXPORT void Discord_Initialize(const char* applicationId,
|
DISCORD_EXPORT void Discord_Initialize(const char* applicationId,
|
||||||
DiscordEventHandlers* handlers,
|
DiscordEventHandlers* handlers,
|
||||||
int autoRegister,
|
int autoRegister,
|
||||||
const char* optionalSteamId);
|
const char* optionalSteamId);
|
||||||
DISCORD_EXPORT void Discord_Shutdown(void);
|
DISCORD_EXPORT void Discord_Shutdown(void);
|
||||||
|
|
||||||
/* checks for incoming messages, dispatches callbacks */
|
/* checks for incoming messages, dispatches callbacks */
|
||||||
DISCORD_EXPORT void Discord_RunCallbacks(void);
|
DISCORD_EXPORT void Discord_RunCallbacks(void);
|
||||||
|
|
||||||
/* If you disable the lib starting its own io thread, you'll need to call this from your own */
|
/* If you disable the lib starting its own io thread, you'll need to call this from your own */
|
||||||
#ifdef DISCORD_DISABLE_IO_THREAD
|
#ifdef DISCORD_DISABLE_IO_THREAD
|
||||||
DISCORD_EXPORT void Discord_UpdateConnection(void);
|
DISCORD_EXPORT void Discord_UpdateConnection(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence* presence);
|
DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence* presence);
|
||||||
|
DISCORD_EXPORT void Discord_ClearPresence(void);
|
||||||
DISCORD_EXPORT void Discord_Respond(const char* userid, /* DISCORD_REPLY_ */ int reply);
|
|
||||||
|
DISCORD_EXPORT void Discord_Respond(const char* userid, /* DISCORD_REPLY_ */ int reply);
|
||||||
#ifdef __cplusplus
|
|
||||||
} /* extern "C" */
|
#ifdef __cplusplus
|
||||||
#endif
|
} /* extern "C" */
|
||||||
|
#endif
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user