diff options
Diffstat (limited to 'editor/property_editor.cpp')
-rw-r--r-- | editor/property_editor.cpp | 82 |
1 files changed, 58 insertions, 24 deletions
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index bc7d8f4b14..eed1efaf9c 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -2101,6 +2101,23 @@ bool PropertyEditor::_is_property_different(const Variant &p_current, const Vari return bool(Variant::evaluate(Variant::OP_NOT_EQUAL, p_current, p_orig)); } +bool PropertyEditor::_is_instanced_node_with_original_property_different(const String &p_name, TreeItem *item) { + bool mbi = _might_be_in_instance(); + if (mbi) { + Variant vorig; + Dictionary d = item->get_metadata(0); + int usage = d.has("usage") ? int(int(d["usage"]) & (PROPERTY_USAGE_STORE_IF_NONONE | PROPERTY_USAGE_STORE_IF_NONZERO)) : 0; + if (_get_instanced_node_original_property(p_name, vorig) || usage) { + Variant v = obj->get(p_name); + + if (_is_property_different(v, vorig, usage)) { + return true; + } + } + } + return false; +} + TreeItem *PropertyEditor::find_item(TreeItem *p_item, const String &p_name) { if (!p_item) @@ -2360,6 +2377,10 @@ void PropertyEditor::_check_reload_status(const String &p_name, TreeItem *item) } } + if (_is_instanced_node_with_original_property_different(p_name, item)) { + has_reload = true; + } + if (obj->call("property_can_revert", p_name).operator bool()) { has_reload = true; @@ -2665,13 +2686,14 @@ TreeItem *PropertyEditor::get_parent_node(String p_path, HashMap<String, TreeIte item->set_editable(1, false); item->set_selectable(1, subsection_selectable); - if (use_folding) { + if (use_folding) { // if (!obj->editor_is_section_unfolded(p_path)) { updating_folding = true; item->set_collapsed(true); updating_folding = false; } item->set_metadata(0, p_path); + foldable_property_cache.push_back(p_path); } if (item->get_parent() == root) { @@ -2720,6 +2742,7 @@ void PropertyEditor::refresh() { void PropertyEditor::update_tree() { tree->clear(); + foldable_property_cache.clear(); if (!obj) return; @@ -3076,7 +3099,7 @@ void PropertyEditor::update_tree() { item->set_text(1, type + " ID: " + itos(id)); item->add_button(1, get_icon("EditResource", "EditorIcons")); } else { - item->set_text(1, "[Empty]"); + item->set_text(1, TTR("[Empty]")); } if (has_icon(p.hint_string, "EditorIcons")) { @@ -3507,20 +3530,9 @@ void PropertyEditor::update_tree() { bool has_reload = false; - bool mbi = _might_be_in_instance(); - if (mbi) { - - Variant vorig; - Dictionary d = item->get_metadata(0); - int usage = d.has("usage") ? int(int(d["usage"]) & (PROPERTY_USAGE_STORE_IF_NONONE | PROPERTY_USAGE_STORE_IF_NONZERO)) : 0; - if (_get_instanced_node_original_property(p.name, vorig) || usage) { - Variant v = obj->get(p.name); - - if (_is_property_different(v, vorig, usage)) { - item->add_button(1, get_icon("ReloadSmall", "EditorIcons"), 3); - has_reload = true; - } - } + if (_is_instanced_node_with_original_property_different(p.name, item)) { + item->add_button(1, get_icon("ReloadSmall", "EditorIcons"), 3); + has_reload = true; } if (obj->call("property_can_revert", p.name).operator bool()) { @@ -3540,7 +3552,7 @@ void PropertyEditor::update_tree() { } } - if (mbi && !has_reload && item->get_cell_mode(1) == TreeItem::CELL_MODE_RANGE && item->get_text(1) == String()) { + if (_might_be_in_instance() && !has_reload && item->get_cell_mode(1) == TreeItem::CELL_MODE_RANGE && item->get_text(1) == String()) { item->add_button(1, get_icon("ReloadEmpty", "EditorIcons"), 3, true); } } @@ -3728,8 +3740,8 @@ void PropertyEditor::_item_edited() { _edit_set(name, item->get_text(1), refresh_all); } } break; - // math types + // math types case Variant::VECTOR3: { } break; @@ -4213,6 +4225,25 @@ void PropertyEditor::set_use_folding(bool p_enable) { tree->set_hide_folding(false); } +void PropertyEditor::collapse_all_folding() { + if (!obj) + return; + for (List<String>::Element *E = foldable_property_cache.front(); E; E = E->next()) { + obj->editor_set_section_unfold(E->get(), false); + } + update_tree(); +} + +void PropertyEditor::expand_all_folding() { + + if (!obj) + return; + for (List<String>::Element *E = foldable_property_cache.front(); E; E = E->next()) { + obj->editor_set_section_unfold(E->get(), true); + } + update_tree(); +} + PropertyEditor::PropertyEditor() { _prop_edited = "property_edited"; @@ -4596,21 +4627,24 @@ SectionedPropertyEditor::~SectionedPropertyEditor() { double PropertyValueEvaluator::eval(const String &p_text) { + // If range value contains a comma replace it with dot (issue #6028) + const String &p_new_text = p_text.replace(",", "."); + if (!obj || !script_language) - return _default_eval(p_text); + return _default_eval(p_new_text); Ref<Script> script = Ref<Script>(script_language->create_script()); - script->set_source_code(_build_script(p_text)); + script->set_source_code(_build_script(p_new_text)); Error err = script->reload(); if (err) { - print_line("[PropertyValueEvaluator] Error loading script for expression: " + p_text); - return _default_eval(p_text); + print_line("[PropertyValueEvaluator] Error loading script for expression: " + p_new_text); + return _default_eval(p_new_text); } Object dummy; ScriptInstance *script_instance = script->instance_create(&dummy); if (!script_instance) - return _default_eval(p_text); + return _default_eval(p_new_text); Variant::CallError call_err; Variant arg = obj; @@ -4621,7 +4655,7 @@ double PropertyValueEvaluator::eval(const String &p_text) { } print_line("[PropertyValueEvaluator]: Error eval! Error code: " + itos(call_err.error)); - return _default_eval(p_text); + return _default_eval(p_new_text); } void PropertyValueEvaluator::edit(Object *p_obj) { |