Skip to content

Commit 33ac302

Browse files
author
Roberto De Ioris
committed
added SDirectoryPicker
1 parent a77e19f commit 33ac302

9 files changed

Lines changed: 88 additions & 70 deletions

Source/UnrealEnginePython/Private/Slate/UEPySColorBlock.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#pragma once
22

3-
#include "UnrealEnginePython.h"
4-
5-
63
#include "UEPySLeafWidget.h"
74

85
#include "Runtime/Slate/Public/Widgets/Colors/SColorBlock.h"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#pragma once
2+
3+
#include "UEPySCompoundWidget.h"
4+
5+
#if WITH_EDITOR
6+
#if ENGINE_MINOR_VERSION > 13
7+
8+
#include "Developer/DesktopWidgets/Public/Widgets/Input/SDirectoryPicker.h"
9+
10+
extern PyTypeObject ue_PySDirectoryPickerType;
11+
12+
typedef struct
13+
{
14+
ue_PySCompoundWidget s_compound_widget;
15+
/* Type-specific fields go here. */
16+
} ue_PySDirectoryPicker;
17+
18+
void ue_python_init_sdirectory_picker(PyObject *);
19+
#endif
20+
#endif

Source/UnrealEnginePython/Private/Slate/UEPySEditableTextBox.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#pragma once
22

3-
#include "UnrealEnginePython.h"
4-
53
#include "UEPySBorder.h"
64

75
#include "Runtime/Slate/Public/Widgets/Input/SEditableTextBox.h"

Source/UnrealEnginePython/Private/Slate/UEPySFilePathPicker.cpp

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,7 @@ static PyMethodDef ue_PySFilePathPicker_methods[] = {
77
{ NULL } /* Sentinel */
88
};
99

10-
PyTypeObject ue_PySFilePathPickerType = {
11-
PyVarObject_HEAD_INIT(NULL, 0)
12-
"unreal_engine.SFilePathPicker", /* tp_name */
13-
sizeof(ue_PySFilePathPicker), /* tp_basicsize */
14-
0, /* tp_itemsize */
15-
0, /* tp_dealloc */
16-
0, /* tp_print */
17-
0, /* tp_getattr */
18-
0, /* tp_setattr */
19-
0, /* tp_reserved */
20-
0, /* tp_repr */
21-
0, /* tp_as_number */
22-
0, /* tp_as_sequence */
23-
0, /* tp_as_mapping */
24-
0, /* tp_hash */
25-
0, /* tp_call */
26-
0, /* tp_str */
27-
0, /* tp_getattro */
28-
0, /* tp_setattro */
29-
0, /* tp_as_buffer */
30-
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
31-
"Unreal Engine SFilePathPicker", /* tp_doc */
32-
0, /* tp_traverse */
33-
0, /* tp_clear */
34-
0, /* tp_richcompare */
35-
0, /* tp_weaklistoffset */
36-
0, /* tp_iter */
37-
0, /* tp_iternext */
38-
ue_PySFilePathPicker_methods, /* tp_methods */
39-
};
10+
DECLARE_UE_PY_SLATE_WIDGET(SFilePathPicker);
4011

4112
static int ue_py_sfile_path_picker_init(ue_PySFilePathPicker *self, PyObject *args, PyObject *kwargs)
4213
{

Source/UnrealEnginePython/Private/Slate/UEPySFilePathPicker.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#pragma once
22

3-
#include "UnrealEnginePython.h"
4-
53
#include "UEPySCompoundWidget.h"
64

75
#if WITH_EDITOR
@@ -10,7 +8,8 @@
108

119
extern PyTypeObject ue_PySFilePathPickerType;
1210

13-
typedef struct {
11+
typedef struct
12+
{
1413
ue_PySCompoundWidget s_compound_widget;
1514
/* Type-specific fields go here. */
1615
} ue_PySFilePathPicker;

Source/UnrealEnginePython/Private/Slate/UEPySHeaderRow.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#pragma once
22

3-
#include "UnrealEnginePython.h"
4-
53
#include "UEPySBorder.h"
64

75
#include "Runtime/Slate/Public/Widgets/Views/SHeaderRow.h"

Source/UnrealEnginePython/Private/Slate/UEPySObjectPropertyEntryBox.cpp

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,7 @@ static PyMethodDef ue_PySObjectPropertyEntryBox_methods[] = {
77
{ NULL } /* Sentinel */
88
};
99

10-
PyTypeObject ue_PySObjectPropertyEntryBoxType = {
11-
PyVarObject_HEAD_INIT(NULL, 0)
12-
"unreal_engine.SObjectPropertyEntryBox", /* tp_name */
13-
sizeof(ue_PySObjectPropertyEntryBox), /* tp_basicsize */
14-
0, /* tp_itemsize */
15-
0, /* tp_dealloc */
16-
0, /* tp_print */
17-
0, /* tp_getattr */
18-
0, /* tp_setattr */
19-
0, /* tp_reserved */
20-
0, /* tp_repr */
21-
0, /* tp_as_number */
22-
0, /* tp_as_sequence */
23-
0, /* tp_as_mapping */
24-
0, /* tp_hash */
25-
0, /* tp_call */
26-
0, /* tp_str */
27-
0, /* tp_getattro */
28-
0, /* tp_setattro */
29-
0, /* tp_as_buffer */
30-
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
31-
"Unreal Engine SObjectPropertyEntryBox", /* tp_doc */
32-
0, /* tp_traverse */
33-
0, /* tp_clear */
34-
0, /* tp_richcompare */
35-
0, /* tp_weaklistoffset */
36-
0, /* tp_iter */
37-
0, /* tp_iternext */
38-
ue_PySObjectPropertyEntryBox_methods, /* tp_methods */
39-
};
10+
DECLARE_UE_PY_SLATE_WIDGET(SObjectPropertyEntryBox);
4011

4112
static int ue_py_sobject_property_entry_box_init(ue_PySObjectPropertyEntryBox *self, PyObject *args, PyObject *kwargs)
4213
{

Source/UnrealEnginePython/Private/Slate/UEPySlate.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
#include "UEPySGraphEditor.h"
9797
#include "UEPySPythonShelf.h"
9898
#include "UEPySFilePathPicker.h"
99+
#include "UEPySDirectoryPicker.h"
99100
#include "UEPySDropTarget.h"
100101
#include "UEPySAssetDropTarget.h"
101102
#include "UEPySObjectPropertyEntryBox.h"
@@ -901,6 +902,7 @@ void ue_python_init_slate(PyObject *module)
901902
ue_python_init_spython_shelf(module);
902903
#if ENGINE_MINOR_VERSION > 13
903904
ue_python_init_sfile_path_picker(module);
905+
ue_python_init_sdirectory_picker(module);
904906
#endif
905907
#endif
906908
ue_python_init_sdrop_target(module);

0 commit comments

Comments
 (0)