1+ #include " UEPyFSlowTask.h"
2+
3+ #include " Misc/FeedbackContext.h"
4+
5+ #if WITH_EDITOR
6+
7+ static PyObject *py_ue_fslowtask_initialize (ue_PyFSlowTask *self, PyObject * args)
8+ {
9+ self->slowtask .Initialize ();
10+
11+ Py_RETURN_NONE;
12+ }
13+
14+ static PyObject *py_ue_fslowtask_destroy (ue_PyFSlowTask *self, PyObject * args)
15+ {
16+ self->slowtask .Destroy ();
17+
18+ Py_RETURN_NONE;
19+ }
20+
21+ static PyObject *py_ue_fslowtask_make_dialog_delayed (ue_PyFSlowTask *self, PyObject * args)
22+ {
23+ float threshold;
24+ PyObject *py_show_cancel_button = nullptr ;
25+ PyObject *py_allow_in_pie = nullptr ;
26+ if (!PyArg_ParseTuple (args, " f|OO:make_dialog_delayed" , &threshold, &py_show_cancel_button, &py_allow_in_pie))
27+ {
28+ return nullptr ;
29+ }
30+
31+ bool show_cancel_button = false ;
32+ if (nullptr != py_show_cancel_button && PyObject_IsTrue (py_show_cancel_button))
33+ {
34+ show_cancel_button = true ;
35+ }
36+
37+ bool allow_in_pie = false ;
38+ if (nullptr != py_allow_in_pie && PyObject_IsTrue (py_allow_in_pie))
39+ {
40+ allow_in_pie = true ;
41+ }
42+
43+ self->slowtask .MakeDialogDelayed (threshold, show_cancel_button, allow_in_pie);
44+
45+ Py_RETURN_NONE;
46+ }
47+
48+ static PyObject *py_ue_fslowtask_make_dialog (ue_PyFSlowTask *self, PyObject * args)
49+ {
50+ PyObject *py_show_cancel_button = nullptr ;
51+ PyObject *py_allow_in_pie = nullptr ;
52+ if (!PyArg_ParseTuple (args, " |OO:make_dialog" , &py_show_cancel_button, &py_allow_in_pie))
53+ {
54+ return nullptr ;
55+ }
56+
57+ bool show_cancel_button = false ;
58+ if (nullptr != py_show_cancel_button && PyObject_IsTrue (py_show_cancel_button))
59+ {
60+ show_cancel_button = true ;
61+ }
62+
63+ bool allow_in_pie = false ;
64+ if (nullptr != py_allow_in_pie && PyObject_IsTrue (py_allow_in_pie))
65+ {
66+ allow_in_pie = true ;
67+ }
68+
69+ self->slowtask .MakeDialog (show_cancel_button, allow_in_pie);
70+
71+ Py_RETURN_NONE;
72+ }
73+
74+ static PyObject *py_ue_fslowtask_enter_progress_frame (ue_PyFSlowTask *self, PyObject * args)
75+ {
76+ float expected_work_this_frame = 1.0 ;
77+ char *text = " " ;
78+ if (!PyArg_ParseTuple (args, " |fs:enter_progress_frame" , &expected_work_this_frame, &text))
79+ {
80+ return nullptr ;
81+ }
82+
83+ self->slowtask .EnterProgressFrame (expected_work_this_frame, FText::FromString (UTF8_TO_TCHAR (text)));
84+
85+ Py_RETURN_NONE;
86+ }
87+
88+ static PyObject *py_ue_fslowtask_get_current_message (ue_PyFSlowTask *self, PyObject * args)
89+ {
90+ FText current_message = self->slowtask .GetCurrentMessage ();
91+ return PyUnicode_FromString (TCHAR_TO_UTF8 (*current_message.ToString ()));
92+ }
93+
94+ static PyObject *py_ue_fslowtask_received_user_cancel (ue_PyFSlowTask *self, PyObject * args )
95+ {
96+ if (GWarn->ReceivedUserCancel ())
97+ {
98+ Py_INCREF (Py_True);
99+ return Py_True;
100+ }
101+ Py_INCREF (Py_False);
102+ return Py_False;
103+ }
104+
105+ static PyMethodDef ue_PyFSlowTask_methods[] = {
106+ { " initialize" , (PyCFunction)py_ue_fslowtask_initialize, METH_VARARGS , " " },
107+ { " destroy" , (PyCFunction)py_ue_fslowtask_destroy, METH_VARARGS , " " },
108+ { " make_dialog_delayed" , (PyCFunction)py_ue_fslowtask_make_dialog_delayed, METH_VARARGS , " " },
109+ { " make_dialog" , (PyCFunction)py_ue_fslowtask_make_dialog, METH_VARARGS , " " },
110+ { " enter_progress_frame" , (PyCFunction)py_ue_fslowtask_enter_progress_frame, METH_VARARGS , " " },
111+ { " get_current_message" , (PyCFunction)py_ue_fslowtask_get_current_message, METH_VARARGS , " " },
112+ { " received_user_cancel" , (PyCFunction)py_ue_fslowtask_received_user_cancel, METH_VARARGS , " " },
113+ { NULL } /* Sentinel */
114+ };
115+
116+ static PyTypeObject ue_PyFSlowTaskType = {
117+ PyVarObject_HEAD_INIT (NULL , 0 )
118+ " unreal_engine.FSlowTask" , /* tp_name */
119+ sizeof (ue_PyFSlowTask), /* tp_basicsize */
120+ 0 , /* tp_itemsize */
121+ 0 , /* tp_dealloc */
122+ 0 , /* tp_print */
123+ 0 , /* tp_getattr */
124+ 0 , /* tp_setattr */
125+ 0 , /* tp_reserved */
126+ 0 , /* tp_repr */
127+ 0 , /* tp_as_number */
128+ 0 , /* tp_as_sequence */
129+ 0 , /* tp_as_mapping */
130+ 0 , /* tp_hash */
131+ 0 , /* tp_call */
132+ 0 , /* tp_str */
133+ 0 , /* tp_getattro */
134+ 0 , /* tp_setattro */
135+ 0 , /* tp_as_buffer */
136+ #if PY_MAJOR_VERSION < 3
137+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, /* tp_flags */
138+ #else
139+ Py_TPFLAGS_DEFAULT, /* tp_flags */
140+ #endif
141+ " Unreal Engine FSlowTask" , /* tp_doc */
142+ 0 , /* tp_traverse */
143+ 0 , /* tp_clear */
144+ 0 , /* tp_richcompare */
145+ 0 , /* tp_weaklistoffset */
146+ 0 , /* tp_iter */
147+ 0 , /* tp_iternext */
148+ ue_PyFSlowTask_methods, /* tp_methods */
149+ 0 ,
150+ 0 ,
151+ };
152+
153+ static int py_ue_fslowtask_init (ue_PyFSlowTask *self, PyObject * args)
154+ {
155+ float amount_of_work;
156+ char *default_message = " " ;
157+ PyObject *py_enabled = nullptr ;
158+ if (!PyArg_ParseTuple (args, " f|sO:__init__" , &amount_of_work, &default_message, &py_enabled))
159+ {
160+ return -1 ;
161+ }
162+
163+ bool enabled = true ;
164+ if (nullptr != py_enabled && !PyObject_IsTrue (py_enabled))
165+ {
166+ enabled = false ;
167+ }
168+
169+ new (&self->slowtask ) FSlowTask (amount_of_work, FText::FromString (UTF8_TO_TCHAR (default_message)), enabled);
170+ return 0 ;
171+ }
172+
173+ void ue_python_init_fslowtask (PyObject *ue_module)
174+ {
175+ ue_PyFSlowTaskType.tp_new = PyType_GenericNew;
176+ ue_PyFSlowTaskType.tp_init = (initproc)py_ue_fslowtask_init;
177+
178+ if (PyType_Ready (&ue_PyFSlowTaskType) < 0 )
179+ return ;
180+
181+ Py_INCREF (&ue_PyFSlowTaskType);
182+ PyModule_AddObject (ue_module, " FSlowTask" , (PyObject *)&ue_PyFSlowTaskType);
183+ }
184+
185+ ue_PyFSlowTask *py_ue_is_fslowtask (PyObject *obj)
186+ {
187+ if (!PyObject_IsInstance (obj, (PyObject *)&ue_PyFSlowTaskType))
188+ return nullptr ;
189+ return (ue_PyFSlowTask *)obj;
190+ }
191+
192+ #endif
0 commit comments