diff options
Diffstat (limited to 'editor/plugins/script_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 44 |
1 files changed, 13 insertions, 31 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 736826c231..c605844728 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -43,12 +43,13 @@ #include "editor/editor_help_search.h" #include "editor/editor_node.h" #include "editor/editor_paths.h" -#include "editor/editor_run_script.h" #include "editor/editor_scale.h" +#include "editor/editor_script.h" #include "editor/editor_settings.h" #include "editor/filesystem_dock.h" #include "editor/find_in_files.h" #include "editor/gui/editor_file_dialog.h" +#include "editor/gui/editor_run_bar.h" #include "editor/inspector_dock.h" #include "editor/node_dock.h" #include "editor/plugins/shader_editor_plugin.h" @@ -943,11 +944,7 @@ void ScriptEditor::_resave_scripts(const String &p_str) { se->insert_final_newline(); if (convert_indent_on_save) { - if (use_space_indentation) { - se->convert_indent_to_spaces(); - } else { - se->convert_indent_to_tabs(); - } + se->convert_indent(); } Ref<TextFile> text_file = scr; @@ -1298,11 +1295,7 @@ void ScriptEditor::_menu_option(int p_option) { current->insert_final_newline(); if (convert_indent_on_save) { - if (use_space_indentation) { - current->convert_indent_to_spaces(); - } else { - current->convert_indent_to_tabs(); - } + current->convert_indent(); } Ref<Resource> resource = current->get_edited_resource(); @@ -1375,9 +1368,7 @@ void ScriptEditor::_menu_option(int p_option) { Ref<EditorScript> es = memnew(EditorScript); es->set_script(scr); - es->set_editor(EditorNode::get_singleton()); - - es->_run(); + es->run(); } break; case FILE_CLOSE: { if (current->is_unsaved()) { @@ -1592,7 +1583,7 @@ void ScriptEditor::_tab_changed(int p_which) { void ScriptEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - EditorNode::get_singleton()->connect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop)); + EditorRunBar::get_singleton()->connect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop)); EditorNode::get_singleton()->connect("script_add_function_request", callable_mp(this, &ScriptEditor::_add_callback)); EditorNode::get_singleton()->connect("resource_saved", callable_mp(this, &ScriptEditor::_res_saved_callback)); EditorNode::get_singleton()->connect("scene_saved", callable_mp(this, &ScriptEditor::_scene_saved_callback)); @@ -1643,10 +1634,11 @@ void ScriptEditor::_notification(int p_what) { get_tree()->connect("tree_changed", callable_mp(this, &ScriptEditor::_tree_changed)); InspectorDock::get_singleton()->connect("request_help", callable_mp(this, &ScriptEditor::_help_class_open)); EditorNode::get_singleton()->connect("request_help_search", callable_mp(this, &ScriptEditor::_help_search)); + EditorNode::get_singleton()->connect("scene_closed", callable_mp(this, &ScriptEditor::_close_builtin_scripts_from_scene)); } break; case NOTIFICATION_EXIT_TREE: { - EditorNode::get_singleton()->disconnect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop)); + EditorRunBar::get_singleton()->disconnect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop)); } break; case NOTIFICATION_APPLICATION_FOCUS_IN: { @@ -1677,7 +1669,7 @@ bool ScriptEditor::can_take_away_focus() const { } } -void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) { +void ScriptEditor::_close_builtin_scripts_from_scene(const String &p_scene) { for (int i = 0; i < tab_container->get_tab_count(); i++) { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i)); @@ -1687,7 +1679,7 @@ void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) { continue; } - if (scr->is_built_in() && scr->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed + if (scr->is_built_in() && scr->get_path().begins_with(p_scene)) { // Is an internal script and belongs to scene being closed. _close_tab(i, false); i--; } @@ -2451,11 +2443,7 @@ void ScriptEditor::save_current_script() { current->insert_final_newline(); if (convert_indent_on_save) { - if (use_space_indentation) { - current->convert_indent_to_spaces(); - } else { - current->convert_indent_to_tabs(); - } + current->convert_indent(); } Ref<Resource> resource = current->get_edited_resource(); @@ -2499,11 +2487,7 @@ void ScriptEditor::save_all_scripts() { } if (convert_indent_on_save) { - if (use_space_indentation) { - se->convert_indent_to_spaces(); - } else { - se->convert_indent_to_tabs(); - } + se->convert_indent(); } if (trim_trailing_whitespace_on_save) { @@ -2730,7 +2714,6 @@ void ScriptEditor::_editor_settings_changed() { trim_trailing_whitespace_on_save = EDITOR_GET("text_editor/behavior/files/trim_trailing_whitespace_on_save"); convert_indent_on_save = EDITOR_GET("text_editor/behavior/files/convert_indent_on_save"); - use_space_indentation = EDITOR_GET("text_editor/behavior/indent/type"); members_overview_enabled = EDITOR_GET("text_editor/script_list/show_members_overview"); help_overview_enabled = EDITOR_GET("text_editor/help/show_help_index"); @@ -3317,7 +3300,7 @@ void ScriptEditor::_help_class_open(const String &p_class) { eh->set_name(p_class); tab_container->add_child(eh); _go_to_tab(tab_container->get_tab_count() - 1); - eh->go_to_class(p_class, 0); + eh->go_to_class(p_class); eh->connect("go_to_help", callable_mp(this, &ScriptEditor::_help_class_goto)); _add_recent_script(p_class); _sort_list_on_update = true; @@ -4081,7 +4064,6 @@ ScriptEditor::ScriptEditor() { edit_pass = 0; trim_trailing_whitespace_on_save = EDITOR_GET("text_editor/behavior/files/trim_trailing_whitespace_on_save"); convert_indent_on_save = EDITOR_GET("text_editor/behavior/files/convert_indent_on_save"); - use_space_indentation = EDITOR_GET("text_editor/behavior/indent/type"); ScriptServer::edit_request_func = _open_script_request; |