summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorHristo Stamenov <capitane71@gmail.com>2022-07-31 11:07:48 +0300
committerHristo Stamenov <capitane71@gmail.com>2022-08-03 21:45:16 +0300
commit0e1f7e9f89e74ebf4b2dec04f26ffab13c32a237 (patch)
treefd05f2fef5c5d6b9d30ec20fac8317e3125f0a5c /core
parent19e0e06dd08fd9dd89fb09e0fed1286eaae32945 (diff)
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.
Diffstat (limited to 'core')
-rw-r--r--core/object/object.cpp2
-rw-r--r--core/object/script_language.cpp25
-rw-r--r--core/object/script_language.h1
-rw-r--r--core/object/script_language_extension.h8
4 files changed, 34 insertions, 2 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<StringName> &p_names, bool *r_valid) co
void Object::get_property_list(List<PropertyInfo> *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<PropertyInfo> *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<DocData::ClassDoc> 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<Script> script = get_script();
+ if (script->is_valid() && pcount > 0) {
+ p_list->push_back(script->get_class_category());
+ }
+#endif // TOOLS_ENABLED
+
for (uint32_t i = 0; i < pcount; i++) {
p_list->push_back(PropertyInfo(pinfo[i]));
}