diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/create_dialog.cpp | 2 | ||||
-rw-r--r-- | editor/doc/doc_data.cpp | 79 | ||||
-rw-r--r-- | editor/doc/doc_data.h | 1 | ||||
-rw-r--r-- | editor/editor_help.cpp | 9 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 5 | ||||
-rw-r--r-- | editor/scene_tree_dock.cpp | 1 | ||||
-rw-r--r-- | editor/script_create_dialog.cpp | 25 |
7 files changed, 82 insertions, 40 deletions
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index d5f0dc01ee..5344658223 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -811,6 +811,4 @@ CreateDialog::CreateDialog() { type_blacklist.insert("PluginScript"); // PluginScript must be initialized before use, which is not possible here type_blacklist.insert("ScriptCreateDialog"); // This is an exposed editor Node that doesn't have an Editor prefix. - - EDITOR_DEF("interface/editors/derive_script_globals_by_name", true); } diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index 0f99e2ba1e..1a0f8e5257 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -205,6 +205,29 @@ static void argument_doc_from_arginfo(DocData::ArgumentDoc &p_argument, const Pr } } +static Variant get_documentation_default_value(const StringName &p_class_name, const StringName &p_property_name, bool &r_default_value_valid) { + + Variant default_value = Variant(); + r_default_value_valid = false; + + if (ClassDB::can_instance(p_class_name)) { + default_value = ClassDB::class_get_default_property_value(p_class_name, p_property_name, &r_default_value_valid); + } else { + // Cannot get default value of classes that can't be instanced + List<StringName> inheriting_classes; + ClassDB::get_direct_inheriters_from_class(p_class_name, &inheriting_classes); + for (List<StringName>::Element *E2 = inheriting_classes.front(); E2; E2 = E2->next()) { + if (ClassDB::can_instance(E2->get())) { + default_value = ClassDB::class_get_default_property_value(E2->get(), p_property_name, &r_default_value_valid); + if (r_default_value_valid) + break; + } + } + } + + return default_value; +} + void DocData::generate(bool p_basic_types) { List<StringName> classes; @@ -229,47 +252,53 @@ void DocData::generate(bool p_basic_types) { c.category = ClassDB::get_category(name); List<PropertyInfo> properties; + List<PropertyInfo> own_properties; if (name == "ProjectSettings") { //special case for project settings, so settings can be documented ProjectSettings::get_singleton()->get_property_list(&properties); + own_properties = properties; } else { - ClassDB::get_property_list(name, &properties, true); + ClassDB::get_property_list(name, &properties); + ClassDB::get_property_list(name, &own_properties, true); } + List<PropertyInfo>::Element *EO = own_properties.front(); for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { + bool inherited = EO == NULL; + if (EO && EO->get() == E->get()) { + inherited = false; + EO = EO->next(); + } + if (E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_INTERNAL) continue; PropertyDoc prop; - StringName setter = ClassDB::get_property_setter(name, E->get().name); - StringName getter = ClassDB::get_property_getter(name, E->get().name); prop.name = E->get().name; - prop.setter = setter; - prop.getter = getter; - Variant default_value = Variant(); + prop.overridden = inherited; + bool default_value_valid = false; + Variant default_value = get_documentation_default_value(name, E->get().name, default_value_valid); - if (ClassDB::can_instance(name)) { - default_value = ClassDB::class_get_default_property_value(name, E->get().name, &default_value_valid); - } else { - // Cannot get default value of classes that can't be instanced - List<StringName> inheriting_classes; - ClassDB::get_direct_inheriters_from_class(name, &inheriting_classes); - for (List<StringName>::Element *E2 = inheriting_classes.front(); E2; E2 = E2->next()) { - if (ClassDB::can_instance(E2->get())) { - default_value = ClassDB::class_get_default_property_value(E2->get(), E->get().name, &default_value_valid); - if (default_value_valid) - break; - } - } + if (inherited) { + bool base_default_value_valid = false; + Variant base_default_value = get_documentation_default_value(ClassDB::get_parent_class(name), E->get().name, base_default_value_valid); + if (!default_value_valid || !base_default_value_valid || default_value == base_default_value) + continue; } if (default_value_valid && default_value.get_type() != Variant::OBJECT) { prop.default_value = default_value.get_construct_string().replace("\n", ""); } + StringName setter = ClassDB::get_property_setter(name, E->get().name); + StringName getter = ClassDB::get_property_getter(name, E->get().name); + + prop.setter = setter; + prop.getter = getter; + bool found_type = false; if (getter != StringName()) { MethodBind *mb = ClassDB::get_method(name, getter); @@ -1076,10 +1105,16 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri if (c.properties[i].default_value != String()) { additional_attributes += " default=\"" + c.properties[i].default_value.xml_escape(true) + "\""; } + const PropertyDoc &p = c.properties[i]; - _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\"" + additional_attributes + ">"); - _write_string(f, 3, p.description.strip_edges().xml_escape()); - _write_string(f, 2, "</member>"); + + if (c.properties[i].overridden) { + _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\" override=\"true\"" + additional_attributes + "/>"); + } else { + _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\"" + additional_attributes + ">"); + _write_string(f, 3, p.description.strip_edges().xml_escape()); + _write_string(f, 2, "</member>"); + } } _write_string(f, 1, "</members>"); } diff --git a/editor/doc/doc_data.h b/editor/doc/doc_data.h index 3d5867dcca..6d601f0dce 100644 --- a/editor/doc/doc_data.h +++ b/editor/doc/doc_data.h @@ -74,6 +74,7 @@ public: String description; String setter, getter; String default_value; + bool overridden; bool operator<(const PropertyDoc &p_prop) const { return name < p_prop.name; } diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 04e9177d26..2b58d105de 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -489,6 +489,10 @@ void EditorHelp::_update_doc() { describe = true; } + if (cd.properties[i].overridden) { + describe = false; + } + class_desc->push_cell(); class_desc->push_font(doc_code_font); class_desc->push_color(headline_color); @@ -506,7 +510,7 @@ void EditorHelp::_update_doc() { if (cd.properties[i].default_value != "") { class_desc->push_color(symbol_color); - class_desc->add_text(" [default: "); + class_desc->add_text(cd.properties[i].overridden ? " [override: " : " [default: "); class_desc->pop(); class_desc->push_color(value_color); _add_text(_fix_constant(cd.properties[i].default_value)); @@ -992,6 +996,9 @@ void EditorHelp::_update_doc() { for (int i = 0; i < cd.properties.size(); i++) { + if (cd.properties[i].overridden) + continue; + property_line[cd.properties[i].name] = class_desc->get_line_count() - 2; class_desc->push_table(2); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 18049e62b4..43d37a8edc 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -4061,7 +4061,10 @@ void _update_all_gizmos(Node *p_node) { } void SpatialEditor::update_all_gizmos(Node *p_node) { - if (!p_node) p_node = SceneTree::get_singleton()->get_root(); + if (!p_node) { + if (!SceneTree::get_singleton()) return; + p_node = SceneTree::get_singleton()->get_root(); + } _update_all_gizmos(p_node); } diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 2ddf1f7056..ae91e7d79f 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -2918,5 +2918,6 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel profile_allow_script_editing = true; EDITOR_DEF("interface/editors/show_scene_tree_root_selection", true); + EDITOR_DEF("interface/editors/derive_script_globals_by_name", true); EDITOR_DEF("_use_favorites_root_selection", false); } diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index ffb3f5feab..01cb816556 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -55,6 +55,15 @@ void ScriptCreateDialog::_notification(int p_what) { String last_lang = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_language", ""); Ref<Texture> last_lang_icon; if (!last_lang.empty()) { + + for (int i = 0; i < language_menu->get_item_count(); i++) { + if (language_menu->get_item_text(i) == last_lang) { + language_menu->select(i); + current_language = i; + break; + } + } + last_lang_icon = get_icon(last_lang, "EditorIcons"); } else { last_lang_icon = language_menu->get_item_icon(default_language); @@ -757,7 +766,6 @@ ScriptCreateDialog::ScriptCreateDialog() { status_panel = memnew(PanelContainer); status_panel->set_h_size_flags(Control::SIZE_FILL); - status_panel->add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("bg", "Tree")); status_panel->add_child(vb); /* Spacing */ @@ -794,19 +802,8 @@ ScriptCreateDialog::ScriptCreateDialog() { } } - String last_selected_language = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_language", ""); - if (last_selected_language != "") { - for (int i = 0; i < language_menu->get_item_count(); i++) { - if (language_menu->get_item_text(i) == last_selected_language) { - language_menu->select(i); - current_language = i; - break; - } - } - } else { - language_menu->select(default_language); - current_language = default_language; - } + language_menu->select(default_language); + current_language = default_language; language_menu->connect("item_selected", this, "_lang_changed"); |