diff options
author | Andreas Haas <hinsbart@gmail.com> | 2017-06-13 20:03:08 +0000 |
---|---|---|
committer | Andreas Haas <hinsbart@gmail.com> | 2017-06-13 20:03:08 +0000 |
commit | 8361b1ce07266350ef6b6a2d34411030b7e587b2 (patch) | |
tree | ff9cab7037410224c1b76aab30f394305b523fe8 /modules/visual_script | |
parent | a8a1f2e2a864e6b58d5bcf1c7e53a43cdb6d95d9 (diff) |
Add ability to use custom script templates.
Templates will be loaded from .godot/script_templates
For now they're disabled for GDNative.
Ideas for further improvements:
- Add a "Save as Template" option to the script editor, as it can normally only save to res://
- Support more placeholders / custom placeholders
Diffstat (limited to 'modules/visual_script')
-rw-r--r-- | modules/visual_script/visual_script.cpp | 11 | ||||
-rw-r--r-- | modules/visual_script/visual_script.h | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index aec60391d3..bb8111ce99 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -2369,6 +2369,17 @@ Ref<Script> VisualScriptLanguage::get_template(const String &p_class_name, const script->set_instance_base_type(p_base_class_name); return script; } + +bool VisualScriptLanguage::is_using_templates() { + + return true; +} + +void VisualScriptLanguage::make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script) { + Ref<VisualScript> script = p_script; + script->set_instance_base_type(p_base_class_name); +} + bool VisualScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions) const { return false; diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index 72843099c7..1ccc358342 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -564,6 +564,8 @@ public: virtual void get_comment_delimiters(List<String> *p_delimiters) const; virtual void get_string_delimiters(List<String> *p_delimiters) const; virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const; + virtual bool is_using_templates(); + virtual void make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script); virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = NULL) const; virtual Script *create_script() const; virtual bool has_named_classes() const; |