2727#include " ../utils/Class.hpp"
2828#include " ../utils/VariantArguments.hpp"
2929#include " ../utils/VariantType.hpp"
30- #include " ../utils/VariantTypedArray.hpp"
3130#include " ../utils/convert_godot_lua.hpp"
3231
3332#include < godot_cpp/classes/node.hpp>
@@ -53,14 +52,12 @@ static LuaScriptProperty lua_property(sol::this_state L, sol::stack_object value
5352 // index 1: either a Variant type or the default value
5453 if (auto type = table.get <sol::optional<VariantType>>(1 )) {
5554 property.type = type->get_type ();
55+ if (type->has_type_hints ()) {
56+ property.hint = type->get_property_hint ();
57+ property.hint_string = type->get_property_hint_string ();
58+ }
5659 property.default_value = type->construct_default ();
5760 }
58- else if (auto typed_array = table.get <sol::optional<VariantTypedArray>>(1 )) {
59- property.type = Variant::Type::ARRAY;
60- property.hint = PROPERTY_HINT_ARRAY_TYPE;
61- property.hint_string = typed_array->get_hint_string ();
62- property.default_value = typed_array->construct_default ();
63- }
6461 else if (auto cls = table.get <sol::optional<Class>>(1 )) {
6562 property.type = Variant::Type::OBJECT;
6663 property.class_name = cls->get_name ();
@@ -80,16 +77,12 @@ static LuaScriptProperty lua_property(sol::this_state L, sol::stack_object value
8077 // PropertyInfo fields
8178 if (auto type = table.get <sol::optional<VariantType>>(" type" )) {
8279 property.type = type->get_type ();
83- if (property.default_value .get_type () == Variant::Type::NIL) {
84- property.default_value = type->construct_default ();
80+ if (type->has_type_hints ()) {
81+ property.hint = type->get_property_hint ();
82+ property.hint_string = type->get_property_hint_string ();
8583 }
86- }
87- else if (auto typed_array = table.get <sol::optional<VariantTypedArray>>(" type" )) {
88- property.type = Variant::Type::ARRAY;
89- property.hint = PROPERTY_HINT_ARRAY_TYPE;
90- property.hint_string = typed_array->get_hint_string ();
91- if (property.default_value .get_type () == Variant::Type::NIL) {
92- property.default_value = typed_array->construct_default ();
84+ if (property.default_value == Variant ()) {
85+ property.default_value = type->construct_default ();
9386 }
9487 }
9588 if (auto hint = table.get <sol::optional<uint32_t >>(" hint" )) {
@@ -125,10 +118,11 @@ static LuaScriptProperty lua_property(sol::this_state L, sol::stack_object value
125118 }
126119
127120 if (property.type == 0 ) {
128- property.type = property.default_value .get_type ();
129- if (property.default_value .get_type () == Variant::Type::ARRAY && Array (property.default_value ).is_typed ()) {
130- property.hint = PROPERTY_HINT_ARRAY_TYPE;
131- property.hint_string = VariantTypedArray::of (property.default_value ).get_hint_string ();
121+ VariantType type = VariantType::from_variant (property.default_value );
122+ property.type = type.get_type ();
123+ if (type.has_type_hints ()) {
124+ property.hint = type.get_property_hint ();
125+ property.hint_string = type.get_property_hint_string ();
132126 }
133127 }
134128 property.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE;
0 commit comments