From a78226c32ceb0614e079f5cdd5653af7be729dac Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Wed, 6 Jul 2016 20:35:49 -0300 Subject: Only allow built-in scripts to be edited when the scene they belong to is loaded, closes #5403 --- tools/editor/plugins/script_editor_plugin.cpp | 77 +++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 3 deletions(-) (limited to 'tools/editor/plugins/script_editor_plugin.cpp') diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index ee83b6b03..aa0f52d57 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -43,6 +43,28 @@ /*** SCRIPT EDITOR ****/ +static bool _can_open_in_editor(Script* p_script) { + + String path = p_script->get_path(); + + if (path.find("::")!=-1) { + //refuse handling this if it can't be edited + + bool valid=false; + for(int i=0;iget_editor_data().get_edited_scene_count();i++) { + if (path.begins_with(EditorNode::get_singleton()->get_editor_data().get_scene_path(i))) { + valid=true; + break; + } + } + + return valid; + } + + return true; +} + + class EditorScriptCodeCompletionCache : public ScriptCodeCompletionCache { @@ -747,9 +769,9 @@ void ScriptEditor::_go_to_tab(int p_idx) { _update_script_colors(); } -void ScriptEditor::_close_current_tab() { +void ScriptEditor::_close_tab(int p_idx) { - int selected = tab_container->get_current_tab(); + int selected = p_idx; if (selected<0 || selected>=tab_container->get_child_count()) return; @@ -795,6 +817,11 @@ void ScriptEditor::_close_current_tab() { _update_script_names(); EditorNode::get_singleton()->save_layout(); +} + +void ScriptEditor::_close_current_tab() { + + _close_tab(tab_container->get_current_tab()); } @@ -1681,6 +1708,33 @@ void ScriptEditor::_notification(int p_what) { } + +void ScriptEditor::close_builtin_scripts_from_scene(const String& p_scene) { + + + + for(int i=0;iget_child_count();i++) { + + ScriptTextEditor *ste = tab_container->get_child(i)->cast_to(); + + if (ste) { + + Ref