summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-05-04 23:32:40 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-05-04 23:32:40 -0300
commit68700ee3a98298709371c5b970c3083ef534faac (patch)
treebefec434d1ffa33b6c5f20f0afb869ac69f773ec /tools
parenta6e6c5b8787d8218762f8a52ed99ef4248248c94 (diff)
Proper support for code editor autosaving (disabled by default)
Diffstat (limited to 'tools')
-rw-r--r--tools/editor/editor_settings.cpp2
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp40
-rw-r--r--tools/editor/plugins/script_editor_plugin.h4
3 files changed, 44 insertions, 2 deletions
diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp
index 52eeb1fefd..9a4505efed 100644
--- a/tools/editor/editor_settings.cpp
+++ b/tools/editor/editor_settings.cpp
@@ -408,7 +408,7 @@ void EditorSettings::_load_defaults() {
set("text_editor/idle_parse_delay",2);
set("text_editor/create_signal_callbacks",true);
- set("text_editor/autosave_interval_seconds",60);
+ set("text_editor/autosave_interval_secs",0);
set("text_editor/font","");
hints["text_editor/font"]=PropertyInfo(Variant::STRING,"text_editor/font",PROPERTY_HINT_GLOBAL_FILE,"*.fnt");
set("text_editor/auto_brace_complete", false);
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index 7deb856fa6..e6e311cfa1 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")));
}
@@ -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();
}
diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h
index 7526138112..acfdd1e966 100644
--- a/tools/editor/plugins/script_editor_plugin.h
+++ b/tools/editor/plugins/script_editor_plugin.h
@@ -154,6 +154,7 @@ class ScriptEditor : public VBoxContainer {
MenuButton *window_menu;
MenuButton *debug_menu;
MenuButton *help_menu;
+ Timer *autosave_timer;
uint64_t idle;
TabContainer *tab_container;
@@ -195,6 +196,9 @@ class ScriptEditor : public VBoxContainer {
void _show_debugger(bool p_show);
void _update_window_menu();
+ void _editor_settings_changed();
+ void _autosave_scripts();
+
static ScriptEditor *script_editor;
protected:
void _notification(int p_what);