From 9d5b80705912d85c3c7301ac0ea0afbf9372a660 Mon Sep 17 00:00:00 2001 From: fabriceci Date: Mon, 11 Oct 2021 11:30:59 +0200 Subject: Improve editor template workflow Co-Authored-By: jmb462 --- editor/editor_settings.cpp | 40 --- editor/plugin_config_dialog.cpp | 54 +--- editor/script_create_dialog.cpp | 575 +++++++++++++++++++++++++--------------- editor/script_create_dialog.h | 33 ++- editor/template_builders.py | 95 +++++++ 5 files changed, 481 insertions(+), 316 deletions(-) create mode 100644 editor/template_builders.py (limited to 'editor') diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 1ac1d6f048..fabf497d9c 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -781,43 +781,6 @@ bool EditorSettings::_is_default_text_editor_theme(String p_theme_name) { return p_theme_name == "default" || p_theme_name == "godot 2" || p_theme_name == "custom"; } -static Dictionary _get_builtin_script_templates() { - Dictionary templates; - - // No Comments - templates["no_comments.gd"] = - "extends %BASE%\n" - "\n" - "\n" - "func _ready()%VOID_RETURN%:\n" - "%TS%pass\n"; - - // Empty - templates["empty.gd"] = - "extends %BASE%" - "\n" - "\n"; - - return templates; -} - -static void _create_script_templates(const String &p_path) { - Dictionary templates = _get_builtin_script_templates(); - List keys; - templates.get_key_list(&keys); - FileAccessRef file = FileAccess::create(FileAccess::ACCESS_FILESYSTEM); - DirAccessRef dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - dir->change_dir(p_path); - for (int i = 0; i < keys.size(); i++) { - if (!dir->file_exists(keys[i])) { - Error err = file->reopen(p_path.plus_file((String)keys[i]), FileAccess::WRITE); - ERR_FAIL_COND(err != OK); - file->store_string(templates[keys[i]]); - file->close(); - } - } -} - // PUBLIC METHODS EditorSettings *EditorSettings::get_singleton() { @@ -852,10 +815,7 @@ void EditorSettings::create() { } if (EditorPaths::get_singleton()->are_paths_valid()) { - _create_script_templates(EditorPaths::get_singleton()->get_config_dir().plus_file("script_templates")); - // Validate editor config file. - DirAccessRef dir = DirAccess::open(EditorPaths::get_singleton()->get_config_dir()); String config_file_name = "editor_settings-" + itos(VERSION_MAJOR) + ".tres"; config_file_path = EditorPaths::get_singleton()->get_config_dir().plus_file(config_file_name); diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp index ad22aafb2b..e6e53d2e29 100644 --- a/editor/plugin_config_dialog.cpp +++ b/editor/plugin_config_dialog.cpp @@ -36,12 +36,6 @@ #include "editor/editor_plugin.h" #include "editor/editor_scale.h" #include "editor/project_settings_editor.h" -#include "scene/gui/grid_container.h" - -#include "modules/modules_enabled.gen.h" // For gdscript. -#ifdef MODULE_GDSCRIPT_ENABLED -#include "modules/gdscript/gdscript.h" -#endif void PluginConfigDialog::_clear_fields() { name_edit->set_text(""); @@ -76,42 +70,16 @@ void PluginConfigDialog::_on_confirmed() { String lang_name = ScriptServer::get_language(lang_idx)->get_name(); Ref