Skip to content

Commit 1c718ae

Browse files
author
Roberto De Ioris
committed
pre4.15 first round
1 parent c33ee14 commit 1c718ae

File tree

8 files changed

+21
-68
lines changed

8 files changed

+21
-68
lines changed

Source/UnrealEnginePython/Private/PythonComponent.cpp

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -426,62 +426,6 @@ UObject *UPythonComponent::CallPythonComponentMethodObject(FString method_name,
426426
return nullptr;
427427
}
428428

429-
430-
TMap<FString, FString> UPythonComponent::CallPythonComponentMethodMap(FString method_name, FString args){
431-
TMap<FString, FString> output_map;
432-
433-
if (!py_component_instance)
434-
return output_map;
435-
436-
FScopePythonGIL gil;
437-
438-
PyObject *ret = nullptr;
439-
if (args.IsEmpty()) {
440-
ret = PyObject_CallMethod(py_component_instance, TCHAR_TO_UTF8(*method_name), NULL);
441-
}
442-
else {
443-
ret = PyObject_CallMethod(py_component_instance, TCHAR_TO_UTF8(*method_name), (char *)"s", TCHAR_TO_UTF8(*args));
444-
}
445-
446-
if (!ret) {
447-
unreal_engine_py_log_error();
448-
return output_map;
449-
}
450-
451-
if (!PyDict_Check(ret)) {
452-
UE_LOG(LogPython, Error, TEXT("return value is not a dict"));
453-
return output_map;
454-
}
455-
456-
PyObject *py_keys = PyDict_Keys(ret);
457-
Py_ssize_t len = PyList_Size(py_keys);
458-
459-
for (Py_ssize_t i = 0; i < len; i++) {
460-
PyObject *py_key = PyList_GetItem(py_keys, i);
461-
PyObject *py_str_key = PyObject_Str(py_key);
462-
PyObject *py_str_value = PyObject_Str(PyDict_GetItem(ret, py_key));
463-
464-
if (!py_str_key || !py_str_value) {
465-
Py_DECREF(ret);
466-
return output_map;
467-
}
468-
469-
char *str_key = PyUnicode_AsUTF8(py_str_key);
470-
char *str_value = PyUnicode_AsUTF8(py_str_value);
471-
472-
FString ret_fstring_key = FString(UTF8_TO_TCHAR(str_key));
473-
FString ret_fstring_value = FString(UTF8_TO_TCHAR(str_value));
474-
475-
output_map.Add(ret_fstring_key, ret_fstring_value);
476-
477-
Py_DECREF(py_str_key);
478-
Py_DECREF(py_str_value);
479-
}
480-
481-
Py_DECREF(ret);
482-
483-
return output_map;
484-
}
485429
void UPythonComponent::CallPythonComponentMethodStringArray(FString method_name, FString args, TArray<FString> &output_strings)
486430
{
487431
if (!py_component_instance)
@@ -528,7 +472,7 @@ void UPythonComponent::CallPythonComponentMethodStringArray(FString method_name,
528472
}
529473

530474
Py_DECREF(ret);
531-
}
475+
}
532476

533477

534478
UPythonComponent::~UPythonComponent()

Source/UnrealEnginePython/Private/Slate/UEPySlate.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
#include "LevelEditor.h"
66
#include "Editor/UnrealEd/Public/Toolkits/AssetEditorToolkit.h"
77
#include "Editor/Persona/Public/PersonaModule.h"
8+
#if ENGINE_MINOR_VERSION >= 14
89
#include "Editor/AnimationEditor/Public/IAnimationEditorModule.h"
10+
#endif
911
#include "Editor/StaticMeshEditor/Public/StaticMeshEditorModule.h"
1012
#include "Editor/PropertyEditor/Public/PropertyEditorModule.h"
1113
#include "Editor/PropertyEditor/Public/ISinglePropertyView.h"
@@ -802,10 +804,12 @@ PyObject *py_unreal_engine_add_menu_extension(PyObject * self, PyObject * args)
802804
FPersonaModule &Module = FModuleManager::LoadModuleChecked<FPersonaModule>(module);
803805
menu_extension_interface = (IHasMenuExtensibility *)&Module;
804806
}
807+
#if ENGINE_MINOR_VERSION >= 14
805808
else if (!strcmp(module, (char *)"AnimationEditor")) {
806809
IAnimationEditorModule &Module = FModuleManager::LoadModuleChecked<IAnimationEditorModule>(module);
807810
menu_extension_interface = (IHasMenuExtensibility *)&Module;
808811
}
812+
#endif
809813
else if (!strcmp(module, (char *)"StaticMeshEditor")) {
810814
IStaticMeshEditorModule &Module = FModuleManager::LoadModuleChecked<IStaticMeshEditorModule>(module);
811815
menu_extension_interface = (IHasMenuExtensibility *)&Module;

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,13 @@ static PyMethodDef ue_PyUObject_methods[] = {
473473

474474
{ "add_anim_composite_section", (PyCFunction)py_ue_add_anim_composite_section, METH_VARARGS, "" },
475475

476+
#if ENGINE_MINOR_VERSION >= 14
476477
#if WITH_EDITOR
477478
{ "get_raw_animation_data", (PyCFunction)py_ue_anim_sequence_get_raw_animation_data, METH_VARARGS, "" },
478479
{ "get_raw_animation_track", (PyCFunction)py_ue_anim_sequence_get_raw_animation_track, METH_VARARGS, "" },
479480
{ "add_new_raw_track", (PyCFunction)py_ue_anim_sequence_add_new_raw_track, METH_VARARGS, "" },
480481
#endif
482+
#endif
481483

482484

483485
// StaticMesh
@@ -680,7 +682,9 @@ static PyMethodDef ue_PyUObject_methods[] = {
680682
{ "skeleton_find_bone_index", (PyCFunction)py_ue_skeleton_find_bone_index, METH_VARARGS, "" },
681683
{ "skeleton_get_ref_bone_pose", (PyCFunction)py_ue_skeleton_get_ref_bone_pose, METH_VARARGS, "" },
682684

685+
#if ENGINE_MINOR_VERSION >= 14
683686
{ "skeleton_add_bone", (PyCFunction)py_ue_skeleton_add_bone, METH_VARARGS, "" },
687+
#endif
684688

685689

686690
// Timer

Source/UnrealEnginePython/Private/UObject/UEPyAnimSequence.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "UnrealEnginePythonPrivatePCH.h"
22
#include "Animation/AnimSequence.h"
33
#include "Animation/BlendSpaceBase.h"
4+
#include "Animation/AnimMontage.h"
45

56
PyObject *py_ue_anim_get_skeleton(ue_PyUObject * self, PyObject * args) {
67
ue_py_check(self);
@@ -21,7 +22,7 @@ PyObject *py_ue_anim_get_skeleton(ue_PyUObject * self, PyObject * args) {
2122
return (PyObject *)ret;
2223
}
2324

24-
25+
#if ENGINE_MINOR_VERSION > 14
2526
#if WITH_EDITOR
2627
PyObject *py_ue_anim_sequence_get_raw_animation_data(ue_PyUObject * self, PyObject * args) {
2728
ue_py_check(self);
@@ -94,6 +95,7 @@ PyObject *py_ue_anim_sequence_add_new_raw_track(ue_PyUObject * self, PyObject *
9495
return PyLong_FromLong(index);
9596
}
9697
#endif
98+
#endif
9799

98100
PyObject *py_ue_anim_set_skeleton(ue_PyUObject * self, PyObject * args) {
99101
ue_py_check(self);

Source/UnrealEnginePython/Private/UObject/UEPySkeletal.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ PyObject *py_ue_skeleton_get_ref_bone_pose(ue_PyUObject *self, PyObject * args)
137137
return py_ue_new_ftransform(skeleton->GetReferenceSkeleton().GetRefBonePose()[index]);
138138
}
139139

140+
#if ENGINE_MINOR_VERSION >= 14
140141
PyObject *py_ue_skeleton_add_bone(ue_PyUObject *self, PyObject * args) {
141142

142143
ue_py_check(self);
@@ -171,4 +172,5 @@ PyObject *py_ue_skeleton_add_bone(ue_PyUObject *self, PyObject * args) {
171172
skeleton->MarkPackageDirty();
172173

173174
Py_RETURN_NONE;
174-
}
175+
}
176+
#endif

Source/UnrealEnginePython/Private/UnrealEnginePython.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#include "UnrealEnginePythonPrivatePCH.h"
44
#include "PythonBlueprintFunctionLibrary.h"
55
#include "HAL/IConsoleManager.h"
6+
#if ENGINE_MINOR_VERSION < 13
7+
#include "ClassIconFinder.h"
8+
#endif
69

710
void unreal_engine_init_py_module();
811

@@ -227,7 +230,7 @@ void FUnrealEnginePythonModule::StartupModule()
227230
StyleSet->SetContentRoot(IPluginManager::Get().FindPlugin("UnrealEnginePython")->GetBaseDir() / "Resources");
228231
StyleSet->Set("ClassThumbnail.PythonScript", new FSlateImageBrush(StyleSet->RootToContentDir("Icon128.png"), FVector2D(128.0f, 128.0f)));
229232
FSlateStyleRegistry::RegisterSlateStyle(*StyleSet.Get());
230-
#if ENGINE_MINOR_VERSION == 13
233+
#if ENGINE_MINOR_VERSION < 13
231234
FClassIconFinder::RegisterIconSource(StyleSet.Get());
232235
#endif
233236
#endif

Source/UnrealEnginePython/Private/Wrappers/UEPyFStringAssetReference.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "UEPyFStringAssetReference.h"
44

55
static PyObject *py_ue_fstring_asset_reference_get_asset_name(ue_PyFStringAssetReference *self, PyObject * args) {
6-
return PyUnicode_FromString(TCHAR_TO_UTF8(*self->fstring_asset_reference.GetAssetName()));
6+
return PyUnicode_FromString(TCHAR_TO_UTF8(*self->fstring_asset_reference.ToString()));
77
}
88

99
static PyObject *py_ue_fstring_asset_reference_get_long_package_name(ue_PyFStringAssetReference *self, PyObject * args) {
@@ -20,7 +20,7 @@ static PyMethodDef ue_PyFStringAssetReference_methods[] = {
2020
static PyObject *ue_PyFStringAssetReference_str(ue_PyFStringAssetReference *self)
2121
{
2222
return PyUnicode_FromFormat("<unreal_engine.FStringAssetReference {'asset_name': %s}>",
23-
TCHAR_TO_UTF8(*self->fstring_asset_reference.GetAssetName()));
23+
TCHAR_TO_UTF8(*self->fstring_asset_reference.ToString()));
2424
}
2525

2626
static PyTypeObject ue_PyFStringAssetReferenceType = {

Source/UnrealEnginePython/Public/PythonComponent.h

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

55
#include "PythonComponent.generated.h"
66

7-
8-
97
UCLASS(BlueprintType, Blueprintable, ClassGroup = (Python), meta = (BlueprintSpawnableComponent))
108
class UPythonComponent : public UActorComponent
119
{
@@ -47,9 +45,6 @@ class UPythonComponent : public UActorComponent
4745
UFUNCTION(BlueprintCallable, Category = "Python")
4846
FString CallPythonComponentMethodString(FString method_name, FString args);
4947

50-
UFUNCTION(BlueprintCallable, Category = "Python")
51-
TMap<FString, FString> CallPythonComponentMethodMap(FString method_name, FString args);
52-
5348
UFUNCTION(BlueprintCallable, Category = "Python")
5449
void CallPythonComponentMethodStringArray(FString method_name, FString args, TArray<FString> &output_strings);
5550

@@ -88,4 +83,3 @@ class UPythonComponent : public UActorComponent
8883
// mapped uobject, required for debug and advanced reflection
8984
ue_PyUObject *py_uobject;
9085
};
91-

0 commit comments

Comments
 (0)