summaryrefslogtreecommitdiff
path: root/editor/script_create_dialog.h
diff options
context:
space:
mode:
Diffstat (limited to 'editor/script_create_dialog.h')
-rw-r--r--editor/script_create_dialog.h39
1 files changed, 20 insertions, 19 deletions
diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h
index 7c2ef1e150..67d30e21fb 100644
--- a/editor/script_create_dialog.h
+++ b/editor/script_create_dialog.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -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;
@@ -57,15 +59,18 @@ class ScriptCreateDialog : public ConfirmationDialog {
OptionButton *language_menu;
OptionButton *template_menu;
LineEdit *file_path;
+ LineEdit *internal_name;
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;
@@ -75,29 +80,18 @@ 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;
int default_language;
bool re_check_path;
- 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;
- };
+ Control *path_controls[2];
+ Control *name_controls[2];
- 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;
@@ -105,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);
@@ -121,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);