summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_autoload_settings.cpp4
-rw-r--r--editor/editor_export.cpp6
-rw-r--r--editor/editor_help.cpp15
-rw-r--r--editor/editor_help.h1
-rw-r--r--editor/editor_path.cpp3
-rw-r--r--editor/editor_properties.cpp15
-rw-r--r--editor/editor_settings.cpp13
-rw-r--r--editor/editor_settings.h3
-rw-r--r--editor/project_export.cpp13
-rw-r--r--editor/project_manager.cpp43
-rw-r--r--editor/script_create_dialog.cpp118
-rw-r--r--editor/script_create_dialog.h19
-rw-r--r--editor/script_editor_debugger.cpp2
13 files changed, 202 insertions, 53 deletions
diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp
index 555a7f99c8..f44e1b7b14 100644
--- a/editor/editor_autoload_settings.cpp
+++ b/editor/editor_autoload_settings.cpp
@@ -439,11 +439,11 @@ void EditorAutoloadSettings::update_autoload() {
}
if (info.in_editor) {
ERR_CONTINUE(!info.node);
- get_tree()->get_root()->remove_child(info.node);
+ get_tree()->get_root()->call_deferred("remove_child", info.node);
}
if (info.node) {
- memdelete(info.node);
+ info.node->queue_delete();
info.node = NULL;
}
}
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp
index e2a750cf08..e58c7c992a 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -148,6 +148,12 @@ String EditorExportPreset::get_include_filter() const {
void EditorExportPreset::set_export_path(const String &p_path) {
export_path = p_path;
+ /* NOTE(SonerSound): if there is a need to implement a PropertyHint that specifically indicates a relative path,
+ * this should be removed. */
+ if (export_path.is_abs_path()) {
+ String res_path = OS::get_singleton()->get_resource_dir();
+ export_path = res_path.path_to_file(export_path);
+ }
EditorExport::singleton->save_presets();
}
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 385b6924df..2e8f8ec646 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -164,6 +164,17 @@ void EditorHelp::_class_desc_select(const String &p_select) {
void EditorHelp::_class_desc_input(const Ref<InputEvent> &p_input) {
}
+void EditorHelp::_class_desc_resized() {
+ // Add extra horizontal margins for better readability.
+ // The margins increase as the width of the editor help container increases.
+ const int display_margin = MAX(30 * EDSCALE, get_parent_anchorable_rect().size.width - 900 * EDSCALE) * 0.5;
+
+ Ref<StyleBox> class_desc_stylebox = EditorNode::get_singleton()->get_theme_base()->get_stylebox("normal", "RichTextLabel")->duplicate();
+ class_desc_stylebox->set_default_margin(MARGIN_LEFT, display_margin);
+ class_desc_stylebox->set_default_margin(MARGIN_RIGHT, display_margin);
+ class_desc->add_style_override("normal", class_desc_stylebox);
+}
+
void EditorHelp::_add_type(const String &p_type, const String &p_enum) {
String t = p_type;
@@ -1488,6 +1499,7 @@ void EditorHelp::_bind_methods() {
ClassDB::bind_method("_class_list_select", &EditorHelp::_class_list_select);
ClassDB::bind_method("_class_desc_select", &EditorHelp::_class_desc_select);
ClassDB::bind_method("_class_desc_input", &EditorHelp::_class_desc_input);
+ ClassDB::bind_method("_class_desc_resized", &EditorHelp::_class_desc_resized);
ClassDB::bind_method("_request_help", &EditorHelp::_request_help);
ClassDB::bind_method("_unhandled_key_input", &EditorHelp::_unhandled_key_input);
ClassDB::bind_method("_search", &EditorHelp::_search);
@@ -1506,8 +1518,11 @@ EditorHelp::EditorHelp() {
add_child(class_desc);
class_desc->set_v_size_flags(SIZE_EXPAND_FILL);
class_desc->add_color_override("selection_color", get_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
+
class_desc->connect("meta_clicked", this, "_class_desc_select");
class_desc->connect("gui_input", this, "_class_desc_input");
+ class_desc->connect("resized", this, "_class_desc_resized");
+ _class_desc_resized();
// Added second so it opens at the bottom so it won't offset the entire widget.
find_bar = memnew(FindBar);
diff --git a/editor/editor_help.h b/editor/editor_help.h
index 3824ba231e..1019cafffc 100644
--- a/editor/editor_help.h
+++ b/editor/editor_help.h
@@ -151,6 +151,7 @@ class EditorHelp : public VBoxContainer {
void _class_list_select(const String &p_select);
void _class_desc_select(const String &p_select);
void _class_desc_input(const Ref<InputEvent> &p_input);
+ void _class_desc_resized();
Error _goto_desc(const String &p_class, int p_vscr = -1);
//void _update_history_buttons();
diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp
index 12510e27de..23d28261d1 100644
--- a/editor/editor_path.cpp
+++ b/editor/editor_path.cpp
@@ -78,6 +78,9 @@ void EditorPath::_about_to_show() {
}
void EditorPath::update_path() {
+ set_text("");
+ set_tooltip("");
+ set_icon(NULL);
for (int i = 0; i < history->get_path_size(); i++) {
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 20ba07c102..378dd34e39 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -209,13 +209,7 @@ EditorPropertyTextEnum::EditorPropertyTextEnum() {
void EditorPropertyPath::_path_selected(const String &p_path) {
- String final_path = p_path;
- if (final_path.is_abs_path()) {
- String res_path = OS::get_singleton()->get_resource_dir() + "/";
- final_path = res_path.path_to_file(final_path);
- }
-
- emit_changed(get_edited_property(), final_path);
+ emit_changed(get_edited_property(), p_path);
update_property();
}
void EditorPropertyPath::_path_pressed() {
@@ -228,13 +222,6 @@ void EditorPropertyPath::_path_pressed() {
}
String full_path = get_edited_object()->get(get_edited_property());
- if (full_path.is_rel_path()) {
-
- if (!DirAccess::exists(full_path.get_base_dir())) {
- DirAccessRef da(DirAccess::create(DirAccess::ACCESS_FILESYSTEM));
- da->make_dir_recursive(full_path.get_base_dir());
- }
- }
dialog->clear_filters();
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index ef5a067d01..ea6361665c 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -1209,6 +1209,11 @@ String EditorSettings::get_script_templates_dir() const {
return get_settings_dir().plus_file("script_templates");
}
+String EditorSettings::get_project_script_templates_dir() const {
+
+ return ProjectSettings::get_singleton()->get("editor/script_templates_search_path");
+}
+
// Cache directory
String EditorSettings::get_cache_dir() const {
@@ -1429,10 +1434,14 @@ bool EditorSettings::is_default_text_editor_theme() {
return _is_default_text_editor_theme(p_file.get_file().to_lower());
}
-Vector<String> EditorSettings::get_script_templates(const String &p_extension) {
+Vector<String> EditorSettings::get_script_templates(const String &p_extension, const String &p_custom_path) {
Vector<String> templates;
- DirAccess *d = DirAccess::open(get_script_templates_dir());
+ String template_dir = get_script_templates_dir();
+ if (!p_custom_path.empty()) {
+ template_dir = p_custom_path;
+ }
+ DirAccess *d = DirAccess::open(template_dir);
if (d) {
d->list_dir_begin();
String file = d->get_next();
diff --git a/editor/editor_settings.h b/editor/editor_settings.h
index 890850629e..0738185e95 100644
--- a/editor/editor_settings.h
+++ b/editor/editor_settings.h
@@ -166,6 +166,7 @@ public:
String get_project_settings_dir() const;
String get_text_editor_themes_dir() const;
String get_script_templates_dir() const;
+ String get_project_script_templates_dir() const;
String get_cache_dir() const;
String get_feature_profiles_dir() const;
@@ -187,7 +188,7 @@ public:
bool save_text_editor_theme_as(String p_file);
bool is_default_text_editor_theme();
- Vector<String> get_script_templates(const String &p_extension);
+ Vector<String> get_script_templates(const String &p_extension, const String &p_custom_path = String());
String get_editor_layouts_config() const;
void add_shortcut(const String &p_name, Ref<ShortCut> &p_shortcut);
diff --git a/editor/project_export.cpp b/editor/project_export.cpp
index c78a81dbe0..956da92c35 100644
--- a/editor/project_export.cpp
+++ b/editor/project_export.cpp
@@ -931,17 +931,8 @@ void ProjectExportDialog::_export_project() {
export_project->add_filter("*." + extension_list[i] + " ; " + platform->get_name() + " Export");
}
- String current_preset_export_path = current->get_export_path();
-
- if (current_preset_export_path != "") {
-
- if (!DirAccess::exists(current_preset_export_path.get_base_dir())) {
-
- DirAccessRef da(DirAccess::create(DirAccess::ACCESS_FILESYSTEM));
- da->make_dir_recursive(current_preset_export_path.get_base_dir());
- }
-
- export_project->set_current_path(current_preset_export_path);
+ if (current->get_export_path() != "") {
+ export_project->set_current_path(current->get_export_path());
} else {
if (extension_list.size() >= 1) {
export_project->set_current_file(default_filename + "." + extension_list[0]);
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index b88b2b38a0..5709bdc3fa 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -1255,19 +1255,22 @@ void ProjectList::create_project_item_control(int p_index) {
TextureRect *tf = memnew(TextureRect);
tf->set_texture(get_icon("DefaultProjectIcon", "EditorIcons"));
+ if (item.missing) {
+ tf->set_modulate(Color(1, 1, 1, 0.5));
+ }
hb->add_child(tf);
hb->icon = tf;
VBoxContainer *vb = memnew(VBoxContainer);
if (item.grayed)
- vb->set_modulate(Color(0.5, 0.5, 0.5));
+ vb->set_modulate(Color(1, 1, 1, 0.5));
vb->set_h_size_flags(SIZE_EXPAND_FILL);
hb->add_child(vb);
Control *ec = memnew(Control);
ec->set_custom_minimum_size(Size2(0, 1));
ec->set_mouse_filter(MOUSE_FILTER_PASS);
vb->add_child(ec);
- Label *title = memnew(Label(item.project_name));
+ Label *title = memnew(Label(!item.missing ? item.project_name : TTR("Missing Project")));
title->add_font_override("font", get_font("title", "EditorFonts"));
title->add_color_override("font_color", font_color);
title->set_clip_text(true);
@@ -1278,12 +1281,21 @@ void ProjectList::create_project_item_control(int p_index) {
vb->add_child(path_hb);
Button *show = memnew(Button);
- show->set_icon(get_icon("Load", "EditorIcons")); // Folder icon
+ // Display a folder icon if the project directory can be opened, or a "broken file" icon if it can't
+ show->set_icon(get_icon(!item.missing ? "Load" : "FileBroken", "EditorIcons"));
show->set_flat(true);
- show->set_modulate(Color(1, 1, 1, 0.5));
+ if (!item.grayed) {
+ // Don't make the icon less prominent if the parent is already grayed out
+ show->set_modulate(Color(1, 1, 1, 0.5));
+ }
path_hb->add_child(show);
- show->connect("pressed", this, "_show_project", varray(item.path));
- show->set_tooltip(TTR("Show in File Manager"));
+
+ if (!item.missing) {
+ show->connect("pressed", this, "_show_project", varray(item.path));
+ show->set_tooltip(TTR("Show in File Manager"));
+ } else {
+ show->set_tooltip(TTR("Error: Project is missing on the filesystem."));
+ }
Label *fpath = memnew(Label(item.path));
path_hb->add_child(fpath);
@@ -1737,10 +1749,18 @@ void ProjectManager::_update_project_buttons() {
Vector<ProjectList::Item> selected_projects = _project_list->get_selected_projects();
bool empty_selection = selected_projects.empty();
+ bool is_missing_project_selected = false;
+ for (int i = 0; i < selected_projects.size(); ++i) {
+ if (selected_projects[i].missing) {
+ is_missing_project_selected = true;
+ break;
+ }
+ }
+
erase_btn->set_disabled(empty_selection);
- open_btn->set_disabled(empty_selection);
- rename_btn->set_disabled(empty_selection);
- run_btn->set_disabled(empty_selection);
+ open_btn->set_disabled(empty_selection || is_missing_project_selected);
+ rename_btn->set_disabled(empty_selection || is_missing_project_selected);
+ run_btn->set_disabled(empty_selection || is_missing_project_selected);
erase_missing_btn->set_visible(_project_list->is_any_project_missing());
}
@@ -1928,6 +1948,9 @@ void ProjectManager::_open_selected_projects_ask() {
}
ProjectList::Item project = _project_list->get_selected_projects()[0];
+ if (project.missing) {
+ return;
+ }
// Update the project settings or don't open
String conf = project.path.plus_file("project.godot");
@@ -2110,7 +2133,7 @@ void ProjectManager::_erase_project() {
void ProjectManager::_erase_missing_projects() {
- erase_missing_ask->set_text(TTR("Remove all missing projects from the list? The project folders' contents won't be modified."));
+ erase_missing_ask->set_text(TTR("Remove all missing projects from the list?\nThe project folders' contents won't be modified."));
erase_missing_ask->popup_centered_minsize();
}
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp
index 7d0f40fe91..ffb3f5feab 100644
--- a/editor/script_create_dialog.cpp
+++ b/editor/script_create_dialog.cpp
@@ -34,6 +34,7 @@
#include "core/os/file_access.h"
#include "core/project_settings.h"
#include "core/script_language.h"
+#include "core/string_builder.h"
#include "editor/create_dialog.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
@@ -238,16 +239,22 @@ void ScriptCreateDialog::_parent_name_changed(const String &p_parent) {
void ScriptCreateDialog::_template_changed(int p_template) {
- String selected_template = p_template == 0 ? "" : template_menu->get_item_text(template_menu->get_selected());
+ String selected_template = p_template == 0 ? "" : template_menu->get_item_text(p_template);
EditorSettings::get_singleton()->set_project_metadata("script_setup", "last_selected_template", selected_template);
if (p_template == 0) {
//default
script_template = "";
return;
}
- String ext = ScriptServer::get_language(language_menu->get_selected())->get_extension();
- String name = template_list[p_template - 1] + "." + ext;
- script_template = EditorSettings::get_singleton()->get_script_templates_dir().plus_file(name);
+ int selected_id = template_menu->get_selected_id();
+
+ for (int i = 0; i < template_list.size(); i++) {
+ const ScriptTemplateInfo &sinfo = template_list[i];
+ if (sinfo.id == selected_id) {
+ script_template = sinfo.dir.plus_file(sinfo.name + "." + sinfo.extension);
+ break;
+ }
+ }
}
void ScriptCreateDialog::ok_pressed() {
@@ -368,23 +375,77 @@ void ScriptCreateDialog::_lang_changed(int l) {
bool use_templates = language->is_using_templates();
template_menu->set_disabled(!use_templates);
template_menu->clear();
- if (use_templates) {
- template_list = EditorSettings::get_singleton()->get_script_templates(language->get_extension());
+ if (use_templates) {
+ _update_script_templates(language->get_extension());
String last_lang = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_language", "");
String last_template = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_template", "");
template_menu->add_item(TTR("Default"));
+
+ ScriptTemplateInfo *templates = template_list.ptrw();
+
+ Vector<String> origin_names;
+ origin_names.push_back(TTR("Project"));
+ origin_names.push_back(TTR("Editor"));
+ int cur_origin = -1;
+
+ // Populate script template items previously sorted and now grouped by origin
for (int i = 0; i < template_list.size(); i++) {
- String s = template_list[i].capitalize();
- template_menu->add_item(s);
- if (language_menu->get_item_text(language_menu->get_selected()) == last_lang && last_template == s) {
- template_menu->select(i + 1);
+
+ if (int(templates[i].origin) != cur_origin) {
+ template_menu->add_separator();
+
+ String origin_name = origin_names[templates[i].origin];
+
+ int last_index = template_menu->get_item_count() - 1;
+ template_menu->set_item_text(last_index, origin_name);
+
+ cur_origin = templates[i].origin;
}
+ String item_name = templates[i].name.capitalize();
+ template_menu->add_item(item_name);
+
+ int new_id = template_menu->get_item_count() - 1;
+ templates[i].id = new_id;
}
- } else {
+ // Disable overridden
+ for (Map<String, Vector<int> >::Element *E = template_overrides.front(); E; E = E->next()) {
+ const Vector<int> &overrides = E->get();
+
+ if (overrides.size() == 1) {
+ continue; // doesn't override anything
+ }
+ const ScriptTemplateInfo &extended = template_list[overrides[0]];
+
+ StringBuilder override_info;
+ override_info += TTR("Overrides");
+ override_info += ": ";
+
+ for (int i = 1; i < overrides.size(); i++) {
+ const ScriptTemplateInfo &overridden = template_list[overrides[i]];
+
+ int disable_index = template_menu->get_item_index(overridden.id);
+ template_menu->set_item_disabled(disable_index, true);
+ override_info += origin_names[overridden.origin];
+ if (i < overrides.size() - 1) {
+ override_info += ", ";
+ }
+ }
+ template_menu->set_item_icon(extended.id, get_icon("Override", "EditorIcons"));
+ template_menu->get_popup()->set_item_tooltip(extended.id, override_info.as_string());
+ }
+ // Reselect last selected template
+ for (int i = 0; i < template_menu->get_item_count(); i++) {
+ const String &ti = template_menu->get_item_text(i);
+ if (language_menu->get_item_text(language_menu->get_selected()) == last_lang && last_template == ti) {
+ template_menu->select(i);
+ break;
+ }
+ }
+ } else {
template_menu->add_item(TTR("N/A"));
script_template = "";
}
@@ -396,6 +457,41 @@ void ScriptCreateDialog::_lang_changed(int l) {
_update_dialog();
}
+void ScriptCreateDialog::_update_script_templates(const String &p_extension) {
+
+ template_list.clear();
+ template_overrides.clear();
+
+ Vector<String> dirs;
+
+ // Ordered from local to global for correct override mechanism
+ dirs.push_back(EditorSettings::get_singleton()->get_project_script_templates_dir());
+ dirs.push_back(EditorSettings::get_singleton()->get_script_templates_dir());
+
+ for (int i = 0; i < dirs.size(); i++) {
+
+ Vector<String> list = EditorSettings::get_singleton()->get_script_templates(p_extension, dirs[i]);
+
+ for (int j = 0; j < list.size(); j++) {
+ ScriptTemplateInfo sinfo;
+ sinfo.origin = ScriptOrigin(i);
+ sinfo.dir = dirs[i];
+ sinfo.name = list[j];
+ sinfo.extension = p_extension;
+ template_list.push_back(sinfo);
+
+ if (!template_overrides.has(sinfo.name)) {
+ Vector<int> overrides;
+ overrides.push_back(template_list.size() - 1); // first one
+ template_overrides.insert(sinfo.name, overrides);
+ } else {
+ Vector<int> &overrides = template_overrides[sinfo.name];
+ overrides.push_back(template_list.size() - 1);
+ }
+ }
+ }
+}
+
void ScriptCreateDialog::_built_in_pressed() {
if (internal->is_pressed()) {
diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h
index 202846fd3c..31cf2478cf 100644
--- a/editor/script_create_dialog.h
+++ b/editor/script_create_dialog.h
@@ -78,8 +78,25 @@ class ScriptCreateDialog : public ConfirmationDialog {
int current_language;
int default_language;
bool re_check_path;
+
+ enum ScriptOrigin {
+ SCRIPT_ORIGIN_PROJECT,
+ SCRIPT_ORIGIN_EDITOR,
+ };
+ struct ScriptTemplateInfo {
+ int id;
+ ScriptOrigin origin;
+ String dir;
+ String name;
+ String extension;
+ };
+
String script_template;
- Vector<String> template_list;
+ Vector<ScriptTemplateInfo> template_list;
+ Map<String, Vector<int> > template_overrides; // name : indices
+
+ void _update_script_templates(const String &p_extension);
+
String base_type;
void _path_hbox_sorted();
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index f7ff754a0b..fc5aecdbe9 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -1376,7 +1376,7 @@ void ScriptEditorDebugger::stop() {
profiler->set_enabled(true);
inspect_scene_tree->clear();
- inspector->edit(NULL);
+ EditorNode::get_singleton()->edit_current();
EditorNode::get_singleton()->get_pause_button()->set_pressed(false);
EditorNode::get_singleton()->get_pause_button()->set_disabled(true);
EditorNode::get_singleton()->get_scene_tree_dock()->hide_remote_tree();