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
This commit is contained in:
@@ -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?
|
||||
|
||||
Reference in New Issue
Block a user