summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-07-13 11:51:19 +0200
committerGitHub <noreply@github.com>2017-07-13 11:51:19 +0200
commit9fd7beaa936be4d3cf3182902dc94087f24e9f69 (patch)
tree0d165abe81f91d0b99d4ae32a2247e163c0c3062 /editor
parent5cd4fdfda506c28fd99c2af24b7fe46a164015d2 (diff)
parent7ac2b6d3b34ec919ba3b8b929f8ff12821844805 (diff)
Merge pull request #9622 from Hinsbart/default_templates
Add default GDScript templates.
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_settings.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 5c6ba892cb..7a7b2b7d1e 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -216,6 +216,20 @@ Variant _EDITOR_DEF(const String &p_var, const Variant &p_default) {
return p_default;
}
+static void _create_script_templates(const String &p_path) {
+
+ FileAccess *file = FileAccess::open(p_path.plus_file("no_comments.gd"), FileAccess::WRITE);
+ ERR_FAIL_COND(!file);
+ String script = String("extends %BASE%\n\nfunc _ready():\n%TS%pass\n");
+ file->store_string(script);
+ file->close();
+ file->reopen(p_path.plus_file("empty.gd"), FileAccess::WRITE);
+ script = "extends %BASE%\n\n";
+ file->store_string(script);
+ file->close();
+ memdelete(file);
+}
+
void EditorSettings::create() {
if (singleton.ptr())
@@ -294,6 +308,7 @@ void EditorSettings::create() {
if (dir->change_dir("script_templates") != OK) {
dir->make_dir("script_templates");
+ _create_script_templates(dir->get_current_dir() + "/script_templates");
} else {
dir->change_dir("..");
}