diff options
Diffstat (limited to 'tools/editor/plugins/script_editor_plugin.cpp')
-rw-r--r-- | tools/editor/plugins/script_editor_plugin.cpp | 64 |
1 files changed, 51 insertions, 13 deletions
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 7deb856fa6..edc5d460e7 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -130,6 +130,7 @@ void ScriptEditorQuickOpen::_bind_methods() { ObjectTypeDB::bind_method(_MD("_confirmed"),&ScriptEditorQuickOpen::_confirmed); ObjectTypeDB::bind_method(_MD("_sbox_input"),&ScriptEditorQuickOpen::_sbox_input); + ADD_SIGNAL(MethodInfo("goto_line",PropertyInfo(Variant::INT,"line"))); } @@ -815,11 +816,11 @@ void ScriptEditor::_menu_option(int p_option) { if (scr.is_null()) return; - int begin, end; - begin = tx->get_selection_from_line(); + if (tx->is_selection_active()) { - end = tx->get_selection_to_line(); + int begin = tx->get_selection_from_line(); + int end = tx->get_selection_to_line(); for (int i = begin; i <= end; i++) { String line_text = tx->get_line(i); @@ -839,7 +840,7 @@ void ScriptEditor::_menu_option(int p_option) { } else { - begin = tx->cursor_get_line(); + int begin = tx->cursor_get_line(); String line_text = tx->get_line(begin); // begins with tab if (line_text.begins_with("\t")) @@ -865,11 +866,10 @@ void ScriptEditor::_menu_option(int p_option) { if (scr.is_null()) return; - int begin, end; - begin = tx->get_selection_from_line(); if (tx->is_selection_active()) { - end = tx->get_selection_to_line(); + int begin = tx->get_selection_from_line(); + int end = tx->get_selection_to_line(); for (int i = begin; i <= end; i++) { String line_text = tx->get_line(i); @@ -879,7 +879,7 @@ void ScriptEditor::_menu_option(int p_option) { } else { - begin = tx->cursor_get_line(); + int begin = tx->cursor_get_line(); String line_text = tx->get_line(begin); line_text = '\t' + line_text; tx->set_line(begin, line_text); @@ -912,11 +912,12 @@ void ScriptEditor::_menu_option(int p_option) { if (scr.is_null()) return; - int begin, end; - begin = tx->get_selection_from_line(); + + if (tx->is_selection_active()) { - end = tx->get_selection_to_line(); + int begin = tx->get_selection_from_line(); + int end = tx->get_selection_to_line(); for (int i = begin; i <= end; i++) { String line_text = tx->get_line(i); @@ -930,7 +931,7 @@ void ScriptEditor::_menu_option(int p_option) { } else { - begin = tx->cursor_get_line(); + int begin = tx->cursor_get_line(); String line_text = tx->get_line(begin); if (line_text.begins_with("#")) @@ -1089,6 +1090,18 @@ void ScriptEditor::_notification(int p_what) { editor->connect("stop_pressed",this,"_editor_stop"); editor->connect("script_add_function_request",this,"_add_callback"); editor->connect("resource_saved",this,"_res_saved_callback"); + autosave_timer->connect("timeout",this,"_autosave_scripts"); + { + float autosave_time = EditorSettings::get_singleton()->get("text_editor/autosave_interval_secs"); + if (autosave_time>0) { + autosave_timer->set_wait_time(autosave_time); + autosave_timer->start(); + } else { + autosave_timer->stop(); + } + } + + EditorSettings::get_singleton()->connect("settings_changed",this,"_editor_settings_changed"); } @@ -1339,7 +1352,8 @@ void ScriptEditor::_bind_methods() { ObjectTypeDB::bind_method("_breaked",&ScriptEditor::_breaked); ObjectTypeDB::bind_method("_show_debugger",&ScriptEditor::_show_debugger); ObjectTypeDB::bind_method("_get_debug_tooltip",&ScriptEditor::_get_debug_tooltip); - + ObjectTypeDB::bind_method("_autosave_scripts",&ScriptEditor::_autosave_scripts); + ObjectTypeDB::bind_method("_editor_settings_changed",&ScriptEditor::_editor_settings_changed); } @@ -1568,6 +1582,25 @@ void ScriptEditor::_add_callback(Object *p_obj, const String& p_function, const } +void ScriptEditor::_editor_settings_changed() { + + print_line("settings changed"); + float autosave_time = EditorSettings::get_singleton()->get("text_editor/autosave_interval_secs"); + if (autosave_time>0) { + autosave_timer->set_wait_time(autosave_time); + autosave_timer->start(); + } else { + autosave_timer->stop(); + } + +} + +void ScriptEditor::_autosave_scripts() { + + print_line("autosaving"); + save_external_data(); +} + ScriptEditor::ScriptEditor(EditorNode *p_editor) { editor=p_editor; @@ -1718,6 +1751,11 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { v_split->add_child(debugger); debugger->connect("breaked",this,"_breaked"); + + autosave_timer = memnew( Timer ); + autosave_timer->set_one_shot(false); + add_child(autosave_timer); + // debugger_gui->hide(); } |