Skip to content

Commit 18062da

Browse files
author
Roberto De Ioris
committed
added editor saving facilities
1 parent 4ec0808 commit 18062da

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

Source/UnrealEnginePython/Private/UEPyEditor.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,39 @@ PyObject *py_unreal_engine_editor_command_build(PyObject * self, PyObject * args
6363
return Py_None;
6464
}
6565

66+
PyObject *py_unreal_engine_editor_command_save_current_level(PyObject * self, PyObject * args) {
67+
68+
if (!GEditor)
69+
return PyErr_Format(PyExc_Exception, "no GEditor found");
70+
71+
FLevelEditorActionCallbacks::Save();
72+
73+
Py_INCREF(Py_None);
74+
return Py_None;
75+
}
76+
77+
PyObject *py_unreal_engine_editor_command_save_all_levels(PyObject * self, PyObject * args) {
78+
79+
if (!GEditor)
80+
return PyErr_Format(PyExc_Exception, "no GEditor found");
81+
82+
FLevelEditorActionCallbacks::SaveAllLevels();
83+
84+
Py_INCREF(Py_None);
85+
return Py_None;
86+
}
87+
88+
PyObject *py_unreal_engine_editor_save_all(PyObject * self, PyObject * args) {
89+
90+
if (!GEditor)
91+
return PyErr_Format(PyExc_Exception, "no GEditor found");
92+
93+
FEditorFileUtils::SaveDirtyPackages(false, true, true, false, false, false);
94+
95+
Py_INCREF(Py_None);
96+
return Py_None;
97+
}
98+
6699
PyObject *py_unreal_engine_editor_command_build_lighting(PyObject * self, PyObject * args) {
67100

68101
if (!GEditor)

Source/UnrealEnginePython/Private/UEPyEditor.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ PyObject *py_unreal_engine_editor_on_asset_post_import(PyObject *, PyObject *);
3535
PyObject *py_unreal_engine_editor_command_build(PyObject *, PyObject *);
3636
PyObject *py_unreal_engine_editor_command_build_lighting(PyObject *, PyObject *);
3737

38+
PyObject *py_unreal_engine_editor_command_save_current_level(PyObject *, PyObject *);
39+
PyObject *py_unreal_engine_editor_command_save_all_levels(PyObject *, PyObject *);
40+
41+
PyObject *py_unreal_engine_editor_save_all(PyObject *, PyObject *);
42+
3843
PyObject *py_unreal_engine_add_level_to_world(ue_PyUObject *, PyObject *);
3944
PyObject *py_unreal_engine_move_selected_actors_to_level(ue_PyUObject *, PyObject *);
4045

Source/UnrealEnginePython/Private/UEPyEngine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ PyObject *py_unreal_engine_new_class(PyObject *, PyObject *);
3636

3737
PyObject *py_unreal_engine_create_and_dispatch_when_ready(PyObject *, PyObject *);
3838

39-
39+
PyObject *py_unreal_engine_convert_relative_path_to_full(PyObject *, PyObject *);
4040

4141

4242

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ static PyMethodDef unreal_engine_methods[] = {
142142

143143
{ "editor_command_build", py_unreal_engine_editor_command_build, METH_VARARGS, "" },
144144
{ "editor_command_build_lighting", py_unreal_engine_editor_command_build_lighting, METH_VARARGS, "" },
145+
{ "editor_command_save_current_level", py_unreal_engine_editor_command_save_current_level, METH_VARARGS, "" },
146+
{ "editor_command_save_all_levels", py_unreal_engine_editor_command_save_all_levels, METH_VARARGS, "" },
147+
148+
{ "editor_save_all", py_unreal_engine_editor_save_all, METH_VARARGS, "" },
145149
#pragma warning(suppress: 4191)
146150
{ "get_assets_by_filter", (PyCFunction)py_unreal_engine_get_assets_by_filter, METH_VARARGS | METH_KEYWORDS, "" },
147151
{ "create_blueprint", py_unreal_engine_create_blueprint, METH_VARARGS, "" },

0 commit comments

Comments
 (0)