Skip to content

Commit a74a33e

Browse files
committed
added read-only access to pin direction and subcategory object
1 parent fda6204 commit a74a33e

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraphPin.cpp

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,26 @@ static PyObject *py_ue_edgraphpin_get_sub_category(ue_PyEdGraphPin *self, void *
114114
#endif
115115
}
116116

117+
static PyObject *py_ue_edgraphpin_get_sub_category_object(ue_PyEdGraphPin *self, void *closure)
118+
{
119+
TWeakObjectPtr<UObject> u_object = self->pin->PinType.PinSubCategoryObject;
120+
if (!u_object.IsValid())
121+
{
122+
Py_RETURN_NONE;
123+
}
124+
Py_RETURN_UOBJECT(u_object.Get());
125+
}
126+
117127
static PyObject *py_ue_edgraphpin_get_default_value(ue_PyEdGraphPin *self, void *closure)
118128
{
119129
return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->pin->DefaultValue)));
120130
}
121131

132+
static PyObject *py_ue_edgraphpin_get_direction(ue_PyEdGraphPin *self, void *closure)
133+
{
134+
return PyLong_FromLong(self->pin->Direction);
135+
}
136+
122137
static int py_ue_edgraphpin_set_default_value(ue_PyEdGraphPin *self, PyObject *value, void *closure)
123138
{
124139
if (value && PyUnicodeOrString_Check(value))
@@ -217,19 +232,26 @@ static PyGetSetDef ue_PyEdGraphPin_getseters[] = {
217232
{ (char*)"name", (getter)py_ue_edgraphpin_get_name, NULL, (char *)"", NULL },
218233
{ (char*)"category", (getter)py_ue_edgraphpin_get_category, (setter)py_ue_edgraphpin_set_category, (char *)"", NULL },
219234
{ (char*)"sub_category", (getter)py_ue_edgraphpin_get_sub_category, (setter)py_ue_edgraphpin_set_sub_category, (char *)"", NULL },
235+
{ (char*)"sub_category_object", (getter)py_ue_edgraphpin_get_sub_category_object, NULL, (char*)"", NULL },
220236
{ (char*)"default_value", (getter)py_ue_edgraphpin_get_default_value, (setter)py_ue_edgraphpin_set_default_value, (char *)"", NULL },
221237
{ (char*)"default_text_value", (getter)py_ue_edgraphpin_get_default_text_value, (setter)py_ue_edgraphpin_set_default_text_value, (char *)"", NULL },
222238
{ (char*)"default_object", (getter)py_ue_edgraphpin_get_default_object, (setter)py_ue_edgraphpin_set_default_object, (char *)"", NULL },
239+
{ (char*)"direction", (getter)py_ue_edgraphpin_get_direction, NULL, (char*)"", NULL },
223240
{ NULL } /* Sentinel */
224241
};
225242

226243
static PyObject *ue_PyEdGraphPin_str(ue_PyEdGraphPin *self)
227244
{
228-
return PyUnicode_FromFormat("<unreal_engine.EdGraphPin {'name': '%s', 'type': '%s'}>",
245+
FString dir = _T("???");
246+
if (self->pin->Direction == EEdGraphPinDirection::EGPD_Input)
247+
dir = _T("in");
248+
else if (self->pin->Direction == EEdGraphPinDirection::EGPD_Output)
249+
dir = _T("out");
250+
return PyUnicode_FromFormat("<unreal_engine.EdGraphPin {'name': '%s', 'type': '%s', 'direction': '%s'}>",
229251
#if ENGINE_MINOR_VERSION > 18
230-
TCHAR_TO_UTF8(*self->pin->PinName.ToString()), TCHAR_TO_UTF8(*self->pin->PinType.PinCategory.ToString()));
252+
TCHAR_TO_UTF8(*self->pin->PinName.ToString()), TCHAR_TO_UTF8(*self->pin->PinType.PinCategory.ToString()), TCHAR_TO_UTF8(*dir));
231253
#else
232-
TCHAR_TO_UTF8(*self->pin->PinName), TCHAR_TO_UTF8(*self->pin->PinType.PinCategory));
254+
TCHAR_TO_UTF8(*self->pin->PinName), TCHAR_TO_UTF8(*self->pin->PinType.PinCategory), TCHAR_TO_UTF8(*dir));
233255
#endif
234256
}
235257

0 commit comments

Comments
 (0)