From d7073a77e1dfcdb7259737adf40e522264b89d1a Mon Sep 17 00:00:00 2001 From: Paulb23 Date: Tue, 12 Apr 2016 15:45:31 +0100 Subject: Added color themes to the text editor --- tools/editor/plugins/script_editor_plugin.cpp | 64 +++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (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 8e0bae6c7..dd8403c7b 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -951,6 +951,23 @@ void ScriptEditor::swap_lines(TextEdit *tx, int line1, int line2) tx->cursor_set_line(line2); } +void ScriptEditor::_file_dialog_action(String p_file) { + + switch (file_dialog_option) { + case FILE_SAVE_THEME_AS: { + if(!EditorSettings::get_singleton()->save_text_editor_theme_as(p_file)) { + editor->show_warning(TTR("Error while saving theme"), TTR("Error saving")); + } + } break; + case FILE_IMPORT_THEME: { + if(!EditorSettings::get_singleton()->import_text_editor_theme(p_file)) { + editor->show_warning(TTR("Error importing theme"), TTR("Error importing")); + } + } break; + } + file_dialog_option = -1; +} + void ScriptEditor::_menu_option(int p_option) { @@ -990,6 +1007,33 @@ void ScriptEditor::_menu_option(int p_option) { #endif } break; + case FILE_IMPORT_THEME: { + file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM); + file_dialog_option = FILE_IMPORT_THEME; + file_dialog->clear_filters(); + file_dialog->add_filter("*.tet"); + file_dialog->popup_centered_ratio(); + file_dialog->set_title(TTR("Import Theme")); + } break; + case FILE_RELOAD_THEME: { + EditorSettings::get_singleton()->load_text_editor_theme(); + } break; + case FILE_SAVE_THEME: { + if(!EditorSettings::get_singleton()->save_text_editor_theme()) { + editor->show_warning(TTR("Error while saving theme"), TTR("Error saving")); + } + } break; + case FILE_SAVE_THEME_AS: { + file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE); + file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM); + file_dialog_option = FILE_SAVE_THEME_AS; + file_dialog->clear_filters(); + file_dialog->add_filter("*.tet"); + file_dialog->set_current_path(EditorSettings::get_singleton()->get_settings_path() + "/text_editor_themes/" + EditorSettings::get_singleton()->get("text_editor/color_theme")); + file_dialog->popup_centered_ratio(); + file_dialog->set_title(TTR("Save Theme As..")); + } break; case SEARCH_HELP: { help_search_dialog->popup(); @@ -2122,6 +2166,13 @@ void ScriptEditor::_editor_settings_changed() { autosave_timer->stop(); } + if (current_theme == "") { + current_theme = EditorSettings::get_singleton()->get("text_editor/color_theme"); + } else if (current_theme != EditorSettings::get_singleton()->get("text_editor/color_theme")) { + current_theme = EditorSettings::get_singleton()->get("text_editor/color_theme"); + EditorSettings::get_singleton()->load_text_editor_theme(); + } + for(int i=0;iget_child_count();i++) { ScriptTextEditor *ste = tab_container->get_child(i)->cast_to(); @@ -2364,6 +2415,7 @@ void ScriptEditor::set_scene_root_script( Ref