Skip to content

Commit 739b65a

Browse files
author
Roberto De Ioris
committed
improved SObjectPropertyEntryBox
1 parent 7824830 commit 739b65a

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

Source/UnrealEnginePython/Private/Slate/UEPySObjectPropertyEntryBox.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ PyTypeObject ue_PySObjectPropertyEntryBoxType = {
4444
static int ue_py_sobject_property_entry_box_init(ue_PySObjectPropertyEntryBox *self, PyObject *args, PyObject *kwargs) {
4545
ue_py_slate_setup_farguments(SObjectPropertyEntryBox);
4646

47+
ue_py_slate_farguments_optional_bool("allow_clear", AllowClear);
48+
ue_py_slate_farguments_optional_bool("display_browse", DisplayBrowse);
49+
ue_py_slate_farguments_optional_bool("display_use_selected", DisplayUseSelected);
50+
ue_py_slate_farguments_optional_bool("enable_content_picker", EnableContentPicker);
51+
ue_py_slate_farguments_string("object_path", ObjectPath);
52+
53+
ue_py_slate_farguments_optional_uobject("allowed_class", AllowedClass, UClass);
54+
55+
ue_py_slate_farguments_event("on_object_changed", OnObjectChanged, FOnSetObject, OnAssetChanged);
56+
4757
ue_py_snew(SObjectPropertyEntryBox, s_compound_widget.s_widget);
4858
return 0;
4959
}

Source/UnrealEnginePython/Private/Slate/UEPySlate.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,16 @@ void UPythonSlateDelegate::OnAssetSelected(const FAssetData& AssetData) {
172172
Py_XDECREF(ret);
173173
}
174174

175+
void UPythonSlateDelegate::OnAssetChanged(const FAssetData& AssetData) {
176+
FScopePythonGIL gil;
177+
178+
PyObject *ret = PyObject_CallFunction(py_callable, (char *)"O", py_ue_new_fassetdata((FAssetData *)&AssetData));
179+
if (!ret) {
180+
unreal_engine_py_log_error();
181+
}
182+
Py_XDECREF(ret);
183+
}
184+
175185
TSharedPtr<SWidget> UPythonSlateDelegate::OnGetAssetContextMenu(const TArray<FAssetData>& SelectedAssets) {
176186
FScopePythonGIL gil;
177187

Source/UnrealEnginePython/Private/Slate/UEPySlate.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,18 @@ ue_PySWidget *ue_py_get_swidget(TSharedRef<SWidget> s_widget);
279279
}\
280280
}
281281

282+
#define ue_py_slate_farguments_optional_uobject(param, attribute, _type) { PyObject *value = ue_py_dict_get_item(kwargs, param);\
283+
if (value) {\
284+
if (_type *u_object = ue_py_check_type<_type>(value)) {\
285+
arguments.attribute((_type *)u_object);\
286+
}\
287+
else {\
288+
PyErr_SetString(PyExc_TypeError, "unsupported type for attribute " param); \
289+
return -1;\
290+
}\
291+
}\
292+
}
293+
282294

283295
#define ue_py_slate_farguments_optional_fvector2d(param, attribute) { PyObject *value = ue_py_dict_get_item(kwargs, param);\
284296
if (value) {\
@@ -439,6 +451,7 @@ class UPythonSlateDelegate : public UPythonDelegate
439451
void OnAssetSelected(const FAssetData& AssetData);
440452
TSharedRef<FExtender> OnExtendContentBrowserMenu(const TArray<FAssetData> &SelectedAssets);
441453
void MenuPyAssetBuilder(FMenuBuilder &Builder, TArray<FAssetData> SelectedAssets);
454+
void OnAssetChanged(const FAssetData &);
442455
#endif
443456

444457
TSharedPtr<SWidget> OnContextMenuOpening();

0 commit comments

Comments
 (0)