Skip to content

Commit b76e101

Browse files
author
David
committed
More wraps of 4.24 updates with appropriate ENGINE_MINOR_VERSION so still builds on 4.18.
Builds on 4.18 and 4.25 (only versions tested).
1 parent 350998c commit b76e101

File tree

8 files changed

+146
-4
lines changed

8 files changed

+146
-4
lines changed

Source/PythonEditor/Private/PythonEditor.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
#include "PythonEditorStyle.h"
88
#include "PythonProjectEditor.h"
99
#include "PythonProject.h"
10+
#if ENGINE_MINOR_VERSION >= 24
1011
#include "Subsystems/AssetEditorSubsystem.h"
12+
#endif
1113
#include "Runtime/Slate/Public/Framework/MultiBox/MultiBoxBuilder.h"
1214

1315
static const FName PythonEditorTabName( TEXT( "PythonEditor" ) );
@@ -91,4 +93,4 @@ class FPythonEditor : public IModuleInterface
9193

9294
IMPLEMENT_MODULE( FPythonEditor, PythonEditor )
9395

94-
#undef LOCTEXT_NAMESPACE
96+
#undef LOCTEXT_NAMESPACE

Source/PythonEditor/Private/PythonProjectEditor.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
#include "PythonProjectEditor.h"
44

5+
#if ENGINE_MINOR_VERSION >= 24
56
#include "Subsystems/AssetEditorSubsystem.h"
67

78
// #include "UnrealEd.h"
9+
#endif
810

911
#include "SPythonEditor.h"
1012
#include "SPythonProjectEditor.h"
@@ -216,9 +218,13 @@ void FPythonProjectEditor::RegisterToolbarTab(const TSharedRef<class FTabManager
216218

217219
void FPythonProjectEditor::InitPythonEditor(const EToolkitMode::Type Mode, const TSharedPtr< class IToolkitHost >& InitToolkitHost, class UPythonProject* PythonProject)
218220
{
221+
#if ENGINE_MINOR_VERSION >= 24
219222
// UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>();
220223
// GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->CloseOtherEditors(PythonProject, this);
221224
GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->CloseOtherEditors(PythonProject, this);
225+
#else
226+
FAssetEditorManager::Get().CloseOtherEditors(PythonProject, this);
227+
#endif
222228
PythonProjectBeingEdited = PythonProject;
223229

224230
TSharedPtr<FPythonProjectEditor> ThisPtr(SharedThis(this));

Source/UnrealEnginePython/Private/MaterialEditorUtilities/UEPyFMaterialEditorUtilities.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
#if WITH_EDITOR
55

6+
#if ENGINE_MINOR_VERSION >= 24
67
#include "Subsystems/AssetEditorSubsystem.h"
8+
#endif
79

810
#include "Materials/Material.h"
911
#include "Runtime/Engine/Classes/EdGraph/EdGraph.h"
@@ -57,9 +59,13 @@ static PyObject *py_ue_command_apply(PyObject *cls, PyObject * args)
5759
return PyErr_Format(PyExc_Exception, "argument is not a UMaterial");
5860
}
5961

62+
#if ENGINE_MINOR_VERSION >= 24
6063
//UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>();
6164

6265
IAssetEditorInstance *Instance = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->FindEditorForAsset(Material, false);
66+
#else
67+
IAssetEditorInstance *Instance = FAssetEditorManager::Get().FindEditorForAsset(Material, false);
68+
#endif
6369
if (!Instance)
6470
{
6571
return PyErr_Format(PyExc_Exception, "unable to retrieve editor for UMaterial");
@@ -133,4 +139,4 @@ void ue_python_init_fmaterial_editor_utilities(PyObject *ue_module)
133139
PyModule_AddObject(ue_module, "FMaterialEditorUtilities", (PyObject *)&ue_PyFMaterialEditorUtilitiesType);
134140
}
135141

136-
#endif
142+
#endif

Source/UnrealEnginePython/Private/UEPyEditor.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,8 +1178,12 @@ PyObject *py_unreal_engine_get_selected_assets(PyObject * self, PyObject * args)
11781178
PyObject *py_unreal_engine_get_all_edited_assets(PyObject * self, PyObject * args)
11791179
{
11801180

1181+
#if ENGINE_MINOR_VERSION >= 24
11811182
//UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>();
11821183
TArray<UObject *> assets = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->GetAllEditedAssets();
1184+
#else
1185+
TArray<UObject *> assets = FAssetEditorManager::Get().GetAllEditedAssets();
1186+
#endif
11831187
PyObject *assets_list = PyList_New(0);
11841188

11851189
for (UObject *asset : assets)
@@ -1207,9 +1211,13 @@ PyObject *py_unreal_engine_open_editor_for_asset(PyObject * self, PyObject * arg
12071211
if (!u_obj)
12081212
return PyErr_Format(PyExc_Exception, "argument is not a UObject");
12091213

1214+
#if ENGINE_MINOR_VERSION >= 24
12101215
//UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>();
12111216

12121217
if (GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->OpenEditorForAsset(u_obj))
1218+
#else
1219+
if (FAssetEditorManager::Get().OpenEditorForAsset(u_obj))
1220+
#endif
12131221
{
12141222
Py_RETURN_TRUE;
12151223
}
@@ -1234,8 +1242,12 @@ PyObject *py_unreal_engine_find_editor_for_asset(PyObject * self, PyObject * arg
12341242
if (py_bool && PyObject_IsTrue(py_bool))
12351243
bFocus = true;
12361244

1245+
#if ENGINE_MINOR_VERSION >= 24
12371246
//UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>();
12381247
IAssetEditorInstance *instance = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->FindEditorForAsset(u_obj, bFocus);
1248+
#else
1249+
IAssetEditorInstance *instance = FAssetEditorManager::Get().FindEditorForAsset(u_obj, bFocus);
1250+
#endif
12391251
if (!instance)
12401252
return PyErr_Format(PyExc_Exception, "no editor found for asset");
12411253

@@ -1255,15 +1267,23 @@ PyObject *py_unreal_engine_close_editor_for_asset(PyObject * self, PyObject * ar
12551267
if (!u_obj)
12561268
return PyErr_Format(PyExc_Exception, "argument is not a UObject");
12571269

1270+
#if ENGINE_MINOR_VERSION >= 24
12581271
//UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>();
12591272
GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->CloseAllEditorsForAsset(u_obj);
1273+
#else
1274+
FAssetEditorManager::Get().CloseAllEditorsForAsset(u_obj);
1275+
#endif
12601276

12611277
Py_RETURN_NONE;
12621278
}
12631279

12641280
PyObject *py_unreal_engine_close_all_asset_editors(PyObject * self, PyObject * args)
12651281
{
1282+
#if ENGINE_MINOR_VERSION >= 24
12661283
GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->CloseAllAssetEditors();
1284+
#else
1285+
FAssetEditorManager::Get().CloseAllAssetEditors();
1286+
#endif
12671287

12681288
Py_RETURN_NONE;
12691289
}

Source/UnrealEnginePython/Private/UObject/UEPyMaterial.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,12 @@ PyObject *py_ue_static_mesh_set_collision_for_lod(ue_PyUObject *self, PyObject *
511511
FMeshSectionInfo info = mesh->SectionInfoMap.Get(lod_index, material_index);
512512
#endif
513513
info.bEnableCollision = enabled;
514+
515+
#if ENGINE_MINOR_VERSION >= 23
514516
mesh->GetSectionInfoMap().Set(lod_index, material_index, info);
517+
#else
518+
mesh->SectionInfoMap.Set(lod_index, material_index, info);
519+
#endif
515520

516521
mesh->MarkPackageDirty();
517522

@@ -545,9 +550,17 @@ PyObject *py_ue_static_mesh_set_shadow_for_lod(ue_PyUObject *self, PyObject * ar
545550
enabled = true;
546551
}
547552

553+
#if ENGINE_MINOR_VERSION >= 23
548554
FMeshSectionInfo info = mesh->GetSectionInfoMap().Get(lod_index, material_index);
555+
#else
556+
FMeshSectionInfo info = mesh->SectionInfoMap.Get(lod_index, material_index);
557+
#endif
549558
info.bCastShadow = enabled;
559+
#if ENGINE_MINOR_VERSION >= 23
550560
mesh->GetSectionInfoMap().Set(lod_index, material_index, info);
561+
#else
562+
mesh->SectionInfoMap.Set(lod_index, material_index, info);
563+
#endif
551564

552565
mesh->MarkPackageDirty();
553566

Source/UnrealEnginePython/Private/UObject/UEPySequencer.cpp

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
#include "Runtime/LevelSequence/Public/LevelSequence.h"
99

1010
#if WITH_EDITOR
11+
#if ENGINE_MINOR_VERSION >= 24
1112
#include "Subsystems/AssetEditorSubsystem.h"
13+
#endif
1214
#include "Editor/Sequencer/Public/ISequencer.h"
1315
#include "Editor/Sequencer/Public/ISequencerModule.h"
1416
#include "Editor/UnrealEd/Public/Toolkits/AssetEditorManager.h"
@@ -237,12 +239,18 @@ PyObject *py_ue_sequencer_changed(ue_PyUObject *self, PyObject * args)
237239
if (py_bool && PyObject_IsTrue(py_bool))
238240
{
239241
// try to open the editor for the asset
240-
// FAssetEditorManager::Get().OpenEditorForAsset(seq);
242+
#if ENGINE_MINOR_VERSION >= 24
241243
GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->OpenEditorForAsset(seq);
244+
#else
245+
FAssetEditorManager::Get().OpenEditorForAsset(seq);
246+
#endif
242247
}
243248

244-
// IAssetEditorInstance* editor = FAssetEditorManager::Get().FindEditorForAsset(seq, true);
249+
#if ENGINE_MINOR_VERSION >= 24
245250
IAssetEditorInstance* editor = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->FindEditorForAsset(seq, true);
251+
#else
252+
IAssetEditorInstance *editor = FAssetEditorManager::Get().FindEditorForAsset(seq, true);
253+
#endif
246254
if (editor)
247255
{
248256
FLevelSequenceEditorToolkit *toolkit = (FLevelSequenceEditorToolkit *)editor;
@@ -474,10 +482,16 @@ PyObject *py_ue_sequencer_add_actor(ue_PyUObject *self, PyObject * args)
474482

475483
// try to open the editor for the asset
476484

485+
#if ENGINE_MINOR_VERSION >= 24
477486
//UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>();
478487
GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->OpenEditorForAsset(seq);
479488

480489
IAssetEditorInstance *editor = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->FindEditorForAsset(seq, true);
490+
#else
491+
FAssetEditorManager::Get().OpenEditorForAsset(seq);
492+
493+
IAssetEditorInstance *editor = FAssetEditorManager::Get().FindEditorForAsset(seq, true);
494+
#endif
481495
if (editor)
482496
{
483497
FLevelSequenceEditorToolkit *toolkit = (FLevelSequenceEditorToolkit *)editor;
@@ -531,10 +545,16 @@ PyObject *py_ue_sequencer_add_actor_component(ue_PyUObject *self, PyObject * arg
531545

532546
// try to open the editor for the asset
533547

548+
#if ENGINE_MINOR_VERSION >= 24
534549
UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>();
535550
AssetEditorSubsystem->OpenEditorForAsset(seq);
536551

537552
IAssetEditorInstance *editor = AssetEditorSubsystem->FindEditorForAsset(seq, true);
553+
#else
554+
FAssetEditorManager::Get().OpenEditorForAsset(seq);
555+
556+
IAssetEditorInstance *editor = FAssetEditorManager::Get().FindEditorForAsset(seq, true);
557+
#endif
538558
FGuid new_guid;
539559
if (editor)
540560
{
@@ -582,10 +602,16 @@ PyObject *py_ue_sequencer_make_new_spawnable(ue_PyUObject *self, PyObject * args
582602

583603
// try to open the editor for the asset
584604

605+
#if ENGINE_MINOR_VERSION >= 24
585606
//UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>();
586607
GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->OpenEditorForAsset(seq);
587608

588609
IAssetEditorInstance *editor = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->FindEditorForAsset(seq, true);
610+
#else
611+
FAssetEditorManager::Get().OpenEditorForAsset(seq);
612+
613+
IAssetEditorInstance *editor = FAssetEditorManager::Get().FindEditorForAsset(seq, true);
614+
#endif
589615
if (!editor)
590616
{
591617
return PyErr_Format(PyExc_Exception, "unable to access sequencer");

Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,17 @@ PyObject *py_ue_static_mesh_get_raw_mesh(ue_PyUObject *self, PyObject * args)
124124

125125
FRawMesh raw_mesh;
126126

127+
#if ENGINE_MINOR_VERSION >= 24
127128
if (lod_index < 0 || lod_index >= mesh->GetSourceModels().Num())
128129
return PyErr_Format(PyExc_Exception, "invalid LOD index");
129130

130131
mesh->GetSourceModel(lod_index).RawMeshBulkData->LoadRawMesh(raw_mesh);
132+
#else
133+
if (lod_index < 0 || lod_index >= mesh->SourceModels.Num())
134+
return PyErr_Format(PyExc_Exception, "invalid LOD index");
135+
136+
mesh->SourceModels[lod_index].RawMeshBulkData->LoadRawMesh(raw_mesh);
137+
#endif
131138

132139
return py_ue_new_fraw_mesh(raw_mesh);
133140
}

Source/UnrealEnginePython/Private/UObject/UEPyViewport.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,31 @@ PyObject *py_unreal_engine_editor_set_view_mode(PyObject * self, PyObject * args
6161
return NULL;
6262
}
6363

64+
#if ENGINE_MINOR_VERSION >= 24
6465
FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked<FLevelEditorModule>("LevelEditor");
6566
TSharedPtr<SLevelViewport> ActiveLevelViewport = LevelEditorModule.GetFirstActiveLevelViewport();
67+
#else
68+
FLevelEditorModule &EditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
69+
#endif
6670

71+
#if ENGINE_MINOR_VERSION >= 24
6772
if (!ActiveLevelViewport.IsValid())
73+
#else
74+
if (!EditorModule.GetFirstActiveViewport().IsValid())
75+
#endif
6876
return PyErr_Format(PyExc_Exception, "no active LevelEditor Viewport");
6977

78+
#if ENGINE_MINOR_VERSION >= 24
7079
FLevelEditorViewportClient& LevelViewportClient = ActiveLevelViewport->GetLevelViewportClient();
80+
#else
81+
FLevelEditorViewportClient &viewport_client = EditorModule.GetFirstActiveViewport()->GetLevelViewportClient();
82+
#endif
7183

84+
#if ENGINE_MINOR_VERSION >= 24
7285
LevelViewportClient.SetViewMode((EViewModeIndex)mode);
86+
#else
87+
viewport_client.SetViewMode((EViewModeIndex)mode);
88+
#endif
7389

7490
Py_RETURN_NONE;
7591
}
@@ -85,15 +101,29 @@ PyObject *py_unreal_engine_editor_set_camera_speed(PyObject * self, PyObject * a
85101
}
86102

87103

104+
#if ENGINE_MINOR_VERSION >= 24
88105
FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked<FLevelEditorModule>("LevelEditor");
89106
TSharedPtr<SLevelViewport> ActiveLevelViewport = LevelEditorModule.GetFirstActiveLevelViewport();
90107

91108
if (!ActiveLevelViewport.IsValid())
109+
#else
110+
FLevelEditorModule &EditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
111+
112+
if (!EditorModule.GetFirstActiveViewport().IsValid())
113+
#endif
92114
return PyErr_Format(PyExc_Exception, "no active LevelEditor Viewport");
93115

116+
#if ENGINE_MINOR_VERSION >= 24
94117
FLevelEditorViewportClient& LevelViewportClient = ActiveLevelViewport->GetLevelViewportClient();
118+
#else
119+
FLevelEditorViewportClient &viewport_client = EditorModule.GetFirstActiveViewport()->GetLevelViewportClient();
120+
#endif
95121

122+
#if ENGINE_MINOR_VERSION >= 24
96123
LevelViewportClient.SetCameraSpeedSetting(speed);
124+
#else
125+
viewport_client.SetCameraSpeedSetting(speed);
126+
#endif
97127

98128
Py_RETURN_NONE;
99129
}
@@ -112,15 +142,31 @@ PyObject *py_unreal_engine_editor_set_view_location(PyObject * self, PyObject *
112142
if (!vector)
113143
return PyErr_Format(PyExc_Exception, "argument is not a FVector");
114144

145+
#if ENGINE_MINOR_VERSION >= 24
115146
FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked<FLevelEditorModule>("LevelEditor");
116147
TSharedPtr<SLevelViewport> ActiveLevelViewport = LevelEditorModule.GetFirstActiveLevelViewport();
148+
#else
149+
FLevelEditorModule &EditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
150+
#endif
117151

152+
#if ENGINE_MINOR_VERSION >= 24
118153
if (!ActiveLevelViewport.IsValid())
154+
#else
155+
if (!EditorModule.GetFirstActiveViewport().IsValid())
156+
#endif
119157
return PyErr_Format(PyExc_Exception, "no active LevelEditor Viewport");
120158

159+
#if ENGINE_MINOR_VERSION >= 24
121160
FLevelEditorViewportClient& LevelViewportClient = ActiveLevelViewport->GetLevelViewportClient();
161+
#else
162+
FLevelEditorViewportClient &viewport_client = EditorModule.GetFirstActiveViewport()->GetLevelViewportClient();
163+
#endif
122164

165+
#if ENGINE_MINOR_VERSION >= 24
123166
LevelViewportClient.SetViewLocation(vector->vec);
167+
#else
168+
viewport_client.SetViewLocation(vector->vec);
169+
#endif
124170

125171
Py_RETURN_NONE;
126172
}
@@ -139,15 +185,31 @@ PyObject *py_unreal_engine_editor_set_view_rotation(PyObject * self, PyObject *
139185
if (!rotator)
140186
return PyErr_Format(PyExc_Exception, "argument is not a FRotator");
141187

188+
#if ENGINE_MINOR_VERSION >= 24
142189
FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked<FLevelEditorModule>("LevelEditor");
143190
TSharedPtr<SLevelViewport> ActiveLevelViewport = LevelEditorModule.GetFirstActiveLevelViewport();
191+
#else
192+
FLevelEditorModule &EditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
193+
#endif
144194

195+
#if ENGINE_MINOR_VERSION >= 24
145196
if (!ActiveLevelViewport.IsValid())
197+
#else
198+
if (!EditorModule.GetFirstActiveViewport().IsValid())
199+
#endif
146200
return PyErr_Format(PyExc_Exception, "no active LevelEditor Viewport");
147201

202+
#if ENGINE_MINOR_VERSION >= 24
148203
FLevelEditorViewportClient& LevelViewportClient = ActiveLevelViewport->GetLevelViewportClient();
204+
#else
205+
FLevelEditorViewportClient &viewport_client = EditorModule.GetFirstActiveViewport()->GetLevelViewportClient();
206+
#endif
149207

208+
#if ENGINE_MINOR_VERSION >= 24
150209
LevelViewportClient.SetViewRotation(rotator->rot);
210+
#else
211+
viewport_client.SetViewRotation(rotator->rot);
212+
#endif
151213

152214
Py_RETURN_NONE;
153215
}

0 commit comments

Comments
 (0)