summaryrefslogtreecommitdiff
path: root/editor/editor_settings.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-06-14 23:11:41 +0200
committerGitHub <noreply@github.com>2017-06-14 23:11:41 +0200
commit19017a760cbddee9bf0b40824ae9fbf5ca6d9042 (patch)
treec0338f78ed6a476261f16ee684f0654471eae5d5 /editor/editor_settings.cpp
parent80de0c35df3aea7155c6e8026448896c3c749126 (diff)
parent8361b1ce07266350ef6b6a2d34411030b7e587b2 (diff)
Merge pull request #9158 from Hinsbart/script_templates
Add ability to use custom script templates.
Diffstat (limited to 'editor/editor_settings.cpp')
-rw-r--r--editor/editor_settings.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 07c7fe97e4..3627a43279 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -292,6 +292,12 @@ void EditorSettings::create() {
dir->change_dir("..");
}
+ if (dir->change_dir("script_templates") != OK) {
+ dir->make_dir("script_templates");
+ } else {
+ dir->change_dir("..");
+ }
+
if (dir->change_dir("tmp") != OK) {
dir->make_dir("tmp");
} else {
@@ -946,6 +952,25 @@ bool EditorSettings::save_text_editor_theme_as(String p_file) {
return false;
}
+Vector<String> EditorSettings::get_script_templates(const String &p_extension) {
+
+ Vector<String> templates;
+ DirAccess *d = DirAccess::open(settings_path + "/script_templates");
+ if (d) {
+ d->list_dir_begin();
+ String file = d->get_next();
+ while (file != String()) {
+ if (file.get_extension() == p_extension) {
+ templates.push_back(file.get_basename());
+ }
+ file = d->get_next();
+ }
+ d->list_dir_end();
+ memdelete(d);
+ }
+ return templates;
+}
+
bool EditorSettings::_save_text_editor_theme(String p_file) {
String theme_section = "color_theme";
Ref<ConfigFile> cf = memnew(ConfigFile); // hex is better?