From 0e1f7e9f89e74ebf4b2dec04f26ffab13c32a237 Mon Sep 17 00:00:00 2001 From: Hristo Stamenov Date: Sun, 31 Jul 2022 11:07:48 +0300 Subject: Removed faulty function update after get_property_list. The function tried to rearrange properties but that lead to problems with duplication or deleted properties. Implemented the logic that that function did inside the get_property_list both for tool scripts and non-tool scripts. --- core/object/object.cpp | 2 - core/object/script_language.cpp | 25 +++++++++ core/object/script_language.h | 1 + core/object/script_language_extension.h | 8 +++ editor/editor_inspector.cpp | 98 +++------------------------------ editor/editor_inspector.h | 1 - modules/gdscript/gdscript.cpp | 42 ++++++++++---- modules/mono/csharp_script.cpp | 45 +++++++++++---- modules/visual_script/visual_script.cpp | 4 ++ 9 files changed, 110 insertions(+), 116 deletions(-) diff --git a/core/object/object.cpp b/core/object/object.cpp index 75dbe8872f..0fcd1c0e40 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -472,7 +472,6 @@ Variant Object::get_indexed(const Vector &p_names, bool *r_valid) co void Object::get_property_list(List *p_list, bool p_reversed) const { if (script_instance && p_reversed) { - p_list->push_back(PropertyInfo(Variant::NIL, "Script Variables", PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_CATEGORY)); script_instance->get_property_list(p_list); } @@ -503,7 +502,6 @@ void Object::get_property_list(List *p_list, bool p_reversed) cons } if (script_instance && !p_reversed) { - p_list->push_back(PropertyInfo(Variant::NIL, "Script Variables", PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_CATEGORY)); script_instance->get_property_list(p_list); } diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp index 226fd8b791..b06c2e8896 100644 --- a/core/object/script_language.cpp +++ b/core/object/script_language.cpp @@ -101,6 +101,31 @@ Dictionary Script::_get_script_constant_map() { return ret; } +#ifdef TOOLS_ENABLED + +PropertyInfo Script::get_class_category() const { + String path = get_path(); + String name; + + if (is_built_in()) { + if (get_name().is_empty()) { + name = TTR("Built-in script"); + } else { + name = vformat("%s (%s)", get_name(), TTR("Built-in")); + } + } else { + if (get_name().is_empty()) { + name = path.get_file(); + } else { + name = get_name(); + } + } + + return PropertyInfo(Variant::NIL, name, PROPERTY_HINT_NONE, path, PROPERTY_USAGE_CATEGORY); +} + +#endif // TOOLS_ENABLED + void Script::_bind_methods() { ClassDB::bind_method(D_METHOD("can_instantiate"), &Script::can_instantiate); //ClassDB::bind_method(D_METHOD("instance_create","base_object"),&Script::instance_create); diff --git a/core/object/script_language.h b/core/object/script_language.h index c9f8a4f828..f5f052b600 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -132,6 +132,7 @@ public: #ifdef TOOLS_ENABLED virtual Vector get_documentation() const = 0; + virtual PropertyInfo get_class_category() const; #endif // TOOLS_ENABLED virtual bool has_method(const StringName &p_method) const = 0; diff --git a/core/object/script_language_extension.h b/core/object/script_language_extension.h index 10eacfd9f7..2869f4ad98 100644 --- a/core/object/script_language_extension.h +++ b/core/object/script_language_extension.h @@ -663,6 +663,14 @@ public: if (native_info->get_property_list_func) { uint32_t pcount; const GDNativePropertyInfo *pinfo = native_info->get_property_list_func(instance, &pcount); + +#ifdef TOOLS_ENABLED + Ref