Refactors in UlxLuaValues, and add cursor-rewind to ReadLuaValues node.
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include <string_view>
|
||||
#include <string>
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Common.h"
|
||||
#include "LuaCall.generated.h"
|
||||
|
||||
class UlxLuaValues;
|
||||
@@ -212,18 +213,9 @@ class INTEGRATION_API UlxLuaValues : public UObject
|
||||
GENERATED_BODY()
|
||||
|
||||
private:
|
||||
// The raw serialized data returned by Lua.
|
||||
// The deserialized values.
|
||||
//
|
||||
std::string Serialized;
|
||||
|
||||
// For each chunk, the type of the chunk.
|
||||
//
|
||||
TArray<ElxLuaValueType> Types;
|
||||
|
||||
// For each chunk, a pointer to the serialized
|
||||
// data.
|
||||
//
|
||||
TArray<std::string_view> Data;
|
||||
TArray<LuaValue> Values;
|
||||
|
||||
// The current cursor.
|
||||
//
|
||||
@@ -233,14 +225,8 @@ private:
|
||||
//
|
||||
int SavedCursor = 0;
|
||||
|
||||
private:
|
||||
// Clear everything.
|
||||
//
|
||||
void Empty();
|
||||
|
||||
// Compare two types for equality.
|
||||
//
|
||||
static ElxSuccessOrWrongType CheckType(ElxLuaValueType Type, ElxLuaValueType Desired);
|
||||
static const ElxSuccessOrWrongType WrongType = ElxSuccessOrWrongType::WrongType;
|
||||
static const ElxSuccessOrWrongType Success = ElxSuccessOrWrongType::Success;
|
||||
|
||||
public:
|
||||
UlxLuaValues() {}
|
||||
@@ -264,13 +250,13 @@ public:
|
||||
// Return the number of elements remaining after the cursor.
|
||||
//
|
||||
UFUNCTION(BlueprintPure, Category = "Luprex|Lua Value Array")
|
||||
int Length() const { return Types.Num() - Cursor; }
|
||||
int Length() const { return Values.Num() - Cursor; }
|
||||
|
||||
// Return the total number of elements, including both those
|
||||
// before and after the cursor.
|
||||
//
|
||||
UFUNCTION(BlueprintPure, Category = "Luprex|Lua Value Array")
|
||||
int TotalLength() const { return Types.Num(); }
|
||||
int TotalLength() const { return Values.Num(); }
|
||||
|
||||
// Get the current position of the cursor.
|
||||
//
|
||||
@@ -281,7 +267,7 @@ public:
|
||||
// be within the array.
|
||||
//
|
||||
UFUNCTION(BlueprintCallable, Category = "Luprex|Lua Value Array")
|
||||
void SetCursor(int n) { Cursor = FMath::Clamp(n, 0, Types.Num()); }
|
||||
void SetCursor(int n) { Cursor = FMath::Clamp(n, 0, Values.Num()); }
|
||||
|
||||
// Get the type of the next element.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user