Skip to content

Commit 4fa232a

Browse files
authored
Feature: UE 4.24 upgrade #1
Modified: - Updated the plugin to work with `UE 4.24`
2 parents 4b5da5b + c1e003d commit 4fa232a

18 files changed

Lines changed: 186 additions & 24 deletions

‎Source/PythonAutomation/PythonAutomation.Build.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public PythonAutomation(TargetInfo Target)
1313
{
1414
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
1515
string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD");
16-
bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild);
16+
bUseUnity = string.IsNullOrEmpty(enableUnityBuild);
1717

1818
PrivateIncludePaths.AddRange(
1919
new string[] {
@@ -26,7 +26,7 @@ public PythonAutomation(TargetInfo Target)
2626
new string[] {
2727
"Core",
2828
"CoreUObject", // @todo Mac: for some reason it's needed to link in debug on Mac
29-
"Engine",
29+
"Engine",
3030
"UnrealEd",
3131
"UnrealEnginePython"
3232
}

‎Source/PythonConsole/PythonConsole.Build.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public PythonConsole(TargetInfo Target)
1313
{
1414
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
1515
string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD");
16-
bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild);
16+
bUseUnity = string.IsNullOrEmpty(enableUnityBuild);
1717

1818
PrivateIncludePaths.AddRange(
1919
new string[] {

‎Source/PythonEditor/Private/PythonProjectEditor.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "PythonProjectEditorCommands.h"
1414
#include "Runtime/Core/Public/HAL/PlatformFilemanager.h"
1515
#include "Runtime/Core/Public/Misc/MessageDialog.h"
16+
#include "Editor/UnrealEd/Public/Toolkits/AssetEditorManager.h"
1617
#define LOCTEXT_NAMESPACE "PythonEditor"
1718

1819
TWeakPtr<FPythonProjectEditor> FPythonProjectEditor::PythonEditor;
@@ -209,7 +210,12 @@ void FPythonProjectEditor::RegisterToolbarTab(const TSharedRef<class FTabManager
209210

210211
void FPythonProjectEditor::InitPythonEditor(const EToolkitMode::Type Mode, const TSharedPtr< class IToolkitHost >& InitToolkitHost, class UPythonProject* PythonProject)
211212
{
213+
#if ENGINE_MINOR_VERSION >= 24
214+
UAssetEditorSubsystem* AssetEditor = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>();
215+
AssetEditor->CloseOtherEditors(PythonProject, this);
216+
#else
212217
FAssetEditorManager::Get().CloseOtherEditors(PythonProject, this);
218+
#endif
213219
PythonProjectBeingEdited = PythonProject;
214220

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

‎Source/PythonEditor/PythonEditor.Build.cs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public PythonEditor(TargetInfo Target)
1313

1414
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
1515
string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD");
16-
bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild);
16+
bUseUnity = string.IsNullOrEmpty(enableUnityBuild);
1717

1818
PrivateIncludePaths.AddRange(
1919
new string[] {
@@ -26,14 +26,15 @@ public PythonEditor(TargetInfo Target)
2626
{
2727
"Core",
2828
"CoreUObject",
29+
"Engine",
2930
"SlateCore",
3031
"Slate",
3132
"AssetTools",
3233
"UnrealEd",
3334
"EditorStyle",
3435
"PropertyEditor",
3536
"Kismet", // for FWorkflowCentricApplication
36-
"InputCore",
37+
"InputCore",
3738
"DirectoryWatcher",
3839
"LevelEditor",
3940
"Projects",

‎Source/UnrealEnginePython/Private/MaterialEditorUtilities/UEPyFMaterialEditorUtilities.cpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ static PyObject *py_ue_command_apply(PyObject *cls, PyObject * args)
5454
return PyErr_Format(PyExc_Exception, "argument is not a UMaterial");
5555
}
5656

57+
#if ENGINE_MINOR_VERSION >= 24
58+
UAssetEditorSubsystem *AssetEditorSubsystem = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>();
59+
IAssetEditorInstance *Instance = AssetEditorSubsystem->FindEditorForAsset(Material, false);
60+
#else
5761
IAssetEditorInstance *Instance = FAssetEditorManager::Get().FindEditorForAsset(Material, false);
62+
#endif
5863
if (!Instance)
5964
{
6065
return PyErr_Format(PyExc_Exception, "unable to retrieve editor for UMaterial");

‎Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.cpp‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "UEPyFMenuBuilder.h"
2-
32
#include "Wrappers/UEPyESlateEnums.h"
43

54
static PyObject* py_ue_fmenu_builder_begin_section(ue_PyFMenuBuilder* self, PyObject* args)
@@ -139,9 +138,15 @@ static PyObject* py_ue_fmenu_builder_add_asset_actions(ue_PyFMenuBuilder* self,
139138
}
140139
Py_DECREF(py_assets);
141140

141+
#if ENGINE_MINOR_VERSION >= 24
142+
FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
143+
TArray<FContentBrowserMenuExtender_SelectedAssets>& AssetMenuExtenderDelegates = ContentBrowserModule.GetAllAssetViewContextMenuExtenders();
144+
if (AssetMenuExtenderDelegates.Num() > 0)
145+
#else
142146
FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>(TEXT("AssetTools"));
143147
bool addedSomething = AssetToolsModule.Get().GetAssetActions(u_objects, self->menu_builder, true);
144148
if (addedSomething)
149+
#endif
145150
{
146151
Py_RETURN_TRUE;
147152
}

‎Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44

55
#include "Runtime/Slate/Public/Framework/Commands/UIAction.h"
66
#if WITH_EDITOR
7+
#if ENGINE_MINOR_VERSION >= 24
8+
#include "ContentBrowserModule.h"
9+
#else
710
#include "Developer/AssetTools/Public/AssetToolsModule.h"
811
#include "Developer/AssetTools/Public/IAssetTools.h"
912
#endif
13+
#endif
1014

1115
#include "Runtime/Slate/Public/Framework/MultiBox/MultiBoxBuilder.h"
1216

‎Source/UnrealEnginePython/Private/Slate/UEPySTextBlock.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ static PyObject *py_ue_stext_block_set_text(ue_PySTextBlock *self, PyObject * ar
1111
return nullptr;
1212
}
1313

14+
#if ENGINE_MINOR_VERSION >= 24
15+
py_STextBlock->SetText(FText::FromString(UTF8_TO_TCHAR(text)));
16+
#else
1417
py_STextBlock->SetText(FString(UTF8_TO_TCHAR(text)));
18+
#endif
1519

1620
Py_RETURN_SLATE_SELF;
1721
}

‎Source/UnrealEnginePython/Private/UEPyEditor.cpp‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,12 @@ PyObject *py_unreal_engine_get_selected_assets(PyObject * self, PyObject * args)
11401140

11411141
PyObject *py_unreal_engine_get_all_edited_assets(PyObject * self, PyObject * args)
11421142
{
1143+
#if ENGINE_MINOR_VERSION >= 24
1144+
UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>();
1145+
TArray<UObject *> assets = AssetEditorSubsystem->GetAllEditedAssets();
1146+
#else
11431147
TArray<UObject *> assets = FAssetEditorManager::Get().GetAllEditedAssets();
1148+
#endif
11441149
PyObject *assets_list = PyList_New(0);
11451150

11461151
for (UObject *asset : assets)
@@ -1168,7 +1173,12 @@ PyObject *py_unreal_engine_open_editor_for_asset(PyObject * self, PyObject * arg
11681173
if (!u_obj)
11691174
return PyErr_Format(PyExc_Exception, "argument is not a UObject");
11701175

1176+
#if ENGINE_MINOR_VERSION >= 24
1177+
UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>();
1178+
if (AssetEditorSubsystem->OpenEditorForAsset(u_obj))
1179+
#else
11711180
if (FAssetEditorManager::Get().OpenEditorForAsset(u_obj))
1181+
#endif
11721182
{
11731183
Py_RETURN_TRUE;
11741184
}
@@ -1193,7 +1203,11 @@ PyObject *py_unreal_engine_find_editor_for_asset(PyObject * self, PyObject * arg
11931203
if (py_bool && PyObject_IsTrue(py_bool))
11941204
bFocus = true;
11951205

1206+
#if ENGINE_MINOR_VERSION >= 24
1207+
IAssetEditorInstance* instance = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->FindEditorForAsset(u_obj, bFocus);
1208+
#else
11961209
IAssetEditorInstance *instance = FAssetEditorManager::Get().FindEditorForAsset(u_obj, bFocus);
1210+
#endif
11971211
if (!instance)
11981212
return PyErr_Format(PyExc_Exception, "no editor found for asset");
11991213

@@ -1212,14 +1226,23 @@ PyObject *py_unreal_engine_close_editor_for_asset(PyObject * self, PyObject * ar
12121226
UObject *u_obj = ue_py_check_type<UObject>(py_obj);
12131227
if (!u_obj)
12141228
return PyErr_Format(PyExc_Exception, "argument is not a UObject");
1229+
1230+
#if ENGINE_MINOR_VERSION >= 24
1231+
GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->CloseAllEditorsForAsset(u_obj);
1232+
#else
12151233
FAssetEditorManager::Get().CloseAllEditorsForAsset(u_obj);
1234+
#endif
12161235

12171236
Py_RETURN_NONE;
12181237
}
12191238

12201239
PyObject *py_unreal_engine_close_all_asset_editors(PyObject * self, PyObject * args)
12211240
{
1241+
#if ENGINE_MINOR_VERSION >= 24
1242+
GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->CloseAllAssetEditors();
1243+
#else
12221244
FAssetEditorManager::Get().CloseAllAssetEditors();
1245+
#endif
12231246

12241247
Py_RETURN_NONE;
12251248
}
@@ -1355,7 +1378,11 @@ PyObject *py_unreal_engine_reload_blueprint(PyObject * self, PyObject * args)
13551378
UBlueprint *reloaded_bp = nullptr;
13561379

13571380
Py_BEGIN_ALLOW_THREADS
1358-
reloaded_bp = FKismetEditorUtilities::ReloadBlueprint(bp);
1381+
#if ENGINE_MINOR_VERSION >= 24
1382+
reloaded_bp = FKismetEditorUtilities::ReplaceBlueprint(bp, bp);
1383+
#else
1384+
reloaded_bp = FKismetEditorUtilities::ReloadBlueprint(bp;
1385+
#endif
13591386
Py_END_ALLOW_THREADS
13601387

13611388
Py_RETURN_UOBJECT(reloaded_bp);

‎Source/UnrealEnginePython/Private/UEPyModule.cpp‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,11 @@ static PyObject* py_ue_get_py_proxy(ue_PyUObject* self, PyObject* args)
202202

203203
static PyObject* py_unreal_engine_shutdown(PyObject* self, PyObject* args)
204204
{
205-
205+
#if ENGINE_MINOR_VERSION >= 24
206+
RequestEngineExit(UTF8_TO_TCHAR("UnrealEnginePython: User requested exit."));
207+
#else
206208
GIsRequestingExit = true;
209+
#endif
207210

208211
Py_RETURN_NONE;
209212
}

0 commit comments

Comments
 (0)