|
3 | 3 | #include "Runtime/MovieSceneCapture/Public/MovieSceneCapture.h" |
4 | 4 |
|
5 | 5 |
|
6 | | -PyObject *py_ue_capture_initialize(ue_PyUObject * self, PyObject * args) { |
| 6 | +PyObject *py_ue_capture_initialize(ue_PyUObject * self, PyObject * args) |
| 7 | +{ |
7 | 8 |
|
8 | 9 | ue_py_check(self); |
9 | 10 |
|
10 | | - PyObject *py_widget; |
| 11 | + PyObject *py_widget = nullptr; |
11 | 12 |
|
12 | | - if (!PyArg_ParseTuple(args, "O", &py_widget)) { |
| 13 | + if (!PyArg_ParseTuple(args, "|O:capture_initialize", &py_widget)) |
| 14 | + { |
13 | 15 | return nullptr; |
14 | 16 | } |
15 | 17 |
|
16 | 18 | UMovieSceneCapture *capture = ue_py_check_type<UMovieSceneCapture>(self); |
17 | 19 | if (!capture) |
18 | 20 | return PyErr_Format(PyExc_Exception, "uobject is not a UMovieSceneCapture"); |
19 | 21 |
|
20 | | - ue_PySWidget *s_widget = py_ue_is_swidget(py_widget); |
21 | | - if (!s_widget) |
22 | | - return PyErr_Format(PyExc_Exception, "argument is not a SWidget"); |
23 | | - |
24 | 22 | #if WITH_EDITOR |
25 | | - if (s_widget->s_widget->GetType().Compare(FName("SPythonEditorViewport")) == 0) { |
26 | | - TSharedRef<SPythonEditorViewport> s_viewport = StaticCastSharedRef<SPythonEditorViewport>(s_widget->s_widget); |
27 | | - capture->Initialize(s_viewport->GetSceneViewport()); |
28 | | - capture->StartWarmup(); |
| 23 | + if (py_widget) |
| 24 | + { |
| 25 | + ue_PySWidget *s_widget = py_ue_is_swidget(py_widget); |
| 26 | + if (!s_widget) |
| 27 | + return PyErr_Format(PyExc_Exception, "argument is not a SWidget"); |
| 28 | + |
| 29 | + |
| 30 | + if (s_widget->s_widget->GetType().Compare(FName("SPythonEditorViewport")) == 0) |
| 31 | + { |
| 32 | + TSharedRef<SPythonEditorViewport> s_viewport = StaticCastSharedRef<SPythonEditorViewport>(s_widget->s_widget); |
| 33 | + capture->Initialize(s_viewport->GetSceneViewport()); |
| 34 | + capture->StartWarmup(); |
| 35 | + } |
| 36 | + else |
| 37 | + { |
| 38 | + return PyErr_Format(PyExc_Exception, "argument is not a supported Viewport-based SWidget"); |
| 39 | + } |
| 40 | + |
29 | 41 | } |
30 | | - else { |
31 | | - return PyErr_Format(PyExc_Exception, "argument is not a supported Viewport-based SWidget"); |
| 42 | + else |
| 43 | + { |
| 44 | + for (const FWorldContext &Context : GEngine->GetWorldContexts()) |
| 45 | + { |
| 46 | + if (Context.WorldType == EWorldType::PIE) |
| 47 | + { |
| 48 | + if (Context.GameViewport) |
| 49 | + { |
| 50 | + UE_LOG(LogPython, Error, TEXT("Found Viewport at %p"), Context.GameViewport); |
| 51 | + FSlatePlayInEditorInfo *SlatePIEInfo = GEditor->SlatePlayInEditorMap.Find(Context.ContextHandle); |
| 52 | + |
| 53 | + capture->Initialize(SlatePIEInfo->SlatePlayInEditorWindowViewport); |
| 54 | + } |
| 55 | + } |
| 56 | + } |
32 | 57 | } |
33 | 58 | #endif |
| 59 | + Py_RETURN_NONE; |
| 60 | +} |
34 | 61 |
|
| 62 | +PyObject *py_ue_capture_start(ue_PyUObject * self, PyObject * args) |
| 63 | +{ |
| 64 | + |
| 65 | + ue_py_check(self); |
| 66 | + |
| 67 | + UMovieSceneCapture *capture = ue_py_check_type<UMovieSceneCapture>(self); |
| 68 | + if (!capture) |
| 69 | + return PyErr_Format(PyExc_Exception, "uobject is not a UMovieSceneCapture"); |
| 70 | + |
| 71 | + capture->StartCapture(); |
35 | 72 |
|
36 | 73 | Py_RETURN_NONE; |
37 | 74 | } |
38 | 75 |
|
39 | | -PyObject *py_ue_capture_start(ue_PyUObject * self, PyObject * args) { |
| 76 | +PyObject *py_ue_capture_load_from_config(ue_PyUObject * self, PyObject * args) |
| 77 | +{ |
40 | 78 |
|
41 | 79 | ue_py_check(self); |
42 | 80 |
|
43 | 81 | UMovieSceneCapture *capture = ue_py_check_type<UMovieSceneCapture>(self); |
44 | 82 | if (!capture) |
45 | 83 | return PyErr_Format(PyExc_Exception, "uobject is not a UMovieSceneCapture"); |
46 | 84 |
|
47 | | - capture->StartCapture(); |
| 85 | + capture->LoadFromConfig(); |
48 | 86 |
|
49 | 87 | Py_RETURN_NONE; |
50 | 88 | } |
51 | 89 |
|
52 | | -PyObject *py_ue_capture_stop(ue_PyUObject * self, PyObject * args) { |
| 90 | +PyObject *py_ue_capture_stop(ue_PyUObject * self, PyObject * args) |
| 91 | +{ |
53 | 92 |
|
54 | 93 | ue_py_check(self); |
55 | 94 |
|
|
0 commit comments