diff options
Diffstat (limited to 'tools/editor/scene_tree_dock.cpp')
-rw-r--r-- | tools/editor/scene_tree_dock.cpp | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index c4c3a10f74..e7f4beb46e 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -108,6 +108,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { case TOOL_NEW: { + + if (!_validate_no_foreign()) + break; create_dialog->popup_centered_ratio(); } break; case TOOL_INSTANCE: { @@ -124,6 +127,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; } + if (!_validate_no_foreign()) + break; + file->set_mode(FileDialog::MODE_OPEN_FILE); List<String> extensions; ResourceLoader::get_recognized_extensions_for_type("PackedScene",&extensions); @@ -147,6 +153,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (!current) break; + if (!_validate_no_foreign()) + break; connect_dialog->popup_centered_ratio(); connect_dialog->set_node(current); @@ -156,6 +164,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { Node *current = scene_tree->get_selected(); if (!current) break; + if (!_validate_no_foreign()) + break; groups_editor->set_current(current); groups_editor->popup_centered_ratio(); } break; @@ -165,6 +175,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (!selected) break; + if (!_validate_no_foreign()) + break; + Ref<Script> existing = selected->get_script(); if (existing.is_valid()) editor->push_item(existing.ptr()); @@ -183,6 +196,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (!scene_tree->get_selected()) break; + if (scene_tree->get_selected()==edited_scene) { @@ -195,6 +209,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } + if (!_validate_no_foreign()) + break; + Node * node=scene_tree->get_selected(); ERR_FAIL_COND(!node->get_parent()); int current_pos = node->get_index(); @@ -214,6 +231,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (!edited_scene) break; + if (editor_selection->is_selected(edited_scene)) { @@ -225,6 +243,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; } + if (!_validate_no_foreign()) + break; + List<Node*> selection = editor_selection->get_selected_node_list(); List<Node*> reselect; @@ -313,6 +334,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (!scene_tree->get_selected()) break; + if (editor_selection->is_selected(edited_scene)) { @@ -324,6 +346,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; } + if (!_validate_no_foreign()) + break; + List<Node*> nodes = editor_selection->get_selected_node_list(); Set<Node*> nodeset; for(List<Node*>::Element *E=nodes.front();E;E=E->next()) { @@ -341,6 +366,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (remove_list.empty()) return; + if (!_validate_no_foreign()) + break; + if (p_confirm_override) { _delete_confirm(); @@ -707,6 +735,25 @@ void SceneTreeDock::_node_prerenamed(Node* p_node, const String& p_new_name) { } +bool SceneTreeDock::_validate_no_foreign() { + + List<Node*> selection = editor_selection->get_selected_node_list(); + + for (List<Node*>::Element *E=selection.front();E;E=E->next()) { + + if (E->get()!=edited_scene && E->get()->get_owner()!=edited_scene) { + + accept->get_ok()->set_text("Makes Sense!"); + accept->set_text("Can't operate on nodes from a foreign scene!"); + accept->popup_centered(Size2(300,70));; + return false; + + } + } + + return true; +} + void SceneTreeDock::_node_reparent(NodePath p_path,bool p_node_only) { @@ -894,7 +941,7 @@ void SceneTreeDock::_delete_confirm() { void SceneTreeDock::_update_tool_buttons() { Node *sel = scene_tree->get_selected(); - bool disable = !sel; + bool disable = !sel || (sel!=edited_scene && sel->get_owner()!=edited_scene); bool disable_root = disable || sel->get_parent()==scene_root; tool_buttons[TOOL_INSTANCE]->set_disabled(disable); |