Skip to content

Commit 7e35da4

Browse files
author
Roberto De Ioris
committed
added node_function_entry_set_pure()
1 parent 5096b38 commit 7e35da4

4 files changed

Lines changed: 66 additions & 13 deletions

File tree

‎Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraph.cpp‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "Editor/BlueprintGraph/Classes/EdGraphSchema_K2_Actions.h"
1313
#include "Editor/AIGraph/Classes/AIGraph.h"
1414
#include "Editor/AIGraph/Classes/AIGraphNode.h"
15+
#include "Editor/BlueprintGraph/Classes/K2Node_FunctionEntry.h"
1516

1617
PyObject *py_ue_graph_add_node_call_function(ue_PyUObject * self, PyObject * args)
1718
{
@@ -479,6 +480,61 @@ PyObject *py_ue_node_find_pin(ue_PyUObject * self, PyObject * args)
479480
return ret;
480481
}
481482

483+
PyObject *py_ue_node_function_entry_set_pure(ue_PyUObject * self, PyObject * args)
484+
{
485+
486+
ue_py_check(self);
487+
488+
PyObject *py_bool = nullptr;
489+
if (!PyArg_ParseTuple(args, "O:node_function_entry_set_pure", &py_bool))
490+
{
491+
return nullptr;
492+
}
493+
494+
UK2Node_FunctionEntry *node = ue_py_check_type<UK2Node_FunctionEntry>(self);
495+
if (!node)
496+
return PyErr_Format(PyExc_Exception, "uobject is not a K2Node_FunctionEntry");
497+
498+
UEdGraph *graph = node->GetGraph();
499+
500+
if (!graph)
501+
return PyErr_Format(PyExc_Exception, "unable to get graph from node");
502+
503+
UBlueprint *blueprint = FBlueprintEditorUtils::FindBlueprintForGraph(graph);
504+
if (!blueprint)
505+
return PyErr_Format(PyExc_Exception, "unable to get blueprint from node");
506+
507+
UClass *Class = blueprint->SkeletonGeneratedClass;
508+
UFunction *function = nullptr;
509+
for (TFieldIterator<UFunction> FunctionIt(Class, EFieldIteratorFlags::IncludeSuper); FunctionIt; ++FunctionIt)
510+
{
511+
if (*FunctionIt->GetName() == graph->GetName())
512+
{
513+
function = *FunctionIt;
514+
break;
515+
}
516+
}
517+
518+
if (!function)
519+
return PyErr_Format(PyExc_Exception, "unable to get function from node");
520+
521+
node->Modify();
522+
function->Modify();
523+
524+
if (PyObject_IsTrue(py_bool))
525+
{
526+
function->FunctionFlags |= FUNC_BlueprintPure;
527+
node->AddExtraFlags(FUNC_BlueprintPure);
528+
}
529+
else
530+
{
531+
function->FunctionFlags &= ~FUNC_BlueprintPure;
532+
node->ClearExtraFlags(FUNC_BlueprintPure);
533+
}
534+
535+
Py_RETURN_NONE;
536+
}
537+
482538
PyObject *py_ue_node_create_pin(ue_PyUObject * self, PyObject * args)
483539
{
484540

‎Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraph.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ PyObject *py_ue_node_pins(ue_PyUObject *, PyObject *);
2121
PyObject *py_ue_node_find_pin(ue_PyUObject *, PyObject *);
2222
PyObject *py_ue_node_create_pin(ue_PyUObject *, PyObject *);
2323

24+
PyObject *py_ue_node_function_entry_set_pure(ue_PyUObject *, PyObject *);
25+
2426
PyObject *py_ue_node_get_title(ue_PyUObject *, PyObject *);
2527
PyObject *py_ue_node_allocate_default_pins(ue_PyUObject *, PyObject *);
2628
PyObject *py_ue_node_reconstruct(ue_PyUObject *, PyObject *);

‎Source/UnrealEnginePython/Private/UEPyEditor.cpp‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,18 +1410,12 @@ PyObject *py_unreal_engine_blueprint_set_variable_visibility(PyObject * self, Py
14101410
PyObject *visibility;
14111411
if (!PyArg_ParseTuple(args, "OsO:blueprint_set_variable_visibility", &py_blueprint, &name, &visibility))
14121412
{
1413-
return NULL;
1414-
}
1415-
1416-
if (!ue_is_pyuobject(py_blueprint))
1417-
{
1418-
return PyErr_Format(PyExc_Exception, "argument is not a UObject");
1413+
return nullptr;
14191414
}
14201415

1421-
ue_PyUObject *py_obj = (ue_PyUObject *)py_blueprint;
1422-
if (!py_obj->ue_object->IsA<UBlueprint>())
1423-
return PyErr_Format(PyExc_Exception, "uobject is not a UBlueprint");
1424-
UBlueprint *bp = (UBlueprint *)py_obj->ue_object;
1416+
UBlueprint *bp = ue_py_check_type<UBlueprint>(py_blueprint);
1417+
if (!bp)
1418+
return PyErr_Format(PyExc_Exception, "uobject is not a Blueprint");
14251419

14261420
bool visible = false;
14271421
if (PyObject_IsTrue(visibility))
@@ -1431,8 +1425,7 @@ PyObject *py_unreal_engine_blueprint_set_variable_visibility(PyObject * self, Py
14311425

14321426
FBlueprintEditorUtils::SetBlueprintOnlyEditableFlag(bp, FName(UTF8_TO_TCHAR(name)), !visible);
14331427

1434-
Py_INCREF(Py_None);
1435-
return Py_None;
1428+
Py_RETURN_NONE;
14361429
}
14371430

14381431
PyObject *py_unreal_engine_blueprint_add_new_timeline(PyObject * self, PyObject * args)
@@ -1885,7 +1878,7 @@ PyObject *py_unreal_engine_move_selected_actors_to_level(PyObject *self, PyObjec
18851878
#endif
18861879

18871880
Py_RETURN_NONE;
1888-
}
1881+
}
18891882

18901883
PyObject *py_unreal_engine_move_actor_to_level(PyObject *self, PyObject * args)
18911884
{

‎Source/UnrealEnginePython/Private/UEPyModule.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,8 @@ static PyMethodDef ue_PyUObject_methods[] = {
583583
{ "node_find_pin", (PyCFunction)py_ue_node_find_pin, METH_VARARGS, "" },
584584
{ "node_create_pin", (PyCFunction)py_ue_node_create_pin, METH_VARARGS, "" },
585585

586+
{ "node_function_entry_set_pure", (PyCFunction)py_ue_node_function_entry_set_pure, METH_VARARGS, "" },
587+
586588
{ "node_allocate_default_pins", (PyCFunction)py_ue_node_allocate_default_pins, METH_VARARGS, "" },
587589
{ "node_reconstruct", (PyCFunction)py_ue_node_reconstruct, METH_VARARGS, "" },
588590

0 commit comments

Comments
 (0)