summaryrefslogtreecommitdiff
path: root/editor/scene_tree_dock.cpp
diff options
context:
space:
mode:
authorTomasz Chabora <kobewi4e@gmail.com>2019-08-09 16:31:31 +0200
committerTomasz Chabora <kobewi4e@gmail.com>2019-08-09 16:31:31 +0200
commit9fbba73dd5d447675275cb60b616aaac48462c2a (patch)
treef210b5b124a885ae4298cdfaac51cc13e83db96b /editor/scene_tree_dock.cpp
parent7bb2215ed0d7415179a8b59ad4766a3b573cf696 (diff)
Improve node Change Type option
Diffstat (limited to 'editor/scene_tree_dock.cpp')
-rw-r--r--editor/scene_tree_dock.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index aeee829de2..032b3a19a6 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -399,6 +399,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
Node *selected = scene_tree->get_selected();
+ if (!selected && !editor_selection->get_selected_node_list().empty())
+ selected = editor_selection->get_selected_node_list().front()->get();
+
if (selected)
create_dialog->popup_create(false, true, selected->get_class());
@@ -1983,6 +1986,10 @@ void SceneTreeDock::_create() {
} else if (current_option == TOOL_REPLACE) {
List<Node *> selection = editor_selection->get_selected_node_list();
ERR_FAIL_COND(selection.size() <= 0);
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action(TTR("Change type of node(s)"));
+
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Node *n = E->get();
ERR_FAIL_COND(!n);
@@ -1993,8 +2000,13 @@ void SceneTreeDock::_create() {
Node *newnode = Object::cast_to<Node>(c);
ERR_FAIL_COND(!newnode);
- replace_node(n, newnode);
+ ur->add_do_method(this, "replace_node", n, newnode, true, false);
+ ur->add_do_reference(newnode);
+ ur->add_undo_method(this, "replace_node", newnode, n, false, false);
+ ur->add_undo_reference(n);
}
+
+ ur->commit_action();
} else if (current_option == TOOL_REPARENT_TO_NEW_NODE) {
List<Node *> selection = editor_selection->get_selected_node_list();
ERR_FAIL_COND(selection.size() <= 0);