| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0fbead0 commit 2393013
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,10 @@ | |||
| 3 | 3 | ||
| 4 | 4 | #include "UEPyModule.h" | |
| 5 | 5 | ||
| 6 | + #if WITH_EDITOR | ||
| 7 | + #include "Slate/UEPySWindow.h" | ||
| 8 | + #endif | ||
| 9 | + | ||
| 6 | 10 | FPythonSmartDelegate::FPythonSmartDelegate() | |
| 7 | 11 | { | |
| 8 | 12 | py_callable = nullptr; | |
@@ -59,6 +63,19 @@ void FPythonSmartDelegate::PyFOnAssetPostImport(UFactory *factory, UObject *u_ob | |||
| 59 | 63 | } | |
| 60 | 64 | Py_DECREF(ret); | |
| 61 | 65 | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + void FPythonSmartDelegate::PyFOnMainFrameCreationFinished(TSharedPtr<SWindow> InRootWindow, bool bIsNewProjectWindow) | ||
| 69 | + { | ||
| 70 | + FScopePythonGIL gil; | ||
| 71 | + PyObject *ret = PyObject_CallFunction(py_callable, (char *)"OO", py_ue_new_swidget<ue_PySWindow>(InRootWindow.ToSharedRef(), &ue_PySWindowType), bIsNewProjectWindow ? Py_True : Py_False); | ||
| 72 | + if (!ret) | ||
| 73 | + { | ||
| 74 | + unreal_engine_py_log_error(); | ||
| 75 | + return; | ||
| 76 | + } | ||
| 77 | + Py_DECREF(ret); | ||
| 78 | + | ||
| 62 | 79 | } | |
| 63 | 80 | #endif | |
| 64 | 81 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,6 +34,7 @@ | |||
| 34 | 34 | #include "Wrappers/UEPyFAssetData.h" | |
| 35 | 35 | #include "Wrappers/UEPyFEditorViewportClient.h" | |
| 36 | 36 | #include "Wrappers/UEPyIAssetEditorInstance.h" | |
| 37 | + #include "Editor/MainFrame/Public/Interfaces/IMainFrameModule.h" | ||
| 37 | 38 | ||
| 38 | 39 | #include "UEPyIPlugin.h" | |
| 39 | 40 | ||
@@ -1753,9 +1754,29 @@ PyObject *py_unreal_engine_editor_on_asset_post_import(PyObject * self, PyObject | |||
| 1753 | 1754 | if (!PyCallable_Check(py_callable)) | |
| 1754 | 1755 | return PyErr_Format(PyExc_Exception, "object is not a callable"); | |
| 1755 | 1756 | ||
| 1756 | - TSharedRef<FPythonSmartDelegate> py_delegate = MakeShareable(new FPythonSmartDelegate); | ||
| 1757 | + // will brutally leak | ||
| 1758 | + FPythonSmartDelegate *py_delegate = new FPythonSmartDelegate(); | ||
| 1757 | 1759 | py_delegate->SetPyCallable(py_callable); | |
| 1758 | - FEditorDelegates::OnAssetPostImport.AddSP(py_delegate, &FPythonSmartDelegate::PyFOnAssetPostImport); | ||
| 1760 | + FEditorDelegates::OnAssetPostImport.AddRaw(py_delegate, &FPythonSmartDelegate::PyFOnAssetPostImport); | ||
| 1761 | + Py_RETURN_NONE; | ||
| 1762 | + } | ||
| 1763 | + | ||
| 1764 | + PyObject *py_unreal_engine_on_main_frame_creation_finished(PyObject * self, PyObject * args) | ||
| 1765 | + { | ||
| 1766 | + PyObject *py_callable; | ||
| 1767 | + if (!PyArg_ParseTuple(args, "O:on_main_frame_creation_finished", &py_callable)) | ||
| 1768 | + { | ||
| 1769 | + return NULL; | ||
| 1770 | + } | ||
| 1771 | + | ||
| 1772 | + if (!PyCallable_Check(py_callable)) | ||
| 1773 | + return PyErr_Format(PyExc_Exception, "object is not a callable"); | ||
| 1774 | + | ||
| 1775 | + // will brutally leak | ||
| 1776 | + FPythonSmartDelegate *py_delegate = new FPythonSmartDelegate(); | ||
| 1777 | + py_delegate->SetPyCallable(py_callable); | ||
| 1778 | + IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked<IMainFrameModule>(TEXT("MainFrame")); | ||
| 1779 | + MainFrameModule.OnMainFrameCreationFinished().AddRaw(py_delegate, &FPythonSmartDelegate::PyFOnMainFrameCreationFinished); | ||
| 1759 | 1780 | Py_RETURN_NONE; | |
| 1760 | 1781 | } | |
| 1761 | 1782 | ||
@@ -1929,7 +1950,7 @@ PyObject *py_unreal_engine_add_level_to_world(PyObject *self, PyObject * args) | |||
| 1929 | 1950 | if (py_bool && PyObject_IsTrue(py_bool)) | |
| 1930 | 1951 | { | |
| 1931 | 1952 | streaming_mode_class = ULevelStreamingAlwaysLoaded::StaticClass(); | |
| 1932 | - } | ||
| 1953 | + } | ||
| 1933 | 1954 | ||
| 1934 | 1955 | #if ENGINE_MINOR_VERSION >= 17 | |
| 1935 | 1956 | ULevelStreaming *level_streaming = EditorLevelUtils::AddLevelToWorld(u_world, UTF8_TO_TCHAR(name), streaming_mode_class); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,6 +54,7 @@ PyObject *py_unreal_engine_get_blueprint_components(PyObject *, PyObject *); | |||
| 54 | 54 | ||
| 55 | 55 | PyObject *py_unreal_engine_editor_play(PyObject *, PyObject *); | |
| 56 | 56 | PyObject *py_unreal_engine_editor_on_asset_post_import(PyObject *, PyObject *); | |
| 57 | + PyObject *py_unreal_engine_on_main_frame_creation_finished(PyObject *, PyObject *); | ||
| 57 | 58 | ||
| 58 | 59 | PyObject *py_unreal_engine_editor_command_build(PyObject *, PyObject *); | |
| 59 | 60 | PyObject *py_unreal_engine_editor_command_build_lighting(PyObject *, PyObject *); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -363,6 +363,7 @@ static PyMethodDef unreal_engine_methods[] = { | |||
| 363 | 363 | { "move_actor_to_level", py_unreal_engine_move_actor_to_level, METH_VARARGS, "" }, | |
| 364 | 364 | ||
| 365 | 365 | { "editor_on_asset_post_import", py_unreal_engine_editor_on_asset_post_import, METH_VARARGS, "" }, | |
| 366 | + { "on_main_frame_creation_finished", py_unreal_engine_on_main_frame_creation_finished, METH_VARARGS, "" }, | ||
| 366 | 367 | ||
| 367 | 368 | ||
| 368 | 369 | // transactions | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,6 +21,7 @@ class FPythonSmartDelegate : public TSharedFromThis<FPythonSmartDelegate> | |||
| 21 | 21 | ||
| 22 | 22 | #if WITH_EDITOR | |
| 23 | 23 | void PyFOnAssetPostImport(UFactory *factory, UObject *u_object); | |
| 24 | + void PyFOnMainFrameCreationFinished(TSharedPtr<SWindow> InRootWindow, bool bIsNewProjectWindow); | ||
| 24 | 25 | #endif | |
| 25 | 26 | ||
| 26 | 27 | protected: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments