Skip to content

Commit 2f64a70

Browse files
author
Roberto De Ioris
committed
first round of merges for Kite & Lightning pull request #445
1 parent 560a5d0 commit 2f64a70

File tree

6 files changed

+143
-19
lines changed

6 files changed

+143
-19
lines changed

Source/UnrealEnginePython/Private/Fbx/UEPyFbxProperty.cpp

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,36 @@
55

66
#include "UEPyFbx.h"
77

8-
static PyObject *py_ue_fbx_property_get_name(ue_PyFbxProperty *self, PyObject *args) {
8+
static PyObject *py_ue_fbx_property_get_name(ue_PyFbxProperty *self, PyObject *args)
9+
{
910
return PyUnicode_FromString(self->fbx_property.GetName());
1011
}
1112

12-
static PyObject *py_ue_fbx_property_get_double3(ue_PyFbxProperty *self, PyObject *args) {
13+
static PyObject *py_ue_fbx_property_get_double3(ue_PyFbxProperty *self, PyObject *args)
14+
{
1315
FbxDouble3 value = self->fbx_property.Get<FbxDouble3>();
1416
return Py_BuildValue((char *)"(fff)", value[0], value[1], value[2]);
1517
}
1618

17-
static PyObject *py_ue_fbx_property_get_string(ue_PyFbxProperty *self, PyObject *args) {
18-
return PyUnicode_FromString(self->fbx_property.Get<FbxString>());
19+
static PyObject *py_ue_fbx_property_get_string(ue_PyFbxProperty *self, PyObject *args)
20+
{
21+
return PyUnicode_FromString(self->fbx_property.Get<FbxString>());
1922
}
2023

21-
static PyObject *py_ue_fbx_property_is_valid(ue_PyFbxProperty *self, PyObject *args) {
22-
if (self->fbx_property.IsValid()) {
24+
static PyObject *py_ue_fbx_property_is_valid(ue_PyFbxProperty *self, PyObject *args)
25+
{
26+
if (self->fbx_property.IsValid())
27+
{
2328
Py_RETURN_TRUE;
2429
}
2530
Py_RETURN_FALSE;
2631
}
2732

28-
static PyObject *py_ue_fbx_property_get_curve_node(ue_PyFbxProperty *self, PyObject *args) {
33+
static PyObject *py_ue_fbx_property_get_curve_node(ue_PyFbxProperty *self, PyObject *args)
34+
{
2935
PyObject *py_object;
30-
if (!PyArg_ParseTuple(args, "O", &py_object)) {
36+
if (!PyArg_ParseTuple(args, "O", &py_object))
37+
{
3138
return nullptr;
3239
}
3340

@@ -45,10 +52,28 @@ static PyObject *py_ue_fbx_property_get_curve_node(ue_PyFbxProperty *self, PyObj
4552
return py_ue_new_fbx_object(fbx_anim_curve_node);
4653
}
4754

55+
static PyObject *py_ue_fbx_property_get_bool(ue_PyFbxProperty *self, PyObject *args)
56+
{
57+
if (self->fbx_property.Get<FbxBool>())
58+
Py_RETURN_TRUE;
59+
60+
Py_RETURN_FALSE;
61+
62+
}
63+
64+
static PyObject *py_ue_fbx_property_get_int(ue_PyFbxProperty *self, PyObject *args)
65+
{
66+
return PyLong_FromLong(self->fbx_property.Get<FbxInt>());
67+
68+
}
69+
70+
4871
static PyMethodDef ue_PyFbxProperty_methods[] = {
4972
{ "get_name", (PyCFunction)py_ue_fbx_property_get_name, METH_VARARGS, "" },
5073
{ "get_double3", (PyCFunction)py_ue_fbx_property_get_double3, METH_VARARGS, "" },
51-
{ "get_string", (PyCFunction)py_ue_fbx_property_get_string, METH_VARARGS, "" },
74+
{ "get_string", (PyCFunction)py_ue_fbx_property_get_string, METH_VARARGS, "" },
75+
{ "get_bool", (PyCFunction)py_ue_fbx_property_get_bool, METH_VARARGS, "" },
76+
{ "get_int", (PyCFunction)py_ue_fbx_property_get_int, METH_VARARGS, "" },
5277
{ "is_valid", (PyCFunction)py_ue_fbx_property_is_valid, METH_VARARGS, "" },
5378
{ "get_curve_node", (PyCFunction)py_ue_fbx_property_get_curve_node, METH_VARARGS, "" },
5479
{ NULL } /* Sentinel */
@@ -87,12 +112,14 @@ static PyTypeObject ue_PyFbxPropertyType = {
87112
0, /* tp_getset */
88113
};
89114

90-
static int py_ue_fbx_property_init(ue_PyFbxProperty *self, PyObject * args) {
115+
static int py_ue_fbx_property_init(ue_PyFbxProperty *self, PyObject * args)
116+
{
91117
PyErr_SetString(PyExc_Exception, "instantiating a new FbxProperty is currently not supported");
92118
return -1;
93119
}
94120

95-
void ue_python_init_fbx_property(PyObject *ue_module) {
121+
void ue_python_init_fbx_property(PyObject *ue_module)
122+
{
96123
ue_PyFbxPropertyType.tp_new = PyType_GenericNew;;
97124
ue_PyFbxPropertyType.tp_init = (initproc)py_ue_fbx_property_init;
98125
if (PyType_Ready(&ue_PyFbxPropertyType) < 0)
@@ -102,13 +129,15 @@ void ue_python_init_fbx_property(PyObject *ue_module) {
102129
PyModule_AddObject(ue_module, "FbxProperty", (PyObject *)&ue_PyFbxPropertyType);
103130
}
104131

105-
PyObject *py_ue_new_fbx_property(FbxProperty fbx_property) {
132+
PyObject *py_ue_new_fbx_property(FbxProperty fbx_property)
133+
{
106134
ue_PyFbxProperty *ret = (ue_PyFbxProperty *)PyObject_New(ue_PyFbxProperty, &ue_PyFbxPropertyType);
107135
ret->fbx_property = fbx_property;
108136
return (PyObject *)ret;
109137
}
110138

111-
ue_PyFbxProperty *py_ue_is_fbx_property(PyObject *obj) {
139+
ue_PyFbxProperty *py_ue_is_fbx_property(PyObject *obj)
140+
{
112141
if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFbxPropertyType))
113142
return nullptr;
114143
return (ue_PyFbxProperty *)obj;

Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ static PyObject *py_ue_fmenu_builder_add_menu_entry(ue_PyFMenuBuilder *self, PyO
3434
char *tooltip;
3535
PyObject *py_callable;
3636
PyObject *py_obj = nullptr;
37-
PyObject *py_uiaction_obj = nullptr;
38-
if (!PyArg_ParseTuple(args, "ssO|OO:add_menu_entry", &label, &tooltip, &py_callable, &py_obj, &py_uiaction_obj))
37+
int ui_action_type = EUserInterfaceActionType::Button;
38+
if (!PyArg_ParseTuple(args, "ssO|Oi:add_menu_entry", &label, &tooltip, &py_callable, &py_obj, &ui_action_type))
3939
return nullptr;
4040

4141
if (!PyCallable_Check(py_callable))
@@ -57,9 +57,8 @@ static PyObject *py_ue_fmenu_builder_add_menu_entry(ue_PyFMenuBuilder *self, PyO
5757
handler.BindSP(py_delegate, &FPythonSlateDelegate::SimpleExecuteAction);
5858
}
5959

60-
ue_PyESlateEnums *py_uiaction_enum = py_uiaction_obj ? py_ue_is_eslate_enums(py_uiaction_obj) : nullptr;
6160
self->menu_builder.AddMenuEntry(FText::FromString(UTF8_TO_TCHAR(label)), FText::FromString(UTF8_TO_TCHAR(tooltip)), FSlateIcon(), FUIAction(handler), NAME_None,
62-
py_uiaction_enum ? (EUserInterfaceActionType::Type)(py_uiaction_enum->val) : EUserInterfaceActionType::Button);
61+
(EUserInterfaceActionType::Type)ui_action_type);
6362

6463
Py_RETURN_NONE;
6564
}

Source/UnrealEnginePython/Private/Slate/UEPySBox.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,42 @@ static PyObject *py_ue_sbox_set_content(ue_PySBox *self, PyObject * args)
2020
Py_RETURN_SLATE_SELF;
2121
}
2222

23+
static PyObject *py_ue_sbox_set_height_override(ue_PySBox *self, PyObject * args)
24+
{
25+
ue_py_slate_cast(SBox);
26+
27+
float height_override = 0;
28+
if (!PyArg_ParseTuple(args, "f:set_height_override", &height_override))
29+
{
30+
return NULL;
31+
}
32+
33+
if (height_override != 0)
34+
py_SBox->SetHeightOverride(height_override);
35+
36+
Py_RETURN_NONE;
37+
}
38+
39+
static PyObject *py_ue_sbox_set_width_override(ue_PySBox *self, PyObject * args)
40+
{
41+
ue_py_slate_cast(SBox);
42+
43+
float width_override = 0;
44+
if (!PyArg_ParseTuple(args, "f:set_width_override", &width_override))
45+
{
46+
return NULL;
47+
}
48+
49+
if (width_override != 0)
50+
py_SBox->SetWidthOverride(width_override);
51+
52+
Py_RETURN_NONE;
53+
}
54+
2355
static PyMethodDef ue_PySBox_methods[] = {
2456
{ "set_content", (PyCFunction)py_ue_sbox_set_content, METH_VARARGS, "" },
57+
{ "set_height_override", (PyCFunction)py_ue_sbox_set_height_override, METH_VARARGS, "" },
58+
{ "set_width_override", (PyCFunction)py_ue_sbox_set_width_override, METH_VARARGS, "" },
2559
{ NULL } /* Sentinel */
2660
};
2761

@@ -65,6 +99,7 @@ static int ue_py_sbox_init(ue_PySBox *self, PyObject *args, PyObject *kwargs)
6599
ue_py_slate_farguments_optional_enum("v_align", VAlign, EVerticalAlignment);
66100
ue_py_slate_farguments_struct("padding", Padding, FMargin);
67101
ue_py_slate_farguments_optional_foptional_size("height_override", HeightOverride);
102+
ue_py_slate_farguments_optional_foptional_size("width_override", WidthOverride);
68103
#if ENGINE_MINOR_VERSION > 12
69104
ue_py_slate_farguments_optional_foptional_size("max_aspect_ratio", MaxAspectRatio);
70105
#endif

Source/UnrealEnginePython/Private/Slate/UEPySCheckBox.cpp

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,49 @@ static PyObject *py_ue_scheck_box_is_checked(ue_PySCheckBox *self, PyObject * ar
1212
Py_RETURN_FALSE;
1313
}
1414

15+
static PyObject *py_ue_scheck_box_set_is_checked(ue_PySCheckBox *self, PyObject * args)
16+
{
17+
ue_py_slate_cast(SCheckBox);
18+
PyObject * py_bool;
19+
if (!PyArg_ParseTuple(args, "O:set_is_checked", &py_bool))
20+
{
21+
return NULL;
22+
}
23+
24+
ECheckBoxState CheckedState = PyObject_IsTrue(py_bool) ? ECheckBoxState::Checked : ECheckBoxState::Unchecked;
25+
26+
py_SCheckBox->SetIsChecked(TAttribute<ECheckBoxState>(CheckedState));
27+
28+
Py_RETURN_NONE;
29+
30+
}
31+
32+
static PyObject *py_ue_scheck_box_set_content(ue_PySCheckBox *self, PyObject * args)
33+
{
34+
ue_py_slate_cast(SCheckBox);
35+
PyObject * py_content;
36+
if (!PyArg_ParseTuple(args, "O:set_content", &py_content))
37+
{
38+
return NULL;
39+
}
40+
41+
TSharedPtr<SWidget> child = py_ue_is_swidget<SWidget>(py_content);
42+
if (!child.IsValid())
43+
{
44+
return nullptr;
45+
}
46+
47+
48+
49+
py_SCheckBox->SetContent(child.ToSharedRef());
50+
51+
Py_RETURN_SLATE_SELF;
52+
}
53+
1554
static PyMethodDef ue_PySCheckBox_methods[] = {
1655
{ "is_checked", (PyCFunction)py_ue_scheck_box_is_checked, METH_VARARGS, "" },
56+
{ "set_content", (PyCFunction)py_ue_scheck_box_set_content, METH_VARARGS, "" },
57+
{ "set_is_checked", (PyCFunction)py_ue_scheck_box_set_is_checked, METH_VARARGS, "" },
1758
{ NULL } /* Sentinel */
1859
};
1960

@@ -56,7 +97,23 @@ static int ue_py_scheck_box_init(ue_PySCheckBox *self, PyObject *args, PyObject
5697
ue_py_slate_farguments_struct("foreground_color", ForegroundColor, FSlateColor);
5798
ue_py_slate_farguments_enum("is_checked", IsChecked, ECheckBoxState);
5899
ue_py_slate_farguments_event("on_check_state_changed", OnCheckStateChanged, FOnCheckStateChanged, CheckBoxChanged);
59-
100+
ue_py_slate_farguments_optional_struct_ptr("style", Style, FCheckBoxStyle);
101+
ue_py_slate_farguments_optional_enum("type", Type, ESlateCheckBoxType::Type);
102+
ue_py_slate_farguments_event("on_check_state_changed", OnCheckStateChanged, FOnCheckStateChanged, CheckBoxChanged);
103+
ue_py_slate_farguments_enum("is_checked", IsChecked, ECheckBoxState);
104+
ue_py_slate_farguments_optional_enum("h_align", HAlign, EHorizontalAlignment);
105+
ue_py_slate_farguments_struct("padding", Padding, FMargin);
106+
ue_py_slate_farguments_enum("click_method", ClickMethod, EButtonClickMethod::Type);
107+
ue_py_slate_farguments_optional_bool("is_focusable", IsFocusable);
108+
ue_py_slate_farguments_optional_struct_ptr("unchecked_image", UncheckedImage, FSlateBrush);
109+
ue_py_slate_farguments_optional_struct_ptr("unchecked_hoveredimage", UncheckedHoveredImage, FSlateBrush);
110+
ue_py_slate_farguments_optional_struct_ptr("unchecked_pressedimage", UncheckedPressedImage, FSlateBrush);
111+
ue_py_slate_farguments_optional_struct_ptr("checked_image", CheckedImage, FSlateBrush);
112+
ue_py_slate_farguments_optional_struct_ptr("checked_hoveredimage", CheckedHoveredImage, FSlateBrush);
113+
ue_py_slate_farguments_optional_struct_ptr("checked_pressedimage", CheckedPressedImage, FSlateBrush);
114+
ue_py_slate_farguments_optional_struct_ptr("undetermined_image", UndeterminedImage, FSlateBrush);
115+
ue_py_slate_farguments_optional_struct_ptr("undetermined_hoveredimage", UndeterminedHoveredImage, FSlateBrush);
116+
ue_py_slate_farguments_optional_struct_ptr("undetermined_pressedimage", UndeterminedPressedImage, FSlateBrush);
60117
ue_py_snew(SCheckBox);
61118
return 0;
62119
}
@@ -65,6 +122,7 @@ void ue_python_init_scheck_box(PyObject *ue_module)
65122
{
66123

67124
ue_PySCheckBoxType.tp_init = (initproc)ue_py_scheck_box_init;
125+
ue_PySCheckBoxType.tp_call = (ternaryfunc)py_ue_scheck_box_set_content;
68126

69127
ue_PySCheckBoxType.tp_base = &ue_PySCompoundWidgetType;
70128

Source/UnrealEnginePython/Private/UEPyEngine.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ PyObject *py_unreal_engine_engine_tick(PyObject * self, PyObject * args)
504504
Py_RETURN_NONE;
505505
}
506506

507+
#if WITH_EDITOR
507508
PyObject *py_unreal_engine_tick_rendering_tickables(PyObject * self, PyObject * args)
508509
{
509510
Py_BEGIN_ALLOW_THREADS;
@@ -512,6 +513,7 @@ PyObject *py_unreal_engine_tick_rendering_tickables(PyObject * self, PyObject *
512513

513514
Py_RETURN_NONE;
514515
}
516+
#endif
515517

516518
PyObject *py_unreal_engine_get_delta_time(PyObject * self, PyObject * args)
517519
{

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,9 @@ static PyMethodDef unreal_engine_methods[] = {
364364
#endif
365365

366366
{ "engine_tick", py_unreal_engine_engine_tick, METH_VARARGS, "" },
367-
{ "tick_rendering_tickables", py_unreal_engine_tick_rendering_tickables, METH_VARARGS, "" },
367+
368368
#if WITH_EDITOR
369+
{ "tick_rendering_tickables", py_unreal_engine_tick_rendering_tickables, METH_VARARGS, "" },
369370
{ "all_viewport_clients", py_unreal_engine_all_viewport_clients , METH_VARARGS, "" },
370371
#endif
371372
{ "slate_tick", py_unreal_engine_slate_tick, METH_VARARGS, "" },

0 commit comments

Comments
 (0)