A lot of work on the Lua Call interface and some work on animation queues
This commit is contained in:
@@ -1,8 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "EdGraph/EdGraphPin.h"
|
||||
#include "LuaCall.generated.h"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// These are the types that can actually be packed into
|
||||
// an argument or return value buffer. Any other type is
|
||||
// subject to conversion before packing.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class ELpxSimpleDynamicTag : uint8 {
|
||||
None,
|
||||
@@ -13,13 +23,88 @@ enum class ELpxSimpleDynamicTag : uint8 {
|
||||
Vector
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This UClass is never instantiated. It exists to
|
||||
// expose certain static functions to the blueprint
|
||||
// library.
|
||||
// This is a little parser that parses Lua function 'prototypes'.
|
||||
// The prototypes look like this:
|
||||
//
|
||||
////////////////////////////////////////////////
|
||||
// class.name(int arg1, int arg2) : int ret1, int ret2
|
||||
//
|
||||
// The return values can be omitted if the function has no return
|
||||
// values. Optionally, there can be one last return value which
|
||||
// is just an ellipsis. The class name can be asterisk.
|
||||
//
|
||||
// For more information about the meaning of all this, see the docs
|
||||
// for the 'Call Lua' blueprint node.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
class FlxParsedProto
|
||||
{
|
||||
public:
|
||||
struct Pin
|
||||
{
|
||||
FString Type;
|
||||
FString Name;
|
||||
Pin(const FString &T, const FString &N) : Type(T), Name(N) {}
|
||||
};
|
||||
|
||||
FString ErrorMessage;
|
||||
TArray<FString> Tokens;
|
||||
int NextToken;
|
||||
FString ClassName;
|
||||
FString FunctionName;
|
||||
TArray<Pin> Arguments;
|
||||
TArray<Pin> ReturnValues;
|
||||
bool ExtraReturnValues;
|
||||
|
||||
private:
|
||||
// Check the next token to see if it's exactly equal to text.
|
||||
//
|
||||
bool IsLiteral(const TCHAR *text);
|
||||
|
||||
// Check the next token to see if it's an identifier.
|
||||
//
|
||||
bool IsIdent();
|
||||
|
||||
// Make a syntax error message, using the tokens.
|
||||
//
|
||||
void Syntax();
|
||||
|
||||
// Empty out the FlxParsedProto.
|
||||
//
|
||||
void Empty();
|
||||
|
||||
// Parse a function prototype.
|
||||
//
|
||||
void Parse(const FString &proto);
|
||||
|
||||
public:
|
||||
// Construct with a prototype.
|
||||
//
|
||||
FlxParsedProto(const FString &str) { Parse(str); }
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// To make a Lua Call from inside of a blueprint, use the convenient "Call Lua"
|
||||
// blueprint node. This node macroexpands into a sequence of low-level
|
||||
// function calls. This library contains the low-level functions that
|
||||
// "Call Lua" macroexpands into.
|
||||
//
|
||||
// The procedure for making a lua call using the low-level functions is as follows:
|
||||
//
|
||||
// * Use LuaCallBegin to put the class name and function name into the argument buffer.
|
||||
// * Use LuaCallArgumentXXX to put arguments into the argument buffer.
|
||||
// * Use LuaCallInvoke or LuaCallProbe to actually make the call.
|
||||
// * Use LuaCallReturnValueXXX to fetch return values from the return buffer.
|
||||
//
|
||||
// The two buffers are basically global variables, they are part of the
|
||||
// IntegrationGameModeBase. This is okay because blueprint is single-threaded.
|
||||
//
|
||||
// The following three libraries contain all the low-level functions.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
UCLASS()
|
||||
class INTEGRATION_API UlxLuaCallLibrary : public UObject
|
||||
@@ -27,30 +112,25 @@ class INTEGRATION_API UlxLuaCallLibrary : public UObject
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Get an argument packing function or a return value unpacking function.
|
||||
//
|
||||
static UFunction *GetArgumentPacker(const FString &Type);
|
||||
static UFunction *GetReturnValueUnpacker(const FString &Type);
|
||||
|
||||
// Get the types supported for arguments and return values, as a documentation string.
|
||||
//
|
||||
static FString AllFunctionsWithPrefix(const TCHAR *Prefix);
|
||||
static FString AllKnownArgumentTypes() { return AllFunctionsWithPrefix(TEXT("LuaCallArgument_")); }
|
||||
static FString AllKnownReturnValueTypes() { return AllFunctionsWithPrefix(TEXT("LuaCallReturnValue_")); }
|
||||
|
||||
public:
|
||||
//
|
||||
// Functions that do miscellaneous things.
|
||||
//
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static void LuaCallBegin(UObject *context, const FString &ClassName, const FString &FunctionName);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static void LuaCallAddStringParameter(UObject *context, const FString &Value);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static void LuaCallAddNameParameter(UObject *context, const FName &Value);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static void LuaCallAddFloatParameter(UObject *context, double Value);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static void LuaCallAddIntParameter(UObject *context, int Value);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static void LuaCallAddVectorParameter(UObject *context, const FVector &Value);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static void LuaCallAddVector2DParameter(UObject *context, const FVector2D &Value);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static void LuaCallAddBooleanParameter(UObject *context, bool Value);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static void LuaCallInvoke(UObject *context, AActor *Place);
|
||||
|
||||
@@ -63,19 +143,55 @@ public:
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static ELpxSimpleDynamicTag LuaCallNextResultType(UObject *context);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static FString LuaCallGetStringResult(UObject *context);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static FName LuaCallGetNameResult(UObject *context);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static double LuaCallGetFloatResult(UObject *context);
|
||||
//
|
||||
// Functions that pack arguments into the call buffer.
|
||||
//
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static FVector LuaCallGetVectorResult(UObject *context);
|
||||
static void LuaCallArgument_string(UObject *context, const FString &Value);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static bool LuaCallGetBooleanResult(UObject *context);
|
||||
static void LuaCallArgument_name(UObject *context, const FName &Value);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static void LuaCallArgument_float(UObject *context, double Value);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static void LuaCallArgument_int(UObject *context, int Value);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static void LuaCallArgument_vector(UObject *context, const FVector &Value);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static void LuaCallArgument_vector2d(UObject *context, const FVector2D &Value);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static void LuaCallArgument_boolean(UObject *context, bool Value);
|
||||
|
||||
//
|
||||
// Functions that extract return values from the return buffer.
|
||||
//
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static FString LuaCallReturnValue_string(UObject *context);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static FName LuaCallReturnValue_name(UObject *context);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static double LuaCallReturnValue_float(UObject *context);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static int LuaCallReturnValue_int(UObject *context);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static FVector LuaCallReturnValue_vector(UObject *context);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static FVector2D LuaCallReturnValue_vector2d(UObject *context);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"), Category = "Luprex|Call Lua Function")
|
||||
static bool LuaCallReturnValue_boolean(UObject *context);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user