diff --git a/README.md b/README.md index 68ed706f1..a86c9f35b 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Once the plugin is installed and enabled, you get access to the 'PythonConsole' All of the exposed engine features are under the 'unreal_engine' virtual module (it is completely coded in c into the plugin, so do not expect to run 'import unreal_engine' from a standard python shell) -The minimal supported Unreal Engine version is 4.12, while the latest is 4.23 +The minimal supported Unreal Engine version is 4.12, while the latest is 4.24 We support official python.org releases as well as IntelPython and Anaconda distributions. diff --git a/Source/PythonAutomation/PythonAutomation.Build.cs b/Source/PythonAutomation/PythonAutomation.Build.cs index e2f80b814..6e5127cd6 100644 --- a/Source/PythonAutomation/PythonAutomation.Build.cs +++ b/Source/PythonAutomation/PythonAutomation.Build.cs @@ -13,8 +13,7 @@ public PythonAutomation(TargetInfo Target) { PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD"); - bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild); - + bUseUnity = string.IsNullOrEmpty(enableUnityBuild); PrivateIncludePaths.AddRange( new string[] { "PythonConsole/Private", diff --git a/Source/PythonConsole/PythonConsole.Build.cs b/Source/PythonConsole/PythonConsole.Build.cs index 29476f1dc..2065442b2 100644 --- a/Source/PythonConsole/PythonConsole.Build.cs +++ b/Source/PythonConsole/PythonConsole.Build.cs @@ -13,7 +13,7 @@ public PythonConsole(TargetInfo Target) { PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD"); - bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild); + bUseUnity = string.IsNullOrEmpty(enableUnityBuild); PrivateIncludePaths.AddRange( new string[] { diff --git a/Source/PythonEditor/Private/PythonEditor.cpp b/Source/PythonEditor/Private/PythonEditor.cpp index 42bbf9e5e..00d8cb9f4 100644 --- a/Source/PythonEditor/Private/PythonEditor.cpp +++ b/Source/PythonEditor/Private/PythonEditor.cpp @@ -7,6 +7,7 @@ #include "PythonEditorStyle.h" #include "PythonProjectEditor.h" #include "PythonProject.h" +#include "Subsystems/AssetEditorSubsystem.h" #include "Runtime/Slate/Public/Framework/MultiBox/MultiBoxBuilder.h" static const FName PythonEditorTabName( TEXT( "PythonEditor" ) ); diff --git a/Source/PythonEditor/Private/PythonProjectEditor.cpp b/Source/PythonEditor/Private/PythonProjectEditor.cpp index 33b2a56c8..1d17d5bf5 100644 --- a/Source/PythonEditor/Private/PythonProjectEditor.cpp +++ b/Source/PythonEditor/Private/PythonProjectEditor.cpp @@ -1,6 +1,11 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. #include "PythonProjectEditor.h" + +#include "Subsystems/AssetEditorSubsystem.h" + +// #include "UnrealEd.h" + #include "SPythonEditor.h" #include "SPythonProjectEditor.h" #include "Runtime/Slate/Public/Widgets/Docking/SDockTab.h" @@ -13,6 +18,8 @@ #include "PythonProjectEditorCommands.h" #include "Runtime/Core/Public/HAL/PlatformFilemanager.h" #include "Runtime/Core/Public/Misc/MessageDialog.h" + + #define LOCTEXT_NAMESPACE "PythonEditor" TWeakPtr FPythonProjectEditor::PythonEditor; @@ -209,7 +216,9 @@ void FPythonProjectEditor::RegisterToolbarTab(const TSharedRef& InitToolkitHost, class UPythonProject* PythonProject) { - FAssetEditorManager::Get().CloseOtherEditors(PythonProject, this); + // UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem(); + // GEditor->GetEditorSubsystem()->CloseOtherEditors(PythonProject, this); + GEditor->GetEditorSubsystem()->CloseOtherEditors(PythonProject, this); PythonProjectBeingEdited = PythonProject; TSharedPtr ThisPtr(SharedThis(this)); diff --git a/Source/PythonEditor/PythonEditor.Build.cs b/Source/PythonEditor/PythonEditor.Build.cs index 11b024164..bba5cb41b 100644 --- a/Source/PythonEditor/PythonEditor.Build.cs +++ b/Source/PythonEditor/PythonEditor.Build.cs @@ -13,7 +13,7 @@ public PythonEditor(TargetInfo Target) PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD"); - bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild); + bUseUnity = string.IsNullOrEmpty(enableUnityBuild); PrivateIncludePaths.AddRange( new string[] { @@ -32,11 +32,13 @@ public PythonEditor(TargetInfo Target) "UnrealEd", "EditorStyle", "PropertyEditor", + "ContentBrowser", "Kismet", // for FWorkflowCentricApplication "InputCore", "DirectoryWatcher", "LevelEditor", "Projects", + "Engine", "UnrealEnginePython" } ); diff --git a/Source/UnrealEnginePython/Private/MaterialEditorUtilities/UEPyFMaterialEditorUtilities.cpp b/Source/UnrealEnginePython/Private/MaterialEditorUtilities/UEPyFMaterialEditorUtilities.cpp index 0b80f1466..0cd0bdf4d 100644 --- a/Source/UnrealEnginePython/Private/MaterialEditorUtilities/UEPyFMaterialEditorUtilities.cpp +++ b/Source/UnrealEnginePython/Private/MaterialEditorUtilities/UEPyFMaterialEditorUtilities.cpp @@ -1,7 +1,10 @@ #include "UEPyFMaterialEditorUtilities.h" + #if WITH_EDITOR +#include "Subsystems/AssetEditorSubsystem.h" + #include "Materials/Material.h" #include "Runtime/Engine/Classes/EdGraph/EdGraph.h" @@ -54,7 +57,9 @@ static PyObject *py_ue_command_apply(PyObject *cls, PyObject * args) return PyErr_Format(PyExc_Exception, "argument is not a UMaterial"); } - IAssetEditorInstance *Instance = FAssetEditorManager::Get().FindEditorForAsset(Material, false); + //UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem(); + + IAssetEditorInstance *Instance = GEditor->GetEditorSubsystem()->FindEditorForAsset(Material, false); if (!Instance) { return PyErr_Format(PyExc_Exception, "unable to retrieve editor for UMaterial"); diff --git a/Source/UnrealEnginePython/Private/PythonDelegate.cpp b/Source/UnrealEnginePython/Private/PythonDelegate.cpp index e7e4c6699..640232ba7 100644 --- a/Source/UnrealEnginePython/Private/PythonDelegate.cpp +++ b/Source/UnrealEnginePython/Private/PythonDelegate.cpp @@ -2,6 +2,7 @@ #include "PythonDelegate.h" #include "UEPyModule.h" #include "UEPyCallable.h" +#include "UObject/UEPyUPropertyBackwardsCompatibility.h" UPythonDelegate::UPythonDelegate() { @@ -37,10 +38,10 @@ void UPythonDelegate::ProcessEvent(UFunction *function, void *Parms) py_args = PyTuple_New(signature->NumParms); Py_ssize_t argn = 0; - TFieldIterator PArgs(signature); + TFieldIterator PArgs(signature); for (; PArgs && argn < signature->NumParms && ((PArgs->PropertyFlags & (CPF_Parm | CPF_ReturnParm)) == CPF_Parm); ++PArgs) { - UProperty *prop = *PArgs; + FProperty *prop = *PArgs; PyObject *arg = ue_py_convert_property(prop, (uint8 *)Parms, 0); if (!arg) { @@ -63,7 +64,7 @@ void UPythonDelegate::ProcessEvent(UFunction *function, void *Parms) // currently useless as events do not return a value /* if (signature_set) { - UProperty *return_property = signature->GetReturnProperty(); + FProperty *return_property = signature->GetReturnProperty(); if (return_property && signature->ReturnValueOffset != MAX_uint16) { if (!ue_py_convert_pyobject(ret, return_property, (uint8 *)Parms)) { UE_LOG(LogPython, Error, TEXT("Invalid return value type for delegate")); diff --git a/Source/UnrealEnginePython/Private/PythonFunction.cpp b/Source/UnrealEnginePython/Private/PythonFunction.cpp index efeb5b059..33f3e1363 100644 --- a/Source/UnrealEnginePython/Private/PythonFunction.cpp +++ b/Source/UnrealEnginePython/Private/PythonFunction.cpp @@ -1,6 +1,7 @@ #include "PythonFunction.h" #include "UEPyModule.h" +#include "UObject/UEPyUPropertyBackwardsCompatibility.h" void UPythonFunction::SetPyCallable(PyObject *callable) @@ -30,7 +31,7 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL) // count the number of arguments Py_ssize_t argn = (Context && !is_static) ? 1 : 0; - TFieldIterator IArgs(function); + TFieldIterator IArgs(function); for (; IArgs && ((IArgs->PropertyFlags & (CPF_Parm | CPF_ReturnParm)) == CPF_Parm); ++IArgs) { argn++; } @@ -56,7 +57,7 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL) // is it a blueprint call ? if (*Stack.Code == EX_EndFunctionParms) { - for (UProperty *prop = (UProperty *)function->Children; prop; prop = (UProperty *)prop->Next) { + for (FProperty *prop = (FProperty *)function->Children; prop; prop = (FProperty *)prop->Next) { if (prop->PropertyFlags & CPF_ReturnParm) continue; if (!on_error) { @@ -75,7 +76,7 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL) //UE_LOG(LogPython, Warning, TEXT("BLUEPRINT CALL")); frame = (uint8 *)FMemory_Alloca(function->PropertiesSize); FMemory::Memzero(frame, function->PropertiesSize); - for (UProperty *prop = (UProperty *)function->Children; *Stack.Code != EX_EndFunctionParms; prop = (UProperty *)prop->Next) { + for (FProperty *prop = (FProperty *)function->Children; *Stack.Code != EX_EndFunctionParms; prop = (FProperty *)prop->Next) { Stack.Step(Stack.Object, prop->ContainerPtrToValuePtr(frame)); if (prop->PropertyFlags & CPF_ReturnParm) continue; @@ -107,7 +108,7 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL) } // get return value (if required) - UProperty *return_property = function->GetReturnProperty(); + FProperty *return_property = function->GetReturnProperty(); if (return_property && function->ReturnValueOffset != MAX_uint16) { #if defined(UEPY_MEMORY_DEBUG) UE_LOG(LogPython, Warning, TEXT("FOUND RETURN VALUE")); diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.cpp b/Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.cpp index 3e0b978ed..29e9e07b2 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.cpp @@ -1,5 +1,5 @@ #include "UEPyFMenuBuilder.h" - +#include "IAssetTools.h" #include "Wrappers/UEPyESlateEnums.h" static PyObject* py_ue_fmenu_builder_begin_section(ue_PyFMenuBuilder* self, PyObject* args) @@ -115,6 +115,9 @@ static PyObject* py_ue_fmenu_builder_add_menu_separator(ue_PyFMenuBuilder* self, } #if WITH_EDITOR + +#include "ContentBrowserModule.h" + static PyObject* py_ue_fmenu_builder_add_asset_actions(ue_PyFMenuBuilder* self, PyObject* args) { PyObject* py_assets; @@ -140,8 +143,10 @@ static PyObject* py_ue_fmenu_builder_add_asset_actions(ue_PyFMenuBuilder* self, Py_DECREF(py_assets); FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked(TEXT("AssetTools")); - bool addedSomething = AssetToolsModule.Get().GetAssetActions(u_objects, self->menu_builder, true); - if (addedSomething) + + FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked("ContentBrowser"); + TArray& AssetMenuExtenderDelegates = ContentBrowserModule.GetAllAssetViewContextMenuExtenders(); + if (AssetMenuExtenderDelegates.Num() > 0) { Py_RETURN_TRUE; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySTextBlock.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySTextBlock.cpp index 92df02d50..1fdf549cb 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySTextBlock.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySTextBlock.cpp @@ -11,7 +11,13 @@ static PyObject *py_ue_stext_block_set_text(ue_PySTextBlock *self, PyObject * ar return nullptr; } +#if ENGINE_MINOR_VERSION < 25 py_STextBlock->SetText(FString(UTF8_TO_TCHAR(text))); +#else + FText tempText; + tempText.FromString(FString(UTF8_TO_TCHAR(text))); + py_STextBlock->SetText(tempText); +#endif Py_RETURN_SLATE_SELF; } diff --git a/Source/UnrealEnginePython/Private/UEPyAssetUserData.cpp b/Source/UnrealEnginePython/Private/UEPyAssetUserData.cpp index a43657401..d66068bca 100644 --- a/Source/UnrealEnginePython/Private/UEPyAssetUserData.cpp +++ b/Source/UnrealEnginePython/Private/UEPyAssetUserData.cpp @@ -8,7 +8,7 @@ PyObject *py_ue_asset_import_data(ue_PyUObject * self, PyObject * args) ue_py_check(self); UStruct *u_struct = (UStruct *)self->ue_object->GetClass(); - UClassProperty *u_property = (UClassProperty *)u_struct->FindPropertyByName(TEXT("AssetImportData")); + FClassProperty *u_property = (FClassProperty *)u_struct->FindPropertyByName(TEXT("AssetImportData")); if (!u_property) { return PyErr_Format(PyExc_Exception, "UObject does not have asset import data."); @@ -47,7 +47,7 @@ PyObject *py_ue_asset_import_data_set_sources(ue_PyUObject * self, PyObject * ar TArray filenames; UStruct *u_struct = (UStruct *)self->ue_object->GetClass(); - UClassProperty *u_property = (UClassProperty *)u_struct->FindPropertyByName(TEXT("AssetImportData")); + FClassProperty *u_property = (FClassProperty *)u_struct->FindPropertyByName(TEXT("AssetImportData")); if (!u_property) { return PyErr_Format(PyExc_Exception, "UObject does not have asset import data."); diff --git a/Source/UnrealEnginePython/Private/UEPyEditor.cpp b/Source/UnrealEnginePython/Private/UEPyEditor.cpp index 1b3df7bca..350611c2c 100644 --- a/Source/UnrealEnginePython/Private/UEPyEditor.cpp +++ b/Source/UnrealEnginePython/Private/UEPyEditor.cpp @@ -12,6 +12,7 @@ #include "UnrealEd.h" #include "FbxMeshUtils.h" #include "Kismet2/BlueprintEditorUtils.h" + #include "Editor/LevelEditor/Public/LevelEditorActions.h" #include "Editor/UnrealEd/Public/EditorLevelUtils.h" #include "Runtime/Projects/Public/Interfaces/IPluginManager.h" @@ -41,6 +42,7 @@ #include "UEPyIPlugin.h" + PyObject *py_unreal_engine_redraw_all_viewports(PyObject * self, PyObject * args) { FEditorSupportDelegates::RedrawAllViewports.Broadcast(); @@ -1140,7 +1142,9 @@ PyObject *py_unreal_engine_get_selected_assets(PyObject * self, PyObject * args) PyObject *py_unreal_engine_get_all_edited_assets(PyObject * self, PyObject * args) { - TArray assets = FAssetEditorManager::Get().GetAllEditedAssets(); + + //UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem(); + TArray assets = GEditor->GetEditorSubsystem()->GetAllEditedAssets(); PyObject *assets_list = PyList_New(0); for (UObject *asset : assets) @@ -1168,7 +1172,9 @@ PyObject *py_unreal_engine_open_editor_for_asset(PyObject * self, PyObject * arg if (!u_obj) return PyErr_Format(PyExc_Exception, "argument is not a UObject"); - if (FAssetEditorManager::Get().OpenEditorForAsset(u_obj)) + //UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem(); + + if (GEditor->GetEditorSubsystem()->OpenEditorForAsset(u_obj)) { Py_RETURN_TRUE; } @@ -1193,7 +1199,8 @@ PyObject *py_unreal_engine_find_editor_for_asset(PyObject * self, PyObject * arg if (py_bool && PyObject_IsTrue(py_bool)) bFocus = true; - IAssetEditorInstance *instance = FAssetEditorManager::Get().FindEditorForAsset(u_obj, bFocus); + //UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem(); + IAssetEditorInstance *instance = GEditor->GetEditorSubsystem()->FindEditorForAsset(u_obj, bFocus); if (!instance) return PyErr_Format(PyExc_Exception, "no editor found for asset"); @@ -1212,14 +1219,16 @@ PyObject *py_unreal_engine_close_editor_for_asset(PyObject * self, PyObject * ar UObject *u_obj = ue_py_check_type(py_obj); if (!u_obj) return PyErr_Format(PyExc_Exception, "argument is not a UObject"); - FAssetEditorManager::Get().CloseAllEditorsForAsset(u_obj); + + //UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem(); + GEditor->GetEditorSubsystem()->CloseAllEditorsForAsset(u_obj); Py_RETURN_NONE; } PyObject *py_unreal_engine_close_all_asset_editors(PyObject * self, PyObject * args) { - FAssetEditorManager::Get().CloseAllAssetEditors(); + GEditor->GetEditorSubsystem()->CloseAllAssetEditors(); Py_RETURN_NONE; } @@ -1355,7 +1364,7 @@ PyObject *py_unreal_engine_reload_blueprint(PyObject * self, PyObject * args) UBlueprint *reloaded_bp = nullptr; Py_BEGIN_ALLOW_THREADS - reloaded_bp = FKismetEditorUtilities::ReloadBlueprint(bp); + reloaded_bp = FKismetEditorUtilities::ReplaceBlueprint(bp, bp); Py_END_ALLOW_THREADS Py_RETURN_UOBJECT(reloaded_bp); diff --git a/Source/UnrealEnginePython/Private/UEPyModule.cpp b/Source/UnrealEnginePython/Private/UEPyModule.cpp index 56954d32e..c4c415e31 100644 --- a/Source/UnrealEnginePython/Private/UEPyModule.cpp +++ b/Source/UnrealEnginePython/Private/UEPyModule.cpp @@ -38,6 +38,8 @@ #include "UObject/UEPyExporter.h" #include "UObject/UEPyFoliage.h" +#include "UObject/UEPyUPropertyBackwardsCompatibility.h" + #include "UEPyAssetUserData.h" #if WITH_EDITOR @@ -118,8 +120,8 @@ #include "Runtime/Core/Public/UObject/PropertyPortFlags.h" #if ENGINE_MINOR_VERSION < 18 -#define USoftObjectProperty UAssetObjectProperty -#define USoftClassProperty UAssetClassProperty +#define FSoftObjectProperty UAssetObjectProperty +#define FSoftClassProperty UAssetClassProperty typedef FAssetPtr FSoftObjectPtr; #endif @@ -203,8 +205,8 @@ static PyObject* py_ue_get_py_proxy(ue_PyUObject* self, PyObject* args) static PyObject* py_unreal_engine_shutdown(PyObject* self, PyObject* args) { - GIsRequestingExit = true; - + // GIsRequestingExit = true; + RequestEngineExit(FString(TEXT("I'm Shutting Down, Dave..."))); Py_RETURN_NONE; } @@ -569,7 +571,7 @@ static PyMethodDef ue_PyUObject_methods[] = { { "properties", (PyCFunction)py_ue_properties, METH_VARARGS, "" }, { "get_property_class", (PyCFunction)py_ue_get_property_class, METH_VARARGS, "" }, { "has_property", (PyCFunction)py_ue_has_property, METH_VARARGS, "" }, - { "get_uproperty", (PyCFunction)py_ue_get_uproperty, METH_VARARGS, "" }, + { "get_FProperty", (PyCFunction)py_ue_get_uproperty, METH_VARARGS, "" }, { "get_property_struct", (PyCFunction)py_ue_get_property_struct, METH_VARARGS, "" }, { "get_property_array_dim", (PyCFunction)py_ue_get_property_array_dim, METH_VARARGS, "" }, { "get_inner", (PyCFunction)py_ue_get_inner, METH_VARARGS, "" }, @@ -1223,7 +1225,7 @@ static PyObject* ue_PyUObject_getattro(ue_PyUObject* self, PyObject* attr_name) { u_struct = (UStruct*)self->ue_object->GetClass(); } - UProperty* u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(attr))); + FProperty* u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(attr))); if (u_property) { // swallow previous exception @@ -1315,7 +1317,7 @@ static int ue_PyUObject_setattro(ue_PyUObject* self, PyObject* attr_name, PyObje { ue_py_check_int(self); - // first of all check for UProperty + // first of all check for FProperty if (PyUnicodeOrString_Check(attr_name)) { const char* attr = UEPyUnicode_AsUTF8(attr_name); @@ -1329,7 +1331,7 @@ static int ue_PyUObject_setattro(ue_PyUObject* self, PyObject* attr_name, PyObje { u_struct = (UStruct*)self->ue_object->GetClass(); } - UProperty* u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(attr))); + FProperty* u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(attr))); if (u_property) { #if WITH_EDITOR @@ -1355,7 +1357,7 @@ static int ue_PyUObject_setattro(ue_PyUObject* self, PyObject* attr_name, PyObje } else { - PyErr_SetString(PyExc_ValueError, "invalid value for UProperty"); + PyErr_SetString(PyExc_ValueError, "invalid value for FProperty"); return -1; } } @@ -1363,7 +1365,7 @@ static int ue_PyUObject_setattro(ue_PyUObject* self, PyObject* attr_name, PyObje #endif return 0; } - PyErr_SetString(PyExc_ValueError, "invalid value for UProperty"); + PyErr_SetString(PyExc_ValueError, "invalid value for FProperty"); return -1; } @@ -1473,19 +1475,19 @@ static PyObject* ue_PyUObject_call(ue_PyUObject* self, PyObject* args, PyObject* break; } - UProperty* u_property = ue_struct_get_field_from_name(u_script_struct, (char*)struct_key); + FProperty* u_property = ue_struct_get_field_from_name(u_script_struct, (char*)struct_key); if (u_property) { if (!ue_py_convert_pyobject(value, u_property, data, 0)) { FMemory::Free(data); - return PyErr_Format(PyExc_Exception, "invalid value for UProperty"); + return PyErr_Format(PyExc_Exception, "invalid value for FProperty"); } } else { FMemory::Free(data); - return PyErr_Format(PyExc_Exception, "UProperty %s not found", struct_key); + return PyErr_Format(PyExc_Exception, "FProperty %s not found", struct_key); } } } @@ -2015,9 +2017,9 @@ AActor* ue_get_actor(ue_PyUObject* py_obj) } // convert a property to a python object -PyObject* ue_py_convert_property(UProperty* prop, uint8* buffer, int32 index) +PyObject* ue_py_convert_property(FProperty* prop, uint8* buffer, int32 index) { - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { bool value = casted_prop->GetPropertyValue_InContainer(buffer, index); if (value) @@ -2027,44 +2029,44 @@ PyObject* ue_py_convert_property(UProperty* prop, uint8* buffer, int32 index) Py_RETURN_FALSE; } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { int value = casted_prop->GetPropertyValue_InContainer(buffer, index); return PyLong_FromLong(value); } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { uint32 value = casted_prop->GetPropertyValue_InContainer(buffer, index); return PyLong_FromUnsignedLong(value); } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { long long value = casted_prop->GetPropertyValue_InContainer(buffer, index); return PyLong_FromLongLong(value); } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { uint64 value = casted_prop->GetPropertyValue_InContainer(buffer, index); return PyLong_FromUnsignedLongLong(value); } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { float value = casted_prop->GetPropertyValue_InContainer(buffer, index); return PyFloat_FromDouble(value); } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { uint8 value = casted_prop->GetPropertyValue_InContainer(buffer, index); return PyLong_FromUnsignedLong(value); } #if ENGINE_MINOR_VERSION >= 15 - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { void* prop_addr = casted_prop->ContainerPtrToValuePtr(buffer, index); uint64 enum_index = casted_prop->GetUnderlyingProperty()->GetUnsignedIntPropertyValue(prop_addr); @@ -2072,25 +2074,25 @@ PyObject* ue_py_convert_property(UProperty* prop, uint8* buffer, int32 index) } #endif - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { FString value = casted_prop->GetPropertyValue_InContainer(buffer, index); return PyUnicode_FromString(TCHAR_TO_UTF8(*value)); } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { FText value = casted_prop->GetPropertyValue_InContainer(buffer, index); return PyUnicode_FromString(TCHAR_TO_UTF8(*value.ToString())); } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { FName value = casted_prop->GetPropertyValue_InContainer(buffer, index); return PyUnicode_FromString(TCHAR_TO_UTF8(*value.ToString())); } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { auto value = casted_prop->GetObjectPropertyValue_InContainer(buffer, index); if (value) @@ -2100,7 +2102,7 @@ PyObject* ue_py_convert_property(UProperty* prop, uint8* buffer, int32 index) Py_RETURN_NONE; } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { auto value = casted_prop->GetPropertyValue_InContainer(buffer, index); if (value) @@ -2111,7 +2113,7 @@ PyObject* ue_py_convert_property(UProperty* prop, uint8* buffer, int32 index) } // try to manage known struct first - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { if (auto casted_struct = Cast(casted_prop->Struct)) { @@ -2155,7 +2157,7 @@ PyObject* ue_py_convert_property(UProperty* prop, uint8* buffer, int32 index) return PyErr_Format(PyExc_TypeError, "unsupported UStruct type"); } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { auto value = casted_prop->GetPropertyValue_InContainer(buffer, index); UObject* strong_obj = value.Get(); @@ -2167,24 +2169,24 @@ PyObject* ue_py_convert_property(UProperty* prop, uint8* buffer, int32 index) Py_RETURN_NONE; } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { Py_RETURN_UOBJECT(casted_prop); } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { Py_RETURN_UOBJECT(casted_prop); } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { FScriptArrayHelper_InContainer array_helper(casted_prop, buffer, index); - UProperty* array_prop = casted_prop->Inner; + FProperty* array_prop = casted_prop->Inner; // check for TArray, so we can use bytearray optimization - if (auto uint8_tarray = Cast(array_prop)) + if (auto uint8_tarray = Cast(array_prop)) { uint8* buf = array_helper.GetRawPtr(); return PyByteArray_FromStringAndSize((char*)buf, array_helper.Num()); @@ -2208,7 +2210,7 @@ PyObject* ue_py_convert_property(UProperty* prop, uint8* buffer, int32 index) } #if ENGINE_MINOR_VERSION >= 15 - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { FScriptMapHelper_InContainer map_helper(casted_prop, buffer, index); @@ -2249,12 +2251,12 @@ PyObject* ue_py_convert_property(UProperty* prop, uint8* buffer, int32 index) } // convert a python object to a property -bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, int32 index) +bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, int32 index) { if (PyBool_Check(py_obj)) { - auto casted_prop = Cast(prop); + auto casted_prop = Cast(prop); if (!casted_prop) return false; if (PyObject_IsTrue(py_obj)) @@ -2270,42 +2272,42 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in if (PyNumber_Check(py_obj)) { - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { PyObject* py_long = PyNumber_Long(py_obj); casted_prop->SetPropertyValue_InContainer(buffer, PyLong_AsLong(py_long), index); Py_DECREF(py_long); return true; } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { PyObject* py_long = PyNumber_Long(py_obj); casted_prop->SetPropertyValue_InContainer(buffer, PyLong_AsUnsignedLong(py_long), index); Py_DECREF(py_long); return true; } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { PyObject* py_long = PyNumber_Long(py_obj); casted_prop->SetPropertyValue_InContainer(buffer, PyLong_AsLongLong(py_long), index); Py_DECREF(py_long); return true; } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { PyObject* py_long = PyNumber_Long(py_obj); casted_prop->SetPropertyValue_InContainer(buffer, PyLong_AsUnsignedLongLong(py_long), index); Py_DECREF(py_long); return true; } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { PyObject* py_float = PyNumber_Float(py_obj); casted_prop->SetPropertyValue_InContainer(buffer, PyFloat_AsDouble(py_float), index); Py_DECREF(py_float); return true; } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { PyObject* py_long = PyNumber_Long(py_obj); casted_prop->SetPropertyValue_InContainer(buffer, PyLong_AsUnsignedLong(py_long), index); @@ -2313,7 +2315,7 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in return true; } #if ENGINE_MINOR_VERSION >= 15 - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { PyObject* py_long = PyNumber_Long(py_obj); void* prop_addr = casted_prop->ContainerPtrToValuePtr(buffer, index); @@ -2329,17 +2331,17 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in if (PyUnicodeOrString_Check(py_obj)) { - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { casted_prop->SetPropertyValue_InContainer(buffer, UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(py_obj)), index); return true; } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { casted_prop->SetPropertyValue_InContainer(buffer, UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(py_obj)), index); return true; } - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { casted_prop->SetPropertyValue_InContainer(buffer, FText::FromString(UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(py_obj))), index); return true; @@ -2349,11 +2351,11 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in if (PyBytes_Check(py_obj)) { - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { FScriptArrayHelper_InContainer helper(casted_prop, buffer, index); - if (auto item_casted_prop = Cast(casted_prop->Inner)) + if (auto item_casted_prop = Cast(casted_prop->Inner)) { Py_ssize_t pybytes_len = PyBytes_Size(py_obj); @@ -2381,11 +2383,11 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in if (PyByteArray_Check(py_obj)) { - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { FScriptArrayHelper_InContainer helper(casted_prop, buffer, index); - if (auto item_casted_prop = Cast(casted_prop->Inner)) + if (auto item_casted_prop = Cast(casted_prop->Inner)) { Py_ssize_t pybytes_len = PyByteArray_Size(py_obj); @@ -2414,11 +2416,11 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in if (PyList_Check(py_obj)) { - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { FScriptArrayHelper_InContainer helper(casted_prop, buffer, index); - UProperty* array_prop = casted_prop->Inner; + FProperty* array_prop = casted_prop->Inner; Py_ssize_t pylist_len = PyList_Size(py_obj); // fix array helper size @@ -2447,11 +2449,11 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in if (PyTuple_Check(py_obj)) { - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { FScriptArrayHelper_InContainer helper(casted_prop, buffer, index); - UProperty* array_prop = casted_prop->Inner; + FProperty* array_prop = casted_prop->Inner; Py_ssize_t pytuple_len = PyTuple_Size(py_obj); // fix array helper size @@ -2481,7 +2483,7 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in #if ENGINE_MINOR_VERSION >= 15 if (PyDict_Check(py_obj)) { - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { FScriptMapHelper_InContainer map_helper(casted_prop, buffer, index); @@ -2519,7 +2521,7 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in if (ue_PyFVector * py_vec = py_ue_is_fvector(py_obj)) { - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { if (casted_prop->Struct == TBaseStructure::Get()) { @@ -2532,7 +2534,7 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in if (ue_PyFVector2D * py_vec = py_ue_is_fvector2d(py_obj)) { - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { if (casted_prop->Struct == TBaseStructure::Get()) { @@ -2545,7 +2547,7 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in if (ue_PyFRotator * py_rot = py_ue_is_frotator(py_obj)) { - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { if (casted_prop->Struct == TBaseStructure::Get()) { @@ -2558,7 +2560,7 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in if (ue_PyFTransform * py_transform = py_ue_is_ftransform(py_obj)) { - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { if (casted_prop->Struct == TBaseStructure::Get()) { @@ -2571,7 +2573,7 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in if (ue_PyFColor * py_color = py_ue_is_fcolor(py_obj)) { - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { if (casted_prop->Struct == TBaseStructure::Get()) { @@ -2585,7 +2587,7 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in if (ue_PyFLinearColor * py_color = py_ue_is_flinearcolor(py_obj)) { - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { if (casted_prop->Struct == TBaseStructure::Get()) { @@ -2598,7 +2600,7 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in if (ue_PyFHitResult * py_hit = py_ue_is_fhitresult(py_obj)) { - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { if (casted_prop->Struct == FHitResult::StaticStruct()) { @@ -2613,7 +2615,7 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in if (py_ue_is_uscriptstruct(py_obj)) { ue_PyUScriptStruct* py_u_struct = (ue_PyUScriptStruct*)py_obj; - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { if (casted_prop->Struct == py_u_struct->u_struct) { @@ -2631,31 +2633,31 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in ue_PyUObject* ue_obj = (ue_PyUObject*)py_obj; if (ue_obj->ue_object->IsA()) { - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { casted_prop->SetPropertyValue_InContainer(buffer, ue_obj->ue_object, index); return true; } - else if (auto casted_prop_soft_class = Cast(prop)) + else if (auto casted_prop_soft_class = Cast(prop)) { casted_prop_soft_class->SetPropertyValue_InContainer(buffer, FSoftObjectPtr(ue_obj->ue_object), index); return true; } - else if (auto casted_prop_soft_object = Cast(prop)) + else if (auto casted_prop_soft_object = Cast(prop)) { casted_prop_soft_object->SetPropertyValue_InContainer(buffer, FSoftObjectPtr(ue_obj->ue_object), index); return true; } - else if (auto casted_prop_weak_object = Cast(prop)) + else if (auto casted_prop_weak_object = Cast(prop)) { casted_prop_weak_object->SetPropertyValue_InContainer(buffer, FWeakObjectPtr(ue_obj->ue_object), index); return true; } - else if (auto casted_prop_base = Cast(prop)) + else if (auto casted_prop_base = Cast(prop)) { // ensure the object type is correct, otherwise crash could happen (soon or later) if (!ue_obj->ue_object->IsA(casted_prop_base->PropertyClass)) @@ -2672,7 +2674,7 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in if (ue_obj->ue_object->IsA()) { - if (auto casted_prop = Cast(prop)) + if (auto casted_prop = Cast(prop)) { // if the property specifies an interface, the object must be of a class that implements it if (casted_prop->PropertyClass->HasAnyClassFlags(CLASS_Interface)) @@ -2691,7 +2693,7 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in return true; } - else if (auto casted_prop_soft_object = Cast(prop)) + else if (auto casted_prop_soft_object = Cast(prop)) { if (!ue_obj->ue_object->IsA(casted_prop_soft_object->PropertyClass)) return false; @@ -2700,7 +2702,7 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in return true; } - else if (auto casted_prop_interface = Cast(prop)) + else if (auto casted_prop_interface = Cast(prop)) { // ensure the object type is correct, otherwise crash could happen (soon or later) if (!ue_obj->ue_object->GetClass()->ImplementsInterface(casted_prop_interface->InterfaceClass)) @@ -2716,7 +2718,7 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in if (py_obj == Py_None) { - auto casted_prop_class = Cast(prop); + auto casted_prop_class = Cast(prop); if (casted_prop_class) { @@ -2724,7 +2726,7 @@ bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, in return true; } - auto casted_prop = Cast(prop); + auto casted_prop = Cast(prop); if (casted_prop) { @@ -2879,10 +2881,10 @@ void ue_autobind_events_for_pyclass(ue_PyUObject* u_obj, PyObject* py_class) static void py_ue_destroy_params(UFunction* u_function, uint8* buffer) { // destroy params - TFieldIterator DArgs(u_function); + TFieldIterator DArgs(u_function); for (; DArgs && (DArgs->PropertyFlags & CPF_Parm); ++DArgs) { - UProperty* prop = *DArgs; + FProperty* prop = *DArgs; prop->DestroyValue_InContainer(buffer); } } @@ -2908,9 +2910,9 @@ PyObject* py_ue_ufunction_call(UFunction* u_function, UObject* u_obj, PyObject* uint8* buffer = (uint8*)FMemory_Alloca(u_function->ParmsSize); FMemory::Memzero(buffer, u_function->ParmsSize); // initialize args - for (TFieldIterator IArgs(u_function); IArgs && IArgs->HasAnyPropertyFlags(CPF_Parm); ++IArgs) + for (TFieldIterator IArgs(u_function); IArgs && IArgs->HasAnyPropertyFlags(CPF_Parm); ++IArgs) { - UProperty* prop = *IArgs; + FProperty* prop = *IArgs; if (!prop->HasAnyPropertyFlags(CPF_ZeroConstructor)) { prop->InitializeValue_InContainer(buffer); @@ -2943,10 +2945,10 @@ PyObject* py_ue_ufunction_call(UFunction* u_function, UObject* u_obj, PyObject* int has_out_params = 0; - TFieldIterator PArgs(u_function); + TFieldIterator PArgs(u_function); for (; PArgs && ((PArgs->PropertyFlags & (CPF_Parm | CPF_ReturnParm)) == CPF_Parm); ++PArgs) { - UProperty* prop = *PArgs; + FProperty* prop = *PArgs; if (argn < tuple_len) { PyObject* py_arg = PyTuple_GetItem(args, argn); @@ -2974,7 +2976,7 @@ PyObject* py_ue_ufunction_call(UFunction* u_function, UObject* u_obj, PyObject* } } } - if (prop->HasAnyPropertyFlags(CPF_OutParm) && (prop->IsA() || prop->HasAnyPropertyFlags(CPF_ConstParm) == false)) + if (prop->HasAnyPropertyFlags(CPF_OutParm) && (prop->IsA() || prop->HasAnyPropertyFlags(CPF_ConstParm) == false)) { has_out_params++; } @@ -2991,10 +2993,10 @@ PyObject* py_ue_ufunction_call(UFunction* u_function, UObject* u_obj, PyObject* PyObject* ret = nullptr; int has_ret_param = 0; - TFieldIterator Props(u_function); + TFieldIterator Props(u_function); for (; Props; ++Props) { - UProperty* prop = *Props; + FProperty* prop = *Props; if (prop->GetPropertyFlags() & CPF_ReturnParm) { ret = ue_py_convert_property(prop, buffer, 0); @@ -3016,11 +3018,11 @@ PyObject* py_ue_ufunction_call(UFunction* u_function, UObject* u_obj, PyObject* { PyTuple_SetItem(multi_ret, 0, ret); } - TFieldIterator OProps(u_function); + TFieldIterator OProps(u_function); for (; OProps; ++OProps) { - UProperty* prop = *OProps; - if (prop->HasAnyPropertyFlags(CPF_OutParm) && (prop->IsA() || prop->HasAnyPropertyFlags(CPF_ConstParm) == false)) + FProperty* prop = *OProps; + if (prop->HasAnyPropertyFlags(CPF_OutParm) && (prop->IsA() || prop->HasAnyPropertyFlags(CPF_ConstParm) == false)) { // skip return param as it must be always the first if (prop->GetPropertyFlags() & CPF_ReturnParm) @@ -3053,7 +3055,7 @@ PyObject* py_ue_ufunction_call(UFunction* u_function, UObject* u_obj, PyObject* PyObject* ue_unbind_pyevent(ue_PyUObject* u_obj, FString event_name, PyObject* py_callable, bool fail_on_wrong_property) { - UProperty* u_property = u_obj->ue_object->GetClass()->FindPropertyByName(FName(*event_name)); + FProperty* u_property = u_obj->ue_object->GetClass()->FindPropertyByName(FName(*event_name)); if (!u_property) { if (fail_on_wrong_property) @@ -3061,7 +3063,7 @@ PyObject* ue_unbind_pyevent(ue_PyUObject* u_obj, FString event_name, PyObject* p Py_RETURN_NONE; } - if (auto casted_prop = Cast(u_property)) + if (auto casted_prop = Cast(u_property)) { UPythonDelegate* py_delegate = FUnrealEnginePythonHouseKeeper::Get()->FindDelegate(u_obj->ue_object, py_callable); if (py_delegate != nullptr) @@ -3082,7 +3084,7 @@ PyObject* ue_unbind_pyevent(ue_PyUObject* u_obj, FString event_name, PyObject* p #endif } } - else if (auto casted_prop_delegate = Cast(u_property)) + else if (auto casted_prop_delegate = Cast(u_property)) { FScriptDelegate script_delegate = casted_prop_delegate->GetPropertyValue_InContainer(u_obj->ue_object); script_delegate.Unbind(); @@ -3102,7 +3104,7 @@ PyObject* ue_unbind_pyevent(ue_PyUObject* u_obj, FString event_name, PyObject* p PyObject* ue_bind_pyevent(ue_PyUObject* u_obj, FString event_name, PyObject* py_callable, bool fail_on_wrong_property) { - UProperty* u_property = u_obj->ue_object->GetClass()->FindPropertyByName(FName(*event_name)); + FProperty* u_property = u_obj->ue_object->GetClass()->FindPropertyByName(FName(*event_name)); if (!u_property) { if (fail_on_wrong_property) @@ -3110,7 +3112,7 @@ PyObject* ue_bind_pyevent(ue_PyUObject* u_obj, FString event_name, PyObject* py_ Py_RETURN_NONE; } - if (auto casted_prop = Cast(u_property)) + if (auto casted_prop = Cast(u_property)) { #if ENGINE_MINOR_VERSION < 23 FMulticastScriptDelegate multiscript_delegate = casted_prop->GetPropertyValue_InContainer(u_obj->ue_object); @@ -3133,7 +3135,7 @@ PyObject* ue_bind_pyevent(ue_PyUObject* u_obj, FString event_name, PyObject* py_ casted_prop->SetMulticastDelegate(u_obj->ue_object, multiscript_delegate); #endif } - else if (auto casted_prop_delegate = Cast(u_property)) + else if (auto casted_prop_delegate = Cast(u_property)) { FScriptDelegate script_delegate = casted_prop_delegate->GetPropertyValue_InContainer(u_obj->ue_object); @@ -3206,7 +3208,7 @@ UFunction* unreal_engine_add_function(UClass* u_class, char* name, PyObject* py_ PyObject* annotations = PyObject_GetAttrString(py_callable, "__annotations__"); UField** next_property = &function->Children; - UProperty** next_property_link = &function->PropertyLink; + FProperty** next_property_link = &function->PropertyLink; PyObject* parameters_keys = PyObject_GetIter(parameters); // do not process args if no annotations are available @@ -3229,65 +3231,65 @@ UFunction* unreal_engine_add_function(UClass* u_class, char* name, PyObject* py_ if (!value) continue; - UProperty* prop = nullptr; + FProperty* prop = nullptr; if (PyType_Check(value)) { if ((PyTypeObject*)value == &PyFloat_Type) { - prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); } else if ((PyTypeObject*)value == &PyUnicode_Type) { - prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); } else if ((PyTypeObject*)value == &PyBool_Type) { - prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); } else if ((PyTypeObject*)value == &PyLong_Type) { - prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); } else if ((PyTypeObject*)value == &ue_PyFVectorType) { - UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); prop_struct->Struct = TBaseStructure::Get(); prop = prop_struct; } else if ((PyTypeObject*)value == &ue_PyFVector2DType) { - UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); prop_struct->Struct = TBaseStructure::Get(); prop = prop_struct; } else if ((PyTypeObject*)value == &ue_PyFRotatorType) { - UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); prop_struct->Struct = TBaseStructure::Get(); prop = prop_struct; } else if ((PyTypeObject*)value == &ue_PyFLinearColorType) { - UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); prop_struct->Struct = TBaseStructure::Get(); prop = prop_struct; } else if ((PyTypeObject*)value == &ue_PyFColorType) { - UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); prop_struct->Struct = TBaseStructure::Get(); prop = prop_struct; } else if ((PyTypeObject*)value == &ue_PyFTransformType) { - UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); prop_struct->Struct = TBaseStructure::Get(); prop = prop_struct; } #if ENGINE_MINOR_VERSION > 18 else if ((PyTypeObject*)value == &ue_PyFQuatType) { - UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); prop_struct->Struct = TBaseStructure::Get(); prop = prop_struct; } @@ -3321,7 +3323,7 @@ UFunction* unreal_engine_add_function(UClass* u_class, char* name, PyObject* py_ UE_LOG(LogPython, Error, TEXT("type for %s must be a UClass"), UTF8_TO_TCHAR(name)); return nullptr; } - UClassProperty* prop_class = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FClassProperty* prop_class = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); prop_class->SetMetaClass((UClass*)py_obj->ue_object); prop_class->PropertyClass = UClass::StaticClass(); prop = prop_class; @@ -3333,15 +3335,15 @@ UFunction* unreal_engine_add_function(UClass* u_class, char* name, PyObject* py_ if (py_obj->ue_object->IsA()) { UClass* p_u_class = (UClass*)py_obj->ue_object; - UObjectProperty* prop_base = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FObjectProperty* prop_base = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); prop_base->SetPropertyClass(p_u_class); prop = prop_base; } #if ENGINE_MINOR_VERSION > 17 else if (py_obj->ue_object->IsA()) { - UEnumProperty* prop_enum = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); - UNumericProperty* prop_underlying = NewObject(prop_enum, TEXT("UnderlyingType"), RF_Public); + FEnumProperty* prop_enum = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FNumericProperty* prop_underlying = NewObject(prop_enum, TEXT("UnderlyingType"), RF_Public); prop_enum->SetEnum((UEnum*)py_obj->ue_object); prop_enum->AddCppProperty(prop_underlying); prop = prop_enum; @@ -3349,7 +3351,7 @@ UFunction* unreal_engine_add_function(UClass* u_class, char* name, PyObject* py_ #endif else if (py_obj->ue_object->IsA()) { - UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); prop_struct->Struct = (UScriptStruct*)py_obj->ue_object; prop = prop_struct; } @@ -3377,66 +3379,66 @@ UFunction* unreal_engine_add_function(UClass* u_class, char* name, PyObject* py_ if (py_return_value) { UE_LOG(LogPython, Warning, TEXT("Return Value found")); - UProperty* prop = nullptr; + FProperty* prop = nullptr; char* p_name = (char*) "ReturnValue"; if (PyType_Check(py_return_value)) { if ((PyTypeObject*)py_return_value == &PyFloat_Type) { - prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); } else if ((PyTypeObject*)py_return_value == &PyUnicode_Type) { - prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); } else if ((PyTypeObject*)py_return_value == &PyBool_Type) { - prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); } else if ((PyTypeObject*)py_return_value == &PyLong_Type) { - prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); } else if ((PyTypeObject*)py_return_value == &ue_PyFVectorType) { - UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); prop_struct->Struct = TBaseStructure::Get(); prop = prop_struct; } else if ((PyTypeObject*)py_return_value == &ue_PyFVector2DType) { - UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); prop_struct->Struct = TBaseStructure::Get(); prop = prop_struct; } else if ((PyTypeObject*)py_return_value == &ue_PyFRotatorType) { - UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); prop_struct->Struct = TBaseStructure::Get(); prop = prop_struct; } else if ((PyTypeObject*)py_return_value == &ue_PyFLinearColorType) { - UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); prop_struct->Struct = TBaseStructure::Get(); prop = prop_struct; } else if ((PyTypeObject*)py_return_value == &ue_PyFColorType) { - UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); prop_struct->Struct = TBaseStructure::Get(); prop = prop_struct; } else if ((PyTypeObject*)py_return_value == &ue_PyFTransformType) { - UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); prop_struct->Struct = TBaseStructure::Get(); prop = prop_struct; } #if ENGINE_MINOR_VERSION > 18 else if ((PyTypeObject*)py_return_value == &ue_PyFQuatType) { - UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); prop_struct->Struct = TBaseStructure::Get(); prop = prop_struct; } @@ -3470,7 +3472,7 @@ UFunction* unreal_engine_add_function(UClass* u_class, char* name, PyObject* py_ UE_LOG(LogPython, Error, TEXT("type for %s must be a UClass"), UTF8_TO_TCHAR(name)); return nullptr; } - UClassProperty* prop_class = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FClassProperty* prop_class = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); prop_class->SetMetaClass((UClass*)py_obj->ue_object); prop_class->PropertyClass = UClass::StaticClass(); prop = prop_class; @@ -3482,15 +3484,15 @@ UFunction* unreal_engine_add_function(UClass* u_class, char* name, PyObject* py_ if (py_obj->ue_object->IsA()) { UClass* p_u_class = (UClass*)py_obj->ue_object; - UObjectProperty* prop_base = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FObjectProperty* prop_base = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); prop_base->SetPropertyClass(p_u_class); prop = prop_base; } #if ENGINE_MINOR_VERSION > 17 else if (py_obj->ue_object->IsA()) { - UEnumProperty* prop_enum = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); - UNumericProperty* prop_underlying = NewObject(prop_enum, TEXT("UnderlyingType"), RF_Public); + FEnumProperty* prop_enum = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FNumericProperty* prop_underlying = NewObject(prop_enum, TEXT("UnderlyingType"), RF_Public); prop_enum->SetEnum((UEnum*)py_obj->ue_object); prop_enum->AddCppProperty(prop_underlying); prop = prop_enum; @@ -3498,7 +3500,7 @@ UFunction* unreal_engine_add_function(UClass* u_class, char* name, PyObject* py_ #endif else if (py_obj->ue_object->IsA()) { - UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + FStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); prop_struct->Struct = (UScriptStruct*)py_obj->ue_object; prop = prop_struct; } @@ -3528,33 +3530,33 @@ UFunction* unreal_engine_add_function(UClass* u_class, char* name, PyObject* py_ if (!function->IsSignatureCompatibleWith(parent_function)) { - TFieldIterator It(parent_function); + TFieldIterator It(parent_function); while (It) { - UProperty* p = *It; + FProperty* p = *It; if (p->PropertyFlags & CPF_Parm) { UE_LOG(LogPython, Warning, TEXT("Parent PROP: %s %d/%d %d %d %d %s %p"), *p->GetName(), (int)p->PropertyFlags, (int)UFunction::GetDefaultIgnoredSignatureCompatibilityFlags(), (int)(p->PropertyFlags & ~UFunction::GetDefaultIgnoredSignatureCompatibilityFlags()), p->GetSize(), p->GetOffset_ForGC(), *p->GetClass()->GetName(), p->GetClass()); - UClassProperty* ucp = Cast(p); + FClassProperty* ucp = Cast(p); if (ucp) { - UE_LOG(LogPython, Warning, TEXT("Parent UClassProperty = %p %s %p %s"), ucp->PropertyClass, *ucp->PropertyClass->GetName(), ucp->MetaClass, *ucp->MetaClass->GetName()); + UE_LOG(LogPython, Warning, TEXT("Parent FClassProperty = %p %s %p %s"), ucp->PropertyClass, *ucp->PropertyClass->GetName(), ucp->MetaClass, *ucp->MetaClass->GetName()); } } ++It; } - TFieldIterator It2(function); + TFieldIterator It2(function); while (It2) { - UProperty* p = *It2; + FProperty* p = *It2; if (p->PropertyFlags & CPF_Parm) { UE_LOG(LogPython, Warning, TEXT("Function PROP: %s %d/%d %d %d %d %s %p"), *p->GetName(), (int)p->PropertyFlags, (int)UFunction::GetDefaultIgnoredSignatureCompatibilityFlags(), (int)(p->PropertyFlags & ~UFunction::GetDefaultIgnoredSignatureCompatibilityFlags()), p->GetSize(), p->GetOffset_ForGC(), *p->GetClass()->GetName(), p->GetClass()); - UClassProperty* ucp = Cast(p); + FClassProperty* ucp = Cast(p); if (ucp) { - UE_LOG(LogPython, Warning, TEXT("Function UClassProperty = %p %s %p %s"), ucp->PropertyClass, *ucp->PropertyClass->GetName(), ucp->MetaClass, *ucp->MetaClass->GetName()); + UE_LOG(LogPython, Warning, TEXT("Function FClassProperty = %p %s %p %s"), ucp->PropertyClass, *ucp->PropertyClass->GetName(), ucp->MetaClass, *ucp->MetaClass->GetName()); } } ++It2; @@ -3568,10 +3570,10 @@ UFunction* unreal_engine_add_function(UClass* u_class, char* name, PyObject* py_ function->NumParms = 0; // allocate properties storage (ignore super) - TFieldIterator props(function, EFieldIteratorFlags::ExcludeSuper); + TFieldIterator props(function, EFieldIteratorFlags::ExcludeSuper); for (; props; ++props) { - UProperty* p = *props; + FProperty* p = *props; if (p->HasAnyPropertyFlags(CPF_Parm)) { function->NumParms++; diff --git a/Source/UnrealEnginePython/Private/UEPyModule.h b/Source/UnrealEnginePython/Private/UEPyModule.h index 9d865cb16..d79e64f64 100644 --- a/Source/UnrealEnginePython/Private/UEPyModule.h +++ b/Source/UnrealEnginePython/Private/UEPyModule.h @@ -5,6 +5,7 @@ #include "PythonSmartDelegate.h" #include "UEPyUScriptStruct.h" #include "PythonHouseKeeper.h" +#include "UObject/UEPyUPropertyBackwardsCompatibility.h" // common wrappersno #include "Wrappers/UEPyFVector.h" @@ -24,11 +25,10 @@ #endif #endif - UWorld *ue_get_uworld(ue_PyUObject *); AActor *ue_get_actor(ue_PyUObject *); -PyObject *ue_py_convert_property(UProperty *, uint8 *, int32); -bool ue_py_convert_pyobject(PyObject *, UProperty *, uint8 *, int32); +PyObject *ue_py_convert_property(FProperty *, uint8 *, int32); +bool ue_py_convert_pyobject(PyObject *, FProperty *, uint8 *, int32); ue_PyUObject *ue_is_pyuobject(PyObject *); void ue_bind_events_for_py_class_by_attribute(UObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UEPySubclassing.cpp b/Source/UnrealEnginePython/Private/UEPySubclassing.cpp index 548a83935..6b64886c2 100644 --- a/Source/UnrealEnginePython/Private/UEPySubclassing.cpp +++ b/Source/UnrealEnginePython/Private/UEPySubclassing.cpp @@ -1,6 +1,7 @@ #include "UEPyModule.h" #include "PythonClass.h" #include "UObject/UEPyObject.h" +#include "UObject/UEPyUPropertyBackwardsCompatibility.h" // hack for avoiding loops in class constructors (thanks to the Unreal.js project for the idea) UClass *ue_py_class_constructor_placeholder = nullptr; @@ -70,9 +71,9 @@ int unreal_engine_py_init(ue_PyUObject *self, PyObject *args, PyObject *kwds) bool prop_added = false; - if (UProperty *u_property = new_class->FindPropertyByName(FName(UTF8_TO_TCHAR(class_key)))) + if (FProperty *u_property = new_class->FindPropertyByName(FName(UTF8_TO_TCHAR(class_key)))) { - UE_LOG(LogPython, Warning, TEXT("Found UProperty %s"), UTF8_TO_TCHAR(class_key)); + UE_LOG(LogPython, Warning, TEXT("Found FProperty %s"), UTF8_TO_TCHAR(class_key)); PyDict_SetItem(py_additional_properties, key, value); prop_added = true; } @@ -83,7 +84,7 @@ int unreal_engine_py_init(ue_PyUObject *self, PyObject *args, PyObject *kwds) if (py_obj->ue_object->IsA()) { UClass *p_class = (UClass *)py_obj->ue_object; - if (p_class->IsChildOf()) + if (p_class->IsChildOf()) { if (!py_ue_add_property(self, Py_BuildValue("(Os)", value, class_key))) { @@ -94,7 +95,7 @@ int unreal_engine_py_init(ue_PyUObject *self, PyObject *args, PyObject *kwds) } else { - if (!py_ue_add_property(self, Py_BuildValue("(OsO)", (PyObject *)ue_get_python_uobject(UObjectProperty::StaticClass()), class_key, value))) + if (!py_ue_add_property(self, Py_BuildValue("(OsO)", (PyObject *)ue_get_python_uobject(FObjectProperty::StaticClass()), class_key, value))) { unreal_engine_py_log_error(); return -1; @@ -104,7 +105,7 @@ int unreal_engine_py_init(ue_PyUObject *self, PyObject *args, PyObject *kwds) } else if (py_obj->ue_object->IsA()) { - if (!py_ue_add_property(self, Py_BuildValue("(OsO)", (PyObject *)ue_get_python_uobject(UStructProperty::StaticClass()), class_key, value))) + if (!py_ue_add_property(self, Py_BuildValue("(OsO)", (PyObject *)ue_get_python_uobject(FStructProperty::StaticClass()), class_key, value))) { unreal_engine_py_log_error(); return -1; @@ -125,7 +126,7 @@ int unreal_engine_py_init(ue_PyUObject *self, PyObject *args, PyObject *kwds) if (py_obj->ue_object->IsA()) { UClass *p_class = (UClass *)py_obj->ue_object; - if (p_class->IsChildOf()) + if (p_class->IsChildOf()) { if (!py_ue_add_property(self, Py_BuildValue("(Os)", value, class_key))) { @@ -137,7 +138,7 @@ int unreal_engine_py_init(ue_PyUObject *self, PyObject *args, PyObject *kwds) else { - if (!py_ue_add_property(self, Py_BuildValue("([O]sO)", (PyObject *)ue_get_python_uobject(UObjectProperty::StaticClass()), class_key, first_item))) + if (!py_ue_add_property(self, Py_BuildValue("([O]sO)", (PyObject *)ue_get_python_uobject(FObjectProperty::StaticClass()), class_key, first_item))) { unreal_engine_py_log_error(); return -1; @@ -147,7 +148,7 @@ int unreal_engine_py_init(ue_PyUObject *self, PyObject *args, PyObject *kwds) } else if (py_obj->ue_object->IsA()) { - if (!py_ue_add_property(self, Py_BuildValue("([O]sO)", (PyObject *)ue_get_python_uobject(UStructProperty::StaticClass()), class_key, first_item))) + if (!py_ue_add_property(self, Py_BuildValue("([O]sO)", (PyObject *)ue_get_python_uobject(FStructProperty::StaticClass()), class_key, first_item))) { unreal_engine_py_log_error(); return -1; @@ -176,36 +177,36 @@ int unreal_engine_py_init(ue_PyUObject *self, PyObject *args, PyObject *kwds) if (py_obj->ue_object->IsA()) { UClass *p_class = (UClass *)py_obj->ue_object; - if (p_class->IsChildOf()) + if (p_class->IsChildOf()) { first_item = py_key; } else { - first_item = (PyObject *)ue_get_python_uobject(UObjectProperty::StaticClass()); + first_item = (PyObject *)ue_get_python_uobject(FObjectProperty::StaticClass()); } } else if (py_obj->ue_object->IsA()) { - first_item = (PyObject *)ue_get_python_uobject(UStructProperty::StaticClass()); + first_item = (PyObject *)ue_get_python_uobject(FStructProperty::StaticClass()); } ue_PyUObject *py_obj2 = (ue_PyUObject *)py_value; if (py_obj2->ue_object->IsA()) { UClass *p_class = (UClass *)py_obj2->ue_object; - if (p_class->IsChildOf()) + if (p_class->IsChildOf()) { second_item = py_value; } else { - second_item = (PyObject *)ue_get_python_uobject(UObjectProperty::StaticClass()); + second_item = (PyObject *)ue_get_python_uobject(FObjectProperty::StaticClass()); } } else if (py_obj2->ue_object->IsA()) { - second_item = (PyObject *)ue_get_python_uobject(UStructProperty::StaticClass()); + second_item = (PyObject *)ue_get_python_uobject(FStructProperty::StaticClass()); } if (!py_ue_add_property(self, Py_BuildValue("([OO]sOO)", first_item, second_item, class_key, py_key, py_value))) @@ -341,10 +342,10 @@ int unreal_engine_py_init(ue_PyUObject *self, PyObject *args, PyObject *kwds) PyObject *mc_value = PyDict_GetItem(found_additional_props, mc_key); const char *mc_name = UEPyUnicode_AsUTF8(mc_key); - UProperty *u_property = ObjectInitializer.GetObj()->GetClass()->FindPropertyByName(FName(UTF8_TO_TCHAR(mc_name))); + FProperty *u_property = ObjectInitializer.GetObj()->GetClass()->FindPropertyByName(FName(UTF8_TO_TCHAR(mc_name))); if (u_property) { - if (auto casted_prop = Cast(u_property)) + if (auto casted_prop = Cast(u_property)) { #if ENGINE_MINOR_VERSION >= 23 FMulticastScriptDelegate multiscript_delegate = *casted_prop->GetMulticastDelegate(ObjectInitializer.GetObj()); diff --git a/Source/UnrealEnginePython/Private/UEPyUScriptStruct.cpp b/Source/UnrealEnginePython/Private/UEPyUScriptStruct.cpp index 28df03059..a5cd11d79 100644 --- a/Source/UnrealEnginePython/Private/UEPyUScriptStruct.cpp +++ b/Source/UnrealEnginePython/Private/UEPyUScriptStruct.cpp @@ -12,7 +12,7 @@ static PyObject *py_ue_uscriptstruct_get_field(ue_PyUScriptStruct *self, PyObjec return nullptr; } - UProperty *u_property = self->u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(name))); + FProperty *u_property = self->u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(name))); if (!u_property) return PyErr_Format(PyExc_Exception, "unable to find property %s", name); @@ -27,7 +27,7 @@ static PyObject *py_ue_uscriptstruct_get_field_array_dim(ue_PyUScriptStruct *sel return nullptr; } - UProperty *u_property = self->u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(name))); + FProperty *u_property = self->u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(name))); if (!u_property) return PyErr_Format(PyExc_Exception, "unable to find property %s", name); @@ -44,7 +44,7 @@ static PyObject *py_ue_uscriptstruct_set_field(ue_PyUScriptStruct *self, PyObjec return nullptr; } - UProperty *u_property = self->u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(name))); + FProperty *u_property = self->u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(name))); if (!u_property) return PyErr_Format(PyExc_Exception, "unable to find property %s", name); @@ -62,9 +62,9 @@ static PyObject *py_ue_uscriptstruct_fields(ue_PyUScriptStruct *self, PyObject * { PyObject *ret = PyList_New(0); - for (TFieldIterator PropIt(self->u_struct); PropIt; ++PropIt) + for (TFieldIterator PropIt(self->u_struct); PropIt; ++PropIt) { - UProperty* property = *PropIt; + FProperty* property = *PropIt; PyObject *property_name = PyUnicode_FromString(TCHAR_TO_UTF8(*property->GetName())); PyList_Append(ret, property_name); Py_DECREF(property_name); @@ -92,7 +92,7 @@ PyObject *py_ue_uscriptstruct_as_dict(ue_PyUScriptStruct * self, PyObject * args static const FName DisplayNameKey(TEXT("DisplayName")); PyObject *py_struct_dict = PyDict_New(); - TFieldIterator SArgs(self->u_struct); + TFieldIterator SArgs(self->u_struct); for (; SArgs; ++SArgs) { PyObject *struct_value = ue_py_convert_property(*SArgs, self->u_struct_ptr, 0); @@ -143,10 +143,10 @@ static PyObject *ue_PyUScriptStruct_str(ue_PyUScriptStruct *self) TCHAR_TO_UTF8(*self->u_struct->GetName()), self->u_struct->GetStructureSize(), self->u_struct_ptr); } -static UProperty *get_field_from_name(UScriptStruct *u_struct, char *name) +static FProperty *get_field_from_name(UScriptStruct *u_struct, char *name) { FString attr = UTF8_TO_TCHAR(name); - UProperty *u_property = u_struct->FindPropertyByName(FName(*attr)); + FProperty *u_property = u_struct->FindPropertyByName(FName(*attr)); if (u_property) return u_property; @@ -154,9 +154,9 @@ static UProperty *get_field_from_name(UScriptStruct *u_struct, char *name) static const FName DisplayNameKey(TEXT("DisplayName")); // if the property is not found, attempt to search for DisplayName - for (TFieldIterator prop(u_struct); prop; ++prop) + for (TFieldIterator prop(u_struct); prop; ++prop) { - UProperty *property = *prop; + FProperty *property = *prop; if (property->HasMetaData(DisplayNameKey)) { FString display_name = property->GetMetaData(DisplayNameKey); @@ -171,7 +171,7 @@ static UProperty *get_field_from_name(UScriptStruct *u_struct, char *name) return nullptr; } -UProperty *ue_struct_get_field_from_name(UScriptStruct *u_struct, char *name) +FProperty *ue_struct_get_field_from_name(UScriptStruct *u_struct, char *name) { return get_field_from_name(u_struct, name); } @@ -185,7 +185,7 @@ static PyObject *ue_PyUScriptStruct_getattro(ue_PyUScriptStruct *self, PyObject { const char *attr = UEPyUnicode_AsUTF8(attr_name); // first check for property - UProperty *u_property = get_field_from_name(self->u_struct, (char *)attr); + FProperty *u_property = get_field_from_name(self->u_struct, (char *)attr); if (u_property) { // swallow previous exception @@ -199,19 +199,19 @@ static PyObject *ue_PyUScriptStruct_getattro(ue_PyUScriptStruct *self, PyObject static int ue_PyUScriptStruct_setattro(ue_PyUScriptStruct *self, PyObject *attr_name, PyObject *value) { - // first of all check for UProperty + // first of all check for FProperty if (PyUnicodeOrString_Check(attr_name)) { const char *attr = UEPyUnicode_AsUTF8(attr_name); // first check for property - UProperty *u_property = get_field_from_name(self->u_struct, (char *)attr); + FProperty *u_property = get_field_from_name(self->u_struct, (char *)attr); if (u_property) { if (ue_py_convert_pyobject(value, u_property, self->u_struct_ptr, 0)) { return 0; } - PyErr_SetString(PyExc_ValueError, "invalid value for UProperty"); + PyErr_SetString(PyExc_ValueError, "invalid value for FProperty"); return -1; } } diff --git a/Source/UnrealEnginePython/Private/UEPyUScriptStruct.h b/Source/UnrealEnginePython/Private/UEPyUScriptStruct.h index 1078cf686..b06ca03ea 100644 --- a/Source/UnrealEnginePython/Private/UEPyUScriptStruct.h +++ b/Source/UnrealEnginePython/Private/UEPyUScriptStruct.h @@ -1,6 +1,7 @@ #pragma once #include "UEPyModule.h" +#include "UObject/UEPyUPropertyBackwardsCompatibility.h" typedef struct { @@ -17,6 +18,6 @@ PyObject *py_ue_new_owned_uscriptstruct(UScriptStruct *, uint8 *); PyObject *py_ue_new_owned_uscriptstruct_zero_copy(UScriptStruct *, uint8 *); ue_PyUScriptStruct *py_ue_is_uscriptstruct(PyObject *); -UProperty *ue_struct_get_field_from_name(UScriptStruct *, char *); +FProperty *ue_struct_get_field_from_name(UScriptStruct *, char *); void ue_python_init_uscriptstruct(PyObject *); \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyActor.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyActor.cpp index e319bcc94..cdde15840 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyActor.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyActor.cpp @@ -649,7 +649,7 @@ PyObject *py_ue_actor_create_default_subobject(ue_PyUObject * self, PyObject * a UObject *ret_obj = nullptr; Py_BEGIN_ALLOW_THREADS; - ret_obj = actor->CreateDefaultSubobject(FName(UTF8_TO_TCHAR(name)), UObject::StaticClass(), u_class, false, false, true); + ret_obj = actor->CreateDefaultSubobject(FName(UTF8_TO_TCHAR(name)), UObject::StaticClass(), u_class, false, true); Py_END_ALLOW_THREADS; if (!ret_obj) diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyCapture.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyCapture.cpp index 26f2194c4..82aa034f9 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyCapture.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyCapture.cpp @@ -118,8 +118,16 @@ struct FInEditorMultiCapture : TSharedFromThis UGameViewportClient::OnViewportCreated().AddRaw(this, &FInEditorMultiCapture::OnStart); FEditorDelegates::EndPIE.AddRaw(this, &FInEditorMultiCapture::OnEndPIE); - FAudioDevice* AudioDevice = GEngine->GetMainAudioDevice(); - if (AudioDevice != nullptr) + //Use auto because UE4.25 changed type, but type has same interface + auto AudioDevice = GEngine->GetMainAudioDevice(); + +#if ENGINE_MINOR_VERSION >= 25 + bool bIsDeviceValid = AudioDevice.IsValid(); +#else + bool bIsDeviceValid = (AudioDevice != nullptr); +#endif + + if (bIsDeviceValid) { TransientMasterVolume = AudioDevice->GetTransientMasterVolume(); AudioDevice->SetTransientMasterVolume(0.0f); @@ -278,8 +286,16 @@ struct FInEditorMultiCapture : TSharedFromThis FObjectReader(GetMutableDefault(), BackedUpPlaySettings); - FAudioDevice* AudioDevice = GEngine->GetMainAudioDevice(); - if (AudioDevice != nullptr) + //Use auto because UE4.25 changed type, but type has same interface + auto AudioDevice = GEngine->GetMainAudioDevice(); + +#if ENGINE_MINOR_VERSION >= 25 + bool bIsDeviceValid = AudioDevice.IsValid(); +#else + bool bIsDeviceValid = (AudioDevice != nullptr); +#endif + + if (bIsDeviceValid) { AudioDevice->SetTransientMasterVolume(TransientMasterVolume); } diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyMaterial.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyMaterial.cpp index c958094f6..efe80cc65 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyMaterial.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyMaterial.cpp @@ -511,7 +511,7 @@ PyObject *py_ue_static_mesh_set_collision_for_lod(ue_PyUObject *self, PyObject * FMeshSectionInfo info = mesh->SectionInfoMap.Get(lod_index, material_index); #endif info.bEnableCollision = enabled; - mesh->SectionInfoMap.Set(lod_index, material_index, info); + mesh->GetSectionInfoMap().Set(lod_index, material_index, info); mesh->MarkPackageDirty(); @@ -545,9 +545,9 @@ PyObject *py_ue_static_mesh_set_shadow_for_lod(ue_PyUObject *self, PyObject * ar enabled = true; } - FMeshSectionInfo info = mesh->SectionInfoMap.Get(lod_index, material_index); + FMeshSectionInfo info = mesh->GetSectionInfoMap().Get(lod_index, material_index); info.bCastShadow = enabled; - mesh->SectionInfoMap.Set(lod_index, material_index, info); + mesh->GetSectionInfoMap().Set(lod_index, material_index, info); mesh->MarkPackageDirty(); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyObject.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyObject.cpp index 3b2983b99..5fcded8ec 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyObject.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyObject.cpp @@ -186,11 +186,11 @@ PyObject *py_ue_get_property_struct(ue_PyUObject * self, PyObject * args) u_struct = (UStruct *)self->ue_object->GetClass(); } - UProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); + FProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); if (!u_property) return PyErr_Format(PyExc_Exception, "unable to find property %s", property_name); - UStructProperty *prop = Cast(u_property); + FStructProperty *prop = Cast(u_property); if (!prop) return PyErr_Format(PyExc_Exception, "object is not a StructProperty"); return py_ue_new_uscriptstruct(prop->Struct, prop->ContainerPtrToValuePtr(self->ue_object)); @@ -357,7 +357,7 @@ PyObject *py_ue_post_edit_change_property(ue_PyUObject *self, PyObject * args) u_struct = (UStruct *)self->ue_object->GetClass(); } - UProperty *prop = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(prop_name))); + FProperty *prop = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(prop_name))); if (!prop) return PyErr_Format(PyExc_Exception, "unable to find property %s", prop_name); @@ -386,7 +386,7 @@ PyObject *py_ue_pre_edit_change(ue_PyUObject *self, PyObject * args) { ue_py_check(self); - UProperty *prop = nullptr; + FProperty *prop = nullptr; char *prop_name = nullptr; if (!PyArg_ParseTuple(args, "|s:pre_edit_change", &prop_name)) @@ -801,7 +801,7 @@ PyObject *py_ue_set_property(ue_PyUObject *self, PyObject * args) u_struct = (UStruct *)self->ue_object->GetClass(); } - UProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); + FProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); if (!u_property) return PyErr_Format(PyExc_Exception, "unable to find property %s", property_name); @@ -838,7 +838,7 @@ PyObject *py_ue_set_property_flags(ue_PyUObject *self, PyObject * args) u_struct = (UStruct *)self->ue_object->GetClass(); } - UProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); + FProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); if (!u_property) return PyErr_Format(PyExc_Exception, "unable to find property %s", property_name); @@ -873,7 +873,7 @@ PyObject *py_ue_add_property_flags(ue_PyUObject *self, PyObject * args) u_struct = (UStruct *)self->ue_object->GetClass(); } - UProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); + FProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); if (!u_property) return PyErr_Format(PyExc_Exception, "unable to find property %s", property_name); @@ -908,7 +908,7 @@ PyObject *py_ue_get_property_flags(ue_PyUObject *self, PyObject * args) u_struct = (UStruct *)self->ue_object->GetClass(); } - UProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); + FProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); if (!u_property) return PyErr_Format(PyExc_Exception, "unable to find property %s", property_name); @@ -994,9 +994,9 @@ PyObject *py_ue_properties(ue_PyUObject *self, PyObject * args) PyObject *ret = PyList_New(0); - for (TFieldIterator PropIt(u_struct); PropIt; ++PropIt) + for (TFieldIterator PropIt(u_struct); PropIt; ++PropIt) { - UProperty* property = *PropIt; + FProperty* property = *PropIt; PyObject *property_name = PyUnicode_FromString(TCHAR_TO_UTF8(*property->GetName())); PyList_Append(ret, property_name); Py_DECREF(property_name); @@ -1078,11 +1078,11 @@ PyObject *py_ue_broadcast(ue_PyUObject *self, PyObject *args) const char *property_name = UEPyUnicode_AsUTF8(py_property_name); - UProperty *u_property = self->ue_object->GetClass()->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); + FProperty *u_property = self->ue_object->GetClass()->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); if (!u_property) return PyErr_Format(PyExc_Exception, "unable to find event property %s", property_name); - if (auto casted_prop = Cast(u_property)) + if (auto casted_prop = Cast(u_property)) { #if ENGINE_MINOR_VERSION >= 23 FMulticastScriptDelegate multiscript_delegate = *casted_prop->GetMulticastDelegate(self->ue_object); @@ -1095,9 +1095,9 @@ PyObject *py_ue_broadcast(ue_PyUObject *self, PyObject *args) uint32 argn = 1; // initialize args - for (TFieldIterator IArgs(casted_prop->SignatureFunction); IArgs && IArgs->HasAnyPropertyFlags(CPF_Parm); ++IArgs) + for (TFieldIterator IArgs(casted_prop->SignatureFunction); IArgs && IArgs->HasAnyPropertyFlags(CPF_Parm); ++IArgs) { - UProperty *prop = *IArgs; + FProperty *prop = *IArgs; if (!prop->HasAnyPropertyFlags(CPF_ZeroConstructor)) { prop->InitializeValue_InContainer(parms); @@ -1145,7 +1145,7 @@ PyObject *py_ue_broadcast(ue_PyUObject *self, PyObject *args) } else { - return PyErr_Format(PyExc_Exception, "property is not a UMulticastDelegateProperty"); + return PyErr_Format(PyExc_Exception, "property is not a FMulticastDelegateProperty"); } Py_RETURN_NONE; @@ -1174,7 +1174,7 @@ PyObject *py_ue_get_property(ue_PyUObject *self, PyObject * args) u_struct = (UStruct *)self->ue_object->GetClass(); } - UProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); + FProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); if (!u_property) return PyErr_Format(PyExc_Exception, "unable to find property %s", property_name); @@ -1203,7 +1203,7 @@ PyObject *py_ue_get_property_array_dim(ue_PyUObject *self, PyObject * args) u_struct = (UStruct *)self->ue_object->GetClass(); } - UProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); + FProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); if (!u_property) return PyErr_Format(PyExc_Exception, "unable to find property %s", property_name); @@ -1270,13 +1270,13 @@ PyObject *py_ue_render_thumbnail(ue_PyUObject *self, PyObject * args) } #endif -PyObject *py_ue_get_uproperty(ue_PyUObject *self, PyObject * args) +PyObject *py_ue_get_FProperty(ue_PyUObject *self, PyObject * args) { ue_py_check(self); char *property_name; - if (!PyArg_ParseTuple(args, "s:get_uproperty", &property_name)) + if (!PyArg_ParseTuple(args, "s:get_FProperty", &property_name)) { return NULL; } @@ -1292,7 +1292,7 @@ PyObject *py_ue_get_uproperty(ue_PyUObject *self, PyObject * args) u_struct = (UStruct *)self->ue_object->GetClass(); } - UProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); + FProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); if (!u_property) return PyErr_Format(PyExc_Exception, "unable to find property %s", property_name); @@ -1305,11 +1305,11 @@ PyObject *py_ue_get_inner(ue_PyUObject *self, PyObject * args) ue_py_check(self); - UArrayProperty *u_property = ue_py_check_type(self); + FArrayProperty *u_property = ue_py_check_type(self); if (!u_property) - return PyErr_Format(PyExc_Exception, "object is not a UArrayProperty"); + return PyErr_Format(PyExc_Exception, "object is not a FArrayProperty"); - UProperty* inner = u_property->Inner; + FProperty* inner = u_property->Inner; if (!inner) Py_RETURN_NONE; @@ -1321,11 +1321,11 @@ PyObject *py_ue_get_key_prop(ue_PyUObject *self, PyObject * args) ue_py_check(self); - UMapProperty *u_property = ue_py_check_type(self); + FMapProperty *u_property = ue_py_check_type(self); if (!u_property) - return PyErr_Format(PyExc_Exception, "object is not a UMapProperty"); + return PyErr_Format(PyExc_Exception, "object is not a FMapProperty"); - UProperty* key = u_property->KeyProp; + FProperty* key = u_property->KeyProp; if (!key) Py_RETURN_NONE; @@ -1337,11 +1337,11 @@ PyObject *py_ue_get_value_prop(ue_PyUObject *self, PyObject * args) ue_py_check(self); - UMapProperty *u_property = ue_py_check_type(self); + FMapProperty *u_property = ue_py_check_type(self); if (!u_property) - return PyErr_Format(PyExc_Exception, "object is not a UMapProperty"); + return PyErr_Format(PyExc_Exception, "object is not a FMapProperty"); - UProperty* value = u_property->ValueProp; + FProperty* value = u_property->ValueProp; if (!value) Py_RETURN_NONE; @@ -1370,7 +1370,7 @@ PyObject *py_ue_has_property(ue_PyUObject *self, PyObject * args) u_struct = (UStruct *)self->ue_object->GetClass(); } - UProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); + FProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); if (!u_property) Py_RETURN_FALSE; Py_RETURN_TRUE; @@ -1398,7 +1398,7 @@ PyObject *py_ue_get_property_class(ue_PyUObject *self, PyObject * args) u_struct = (UStruct *)self->ue_object->GetClass(); } - UProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); + FProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); if (!u_property) return PyErr_Format(PyExc_Exception, "unable to find property %s", property_name); @@ -1551,13 +1551,13 @@ PyObject *py_ue_delegate_bind_ufunction(ue_PyUObject * self, PyObject * args) if (!PyArg_ParseTuple(args, "sOs:delegate_bind_ufunction", &delegate_name, &py_obj, &fname)) return nullptr; - UProperty *u_property = self->ue_object->GetClass()->FindPropertyByName(FName(delegate_name)); + FProperty *u_property = self->ue_object->GetClass()->FindPropertyByName(FName(delegate_name)); if (!u_property) return PyErr_Format(PyExc_Exception, "unable to find property %s", delegate_name); - UDelegateProperty *Prop = Cast(u_property); + FDelegateProperty *Prop = Cast(u_property); if (!Prop) - return PyErr_Format(PyExc_Exception, "property is not a UDelegateProperty"); + return PyErr_Format(PyExc_Exception, "property is not a FDelegateProperty"); UObject *Object = ue_py_check_type(py_obj); if (!Object) @@ -1626,9 +1626,9 @@ PyObject *py_ue_add_property(ue_PyUObject * self, PyObject * args) UObject *scope = nullptr; - UProperty *u_property = nullptr; + FProperty *u_property = nullptr; UClass *u_class = nullptr; - UProperty *u_property2 = nullptr; + FProperty *u_property2 = nullptr; UClass *u_class2 = nullptr; UClass *u_prop_class = nullptr; @@ -1690,9 +1690,9 @@ PyObject *py_ue_add_property(ue_PyUObject * self, PyObject * args) return PyErr_Format(PyExc_Exception, "uobject is not a UClass"); } u_class = (UClass *)py_obj->ue_object; - if (!u_class->IsChildOf()) - return PyErr_Format(PyExc_Exception, "uobject is not a UProperty"); - if (u_class == UArrayProperty::StaticClass()) + if (!u_class->IsChildOf()) + return PyErr_Format(PyExc_Exception, "uobject is not a FProperty"); + if (u_class == FArrayProperty::StaticClass()) return PyErr_Format(PyExc_Exception, "please use a single-item list of property for arrays"); scope = self->ue_object; } @@ -1709,13 +1709,13 @@ PyObject *py_ue_add_property(ue_PyUObject * self, PyObject * args) return PyErr_Format(PyExc_Exception, "uobject is not a UClass"); } u_class = (UClass *)py_obj->ue_object; - if (!u_class->IsChildOf()) - return PyErr_Format(PyExc_Exception, "uobject is not a UProperty"); - if (u_class == UArrayProperty::StaticClass()) + if (!u_class->IsChildOf()) + return PyErr_Format(PyExc_Exception, "uobject is not a FProperty"); + if (u_class == FArrayProperty::StaticClass()) return PyErr_Format(PyExc_Exception, "please use a single-item list of property for arrays"); - UArrayProperty *u_array = NewObject(self->ue_object, UTF8_TO_TCHAR(name), o_flags); + FArrayProperty *u_array = NewObject(self->ue_object, UTF8_TO_TCHAR(name), o_flags); if (!u_array) - return PyErr_Format(PyExc_Exception, "unable to allocate new UProperty"); + return PyErr_Format(PyExc_Exception, "unable to allocate new FProperty"); scope = u_array; is_array = true; } @@ -1735,9 +1735,9 @@ PyObject *py_ue_add_property(ue_PyUObject * self, PyObject * args) return PyErr_Format(PyExc_Exception, "uobject is not a UClass"); } u_class = (UClass *)py_obj->ue_object; - if (!u_class->IsChildOf()) - return PyErr_Format(PyExc_Exception, "uobject is not a UProperty"); - if (u_class == UArrayProperty::StaticClass()) + if (!u_class->IsChildOf()) + return PyErr_Format(PyExc_Exception, "uobject is not a FProperty"); + if (u_class == FArrayProperty::StaticClass()) return PyErr_Format(PyExc_Exception, "please use a two-items list of properties for maps"); // VALUE @@ -1747,15 +1747,15 @@ PyObject *py_ue_add_property(ue_PyUObject * self, PyObject * args) return PyErr_Format(PyExc_Exception, "uobject is not a UClass"); } u_class2 = (UClass *)py_obj2->ue_object; - if (!u_class2->IsChildOf()) - return PyErr_Format(PyExc_Exception, "uobject is not a UProperty"); - if (u_class2 == UArrayProperty::StaticClass()) + if (!u_class2->IsChildOf()) + return PyErr_Format(PyExc_Exception, "uobject is not a FProperty"); + if (u_class2 == FArrayProperty::StaticClass()) return PyErr_Format(PyExc_Exception, "please use a two-items list of properties for maps"); - UMapProperty *u_map = NewObject(self->ue_object, UTF8_TO_TCHAR(name), o_flags); + FMapProperty *u_map = NewObject(self->ue_object, UTF8_TO_TCHAR(name), o_flags); if (!u_map) - return PyErr_Format(PyExc_Exception, "unable to allocate new UProperty"); + return PyErr_Format(PyExc_Exception, "unable to allocate new FProperty"); scope = u_map; is_map = true; } @@ -1771,12 +1771,12 @@ PyObject *py_ue_add_property(ue_PyUObject * self, PyObject * args) return PyErr_Format(PyExc_Exception, "argument is not a UObject or a single item list"); } - u_property = NewObject(scope, u_class, UTF8_TO_TCHAR(name), o_flags); + u_property = NewObject(scope, u_class, UTF8_TO_TCHAR(name), o_flags); if (!u_property) { if (is_array || is_map) scope->MarkPendingKill(); - return PyErr_Format(PyExc_Exception, "unable to allocate new UProperty"); + return PyErr_Format(PyExc_Exception, "unable to allocate new FProperty"); } // one day we may want to support transient properties... @@ -1797,24 +1797,24 @@ PyObject *py_ue_add_property(ue_PyUObject * self, PyObject * args) if (is_array) { - UArrayProperty *u_array = (UArrayProperty *)scope; + FArrayProperty *u_array = (FArrayProperty *)scope; u_array->AddCppProperty(u_property); #if ENGINE_MINOR_VERSION < 20 u_property->SetPropertyFlags(flags); #else u_property->SetPropertyFlags((EPropertyFlags)flags); #endif - if (u_property->GetClass() == UObjectProperty::StaticClass()) + if (u_property->GetClass() == FObjectProperty::StaticClass()) { - UObjectProperty *obj_prop = (UObjectProperty *)u_property; + FObjectProperty *obj_prop = (FObjectProperty *)u_property; if (u_prop_class) { obj_prop->SetPropertyClass(u_prop_class); } } - if (u_property->GetClass() == UStructProperty::StaticClass()) + if (u_property->GetClass() == FStructProperty::StaticClass()) { - UStructProperty *obj_prop = (UStructProperty *)u_property; + FStructProperty *obj_prop = (FStructProperty *)u_property; if (u_script_struct) { obj_prop->Struct = u_script_struct; @@ -1826,14 +1826,14 @@ PyObject *py_ue_add_property(ue_PyUObject * self, PyObject * args) #if ENGINE_MINOR_VERSION >= 15 if (is_map) { - u_property2 = NewObject(scope, u_class2, NAME_None, o_flags); + u_property2 = NewObject(scope, u_class2, NAME_None, o_flags); if (!u_property2) { if (is_array || is_map) scope->MarkPendingKill(); - return PyErr_Format(PyExc_Exception, "unable to allocate new UProperty"); + return PyErr_Format(PyExc_Exception, "unable to allocate new FProperty"); } - UMapProperty *u_map = (UMapProperty *)scope; + FMapProperty *u_map = (FMapProperty *)scope; #if ENGINE_MINOR_VERSION < 20 u_property->SetPropertyFlags(flags); @@ -1843,34 +1843,34 @@ PyObject *py_ue_add_property(ue_PyUObject * self, PyObject * args) u_property2->SetPropertyFlags((EPropertyFlags)flags); #endif - if (u_property->GetClass() == UObjectProperty::StaticClass()) + if (u_property->GetClass() == FObjectProperty::StaticClass()) { - UObjectProperty *obj_prop = (UObjectProperty *)u_property; + FObjectProperty *obj_prop = (FObjectProperty *)u_property; if (u_prop_class) { obj_prop->SetPropertyClass(u_prop_class); } } - if (u_property->GetClass() == UStructProperty::StaticClass()) + if (u_property->GetClass() == FStructProperty::StaticClass()) { - UStructProperty *obj_prop = (UStructProperty *)u_property; + FStructProperty *obj_prop = (FStructProperty *)u_property; if (u_script_struct) { obj_prop->Struct = u_script_struct; } } - if (u_property2->GetClass() == UObjectProperty::StaticClass()) + if (u_property2->GetClass() == FObjectProperty::StaticClass()) { - UObjectProperty *obj_prop = (UObjectProperty *)u_property2; + FObjectProperty *obj_prop = (FObjectProperty *)u_property2; if (u_prop_class2) { obj_prop->SetPropertyClass(u_prop_class2); } } - if (u_property2->GetClass() == UStructProperty::StaticClass()) + if (u_property2->GetClass() == FStructProperty::StaticClass()) { - UStructProperty *obj_prop = (UStructProperty *)u_property2; + FStructProperty *obj_prop = (FStructProperty *)u_property2; if (u_script_struct2) { obj_prop->Struct = u_script_struct2; @@ -1884,30 +1884,30 @@ PyObject *py_ue_add_property(ue_PyUObject * self, PyObject * args) } #endif - if (u_class == UMulticastDelegateProperty::StaticClass()) + if (u_class == FMulticastDelegateProperty::StaticClass()) { - UMulticastDelegateProperty *mcp = (UMulticastDelegateProperty *)u_property; + FMulticastDelegateProperty *mcp = (FMulticastDelegateProperty *)u_property; mcp->SignatureFunction = NewObject(self->ue_object, NAME_None, RF_Public | RF_Transient | RF_MarkAsNative); mcp->SignatureFunction->FunctionFlags = FUNC_MulticastDelegate | FUNC_BlueprintCallable | FUNC_Native; flags |= CPF_BlueprintAssignable | CPF_BlueprintCallable; flags &= ~CPF_Edit; } - else if (u_class == UDelegateProperty::StaticClass()) + else if (u_class == FDelegateProperty::StaticClass()) { - UDelegateProperty *udp = (UDelegateProperty *)u_property; + FDelegateProperty *udp = (FDelegateProperty *)u_property; udp->SignatureFunction = NewObject(self->ue_object, NAME_None, RF_Public | RF_Transient | RF_MarkAsNative); udp->SignatureFunction->FunctionFlags = FUNC_MulticastDelegate | FUNC_BlueprintCallable | FUNC_Native; flags |= CPF_BlueprintAssignable | CPF_BlueprintCallable; flags &= ~CPF_Edit; } - else if (u_class == UObjectProperty::StaticClass()) + else if (u_class == FObjectProperty::StaticClass()) { // ensure it is not an arry as we have already managed it ! if (!is_array && !is_map) { - UObjectProperty *obj_prop = (UObjectProperty *)u_property; + FObjectProperty *obj_prop = (FObjectProperty *)u_property; if (u_prop_class) { obj_prop->SetPropertyClass(u_prop_class); @@ -1915,12 +1915,12 @@ PyObject *py_ue_add_property(ue_PyUObject * self, PyObject * args) } } - else if (u_class == UStructProperty::StaticClass()) + else if (u_class == FStructProperty::StaticClass()) { // ensure it is not an arry as we have already managed it ! if (!is_array && !is_map) { - UStructProperty *obj_prop = (UStructProperty *)u_property; + FStructProperty *obj_prop = (FStructProperty *)u_property; if (u_script_struct) { obj_prop->Struct = u_script_struct; @@ -1977,7 +1977,7 @@ PyObject *py_ue_as_dict(ue_PyUObject * self, PyObject * args) } PyObject *py_struct_dict = PyDict_New(); - TFieldIterator SArgs(u_struct); + TFieldIterator SArgs(u_struct); for (; SArgs; ++SArgs) { PyObject *struct_value = ue_py_convert_property(*SArgs, (uint8 *)u_object, 0); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPySequencer.cpp b/Source/UnrealEnginePython/Private/UObject/UEPySequencer.cpp index 8858a7936..65419111e 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPySequencer.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPySequencer.cpp @@ -8,6 +8,7 @@ #include "Runtime/LevelSequence/Public/LevelSequence.h" #if WITH_EDITOR +#include "Subsystems/AssetEditorSubsystem.h" #include "Editor/Sequencer/Public/ISequencer.h" #include "Editor/Sequencer/Public/ISequencerModule.h" #include "Editor/UnrealEd/Public/Toolkits/AssetEditorManager.h" @@ -209,9 +210,9 @@ static bool ImportFBXTransform(FString NodeName, UMovieScene3DTransformSection* #endif #if WITH_EDITOR + PyObject *py_ue_sequencer_changed(ue_PyUObject *self, PyObject * args) { - ue_py_check(self); PyObject *py_bool = nullptr; @@ -227,13 +228,17 @@ PyObject *py_ue_sequencer_changed(ue_PyUObject *self, PyObject * args) ULevelSequence *seq = (ULevelSequence *)self->ue_object; + //UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem(); + if (py_bool && PyObject_IsTrue(py_bool)) { // try to open the editor for the asset - FAssetEditorManager::Get().OpenEditorForAsset(seq); + // FAssetEditorManager::Get().OpenEditorForAsset(seq); + GEditor->GetEditorSubsystem()->OpenEditorForAsset(seq); } - IAssetEditorInstance *editor = FAssetEditorManager::Get().FindEditorForAsset(seq, true); + // IAssetEditorInstance* editor = FAssetEditorManager::Get().FindEditorForAsset(seq, true); + IAssetEditorInstance* editor = GEditor->GetEditorSubsystem()->FindEditorForAsset(seq, true); if (editor) { FLevelSequenceEditorToolkit *toolkit = (FLevelSequenceEditorToolkit *)editor; @@ -464,9 +469,11 @@ PyObject *py_ue_sequencer_add_actor(ue_PyUObject *self, PyObject * args) actors.Add((AActor *)py_ue_obj->ue_object); // try to open the editor for the asset - FAssetEditorManager::Get().OpenEditorForAsset(seq); - IAssetEditorInstance *editor = FAssetEditorManager::Get().FindEditorForAsset(seq, true); + //UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem(); + GEditor->GetEditorSubsystem()->OpenEditorForAsset(seq); + + IAssetEditorInstance *editor = GEditor->GetEditorSubsystem()->FindEditorForAsset(seq, true); if (editor) { FLevelSequenceEditorToolkit *toolkit = (FLevelSequenceEditorToolkit *)editor; @@ -519,9 +526,11 @@ PyObject *py_ue_sequencer_add_actor_component(ue_PyUObject *self, PyObject * arg UActorComponent* actorComponent = (UActorComponent *)py_ue_obj->ue_object; // try to open the editor for the asset - FAssetEditorManager::Get().OpenEditorForAsset(seq); - IAssetEditorInstance *editor = FAssetEditorManager::Get().FindEditorForAsset(seq, true); + UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem(); + AssetEditorSubsystem->OpenEditorForAsset(seq); + + IAssetEditorInstance *editor = AssetEditorSubsystem->FindEditorForAsset(seq, true); FGuid new_guid; if (editor) { @@ -568,9 +577,11 @@ PyObject *py_ue_sequencer_make_new_spawnable(ue_PyUObject *self, PyObject * args ULevelSequence *seq = (ULevelSequence *)self->ue_object; // try to open the editor for the asset - FAssetEditorManager::Get().OpenEditorForAsset(seq); - IAssetEditorInstance *editor = FAssetEditorManager::Get().FindEditorForAsset(seq, true); + //UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem(); + GEditor->GetEditorSubsystem()->OpenEditorForAsset(seq); + + IAssetEditorInstance *editor = GEditor->GetEditorSubsystem()->FindEditorForAsset(seq, true); if (!editor) { return PyErr_Format(PyExc_Exception, "unable to access sequencer"); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.cpp index eaf1a1cf8..43b4cf434 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.cpp @@ -124,10 +124,10 @@ PyObject *py_ue_static_mesh_get_raw_mesh(ue_PyUObject *self, PyObject * args) FRawMesh raw_mesh; - if (lod_index < 0 || lod_index >= mesh->SourceModels.Num()) + if (lod_index < 0 || lod_index >= mesh->GetSourceModels().Num()) return PyErr_Format(PyExc_Exception, "invalid LOD index"); - mesh->SourceModels[lod_index].RawMeshBulkData->LoadRawMesh(raw_mesh); + mesh->GetSourceModel(lod_index).RawMeshBulkData->LoadRawMesh(raw_mesh); return py_ue_new_fraw_mesh(raw_mesh); } diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyTransform.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyTransform.cpp index 34ae1eade..70793e038 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyTransform.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyTransform.cpp @@ -466,7 +466,7 @@ PyObject *py_ue_get_relative_location(ue_PyUObject *self, PyObject * args) ue_py_check(self); if (self->ue_object->IsA()) { - FVector vec3 = ((USceneComponent *)self->ue_object)->RelativeLocation; + FVector vec3 = ((USceneComponent *)self->ue_object)->GetRelativeLocation(); return py_ue_new_fvector(vec3); } return PyErr_Format(PyExc_Exception, "uobject is not a USceneComponent"); @@ -477,7 +477,7 @@ PyObject *py_ue_get_relative_rotation(ue_PyUObject *self, PyObject * args) ue_py_check(self); if (self->ue_object->IsA()) { - FRotator rot = ((USceneComponent *)self->ue_object)->RelativeRotation; + FRotator rot = ((USceneComponent *)self->ue_object)->GetRelativeRotation(); return py_ue_new_frotator(rot); } return PyErr_Format(PyExc_Exception, "uobject is not a USceneComponent"); @@ -488,7 +488,7 @@ PyObject *py_ue_get_relative_scale(ue_PyUObject *self, PyObject * args) ue_py_check(self); if (self->ue_object->IsA()) { - FVector vec3 = ((USceneComponent *)self->ue_object)->RelativeScale3D; + FVector vec3 = ((USceneComponent *)self->ue_object)->GetRelativeScale3D(); return py_ue_new_fvector(vec3); } return PyErr_Format(PyExc_Exception, "uobject is not a USceneComponent"); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyUPropertyBackwardsCompatibility.h b/Source/UnrealEnginePython/Private/UObject/UEPyUPropertyBackwardsCompatibility.h new file mode 100644 index 000000000..2ebc24140 --- /dev/null +++ b/Source/UnrealEnginePython/Private/UObject/UEPyUPropertyBackwardsCompatibility.h @@ -0,0 +1,37 @@ +#if ENGINE_MINOR_VERSION < 25 +//UE4.25 refactored UProperties to no longer be UObjects +//For compatibility with older engines, added a typedef here rather than polluting code throughout +//Decision to put these definitions for older engine compatibility rather than newer engine compatiblity +// was made with the view that FProperty is the current and future, and therefore should be the standard in code +typedef UProperty FProperty; +typedef UObjectProperty FObjectProperty; +typedef UStructProperty FStructProperty; +typedef UMulticastDelegateProperty FMulticastDelegateProperty; +typedef UArrayProperty FArrayProperty; +typedef UMapProperty FMapProperty; +typedef UDelegateProperty FDelegateProperty; +typedef UObjectProperty FObjectProperty; +typedef UClassProperty FClassProperty; +typedef UBoolProperty FBoolProperty; +typedef UIntProperty FIntProperty; + +typedef UUInt32Property FUInt32Property; +typedef UInt64Property FInt64Property; +typedef UUInt64Property FUInt64Property; +typedef UFloatProperty FFloatProperty; +typedef UByteProperty FByteProperty; +typedef UEnumProperty FEnumProperty; +typedef UStrProperty FStrProperty; +typedef UTextProperty FTextProperty; +typedef UNameProperty FNameProperty; +typedef UObjectPropertyBase FObjectPropertyBase; +typedef UClassProperty FClassProperty; +typedef UStructProperty FStructProperty; +typedef UWeakObjectProperty FWeakObjectProperty; + +typedef USoftObjectProperty FSoftObjectProperty; +typedef USoftClassProperty FSoftClassProperty; + +typedef UNumericProperty FNumericProperty; +typedef UInterfaceProperty FInterfaceProperty; +#endif \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyViewport.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyViewport.cpp index 4e7244b63..1b2d1e5a0 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyViewport.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyViewport.cpp @@ -4,6 +4,8 @@ #include "LevelEditor.h" #include "Editor/LevelEditor/Public/ILevelViewport.h" #include "Editor/UnrealEd/Public/LevelEditorViewport.h" +#include "SLevelViewport.h" + #endif #include "Slate/UEPySWidget.h" @@ -59,14 +61,15 @@ PyObject *py_unreal_engine_editor_set_view_mode(PyObject * self, PyObject * args return NULL; } - FLevelEditorModule &EditorModule = FModuleManager::LoadModuleChecked("LevelEditor"); + FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked("LevelEditor"); + TSharedPtr ActiveLevelViewport = LevelEditorModule.GetFirstActiveLevelViewport(); - if (!EditorModule.GetFirstActiveViewport().IsValid()) + if (!ActiveLevelViewport.IsValid()) return PyErr_Format(PyExc_Exception, "no active LevelEditor Viewport"); - FLevelEditorViewportClient &viewport_client = EditorModule.GetFirstActiveViewport()->GetLevelViewportClient(); + FLevelEditorViewportClient& LevelViewportClient = ActiveLevelViewport->GetLevelViewportClient(); - viewport_client.SetViewMode((EViewModeIndex)mode); + LevelViewportClient.SetViewMode((EViewModeIndex)mode); Py_RETURN_NONE; } @@ -81,14 +84,16 @@ PyObject *py_unreal_engine_editor_set_camera_speed(PyObject * self, PyObject * a return NULL; } - FLevelEditorModule &EditorModule = FModuleManager::LoadModuleChecked("LevelEditor"); - if (!EditorModule.GetFirstActiveViewport().IsValid()) + FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked("LevelEditor"); + TSharedPtr ActiveLevelViewport = LevelEditorModule.GetFirstActiveLevelViewport(); + + if (!ActiveLevelViewport.IsValid()) return PyErr_Format(PyExc_Exception, "no active LevelEditor Viewport"); - FLevelEditorViewportClient &viewport_client = EditorModule.GetFirstActiveViewport()->GetLevelViewportClient(); + FLevelEditorViewportClient& LevelViewportClient = ActiveLevelViewport->GetLevelViewportClient(); - viewport_client.SetCameraSpeedSetting(speed); + LevelViewportClient.SetCameraSpeedSetting(speed); Py_RETURN_NONE; } @@ -107,14 +112,15 @@ PyObject *py_unreal_engine_editor_set_view_location(PyObject * self, PyObject * if (!vector) return PyErr_Format(PyExc_Exception, "argument is not a FVector"); - FLevelEditorModule &EditorModule = FModuleManager::LoadModuleChecked("LevelEditor"); + FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked("LevelEditor"); + TSharedPtr ActiveLevelViewport = LevelEditorModule.GetFirstActiveLevelViewport(); - if (!EditorModule.GetFirstActiveViewport().IsValid()) + if (!ActiveLevelViewport.IsValid()) return PyErr_Format(PyExc_Exception, "no active LevelEditor Viewport"); - FLevelEditorViewportClient &viewport_client = EditorModule.GetFirstActiveViewport()->GetLevelViewportClient(); + FLevelEditorViewportClient& LevelViewportClient = ActiveLevelViewport->GetLevelViewportClient(); - viewport_client.SetViewLocation(vector->vec); + LevelViewportClient.SetViewLocation(vector->vec); Py_RETURN_NONE; } @@ -133,14 +139,15 @@ PyObject *py_unreal_engine_editor_set_view_rotation(PyObject * self, PyObject * if (!rotator) return PyErr_Format(PyExc_Exception, "argument is not a FRotator"); - FLevelEditorModule &EditorModule = FModuleManager::LoadModuleChecked("LevelEditor"); + FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked("LevelEditor"); + TSharedPtr ActiveLevelViewport = LevelEditorModule.GetFirstActiveLevelViewport(); - if (!EditorModule.GetFirstActiveViewport().IsValid()) + if (!ActiveLevelViewport.IsValid()) return PyErr_Format(PyExc_Exception, "no active LevelEditor Viewport"); - FLevelEditorViewportClient &viewport_client = EditorModule.GetFirstActiveViewport()->GetLevelViewportClient(); + FLevelEditorViewportClient& LevelViewportClient = ActiveLevelViewport->GetLevelViewportClient(); - viewport_client.SetViewRotation(rotator->rot); + LevelViewportClient.SetViewRotation(rotator->rot); Py_RETURN_NONE; } diff --git a/Source/UnrealEnginePython/Private/UnrealEnginePython.cpp b/Source/UnrealEnginePython/Private/UnrealEnginePython.cpp index 211124849..41113d733 100644 --- a/Source/UnrealEnginePython/Private/UnrealEnginePython.cpp +++ b/Source/UnrealEnginePython/Private/UnrealEnginePython.cpp @@ -47,7 +47,6 @@ const char *ue4_module_options = "linux_global_symbols"; #include "Android/AndroidApplication.h" #endif - const char *UEPyUnicode_AsUTF8(PyObject *py_str) { #if PY_MAJOR_VERSION < 3 @@ -249,7 +248,11 @@ void FUnrealEnginePythonModule::StartupModule() if (GConfig->GetString(UTF8_TO_TCHAR("Python"), UTF8_TO_TCHAR("Home"), PythonHome, GEngineIni)) { #if PY_MAJOR_VERSION >= 3 + #if ENGINE_MINOR_VERSION >= 20 + wchar_t *home = (wchar_t *)(TCHAR_TO_WCHAR(*PythonHome)); + #else wchar_t *home = (wchar_t *)*PythonHome; + #endif #else char *home = TCHAR_TO_UTF8(*PythonHome); #endif @@ -263,7 +266,11 @@ void FUnrealEnginePythonModule::StartupModule() FPaths::NormalizeFilename(PythonHome); PythonHome = FPaths::ConvertRelativePathToFull(PythonHome); #if PY_MAJOR_VERSION >= 3 + #if ENGINE_MINOR_VERSION >= 20 + wchar_t *home = (wchar_t *)(TCHAR_TO_WCHAR(*PythonHome)); + #else wchar_t *home = (wchar_t *)*PythonHome; + #endif #else char *home = TCHAR_TO_UTF8(*PythonHome); #endif @@ -277,7 +284,11 @@ void FUnrealEnginePythonModule::StartupModule() if (GConfig->GetString(UTF8_TO_TCHAR("Python"), UTF8_TO_TCHAR("ProgramName"), IniValue, GEngineIni)) { #if PY_MAJOR_VERSION >= 3 + #if ENGINE_MINOR_VERSION >= 20 + wchar_t *program_name = (wchar_t *)(TCHAR_TO_WCHAR(*IniValue)); + #else wchar_t *program_name = (wchar_t *)*IniValue; + #endif #else char *program_name = TCHAR_TO_UTF8(*IniValue); #endif @@ -290,7 +301,11 @@ void FUnrealEnginePythonModule::StartupModule() FPaths::NormalizeFilename(IniValue); IniValue = FPaths::ConvertRelativePathToFull(IniValue); #if PY_MAJOR_VERSION >= 3 + #if ENGINE_MINOR_VERSION >= 20 + wchar_t *program_name = (wchar_t *)(TCHAR_TO_WCHAR(*IniValue)); + #else wchar_t *program_name = (wchar_t *)*IniValue; + #endif #else char *program_name = TCHAR_TO_UTF8(*IniValue); #endif @@ -391,6 +406,7 @@ void FUnrealEnginePythonModule::StartupModule() } // Setup our own paths for PYTHONPATH + #if PLATFORM_WINDOWS TArray OurPythonPaths = { PythonHome, FPaths::Combine(PythonHome, TEXT("Lib")), @@ -403,10 +419,10 @@ void FUnrealEnginePythonModule::StartupModule() PathVars.Append(OurPythonPaths); FString ModifiedPath = FString::Join(PathVars, PathDelimiter); FPlatformMisc::SetEnvironmentVar(TEXT("PATH"), *ModifiedPath); + #endif } - #if PY_MAJOR_VERSION >= 3 init_unreal_engine_builtin(); #if PLATFORM_ANDROID diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFEditorViewportClient.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFEditorViewportClient.cpp index 43aff5748..5e4849a52 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFEditorViewportClient.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFEditorViewportClient.cpp @@ -105,8 +105,25 @@ static PyObject *py_ue_feditor_viewport_client_set_realtime(ue_PyFEditorViewport if (!PyArg_ParseTuple(args, "OO", &bInRealtime, &bStoreCurrentValue)) return nullptr; +#if ENGINE_MINOR_VERSION >= 25 + // UE4.25 split this setting to 2 separate functions + if (PyObject_IsTrue(bStoreCurrentValue)) + { + //Persist across editor sessions + self->editor_viewport_client->SetRealtime(PyObject_IsTrue(bInRealtime) ? true : false); + } + else + { + //Don't persist across editor sessions + FText OverrideSourceText; + OverrideSourceText.FromString(TEXT("UnrealEnginePython plugin script")); + self->editor_viewport_client->SetRealtimeOverride(PyObject_IsTrue(bInRealtime) ? true : false, OverrideSourceText); + } + +#else self->editor_viewport_client->SetRealtime(PyObject_IsTrue(bInRealtime) ? true : false, PyObject_IsTrue(bStoreCurrentValue) ? true : false); +#endif Py_RETURN_NONE; } diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFRawMesh.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFRawMesh.h index ba6ad8a90..44f4a57ea 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFRawMesh.h +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFRawMesh.h @@ -5,7 +5,12 @@ #if ENGINE_MINOR_VERSION > 13 +#if ENGINE_MINOR_VERSION < 25 #include "Developer/RawMesh/Public/RawMesh.h" +#else +#include "Runtime/RawMesh/Public/RawMesh.h" +#endif + struct ue_PyFRawMesh { diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFSoftSkinVertex.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFSoftSkinVertex.cpp index 64e168222..0a63a0abe 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFSoftSkinVertex.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFSoftSkinVertex.cpp @@ -89,7 +89,11 @@ static int py_ue_fsoft_skin_vertex_set_tangent_z(ue_PyFSoftSkinVertex *self, PyO static PyObject *py_ue_fsoft_skin_vertex_get_influence_bones(ue_PyFSoftSkinVertex *self, void *closure) { - uint8 *data = self->ss_vertex.InfluenceBones; +#if ENGINE_MINOR_VERSION >= 25 + uint16* data = self->ss_vertex.InfluenceBones; +#else + uint8* data = self->ss_vertex.InfluenceBones; +#endif return Py_BuildValue((char*)"(iiiiiiii)", data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]); } diff --git a/Source/UnrealEnginePython/Private/hosts-per-state.py b/Source/UnrealEnginePython/Private/hosts-per-state.py new file mode 100644 index 000000000..4b1fa8084 --- /dev/null +++ b/Source/UnrealEnginePython/Private/hosts-per-state.py @@ -0,0 +1,13 @@ +""" Get lists of event hosts per state """ +from datetime import datetime, timezone, timedelta +import json +import csv +import sys +import copy + +import pytz +import pygsheets +import requests + +from auth.auth import create_drive_api, create_sheets_api, get_mobilize_credentials +import utils diff --git a/Source/UnrealEnginePython/UnrealEnginePython.Build.cs b/Source/UnrealEnginePython/UnrealEnginePython.Build.cs index a6fe71946..e727d0ec0 100644 --- a/Source/UnrealEnginePython/UnrealEnginePython.Build.cs +++ b/Source/UnrealEnginePython/UnrealEnginePython.Build.cs @@ -18,7 +18,7 @@ public class UnrealEnginePython : ModuleRules private string[] windowsKnownPaths = { - // "C:/Program Files/Python37", + "C:/Program Files/Python37", "C:/Program Files/Python36", "C:/Program Files/Python35", "C:/Python27", @@ -95,8 +95,9 @@ public UnrealEnginePython(TargetInfo Target) { PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; + PublicDefinitions.Add("WITH_UNREALENGINEPYTHON=1"); // fixed string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD"); - bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild); + bUseUnity = string.IsNullOrEmpty(enableUnityBuild); PublicIncludePaths.AddRange( new string[] { @@ -213,7 +214,7 @@ public UnrealEnginePython(TargetInfo Target) System.Console.WriteLine("Using Python at: " + pythonHome); PublicIncludePaths.Add(pythonHome); string libPath = GetWindowsPythonLibFile(pythonHome); - PublicLibraryPaths.Add(Path.GetDirectoryName(libPath)); + PublicSystemLibraryPaths.Add(Path.GetDirectoryName(libPath)); PublicAdditionalLibraries.Add(libPath); } else if (Target.Platform == UnrealTargetPlatform.Mac) @@ -229,7 +230,7 @@ public UnrealEnginePython(TargetInfo Target) System.Console.WriteLine("Using Python at: " + pythonHome); PublicIncludePaths.Add(pythonHome); string libPath = GetMacPythonLibFile(pythonHome); - PublicLibraryPaths.Add(Path.GetDirectoryName(libPath)); + PublicAdditionalLibraries.Add(Path.GetDirectoryName(libPath)); PublicDelayLoadDLLs.Add(libPath); } else if (Target.Platform == UnrealTargetPlatform.Linux) @@ -259,14 +260,15 @@ public UnrealEnginePython(TargetInfo Target) } #if WITH_FORWARDED_MODULE_RULES_CTOR else if (Target.Platform == UnrealTargetPlatform.Android) - { + { PublicIncludePaths.Add(System.IO.Path.Combine(ModuleDirectory, "../../android/python35/include")); - PublicLibraryPaths.Add(System.IO.Path.Combine(ModuleDirectory, "../../android/armeabi-v7a")); + PublicAdditionalLibraries.Add(System.IO.Path.Combine(ModuleDirectory, "../../android/armeabi-v7a")); PublicAdditionalLibraries.Add("python3.5m"); string APLName = "UnrealEnginePython_APL.xml"; - string RelAPLPath = Utils.MakePathRelativeTo(System.IO.Path.Combine(ModuleDirectory, APLName), Target.RelativeEnginePath); - AdditionalPropertiesForReceipt.Add(new ReceiptProperty("AndroidPlugin", RelAPLPath)); + string RelAPLPath = Utils.MakePathRelativeTo(ModuleDirectory, Target.RelativeEnginePath); + AdditionalPropertiesForReceipt.Add("AndroidPlugin", Path.Combine(RelAPLPath, APLName)); + } #endif