More tstrong
This commit is contained in:
@@ -257,15 +257,15 @@ void WingVariables::Print(WingOut Out)
|
|||||||
void WingVariables::Load(WingOut Errors)
|
void WingVariables::Load(WingOut Errors)
|
||||||
{
|
{
|
||||||
Empty();
|
Empty();
|
||||||
if (Blueprint != nullptr) return LoadBlueprint();
|
if (Blueprint) return LoadBlueprint();
|
||||||
if (Graph != nullptr) return LoadGraph();
|
if (Graph) return LoadGraph();
|
||||||
if (CustomEvent != nullptr) return LoadCustomEvent();
|
if (CustomEvent) return LoadCustomEvent();
|
||||||
ErrorNoBackingStore(Errors);
|
ErrorNoBackingStore(Errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WingVariables::LoadBlueprint()
|
void WingVariables::LoadBlueprint()
|
||||||
{
|
{
|
||||||
UObject *CDO = WingUtils::GetGeneratedCDO(Blueprint);
|
UObject *CDO = WingUtils::GetGeneratedCDO(Blueprint.Get());
|
||||||
|
|
||||||
for (FBPVariableDescription& Desc : Blueprint->NewVariables)
|
for (FBPVariableDescription& Desc : Blueprint->NewVariables)
|
||||||
{
|
{
|
||||||
@@ -281,7 +281,7 @@ void WingVariables::LoadGraph()
|
|||||||
{
|
{
|
||||||
TWeakObjectPtr<UK2Node_EditablePinBase> EntryNode;
|
TWeakObjectPtr<UK2Node_EditablePinBase> EntryNode;
|
||||||
TWeakObjectPtr<UK2Node_EditablePinBase> ResultNode;
|
TWeakObjectPtr<UK2Node_EditablePinBase> ResultNode;
|
||||||
FBlueprintEditorUtils::GetEntryAndResultNodes(Graph, EntryNode, ResultNode);
|
FBlueprintEditorUtils::GetEntryAndResultNodes(Graph.Get(), EntryNode, ResultNode);
|
||||||
if (EntryNode.IsValid()) LoadEditablePinBase(EntryNode.Get(), InputVariables);
|
if (EntryNode.IsValid()) LoadEditablePinBase(EntryNode.Get(), InputVariables);
|
||||||
if (ResultNode.IsValid()) LoadEditablePinBase(ResultNode.Get(), OutputVariables);
|
if (ResultNode.IsValid()) LoadEditablePinBase(ResultNode.Get(), OutputVariables);
|
||||||
LoadLocalVariables(EntryNode.Get());
|
LoadLocalVariables(EntryNode.Get());
|
||||||
@@ -359,7 +359,7 @@ void WingVariables::LoadEditablePinBase(UK2Node_EditablePinBase* Node, WingVaria
|
|||||||
|
|
||||||
void WingVariables::LoadCustomEvent()
|
void WingVariables::LoadCustomEvent()
|
||||||
{
|
{
|
||||||
LoadEditablePinBase(CustomEvent, InputVariables);
|
LoadEditablePinBase(CustomEvent.Get(), InputVariables);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WingVariables::Check(WingOut Errors)
|
bool WingVariables::Check(WingOut Errors)
|
||||||
@@ -382,7 +382,7 @@ bool WingVariables::CheckBlueprint(WingOut Errors)
|
|||||||
|
|
||||||
bool WingVariables::CheckGraph(WingOut Errors)
|
bool WingVariables::CheckGraph(WingOut Errors)
|
||||||
{
|
{
|
||||||
EGraphType T = Graph->GetSchema()->GetGraphType(Graph);
|
EGraphType T = Graph->GetSchema()->GetGraphType(Graph.Get());
|
||||||
bool AllowLocal = (T == EGraphType::GT_Function);
|
bool AllowLocal = (T == EGraphType::GT_Function);
|
||||||
bool AllowInput = (T == EGraphType::GT_Function) || (T == EGraphType::GT_Macro);
|
bool AllowInput = (T == EGraphType::GT_Function) || (T == EGraphType::GT_Macro);
|
||||||
bool AllowOutput = (T == EGraphType::GT_Function) || (T == EGraphType::GT_Macro);
|
bool AllowOutput = (T == EGraphType::GT_Function) || (T == EGraphType::GT_Macro);
|
||||||
@@ -481,8 +481,8 @@ bool WingVariables::ModifyBlueprintDefaults(WingOut Errors)
|
|||||||
if (Input.DefaultSpecified) AnySpecified = true;
|
if (Input.DefaultSpecified) AnySpecified = true;
|
||||||
if (!AnySpecified) return true;
|
if (!AnySpecified) return true;
|
||||||
|
|
||||||
FKismetEditorUtilities::CompileBlueprint(Blueprint);
|
FKismetEditorUtilities::CompileBlueprint(Blueprint.Get());
|
||||||
UObject *CDO = WingUtils::GetGeneratedCDO(Blueprint);
|
UObject *CDO = WingUtils::GetGeneratedCDO(Blueprint.Get());
|
||||||
if (!CDO)
|
if (!CDO)
|
||||||
{
|
{
|
||||||
Errors.Printf(TEXT("Blueprint didn't compile, cannot store default values"));
|
Errors.Printf(TEXT("Blueprint didn't compile, cannot store default values"));
|
||||||
@@ -535,7 +535,7 @@ bool WingVariables::ModifyCustomEvent(WingOut Errors)
|
|||||||
{
|
{
|
||||||
if (!CheckCustomEvent(Errors)) return false;
|
if (!CheckCustomEvent(Errors)) return false;
|
||||||
ClearLinks();
|
ClearLinks();
|
||||||
if (!ModifyEditablePinBase(InputVariables, CustomEvent, Errors)) return false;
|
if (!ModifyEditablePinBase(InputVariables, CustomEvent.Get(), Errors)) return false;
|
||||||
CustomEvent->ReconstructNode();
|
CustomEvent->ReconstructNode();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -567,7 +567,7 @@ bool WingVariables::GetGraphNodes(
|
|||||||
LocalNode = nullptr;
|
LocalNode = nullptr;
|
||||||
|
|
||||||
TWeakObjectPtr<UK2Node_EditablePinBase> Inputs, Outputs;
|
TWeakObjectPtr<UK2Node_EditablePinBase> Inputs, Outputs;
|
||||||
FBlueprintEditorUtils::GetEntryAndResultNodes(Graph, Inputs, Outputs);
|
FBlueprintEditorUtils::GetEntryAndResultNodes(Graph.Get(), Inputs, Outputs);
|
||||||
if (!Inputs.IsValid())
|
if (!Inputs.IsValid())
|
||||||
{
|
{
|
||||||
Errors.Printf(TEXT("ERROR: no function entry node for graph."));
|
Errors.Printf(TEXT("ERROR: no function entry node for graph."));
|
||||||
@@ -609,13 +609,13 @@ bool WingVariables::CreateBlueprint(WingOut Errors)
|
|||||||
|
|
||||||
// Check for name collisions against existing variables, components, and the like.
|
// Check for name collisions against existing variables, components, and the like.
|
||||||
TSet<FName> Names;
|
TSet<FName> Names;
|
||||||
FBlueprintEditorUtils::GetClassVariableList(Blueprint, Names);
|
FBlueprintEditorUtils::GetClassVariableList(Blueprint.Get(), Names);
|
||||||
if (!WingUtils::FindNoDuplicateNames(Names, BlueprintVariables.Variables, TEXT("variable or component"), Errors)) return false;
|
if (!WingUtils::FindNoDuplicateNames(Names, BlueprintVariables.Variables, TEXT("variable or component"), Errors)) return false;
|
||||||
|
|
||||||
// Create the variables.
|
// Create the variables.
|
||||||
for (const WingVariables::Var& V : BlueprintVariables.Variables)
|
for (const WingVariables::Var& V : BlueprintVariables.Variables)
|
||||||
{
|
{
|
||||||
if (!FBlueprintEditorUtils::AddMemberVariable(Blueprint, V.Name, V.Type))
|
if (!FBlueprintEditorUtils::AddMemberVariable(Blueprint.Get(), V.Name, V.Type))
|
||||||
{
|
{
|
||||||
Errors.Printf(TEXT("ERROR: Failed to add variable '%s'\n"),
|
Errors.Printf(TEXT("ERROR: Failed to add variable '%s'\n"),
|
||||||
*WingUtils::ExternalizeID(V.Name));
|
*WingUtils::ExternalizeID(V.Name));
|
||||||
@@ -663,10 +663,10 @@ bool WingVariables::CreateGraph(WingOut Errors)
|
|||||||
AddUserPinInfo(V, EGPD_Input, OutputNode);
|
AddUserPinInfo(V, EGPD_Input, OutputNode);
|
||||||
|
|
||||||
// Create local variables via the proper API.
|
// Create local variables via the proper API.
|
||||||
UBlueprint* BP = FBlueprintEditorUtils::FindBlueprintForGraph(Graph);
|
UBlueprint* BP = FBlueprintEditorUtils::FindBlueprintForGraph(Graph.Get());
|
||||||
for (const Var& V : LocalVariables.Variables)
|
for (const Var& V : LocalVariables.Variables)
|
||||||
{
|
{
|
||||||
if (!FBlueprintEditorUtils::AddLocalVariable(BP, Graph, V.Name, V.Type, V.DefaultValue))
|
if (!FBlueprintEditorUtils::AddLocalVariable(BP, Graph.Get(), V.Name, V.Type, V.DefaultValue))
|
||||||
{
|
{
|
||||||
Errors.Printf(TEXT("ERROR: Failed to create local variable '%s'\n"),
|
Errors.Printf(TEXT("ERROR: Failed to create local variable '%s'\n"),
|
||||||
*WingUtils::ExternalizeID(V.Name));
|
*WingUtils::ExternalizeID(V.Name));
|
||||||
@@ -692,7 +692,7 @@ bool WingVariables::CreateCustomEvent(WingOut Errors)
|
|||||||
Names, InputVariables.Variables, TEXT("event parameter"), Errors)) return false;
|
Names, InputVariables.Variables, TEXT("event parameter"), Errors)) return false;
|
||||||
|
|
||||||
for (const Var& V : InputVariables.Variables)
|
for (const Var& V : InputVariables.Variables)
|
||||||
AddUserPinInfo(V, EGPD_Output, CustomEvent);
|
AddUserPinInfo(V, EGPD_Output, CustomEvent.Get());
|
||||||
|
|
||||||
CustomEvent->ReconstructNode();
|
CustomEvent->ReconstructNode();
|
||||||
return true;
|
return true;
|
||||||
@@ -729,7 +729,7 @@ bool WingVariables::RemoveBlueprint(WingOut Errors)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove them.
|
// Remove them.
|
||||||
FBlueprintEditorUtils::BulkRemoveMemberVariables(Blueprint, Names);
|
FBlueprintEditorUtils::BulkRemoveMemberVariables(Blueprint.Get(), Names);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -766,12 +766,12 @@ bool WingVariables::RemoveGraph(WingOut Errors)
|
|||||||
OutputNode->RemoveUserDefinedPinByName(V.Name);
|
OutputNode->RemoveUserDefinedPinByName(V.Name);
|
||||||
|
|
||||||
// Remove local variables.
|
// Remove local variables.
|
||||||
UBlueprint* BP = FBlueprintEditorUtils::FindBlueprintForGraph(Graph);
|
UBlueprint* BP = FBlueprintEditorUtils::FindBlueprintForGraph(Graph.Get());
|
||||||
for (const Var& V : LocalVariables.Variables)
|
for (const Var& V : LocalVariables.Variables)
|
||||||
{
|
{
|
||||||
LocalNode->LocalVariables.RemoveAll(
|
LocalNode->LocalVariables.RemoveAll(
|
||||||
[&](const FBPVariableDescription& Desc) { return Desc.VarName == V.Name; });
|
[&](const FBPVariableDescription& Desc) { return Desc.VarName == V.Name; });
|
||||||
FBlueprintEditorUtils::RemoveVariableNodes(BP, V.Name, true, Graph);
|
FBlueprintEditorUtils::RemoveVariableNodes(BP, V.Name, true, Graph.Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (InputNode) InputNode->ReconstructNode();
|
if (InputNode) InputNode->ReconstructNode();
|
||||||
@@ -798,22 +798,22 @@ bool WingVariables::RemoveCustomEvent(WingOut Errors)
|
|||||||
|
|
||||||
bool WingVariables::SetBackingStore(UObject *Obj, WingOut Errors)
|
bool WingVariables::SetBackingStore(UObject *Obj, WingOut Errors)
|
||||||
{
|
{
|
||||||
Blueprint = nullptr;
|
Blueprint.Reset();
|
||||||
Graph = nullptr;
|
Graph.Reset();
|
||||||
CustomEvent = nullptr;
|
CustomEvent.Reset();
|
||||||
if (UBlueprint *BP = Cast<UBlueprint>(Obj))
|
if (UBlueprint *BP = Cast<UBlueprint>(Obj))
|
||||||
{
|
{
|
||||||
Blueprint = BP;
|
Blueprint.Reset(BP);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (UEdGraph *G = Cast<UEdGraph>(Obj))
|
if (UEdGraph *G = Cast<UEdGraph>(Obj))
|
||||||
{
|
{
|
||||||
Graph = G;
|
Graph.Reset(G);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (UK2Node_CustomEvent *E = Cast<UK2Node_CustomEvent>(Obj))
|
if (UK2Node_CustomEvent *E = Cast<UK2Node_CustomEvent>(Obj))
|
||||||
{
|
{
|
||||||
CustomEvent = E;
|
CustomEvent.Reset(E);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Errors.Printf(TEXT(
|
Errors.Printf(TEXT(
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "EdGraph/EdGraphPin.h"
|
#include "EdGraph/EdGraphPin.h"
|
||||||
|
#include "Engine/Blueprint.h"
|
||||||
|
#include "K2Node_CustomEvent.h"
|
||||||
|
#include "UObject/StrongObjectPtr.h"
|
||||||
#include "WingBasics.h"
|
#include "WingBasics.h"
|
||||||
|
|
||||||
struct FBPVariableDescription;
|
struct FBPVariableDescription;
|
||||||
struct WingTokenizer;
|
struct WingTokenizer;
|
||||||
class UObject;
|
class UObject;
|
||||||
class UBlueprint;
|
|
||||||
class UEdGraph;
|
|
||||||
class UK2Node_CustomEvent;
|
|
||||||
class UK2Node_EditablePinBase;
|
class UK2Node_EditablePinBase;
|
||||||
class UK2Node_FunctionEntry;
|
class UK2Node_FunctionEntry;
|
||||||
struct FUserPinInfo;
|
struct FUserPinInfo;
|
||||||
@@ -92,9 +92,9 @@ public:
|
|||||||
|
|
||||||
// The backing store. Only one of these should be set.
|
// The backing store. Only one of these should be set.
|
||||||
|
|
||||||
UBlueprint *Blueprint = nullptr;
|
TStrongObjectPtr<UBlueprint> Blueprint;
|
||||||
UEdGraph *Graph = nullptr;
|
TStrongObjectPtr<UEdGraph> Graph;
|
||||||
UK2Node_CustomEvent *CustomEvent = nullptr;
|
TStrongObjectPtr<UK2Node_CustomEvent> CustomEvent;
|
||||||
|
|
||||||
// The Workspace. At any given time, these may or may not contain
|
// The Workspace. At any given time, these may or may not contain
|
||||||
// the same data as the backing store.
|
// the same data as the backing store.
|
||||||
|
|||||||
Reference in New Issue
Block a user