3535#include " UObject/UEPyAnimSequence.h"
3636#include " UObject/UEPyCapture.h"
3737#include " UObject/UEPyLandscape.h"
38+ #include " UObject/UEPyUserDefinedStruct.h"
39+ #include " UObject/UEPyDataTable.h"
3840
3941
4042#include " UEPyAssetUserData.h"
5355
5456#include " Slate/UEPySlate.h"
5557
58+ #if ENGINE_MINOR_VERSION < 18
59+ #define USoftObjectProperty UAssetObjectProperty
60+ #define USoftClassProperty UAssetClassProperty
61+ typedef FAssetPtr FSoftObjectPtr;
62+ #endif
63+
5664DEFINE_LOG_CATEGORY (LogPython);
5765
5866
@@ -267,6 +275,7 @@ static PyMethodDef unreal_engine_methods[] = {
267275
268276 { " string_to_guid" , py_unreal_engine_string_to_guid, METH_VARARGS , " " },
269277 { " new_guid" , py_unreal_engine_new_guid, METH_VARARGS , " " },
278+ { " guid_to_string" , py_unreal_engine_guid_to_string, METH_VARARGS , " " },
270279
271280 { " heightmap_expand" , py_unreal_engine_heightmap_expand, METH_VARARGS , " " },
272281 { " heightmap_import" , py_unreal_engine_heightmap_import, METH_VARARGS , " " },
@@ -279,7 +288,7 @@ static PyMethodDef unreal_engine_methods[] = {
279288 { " create_blueprint_from_actor" , py_unreal_engine_create_blueprint_from_actor, METH_VARARGS , " " },
280289 { " replace_blueprint" , py_unreal_engine_replace_blueprint, METH_VARARGS , " " },
281290 { " get_blueprint_hierarchy_from_class" , py_unreal_engine_get_blueprint_hierarchy_from_class, METH_VARARGS , " " },
282- { " reload_blueprint" , py_unreal_engine_reload_blueprint, METH_VARARGS , " " },
291+ { " reload_blueprint" , py_unreal_engine_reload_blueprint, METH_VARARGS , " " },
283292 { " compile_blueprint" , py_unreal_engine_compile_blueprint, METH_VARARGS , " " },
284293 { " blueprint_add_member_variable" , py_unreal_engine_blueprint_add_member_variable, METH_VARARGS , " " },
285294 { " blueprint_add_event_dispatcher" , py_unreal_engine_blueprint_add_event_dispatcher, METH_VARARGS , " " },
@@ -489,6 +498,7 @@ static PyMethodDef ue_PyUObject_methods[] = {
489498 { " get_py_proxy" , (PyCFunction)py_ue_get_py_proxy, METH_VARARGS , " " },
490499
491500 { " post_edit_change" , (PyCFunction)py_ue_post_edit_change, METH_VARARGS , " " },
501+ { " post_edit_change_property" , (PyCFunction)py_ue_post_edit_change_property, METH_VARARGS , " " },
492502 { " pre_edit_change" , (PyCFunction)py_ue_pre_edit_change, METH_VARARGS , " " },
493503 { " modify" , (PyCFunction)py_ue_modify, METH_VARARGS , " " },
494504
@@ -531,6 +541,20 @@ static PyMethodDef ue_PyUObject_methods[] = {
531541 { " node_reconstruct" , (PyCFunction)py_ue_node_reconstruct, METH_VARARGS , " " },
532542
533543 { " get_material_graph" , (PyCFunction)py_ue_get_material_graph, METH_VARARGS , " " },
544+
545+ { " struct_add_variable" , (PyCFunction)py_ue_struct_add_variable, METH_VARARGS , " " },
546+ { " struct_get_variables" , (PyCFunction)py_ue_struct_get_variables, METH_VARARGS , " " },
547+ { " struct_remove_variable" , (PyCFunction)py_ue_struct_remove_variable, METH_VARARGS , " " },
548+ { " struct_move_variable_up" , (PyCFunction)py_ue_struct_move_variable_up, METH_VARARGS , " " },
549+ { " struct_move_variable_down" , (PyCFunction)py_ue_struct_move_variable_down, METH_VARARGS , " " },
550+
551+ { " data_table_add_row" , (PyCFunction)py_ue_data_table_add_row, METH_VARARGS , " " },
552+ { " data_table_remove_row" , (PyCFunction)py_ue_data_table_remove_row, METH_VARARGS , " " },
553+ { " data_table_rename_row" , (PyCFunction)py_ue_data_table_rename_row, METH_VARARGS , " " },
554+ { " data_table_as_dict" , (PyCFunction)py_ue_data_table_as_dict, METH_VARARGS , " " },
555+ { " data_table_as_json" , (PyCFunction)py_ue_data_table_as_json, METH_VARARGS , " " },
556+ { " data_table_find_row" , (PyCFunction)py_ue_data_table_find_row, METH_VARARGS , " " },
557+ { " data_table_get_all_rows" , (PyCFunction)py_ue_data_table_get_all_rows, METH_VARARGS , " " },
534558#endif
535559
536560 { " is_rooted" , (PyCFunction)py_ue_is_rooted, METH_VARARGS , " " },
@@ -700,7 +724,14 @@ static PyMethodDef ue_PyUObject_methods[] = {
700724 { " get_current_level" , (PyCFunction)py_ue_get_current_level, METH_VARARGS , " " },
701725 { " set_current_level" , (PyCFunction)py_ue_set_current_level, METH_VARARGS , " " },
702726
727+ #if WITH_EDITOR
728+ { " add_foliage_asset" , (PyCFunction)py_ue_add_foliage_asset, METH_VARARGS , " " },
729+ #endif
730+ { " get_instanced_foliage_actor_for_current_level" , (PyCFunction)py_ue_get_instanced_foliage_actor_for_current_level, METH_VARARGS , " " },
731+
732+
703733 { " add_actor_component" , (PyCFunction)py_ue_add_actor_component, METH_VARARGS , " " },
734+ { " add_instance_component" , (PyCFunction)py_ue_add_instance_component, METH_VARARGS , " " },
704735 { " add_actor_root_component" , (PyCFunction)py_ue_add_actor_root_component, METH_VARARGS , " " },
705736 { " get_actor_component_by_type" , (PyCFunction)py_ue_get_actor_component_by_type, METH_VARARGS , " " },
706737 { " get_component_by_type" , (PyCFunction)py_ue_get_actor_component_by_type, METH_VARARGS , " " },
@@ -947,7 +978,7 @@ void ue_pydelegates_cleanup(ue_PyUObject *self)
947978#endif
948979 py_delegate->RemoveFromRoot ();
949980 }
950- }
981+ }
951982 self->python_delegates_gc ->clear ();
952983 delete self->python_delegates_gc ;
953984 self->python_delegates_gc = nullptr ;
@@ -1043,9 +1074,9 @@ static PyObject *ue_PyUObject_getattro(ue_PyUObject *self, PyObject *attr_name)
10431074#else
10441075 return PyLong_FromLong (u_enum->FindEnumIndex (item.Key ));
10451076#endif
1046- }
10471077 }
10481078 }
1079+ }
10491080#endif
10501081 if (self->ue_object ->IsA <UEnum>())
10511082 {
@@ -1057,16 +1088,16 @@ static PyObject *ue_PyUObject_getattro(ue_PyUObject *self, PyObject *attr_name)
10571088 return PyLong_FromLong (u_enum->FindEnumIndex (FName (UTF8_TO_TCHAR (attr))));
10581089#endif
10591090 }
1060- }
1091+ }
10611092
10621093 if (function)
10631094 {
10641095 // swallow previous exception
10651096 PyErr_Clear ();
10661097 return py_ue_new_callable (function, self->ue_object );
10671098 }
1068- }
10691099 }
1100+ }
10701101 return ret;
10711102}
10721103
@@ -2059,7 +2090,7 @@ void unreal_engine_py_log_error()
20592090 if (zero)
20602091 {
20612092 msg = PyBytes_AsString (zero);
2062- }
2093+ }
20632094#else
20642095 msg = PyString_AsString (PyObject_Str (value));
20652096#endif
@@ -2114,7 +2145,7 @@ void unreal_engine_py_log_error()
21142145 }
21152146
21162147 PyErr_Clear ();
2117- }
2148+ }
21182149
21192150// retrieve a UWorld from a generic UObject (if possible)
21202151UWorld *ue_get_uworld (ue_PyUObject *py_obj)
@@ -2245,8 +2276,7 @@ PyObject *ue_py_convert_property(UProperty *prop, uint8 *buffer)
22452276 Py_INCREF (ret);
22462277 return (PyObject *)ret;
22472278 }
2248- Py_INCREF (Py_None);
2249- return Py_None;
2279+ Py_RETURN_NONE;
22502280 }
22512281
22522282 if (auto casted_prop = Cast<UClassProperty>(prop))
@@ -2764,24 +2794,47 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer)
27642794 ue_PyUObject *ue_obj = (ue_PyUObject *)py_obj;
27652795 if (ue_obj->ue_object ->IsA <UClass>())
27662796 {
2767- auto casted_prop = Cast<UClassProperty>(prop);
2768- if (!casted_prop)
2797+ if (auto casted_prop = Cast<UClassProperty>(prop))
2798+ {
2799+ casted_prop->SetPropertyValue_InContainer (buffer, ue_obj->ue_object );
2800+ return true ;
2801+ }
2802+ else if (auto casted_prop_soft_class = Cast<USoftClassProperty>(prop))
2803+ {
2804+ casted_prop_soft_class->SetPropertyValue_InContainer (buffer, FSoftObjectPtr (ue_obj->ue_object ));
2805+ return true ;
2806+ }
2807+ else if (auto casted_prop_soft_object = Cast<USoftObjectProperty>(prop))
2808+ {
2809+ casted_prop_soft_object->SetPropertyValue_InContainer (buffer, FSoftObjectPtr (ue_obj->ue_object ));
2810+ return true ;
2811+ }
2812+
27692813 return false ;
2770- casted_prop->SetPropertyValue_InContainer (buffer, (UClass *)ue_obj->ue_object );
2771- return true ;
27722814 }
27732815
2816+
27742817 if (ue_obj->ue_object ->IsA <UObject>())
27752818 {
2776- auto casted_prop = Cast<UObjectPropertyBase>(prop);
2777- if (!casted_prop)
2778- return false ;
2819+ if (auto casted_prop = Cast<UObjectPropertyBase>(prop))
2820+ {
27792821 // ensure the object type is correct, otherwise crash could happen (soon or later)
27802822 if (!ue_obj->ue_object ->IsA (casted_prop->PropertyClass ))
27812823 return false ;
27822824 casted_prop->SetObjectPropertyValue_InContainer (buffer, ue_obj->ue_object );
27832825 return true ;
27842826 }
2827+ else if (auto casted_prop_soft_object = Cast<USoftObjectProperty>(prop))
2828+
2829+ {
2830+ if (!ue_obj->ue_object ->IsA (casted_prop_soft_object->PropertyClass ))
2831+ return false ;
2832+ casted_prop_soft_object->SetPropertyValue_InContainer (buffer, FSoftObjectPtr (ue_obj->ue_object ));
2833+ return true ;
2834+ }
2835+
2836+ }
2837+ return false ;
27852838 }
27862839
27872840 if (py_obj == Py_None)
@@ -2994,10 +3047,10 @@ PyObject *py_ue_ufunction_call(UFunction *u_function, UObject *u_obj, PyObject *
29943047#else
29953048 prop->ImportText (*default_key_value, prop->ContainerPtrToValuePtr <uint8>(buffer), PPF_Localized, NULL );
29963049#endif
2997- }
3050+ }
29983051#endif
29993052
3000- }
3053+ }
30013054
30023055 Py_ssize_t tuple_len = PyTuple_Size (args);
30033056
@@ -3481,6 +3534,21 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_
34813534 return function;
34823535}
34833536
3537+ FGuid *ue_py_check_fguid (PyObject *py_obj)
3538+ {
3539+ ue_PyUScriptStruct *ue_py_struct = py_ue_is_uscriptstruct (py_obj);
3540+ if (!ue_py_struct)
3541+ {
3542+ return nullptr ;
3543+ }
3544+
3545+ if (ue_py_struct->u_struct == FindObject<UScriptStruct>(ANY_PACKAGE , UTF8_TO_TCHAR ((char *)" Guid" )))
3546+ {
3547+ return (FGuid*)ue_py_struct->data ;
3548+ }
3549+
3550+ return nullptr ;
3551+ }
34843552uint8 * do_ue_py_check_struct (PyObject *py_obj, UScriptStruct* chk_u_struct)
34853553{
34863554 ue_PyUScriptStruct *ue_py_struct = py_ue_is_uscriptstruct (py_obj);
0 commit comments