More work on look-at, split LuaCall into LuaInvoke/LuaProbe
This commit is contained in:
@@ -45,20 +45,19 @@
|
||||
|
||||
// All argument pins will have internal Names that start with "A:"
|
||||
|
||||
const FName UK2Node_LuaCall::FunctionPinName(TEXT("Lua Function Prototype"));
|
||||
const FName UK2Node_LuaCall::InvokeOrProbePinName(TEXT("Invoke or Probe"));
|
||||
const FName UK2Node_LuaCall::PlacePinName(TEXT("Place Tangible"));
|
||||
const FName UK2Node_LuaCall::ExtraResultsPinName(TEXT("Extra Results"));
|
||||
const FName UK2Node_LuaCall::ErrorPinName(TEXT("Lua Error"));
|
||||
const FName UK2Node_LuaInvoke::FunctionPinName(TEXT("Lua Function Prototype"));
|
||||
const FName UK2Node_LuaInvoke::PlacePinName(TEXT("Place Tangible"));
|
||||
const FName UK2Node_LuaInvoke::ExtraResultsPinName(TEXT("Extra Results"));
|
||||
const FName UK2Node_LuaInvoke::ErrorPinName(TEXT("Lua Error"));
|
||||
|
||||
bool UK2Node_LuaCall::IsPrefix(const UEdGraphPin *Pin, char Prefix)
|
||||
bool UK2Node_LuaInvoke::IsPrefix(const UEdGraphPin *Pin, char Prefix)
|
||||
{
|
||||
TCHAR pname[FName::StringBufferSize];
|
||||
Pin->PinName.ToString(pname);
|
||||
return pname[0] == Prefix && pname[1] == ':';
|
||||
}
|
||||
|
||||
FName UK2Node_LuaCall::AddPrefix(const FString &Name, char Prefix)
|
||||
FName UK2Node_LuaInvoke::AddPrefix(const FString &Name, char Prefix)
|
||||
{
|
||||
TCHAR PrefixChars[3];
|
||||
PrefixChars[0] = Prefix;
|
||||
@@ -68,7 +67,7 @@ FName UK2Node_LuaCall::AddPrefix(const FString &Name, char Prefix)
|
||||
return FName(*Prefixed);
|
||||
}
|
||||
|
||||
FString UK2Node_LuaCall::RemovePrefix(FName Name, char Prefix)
|
||||
FString UK2Node_LuaInvoke::RemovePrefix(FName Name, char Prefix)
|
||||
{
|
||||
TCHAR pname[FName::StringBufferSize];
|
||||
Name.ToString(pname);
|
||||
@@ -91,12 +90,23 @@ static FEdGraphPinType GetPinType(const FProperty *Property)
|
||||
}
|
||||
|
||||
|
||||
UK2Node_LuaCall::UK2Node_LuaCall(const FObjectInitializer& ObjectInitializer)
|
||||
UK2Node_LuaInvoke::UK2Node_LuaInvoke(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer), NodeTooltip(MakeTooltip())
|
||||
{
|
||||
}
|
||||
|
||||
UK2Node_LuaProbe::UK2Node_LuaProbe(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
FText UK2Node_LuaInvoke::MakeTooltip() const
|
||||
{
|
||||
// TODO: replace this string manipulation with text manipulation.
|
||||
FString ArgTypes = UlxLuaCallLibrary::AllKnownArgumentTypes();
|
||||
FString RetTypes = UlxLuaCallLibrary::AllKnownReturnValueTypes();
|
||||
NodeTooltip = FText::FromString(FString::Printf(TEXT(
|
||||
return FText::FromString(FString::Printf(TEXT(
|
||||
"Call a Lua function.\n"
|
||||
"\n"
|
||||
"The lua function prototype must be a hardwired string which must look like\n"
|
||||
@@ -124,16 +134,14 @@ UK2Node_LuaCall::UK2Node_LuaCall(const FObjectInitializer& ObjectInitializer)
|
||||
"\n"), *ArgTypes, *RetTypes));
|
||||
}
|
||||
|
||||
void UK2Node_LuaCall::AllocateDefaultPins()
|
||||
void UK2Node_LuaInvoke::AllocateDefaultPins()
|
||||
{
|
||||
Super::AllocateDefaultPins();
|
||||
CreateCorrectPins();
|
||||
}
|
||||
|
||||
void UK2Node_LuaCall::CreateCorrectPins()
|
||||
void UK2Node_LuaInvoke::CreateCorrectPins()
|
||||
{
|
||||
UEnum *IPEnum = StaticEnum<ElxInvokeOrProbe>();
|
||||
|
||||
if (LuaFunctionPrototype.IsEmpty())
|
||||
{
|
||||
LuaFunctionPrototype = TEXT("class.func(int arg1, int arg2) : int ret1, int ret2");
|
||||
@@ -180,7 +188,7 @@ void UK2Node_LuaCall::CreateCorrectPins()
|
||||
CreatePin(EGPD_Output, UEdGraphSchema_K2::PC_Exec, UEdGraphSchema_K2::PN_Then);
|
||||
}
|
||||
|
||||
if (InvokeOrProbe == TEXT("Probe"))
|
||||
if (!IsInvoke())
|
||||
{
|
||||
if (!KeepPin(ErrorPinName))
|
||||
{
|
||||
@@ -193,11 +201,6 @@ void UK2Node_LuaCall::CreateCorrectPins()
|
||||
UEdGraphPin *P = CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_String, FunctionPinName);
|
||||
}
|
||||
|
||||
if (!KeepPin(InvokeOrProbePinName))
|
||||
{
|
||||
UEdGraphPin *P = CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Byte, IPEnum, InvokeOrProbePinName);
|
||||
}
|
||||
|
||||
if (!KeepPin(PlacePinName))
|
||||
{
|
||||
UEdGraphPin *P = CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Object, AActor::StaticClass(), PlacePinName);
|
||||
@@ -205,9 +208,7 @@ void UK2Node_LuaCall::CreateCorrectPins()
|
||||
|
||||
// Copy the property names into the pins.
|
||||
UEdGraphPin *FunctionPin = FindPinChecked(FunctionPinName);
|
||||
UEdGraphPin *InvokeOrProbePin = FindPinChecked(InvokeOrProbePinName);
|
||||
FunctionPin->DefaultValue = LuaFunctionPrototype;
|
||||
InvokeOrProbePin->DefaultValue = InvokeOrProbe;
|
||||
|
||||
// Create Argument pins in the correct order, reusing old pins where possible.
|
||||
for (const FlxParsedProto::Pin & Pin : ParsedProto.Arguments)
|
||||
@@ -263,12 +264,19 @@ void UK2Node_LuaCall::CreateCorrectPins()
|
||||
}
|
||||
|
||||
|
||||
FText UK2Node_LuaCall::GetNodeTitle(ENodeTitleType::Type TitleType) const
|
||||
FText UK2Node_LuaInvoke::GetNodeTitle(ENodeTitleType::Type TitleType) const
|
||||
{
|
||||
return LOCTEXT("LuaCall_Title", "Call a Lua Function");
|
||||
if (IsInvoke())
|
||||
{
|
||||
return LOCTEXT("LuaInvoke_Title", "Invoke a Lua Function");
|
||||
}
|
||||
else
|
||||
{
|
||||
return LOCTEXT("LuaProbe_Title", "Probe a Lua Function");
|
||||
}
|
||||
}
|
||||
|
||||
FText UK2Node_LuaCall::GetPinDisplayName(const UEdGraphPin* Pin) const
|
||||
FText UK2Node_LuaInvoke::GetPinDisplayName(const UEdGraphPin* Pin) const
|
||||
{
|
||||
// The exec pins don't need labels.
|
||||
if ((Pin->PinName == UEdGraphSchema_K2::PN_Execute) || (Pin->PinName == UEdGraphSchema_K2::PN_Then))
|
||||
@@ -277,7 +285,7 @@ FText UK2Node_LuaCall::GetPinDisplayName(const UEdGraphPin* Pin) const
|
||||
}
|
||||
|
||||
// Many pins can go unlabeled if they have default values.
|
||||
if ((Pin->PinName == FunctionPinName) || (Pin->PinName == InvokeOrProbePinName))
|
||||
if (Pin->PinName == FunctionPinName)
|
||||
{
|
||||
if (Pin->LinkedTo.Num() == 0)
|
||||
{
|
||||
@@ -301,18 +309,18 @@ FText UK2Node_LuaCall::GetPinDisplayName(const UEdGraphPin* Pin) const
|
||||
return FText::FromName(Pin->PinName);
|
||||
}
|
||||
|
||||
void UK2Node_LuaCall::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent)
|
||||
void UK2Node_LuaInvoke::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent)
|
||||
{
|
||||
Super::PostEditChangeProperty(PropertyChangedEvent);
|
||||
GetGraph()->NotifyNodeChanged(this);
|
||||
}
|
||||
|
||||
void UK2Node_LuaCall::PinConnectionListChanged(UEdGraphPin* Pin)
|
||||
void UK2Node_LuaInvoke::PinConnectionListChanged(UEdGraphPin* Pin)
|
||||
{
|
||||
Modify();
|
||||
}
|
||||
|
||||
void UK2Node_LuaCall::PinDefaultValueChanged(UEdGraphPin* Pin)
|
||||
void UK2Node_LuaInvoke::PinDefaultValueChanged(UEdGraphPin* Pin)
|
||||
{
|
||||
if(Pin->PinName == FunctionPinName)
|
||||
{
|
||||
@@ -320,20 +328,14 @@ void UK2Node_LuaCall::PinDefaultValueChanged(UEdGraphPin* Pin)
|
||||
CreateCorrectPins();
|
||||
GetGraph()->NotifyNodeChanged(this);
|
||||
}
|
||||
else if (Pin->PinName == InvokeOrProbePinName)
|
||||
{
|
||||
InvokeOrProbe = Pin->DefaultValue;
|
||||
CreateCorrectPins();
|
||||
GetGraph()->NotifyNodeChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
FText UK2Node_LuaCall::GetTooltipText() const
|
||||
FText UK2Node_LuaInvoke::GetTooltipText() const
|
||||
{
|
||||
return NodeTooltip;
|
||||
}
|
||||
|
||||
void UK2Node_LuaCall::PostReconstructNode()
|
||||
void UK2Node_LuaInvoke::PostReconstructNode()
|
||||
{
|
||||
Super::PostReconstructNode();
|
||||
CreateCorrectPins();
|
||||
@@ -342,7 +344,7 @@ void UK2Node_LuaCall::PostReconstructNode()
|
||||
#define LuaCallLibraryFunction(name) (UlxLuaCallLibrary::StaticClass()->FindFunctionByName(GET_MEMBER_NAME_CHECKED(UlxLuaCallLibrary, name)))
|
||||
|
||||
|
||||
void UK2Node_LuaCall::ExpandNode(class FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph)
|
||||
void UK2Node_LuaInvoke::ExpandNode(class FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph)
|
||||
{
|
||||
Super::ExpandNode(CompilerContext, SourceGraph);
|
||||
const UEdGraphSchema_K2* Schema = CompilerContext.GetSchema();
|
||||
@@ -382,7 +384,14 @@ void UK2Node_LuaCall::ExpandNode(class FKismetCompilerContext& CompilerContext,
|
||||
}
|
||||
|
||||
// Add the invoke or probe node.
|
||||
if (InvokeOrProbe == TEXT("Probe"))
|
||||
if (IsInvoke())
|
||||
{
|
||||
UK2Node_CallFunction* ActionNode = MakeCallFunctionNode(LuaCallLibraryFunction(LuaCallInvoke));
|
||||
CompilerContext.MovePinLinksToIntermediate(*FindPinChecked(PlacePinName, EGPD_Input), *ActionNode->FindPinChecked(TEXT("Place")));
|
||||
ThenPin->MakeLinkTo(ActionNode->GetExecPin());
|
||||
ThenPin = ActionNode->GetThenPin();
|
||||
}
|
||||
else
|
||||
{
|
||||
UK2Node_CallFunction* ActionNode = MakeCallFunctionNode(LuaCallLibraryFunction(LuaCallProbe));
|
||||
CompilerContext.MovePinLinksToIntermediate(*FindPinChecked(PlacePinName, EGPD_Input), *ActionNode->FindPinChecked(TEXT("Place")));
|
||||
@@ -390,13 +399,6 @@ void UK2Node_LuaCall::ExpandNode(class FKismetCompilerContext& CompilerContext,
|
||||
ThenPin->MakeLinkTo(ActionNode->GetExecPin());
|
||||
ThenPin = ActionNode->FindPinChecked(TEXT("True"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UK2Node_CallFunction* ActionNode = MakeCallFunctionNode(LuaCallLibraryFunction(LuaCallInvoke));
|
||||
CompilerContext.MovePinLinksToIntermediate(*FindPinChecked(PlacePinName, EGPD_Input), *ActionNode->FindPinChecked(TEXT("Place")));
|
||||
ThenPin->MakeLinkTo(ActionNode->GetExecPin());
|
||||
ThenPin = ActionNode->GetThenPin();
|
||||
}
|
||||
|
||||
// Add Unpacking operations for all return value pins.
|
||||
for (const FlxParsedProto::Pin &PinInfo : ParsedProto.ReturnValues)
|
||||
@@ -430,7 +432,7 @@ void UK2Node_LuaCall::ExpandNode(class FKismetCompilerContext& CompilerContext,
|
||||
CompilerContext.MovePinLinksToIntermediate(*GetThenPin(), *ThenPin);
|
||||
|
||||
// Make sure we didn't have return values for an invoke.
|
||||
if ((InvokeOrProbe != TEXT("Probe")) && ((ParsedProto.ReturnValues.Num() > 0) || (ParsedProto.ExtraReturnValues)))
|
||||
if (IsInvoke() && ((ParsedProto.ReturnValues.Num() > 0) || (ParsedProto.ExtraReturnValues)))
|
||||
{
|
||||
CompilerContext.MessageLog.Error(TEXT("Lua Call in Invoke mode does not support return values"));
|
||||
}
|
||||
@@ -439,7 +441,7 @@ void UK2Node_LuaCall::ExpandNode(class FKismetCompilerContext& CompilerContext,
|
||||
}
|
||||
|
||||
|
||||
UK2Node::ERedirectType UK2Node_LuaCall::DoPinsMatchForReconstruction(const UEdGraphPin* NewPin, int32 NewPinIndex, const UEdGraphPin* OldPin, int32 OldPinIndex) const
|
||||
UK2Node::ERedirectType UK2Node_LuaInvoke::DoPinsMatchForReconstruction(const UEdGraphPin* NewPin, int32 NewPinIndex, const UEdGraphPin* OldPin, int32 OldPinIndex) const
|
||||
{
|
||||
ERedirectType RedirectType = ERedirectType_None;
|
||||
|
||||
@@ -484,7 +486,7 @@ UK2Node::ERedirectType UK2Node_LuaCall::DoPinsMatchForReconstruction(const UEdGr
|
||||
return RedirectType;
|
||||
}
|
||||
|
||||
bool UK2Node_LuaCall::IsConnectionDisallowed(const UEdGraphPin* MyPin, const UEdGraphPin* OtherPin, FString& OutReason) const
|
||||
bool UK2Node_LuaInvoke::IsConnectionDisallowed(const UEdGraphPin* MyPin, const UEdGraphPin* OtherPin, FString& OutReason) const
|
||||
{
|
||||
// The function pin cannot be connected.
|
||||
if (MyPin->PinName == FunctionPinName)
|
||||
@@ -493,17 +495,10 @@ bool UK2Node_LuaCall::IsConnectionDisallowed(const UEdGraphPin* MyPin, const UEd
|
||||
return true;
|
||||
}
|
||||
|
||||
// The invoke-or-probe pin cannot be connected.
|
||||
if (MyPin->PinName == InvokeOrProbePinName)
|
||||
{
|
||||
OutReason = LOCTEXT("Error_InvokeOrProbeMustBeHardwired", "Invoke vs Probe must be a hardwired constant.").ToString();
|
||||
return true;
|
||||
}
|
||||
|
||||
return Super::IsConnectionDisallowed(MyPin, OtherPin, OutReason);
|
||||
}
|
||||
|
||||
void UK2Node_LuaCall::GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const
|
||||
void UK2Node_LuaInvoke::GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const
|
||||
{
|
||||
// actions get registered under specific object-keys; the idea is that
|
||||
// actions might have to be updated (or deleted) if their object-key is
|
||||
@@ -523,7 +518,7 @@ void UK2Node_LuaCall::GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRe
|
||||
}
|
||||
}
|
||||
|
||||
FText UK2Node_LuaCall::GetMenuCategory() const
|
||||
FText UK2Node_LuaInvoke::GetMenuCategory() const
|
||||
{
|
||||
return FText::FromString(FString(TEXT("Luprex|Lua")));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user