Repository navigation
Expand file tree
/
Copy pathUEPyUserDefinedStruct.cpp
More file actions
142 lines (98 loc) · 3.56 KB
/
Copy pathUEPyUserDefinedStruct.cpp
File metadata and controls
142 lines (98 loc) · 3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#include "UEPyUserDefinedStruct.h"
#if WITH_EDITOR
#include "Classes/UserDefinedStructure/UserDefinedStructEditorData.h"
#include "Public/Kismet2/StructureEditorUtils.h"
PyObject *py_ue_struct_add_variable(ue_PyUObject * self, PyObject * args)
{
ue_py_check(self);
PyObject *py_var;
if (!PyArg_ParseTuple(args, "O:struct_add_variable", &py_var))
{
return nullptr;
}
UUserDefinedStruct *u_struct = ue_py_check_type<UUserDefinedStruct>(self);
if (!u_struct)
return PyErr_Format(PyExc_Exception, "uobject is not a UUserDefinedStruct");
FStructVariableDescription *var = ue_py_check_struct<FStructVariableDescription>(py_var);
if (!var)
return PyErr_Format(PyExc_Exception, "argument is not a FStructVariableDescription");
var->VarGuid = FGuid::NewGuid();
FStructureEditorUtils::GetVarDesc(u_struct).Add(*var);
FStructureEditorUtils::OnStructureChanged(u_struct, FStructureEditorUtils::EStructureEditorChangeInfo::AddedVariable);
return py_ue_new_uscriptstruct(FindObject<UScriptStruct>(ANY_PACKAGE, UTF8_TO_TCHAR((char *)"Guid")), (uint8 *)&var->VarGuid);
}
PyObject *py_ue_struct_get_variables(ue_PyUObject * self, PyObject * args)
{
ue_py_check(self);
UUserDefinedStruct *u_struct = ue_py_check_type<UUserDefinedStruct>(self);
if (!u_struct)
return PyErr_Format(PyExc_Exception, "uobject is not a UUserDefinedStruct");
TArray<FStructVariableDescription> variables = FStructureEditorUtils::GetVarDesc(u_struct);
PyObject *py_list = PyList_New(0);
for (FStructVariableDescription description : variables)
{
PyList_Append(py_list, py_ue_new_uscriptstruct(FStructVariableDescription::StaticStruct(), (uint8*)&description));
}
return py_list;
}
PyObject *py_ue_struct_remove_variable(ue_PyUObject * self, PyObject * args)
{
ue_py_check(self);
PyObject *py_guid;
if (!PyArg_ParseTuple(args, "O:struct_remove_variable", &py_guid))
{
return nullptr;
}
UUserDefinedStruct *u_struct = ue_py_check_type<UUserDefinedStruct>(self);
if (!u_struct)
return PyErr_Format(PyExc_Exception, "uobject is not a UUserDefinedStruct");
FGuid *guid = ue_py_check_fguid(py_guid);
if (!guid)
return PyErr_Format(PyExc_Exception, "object is not a FGuid");
if (FStructureEditorUtils::RemoveVariable(u_struct, *guid))
{
Py_RETURN_TRUE;
}
Py_RETURN_FALSE;
}
PyObject *py_ue_struct_move_variable_up(ue_PyUObject * self, PyObject * args)
{
ue_py_check(self);
PyObject *py_guid;
if (!PyArg_ParseTuple(args, "O:struct_move_variable_up", &py_guid))
{
return nullptr;
}
UUserDefinedStruct *u_struct = ue_py_check_type<UUserDefinedStruct>(self);
if (!u_struct)
return PyErr_Format(PyExc_Exception, "uobject is not a UUserDefinedStruct");
FGuid *guid = ue_py_check_fguid(py_guid);
if (!guid)
return PyErr_Format(PyExc_Exception, "object is not a FGuid");
if (FStructureEditorUtils::MoveVariable(u_struct, *guid, FStructureEditorUtils::EMoveDirection::MD_Up))
{
Py_RETURN_TRUE;
}
Py_RETURN_FALSE;
}
PyObject *py_ue_struct_move_variable_down(ue_PyUObject * self, PyObject * args)
{
ue_py_check(self);
PyObject *py_guid;
if (!PyArg_ParseTuple(args, "O:struct_move_variable_down", &py_guid))
{
return nullptr;
}
UUserDefinedStruct *u_struct = ue_py_check_type<UUserDefinedStruct>(self);
if (!u_struct)
return PyErr_Format(PyExc_Exception, "uobject is not a UUserDefinedStruct");
FGuid *guid = ue_py_check_fguid(py_guid);
if (!guid)
return PyErr_Format(PyExc_Exception, "object is not a FGuid");
if (FStructureEditorUtils::MoveVariable(u_struct, *guid, FStructureEditorUtils::EMoveDirection::MD_Down))
{
Py_RETURN_TRUE;
}
Py_RETURN_FALSE;
}
#endif