|
4 | 4 |
|
5 | 5 | #include "Runtime/Engine/Classes/EdGraph/EdGraph.h" |
6 | 6 | #include "Editor/BlueprintGraph/Classes/K2Node_CallFunction.h" |
| 7 | +#include "Editor/BlueprintGraph/Classes/K2Node_DynamicCast.h" |
7 | 8 | #include "Editor/BlueprintGraph/Classes/EdGraphSchema_K2.h" |
8 | 9 | #include "Editor/BlueprintGraph/Classes/K2Node_CustomEvent.h" |
9 | 10 | #include "Editor/BlueprintGraph/Classes/K2Node_VariableGet.h" |
@@ -380,6 +381,60 @@ PyObject *py_ue_graph_add_node(ue_PyUObject * self, PyObject * args) |
380 | 381 | Py_RETURN_UOBJECT(node); |
381 | 382 | } |
382 | 383 |
|
| 384 | +PyObject *py_ue_graph_add_node_dynamic_cast(ue_PyUObject * self, PyObject * args) |
| 385 | +{ |
| 386 | + |
| 387 | + ue_py_check(self); |
| 388 | + |
| 389 | + PyObject *py_node_class; |
| 390 | + int x = 0; |
| 391 | + int y = 0; |
| 392 | + |
| 393 | + char *metadata = nullptr; |
| 394 | + PyObject *py_data = nullptr; |
| 395 | + |
| 396 | + if(!PyArg_ParseTuple(args, "O|iis:graph_add_node_dynamic_cast", &py_node_class, &x, &y, &metadata)) |
| 397 | + { |
| 398 | + return nullptr; |
| 399 | + } |
| 400 | + |
| 401 | + UEdGraph *graph = ue_py_check_type<UEdGraph>(self); |
| 402 | + if(!graph) |
| 403 | + return PyErr_Format(PyExc_Exception, "uobject is not a UEdGraph"); |
| 404 | + |
| 405 | + UClass *u_class = ue_py_check_type<UClass>(py_node_class); |
| 406 | + if(!u_class) |
| 407 | + return PyErr_Format(PyExc_Exception, "argument is not a UClass"); |
| 408 | + |
| 409 | + UK2Node_DynamicCast *node = NewObject<UK2Node_DynamicCast>(graph); |
| 410 | + node->TargetType = u_class; |
| 411 | + node->SetPurity(false); |
| 412 | + node->AllocateDefaultPins(); |
| 413 | + |
| 414 | + node->CreateNewGuid(); |
| 415 | + node->PostPlacedNewNode(); |
| 416 | + node->SetFlags(RF_Transactional); |
| 417 | + node->NodePosX = x; |
| 418 | + node->NodePosY = y; |
| 419 | + |
| 420 | + if(metadata == nullptr || strlen(metadata) == 0) |
| 421 | + { |
| 422 | + UEdGraphSchema_K2::SetNodeMetaData(node, FNodeMetadata::DefaultGraphNode); |
| 423 | + } |
| 424 | + else |
| 425 | + { |
| 426 | + UEdGraphSchema_K2::SetNodeMetaData(node, FName(UTF8_TO_TCHAR(metadata))); |
| 427 | + } |
| 428 | + graph->AddNode(node); |
| 429 | + |
| 430 | + if(UBlueprint *bp = Cast<UBlueprint>(node->GetGraph()->GetOuter())) |
| 431 | + { |
| 432 | + FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(bp); |
| 433 | + } |
| 434 | + |
| 435 | + Py_RETURN_UOBJECT(node); |
| 436 | +} |
| 437 | + |
383 | 438 | PyObject *py_ue_node_pins(ue_PyUObject * self, PyObject * args) |
384 | 439 | { |
385 | 440 |
|
|
0 commit comments