Skip to content

Commit 321b71c

Browse files
committed
added backward support for versions below 4.27, but did not test it. I want to check for 4.26.2
1 parent b77c30e commit 321b71c

File tree

11 files changed

+140
-8
lines changed

11 files changed

+140
-8
lines changed

Source/UnrealEnginePython/Private/Http/UEPyIHttpRequest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,11 @@ static int ue_py_ihttp_request_init(ue_PyIHttpRequest *self, PyObject *args, PyO
307307
{
308308
return -1;
309309
}
310+
#if ENGINE_MINOR_VERSION == 27
311+
new(&self->http_request) TSharedRef<IHttpRequest, ESPMode::ThreadSafe>(FHttpModule::Get().CreateRequest());
312+
#else
310313
new(&self->http_request) TSharedRef<IHttpRequest>(FHttpModule::Get().CreateRequest());
314+
#endif
311315
new(&self->on_process_request_complete) TSharedPtr<FPythonSmartHttpDelegate>(nullptr);
312316
new(&self->on_request_progress) TSharedPtr<FPythonSmartHttpDelegate>(nullptr);
313317
self->py_dict = PyDict_New();

Source/UnrealEnginePython/Private/Slate/UEPySCheckBox.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "UEPySCheckBox.h"
1+
#include "UEPySCheckBox.h"
22

33

44
static PyObject *py_ue_scheck_box_is_checked(ue_PySCheckBox *self, PyObject * args)
@@ -103,7 +103,18 @@ static int ue_py_scheck_box_init(ue_PySCheckBox *self, PyObject *args, PyObject
103103
ue_py_slate_farguments_enum("is_checked", IsChecked, ECheckBoxState);
104104
ue_py_slate_farguments_optional_enum("h_align", HAlign, EHorizontalAlignment);
105105
ue_py_slate_farguments_struct("padding", Padding, FMargin);
106+
#if ENGINE_MINOR_VERSION == 27
107+
//#pragma message("need more information!! mutable .... thing")
108+
#ifndef UE_BUILD_DEBUG
109+
#error "TODO: "
110+
#else
111+
#pragma message(" ====================================================== WARNING! ACHTUNG! Atención! ================================================")
112+
#pragma message("\t\tue_py_slate_farguments_enum(\"click_method\", ClickMethod, EButtonClickMethod::Type); // ")
113+
#pragma message(" ====================================================== WARNING! ACHTUNG! Atención! ================================================")
114+
#endif
115+
#else
106116
ue_py_slate_farguments_enum("click_method", ClickMethod, EButtonClickMethod::Type);
117+
#endif
107118
ue_py_slate_farguments_optional_bool("is_focusable", IsFocusable);
108119
ue_py_slate_farguments_optional_struct_ptr("unchecked_image", UncheckedImage, FSlateBrush);
109120
ue_py_slate_farguments_optional_struct_ptr("unchecked_hoveredimage", UncheckedHoveredImage, FSlateBrush);

Source/UnrealEnginePython/Private/Slate/UEPySlate.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,11 @@ PyObject *py_unreal_engine_invoke_tab(PyObject * self, PyObject * args)
14941494
return NULL;
14951495
}
14961496

1497+
#if ENGINE_MINOR_VERSION == 27
1498+
FGlobalTabmanager::Get()->TryInvokeTab(FTabId(FName(UTF8_TO_TCHAR(name))));
1499+
#else
14971500
FGlobalTabmanager::Get()->InvokeTab(FTabId(FName(UTF8_TO_TCHAR(name))));
1501+
#endif
14981502

14991503
Py_INCREF(Py_None);
15001504
return Py_None;

Source/UnrealEnginePython/Private/UEPyEditor.cpp

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ PyObject *py_unreal_engine_create_asset(PyObject * self, PyObject * args)
676676
PyObject *py_unreal_engine_get_asset_referencers(PyObject * self, PyObject * args)
677677
{
678678
char *path;
679+
679680
int depency_type = (int)EAssetRegistryDependencyType::All;
680681

681682
if (!PyArg_ParseTuple(args, "s|i:get_asset_referencers", &path, &depency_type))
@@ -688,7 +689,11 @@ PyObject *py_unreal_engine_get_asset_referencers(PyObject * self, PyObject * arg
688689

689690
FAssetRegistryModule& AssetRegistryModule = FModuleManager::GetModuleChecked<FAssetRegistryModule>("AssetRegistry");
690691
TArray<FName> referencers;
691-
AssetRegistryModule.Get().GetReferencers(UTF8_TO_TCHAR(path), referencers, (EAssetRegistryDependencyType::Type) depency_type);
692+
693+
694+
695+
AssetRegistryModule.Get().GetReferencers(UTF8_TO_TCHAR(path), referencers, (EAssetRegistryDependencyType::Type)depency_type);
696+
692697

693698
PyObject *referencers_list = PyList_New(0);
694699
for (FName name : referencers)
@@ -1346,7 +1351,11 @@ PyObject *py_unreal_engine_create_blueprint(PyObject * self, PyObject * args)
13461351
return PyErr_Format(PyExc_Exception, "invalid blueprint name");
13471352
}
13481353

1349-
UPackage *outer = CreatePackage(nullptr, UTF8_TO_TCHAR(name));
1354+
#if ENGINE_MINOR_VERSION == 27
1355+
UPackage *outer = CreatePackage(UTF8_TO_TCHAR(name));
1356+
#else
1357+
UPackage* outer = CreatePackage(nullptr, UTF8_TO_TCHAR(name));
1358+
#endif
13501359
if (!outer)
13511360
return PyErr_Format(PyExc_Exception, "unable to create package");
13521361

@@ -1508,7 +1517,14 @@ PyObject *py_unreal_engine_create_blueprint_from_actor(PyObject * self, PyObject
15081517
return PyErr_Format(PyExc_Exception, "uobject is not a UClass");
15091518
AActor *actor = (AActor *)py_obj->ue_object;
15101519

1511-
UBlueprint *bp = FKismetEditorUtilities::CreateBlueprintFromActor(UTF8_TO_TCHAR(name), actor, true);
1520+
#if ENGINE_MINOR_VERSION == 27
1521+
FKismetEditorUtilities::FCreateBlueprintFromActorParams Params;
1522+
Params.bReplaceActor = true;
1523+
1524+
UBlueprint* bp = FKismetEditorUtilities::CreateBlueprintFromActor( *FString( UTF8_TO_TCHAR(name) ), actor, Params);
1525+
#else
1526+
UBlueprint* bp = FKismetEditorUtilities::CreateBlueprintFromActor(UTF8_TO_TCHAR(name), actor, true);
1527+
#endif
15121528

15131529
Py_RETURN_UOBJECT(bp);
15141530
}
@@ -2089,7 +2105,11 @@ PyObject *py_ue_factory_create_new(ue_PyUObject *self, PyObject * args)
20892105
FString PackageName = PackageTools::SanitizePackageName(FString(UTF8_TO_TCHAR(name)));
20902106
#endif
20912107

2092-
UPackage *outer = CreatePackage(nullptr, *PackageName);
2108+
#if ENGINE_MINOR_VERSION == 27
2109+
UPackage* outer = CreatePackage(*PackageName);
2110+
#else
2111+
UPackage* outer = CreatePackage(nullptr, *PackageName);
2112+
#endif
20932113
if (!outer)
20942114
return PyErr_Format(PyExc_Exception, "unable to create package");
20952115

@@ -2161,7 +2181,11 @@ PyObject *py_ue_factory_import_object(ue_PyUObject *self, PyObject * args)
21612181
FString object_name = ObjectTools::SanitizeObjectName(FPaths::GetBaseFilename(UTF8_TO_TCHAR(filename)));
21622182
FString pkg_name = FString(UTF8_TO_TCHAR(name)) + TEXT("/") + object_name;
21632183

2164-
UPackage *outer = CreatePackage(nullptr, *pkg_name);
2184+
#if ENGINE_MINOR_VERSION == 27
2185+
UPackage* outer = CreatePackage(*pkg_name);
2186+
#else
2187+
UPackage* outer = CreatePackage(nullptr, *pkg_name);
2188+
#endif
21652189
if (!outer)
21662190
return PyErr_Format(PyExc_Exception, "unable to create package");
21672191

Source/UnrealEnginePython/Private/UEPyEngine.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ PyObject *py_unreal_engine_object_path_to_package_name(PyObject * self, PyObject
215215
{
216216
return NULL;
217217
}
218-
return PyUnicode_FromString(TCHAR_TO_UTF8(*FPackageName::ObjectPathToPackageName(UTF8_TO_TCHAR(path))));
218+
return PyUnicode_FromString(TCHAR_TO_UTF8(*FPackageName::ObjectPathToPackageName( FString( UTF8_TO_TCHAR(path) ) )));
219219
}
220220

221221
PyObject *py_unreal_engine_get_path(PyObject * self, PyObject * args)
@@ -1057,7 +1057,11 @@ PyObject *py_unreal_engine_create_package(PyObject *self, PyObject * args)
10571057
{
10581058
return PyErr_Format(PyExc_Exception, "package %s already exists", TCHAR_TO_UTF8(*u_package->GetPathName()));
10591059
}
1060+
#if ENGINE_MINOR_VERSION == 27
1061+
u_package = CreatePackage(UTF8_TO_TCHAR(name));
1062+
#else
10601063
u_package = CreatePackage(nullptr, UTF8_TO_TCHAR(name));
1064+
#endif
10611065
if (!u_package)
10621066
return PyErr_Format(PyExc_Exception, "unable to create package");
10631067
u_package->FileName = *FPackageName::LongPackageNameToFilename(UTF8_TO_TCHAR(name), FPackageName::GetAssetPackageExtension());
@@ -1082,7 +1086,11 @@ PyObject *py_unreal_engine_get_or_create_package(PyObject *self, PyObject * args
10821086
// create a new package if it does not exist
10831087
if (!u_package)
10841088
{
1089+
#if ENGINE_MINOR_VERSION == 27
1090+
u_package = CreatePackage(UTF8_TO_TCHAR(name));
1091+
#else
10851092
u_package = CreatePackage(nullptr, UTF8_TO_TCHAR(name));
1093+
#endif
10861094
if (!u_package)
10871095
return PyErr_Format(PyExc_Exception, "unable to create package");
10881096
u_package->FileName = *FPackageName::LongPackageNameToFilename(UTF8_TO_TCHAR(name), FPackageName::GetAssetPackageExtension());

Source/UnrealEnginePython/Private/UObject/UEPyObject.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,7 +2784,11 @@ PyObject *py_ue_save_package(ue_PyUObject * self, PyObject * args)
27842784
}
27852785
}
27862786
// create a new package if it does not exist
2787+
#if ENGINE_MINOR_VERSION == 27
2788+
package = CreatePackage(UTF8_TO_TCHAR(name));
2789+
#else
27872790
package = CreatePackage(nullptr, UTF8_TO_TCHAR(name));
2791+
#endif
27882792
if (!package)
27892793
return PyErr_Format(PyExc_Exception, "unable to create package");
27902794

Source/UnrealEnginePython/Private/UObject/UEPySequencer.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "UEPySequencer.h"
1+
#include "UEPySequencer.h"
22

33
#include "Runtime/MovieScene/Public/MovieScene.h"
44
#include "Runtime/MovieScene/Public/MovieScenePossessable.h"
@@ -601,7 +601,11 @@ PyObject *py_ue_sequencer_add_camera(ue_PyUObject *self, PyObject * args)
601601
// Lock the viewport to this camera
602602
if (NewCamera && NewCamera->GetLevel())
603603
{
604+
#if ENGINE_MINOR_VERSION == 27
605+
GCurrentLevelEditingViewportClient->SetCinematicActorLock(nullptr);
606+
#else
604607
GCurrentLevelEditingViewportClient->SetMatineeActorLock(nullptr);
608+
#endif
605609
GCurrentLevelEditingViewportClient->SetActorLock(NewCamera);
606610
GCurrentLevelEditingViewportClient->bLockedCameraView = true;
607611
GCurrentLevelEditingViewportClient->UpdateViewForLockedActor();
@@ -611,7 +615,18 @@ PyObject *py_ue_sequencer_add_camera(ue_PyUObject *self, PyObject * args)
611615
UMovieSceneSequence* Sequence = sequencer->GetFocusedMovieSceneSequence();
612616
UMovieScene* OwnerMovieScene = Sequence->GetMovieScene();
613617

618+
#if ENGINE_MINOR_VERSION == 27
619+
#ifndef UE_BUILD_DEBUG
620+
#error "don't compile it for production'"
621+
#else
622+
//MovieSceneToolHelpers::CameraAdded(OwnerMovieScene, CameraGuid, sequencer->GetLocalTime().Time.FloorToFrame());
623+
#pragma message(" ====================================================== WARNING! ACHTUNG! Atención! ================================================")
624+
#pragma message("\t\tMovieSceneToolHelpers::CameraAdded(OwnerMovieScene, CameraGuid, sequencer->GetLocalTime().Time.FloorToFrame());")
625+
#pragma message(" ====================================================== WARNING! ACHTUNG! Atención! ================================================")
626+
#endif
627+
#else
614628
MovieSceneToolHelpers::CameraAdded(OwnerMovieScene, CameraGuid, sequencer->GetLocalTime().Time.FloorToFrame());
629+
#endif
615630

616631
}
617632
#else

Source/UnrealEnginePython/Private/UObject/UEPySkeletal.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,14 @@ PyObject *py_ue_skeletal_mesh_set_soft_vertices(ue_PyUObject *self, PyObject * a
270270
model.Sections[section_index].NumVertices = soft_vertices.Num();
271271
model.Sections[section_index].CalcMaxBoneInfluences();
272272

273+
#if ENGINE_MINOR_VERSION == 27
274+
mesh->GetRefBasesInvMatrix().Empty();
275+
#else
273276
mesh->RefBasesInvMatrix.Empty();
277+
#endif
274278
mesh->CalculateInvRefMatrices();
275279

280+
276281
#if WITH_EDITOR
277282
mesh->PostEditChange();
278283
#endif
@@ -468,11 +473,18 @@ PyObject *py_ue_skeletal_mesh_set_skeleton(ue_PyUObject * self, PyObject * args)
468473
mesh->ReleaseResources();
469474
mesh->ReleaseResourcesFence.Wait();
470475

476+
#if ENGINE_MINOR_VERSION == 27
477+
mesh->SetSkeleton( skeleton );
478+
mesh->SetRefSkeleton( skeleton->GetReferenceSkeleton() );
479+
mesh->GetRefBasesInvMatrix().Empty();
480+
#else
471481
mesh->Skeleton = skeleton;
472482

473483
mesh->RefSkeleton = skeleton->GetReferenceSkeleton();
474484

475485
mesh->RefBasesInvMatrix.Empty();
486+
#endif
487+
476488
mesh->CalculateInvRefMatrices();
477489

478490
#if WITH_EDITOR
@@ -548,7 +560,12 @@ PyObject *py_ue_skeletal_mesh_set_bone_map(ue_PyUObject *self, PyObject * args)
548560

549561
model.Sections[section_index].BoneMap = bone_map;
550562

563+
#if ENGINE_MINOR_VERSION == 27
564+
mesh->GetRefBasesInvMatrix().Empty();
565+
#else
551566
mesh->RefBasesInvMatrix.Empty();
567+
#endif
568+
552569
mesh->CalculateInvRefMatrices();
553570

554571
#if WITH_EDITOR
@@ -701,7 +718,12 @@ PyObject *py_ue_skeletal_mesh_set_active_bone_indices(ue_PyUObject *self, PyObje
701718
model.ActiveBoneIndices = active_indices;
702719
model.ActiveBoneIndices.Sort();
703720

721+
#if ENGINE_MINOR_VERSION == 27
722+
mesh->GetRefBasesInvMatrix().Empty();
723+
#else
704724
mesh->RefBasesInvMatrix.Empty();
725+
#endif
726+
705727
mesh->CalculateInvRefMatrices();
706728

707729
#if WITH_EDITOR
@@ -810,7 +832,11 @@ PyObject *py_ue_skeletal_mesh_set_required_bones(ue_PyUObject *self, PyObject *
810832
model.RequiredBones = required_bones;
811833
model.RequiredBones.Sort();
812834

835+
#if ENGINE_MINOR_VERSION == 27
836+
mesh->GetRefBasesInvMatrix().Empty();
837+
#else
813838
mesh->RefBasesInvMatrix.Empty();
839+
#endif
814840
mesh->CalculateInvRefMatrices();
815841

816842
#if WITH_EDITOR
@@ -1065,7 +1091,11 @@ PyObject *py_ue_skeletal_mesh_build_lod(ue_PyUObject *self, PyObject * args, PyO
10651091
build_settings.bComputeTangents = (py_compute_tangents && PyObject_IsTrue(py_compute_tangents));
10661092
build_settings.bRemoveDegenerateTriangles = true;
10671093

1094+
#if ENGINE_MINOR_VERSION == 27
1095+
bool success = MeshUtilities.BuildSkeletalMesh(lod_model, mesh->GetName(), mesh->GetRefSkeleton(), influences, wedges, faces, points, points_to_map, build_settings);
1096+
#else
10681097
bool success = MeshUtilities.BuildSkeletalMesh(lod_model, mesh->RefSkeleton, influences, wedges, faces, points, points_to_map, build_settings);
1098+
#endif
10691099

10701100
if (!success)
10711101
{
@@ -1079,17 +1109,31 @@ PyObject *py_ue_skeletal_mesh_build_lod(ue_PyUObject *self, PyObject * args, PyO
10791109
}
10801110
#endif
10811111

1112+
#if ENGINE_MINOR_VERSION == 27
1113+
mesh->CalculateRequiredBones(LODModel, mesh->GetRefSkeleton(), nullptr);
1114+
#else
10821115
mesh->CalculateRequiredBones(LODModel, mesh->RefSkeleton, nullptr);
1116+
#endif
10831117
mesh->CalculateInvRefMatrices();
10841118

1119+
#if ENGINE_MINOR_VERSION == 27
1120+
mesh->GetSkeleton()->RecreateBoneTree(mesh);
1121+
mesh->GetSkeleton()->SetPreviewMesh(mesh);
1122+
#else
10851123
mesh->Skeleton->RecreateBoneTree(mesh);
10861124
mesh->Skeleton->SetPreviewMesh(mesh);
1125+
#endif
10871126

10881127
// calculate bounds from points
10891128
mesh->SetImportedBounds(FBoxSphereBounds(points.GetData(), points.Num()));
10901129

1130+
#if ENGINE_MINOR_VERSION == 27
1131+
mesh->GetSkeleton()->PostEditChange();
1132+
mesh->GetSkeleton()->MarkPackageDirty();
1133+
#else
10911134
mesh->Skeleton->PostEditChange();
10921135
mesh->Skeleton->MarkPackageDirty();
1136+
#endif
10931137

10941138
mesh->PostEditChange();
10951139
mesh->MarkPackageDirty();

Source/UnrealEnginePython/Private/Voice/UEPyIVoiceCapture.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,16 @@ static PyTypeObject ue_PyIVoiceCaptureType = {
131131
static int py_ue_ivoice_capture_init(ue_PyIVoiceCapture *self, PyObject * args)
132132
{
133133

134+
#if ENGINE_MINOR_VERSION == 27
135+
#ifdef UE_BUILD_DEBUG
136+
TSharedPtr<IVoiceCapture> voice_capture_ptr = FVoiceModule::Get().CreateVoiceCapture("", 44100, 16);
137+
#else
138+
#error "At first change this record"
139+
#endif
140+
#else
134141
TSharedPtr<IVoiceCapture> voice_capture_ptr = FVoiceModule::Get().CreateVoiceCapture();
142+
#endif
143+
135144
if (!voice_capture_ptr.IsValid())
136145
{
137146
PyErr_SetString(PyExc_Exception, "unable to create a new VoiceCapture");

Source/UnrealEnginePython/Private/Wrappers/UEPyFAssetData.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,13 @@ static PyObject *py_ue_fassetdata_get_tags_and_values(ue_PyFAssetData *self, voi
122122
for (auto It = self->asset_data.TagsAndValues.CreateConstIterator(); It; ++It)
123123
{
124124
PyDict_SetItem(ret,
125+
#if ENGINE_MINOR_VERSION == 27
126+
PyUnicode_FromString(TCHAR_TO_UTF8(*It.Key().ToString() )),
127+
PyUnicode_FromString(TCHAR_TO_UTF8(*It.Value().AsString() )));
128+
#else
125129
PyUnicode_FromString(TCHAR_TO_UTF8(*It->Key.ToString())),
126130
PyUnicode_FromString(TCHAR_TO_UTF8(*It->Value)));
131+
#endif
127132
}
128133
return ret;
129134
}

0 commit comments

Comments
 (0)