diff options
author | fabriceci <fabricecipolla@gmail.com> | 2021-10-11 11:30:59 +0200 |
---|---|---|
committer | jmb462 <jmb462@gmail.com> | 2022-01-02 21:52:09 +0100 |
commit | 9d5b80705912d85c3c7301ac0ea0afbf9372a660 (patch) | |
tree | e9528ac06fcfc29bc43846713d1c3ddb94becc22 /editor/script_create_dialog.h | |
parent | 28174d531b7128f0281fc2b88da2f4962fd3513e (diff) | |
download | redot-engine-9d5b80705912d85c3c7301ac0ea0afbf9372a660.tar.gz |
Improve editor template workflow
Co-Authored-By: jmb462 <jmb462@gmail.com>
Diffstat (limited to 'editor/script_create_dialog.h')
-rw-r--r-- | editor/script_create_dialog.h | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h index dba798eea7..2c980f6e6e 100644 --- a/editor/script_create_dialog.h +++ b/editor/script_create_dialog.h @@ -31,6 +31,7 @@ #ifndef SCRIPT_CREATE_DIALOG_H #define SCRIPT_CREATE_DIALOG_H +#include "core/object/script_language.h" #include "editor/editor_file_dialog.h" #include "editor/editor_settings.h" #include "scene/gui/check_box.h" @@ -50,6 +51,7 @@ class ScriptCreateDialog : public ConfirmationDialog { Label *path_error_label; Label *builtin_warning_label; Label *script_name_warning_label; + Label *template_info_label; PanelContainer *status_panel; LineEdit *parent_name; Button *parent_browse_button; @@ -61,12 +63,14 @@ class ScriptCreateDialog : public ConfirmationDialog { Button *path_button; EditorFileDialog *file_browse; CheckBox *internal; + CheckBox *use_templates; VBoxContainer *path_vb; AcceptDialog *alert; CreateDialog *select_class; bool path_valid; bool create_new; bool is_browsing_parent; + String template_inactive_message; String initial_bp; bool is_new_script_created; bool is_path_valid; @@ -76,6 +80,7 @@ class ScriptCreateDialog : public ConfirmationDialog { bool is_parent_name_valid; bool is_class_name_valid; bool is_built_in; + bool is_using_templates; bool built_in_enabled; bool load_enabled; int current_language; @@ -85,23 +90,8 @@ class ScriptCreateDialog : public ConfirmationDialog { Control *path_controls[2]; Control *name_controls[2]; - enum ScriptOrigin { - SCRIPT_ORIGIN_PROJECT, - SCRIPT_ORIGIN_EDITOR, - }; - struct ScriptTemplateInfo { - int id = 0; - ScriptOrigin origin = ScriptOrigin::SCRIPT_ORIGIN_EDITOR; - String dir; - String name; - String extension; - }; - - String script_template; - Vector<ScriptTemplateInfo> template_list; - Map<String, Vector<int>> template_overrides; // name : indices - - void _update_script_templates(const String &p_extension); + Vector<ScriptLanguage::ScriptTemplate> template_list; + ScriptLanguage *language; String base_type; @@ -109,8 +99,9 @@ class ScriptCreateDialog : public ConfirmationDialog { bool _can_be_built_in(); void _path_changed(const String &p_path = String()); void _path_submitted(const String &p_path = String()); - void _lang_changed(int l = 0); + void _language_changed(int l = 0); void _built_in_pressed(); + void _use_template_pressed(); bool _validate_parent(const String &p_string); bool _validate_class(const String &p_string); String _validate_path(const String &p_path, bool p_file_must_exist); @@ -125,9 +116,15 @@ class ScriptCreateDialog : public ConfirmationDialog { virtual void ok_pressed() override; void _create_new(); void _load_exist(); + Vector<String> get_hierarchy(String p_object) const; void _msg_script_valid(bool valid, const String &p_msg = String()); void _msg_path_valid(bool valid, const String &p_msg = String()); + void _update_template_menu(); void _update_dialog(); + ScriptLanguage::ScriptTemplate _get_current_template() const; + Vector<ScriptLanguage::ScriptTemplate> _get_user_templates(const ScriptLanguage *language, const StringName &p_object, const String &p_dir, const ScriptLanguage::TemplateLocation &p_origin) const; + ScriptLanguage::ScriptTemplate _parse_template(const ScriptLanguage *language, const String &p_path, const String &p_filename, const ScriptLanguage::TemplateLocation &p_origin, const String &p_inherits) const; + String _get_script_origin_label(const ScriptLanguage::TemplateLocation &p_origin) const; protected: void _notification(int p_what); |