summaryrefslogtreecommitdiff
path: root/editor/scene_tree_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/scene_tree_editor.cpp')
-rw-r--r--editor/scene_tree_editor.cpp73
1 files changed, 38 insertions, 35 deletions
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index e38347a653..7d2127d4f8 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -30,6 +30,7 @@
#include "scene_tree_editor.h"
+#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
#include "editor_node.h"
#include "message_queue.h"
@@ -70,8 +71,18 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
} else if (p_id == BUTTON_VISIBILITY) {
undo_redo->create_action(TTR("Toggle Visible"));
- undo_redo->add_do_method(this, "toggle_visible", n);
- undo_redo->add_undo_method(this, "toggle_visible", n);
+ _toggle_visible(n);
+ List<Node *> selection = editor_selection->get_selected_node_list();
+ if (selection.size() > 1) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
+ Node *nv = E->get();
+ ERR_FAIL_COND(!nv);
+ if (nv == n) {
+ continue;
+ }
+ _toggle_visible(nv);
+ }
+ }
undo_redo->commit_action();
} else if (p_id == BUTTON_LOCK) {
@@ -80,6 +91,12 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
_update_tree();
emit_signal("node_changed");
}
+ } else if (p_id == BUTTON_PIN) {
+
+ if (n->is_class("AnimationPlayer")) {
+ AnimationPlayerEditor::singleton->unpin();
+ _update_tree();
+ }
} else if (p_id == BUTTON_GROUP) {
if (n->is_class("CanvasItem")) {
@@ -118,33 +135,13 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
}
}
void SceneTreeEditor::_toggle_visible(Node *p_node) {
- if (p_node->is_class("Spatial")) {
- bool v = bool(p_node->call("is_visible"));
- p_node->call("set_visible", !v);
- } else if (p_node->is_class("CanvasItem")) {
+ if (p_node->has_method("is_visible") && p_node->has_method("set_visible")) {
bool v = bool(p_node->call("is_visible"));
- if (v) {
- p_node->call("hide");
- } else {
- p_node->call("show");
- }
+ undo_redo->add_do_method(p_node, "set_visible", !v);
+ undo_redo->add_undo_method(p_node, "set_visible", v);
}
}
-void SceneTreeEditor::toggle_visible(Node *p_node) {
- _toggle_visible(p_node);
- List<Node *> selection = editor_selection->get_selected_node_list();
- if (selection.size() > 1) {
- for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Node *nv = E->get();
- ERR_FAIL_COND(!nv);
- if (nv == p_node) {
- continue;
- }
- _toggle_visible(nv);
- }
- }
-}
bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
if (!p_node)
@@ -229,7 +226,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
bool has_groups = p_node->has_persistent_groups();
if (has_connections && has_groups) {
- item->add_button(0, get_icon("SignalsAndGroups", "EditorIcons"), BUTTON_SIGNALS, false, TTR("Node has connection(s) and group(s)\nClick to show signals dock."));
+ item->add_button(0, get_icon("SignalsAndGroups", "EditorIcons"), BUTTON_SIGNALS, false, TTR("Node has connection(s) and group(s).\nClick to show signals dock."));
} else if (has_connections) {
item->add_button(0, get_icon("Signals", "EditorIcons"), BUTTON_SIGNALS, false, TTR("Node has connections.\nClick to show signals dock."));
} else if (has_groups) {
@@ -255,18 +252,18 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
if (!p_node->get_script().is_null()) {
- item->add_button(0, get_icon("Script", "EditorIcons"), BUTTON_SCRIPT, false, TTR("Open script"));
+ item->add_button(0, get_icon("Script", "EditorIcons"), BUTTON_SCRIPT, false, TTR("Open Script"));
}
if (p_node->is_class("CanvasItem")) {
bool is_locked = p_node->has_meta("_edit_lock_"); //_edit_group_
if (is_locked)
- item->add_button(0, get_icon("Lock", "EditorIcons"), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock"));
+ item->add_button(0, get_icon("Lock", "EditorIcons"), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it."));
bool is_grouped = p_node->has_meta("_edit_group_");
if (is_grouped)
- item->add_button(0, get_icon("Group", "EditorIcons"), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make selectable"));
+ item->add_button(0, get_icon("Group", "EditorIcons"), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make selectable."));
bool v = p_node->call("is_visible");
if (v)
@@ -282,7 +279,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
bool is_locked = p_node->has_meta("_edit_lock_");
if (is_locked)
- item->add_button(0, get_icon("Lock", "EditorIcons"), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock"));
+ item->add_button(0, get_icon("Lock", "EditorIcons"), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it."));
bool v = p_node->call("is_visible");
if (v)
@@ -294,6 +291,13 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
p_node->connect("visibility_changed", this, "_node_visibility_changed", varray(p_node));
_update_visibility_color(p_node, item);
+ } else if (p_node->is_class("AnimationPlayer")) {
+
+ bool is_pinned = AnimationPlayerEditor::singleton->get_player() == p_node && AnimationPlayerEditor::singleton->is_pinned();
+
+ if (is_pinned) {
+ item->add_button(0, get_icon("Pin", "EditorIcons"), BUTTON_PIN, false, TTR("AnimationPlayer is pinned.\nClick to unpin."));
+ }
}
}
@@ -644,11 +648,12 @@ void SceneTreeEditor::_renamed() {
ERR_FAIL_COND(!n);
String new_name = which->get_text(0);
- if (new_name.find(".") != -1 || new_name.find("/") != -1) {
+ if (!Node::_validate_node_name(new_name)) {
- error->set_text(TTR("Invalid node name, the following characters are not allowed:") + "\n \".\", \"/\"");
+ error->set_text(TTR("Invalid node name, the following characters are not allowed:") + "\n" + Node::invalid_character);
error->popup_centered_minsize();
- new_name = n->get_name();
+
+ which->set_text(0, new_name);
}
if (new_name == n->get_name())
@@ -967,8 +972,6 @@ void SceneTreeEditor::_bind_methods() {
ClassDB::bind_method("_cell_collapsed", &SceneTreeEditor::_cell_collapsed);
ClassDB::bind_method("_rmb_select", &SceneTreeEditor::_rmb_select);
ClassDB::bind_method("_warning_changed", &SceneTreeEditor::_warning_changed);
- ClassDB::bind_method("_toggle_visible", &SceneTreeEditor::_toggle_visible);
- ClassDB::bind_method("toggle_visible", &SceneTreeEditor::toggle_visible);
ClassDB::bind_method("_node_script_changed", &SceneTreeEditor::_node_script_changed);
ClassDB::bind_method("_node_visibility_changed", &SceneTreeEditor::_node_visibility_changed);