summaryrefslogtreecommitdiff
path: root/editor/scene_tree_dock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/scene_tree_dock.cpp')
-rw-r--r--editor/scene_tree_dock.cpp57
1 files changed, 31 insertions, 26 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 738d747956..7e4861cd09 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -336,9 +336,13 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_ATTACH_SCRIPT: {
+ List<Node *> selection = editor_selection->get_selected_node_list();
+ if (selection.empty())
+ break;
+
Node *selected = scene_tree->get_selected();
if (!selected)
- break;
+ selected = selection.front()->get();
Ref<Script> existing = selected->get_script();
@@ -373,7 +377,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_CLEAR_SCRIPT: {
- List<Node *> selection = editor_selection->get_selected_node_list();
+ Array selection = editor_selection->get_selected_nodes();
if (selection.empty())
return;
@@ -381,13 +385,14 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
editor_data->get_undo_redo().create_action(TTR("Clear Script"));
editor_data->get_undo_redo().add_do_method(editor, "push_item", (Script *)NULL);
- for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
+ for (int i = 0; i < selection.size(); i++) {
- Ref<Script> existing = E->get()->get_script();
+ Node *n = Object::cast_to<Node>(selection[i]);
+ Ref<Script> existing = n->get_script();
if (existing.is_valid()) {
const RefPtr empty;
- editor_data->get_undo_redo().add_do_method(E->get(), "set_script", empty);
- editor_data->get_undo_redo().add_undo_method(E->get(), "set_script", existing);
+ editor_data->get_undo_redo().add_do_method(n, "set_script", empty);
+ editor_data->get_undo_redo().add_undo_method(n, "set_script", existing);
}
}
@@ -583,7 +588,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
return;
}
- editor_data->get_undo_redo().create_action("Make node as Root");
+ editor_data->get_undo_redo().create_action(TTR("Make node as Root"));
editor_data->get_undo_redo().add_do_method(node->get_parent(), "remove_child", node);
editor_data->get_undo_redo().add_do_method(root->get_parent(), "remove_child", root);
editor_data->get_undo_redo().add_do_method(node, "add_child", root);
@@ -823,7 +828,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (TOOL_CREATE_FAVORITE == p_tool) {
String name = selected_favorite_root.get_slicec(' ', 0);
if (ScriptServer::is_global_class(name)) {
- new_node = Object::cast_to<Node>(ClassDB::instance(ScriptServer::get_global_class_base(name)));
+ new_node = Object::cast_to<Node>(ClassDB::instance(ScriptServer::get_global_class_native_base(name)));
Ref<Script> script = ResourceLoader::load(ScriptServer::get_global_class_path(name), "Script");
if (new_node && script.is_valid()) {
new_node->set_script(script.get_ref_ptr());
@@ -849,7 +854,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
}
- editor_data->get_undo_redo().create_action("New Scene Root");
+ editor_data->get_undo_redo().create_action(TTR("New Scene Root"));
editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", new_node);
editor_data->get_undo_redo().add_do_method(scene_tree, "update_tree");
editor_data->get_undo_redo().add_do_reference(new_node);
@@ -958,7 +963,7 @@ void SceneTreeDock::_notification(int p_what) {
Button *button_custom = memnew(Button);
node_shortcuts->add_child(button_custom);
- button_custom->set_text(TTR("Custom Node"));
+ button_custom->set_text(TTR("Other Node"));
button_custom->set_icon(get_icon("Add", "EditorIcons"));
button_custom->connect("pressed", this, "_tool_selected", make_binds(TOOL_NEW, false));
@@ -1152,17 +1157,17 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP
if (p.get_type() == Variant::NODE_PATH) {
// Goes through all paths to check if its matching
- for (List<Pair<NodePath, NodePath> >::Element *E = p_renames->front(); E; E = E->next()) {
+ for (List<Pair<NodePath, NodePath> >::Element *F = p_renames->front(); F; F = F->next()) {
NodePath root_path = p_base->get_path();
- NodePath rel_path_old = root_path.rel_path_to(E->get().first);
+ NodePath rel_path_old = root_path.rel_path_to(F->get().first);
- NodePath rel_path_new = E->get().second;
+ NodePath rel_path_new = F->get().second;
// if not empty, get new relative path
- if (E->get().second != NodePath()) {
- rel_path_new = root_path.rel_path_to(E->get().second);
+ if (F->get().second != NodePath()) {
+ rel_path_new = root_path.rel_path_to(F->get().second);
}
// if old path detected, then it needs to be replaced with the new one
@@ -1233,11 +1238,11 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP
if (!ran.has(i))
continue; //channel was removed
- for (List<Pair<NodePath, NodePath> >::Element *E = p_renames->front(); E; E = E->next()) {
+ for (List<Pair<NodePath, NodePath> >::Element *F = p_renames->front(); F; F = F->next()) {
- if (E->get().first == old_np) {
+ if (F->get().first == old_np) {
- if (E->get().second == NodePath()) {
+ if (F->get().second == NodePath()) {
//will be erased
int idx = 0;
@@ -1262,7 +1267,7 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP
} else {
//will be renamed
- NodePath rel_path = new_root_path.rel_path_to(E->get().second);
+ NodePath rel_path = new_root_path.rel_path_to(F->get().second);
NodePath new_path = NodePath(rel_path.get_names(), track_np.get_subnames(), false);
if (new_path == track_np)
@@ -1602,9 +1607,9 @@ void SceneTreeDock::_delete_confirm() {
List<Node *> owned;
n->get_owned_by(n->get_owner(), &owned);
Array owners;
- for (List<Node *>::Element *E = owned.front(); E; E = E->next()) {
+ for (List<Node *>::Element *F = owned.front(); F; F = F->next()) {
- owners.push_back(E->get());
+ owners.push_back(F->get());
}
editor_data->get_undo_redo().add_do_method(n->get_parent(), "remove_child", n);
@@ -1649,9 +1654,9 @@ void SceneTreeDock::_update_script_button() {
}
} else {
button_create_script->show();
- List<Node *> selection = EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list();
- for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Node *n = E->get();
+ Array selection = editor_selection->get_selected_nodes();
+ for (int i = 0; i < selection.size(); i++) {
+ Node *n = Object::cast_to<Node>(selection[i]);
if (!n->get_script().is_null()) {
button_clear_script->show();
return;
@@ -1796,7 +1801,7 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop
Object::Connection &c = F->get();
if (!(c.flags & Object::CONNECT_PERSIST))
continue;
- newnode->connect(c.signal, c.target, c.method, varray(), Object::CONNECT_PERSIST);
+ newnode->connect(c.signal, c.target, c.method, c.binds, Object::CONNECT_PERSIST);
}
}
@@ -2290,7 +2295,7 @@ void SceneTreeDock::_update_create_root_dialog() {
button->set_text(TTR(l));
String name = l.get_slicec(' ', 0);
if (ScriptServer::is_global_class(name))
- name = ScriptServer::get_global_class_base(name);
+ name = ScriptServer::get_global_class_native_base(name);
button->set_icon(EditorNode::get_singleton()->get_class_icon(name));
button->connect("pressed", this, "_favorite_root_selected", make_binds(l));
}