Got the whole look-at demo up and running.
This commit is contained in:
@@ -505,78 +505,100 @@ FString UlxLuaValues::DebugString() const
|
||||
return Output.ToString();
|
||||
}
|
||||
|
||||
bool UlxLuaValues::CheckType(ElxLuaValueType Type, ElxLuaValueType Desired)
|
||||
ElxSuccessOrError UlxLuaValues::CheckType(ElxLuaValueType Type, ElxLuaValueType Desired)
|
||||
{
|
||||
if (Type != Desired)
|
||||
{
|
||||
FString TypeName = StaticEnum<ElxLuaValueType>()->GetDisplayNameTextByValue(int64(Type)).ToString();
|
||||
FString DesiredName = StaticEnum<ElxLuaValueType>()->GetDisplayNameTextByValue(int64(Desired)).ToString();
|
||||
UE_LOG(LogBlueprint, Error, TEXT("Expected a value of type %s, but found %s instead."), *DesiredName, *TypeName);
|
||||
return false;
|
||||
return ElxSuccessOrError::Error;
|
||||
}
|
||||
return true;
|
||||
return ElxSuccessOrError::Success;
|
||||
}
|
||||
|
||||
ElxLuaValueType UlxLuaValues::GetType(int n) const
|
||||
ElxLuaValueType UlxLuaValues::NextType() const
|
||||
{
|
||||
if (n < 0) return ElxLuaValueType::None;
|
||||
if (n >= Types.Num()) return ElxLuaValueType::None;
|
||||
if (Cursor < 0) return ElxLuaValueType::None;
|
||||
if (Cursor >= Types.Num()) return ElxLuaValueType::None;
|
||||
return Types[Cursor];
|
||||
}
|
||||
|
||||
//
|
||||
// Get the Nth value in the array. Array bounds-checking
|
||||
// is handled by 'GetType', which returns 'None' for out-of-bounds
|
||||
// accesses.
|
||||
//
|
||||
|
||||
FString UlxLuaValues::GetString(int n) const
|
||||
void UlxLuaValues::ReadString(ElxSuccessOrError &Status, FString &Result)
|
||||
{
|
||||
if (!CheckType(GetType(n), ElxLuaValueType::String)) return FString();
|
||||
FlxStreamBuffer Decoder(Data[n]);
|
||||
return Decoder.read_fstring();
|
||||
Status = CheckType(NextType(), ElxLuaValueType::String);
|
||||
if (Status == ElxSuccessOrError::Error)
|
||||
{
|
||||
Result.Empty(); return;
|
||||
}
|
||||
Result = FlxStreamBuffer(Data[Cursor++]).read_fstring();
|
||||
}
|
||||
|
||||
FName UlxLuaValues::GetName(int n) const
|
||||
void UlxLuaValues::ReadName(ElxSuccessOrError &Status, FName &Result)
|
||||
{
|
||||
if (!CheckType(GetType(n), ElxLuaValueType::Name)) return FName();
|
||||
FlxStreamBuffer Decoder(Data[n]);
|
||||
return Decoder.read_fname();
|
||||
Status = CheckType(NextType(), ElxLuaValueType::Name);
|
||||
if (Status == ElxSuccessOrError::Error)
|
||||
{
|
||||
Result = FName(); return;
|
||||
}
|
||||
Result = FlxStreamBuffer(Data[Cursor++]).read_fname();
|
||||
}
|
||||
|
||||
double UlxLuaValues::GetFloat(int n) const
|
||||
void UlxLuaValues::ReadFloat(ElxSuccessOrError &Status, double &Result)
|
||||
{
|
||||
if (!CheckType(GetType(n), ElxLuaValueType::Float)) return 0.0;
|
||||
FlxStreamBuffer Decoder(Data[n]);
|
||||
return Decoder.read_double();
|
||||
Status = CheckType(NextType(), ElxLuaValueType::Float);
|
||||
if (Status == ElxSuccessOrError::Error)
|
||||
{
|
||||
Result = 0.0; return;
|
||||
}
|
||||
Result = FlxStreamBuffer(Data[Cursor++]).read_double();
|
||||
}
|
||||
|
||||
int UlxLuaValues::GetInt(int n) const
|
||||
void UlxLuaValues::ReadInt(ElxSuccessOrError &Status, int &Result)
|
||||
{
|
||||
if (!CheckType(GetType(n), ElxLuaValueType::Float)) return 0;
|
||||
FlxStreamBuffer Decoder(Data[n]);
|
||||
return int(Decoder.read_double());
|
||||
Status = CheckType(NextType(), ElxLuaValueType::Float);
|
||||
if (Status == ElxSuccessOrError::Error)
|
||||
{
|
||||
Result = 0.0; return;
|
||||
}
|
||||
double dvalue = FlxStreamBuffer(Data[Cursor++]).read_double();
|
||||
Result = int(dvalue);
|
||||
if (double(Result) != dvalue)
|
||||
{
|
||||
Result = 0; Status = ElxSuccessOrError::Error; return;
|
||||
}
|
||||
}
|
||||
|
||||
FVector UlxLuaValues::GetVector(int n) const
|
||||
void UlxLuaValues::ReadVector(ElxSuccessOrError &Status, FVector &Result)
|
||||
{
|
||||
if (!CheckType(GetType(n), ElxLuaValueType::Vector)) return FVector();
|
||||
FlxStreamBuffer Decoder(Data[n]);
|
||||
return Decoder.read_fvector();
|
||||
Status = CheckType(NextType(), ElxLuaValueType::Vector);
|
||||
if (Status == ElxSuccessOrError::Error)
|
||||
{
|
||||
Result = FVector(); return;
|
||||
}
|
||||
Result = FlxStreamBuffer(Data[Cursor++]).read_fvector();
|
||||
}
|
||||
|
||||
FVector2D UlxLuaValues::GetVector2D(int n) const
|
||||
void UlxLuaValues::ReadVector2D(ElxSuccessOrError &Status, FVector2D &Result)
|
||||
{
|
||||
if (!CheckType(GetType(n), ElxLuaValueType::Vector)) return FVector2D();
|
||||
FlxStreamBuffer Decoder(Data[n]);
|
||||
FVector v = Decoder.read_fvector();
|
||||
return FVector2D(v.X, v.Y);
|
||||
Status = CheckType(NextType(), ElxLuaValueType::Vector);
|
||||
if (Status == ElxSuccessOrError::Error)
|
||||
{
|
||||
Result = FVector2D(); return;
|
||||
}
|
||||
FVector VValue = FlxStreamBuffer(Data[Cursor++]).read_fvector();
|
||||
Result = FVector2D(VValue.X, VValue.Y);
|
||||
}
|
||||
|
||||
bool UlxLuaValues::GetBoolean(int n) const
|
||||
void UlxLuaValues::ReadBoolean(ElxSuccessOrError &Status, bool &Result)
|
||||
{
|
||||
if (!CheckType(GetType(n), ElxLuaValueType::Boolean)) return false;
|
||||
FlxStreamBuffer Decoder(Data[n]);
|
||||
return Decoder.read_bool();
|
||||
Status = CheckType(NextType(), ElxLuaValueType::Boolean);
|
||||
if (Status == ElxSuccessOrError::Error)
|
||||
{
|
||||
Result = false; return;
|
||||
}
|
||||
Result = FlxStreamBuffer(Data[Cursor++]).read_bool();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user