diff options
55 files changed, 351 insertions, 174 deletions
diff --git a/core/global_constants.cpp b/core/global_constants.cpp index b990ec9276..3de36dcb9d 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -606,6 +606,7 @@ void register_global_constants() { BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_BASIS", Variant::BASIS); BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_TRANSFORM", Variant::TRANSFORM); BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_COLOR", Variant::COLOR); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_STRING_NAME", Variant::STRING_NAME); // 15 BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_NODE_PATH", Variant::NODE_PATH); // 15 BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RID", Variant::_RID); BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_OBJECT", Variant::OBJECT); diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index ab88f4d85c..b77ef40fd3 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -328,6 +328,16 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int (*r_len) += 4 * 4; } break; + case Variant::STRING_NAME: { + + String str; + Error err = _decode_string(buf, len, r_len, str); + if (err) + return err; + r_variant = StringName(str); + + } break; + case Variant::NODE_PATH: { ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA); @@ -939,6 +949,11 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo _encode_string(p_variant, buf, r_len); } break; + case Variant::STRING_NAME: { + + _encode_string(p_variant, buf, r_len); + + } break; // math types case Variant::VECTOR2: { diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 991853e86d..144e48d0da 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -75,6 +75,7 @@ enum { VARIANT_DOUBLE = 41, VARIANT_CALLABLE = 42, VARIANT_SIGNAL = 43, + VARIANT_STRING_NAME = 44, OBJECT_EMPTY = 0, OBJECT_EXTERNAL_RESOURCE = 1, OBJECT_INTERNAL_RESOURCE = 2, @@ -260,6 +261,10 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { r_v = v; } break; + case VARIANT_STRING_NAME: { + + r_v = StringName(get_unicode_string()); + } break; case VARIANT_NODE_PATH: { @@ -1394,6 +1399,13 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia f->store_real(val.a); } break; + case Variant::STRING_NAME: { + + f->store_32(VARIANT_STRING_NAME); + String val = p_property; + save_unicode_string(f, val); + + } break; case Variant::NODE_PATH: { f->store_32(VARIANT_NODE_PATH); diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 1d5d8f9280..39bbebefa6 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -248,7 +248,7 @@ void ResourceFormatLoader::_bind_methods() { } ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::PACKED_STRING_ARRAY, "get_recognized_extensions")); - ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "handles_type", PropertyInfo(Variant::STRING, "typename"))); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "handles_type", PropertyInfo(Variant::STRING_NAME, "typename"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_resource_type", PropertyInfo(Variant::STRING, "path"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("get_dependencies", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::STRING, "add_types"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::INT, "rename_dependencies", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::STRING, "renames"))); diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h index 42d71dea46..7e21c2cc24 100644 --- a/core/method_ptrcall.h +++ b/core/method_ptrcall.h @@ -125,6 +125,7 @@ MAKE_PTRARG_BY_REFERENCE(AABB); MAKE_PTRARG_BY_REFERENCE(Basis); MAKE_PTRARG_BY_REFERENCE(Transform); MAKE_PTRARG_BY_REFERENCE(Color); +MAKE_PTRARG(StringName); MAKE_PTRARG(NodePath); MAKE_PTRARG(RID); MAKE_PTRARG(Dictionary); @@ -373,29 +374,7 @@ MAKE_VECARR(Plane); } \ } -//MAKE_DVECARR(Plane); -//for special case StringName - -#define MAKE_STRINGCONV(m_type) \ - template <> \ - struct PtrToArg<m_type> { \ - _FORCE_INLINE_ static m_type convert(const void *p_ptr) { \ - m_type s = *reinterpret_cast<const String *>(p_ptr); \ - return s; \ - } \ - _FORCE_INLINE_ static void encode(m_type p_vec, void *p_ptr) { \ - String *arr = reinterpret_cast<String *>(p_ptr); \ - *arr = p_vec; \ - } \ - }; \ - \ - template <> \ - struct PtrToArg<const m_type &> { \ - _FORCE_INLINE_ static m_type convert(const void *p_ptr) { \ - m_type s = *reinterpret_cast<const String *>(p_ptr); \ - return s; \ - } \ - } +// Special case for IP_Address. #define MAKE_STRINGCONV_BY_REFERENCE(m_type) \ template <> \ @@ -418,7 +397,6 @@ MAKE_VECARR(Plane); } \ } -MAKE_STRINGCONV(StringName); MAKE_STRINGCONV_BY_REFERENCE(IP_Address); template <> diff --git a/core/node_path.h b/core/node_path.h index 5439658910..05b6d844ff 100644 --- a/core/node_path.h +++ b/core/node_path.h @@ -54,15 +54,6 @@ class NodePath { void _update_hash_cache() const; public: - _FORCE_INLINE_ StringName get_sname() const { - - if (data && data->path.size() == 1 && data->subpath.empty()) { - return data->path[0]; - } else { - return operator String(); - } - } - bool is_absolute() const; int get_name_count() const; StringName get_name(int p_idx) const; diff --git a/core/object.cpp b/core/object.cpp index d5db383cbc..a61c4ae392 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -646,10 +646,10 @@ Variant Object::_call_bind(const Variant **p_args, int p_argcount, Callable::Cal return Variant(); } - if (p_args[0]->get_type() != Variant::STRING) { + if (p_args[0]->get_type() != Variant::STRING_NAME && p_args[0]->get_type() != Variant::STRING) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument = 0; - r_error.expected = Variant::STRING; + r_error.expected = Variant::STRING_NAME; return Variant(); } @@ -666,10 +666,10 @@ Variant Object::_call_deferred_bind(const Variant **p_args, int p_argcount, Call return Variant(); } - if (p_args[0]->get_type() != Variant::STRING) { + if (p_args[0]->get_type() != Variant::STRING_NAME && p_args[0]->get_type() != Variant::STRING) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument = 0; - r_error.expected = Variant::STRING; + r_error.expected = Variant::STRING_NAME; return Variant(); } @@ -1108,11 +1108,11 @@ Variant Object::_emit_signal(const Variant **p_args, int p_argcount, Callable::C r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; ERR_FAIL_COND_V(p_argcount < 1, Variant()); - if (p_args[0]->get_type() != Variant::STRING) { + if (p_args[0]->get_type() != Variant::STRING_NAME && p_args[0]->get_type() != Variant::STRING) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument = 0; - r_error.expected = Variant::STRING; - ERR_FAIL_COND_V(p_args[0]->get_type() != Variant::STRING, Variant()); + r_error.expected = Variant::STRING_NAME; + ERR_FAIL_COND_V(p_args[0]->get_type() != Variant::STRING_NAME && p_args[0]->get_type() != Variant::STRING, Variant()); } r_error.error = Callable::CallError::CALL_OK; @@ -1207,7 +1207,7 @@ Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int if (ce.error == Callable::CallError::CALL_ERROR_INVALID_METHOD && !ClassDB::class_exists(target->get_class_name())) { //most likely object is not initialized yet, do not throw error. } else { - ERR_PRINT("Error calling from signal '" + String(p_name) + "': " + Variant::get_callable_error_text(c.callable, args, argc, ce) + "."); + ERR_PRINT("Error calling from signal '" + String(p_name) + "' to callable: " + Variant::get_callable_error_text(c.callable, args, argc, ce) + "."); err = ERR_METHOD_NOT_FOUND; } } @@ -1663,7 +1663,7 @@ void Object::_bind_methods() { { MethodInfo mi; mi.name = "emit_signal"; - mi.arguments.push_back(PropertyInfo(Variant::STRING, "signal")); + mi.arguments.push_back(PropertyInfo(Variant::STRING_NAME, "signal")); ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "emit_signal", &Object::_emit_signal, mi, varray(), false); } @@ -1671,7 +1671,7 @@ void Object::_bind_methods() { { MethodInfo mi; mi.name = "call"; - mi.arguments.push_back(PropertyInfo(Variant::STRING, "method")); + mi.arguments.push_back(PropertyInfo(Variant::STRING_NAME, "method")); ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "call", &Object::_call_bind, mi); } @@ -1679,7 +1679,7 @@ void Object::_bind_methods() { { MethodInfo mi; mi.name = "call_deferred"; - mi.arguments.push_back(PropertyInfo(Variant::STRING, "method")); + mi.arguments.push_back(PropertyInfo(Variant::STRING_NAME, "method")); ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "call_deferred", &Object::_call_deferred_bind, mi, varray(), false); } @@ -1713,9 +1713,9 @@ void Object::_bind_methods() { ADD_SIGNAL(MethodInfo("script_changed")); BIND_VMETHOD(MethodInfo("_notification", PropertyInfo(Variant::INT, "what"))); - BIND_VMETHOD(MethodInfo(Variant::BOOL, "_set", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::NIL, "value"))); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "_set", PropertyInfo(Variant::STRING_NAME, "property"), PropertyInfo(Variant::NIL, "value"))); #ifdef TOOLS_ENABLED - MethodInfo miget("_get", PropertyInfo(Variant::STRING, "property")); + MethodInfo miget("_get", PropertyInfo(Variant::STRING_NAME, "property")); miget.return_val.name = "Variant"; miget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; BIND_VMETHOD(miget); diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp index 2e863c9c76..7d1ae872f4 100644 --- a/core/os/input_event.cpp +++ b/core/os/input_event.cpp @@ -1098,7 +1098,7 @@ void InputEventAction::_bind_methods() { // ClassDB::bind_method(D_METHOD("is_action", "name"), &InputEventAction::is_action); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "action"), "set_action", "get_action"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "action"), "set_action", "get_action"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_strength", "get_strength"); } diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp index ae5f89e870..f23ee30a27 100644 --- a/core/packed_data_container.cpp +++ b/core/packed_data_container.cpp @@ -247,6 +247,7 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd case Variant::PACKED_VECTOR2_ARRAY: case Variant::PACKED_VECTOR3_ARRAY: case Variant::PACKED_COLOR_ARRAY: + case Variant::STRING_NAME: case Variant::NODE_PATH: { uint32_t pos = tmpdata.size(); diff --git a/core/resource.cpp b/core/resource.cpp index 30e09716aa..2afc9e4042 100644 --- a/core/resource.cpp +++ b/core/resource.cpp @@ -423,7 +423,7 @@ void Resource::_bind_methods() { ADD_GROUP("Resource", "resource_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "resource_local_to_scene"), "set_local_to_scene", "is_local_to_scene"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "resource_path", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_path", "get_path"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "resource_name"), "set_name", "get_name"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "resource_name"), "set_name", "get_name"); BIND_VMETHOD(MethodInfo("_setup_local_to_scene")); } diff --git a/core/type_info.h b/core/type_info.h index 8e86567f51..6861531fbd 100644 --- a/core/type_info.h +++ b/core/type_info.h @@ -151,6 +151,7 @@ MAKE_TYPE_INFO(AABB, Variant::AABB) MAKE_TYPE_INFO(Basis, Variant::BASIS) MAKE_TYPE_INFO(Transform, Variant::TRANSFORM) MAKE_TYPE_INFO(Color, Variant::COLOR) +MAKE_TYPE_INFO(StringName, Variant::STRING_NAME) MAKE_TYPE_INFO(NodePath, Variant::NODE_PATH) MAKE_TYPE_INFO(RID, Variant::_RID) MAKE_TYPE_INFO(Callable, Variant::CALLABLE) @@ -165,7 +166,6 @@ MAKE_TYPE_INFO(PackedVector2Array, Variant::PACKED_VECTOR2_ARRAY) MAKE_TYPE_INFO(PackedVector3Array, Variant::PACKED_VECTOR3_ARRAY) MAKE_TYPE_INFO(PackedColorArray, Variant::PACKED_COLOR_ARRAY) -MAKE_TYPE_INFO(StringName, Variant::STRING) MAKE_TYPE_INFO(IP_Address, Variant::STRING) //objectID diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp index 0eef75d587..02f460c93d 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -105,7 +105,7 @@ void UndoRedo::create_action(const String &p_name, MergeMode p_mode) { action_level++; } -void UndoRedo::add_do_method(Object *p_object, const String &p_method, VARIANT_ARG_DECLARE) { +void UndoRedo::add_do_method(Object *p_object, const StringName &p_method, VARIANT_ARG_DECLARE) { VARIANT_ARGPTRS ERR_FAIL_COND(p_object == NULL); @@ -125,7 +125,7 @@ void UndoRedo::add_do_method(Object *p_object, const String &p_method, VARIANT_A actions.write[current_action + 1].do_ops.push_back(do_op); } -void UndoRedo::add_undo_method(Object *p_object, const String &p_method, VARIANT_ARG_DECLARE) { +void UndoRedo::add_undo_method(Object *p_object, const StringName &p_method, VARIANT_ARG_DECLARE) { VARIANT_ARGPTRS ERR_FAIL_COND(p_object == NULL); @@ -149,7 +149,7 @@ void UndoRedo::add_undo_method(Object *p_object, const String &p_method, VARIANT } actions.write[current_action + 1].undo_ops.push_back(undo_op); } -void UndoRedo::add_do_property(Object *p_object, const String &p_property, const Variant &p_value) { +void UndoRedo::add_do_property(Object *p_object, const StringName &p_property, const Variant &p_value) { ERR_FAIL_COND(p_object == NULL); ERR_FAIL_COND(action_level <= 0); @@ -164,7 +164,7 @@ void UndoRedo::add_do_property(Object *p_object, const String &p_property, const do_op.args[0] = p_value; actions.write[current_action + 1].do_ops.push_back(do_op); } -void UndoRedo::add_undo_property(Object *p_object, const String &p_property, const Variant &p_value) { +void UndoRedo::add_undo_property(Object *p_object, const StringName &p_property, const Variant &p_value) { ERR_FAIL_COND(p_object == NULL); ERR_FAIL_COND(action_level <= 0); @@ -446,17 +446,17 @@ Variant UndoRedo::_add_do_method(const Variant **p_args, int p_argcount, Callabl return Variant(); } - if (p_args[1]->get_type() != Variant::STRING) { + if (p_args[1]->get_type() != Variant::STRING_NAME && p_args[1]->get_type() != Variant::STRING) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument = 1; - r_error.expected = Variant::STRING; + r_error.expected = Variant::STRING_NAME; return Variant(); } r_error.error = Callable::CallError::CALL_OK; Object *object = *p_args[0]; - String method = *p_args[1]; + StringName method = *p_args[1]; Variant v[VARIANT_ARG_MAX]; @@ -484,17 +484,17 @@ Variant UndoRedo::_add_undo_method(const Variant **p_args, int p_argcount, Calla return Variant(); } - if (p_args[1]->get_type() != Variant::STRING) { + if (p_args[1]->get_type() != Variant::STRING_NAME && p_args[1]->get_type() != Variant::STRING) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument = 1; - r_error.expected = Variant::STRING; + r_error.expected = Variant::STRING_NAME; return Variant(); } r_error.error = Callable::CallError::CALL_OK; Object *object = *p_args[0]; - String method = *p_args[1]; + StringName method = *p_args[1]; Variant v[VARIANT_ARG_MAX]; @@ -518,7 +518,7 @@ void UndoRedo::_bind_methods() { MethodInfo mi; mi.name = "add_do_method"; mi.arguments.push_back(PropertyInfo(Variant::OBJECT, "object")); - mi.arguments.push_back(PropertyInfo(Variant::STRING, "method")); + mi.arguments.push_back(PropertyInfo(Variant::STRING_NAME, "method")); ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "add_do_method", &UndoRedo::_add_do_method, mi, varray(), false); } @@ -527,7 +527,7 @@ void UndoRedo::_bind_methods() { MethodInfo mi; mi.name = "add_undo_method"; mi.arguments.push_back(PropertyInfo(Variant::OBJECT, "object")); - mi.arguments.push_back(PropertyInfo(Variant::STRING, "method")); + mi.arguments.push_back(PropertyInfo(Variant::STRING_NAME, "method")); ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "add_undo_method", &UndoRedo::_add_undo_method, mi, varray(), false); } diff --git a/core/undo_redo.h b/core/undo_redo.h index e707979291..3b91e9ce36 100644 --- a/core/undo_redo.h +++ b/core/undo_redo.h @@ -65,7 +65,7 @@ private: Type type; Ref<Resource> resref; ObjectID object; - String name; + StringName name; Variant args[VARIANT_ARG_MAX]; }; @@ -103,10 +103,10 @@ protected: public: void create_action(const String &p_name = "", MergeMode p_mode = MERGE_DISABLE); - void add_do_method(Object *p_object, const String &p_method, VARIANT_ARG_LIST); - void add_undo_method(Object *p_object, const String &p_method, VARIANT_ARG_LIST); - void add_do_property(Object *p_object, const String &p_property, const Variant &p_value); - void add_undo_property(Object *p_object, const String &p_property, const Variant &p_value); + void add_do_method(Object *p_object, const StringName &p_method, VARIANT_ARG_LIST); + void add_undo_method(Object *p_object, const StringName &p_method, VARIANT_ARG_LIST); + void add_do_property(Object *p_object, const StringName &p_property, const Variant &p_value); + void add_undo_property(Object *p_object, const StringName &p_property, const Variant &p_value); void add_do_reference(Object *p_object); void add_undo_reference(Object *p_object); diff --git a/core/variant.cpp b/core/variant.cpp index cdc9e47fc8..8daa359917 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -136,6 +136,11 @@ String Variant::get_type_name(Variant::Type p_type) { return "Signal"; } break; + case STRING_NAME: { + + return "StringName"; + + } break; case NODE_PATH: { return "NodePath"; @@ -325,6 +330,15 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { valid_types = valid; } break; + case STRING_NAME: { + + static const Type valid[] = { + STRING, + NIL + }; + + valid_types = valid; + } break; case NODE_PATH: { static const Type valid[] = { @@ -495,6 +509,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type static const Type valid[] = { NODE_PATH, + STRING_NAME, NIL }; @@ -572,6 +587,15 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type valid_types = valid; } break; + case STRING_NAME: { + + static const Type valid[] = { + STRING, + NIL + }; + + valid_types = valid; + } break; case NODE_PATH: { static const Type valid[] = { @@ -808,6 +832,11 @@ bool Variant::is_zero() const { return reinterpret_cast<const Signal *>(_data._mem)->is_null(); } break; + case STRING_NAME: { + + return *reinterpret_cast<const StringName *>(_data._mem) != StringName(); + + } break; case NODE_PATH: { return reinterpret_cast<const NodePath *>(_data._mem)->is_empty(); @@ -1046,6 +1075,11 @@ void Variant::reference(const Variant &p_variant) { memnew_placement(_data._mem, Signal(*reinterpret_cast<const Signal *>(p_variant._data._mem))); } break; + case STRING_NAME: { + + memnew_placement(_data._mem, StringName(*reinterpret_cast<const StringName *>(p_variant._data._mem))); + + } break; case NODE_PATH: { memnew_placement(_data._mem, NodePath(*reinterpret_cast<const NodePath *>(p_variant._data._mem))); @@ -1152,7 +1186,11 @@ void Variant::clear() { memdelete(_data._transform); } break; - // misc types + // misc types + case STRING_NAME: { + + reinterpret_cast<StringName *>(_data._mem)->~StringName(); + } break; case NODE_PATH: { reinterpret_cast<NodePath *>(_data._mem)->~NodePath(); @@ -1453,10 +1491,13 @@ Variant::operator double() const { Variant::operator StringName() const { - if (type == NODE_PATH) { - return reinterpret_cast<const NodePath *>(_data._mem)->get_sname(); + if (type == STRING_NAME) { + return *reinterpret_cast<const StringName *>(_data._mem); + } else if (type == STRING) { + return *reinterpret_cast<const String *>(_data._mem); } - return StringName(operator String()); + + return StringName(); } struct _VariantStrPair { @@ -1523,6 +1564,7 @@ String Variant::stringify(List<const void *> &stack) const { return mtx + ")"; } break; case TRANSFORM: return operator Transform(); + case STRING_NAME: return operator StringName(); case NODE_PATH: return operator NodePath(); case COLOR: return String::num(operator Color().r) + "," + String::num(operator Color().g) + "," + String::num(operator Color().b) + "," + String::num(operator Color().a); case DICTIONARY: { @@ -2191,8 +2233,8 @@ Variant::Variant(const ObjectID &p_id) { Variant::Variant(const StringName &p_string) { - type = STRING; - memnew_placement(_data._mem, String(p_string.operator String())); + type = STRING_NAME; + memnew_placement(_data._mem, StringName(p_string)); } Variant::Variant(const String &p_string) { @@ -2549,6 +2591,10 @@ void Variant::operator=(const Variant &p_variant) { *reinterpret_cast<Signal *>(_data._mem) = *reinterpret_cast<const Signal *>(p_variant._data._mem); } break; + case STRING_NAME: { + + *reinterpret_cast<StringName *>(_data._mem) = *reinterpret_cast<const StringName *>(p_variant._data._mem); + } break; case NODE_PATH: { *reinterpret_cast<NodePath *>(_data._mem) = *reinterpret_cast<const NodePath *>(p_variant._data._mem); @@ -2747,6 +2793,10 @@ uint32_t Variant::hash() const { return hash_djb2_one_64(make_uint64_t(_get_obj().obj)); } break; + case STRING_NAME: { + + return reinterpret_cast<const StringName *>(_data._mem)->hash(); + } break; case NODE_PATH: { return reinterpret_cast<const NodePath *>(_data._mem)->hash(); diff --git a/core/variant.h b/core/variant.h index d41144f4c5..83e8f48d0c 100644 --- a/core/variant.h +++ b/core/variant.h @@ -99,6 +99,7 @@ public: // misc types COLOR, + STRING_NAME, NODE_PATH, // 15 _RID, OBJECT, diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 37c35d7c64..3b82e980bd 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -1215,6 +1215,8 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i // misc types case COLOR: return Color(); + case STRING_NAME: + return StringName(); // 15 case NODE_PATH: return NodePath(); // 15 case _RID: return RID(); @@ -1272,10 +1274,14 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i // misc types case COLOR: return p_args[0]->type == Variant::STRING ? Color::html(*p_args[0]) : Color::hex(*p_args[0]); + case STRING_NAME: + return (StringName(p_args[0]->operator StringName())); // 15 case NODE_PATH: return (NodePath(p_args[0]->operator NodePath())); // 15 case _RID: return (RID(*p_args[0])); case OBJECT: return ((Object *)(p_args[0]->operator Object *())); + case CALLABLE: return ((Callable)(p_args[0]->operator Callable())); + case SIGNAL: return ((Signal)(p_args[0]->operator Signal())); case DICTIONARY: return p_args[0]->operator Dictionary(); case ARRAY: return p_args[0]->operator Array(); // 20 @@ -1840,13 +1846,13 @@ void register_variant_methods() { ADDFUNC0R(CALLABLE, BOOL, Callable, is_standard, varray()); ADDFUNC0R(CALLABLE, OBJECT, Callable, get_object, varray()); ADDFUNC0R(CALLABLE, INT, Callable, get_object_id, varray()); - ADDFUNC0R(CALLABLE, STRING, Callable, get_method, varray()); + ADDFUNC0R(CALLABLE, STRING_NAME, Callable, get_method, varray()); ADDFUNC0R(CALLABLE, INT, Callable, hash, varray()); ADDFUNC0R(SIGNAL, BOOL, Signal, is_null, varray()); ADDFUNC0R(SIGNAL, OBJECT, Signal, get_object, varray()); ADDFUNC0R(SIGNAL, INT, Signal, get_object_id, varray()); - ADDFUNC0R(SIGNAL, STRING, Signal, get_name, varray()); + ADDFUNC0R(SIGNAL, STRING_NAME, Signal, get_name, varray()); ADDFUNC3R(SIGNAL, INT, Signal, connect, CALLABLE, "callable", ARRAY, "binds", INT, "flags", varray(Array(), 0)); @@ -2070,8 +2076,8 @@ void register_variant_methods() { _VariantCall::add_constructor(_VariantCall::Transform_init1, Variant::TRANSFORM, "x_axis", Variant::VECTOR3, "y_axis", Variant::VECTOR3, "z_axis", Variant::VECTOR3, "origin", Variant::VECTOR3); _VariantCall::add_constructor(_VariantCall::Transform_init2, Variant::TRANSFORM, "basis", Variant::BASIS, "origin", Variant::VECTOR3); - _VariantCall::add_constructor(_VariantCall::Callable_init2, Variant::CALLABLE, "object", Variant::OBJECT, "method_name", Variant::STRING); - _VariantCall::add_constructor(_VariantCall::Signal_init2, Variant::SIGNAL, "object", Variant::OBJECT, "signal_name", Variant::STRING); + _VariantCall::add_constructor(_VariantCall::Callable_init2, Variant::CALLABLE, "object", Variant::OBJECT, "method_name", Variant::STRING_NAME); + _VariantCall::add_constructor(_VariantCall::Signal_init2, Variant::SIGNAL, "object", Variant::OBJECT, "signal_name", Variant::STRING_NAME); /* REGISTER CONSTANTS */ diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 6c98cf4de1..31f36560fd 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -53,6 +53,7 @@ CASE_TYPE(PREFIX, OP, BASIS) \ CASE_TYPE(PREFIX, OP, TRANSFORM) \ CASE_TYPE(PREFIX, OP, COLOR) \ + CASE_TYPE(PREFIX, OP, STRING_NAME) \ CASE_TYPE(PREFIX, OP, NODE_PATH) \ CASE_TYPE(PREFIX, OP, _RID) \ CASE_TYPE(PREFIX, OP, OBJECT) \ @@ -88,6 +89,7 @@ TYPE(PREFIX, OP, BASIS), \ TYPE(PREFIX, OP, TRANSFORM), \ TYPE(PREFIX, OP, COLOR), \ + TYPE(PREFIX, OP, STRING_NAME), \ TYPE(PREFIX, OP, NODE_PATH), \ TYPE(PREFIX, OP, _RID), \ TYPE(PREFIX, OP, OBJECT), \ @@ -236,23 +238,35 @@ bool Variant::booleanize() const { _RETURN_FAIL \ }; -#define DEFAULT_OP_STR_REV(m_prefix, m_op_name, m_name, m_op, m_type) \ - CASE_TYPE(m_prefix, m_op_name, m_name) { \ - if (p_b.type == STRING) _RETURN(*reinterpret_cast<const m_type *>(p_b._data._mem) m_op *reinterpret_cast<const String *>(p_a._data._mem)); \ - if (p_b.type == NODE_PATH) _RETURN(*reinterpret_cast<const m_type *>(p_b._data._mem) m_op *reinterpret_cast<const NodePath *>(p_a._data._mem)); \ - \ - _RETURN_FAIL \ +#define DEFAULT_OP_STR_REV(m_prefix, m_op_name, m_name, m_op, m_type) \ + CASE_TYPE(m_prefix, m_op_name, m_name) { \ + if (p_b.type == STRING) _RETURN(*reinterpret_cast<const m_type *>(p_b._data._mem) m_op *reinterpret_cast<const String *>(p_a._data._mem)); \ + if (p_b.type == STRING_NAME) _RETURN(*reinterpret_cast<const m_type *>(p_b._data._mem) m_op *reinterpret_cast<const StringName *>(p_a._data._mem)); \ + if (p_b.type == NODE_PATH) _RETURN(*reinterpret_cast<const m_type *>(p_b._data._mem) m_op *reinterpret_cast<const NodePath *>(p_a._data._mem)); \ + \ + _RETURN_FAIL \ }; -#define DEFAULT_OP_STR(m_prefix, m_op_name, m_name, m_op, m_type) \ - CASE_TYPE(m_prefix, m_op_name, m_name) { \ - if (p_b.type == STRING) _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const String *>(p_b._data._mem)); \ - if (p_b.type == NODE_PATH) _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const NodePath *>(p_b._data._mem)); \ - \ - _RETURN_FAIL \ +#define DEFAULT_OP_STR(m_prefix, m_op_name, m_name, m_op, m_type) \ + CASE_TYPE(m_prefix, m_op_name, m_name) { \ + if (p_b.type == STRING) _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const String *>(p_b._data._mem)); \ + if (p_b.type == STRING_NAME) _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const StringName *>(p_b._data._mem)); \ + if (p_b.type == NODE_PATH) _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const NodePath *>(p_b._data._mem)); \ + \ + _RETURN_FAIL \ + }; + +#define DEFAULT_OP_STR_NULL(m_prefix, m_op_name, m_name, m_op, m_type) \ + CASE_TYPE(m_prefix, m_op_name, m_name) { \ + if (p_b.type == STRING) _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const String *>(p_b._data._mem)); \ + if (p_b.type == STRING_NAME) _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const StringName *>(p_b._data._mem)); \ + if (p_b.type == NODE_PATH) _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const NodePath *>(p_b._data._mem)); \ + if (p_b.type == NIL) _RETURN(!(p_b.type m_op NIL)); \ + \ + _RETURN_FAIL \ }; -#define DEFAULT_OP_STR_NULL(m_prefix, m_op_name, m_name, m_op, m_type) \ +#define DEFAULT_OP_STR_NULL_NP(m_prefix, m_op_name, m_name, m_op, m_type) \ CASE_TYPE(m_prefix, m_op_name, m_name) { \ if (p_b.type == STRING) _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const String *>(p_b._data._mem)); \ if (p_b.type == NODE_PATH) _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const NodePath *>(p_b._data._mem)); \ @@ -261,6 +275,15 @@ bool Variant::booleanize() const { _RETURN_FAIL \ }; +#define DEFAULT_OP_STR_NULL_SN(m_prefix, m_op_name, m_name, m_op, m_type) \ + CASE_TYPE(m_prefix, m_op_name, m_name) { \ + if (p_b.type == STRING) _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const String *>(p_b._data._mem)); \ + if (p_b.type == STRING_NAME) _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const StringName *>(p_b._data._mem)); \ + if (p_b.type == NIL) _RETURN(!(p_b.type m_op NIL)); \ + \ + _RETURN_FAIL \ + }; + #define DEFAULT_OP_LOCALMEM_REV(m_prefix, m_op_name, m_name, m_op, m_type) \ CASE_TYPE(m_prefix, m_op_name, m_name) { \ if (p_b.type == m_name) \ @@ -477,7 +500,8 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, BASIS, ==, _basis); DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, TRANSFORM, ==, _transform); DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, COLOR, ==, Color); - DEFAULT_OP_STR_NULL(math, OP_EQUAL, NODE_PATH, ==, NodePath); + DEFAULT_OP_STR_NULL_SN(math, OP_EQUAL, STRING_NAME, ==, StringName); + DEFAULT_OP_STR_NULL_NP(math, OP_EQUAL, NODE_PATH, ==, NodePath); DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, _RID, ==, RID); DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_BYTE_ARRAY, uint8_t); @@ -570,7 +594,8 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, BASIS, !=, _basis); DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, TRANSFORM, !=, _transform); DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, COLOR, !=, Color); - DEFAULT_OP_STR_NULL(math, OP_NOT_EQUAL, NODE_PATH, !=, NodePath); + DEFAULT_OP_STR_NULL_SN(math, OP_NOT_EQUAL, STRING_NAME, !=, StringName); + DEFAULT_OP_STR_NULL_NP(math, OP_NOT_EQUAL, NODE_PATH, !=, NodePath); DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, _RID, !=, RID); DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_BYTE_ARRAY, uint8_t); @@ -647,6 +672,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_LESS, BASIS) CASE_TYPE(math, OP_LESS, TRANSFORM) CASE_TYPE(math, OP_LESS, COLOR) + CASE_TYPE(math, OP_LESS, STRING_NAME) CASE_TYPE(math, OP_LESS, NODE_PATH) CASE_TYPE(math, OP_LESS, DICTIONARY) _RETURN_FAIL; @@ -676,6 +702,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_LESS_EQUAL, BASIS) CASE_TYPE(math, OP_LESS_EQUAL, TRANSFORM) CASE_TYPE(math, OP_LESS_EQUAL, COLOR) + CASE_TYPE(math, OP_LESS_EQUAL, STRING_NAME) CASE_TYPE(math, OP_LESS_EQUAL, NODE_PATH) CASE_TYPE(math, OP_LESS_EQUAL, CALLABLE) CASE_TYPE(math, OP_LESS_EQUAL, SIGNAL) @@ -754,6 +781,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_GREATER, BASIS) CASE_TYPE(math, OP_GREATER, TRANSFORM) CASE_TYPE(math, OP_GREATER, COLOR) + CASE_TYPE(math, OP_GREATER, STRING_NAME) CASE_TYPE(math, OP_GREATER, NODE_PATH) CASE_TYPE(math, OP_GREATER, DICTIONARY) CASE_TYPE(math, OP_GREATER, CALLABLE) @@ -786,6 +814,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_GREATER_EQUAL, BASIS) CASE_TYPE(math, OP_GREATER_EQUAL, TRANSFORM) CASE_TYPE(math, OP_GREATER_EQUAL, COLOR) + CASE_TYPE(math, OP_GREATER_EQUAL, STRING_NAME) CASE_TYPE(math, OP_GREATER_EQUAL, NODE_PATH) CASE_TYPE(math, OP_GREATER_EQUAL, CALLABLE) CASE_TYPE(math, OP_GREATER_EQUAL, SIGNAL) @@ -844,6 +873,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_ADD, AABB) CASE_TYPE(math, OP_ADD, BASIS) CASE_TYPE(math, OP_ADD, TRANSFORM) + CASE_TYPE(math, OP_ADD, STRING_NAME) CASE_TYPE(math, OP_ADD, NODE_PATH) CASE_TYPE(math, OP_ADD, _RID) CASE_TYPE(math, OP_ADD, OBJECT) @@ -871,6 +901,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_SUBTRACT, AABB) CASE_TYPE(math, OP_SUBTRACT, BASIS) CASE_TYPE(math, OP_SUBTRACT, TRANSFORM) + CASE_TYPE(math, OP_SUBTRACT, STRING_NAME) CASE_TYPE(math, OP_SUBTRACT, NODE_PATH) CASE_TYPE(math, OP_SUBTRACT, _RID) CASE_TYPE(math, OP_SUBTRACT, OBJECT) @@ -953,6 +984,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_MULTIPLY, RECT2) CASE_TYPE(math, OP_MULTIPLY, PLANE) CASE_TYPE(math, OP_MULTIPLY, AABB) + CASE_TYPE(math, OP_MULTIPLY, STRING_NAME) CASE_TYPE(math, OP_MULTIPLY, NODE_PATH) CASE_TYPE(math, OP_MULTIPLY, _RID) CASE_TYPE(math, OP_MULTIPLY, OBJECT) @@ -999,6 +1031,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_DIVIDE, AABB) CASE_TYPE(math, OP_DIVIDE, BASIS) CASE_TYPE(math, OP_DIVIDE, TRANSFORM) + CASE_TYPE(math, OP_DIVIDE, STRING_NAME) CASE_TYPE(math, OP_DIVIDE, NODE_PATH) CASE_TYPE(math, OP_DIVIDE, _RID) CASE_TYPE(math, OP_DIVIDE, OBJECT) @@ -1034,6 +1067,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_POSITIVE, BASIS) CASE_TYPE(math, OP_POSITIVE, TRANSFORM) CASE_TYPE(math, OP_POSITIVE, COLOR) + CASE_TYPE(math, OP_POSITIVE, STRING_NAME) CASE_TYPE(math, OP_POSITIVE, NODE_PATH) CASE_TYPE(math, OP_POSITIVE, _RID) CASE_TYPE(math, OP_POSITIVE, OBJECT) @@ -1070,6 +1104,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_NEGATE, AABB) CASE_TYPE(math, OP_NEGATE, BASIS) CASE_TYPE(math, OP_NEGATE, TRANSFORM) + CASE_TYPE(math, OP_NEGATE, STRING_NAME) CASE_TYPE(math, OP_NEGATE, NODE_PATH) CASE_TYPE(math, OP_NEGATE, _RID) CASE_TYPE(math, OP_NEGATE, OBJECT) @@ -1133,6 +1168,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_MODULE, BASIS) CASE_TYPE(math, OP_MODULE, TRANSFORM) CASE_TYPE(math, OP_MODULE, COLOR) + CASE_TYPE(math, OP_MODULE, STRING_NAME) CASE_TYPE(math, OP_MODULE, NODE_PATH) CASE_TYPE(math, OP_MODULE, _RID) CASE_TYPE(math, OP_MODULE, OBJECT) @@ -2204,6 +2240,8 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } } break; + case STRING_NAME: { + } break; // 15 case NODE_PATH: { } break; // 15 case _RID: { @@ -2223,7 +2261,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } #endif - if (p_index.get_type() != Variant::STRING) { + if (p_index.get_type() != Variant::STRING_NAME && p_index.get_type() != Variant::STRING) { obj->setvar(p_index, p_value, r_valid); return; } @@ -2578,6 +2616,8 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } } break; + case STRING_NAME: { + } break; // 15 case NODE_PATH: { } break; // 15 case _RID: { @@ -2912,6 +2952,8 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::INT, "a8")); } break; + case STRING_NAME: { + } break; // 15 case NODE_PATH: { } break; // 15 case _RID: { @@ -3682,6 +3724,10 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & r_dst = reinterpret_cast<const Color *>(a._data._mem)->linear_interpolate(*reinterpret_cast<const Color *>(b._data._mem), c); } return; + case STRING_NAME: { + r_dst = a; + } + return; case NODE_PATH: { r_dst = a; } diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index f036e00ed5..059dc161c7 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -81,6 +81,7 @@ const char *VariantParser::tk_name[TK_MAX] = { "')'", "identifier", "string", + "string_name", "number", "color", "':'", @@ -93,6 +94,8 @@ const char *VariantParser::tk_name[TK_MAX] = { Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, String &r_err_str) { + bool string_name = false; + while (true) { CharType cchar; @@ -204,6 +207,17 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri r_token.type = TK_COLOR; return OK; }; + case '@': { + cchar = p_stream->get_char(); + if (cchar != '"') { + r_err_str = "Expected '\"' after '@'"; + r_token.type = TK_ERROR; + return ERR_PARSE_ERROR; + } + + string_name = true; + FALLTHROUGH; + } case '"': { String str; @@ -285,8 +299,14 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri if (p_stream->is_utf8()) { str.parse_utf8(str.ascii(true).get_data()); } - r_token.type = TK_STRING; - r_token.value = str; + if (string_name) { + r_token.type = TK_STRING_NAME; + r_token.value = StringName(str); + string_name = false; //reset + } else { + r_token.type = TK_STRING; + r_token.value = str; + } return OK; } break; @@ -1498,6 +1518,14 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, "Color( " + rtosfix(c.r) + ", " + rtosfix(c.g) + ", " + rtosfix(c.b) + ", " + rtosfix(c.a) + " )"); } break; + case Variant::STRING_NAME: { + + String str = p_variant; + + str = "@\"" + str.c_escape() + "\""; + p_store_string_func(p_store_string_ud, str); + + } break; case Variant::NODE_PATH: { String str = p_variant; diff --git a/core/variant_parser.h b/core/variant_parser.h index 89db3ada0d..ad0a4d6682 100644 --- a/core/variant_parser.h +++ b/core/variant_parser.h @@ -92,6 +92,7 @@ public: TK_PARENTHESIS_CLOSE, TK_IDENTIFIER, TK_STRING, + TK_STRING_NAME, TK_NUMBER, TK_COLOR, TK_COLON, diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index b538161443..f5c7b91a99 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -593,7 +593,7 @@ public: } break; case Animation::TYPE_METHOD: { - p_list->push_back(PropertyInfo(Variant::STRING, "name")); + p_list->push_back(PropertyInfo(Variant::STRING_NAME, "name")); p_list->push_back(PropertyInfo(Variant::INT, "arg_count", PROPERTY_HINT_RANGE, "0,5,1")); Dictionary d = animation->track_get_key_value(track, key); @@ -654,7 +654,7 @@ public: } animations += "[stop]"; - p_list->push_back(PropertyInfo(Variant::STRING, "animation", PROPERTY_HINT_ENUM, animations)); + p_list->push_back(PropertyInfo(Variant::STRING_NAME, "animation", PROPERTY_HINT_ENUM, animations)); } break; } @@ -1293,7 +1293,7 @@ public: } break; case Animation::TYPE_METHOD: { - p_list->push_back(PropertyInfo(Variant::STRING, "name")); + p_list->push_back(PropertyInfo(Variant::STRING_NAME, "name")); p_list->push_back(PropertyInfo(Variant::INT, "arg_count", PROPERTY_HINT_RANGE, "0,5,1")); Dictionary d = animation->track_get_key_value(first_track, first_key); @@ -1354,7 +1354,7 @@ public: } animations += "[stop]"; - p_list->push_back(PropertyInfo(Variant::STRING, "animation", PROPERTY_HINT_ENUM, animations)); + p_list->push_back(PropertyInfo(Variant::STRING_NAME, "animation", PROPERTY_HINT_ENUM, animations)); } break; } } diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 69a19b3e83..b309a16858 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -168,6 +168,7 @@ void ConnectDialog::_add_bind() { case Variant::INT: value = 0; break; case Variant::REAL: value = 0.0; break; case Variant::STRING: value = ""; break; + case Variant::STRING_NAME: value = ""; break; case Variant::VECTOR2: value = Vector2(); break; case Variant::RECT2: value = Rect2(); break; case Variant::VECTOR3: value = Vector3(); break; @@ -415,6 +416,7 @@ ConnectDialog::ConnectDialog() { type_list->add_item("int", Variant::INT); type_list->add_item("real", Variant::REAL); type_list->add_item("String", Variant::STRING); + type_list->add_item("StringName", Variant::STRING_NAME); type_list->add_item("Vector2", Variant::VECTOR2); type_list->add_item("Rect2", Variant::RECT2); type_list->add_item("Vector3", Variant::VECTOR3); diff --git a/editor/doc/doc_dump.cpp b/editor/doc/doc_dump.cpp index 4763091b8e..4bcf0c5bf5 100644 --- a/editor/doc/doc_dump.cpp +++ b/editor/doc/doc_dump.cpp @@ -165,6 +165,9 @@ void DocDump::dump(const String &p_file) { //keep it break; case Variant::STRING: + case Variant::STRING_NAME: + default_arg_text = "@\"" + default_arg_text + "\""; + break; case Variant::NODE_PATH: default_arg_text = "\"" + default_arg_text + "\""; break; diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index 0d53cb5189..32fadfc60e 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -534,7 +534,7 @@ void EditorFeatureProfileManager::_class_list_item_selected() { } Variant md = item->get_metadata(0); - if (md.get_type() != Variant::STRING) { + if (md.get_type() != Variant::STRING && md.get_type() != Variant::STRING_NAME) { return; } @@ -598,7 +598,7 @@ void EditorFeatureProfileManager::_class_list_item_edited() { bool checked = item->is_checked(0); Variant md = item->get_metadata(0); - if (md.get_type() == Variant::STRING) { + if (md.get_type() == Variant::STRING || md.get_type() == Variant::STRING_NAME) { String class_selected = md; edited->set_disable_class(class_selected, !checked); _save_and_update(); @@ -620,7 +620,7 @@ void EditorFeatureProfileManager::_property_item_edited() { } Variant md = class_item->get_metadata(0); - if (md.get_type() != Variant::STRING) { + if (md.get_type() != Variant::STRING && md.get_type() != Variant::STRING_NAME) { return; } @@ -633,7 +633,7 @@ void EditorFeatureProfileManager::_property_item_edited() { bool checked = item->is_checked(0); md = item->get_metadata(0); - if (md.get_type() == Variant::STRING) { + if (md.get_type() == Variant::STRING || md.get_type() == Variant::STRING_NAME) { String property_selected = md; edited->set_disable_class_property(class_name, property_selected, !checked); _save_and_update(); @@ -657,7 +657,7 @@ void EditorFeatureProfileManager::_update_selected_profile() { if (class_list->get_selected()) { Variant md = class_list->get_selected()->get_metadata(0); - if (md.get_type() == Variant::STRING) { + if (md.get_type() == Variant::STRING || md.get_type() == Variant::STRING_NAME) { class_selected = md; } else if (md.get_type() == Variant::INT) { feature_selected = md; diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 2ed5686a21..c3daf39b48 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -828,13 +828,13 @@ void EditorProperty::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "checked"), "set_checked", "is_checked"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_red"), "set_draw_red", "is_draw_red"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keying"), "set_keying", "is_keying"); - ADD_SIGNAL(MethodInfo("property_changed", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::NIL, "value", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT))); + ADD_SIGNAL(MethodInfo("property_changed", PropertyInfo(Variant::STRING_NAME, "property"), PropertyInfo(Variant::NIL, "value", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT))); ADD_SIGNAL(MethodInfo("multiple_properties_changed", PropertyInfo(Variant::PACKED_STRING_ARRAY, "properties"), PropertyInfo(Variant::ARRAY, "value"))); - ADD_SIGNAL(MethodInfo("property_keyed", PropertyInfo(Variant::STRING, "property"))); - ADD_SIGNAL(MethodInfo("property_keyed_with_value", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::NIL, "value", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT))); - ADD_SIGNAL(MethodInfo("property_checked", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::STRING, "bool"))); + ADD_SIGNAL(MethodInfo("property_keyed", PropertyInfo(Variant::STRING_NAME, "property"))); + ADD_SIGNAL(MethodInfo("property_keyed_with_value", PropertyInfo(Variant::STRING_NAME, "property"), PropertyInfo(Variant::NIL, "value", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT))); + ADD_SIGNAL(MethodInfo("property_checked", PropertyInfo(Variant::STRING_NAME, "property"), PropertyInfo(Variant::STRING, "bool"))); ADD_SIGNAL(MethodInfo("resource_selected", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource"))); - ADD_SIGNAL(MethodInfo("object_id_selected", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::INT, "id"))); + ADD_SIGNAL(MethodInfo("object_id_selected", PropertyInfo(Variant::STRING_NAME, "property"), PropertyInfo(Variant::INT, "id"))); ADD_SIGNAL(MethodInfo("selected", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::INT, "focusable_idx"))); MethodInfo vm; diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 7ac321019a..b18c6fc59f 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -64,7 +64,11 @@ void EditorPropertyText::_text_changed(const String &p_string) { if (updating) return; - emit_changed(get_edited_property(), p_string, "", true); + if (string_name) { + emit_changed(get_edited_property(), StringName(p_string), "", true); + } else { + emit_changed(get_edited_property(), p_string, "", true); + } } void EditorPropertyText::update_property() { @@ -75,6 +79,9 @@ void EditorPropertyText::update_property() { updating = false; } +void EditorPropertyText::set_string_name(bool p_enabled) { + string_name = p_enabled; +} void EditorPropertyText::set_placeholder(const String &p_string) { text->set_placeholder(p_string); } @@ -92,6 +99,7 @@ EditorPropertyText::EditorPropertyText() { text->connect_compat("text_changed", this, "_text_changed"); text->connect_compat("text_entered", this, "_text_entered"); + string_name = false; updating = false; } @@ -172,7 +180,12 @@ EditorPropertyMultilineText::EditorPropertyMultilineText() { void EditorPropertyTextEnum::_option_selected(int p_which) { - emit_changed(get_edited_property(), options->get_item_text(p_which)); + if (string_name) { + + emit_changed(get_edited_property(), StringName(options->get_item_text(p_which))); + } else { + emit_changed(get_edited_property(), options->get_item_text(p_which)); + } } void EditorPropertyTextEnum::update_property() { @@ -187,10 +200,11 @@ void EditorPropertyTextEnum::update_property() { } } -void EditorPropertyTextEnum::setup(const Vector<String> &p_options) { +void EditorPropertyTextEnum::setup(const Vector<String> &p_options, bool p_string_name) { for (int i = 0; i < p_options.size(); i++) { options->add_item(p_options[i], i); } + string_name = p_string_name; } void EditorPropertyTextEnum::_bind_methods() { @@ -202,6 +216,7 @@ EditorPropertyTextEnum::EditorPropertyTextEnum() { options = memnew(OptionButton); options->set_clip_text(true); options->set_flat(true); + string_name = false; add_child(options); add_focusable(options); @@ -3305,6 +3320,22 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ editor->setup(p_hint != PROPERTY_HINT_COLOR_NO_ALPHA); add_property_editor(p_path, editor); } break; + case Variant::STRING_NAME: { + + if (p_hint == PROPERTY_HINT_ENUM) { + EditorPropertyTextEnum *editor = memnew(EditorPropertyTextEnum); + Vector<String> options = p_hint_text.split(","); + editor->setup(options, true); + add_property_editor(p_path, editor); + } else { + EditorPropertyText *editor = memnew(EditorPropertyText); + if (p_hint == PROPERTY_HINT_PLACEHOLDER_TEXT) { + editor->set_placeholder(p_hint_text); + } + editor->set_string_name(true); + add_property_editor(p_path, editor); + } + } break; case Variant::NODE_PATH: { EditorPropertyNodePath *editor = memnew(EditorPropertyNodePath); diff --git a/editor/editor_properties.h b/editor/editor_properties.h index 7c343f1c67..c5fc8aaf77 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -53,6 +53,7 @@ class EditorPropertyText : public EditorProperty { LineEdit *text; bool updating; + bool string_name; void _text_changed(const String &p_string); void _text_entered(const String &p_string); @@ -60,6 +61,7 @@ protected: static void _bind_methods(); public: + void set_string_name(bool p_enabled); virtual void update_property(); void set_placeholder(const String &p_string); EditorPropertyText(); @@ -91,12 +93,13 @@ class EditorPropertyTextEnum : public EditorProperty { OptionButton *options; void _option_selected(int p_which); + bool string_name; protected: static void _bind_methods(); public: - void setup(const Vector<String> &p_options); + void setup(const Vector<String> &p_options, bool p_string_name = false); virtual void update_property(); EditorPropertyTextEnum(); }; diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index ba66586c81..53ee86c71e 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -804,6 +804,12 @@ void EditorPropertyDictionary::update_property() { prop = memnew(EditorPropertyColor); } break; + case Variant::STRING_NAME: { + EditorPropertyText *ept = memnew(EditorPropertyText); + ept->set_string_name(true); + prop = ept; + + } break; case Variant::NODE_PATH: { prop = memnew(EditorPropertyNodePath); diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp index 745dd37a5b..a39a778c82 100644 --- a/modules/gdscript/gdscript_tokenizer.cpp +++ b/modules/gdscript/gdscript_tokenizer.cpp @@ -160,6 +160,7 @@ static const _bit _type_list[] = { { Variant::COLOR, "Color" }, { Variant::_RID, "RID" }, { Variant::OBJECT, "Object" }, + { Variant::STRING_NAME, "StringName" }, { Variant::NODE_PATH, "NodePath" }, { Variant::DICTIONARY, "Dictionary" }, { Variant::CALLABLE, "Callable" }, @@ -477,7 +478,7 @@ void GDScriptTokenizerText::_advance() { } while (true) { - bool is_node_path = false; + bool is_string_name = false; StringMode string_mode = STRING_DOUBLE_QUOTE; switch (GETCHAR(0)) { @@ -751,7 +752,7 @@ void GDScriptTokenizerText::_advance() { return; } INCPOS(1); - is_node_path = true; + is_string_name = true; FALLTHROUGH; case '\'': case '"': { @@ -862,8 +863,8 @@ void GDScriptTokenizerText::_advance() { } INCPOS(i); - if (is_node_path) { - _make_constant(NodePath(str)); + if (is_string_name) { + _make_constant(StringName(str)); } else { _make_constant(str); } diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp index c11e7fd679..ef99be5b94 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite.cpp @@ -742,7 +742,7 @@ void AnimatedSprite::_bind_methods() { ADD_GROUP("Animation", ""); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "frames", PROPERTY_HINT_RESOURCE_TYPE, "SpriteFrames"), "set_sprite_frames", "get_sprite_frames"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "animation"), "set_animation", "get_animation"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "animation"), "set_animation", "get_animation"); ADD_PROPERTY(PropertyInfo(Variant::INT, "frame"), "set_frame", "get_frame"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "speed_scale"), "set_speed_scale", "get_speed_scale"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing"), "_set_playing", "_is_playing"); diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index bdf1f8b9ce..f5f1a2ed3c 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -674,7 +674,7 @@ void Area2D::_bind_methods() { ADD_GROUP("Audio Bus", "audio_bus_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "audio_bus_override"), "set_audio_bus_override", "is_overriding_audio_bus"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "audio_bus_name", PROPERTY_HINT_ENUM, ""), "set_audio_bus_name", "get_audio_bus_name"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "audio_bus_name", PROPERTY_HINT_ENUM, ""), "set_audio_bus_name", "get_audio_bus_name"); BIND_ENUM_CONSTANT(SPACE_OVERRIDE_DISABLED); BIND_ENUM_CONSTANT(SPACE_OVERRIDE_COMBINE); diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index 871099c2fc..8419600bef 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -522,7 +522,7 @@ void AudioStreamPlayer2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stream_paused", PROPERTY_HINT_NONE, ""), "set_stream_paused", "get_stream_paused"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_distance", PROPERTY_HINT_EXP_RANGE, "1,4096,1,or_greater"), "set_max_distance", "get_max_distance"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "attenuation", PROPERTY_HINT_EXP_EASING, "attenuation"), "set_attenuation", "get_attenuation"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus"); ADD_PROPERTY(PropertyInfo(Variant::INT, "area_mask", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_area_mask", "get_area_mask"); ADD_SIGNAL(MethodInfo("finished")); diff --git a/scene/2d/touch_screen_button.cpp b/scene/2d/touch_screen_button.cpp index ce54cae4b0..7ca165985e 100644 --- a/scene/2d/touch_screen_button.cpp +++ b/scene/2d/touch_screen_button.cpp @@ -404,7 +404,7 @@ void TouchScreenButton::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shape_centered"), "set_shape_centered", "is_shape_centered"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shape_visible"), "set_shape_visible", "is_shape_visible"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "passby_press"), "set_passby_press", "is_passby_press_enabled"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "action"), "set_action", "get_action"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "action"), "set_action", "get_action"); ADD_PROPERTY(PropertyInfo(Variant::INT, "visibility_mode", PROPERTY_HINT_ENUM, "Always,TouchScreen Only"), "set_visibility_mode", "get_visibility_mode"); ADD_SIGNAL(MethodInfo("pressed")); diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp index d88c088f72..e5dc3cbf65 100644 --- a/scene/3d/area.cpp +++ b/scene/3d/area.cpp @@ -719,10 +719,10 @@ void Area::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask"); ADD_GROUP("Audio Bus", "audio_bus_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "audio_bus_override"), "set_audio_bus_override", "is_overriding_audio_bus"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "audio_bus_name", PROPERTY_HINT_ENUM, ""), "set_audio_bus", "get_audio_bus"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "audio_bus_name", PROPERTY_HINT_ENUM, ""), "set_audio_bus", "get_audio_bus"); ADD_GROUP("Reverb Bus", "reverb_bus_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "reverb_bus_enable"), "set_use_reverb_bus", "is_using_reverb_bus"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "reverb_bus_name", PROPERTY_HINT_ENUM, ""), "set_reverb_bus", "get_reverb_bus"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "reverb_bus_name", PROPERTY_HINT_ENUM, ""), "set_reverb_bus", "get_reverb_bus"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "reverb_bus_amount", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_reverb_amount", "get_reverb_amount"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "reverb_bus_uniformity", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_reverb_uniformity", "get_reverb_uniformity"); diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index 21fd4d9a14..320457a3f2 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -1013,7 +1013,7 @@ void AudioStreamPlayer3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stream_paused", PROPERTY_HINT_NONE, ""), "set_stream_paused", "get_stream_paused"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_distance", PROPERTY_HINT_EXP_RANGE, "0,4096,1,or_greater"), "set_max_distance", "get_max_distance"); ADD_PROPERTY(PropertyInfo(Variant::INT, "out_of_range_mode", PROPERTY_HINT_ENUM, "Mix,Pause"), "set_out_of_range_mode", "get_out_of_range_mode"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus"); ADD_PROPERTY(PropertyInfo(Variant::INT, "area_mask", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_area_mask", "get_area_mask"); ADD_GROUP("Emission Angle", "emission_angle"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "emission_angle_enabled"), "set_emission_angle_enabled", "is_emission_angle_enabled"); diff --git a/scene/3d/bone_attachment.cpp b/scene/3d/bone_attachment.cpp index e94e174b92..b1cd9bfe8b 100644 --- a/scene/3d/bone_attachment.cpp +++ b/scene/3d/bone_attachment.cpp @@ -123,5 +123,5 @@ void BoneAttachment::_bind_methods() { ClassDB::bind_method(D_METHOD("set_bone_name", "bone_name"), &BoneAttachment::set_bone_name); ClassDB::bind_method(D_METHOD("get_bone_name"), &BoneAttachment::get_bone_name); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "bone_name"), "set_bone_name", "get_bone_name"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "bone_name"), "set_bone_name", "get_bone_name"); } diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index 7c7b0d49ad..6ffa94eed5 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -2054,10 +2054,10 @@ void PhysicalBone::_get_property_list(List<PropertyInfo> *p_list) const { names += parent->get_bone_name(i); } - p_list->push_back(PropertyInfo(Variant::STRING, "bone_name", PROPERTY_HINT_ENUM, names)); + p_list->push_back(PropertyInfo(Variant::STRING_NAME, "bone_name", PROPERTY_HINT_ENUM, names)); } else { - p_list->push_back(PropertyInfo(Variant::STRING, "bone_name")); + p_list->push_back(PropertyInfo(Variant::STRING_NAME, "bone_name")); } if (joint_data) { diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp index 660b5bc7da..3ef502cfd3 100644 --- a/scene/3d/skeleton.cpp +++ b/scene/3d/skeleton.cpp @@ -774,7 +774,8 @@ void Skeleton::physical_bones_start_simulation_on(const Array &p_bones) { sim_bones.resize(p_bones.size()); int c = 0; for (int i = sim_bones.size() - 1; 0 <= i; --i) { - if (Variant::STRING == p_bones.get(i).get_type()) { + Variant::Type type = p_bones.get(i).get_type(); + if (Variant::STRING == type || Variant::STRING_NAME == type) { int bone_id = find_bone(p_bones.get(i)); if (bone_id != -1) sim_bones.write[c++] = bone_id; diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 610ae7fb13..169ba78aca 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -1130,7 +1130,7 @@ void AnimatedSprite3D::_bind_methods() { ADD_SIGNAL(MethodInfo("frame_changed")); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "frames", PROPERTY_HINT_RESOURCE_TYPE, "SpriteFrames"), "set_sprite_frames", "get_sprite_frames"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "animation"), "set_animation", "get_animation"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "animation"), "set_animation", "get_animation"); ADD_PROPERTY(PropertyInfo(Variant::INT, "frame"), "set_frame", "get_frame"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing"), "_set_playing", "_is_playing"); } diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index bb6cd93878..cda17e5e88 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -126,7 +126,7 @@ void AnimationNodeAnimation::_bind_methods() { ClassDB::bind_method(D_METHOD("set_animation", "name"), &AnimationNodeAnimation::set_animation); ClassDB::bind_method(D_METHOD("get_animation"), &AnimationNodeAnimation::get_animation); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "animation"), "set_animation", "get_animation"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "animation"), "set_animation", "get_animation"); } AnimationNodeAnimation::AnimationNodeAnimation() { diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index 665060d899..9b608adf7a 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -120,7 +120,7 @@ void AnimationNodeStateMachineTransition::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "switch_mode", PROPERTY_HINT_ENUM, "Immediate,Sync,AtEnd"), "set_switch_mode", "get_switch_mode"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "auto_advance"), "set_auto_advance", "has_auto_advance"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "advance_condition"), "set_advance_condition", "get_advance_condition"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "advance_condition"), "set_advance_condition", "get_advance_condition"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "xfade_time", PROPERTY_HINT_RANGE, "0,240,0.01"), "set_xfade_time", "get_xfade_time"); ADD_PROPERTY(PropertyInfo(Variant::INT, "priority", PROPERTY_HINT_RANGE, "0,32,1"), "set_priority", "get_priority"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disabled"), "set_disabled", "is_disabled"); @@ -926,8 +926,8 @@ void AnimationNodeStateMachine::_get_property_list(List<PropertyInfo> *p_list) c } p_list->push_back(PropertyInfo(Variant::ARRAY, "transitions", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); - p_list->push_back(PropertyInfo(Variant::STRING, "start_node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); - p_list->push_back(PropertyInfo(Variant::STRING, "end_node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); + p_list->push_back(PropertyInfo(Variant::STRING_NAME, "start_node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); + p_list->push_back(PropertyInfo(Variant::STRING_NAME, "end_node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); p_list->push_back(PropertyInfo(Variant::VECTOR2, "graph_offset", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); } diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index eb9b5e3aa7..c607203e18 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -1682,9 +1682,9 @@ void AnimationPlayer::_bind_methods() { ClassDB::bind_method(D_METHOD("advance", "delta"), &AnimationPlayer::advance); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "root_node"), "set_root", "get_root"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "current_animation", PROPERTY_HINT_ENUM, "", PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_ANIMATE_AS_TRIGGER), "set_current_animation", "get_current_animation"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "assigned_animation", PROPERTY_HINT_NONE, "", 0), "set_assigned_animation", "get_assigned_animation"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "autoplay", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_autoplay", "get_autoplay"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "current_animation", PROPERTY_HINT_ENUM, "", PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_ANIMATE_AS_TRIGGER), "set_current_animation", "get_current_animation"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "assigned_animation", PROPERTY_HINT_NONE, "", 0), "set_assigned_animation", "get_assigned_animation"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "autoplay", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_autoplay", "get_autoplay"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "current_animation_length", PROPERTY_HINT_NONE, "", 0), "", "get_current_animation_length"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "current_animation_position", PROPERTY_HINT_NONE, "", 0), "", "get_current_animation_position"); @@ -1695,9 +1695,9 @@ void AnimationPlayer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "playback_speed", PROPERTY_HINT_RANGE, "-64,64,0.01"), "set_speed_scale", "get_speed_scale"); ADD_PROPERTY(PropertyInfo(Variant::INT, "method_call_mode", PROPERTY_HINT_ENUM, "Deferred,Immediate"), "set_method_call_mode", "get_method_call_mode"); - ADD_SIGNAL(MethodInfo("animation_finished", PropertyInfo(Variant::STRING, "anim_name"))); - ADD_SIGNAL(MethodInfo("animation_changed", PropertyInfo(Variant::STRING, "old_name"), PropertyInfo(Variant::STRING, "new_name"))); - ADD_SIGNAL(MethodInfo("animation_started", PropertyInfo(Variant::STRING, "anim_name"))); + ADD_SIGNAL(MethodInfo("animation_finished", PropertyInfo(Variant::STRING_NAME, "anim_name"))); + ADD_SIGNAL(MethodInfo("animation_changed", PropertyInfo(Variant::STRING_NAME, "old_name"), PropertyInfo(Variant::STRING_NAME, "new_name"))); + ADD_SIGNAL(MethodInfo("animation_started", PropertyInfo(Variant::STRING_NAME, "anim_name"))); ADD_SIGNAL(MethodInfo("caches_cleared")); BIND_ENUM_CONSTANT(ANIMATION_PROCESS_PHYSICS); diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index 7c6c8ba408..93d61e2882 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -433,13 +433,13 @@ void AnimationNode::_bind_methods() { BIND_VMETHOD(MethodInfo(Variant::ARRAY, "get_parameter_list")); BIND_VMETHOD(MethodInfo(Variant::OBJECT, "get_child_by_name", PropertyInfo(Variant::STRING, "name"))); { - MethodInfo mi = MethodInfo(Variant::NIL, "get_parameter_default_value", PropertyInfo(Variant::STRING, "name")); + MethodInfo mi = MethodInfo(Variant::NIL, "get_parameter_default_value", PropertyInfo(Variant::STRING_NAME, "name")); mi.return_val.usage = PROPERTY_USAGE_NIL_IS_VARIANT; BIND_VMETHOD(mi); } BIND_VMETHOD(MethodInfo("process", PropertyInfo(Variant::REAL, "time"), PropertyInfo(Variant::BOOL, "seek"))); BIND_VMETHOD(MethodInfo(Variant::STRING, "get_caption")); - BIND_VMETHOD(MethodInfo(Variant::STRING, "has_filter")); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "has_filter")); ADD_SIGNAL(MethodInfo("removed_from_graph")); diff --git a/scene/animation/skeleton_ik.cpp b/scene/animation/skeleton_ik.cpp index 518c243dd0..cfda90a558 100644 --- a/scene/animation/skeleton_ik.cpp +++ b/scene/animation/skeleton_ik.cpp @@ -390,8 +390,8 @@ void SkeletonIK::_bind_methods() { ClassDB::bind_method(D_METHOD("start", "one_time"), &SkeletonIK::start, DEFVAL(false)); ClassDB::bind_method(D_METHOD("stop"), &SkeletonIK::stop); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "root_bone"), "set_root_bone", "get_root_bone"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "tip_bone"), "set_tip_bone", "get_tip_bone"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "root_bone"), "set_root_bone", "get_root_bone"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "tip_bone"), "set_tip_bone", "get_tip_bone"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "interpolation", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_interpolation", "get_interpolation"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "target"), "set_target_transform", "get_target_transform"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "override_tip_basis"), "set_override_tip_basis", "is_override_tip_basis"); diff --git a/scene/audio/audio_stream_player.cpp b/scene/audio/audio_stream_player.cpp index 1415be5397..a0c67efc4e 100644 --- a/scene/audio/audio_stream_player.cpp +++ b/scene/audio/audio_stream_player.cpp @@ -417,7 +417,7 @@ void AudioStreamPlayer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "is_autoplay_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stream_paused", PROPERTY_HINT_NONE, ""), "set_stream_paused", "get_stream_paused"); ADD_PROPERTY(PropertyInfo(Variant::INT, "mix_target", PROPERTY_HINT_ENUM, "Stereo,Surround,Center"), "set_mix_target", "get_mix_target"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus"); ADD_SIGNAL(MethodInfo("finished")); diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 74a82faf28..152738420a 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -565,7 +565,7 @@ void AcceptDialog::_bind_methods() { ClassDB::bind_method(D_METHOD("has_autowrap"), &AcceptDialog::has_autowrap); ADD_SIGNAL(MethodInfo("confirmed")); - ADD_SIGNAL(MethodInfo("custom_action", PropertyInfo(Variant::STRING, "action"))); + ADD_SIGNAL(MethodInfo("custom_action", PropertyInfo(Variant::STRING_NAME, "action"))); ADD_GROUP("Dialog", "dialog"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "dialog_text", PROPERTY_HINT_MULTILINE_TEXT, "", PROPERTY_USAGE_DEFAULT_INTL), "set_text", "get_text"); diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 3c434e336c..a325859625 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -1317,15 +1317,15 @@ void GraphEdit::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_snap"), "set_use_snap", "is_using_snap"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "zoom"), "set_zoom", "get_zoom"); - ADD_SIGNAL(MethodInfo("connection_request", PropertyInfo(Variant::STRING, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::STRING, "to"), PropertyInfo(Variant::INT, "to_slot"))); - ADD_SIGNAL(MethodInfo("disconnection_request", PropertyInfo(Variant::STRING, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::STRING, "to"), PropertyInfo(Variant::INT, "to_slot"))); + ADD_SIGNAL(MethodInfo("connection_request", PropertyInfo(Variant::STRING_NAME, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::STRING_NAME, "to"), PropertyInfo(Variant::INT, "to_slot"))); + ADD_SIGNAL(MethodInfo("disconnection_request", PropertyInfo(Variant::STRING_NAME, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::STRING_NAME, "to"), PropertyInfo(Variant::INT, "to_slot"))); ADD_SIGNAL(MethodInfo("popup_request", PropertyInfo(Variant::VECTOR2, "position"))); ADD_SIGNAL(MethodInfo("duplicate_nodes_request")); ADD_SIGNAL(MethodInfo("copy_nodes_request")); ADD_SIGNAL(MethodInfo("paste_nodes_request")); ADD_SIGNAL(MethodInfo("node_selected", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"))); - ADD_SIGNAL(MethodInfo("connection_to_empty", PropertyInfo(Variant::STRING, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::VECTOR2, "release_position"))); - ADD_SIGNAL(MethodInfo("connection_from_empty", PropertyInfo(Variant::STRING, "to"), PropertyInfo(Variant::INT, "to_slot"), PropertyInfo(Variant::VECTOR2, "release_position"))); + ADD_SIGNAL(MethodInfo("connection_to_empty", PropertyInfo(Variant::STRING_NAME, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::VECTOR2, "release_position"))); + ADD_SIGNAL(MethodInfo("connection_from_empty", PropertyInfo(Variant::STRING_NAME, "to"), PropertyInfo(Variant::INT, "to_slot"), PropertyInfo(Variant::VECTOR2, "release_position"))); ADD_SIGNAL(MethodInfo("delete_nodes_request")); ADD_SIGNAL(MethodInfo("_begin_node_move")); ADD_SIGNAL(MethodInfo("_end_node_move")); diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index d9ca940177..0a11b94f48 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -737,10 +737,10 @@ Variant TreeItem::_call_recursive_bind(const Variant **p_args, int p_argcount, C return Variant(); } - if (p_args[0]->get_type() != Variant::STRING) { + if (p_args[0]->get_type() != Variant::STRING && p_args[0]->get_type() != Variant::STRING_NAME) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument = 0; - r_error.expected = Variant::STRING; + r_error.expected = Variant::STRING_NAME; return Variant(); } @@ -861,7 +861,7 @@ void TreeItem::_bind_methods() { { MethodInfo mi; mi.name = "call_recursive"; - mi.arguments.push_back(PropertyInfo(Variant::STRING, "method")); + mi.arguments.push_back(PropertyInfo(Variant::STRING_NAME, "method")); ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "call_recursive", &TreeItem::_call_recursive_bind, mi); } diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index 3d8112b986..89f8fbe648 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -481,7 +481,7 @@ void VideoPlayer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "buffering_msec", PROPERTY_HINT_RANGE, "10,1000"), "set_buffering_msec", "get_buffering_msec"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "stream_position", PROPERTY_HINT_RANGE, "0,1280000,0.1", 0), "set_stream_position", "get_stream_position"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus"); } VideoPlayer::VideoPlayer() { diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 6556dd6d6c..7b10a4dc2f 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -2904,7 +2904,7 @@ void Node::_bind_methods() { { MethodInfo mi; - mi.arguments.push_back(PropertyInfo(Variant::STRING, "method")); + mi.arguments.push_back(PropertyInfo(Variant::STRING_NAME, "method")); mi.name = "rpc"; ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "rpc", &Node::_rpc_bind, mi); @@ -2976,7 +2976,7 @@ void Node::_bind_methods() { ADD_GROUP("Pause", "pause_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "pause_mode", PROPERTY_HINT_ENUM, "Inherit,Stop,Process"), "set_pause_mode", "get_pause_mode"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "name", PROPERTY_HINT_NONE, "", 0), "set_name", "get_name"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "name", PROPERTY_HINT_NONE, "", 0), "set_name", "get_name"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "filename", PROPERTY_HINT_NONE, "", 0), "set_filename", "get_filename"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "owner", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_owner", "get_owner"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multiplayer", PROPERTY_HINT_RESOURCE_TYPE, "MultiplayerAPI", 0), "", "get_multiplayer"); diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 9f9dace9f9..f27415ee6f 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -1011,8 +1011,8 @@ Variant SceneTree::_call_group_flags(const Variant **p_args, int p_argcount, Cal ERR_FAIL_COND_V(p_argcount < 3, Variant()); ERR_FAIL_COND_V(!p_args[0]->is_num(), Variant()); - ERR_FAIL_COND_V(p_args[1]->get_type() != Variant::STRING, Variant()); - ERR_FAIL_COND_V(p_args[2]->get_type() != Variant::STRING, Variant()); + ERR_FAIL_COND_V(p_args[1]->get_type() != Variant::STRING_NAME && p_args[1]->get_type() != Variant::STRING, Variant()); + ERR_FAIL_COND_V(p_args[2]->get_type() != Variant::STRING_NAME && p_args[2]->get_type() != Variant::STRING, Variant()); int flags = *p_args[0]; StringName group = *p_args[1]; @@ -1033,8 +1033,8 @@ Variant SceneTree::_call_group(const Variant **p_args, int p_argcount, Callable: r_error.error = Callable::CallError::CALL_OK; ERR_FAIL_COND_V(p_argcount < 2, Variant()); - ERR_FAIL_COND_V(p_args[0]->get_type() != Variant::STRING, Variant()); - ERR_FAIL_COND_V(p_args[1]->get_type() != Variant::STRING, Variant()); + ERR_FAIL_COND_V(p_args[0]->get_type() != Variant::STRING_NAME && p_args[0]->get_type() != Variant::STRING, Variant()); + ERR_FAIL_COND_V(p_args[1]->get_type() != Variant::STRING_NAME && p_args[1]->get_type() != Variant::STRING, Variant()); StringName group = *p_args[0]; StringName method = *p_args[1]; @@ -1485,8 +1485,8 @@ void SceneTree::_bind_methods() { MethodInfo mi; mi.name = "call_group_flags"; mi.arguments.push_back(PropertyInfo(Variant::INT, "flags")); - mi.arguments.push_back(PropertyInfo(Variant::STRING, "group")); - mi.arguments.push_back(PropertyInfo(Variant::STRING, "method")); + mi.arguments.push_back(PropertyInfo(Variant::STRING_NAME, "group")); + mi.arguments.push_back(PropertyInfo(Variant::STRING_NAME, "method")); ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "call_group_flags", &SceneTree::_call_group_flags, mi); @@ -1495,8 +1495,8 @@ void SceneTree::_bind_methods() { MethodInfo mi2; mi2.name = "call_group"; - mi2.arguments.push_back(PropertyInfo(Variant::STRING, "group")); - mi2.arguments.push_back(PropertyInfo(Variant::STRING, "method")); + mi2.arguments.push_back(PropertyInfo(Variant::STRING_NAME, "group")); + mi2.arguments.push_back(PropertyInfo(Variant::STRING_NAME, "method")); ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "call_group", &SceneTree::_call_group, mi2); diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 6177356e9a..dc3b18646e 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -1048,7 +1048,7 @@ void Animation::track_insert_key(int p_track, float p_time, const Variant &p_key ERR_FAIL_COND(p_key.get_type() != Variant::DICTIONARY); Dictionary d = p_key; - ERR_FAIL_COND(!d.has("method") || d["method"].get_type() != Variant::STRING); + ERR_FAIL_COND(!d.has("method") || (d["method"].get_type() != Variant::STRING_NAME && d["method"].get_type() != Variant::STRING)); ERR_FAIL_COND(!d.has("args") || !d["args"].is_array()); MethodKey k; diff --git a/scene/resources/skin.cpp b/scene/resources/skin.cpp index 28258c0b60..df0620b6c4 100644 --- a/scene/resources/skin.cpp +++ b/scene/resources/skin.cpp @@ -129,7 +129,7 @@ bool Skin::_get(const StringName &p_name, Variant &r_ret) const { void Skin::_get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::INT, "bind_count", PROPERTY_HINT_RANGE, "0,16384,1,or_greater")); for (int i = 0; i < get_bind_count(); i++) { - p_list->push_back(PropertyInfo(Variant::STRING, "bind/" + itos(i) + "/name", PROPERTY_HINT_RANGE, "0,16384,1,or_greater")); + p_list->push_back(PropertyInfo(Variant::STRING_NAME, "bind/" + itos(i) + "/name")); p_list->push_back(PropertyInfo(Variant::INT, "bind/" + itos(i) + "/bone", PROPERTY_HINT_RANGE, "0,16384,1,or_greater", get_bind_name(i) != StringName() ? PROPERTY_USAGE_NOEDITOR : PROPERTY_USAGE_DEFAULT)); p_list->push_back(PropertyInfo(Variant::TRANSFORM, "bind/" + itos(i) + "/pose")); } diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index 3f31dc13f8..d4eb4927b2 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -270,10 +270,10 @@ void VisualShaderNodeCustom::_bind_methods() { BIND_VMETHOD(MethodInfo(Variant::INT, "_get_return_icon_type")); BIND_VMETHOD(MethodInfo(Variant::INT, "_get_input_port_count")); BIND_VMETHOD(MethodInfo(Variant::INT, "_get_input_port_type", PropertyInfo(Variant::INT, "port"))); - BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_input_port_name", PropertyInfo(Variant::INT, "port"))); + BIND_VMETHOD(MethodInfo(Variant::STRING_NAME, "_get_input_port_name", PropertyInfo(Variant::INT, "port"))); BIND_VMETHOD(MethodInfo(Variant::INT, "_get_output_port_count")); BIND_VMETHOD(MethodInfo(Variant::INT, "_get_output_port_type", PropertyInfo(Variant::INT, "port"))); - BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_output_port_name", PropertyInfo(Variant::INT, "port"))); + BIND_VMETHOD(MethodInfo(Variant::STRING_NAME, "_get_output_port_name", PropertyInfo(Variant::INT, "port"))); BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_code", PropertyInfo(Variant::ARRAY, "input_vars"), PropertyInfo(Variant::ARRAY, "output_vars"), PropertyInfo(Variant::INT, "mode"), PropertyInfo(Variant::INT, "type"))); BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_global_code", PropertyInfo(Variant::INT, "mode"))); BIND_VMETHOD(MethodInfo(Variant::BOOL, "_is_highend")); @@ -1847,7 +1847,7 @@ void VisualShaderNodeInput::_bind_methods() { ClassDB::bind_method(D_METHOD("get_input_name"), &VisualShaderNodeInput::get_input_name); ClassDB::bind_method(D_METHOD("get_input_real_name"), &VisualShaderNodeInput::get_input_real_name); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "input_name", PROPERTY_HINT_ENUM, ""), "set_input_name", "get_input_name"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "input_name", PROPERTY_HINT_ENUM, ""), "set_input_name", "get_input_name"); ADD_SIGNAL(MethodInfo("input_type_changed")); } VisualShaderNodeInput::VisualShaderNodeInput() { @@ -2047,7 +2047,7 @@ void VisualShaderNodeUniform::_bind_methods() { ClassDB::bind_method(D_METHOD("set_uniform_name", "name"), &VisualShaderNodeUniform::set_uniform_name); ClassDB::bind_method(D_METHOD("get_uniform_name"), &VisualShaderNodeUniform::get_uniform_name); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "uniform_name"), "set_uniform_name", "get_uniform_name"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "uniform_name"), "set_uniform_name", "get_uniform_name"); } VisualShaderNodeUniform::VisualShaderNodeUniform() { diff --git a/servers/arvr_server.cpp b/servers/arvr_server.cpp index a5bb9f794d..96f1ff049b 100644 --- a/servers/arvr_server.cpp +++ b/servers/arvr_server.cpp @@ -75,11 +75,11 @@ void ARVRServer::_bind_methods() { BIND_ENUM_CONSTANT(RESET_BUT_KEEP_TILT); BIND_ENUM_CONSTANT(DONT_RESET_ROTATION); - ADD_SIGNAL(MethodInfo("interface_added", PropertyInfo(Variant::STRING, "interface_name"))); - ADD_SIGNAL(MethodInfo("interface_removed", PropertyInfo(Variant::STRING, "interface_name"))); + ADD_SIGNAL(MethodInfo("interface_added", PropertyInfo(Variant::STRING_NAME, "interface_name"))); + ADD_SIGNAL(MethodInfo("interface_removed", PropertyInfo(Variant::STRING_NAME, "interface_name"))); - ADD_SIGNAL(MethodInfo("tracker_added", PropertyInfo(Variant::STRING, "tracker_name"), PropertyInfo(Variant::INT, "type"), PropertyInfo(Variant::INT, "id"))); - ADD_SIGNAL(MethodInfo("tracker_removed", PropertyInfo(Variant::STRING, "tracker_name"), PropertyInfo(Variant::INT, "type"), PropertyInfo(Variant::INT, "id"))); + ADD_SIGNAL(MethodInfo("tracker_added", PropertyInfo(Variant::STRING_NAME, "tracker_name"), PropertyInfo(Variant::INT, "type"), PropertyInfo(Variant::INT, "id"))); + ADD_SIGNAL(MethodInfo("tracker_removed", PropertyInfo(Variant::STRING_NAME, "tracker_name"), PropertyInfo(Variant::INT, "type"), PropertyInfo(Variant::INT, "id"))); }; real_t ARVRServer::get_world_scale() const { diff --git a/servers/audio/effects/audio_effect_compressor.cpp b/servers/audio/effects/audio_effect_compressor.cpp index 1ef3bb9b10..701e17e0d6 100644 --- a/servers/audio/effects/audio_effect_compressor.cpp +++ b/servers/audio/effects/audio_effect_compressor.cpp @@ -236,7 +236,7 @@ void AudioEffectCompressor::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "attack_us", PROPERTY_HINT_RANGE, "20,2000,1"), "set_attack_us", "get_attack_us"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "release_ms", PROPERTY_HINT_RANGE, "20,2000,1"), "set_release_ms", "get_release_ms"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "mix", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_mix", "get_mix"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "sidechain", PROPERTY_HINT_ENUM), "set_sidechain", "get_sidechain"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "sidechain", PROPERTY_HINT_ENUM), "set_sidechain", "get_sidechain"); } AudioEffectCompressor::AudioEffectCompressor() { |