From 0e0a6bb39b81eda80fbfc7195aee580d1c173d35 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 9 Jan 2023 15:31:44 +0100 Subject: [PATCH] Removed unused property hints and `Object::get_translatable_strings()` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove unused `EditorPropertyMember` and related hints, previouly used by VisualScript. Such logic should be implemented in the VS module itself. * As the above broke compatibility with the VS module, clean up the other hacks that were still in core in support of VisualScript. * `PROPERTY_USAGE_INTERNATIONALIZED` was only used in Object's `get_translatable_strings()`, which is a legacy function not used anywhere. So both are removed. * Reordered some usage flags after the above removal to minimize the diff. * General clean up. Fixes #30203. Co-authored-by: RĂ©mi Verschelde --- core/core_constants.cpp | 14 +- core/doc_data.h | 5 - core/object/object.cpp | 19 -- core/object/object.h | 21 +- doc/classes/@GlobalScope.xml | 60 ++---- editor/editor_asset_installer.cpp | 1 - editor/editor_node.cpp | 2 +- editor/editor_properties.cpp | 204 +++--------------- editor/editor_properties.h | 34 --- editor/editor_themes.cpp | 39 ++-- editor/plugins/script_editor_plugin.cpp | 31 ++- editor/project_converter_3_to_4.cpp | 3 - .../Godot.SourceGenerators/GodotEnums.cs | 44 ++-- scene/3d/soft_body_3d.cpp | 2 +- scene/gui/button.cpp | 2 +- scene/gui/dialogs.cpp | 2 +- scene/gui/label.cpp | 2 +- scene/gui/menu_bar.cpp | 21 -- scene/gui/menu_bar.h | 1 - scene/gui/option_button.cpp | 4 - scene/gui/option_button.h | 2 - scene/gui/popup_menu.cpp | 8 - scene/gui/popup_menu.h | 2 - scene/gui/tab_container.cpp | 16 -- scene/gui/tab_container.h | 2 - 25 files changed, 112 insertions(+), 429 deletions(-) diff --git a/core/core_constants.cpp b/core/core_constants.cpp index 504b3437360..edb72f73cb5 100644 --- a/core/core_constants.cpp +++ b/core/core_constants.cpp @@ -621,14 +621,6 @@ void register_global_constants() { BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_TYPE_STRING); BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE); - BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_METHOD_OF_VARIANT_TYPE); - BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_METHOD_OF_BASE_TYPE); - BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_METHOD_OF_INSTANCE); - BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_METHOD_OF_SCRIPT); - BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE); - BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_PROPERTY_OF_BASE_TYPE); - BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_PROPERTY_OF_INSTANCE); - BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_PROPERTY_OF_SCRIPT); BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_OBJECT_TOO_BIG); BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_NODE_PATH_VALID_TYPES); BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_SAVE_FILE); @@ -646,10 +638,10 @@ void register_global_constants() { BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_NONE); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_STORAGE); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_EDITOR); + BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_INTERNAL); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_CHECKABLE); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_CHECKED); - BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_INTERNATIONALIZED); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_GROUP); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_CATEGORY); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_SUBGROUP); @@ -663,7 +655,7 @@ void register_global_constants() { BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_CLASS_IS_ENUM); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_NIL_IS_VARIANT); - BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_INTERNAL); + BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_ARRAY); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_HIGH_END_GFX); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_NODE_PATH_FROM_SCENE_ROOT); @@ -673,10 +665,8 @@ void register_global_constants() { BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_EDITOR_BASIC_SETTING); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_READ_ONLY); - BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_ARRAY); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_DEFAULT); - BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_DEFAULT_INTL); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_NO_EDITOR); BIND_CORE_BITFIELD_FLAG(METHOD_FLAG_NORMAL); diff --git a/core/doc_data.h b/core/doc_data.h index c547138619e..1cf4e4f2065 100644 --- a/core/doc_data.h +++ b/core/doc_data.h @@ -378,7 +378,6 @@ public: struct ClassDoc { String name; String inherits; - String category; // FIXME: Wrongly used by VisualScriptPropertySelector, should be removed. String brief_description; String description; Vector tutorials; @@ -409,10 +408,6 @@ public: doc.inherits = p_dict["inherits"]; } - if (p_dict.has("category")) { - doc.category = p_dict["category"]; - } - if (p_dict.has("brief_description")) { doc.brief_description = p_dict["brief_description"]; } diff --git a/core/object/object.cpp b/core/object/object.cpp index 0e82440fc0b..1f0a7e516d0 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -1594,25 +1594,6 @@ bool Object::is_blocking_signals() const { return _block_signals; } -void Object::get_translatable_strings(List *p_strings) const { - List plist; - get_property_list(&plist); - - for (const PropertyInfo &E : plist) { - if (!(E.usage & PROPERTY_USAGE_INTERNATIONALIZED)) { - continue; - } - - String text = get(E.name); - - if (text.is_empty()) { - continue; - } - - p_strings->push_back(text); - } -} - Variant::Type Object::get_static_property_type(const StringName &p_property, bool *r_valid) const { bool valid; Variant::Type t = ClassDB::get_property_type(get_class_name(), p_property, &valid); diff --git a/core/object/object.h b/core/object/object.h index 2ba86c9d313..f78c7c34fd4 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -74,14 +74,6 @@ enum PropertyHint { PROPERTY_HINT_OBJECT_ID, PROPERTY_HINT_TYPE_STRING, ///< a type string, the hint is the base type to choose PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE, ///< so something else can provide this (used in scripts) - PROPERTY_HINT_METHOD_OF_VARIANT_TYPE, ///< a method of a type - PROPERTY_HINT_METHOD_OF_BASE_TYPE, ///< a method of a base type - PROPERTY_HINT_METHOD_OF_INSTANCE, ///< a method of an instance - PROPERTY_HINT_METHOD_OF_SCRIPT, ///< a method of a script & base - PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE, ///< a property of a type - PROPERTY_HINT_PROPERTY_OF_BASE_TYPE, ///< a property of a base type - PROPERTY_HINT_PROPERTY_OF_INSTANCE, ///< a property of an instance - PROPERTY_HINT_PROPERTY_OF_SCRIPT, ///< a property of a script & base PROPERTY_HINT_OBJECT_TOO_BIG, ///< object is too big to send PROPERTY_HINT_NODE_PATH_VALID_TYPES, PROPERTY_HINT_SAVE_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc,". This opens a save dialog @@ -95,16 +87,15 @@ enum PropertyHint { PROPERTY_HINT_HIDE_QUATERNION_EDIT, /// Only Node3D::transform should hide the quaternion editor. PROPERTY_HINT_PASSWORD, PROPERTY_HINT_MAX, - // When updating PropertyHint, also sync the hardcoded list in VisualScriptEditorVariableEdit }; enum PropertyUsageFlags { PROPERTY_USAGE_NONE = 0, PROPERTY_USAGE_STORAGE = 1 << 1, PROPERTY_USAGE_EDITOR = 1 << 2, - PROPERTY_USAGE_CHECKABLE = 1 << 3, // Used for editing global variables. - PROPERTY_USAGE_CHECKED = 1 << 4, // Used for editing global variables. - PROPERTY_USAGE_INTERNATIONALIZED = 1 << 5, // Hint for internationalized strings. + PROPERTY_USAGE_INTERNAL = 1 << 3, + PROPERTY_USAGE_CHECKABLE = 1 << 4, // Used for editing global variables. + PROPERTY_USAGE_CHECKED = 1 << 5, // Used for editing global variables. PROPERTY_USAGE_GROUP = 1 << 6, // Used for grouping props in the editor. PROPERTY_USAGE_CATEGORY = 1 << 7, PROPERTY_USAGE_SUBGROUP = 1 << 8, @@ -117,7 +108,7 @@ enum PropertyUsageFlags { PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE = 1 << 15, PROPERTY_USAGE_CLASS_IS_ENUM = 1 << 16, PROPERTY_USAGE_NIL_IS_VARIANT = 1 << 17, - PROPERTY_USAGE_INTERNAL = 1 << 18, + PROPERTY_USAGE_ARRAY = 1 << 18, // Used in the inspector to group properties as elements of an array. PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE = 1 << 19, // If the object is duplicated also this property will be duplicated. PROPERTY_USAGE_HIGH_END_GFX = 1 << 20, PROPERTY_USAGE_NODE_PATH_FROM_SCENE_ROOT = 1 << 21, @@ -127,10 +118,8 @@ enum PropertyUsageFlags { PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT = 1 << 25, // For Object properties, instantiate them when creating in editor. PROPERTY_USAGE_EDITOR_BASIC_SETTING = 1 << 26, //for project or editor settings, show when basic settings are selected. PROPERTY_USAGE_READ_ONLY = 1 << 27, // Mark a property as read-only in the inspector. - PROPERTY_USAGE_ARRAY = 1 << 28, // Used in the inspector to group properties as elements of an array. PROPERTY_USAGE_DEFAULT = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR, - PROPERTY_USAGE_DEFAULT_INTL = PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNATIONALIZED, PROPERTY_USAGE_NO_EDITOR = PROPERTY_USAGE_STORAGE, }; @@ -894,8 +883,6 @@ public: Variant::Type get_static_property_type(const StringName &p_property, bool *r_valid = nullptr) const; Variant::Type get_static_property_type_indexed(const Vector &p_path, bool *r_valid = nullptr) const; - virtual void get_translatable_strings(List *p_strings) const; - virtual void get_argument_options(const StringName &p_function, int p_idx, List *r_options) const; // Translate message (internationalization). diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index bf3ef7c7f9a..41836650cd7 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -2794,51 +2794,35 @@ - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - + Hints that a string property is a locale code. Editing it will show a locale dialog for picking language and country. - + Hints that a dictionary property is string translation map. Dictionary keys are locale codes and, values are translated strings. - + - + Hints that a quaternion property should disable the temporary euler editor. - + Hints that a string property is a password, and every character is replaced with the secret character. - + The property is not stored, and does not display in the editor. This is the default for non-exported properties. @@ -2849,15 +2833,14 @@ The property is shown in the [EditorInspector] (default). - + + + The property can be checked in the [EditorInspector]. - + The property is checked in the [EditorInspector]. - - The property is a translatable string. - Used to group properties together in the editor. See [EditorInspector]. @@ -2888,7 +2871,8 @@ - + + The property is an array. If the property is a [Resource], a new copy of it is always created when calling [method Node.duplicate] or [method Resource.duplicate]. @@ -2911,15 +2895,9 @@ The property is read-only in the [EditorInspector]. - - The property is an array. - Default usage (storage, editor and network). - - Default usage for translatable strings (storage, editor, network and internationalized). - Default usage but without showing the property in the editor (storage, network). diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index 0258ac532fe..a5bc90159af 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -120,7 +120,6 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { // Mark C# support as unavailable. extension_guess["cs"] = tree->get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons")); } - extension_guess["vs"] = tree->get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons")); extension_guess["res"] = tree->get_theme_icon(SNAME("Resource"), SNAME("EditorIcons")); extension_guess["tres"] = tree->get_theme_icon(SNAME("Resource"), SNAME("EditorIcons")); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 18bb3f3dbb2..03ece6c29be 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2336,7 +2336,7 @@ void EditorNode::_edit_current(bool p_skip_foreign) { if (main_plugin && !skip_main_plugin) { // Special case if use of external editor is true. Resource *current_res = Object::cast_to(current_obj); - if (main_plugin->get_name() == "Script" && !current_obj->is_class("VisualScript") && current_res && !current_res->is_built_in() && (bool(EDITOR_GET("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) { + if (main_plugin->get_name() == "Script" && current_res && !current_res->is_built_in() && (bool(EDITOR_GET("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) { if (!changing_scene) { main_plugin->edit(current_obj); } diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 46aa798252c..7aa050227d8 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -68,7 +68,7 @@ EditorPropertyNil::EditorPropertyNil() { void EditorPropertyText::_set_read_only(bool p_read_only) { text->set_editable(!p_read_only); -}; +} void EditorPropertyText::_text_submitted(const String &p_string) { if (updating) { @@ -133,7 +133,7 @@ EditorPropertyText::EditorPropertyText() { void EditorPropertyMultilineText::_set_read_only(bool p_read_only) { text->set_editable(!p_read_only); open_big_text->set_disabled(p_read_only); -}; +} void EditorPropertyMultilineText::_big_text_changed() { text->set_text(big_text->get_text()); @@ -236,7 +236,7 @@ EditorPropertyMultilineText::EditorPropertyMultilineText(bool p_expression) { void EditorPropertyTextEnum::_set_read_only(bool p_read_only) { option_button->set_disabled(p_read_only); edit_button->set_disabled(p_read_only); -}; +} void EditorPropertyTextEnum::_emit_changed_value(String p_string) { if (string_name) { @@ -450,7 +450,7 @@ EditorPropertyLocale::EditorPropertyLocale() { void EditorPropertyPath::_set_read_only(bool p_read_only) { path->set_editable(!p_read_only); path_edit->set_disabled(p_read_only); -}; +} void EditorPropertyPath::_path_selected(const String &p_path) { emit_changed(get_edited_property(), p_path); @@ -588,7 +588,7 @@ EditorPropertyPath::EditorPropertyPath() { void EditorPropertyClassName::_set_read_only(bool p_read_only) { property->set_disabled(p_read_only); -}; +} void EditorPropertyClassName::setup(const String &p_base_type, const String &p_selected_type) { base_type = p_base_type; @@ -629,112 +629,11 @@ EditorPropertyClassName::EditorPropertyClassName() { add_child(dialog); } -///////////////////// MEMBER ///////////////////////// - -void EditorPropertyMember::_set_read_only(bool p_read_only) { - property->set_disabled(p_read_only); -}; - -void EditorPropertyMember::_property_selected(const String &p_selected) { - emit_changed(get_edited_property(), p_selected); - update_property(); -} - -void EditorPropertyMember::_property_select() { - if (!selector) { - selector = memnew(PropertySelector); - selector->connect("selected", callable_mp(this, &EditorPropertyMember::_property_selected)); - add_child(selector); - } - - String current = get_edited_object()->get(get_edited_property()); - - if (hint == MEMBER_METHOD_OF_VARIANT_TYPE) { - Variant::Type type = Variant::NIL; - for (int i = 0; i < Variant::VARIANT_MAX; i++) { - if (hint_text == Variant::get_type_name(Variant::Type(i))) { - type = Variant::Type(i); - } - } - if (type != Variant::NIL) { - selector->select_method_from_basic_type(type, current); - } - - } else if (hint == MEMBER_METHOD_OF_BASE_TYPE) { - selector->select_method_from_base_type(hint_text, current); - - } else if (hint == MEMBER_METHOD_OF_INSTANCE) { - Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int())); - if (instance) { - selector->select_method_from_instance(instance, current); - } - - } else if (hint == MEMBER_METHOD_OF_SCRIPT) { - Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int())); - if (Object::cast_to