diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_properties.cpp | 8 | ||||
-rw-r--r-- | editor/editor_settings_dialog.cpp | 4 | ||||
-rw-r--r-- | editor/plugins/animation_blend_tree_editor_plugin.cpp | 55 | ||||
-rw-r--r-- | editor/plugins/animation_blend_tree_editor_plugin.h | 5 | ||||
-rw-r--r-- | editor/plugins/animation_tree_editor_plugin.cpp | 15 | ||||
-rw-r--r-- | editor/plugins/animation_tree_editor_plugin.h | 1 |
6 files changed, 61 insertions, 27 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 7364258a07..3b99962435 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -1758,7 +1758,7 @@ void EditorPropertyVector2::_value_changed(double val, const String &p_name) { Vector2 v2; v2.x = spin[0]->get_value(); v2.y = spin[1]->get_value(); - emit_changed(get_edited_property(), v2, p_name); + emit_changed(get_edited_property(), v2, linked->is_pressed() ? "" : p_name); } void EditorPropertyVector2::update_property() { @@ -2005,7 +2005,7 @@ void EditorPropertyVector3::_value_changed(double val, const String &p_name) { v3.y = Math::deg_to_rad(v3.y); v3.z = Math::deg_to_rad(v3.z); } - emit_changed(get_edited_property(), v3, p_name); + emit_changed(get_edited_property(), v3, linked->is_pressed() ? "" : p_name); } void EditorPropertyVector3::update_property() { @@ -2171,7 +2171,7 @@ void EditorPropertyVector2i::_value_changed(double val, const String &p_name) { Vector2i v2; v2.x = spin[0]->get_value(); v2.y = spin[1]->get_value(); - emit_changed(get_edited_property(), v2, p_name); + emit_changed(get_edited_property(), v2, linked->is_pressed() ? "" : p_name); } void EditorPropertyVector2i::update_property() { @@ -2413,7 +2413,7 @@ void EditorPropertyVector3i::_value_changed(double val, const String &p_name) { v3.x = spin[0]->get_value(); v3.y = spin[1]->get_value(); v3.z = spin[2]->get_value(); - emit_changed(get_edited_property(), v3, p_name); + emit_changed(get_edited_property(), v3, linked->is_pressed() ? "" : p_name); } void EditorPropertyVector3i::update_property() { diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp index ec67cde112..8062b6f756 100644 --- a/editor/editor_settings_dialog.cpp +++ b/editor/editor_settings_dialog.cpp @@ -552,6 +552,10 @@ void EditorSettingsDialog::_shortcut_cell_double_clicked() { const ShortcutButton edit_btn_id = EditorSettingsDialog::SHORTCUT_EDIT; const int edit_btn_col = 1; TreeItem *ti = shortcuts->get_selected(); + if (ti == nullptr) { + return; + } + String type = ti->get_meta("type"); int col = shortcuts->get_selected_column(); if (type == "shortcut" && col == 0) { diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index f4b8646e18..ca7b2d0015 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -101,13 +101,13 @@ void AnimationNodeBlendTreeEditor::_property_changed(const StringName &p_propert undo_redo->create_action(TTR("Parameter Changed:") + " " + String(p_property), UndoRedo::MERGE_ENDS); undo_redo->add_do_property(tree, p_property, p_value); undo_redo->add_undo_property(tree, p_property, tree->get(p_property)); - undo_redo->add_do_method(this, "_update_graph"); - undo_redo->add_undo_method(this, "_update_graph"); + undo_redo->add_do_method(this, "update_graph"); + undo_redo->add_undo_method(this, "update_graph"); undo_redo->commit_action(); updating = false; } -void AnimationNodeBlendTreeEditor::_update_graph() { +void AnimationNodeBlendTreeEditor::update_graph() { if (updating || blend_tree.is_null()) { return; } @@ -364,8 +364,8 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) { to_slot = -1; } - undo_redo->add_do_method(this, "_update_graph"); - undo_redo->add_undo_method(this, "_update_graph"); + undo_redo->add_do_method(this, "update_graph"); + undo_redo->add_undo_method(this, "update_graph"); undo_redo->commit_action(); } @@ -416,8 +416,8 @@ void AnimationNodeBlendTreeEditor::_node_dragged(const Vector2 &p_from, const Ve undo_redo->create_action(TTR("Node Moved")); undo_redo->add_do_method(blend_tree.ptr(), "set_node_position", p_which, p_to / EDSCALE); undo_redo->add_undo_method(blend_tree.ptr(), "set_node_position", p_which, p_from / EDSCALE); - undo_redo->add_do_method(this, "_update_graph"); - undo_redo->add_undo_method(this, "_update_graph"); + undo_redo->add_do_method(this, "update_graph"); + undo_redo->add_undo_method(this, "update_graph"); undo_redo->commit_action(); updating = false; } @@ -437,8 +437,8 @@ void AnimationNodeBlendTreeEditor::_connection_request(const String &p_from, int undo_redo->create_action(TTR("Nodes Connected")); undo_redo->add_do_method(blend_tree.ptr(), "connect_node", p_to, p_to_index, p_from); undo_redo->add_undo_method(blend_tree.ptr(), "disconnect_node", p_to, p_to_index); - undo_redo->add_do_method(this, "_update_graph"); - undo_redo->add_undo_method(this, "_update_graph"); + undo_redo->add_do_method(this, "update_graph"); + undo_redo->add_undo_method(this, "update_graph"); undo_redo->commit_action(); } @@ -453,8 +453,8 @@ void AnimationNodeBlendTreeEditor::_disconnection_request(const String &p_from, undo_redo->create_action(TTR("Nodes Disconnected")); undo_redo->add_do_method(blend_tree.ptr(), "disconnect_node", p_to, p_to_index); undo_redo->add_undo_method(blend_tree.ptr(), "connect_node", p_to, p_to_index, p_from); - undo_redo->add_do_method(this, "_update_graph"); - undo_redo->add_undo_method(this, "_update_graph"); + undo_redo->add_do_method(this, "update_graph"); + undo_redo->add_undo_method(this, "update_graph"); undo_redo->commit_action(); updating = false; } @@ -468,8 +468,8 @@ void AnimationNodeBlendTreeEditor::_anim_selected(int p_index, Array p_options, undo_redo->create_action(TTR("Set Animation")); undo_redo->add_do_method(anim.ptr(), "set_animation", option); undo_redo->add_undo_method(anim.ptr(), "set_animation", anim->get_animation()); - undo_redo->add_do_method(this, "_update_graph"); - undo_redo->add_undo_method(this, "_update_graph"); + undo_redo->add_do_method(this, "update_graph"); + undo_redo->add_undo_method(this, "update_graph"); undo_redo->commit_action(); } @@ -491,8 +491,8 @@ void AnimationNodeBlendTreeEditor::_delete_request(const String &p_which) { } } - undo_redo->add_do_method(this, "_update_graph"); - undo_redo->add_undo_method(this, "_update_graph"); + undo_redo->add_do_method(this, "update_graph"); + undo_redo->add_undo_method(this, "update_graph"); undo_redo->commit_action(); } @@ -819,7 +819,7 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) { _update_theme(); if (is_visible_in_tree()) { - _update_graph(); + update_graph(); } } break; @@ -900,12 +900,23 @@ void AnimationNodeBlendTreeEditor::_scroll_changed(const Vector2 &p_scroll) { } void AnimationNodeBlendTreeEditor::_bind_methods() { - ClassDB::bind_method("_update_graph", &AnimationNodeBlendTreeEditor::_update_graph); + ClassDB::bind_method("update_graph", &AnimationNodeBlendTreeEditor::update_graph); ClassDB::bind_method("_update_filters", &AnimationNodeBlendTreeEditor::_update_filters); } AnimationNodeBlendTreeEditor *AnimationNodeBlendTreeEditor::singleton = nullptr; +// AnimationNode's "node_changed" signal means almost update_input. +void AnimationNodeBlendTreeEditor::_node_changed(const StringName &p_node_name) { + // TODO: + // Here is executed during the commit of EditorNode::undo_redo, it is not possible to create an undo_redo action here. + // The disconnect when the number of enabled inputs decreases is done in AnimationNodeBlendTree and update_graph(). + // This means that there is no place to register undo_redo actions. + // In order to implement undo_redo correctly, we may need to implement AnimationNodeEdit such as AnimationTrackKeyEdit + // and add it to _node_selected() with EditorNode::get_singleton()->push_item(AnimationNodeEdit). + update_graph(); +} + void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<AnimationNode> p_node) { if (blend_tree.is_null()) { return; @@ -940,8 +951,8 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima undo_redo->add_undo_method(blend_tree.ptr(), "rename_node", name, prev_name); undo_redo->add_do_method(AnimationTreeEditor::get_singleton()->get_tree(), "rename_parameter", base_path + prev_name, base_path + name); undo_redo->add_undo_method(AnimationTreeEditor::get_singleton()->get_tree(), "rename_parameter", base_path + name, base_path + prev_name); - undo_redo->add_do_method(this, "_update_graph"); - undo_redo->add_undo_method(this, "_update_graph"); + undo_redo->add_do_method(this, "update_graph"); + undo_redo->add_undo_method(this, "update_graph"); undo_redo->commit_action(); updating = false; gn->set_name(new_name); @@ -979,7 +990,7 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima } } - _update_graph(); // Needed to update the signal connections with the new name. + update_graph(); // Needed to update the signal connections with the new name. } void AnimationNodeBlendTreeEditor::_node_renamed_focus_out(Node *le, Ref<AnimationNode> p_node) { @@ -996,6 +1007,7 @@ bool AnimationNodeBlendTreeEditor::can_edit(const Ref<AnimationNode> &p_node) { void AnimationNodeBlendTreeEditor::edit(const Ref<AnimationNode> &p_node) { if (blend_tree.is_valid()) { + blend_tree->disconnect("node_changed", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_changed)); blend_tree->disconnect("removed_from_graph", callable_mp(this, &AnimationNodeBlendTreeEditor::_removed_from_graph)); } @@ -1008,9 +1020,10 @@ void AnimationNodeBlendTreeEditor::edit(const Ref<AnimationNode> &p_node) { } else { read_only = EditorNode::get_singleton()->is_resource_read_only(blend_tree); + blend_tree->connect("node_changed", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_changed)); blend_tree->connect("removed_from_graph", callable_mp(this, &AnimationNodeBlendTreeEditor::_removed_from_graph)); - _update_graph(); + update_graph(); } add_node->set_disabled(read_only); diff --git a/editor/plugins/animation_blend_tree_editor_plugin.h b/editor/plugins/animation_blend_tree_editor_plugin.h index 30a54930a2..46e0d18c69 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.h +++ b/editor/plugins/animation_blend_tree_editor_plugin.h @@ -71,8 +71,6 @@ class AnimationNodeBlendTreeEditor : public AnimationTreeNodeEditorPlugin { int to_slot = -1; String from_node = ""; - void _update_graph(); - struct AddOption { String name; String type; @@ -95,6 +93,7 @@ class AnimationNodeBlendTreeEditor : public AnimationTreeNodeEditorPlugin { void _node_dragged(const Vector2 &p_from, const Vector2 &p_to, const StringName &p_which); void _node_renamed(const String &p_text, Ref<AnimationNode> p_node); void _node_renamed_focus_out(Node *le, Ref<AnimationNode> p_node); + void _node_changed(const StringName &p_node_name); bool updating; @@ -150,6 +149,8 @@ public: virtual bool can_edit(const Ref<AnimationNode> &p_node) override; virtual void edit(const Ref<AnimationNode> &p_node) override; + void update_graph(); + AnimationNodeBlendTreeEditor(); }; diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index ed231c446b..1de4fbaabc 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -50,10 +50,18 @@ #include "scene/scene_string_names.h" void AnimationTreeEditor::edit(AnimationTree *p_tree) { + if (p_tree && !p_tree->is_connected("animation_player_changed", callable_mp(this, &AnimationTreeEditor::_animation_list_changed))) { + p_tree->connect("animation_player_changed", callable_mp(this, &AnimationTreeEditor::_animation_list_changed), CONNECT_DEFERRED); + } + if (tree == p_tree) { return; } + if (tree && tree->is_connected("animation_player_changed", callable_mp(this, &AnimationTreeEditor::_animation_list_changed))) { + tree->disconnect("animation_player_changed", callable_mp(this, &AnimationTreeEditor::_animation_list_changed)); + } + tree = p_tree; Vector<String> path; @@ -73,6 +81,13 @@ void AnimationTreeEditor::_path_button_pressed(int p_path) { } } +void AnimationTreeEditor::_animation_list_changed() { + AnimationNodeBlendTreeEditor *bte = AnimationNodeBlendTreeEditor::get_singleton(); + if (bte) { + bte->update_graph(); + } +} + void AnimationTreeEditor::_update_path() { while (path_hb->get_child_count() > 1) { memdelete(path_hb->get_child(1)); diff --git a/editor/plugins/animation_tree_editor_plugin.h b/editor/plugins/animation_tree_editor_plugin.h index a33d97f62f..9ef9fff8cd 100644 --- a/editor/plugins/animation_tree_editor_plugin.h +++ b/editor/plugins/animation_tree_editor_plugin.h @@ -65,6 +65,7 @@ class AnimationTreeEditor : public VBoxContainer { ObjectID current_root; void _path_button_pressed(int p_path); + void _animation_list_changed(); static Vector<String> get_animation_list(); |