Skip to content

Commit e3ebc3a

Browse files
author
David
committed
Wrapped some 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 fca0597 commit e3ebc3a

File tree

6 files changed

+53
-2
lines changed

6 files changed

+53
-2
lines changed

Source/UnrealEnginePython/Private/UEPyEditor.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,11 @@ PyObject *py_unreal_engine_create_blueprint(PyObject * self, PyObject * args)
12971297

12981298
TArray<UPackage *> TopLevelPackages;
12991299
TopLevelPackages.Add(outer);
1300+
#if ENGINE_MINOR_VERSION >= 21
1301+
if (!UPackageTools::HandleFullyLoadingPackages(TopLevelPackages, FText::FromString("Create a new object")))
1302+
#else
13001303
if (!PackageTools::HandleFullyLoadingPackages(TopLevelPackages, FText::FromString("Create a new object")))
1304+
#endif
13011305
return PyErr_Format(PyExc_Exception, "unable to fully load package");
13021306

13031307
if (FindObject<UBlueprint>(outer, UTF8_TO_TCHAR(bp_name)) != nullptr)
@@ -2024,15 +2028,23 @@ PyObject *py_ue_factory_create_new(ue_PyUObject *self, PyObject * args)
20242028
return PyErr_Format(PyExc_Exception, "invalid object name");
20252029
}
20262030

2031+
#if ENGINE_MINOR_VERSION >= 21
2032+
FString PackageName = UPackageTools::SanitizePackageName(FString(UTF8_TO_TCHAR(name)));
2033+
#else
20272034
FString PackageName = PackageTools::SanitizePackageName(FString(UTF8_TO_TCHAR(name)));
2035+
#endif
20282036

20292037
UPackage *outer = CreatePackage(nullptr, *PackageName);
20302038
if (!outer)
20312039
return PyErr_Format(PyExc_Exception, "unable to create package");
20322040

20332041
TArray<UPackage *> TopLevelPackages;
20342042
TopLevelPackages.Add(outer);
2043+
#if ENGINE_MINOR_VERSION >= 21
2044+
if (!UPackageTools::HandleFullyLoadingPackages(TopLevelPackages, FText::FromString("Create a new object")))
2045+
#else
20352046
if (!PackageTools::HandleFullyLoadingPackages(TopLevelPackages, FText::FromString("Create a new object")))
2047+
#endif
20362048
return PyErr_Format(PyExc_Exception, "unable to fully load package");
20372049

20382050
UClass *u_class = factory->GetSupportedClass();
@@ -2136,7 +2148,11 @@ PyObject *py_unreal_engine_add_level_to_world(PyObject *self, PyObject * args)
21362148
if (!FPackageName::DoesPackageExist(UTF8_TO_TCHAR(name), nullptr, nullptr))
21372149
return PyErr_Format(PyExc_Exception, "package does not exist");
21382150

2151+
#if ENGINE_MINOR_VERSION >= 21
2152+
UClass *streaming_mode_class = ULevelStreamingDynamic::StaticClass();
2153+
#else
21392154
UClass *streaming_mode_class = ULevelStreamingKismet::StaticClass();
2155+
#endif
21402156
if (py_bool && PyObject_IsTrue(py_bool))
21412157
{
21422158
streaming_mode_class = ULevelStreamingAlwaysLoaded::StaticClass();

Source/UnrealEnginePython/Private/UEPyEngine.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,11 @@ PyObject *py_unreal_engine_unload_package(PyObject * self, PyObject * args)
315315
}
316316

317317
FText outErrorMsg;
318+
#if ENGINE_MINOR_VERSION >= 21
319+
if (!UPackageTools::UnloadPackages({ packageToUnload }, outErrorMsg))
320+
#else
318321
if (!PackageTools::UnloadPackages({ packageToUnload }, outErrorMsg))
322+
#endif
319323
{
320324
return PyErr_Format(PyExc_Exception, "%s", TCHAR_TO_UTF8(*outErrorMsg.ToString()));
321325
}

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,11 @@ static PyObject* py_ue_get_py_proxy(ue_PyUObject* self, PyObject* args)
203203
static PyObject* py_unreal_engine_shutdown(PyObject* self, PyObject* args)
204204
{
205205

206-
// GIsRequestingExit = true;
206+
#if ENGINE_MINOR_VERSION >= 24
207207
RequestEngineExit(FString(TEXT("I'm Shutting Down, Dave...")));
208+
#else
209+
GIsRequestingExit = true;
210+
#endif
208211
Py_RETURN_NONE;
209212
}
210213

Source/UnrealEnginePython/Private/UObject/UEPyActor.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,11 @@ PyObject *py_ue_actor_create_default_subobject(ue_PyUObject * self, PyObject * a
649649
UObject *ret_obj = nullptr;
650650

651651
Py_BEGIN_ALLOW_THREADS;
652+
#if ENGINE_MINOR_VERSION >= 24
652653
ret_obj = actor->CreateDefaultSubobject(FName(UTF8_TO_TCHAR(name)), UObject::StaticClass(), u_class, false, true);
654+
#else
655+
ret_obj = actor->CreateDefaultSubobject(FName(UTF8_TO_TCHAR(name)), UObject::StaticClass(), u_class, false, false, true);
656+
#endif
653657
Py_END_ALLOW_THREADS;
654658

655659
if (!ret_obj)
@@ -795,7 +799,11 @@ PyObject *py_ue_get_actor_components_by_type(ue_PyUObject * self, PyObject * arg
795799

796800
PyObject *components = PyList_New(0);
797801

802+
#if ENGINE_MINOR_VERSION >= 24
803+
for (UActorComponent *component : actor->K2_GetComponentsByClass(u_class))
804+
#else
798805
for (UActorComponent *component : actor->GetComponentsByClass(u_class))
806+
#endif
799807
{
800808
ue_PyUObject *item = ue_get_python_uobject(component);
801809
if (item)
@@ -1040,4 +1048,4 @@ PyObject *py_ue_get_editor_world_counterpart_actor(ue_PyUObject * self, PyObject
10401048

10411049
Py_RETURN_UOBJECT(editor_actor);
10421050
}
1043-
#endif
1051+
#endif

Source/UnrealEnginePython/Private/UObject/UEPySequencer.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ static bool ImportFBXTransform(FString NodeName, UMovieScene3DTransformSection*
167167
FInterpCurveFloat EulerRotation[3];
168168
FInterpCurveFloat Scale[3];
169169
#endif
170+
#if ENGINE_MINOR_VERSION > 21
171+
CurveAPI.GetConvertedTransformCurveData(NodeName, Translation[0], Translation[1], Translation[2], EulerRotation[0], EulerRotation[1], EulerRotation[2], Scale[0], Scale[1], Scale[2], DefaultTransform, false);
172+
#else
170173
CurveAPI.GetConvertedTransformCurveData(NodeName, Translation[0], Translation[1], Translation[2], EulerRotation[0], EulerRotation[1], EulerRotation[2], Scale[0], Scale[1], Scale[2], DefaultTransform);
174+
#endif
171175

172176

173177
TransformSection->Modify();
@@ -1670,7 +1674,11 @@ PyObject *py_ue_sequencer_import_fbx_transform(ue_PyUObject *self, PyObject * ar
16701674
#endif
16711675
FTransform DefaultTransform;
16721676
#if ENGINE_MINOR_VERSION >= 18
1677+
#if ENGINE_MINOR_VERSION >= 21
1678+
CurveAPI.GetConvertedTransformCurveData(NodeName, Translation[0], Translation[1], Translation[2], EulerRotation[0], EulerRotation[1], EulerRotation[2], Scale[0], Scale[1], Scale[2], DefaultTransform, false);
1679+
#else
16731680
CurveAPI.GetConvertedTransformCurveData(NodeName, Translation[0], Translation[1], Translation[2], EulerRotation[0], EulerRotation[1], EulerRotation[2], Scale[0], Scale[1], Scale[2], DefaultTransform);
1681+
#endif
16741682
#if ENGINE_MINOR_VERSION < 20
16751683
for (int32 ChannelIndex = 0; ChannelIndex < 3; ++ChannelIndex)
16761684
{

Source/UnrealEnginePython/Private/UObject/UEPyTransform.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,11 @@ PyObject *py_ue_get_relative_location(ue_PyUObject *self, PyObject * args)
466466
ue_py_check(self);
467467
if (self->ue_object->IsA<USceneComponent>())
468468
{
469+
#if ENGINE_MINOR_VERSION >= 24
469470
FVector vec3 = ((USceneComponent *)self->ue_object)->GetRelativeLocation();
471+
#else
472+
FVector vec3 = ((USceneComponent *)self->ue_object)->RelativeLocation;
473+
#endif
470474
return py_ue_new_fvector(vec3);
471475
}
472476
return PyErr_Format(PyExc_Exception, "uobject is not a USceneComponent");
@@ -477,7 +481,11 @@ PyObject *py_ue_get_relative_rotation(ue_PyUObject *self, PyObject * args)
477481
ue_py_check(self);
478482
if (self->ue_object->IsA<USceneComponent>())
479483
{
484+
#if ENGINE_MINOR_VERSION >= 24
480485
FRotator rot = ((USceneComponent *)self->ue_object)->GetRelativeRotation();
486+
#else
487+
FRotator rot = ((USceneComponent *)self->ue_object)->RelativeRotation;
488+
#endif
481489
return py_ue_new_frotator(rot);
482490
}
483491
return PyErr_Format(PyExc_Exception, "uobject is not a USceneComponent");
@@ -488,7 +496,11 @@ PyObject *py_ue_get_relative_scale(ue_PyUObject *self, PyObject * args)
488496
ue_py_check(self);
489497
if (self->ue_object->IsA<USceneComponent>())
490498
{
499+
#if ENGINE_MINOR_VERSION >= 24
491500
FVector vec3 = ((USceneComponent *)self->ue_object)->GetRelativeScale3D();
501+
#else
502+
FVector vec3 = ((USceneComponent *)self->ue_object)->RelativeScale3D;
503+
#endif
492504
return py_ue_new_fvector(vec3);
493505
}
494506
return PyErr_Format(PyExc_Exception, "uobject is not a USceneComponent");

0 commit comments

Comments
 (0)