From 9d5b80705912d85c3c7301ac0ea0afbf9372a660 Mon Sep 17 00:00:00 2001 From: fabriceci Date: Mon, 11 Oct 2021 11:30:59 +0200 Subject: [PATCH] Improve editor template workflow Co-Authored-By: jmb462 --- core/object/script_language.h | 23 +- editor/editor_settings.cpp | 40 -- editor/plugin_config_dialog.cpp | 54 +- editor/script_create_dialog.cpp | 573 +++++++++++------- editor/script_create_dialog.h | 33 +- editor/template_builders.py | 95 +++ modules/gdscript/SCsub | 2 + .../CharacterBody2D/basic_movement.gd | 29 + .../CharacterBody3D/basic_movement.gd | 32 + .../editor_templates/EditorPlugin/plugin.gd | 11 + .../EditorScript/basic_editor_script.gd | 7 + .../gdscript/editor_templates/Node/default.gd | 11 + .../gdscript/editor_templates/Object/empty.gd | 3 + modules/gdscript/editor_templates/SCsub | 16 + modules/gdscript/gdscript.cpp | 14 +- modules/gdscript/gdscript.h | 101 ++- modules/gdscript/gdscript_editor.cpp | 101 ++- modules/mono/SCsub | 2 + modules/mono/csharp_script.cpp | 67 +- modules/mono/csharp_script.h | 4 +- .../CharacterBody2D/basic_movement.cs | 41 ++ .../CharacterBody3D/basic_movement.cs | 44 ++ .../editor_templates/EditorPlugin/plugin.cs | 19 + .../EditorScript/basic_editor_script.cs | 14 + modules/mono/editor_templates/Node/default.cs | 19 + modules/mono/editor_templates/Object/empty.cs | 9 + modules/mono/editor_templates/SCsub | 16 + modules/visual_script/visual_script.cpp | 15 +- modules/visual_script/visual_script.h | 77 ++- 29 files changed, 944 insertions(+), 528 deletions(-) create mode 100644 editor/template_builders.py create mode 100644 modules/gdscript/editor_templates/CharacterBody2D/basic_movement.gd create mode 100644 modules/gdscript/editor_templates/CharacterBody3D/basic_movement.gd create mode 100644 modules/gdscript/editor_templates/EditorPlugin/plugin.gd create mode 100644 modules/gdscript/editor_templates/EditorScript/basic_editor_script.gd create mode 100644 modules/gdscript/editor_templates/Node/default.gd create mode 100644 modules/gdscript/editor_templates/Object/empty.gd create mode 100644 modules/gdscript/editor_templates/SCsub create mode 100644 modules/mono/editor_templates/CharacterBody2D/basic_movement.cs create mode 100644 modules/mono/editor_templates/CharacterBody3D/basic_movement.cs create mode 100644 modules/mono/editor_templates/EditorPlugin/plugin.cs create mode 100644 modules/mono/editor_templates/EditorScript/basic_editor_script.cs create mode 100644 modules/mono/editor_templates/Node/default.cs create mode 100644 modules/mono/editor_templates/Object/empty.cs create mode 100644 modules/mono/editor_templates/SCsub diff --git a/core/object/script_language.h b/core/object/script_language.h index 8d76cbf4795..4754b01a070 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -274,13 +274,32 @@ public: String message; }; + enum TemplateLocation { + TEMPLATE_BUILT_IN, + TEMPLATE_EDITOR, + TEMPLATE_PROJECT + }; + + struct ScriptTemplate { + String inherit = "Object"; + String name; + String description; + String content; + int id = 0; + TemplateLocation origin = TemplateLocation::TEMPLATE_BUILT_IN; + + String get_hash() const { + return itos(origin) + inherit + name; + } + }; + void get_core_type_words(List *p_core_type_words) const; virtual void get_reserved_words(List *p_words) const = 0; virtual bool is_control_flow_keyword(String p_string) const = 0; virtual void get_comment_delimiters(List *p_delimiters) const = 0; virtual void get_string_delimiters(List *p_delimiters) const = 0; - virtual Ref