|
| 1 | +#include "UEPySDirectoryPicker.h" |
| 2 | + |
| 3 | +#if WITH_EDITOR |
| 4 | +#if ENGINE_MINOR_VERSION > 13 |
| 5 | + |
| 6 | + |
| 7 | +static PyObject *py_ue_sdirectory_picker_get_directory(ue_PySDirectoryPicker *self, PyObject * args) |
| 8 | +{ |
| 9 | + ue_py_slate_cast(SDirectoryPicker); |
| 10 | + FString Directory = py_SDirectoryPicker->GetDirectory(); |
| 11 | + |
| 12 | + return PyUnicode_FromString(TCHAR_TO_UTF8(*Directory)); |
| 13 | +} |
| 14 | + |
| 15 | +static PyObject *py_ue_sdirectory_picker_get_file_path(ue_PySDirectoryPicker *self, PyObject * args) |
| 16 | +{ |
| 17 | + ue_py_slate_cast(SDirectoryPicker); |
| 18 | + FString FilePath = py_SDirectoryPicker->GetFilePath(); |
| 19 | + |
| 20 | + return PyUnicode_FromString(TCHAR_TO_UTF8(*FilePath)); |
| 21 | +} |
| 22 | + |
| 23 | + |
| 24 | +static PyMethodDef ue_PySDirectoryPicker_methods[] = { |
| 25 | + { "get_directory", (PyCFunction)py_ue_sdirectory_picker_get_directory, METH_VARARGS, "" }, |
| 26 | + { "get_file_path", (PyCFunction)py_ue_sdirectory_picker_get_file_path, METH_VARARGS, "" }, |
| 27 | + { NULL } /* Sentinel */ |
| 28 | +}; |
| 29 | + |
| 30 | +DECLARE_UE_PY_SLATE_WIDGET(SDirectoryPicker); |
| 31 | + |
| 32 | +DECLARE_DELEGATE_OneParam(FOnDirectoryChanged, const FString& /*Directory*/); |
| 33 | + |
| 34 | +static int ue_py_sdirectory_picker_init(ue_PySDirectoryPicker *self, PyObject *args, PyObject *kwargs) |
| 35 | +{ |
| 36 | + ue_py_slate_setup_farguments(SDirectoryPicker); |
| 37 | + |
| 38 | + ue_py_slate_farguments_optional_text("message", Message); |
| 39 | + ue_py_slate_farguments_optional_string("directory", Directory); |
| 40 | + ue_py_slate_farguments_optional_string("file", File); |
| 41 | + ue_py_slate_farguments_bool("is_enabled", IsEnabled); |
| 42 | + ue_py_slate_farguments_event("on_directory_changed", OnDirectoryChanged, FOnDirectoryChanged, OnStringChanged); |
| 43 | + |
| 44 | + ue_py_snew(SDirectoryPicker); |
| 45 | + return 0; |
| 46 | +} |
| 47 | + |
| 48 | +void ue_python_init_sdirectory_picker(PyObject *ue_module) |
| 49 | +{ |
| 50 | + |
| 51 | + ue_PySDirectoryPickerType.tp_init = (initproc)ue_py_sdirectory_picker_init; |
| 52 | + |
| 53 | + ue_PySDirectoryPickerType.tp_base = &ue_PySCompoundWidgetType; |
| 54 | + |
| 55 | + if (PyType_Ready(&ue_PySDirectoryPickerType) < 0) |
| 56 | + return; |
| 57 | + |
| 58 | + Py_INCREF(&ue_PySDirectoryPickerType); |
| 59 | + PyModule_AddObject(ue_module, "SDirectoryPicker", (PyObject *)&ue_PySDirectoryPickerType); |
| 60 | +} |
| 61 | +#endif |
| 62 | +#endif |
0 commit comments