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+ int show_cancel_button = 0 ;
25+ int allow_in_pie = 0 ;
26+ if (!PyArg_ParseTuple (args, " f|ii:make_dialog_delayed" , &threshold, &show_cancel_button, &allow_in_pie))
27+ {
28+ return nullptr ;
29+ }
30+
31+ self->slowtask .MakeDialogDelayed (threshold, show_cancel_button, allow_in_pie);
32+
33+ Py_RETURN_NONE;
34+ }
35+
36+ static PyObject *py_ue_fslowtask_make_dialog (ue_PyFSlowTask *self, PyObject * args)
37+ {
38+ int show_cancel_button = 0 ;
39+ int allow_in_pie = 0 ;
40+ if (!PyArg_ParseTuple (args, " |ii:make_dialog" , &show_cancel_button, &allow_in_pie))
41+ {
42+ return nullptr ;
43+ }
44+
45+ self->slowtask .MakeDialog (show_cancel_button, allow_in_pie);
46+
47+ Py_RETURN_NONE;
48+ }
49+
50+ static PyObject *py_ue_fslowtask_enter_progress_frame (ue_PyFSlowTask *self, PyObject * args)
51+ {
52+ float expected_work_this_frame = 1.0 ;
53+ char *text = " " ;
54+ if (!PyArg_ParseTuple (args, " |fs:enter_progress_frame" , &expected_work_this_frame, &text))
55+ {
56+ return nullptr ;
57+ }
58+
59+ self->slowtask .EnterProgressFrame (expected_work_this_frame, FText::FromString (UTF8_TO_TCHAR (text)));
60+
61+ Py_RETURN_NONE;
62+ }
63+
64+ static PyObject *py_ue_fslowtask_get_current_message (ue_PyFSlowTask *self, PyObject * args)
65+ {
66+ FText current_message = self->slowtask .GetCurrentMessage ();
67+ return PyUnicode_FromString (TCHAR_TO_UTF8 (*current_message.ToString ()));
68+ }
69+
70+ static PyObject *py_ue_fslowtask_received_user_cancel (ue_PyFSlowTask *self, PyObject * args )
71+ {
72+ if (GWarn->ReceivedUserCancel ())
73+ {
74+ Py_INCREF (Py_True);
75+ return Py_True;
76+ }
77+ Py_INCREF (Py_False);
78+ return Py_False;
79+ }
80+
81+ static PyMethodDef ue_PyFSlowTask_methods[] = {
82+ { " initialize" , (PyCFunction)py_ue_fslowtask_initialize, METH_VARARGS, " " },
83+ { " destroy" , (PyCFunction)py_ue_fslowtask_destroy, METH_VARARGS, " " },
84+ { " make_dialog_delayed" , (PyCFunction)py_ue_fslowtask_make_dialog_delayed, METH_VARARGS, " " },
85+ { " make_dialog" , (PyCFunction)py_ue_fslowtask_make_dialog, METH_VARARGS, " " },
86+ { " enter_progress_frame" , (PyCFunction)py_ue_fslowtask_enter_progress_frame, METH_VARARGS, " " },
87+ { " get_current_message" , (PyCFunction)py_ue_fslowtask_get_current_message, METH_VARARGS, " " },
88+ { " received_user_cancel" , (PyCFunction)py_ue_fslowtask_received_user_cancel, METH_VARARGS, " " },
89+ { NULL } /* Sentinel */
90+ };
91+
92+ static PyTypeObject ue_PyFSlowTaskType = {
93+ PyVarObject_HEAD_INIT (NULL , 0 )
94+ " unreal_engine.FSlowTask" , /* tp_name */
95+ sizeof (ue_PyFSlowTask), /* tp_basicsize */
96+ 0 , /* tp_itemsize */
97+ 0 , /* tp_dealloc */
98+ 0 , /* tp_print */
99+ 0 , /* tp_getattr */
100+ 0 , /* tp_setattr */
101+ 0 , /* tp_reserved */
102+ 0 , /* tp_repr */
103+ 0 , /* tp_as_number */
104+ 0 , /* tp_as_sequence */
105+ 0 , /* tp_as_mapping */
106+ 0 , /* tp_hash */
107+ 0 , /* tp_call */
108+ 0 , /* tp_str */
109+ 0 , /* tp_getattro */
110+ 0 , /* tp_setattro */
111+ 0 , /* tp_as_buffer */
112+ #if PY_MAJOR_VERSION < 3
113+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, /* tp_flags */
114+ #else
115+ Py_TPFLAGS_DEFAULT, /* tp_flags */
116+ #endif
117+ " Unreal Engine FSlowTask" , /* tp_doc */
118+ 0 , /* tp_traverse */
119+ 0 , /* tp_clear */
120+ 0 , /* tp_richcompare */
121+ 0 , /* tp_weaklistoffset */
122+ 0 , /* tp_iter */
123+ 0 , /* tp_iternext */
124+ ue_PyFSlowTask_methods, /* tp_methods */
125+ 0 ,
126+ 0 ,
127+ };
128+
129+ static int py_ue_fslowtask_init (ue_PyFSlowTask *self, PyObject * args)
130+ {
131+ float amount_of_work;
132+ char *default_message = " " ;
133+ int enabled = 1 ;
134+ if (!PyArg_ParseTuple (args, " f|si:__init__" , &amount_of_work, &default_message, &enabled))
135+ {
136+ return -1 ;
137+ }
138+
139+ new (&self->slowtask ) FSlowTask (amount_of_work, FText::FromString (UTF8_TO_TCHAR (default_message)), enabled);
140+ return 0 ;
141+ }
142+
143+ void ue_python_init_fslowtask (PyObject *ue_module)
144+ {
145+ ue_PyFSlowTaskType.tp_new = PyType_GenericNew;
146+ ue_PyFSlowTaskType.tp_init = (initproc)py_ue_fslowtask_init;
147+
148+ if (PyType_Ready (&ue_PyFSlowTaskType) < 0 )
149+ return ;
150+
151+ Py_INCREF (&ue_PyFSlowTaskType);
152+ PyModule_AddObject (ue_module, " FSlowTask" , (PyObject *)&ue_PyFSlowTaskType);
153+ }
154+
155+ ue_PyFSlowTask *py_ue_is_fslowtask (PyObject *obj)
156+ {
157+ if (!PyObject_IsInstance (obj, (PyObject *)&ue_PyFSlowTaskType))
158+ return nullptr ;
159+ return (ue_PyFSlowTask *)obj;
160+ }
161+
162+ #endif
0 commit comments