summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_file_system.cpp2
-rw-r--r--editor/editor_node.cpp18
-rw-r--r--editor/editor_paths.cpp14
-rw-r--r--editor/find_in_files.cpp2
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp24
-rw-r--r--editor/plugins/script_editor_plugin.cpp67
-rw-r--r--editor/plugins/script_editor_plugin.h3
-rw-r--r--editor/plugins/script_text_editor.cpp2
-rw-r--r--editor/plugins/text_editor.cpp4
-rw-r--r--editor/plugins/text_editor.h2
10 files changed, 91 insertions, 47 deletions
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index 6fef65c92d..767856f939 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -2163,7 +2163,7 @@ Error EditorFileSystem::_resource_import(const String &p_path) {
}
bool EditorFileSystem::_should_skip_directory(const String &p_path) {
- if (p_path == ProjectSettings::get_singleton()->get_project_data_path()) {
+ if (p_path.begins_with(ProjectSettings::get_singleton()->get_project_data_path())) {
return true;
}
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 5fd0a41788..9b7dc966e6 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -1776,19 +1776,25 @@ void EditorNode::restart_editor() {
}
void EditorNode::_save_all_scenes() {
+ bool all_saved = true;
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
Node *scene = editor_data.get_edited_scene_root(i);
- if (scene && scene->get_scene_file_path() != "" && DirAccess::exists(scene->get_scene_file_path().get_base_dir())) {
- if (i != editor_data.get_edited_scene()) {
- _save_scene(scene->get_scene_file_path(), i);
+ if (scene) {
+ if (scene->get_scene_file_path() != "" && DirAccess::exists(scene->get_scene_file_path().get_base_dir())) {
+ if (i != editor_data.get_edited_scene()) {
+ _save_scene(scene->get_scene_file_path(), i);
+ } else {
+ _save_scene_with_preview(scene->get_scene_file_path());
+ }
} else {
- _save_scene_with_preview(scene->get_scene_file_path());
+ all_saved = false;
}
- } else {
- show_warning(TTR("Could not save one or more scenes!"), TTR("Save All Scenes"));
}
}
+ if (!all_saved) {
+ show_warning(TTR("Could not save one or more scenes!"), TTR("Save All Scenes"));
+ }
_save_default_environment();
}
diff --git a/editor/editor_paths.cpp b/editor/editor_paths.cpp
index 71f13c0c2f..5b48cc2638 100644
--- a/editor/editor_paths.cpp
+++ b/editor/editor_paths.cpp
@@ -200,6 +200,20 @@ EditorPaths::EditorPaths() {
paths_valid = false;
}
}
+
+ // Check that the project data directory '.gdignore' file exists
+ String project_data_gdignore_file_path = project_data_dir.plus_file(".gdignore");
+ if (!FileAccess::exists(project_data_gdignore_file_path)) {
+ // Add an empty .gdignore file to avoid scan.
+ FileAccessRef f = FileAccess::open(project_data_gdignore_file_path, FileAccess::WRITE);
+ if (f) {
+ f->store_line("");
+ f->close();
+ } else {
+ ERR_PRINT("Failed to create file " + project_data_gdignore_file_path);
+ }
+ }
+
Engine::get_singleton()->set_shader_cache_path(project_data_dir);
// Editor metadata dir.
diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp
index 283496c0f1..b61f6e12eb 100644
--- a/editor/find_in_files.cpp
+++ b/editor/find_in_files.cpp
@@ -235,7 +235,7 @@ void FindInFiles::_scan_dir(String path, PackedStringArray &out_folders) {
// Ignore special dirs (such as .git and project data directory)
String project_data_dir_name = ProjectSettings::get_singleton()->get_project_data_dir_name();
- if (file.begins_with(".") || file == project_data_dir_name) {
+ if (file.begins_with(".") || file.begins_with(project_data_dir_name)) {
continue;
}
if (dir->current_is_hidden()) {
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index ef872bcead..8935f715e6 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -1174,7 +1174,6 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
if (!panning) {
if (b->is_pressed() &&
(b->get_button_index() == MOUSE_BUTTON_MIDDLE ||
- b->get_button_index() == MOUSE_BUTTON_RIGHT ||
(b->get_button_index() == MOUSE_BUTTON_LEFT && tool == TOOL_PAN) ||
(b->get_button_index() == MOUSE_BUTTON_LEFT && !EditorSettings::get_singleton()->get("editors/2d/simple_panning") && pan_pressed))) {
// Pan the viewport
@@ -1232,8 +1231,9 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
}
}
- if (is_pan_key) {
+ if (is_pan_key && pan_pressed != k->is_pressed()) {
pan_pressed = k->is_pressed();
+ _update_cursor();
}
}
@@ -2615,7 +2615,19 @@ void CanvasItemEditor::_update_cursor() {
c = CURSOR_HSIZE;
}
- viewport->set_default_cursor_shape(c);
+ if (pan_pressed) {
+ c = CURSOR_DRAG;
+ }
+
+ if (c != viewport->get_default_cursor_shape()) {
+ viewport->set_default_cursor_shape(c);
+
+ // Force refresh cursor if it's over the viewport.
+ if (viewport->get_global_rect().has_point(get_global_mouse_position())) {
+ DisplayServer::CursorShape ds_cursor_shape = (DisplayServer::CursorShape)viewport->get_default_cursor_shape();
+ DisplayServer::get_singleton()->cursor_set_shape(ds_cursor_shape);
+ }
+ }
}
void CanvasItemEditor::_draw_text_at_position(Point2 p_position, String p_string, Side p_side) {
@@ -4254,10 +4266,6 @@ void CanvasItemEditor::_button_tool_select(int p_index) {
viewport->update();
_update_cursor();
-
- // Request immediate refresh of cursor when using hot-keys to switch between tools
- DisplayServer::CursorShape ds_cursor_shape = (DisplayServer::CursorShape)viewport->get_default_cursor_shape();
- DisplayServer::get_singleton()->cursor_set_shape(ds_cursor_shape);
}
void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, bool p_scale, bool p_on_existing) {
@@ -5384,7 +5392,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
pan_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_tool_select), make_binds(TOOL_PAN));
pan_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/pan_mode", TTR("Pan Mode"), KEY_G));
pan_button->set_shortcut_context(this);
- pan_button->set_tooltip(TTR("Pan Mode"));
+ pan_button->set_tooltip(TTR("You can also use Pan View shortcut (Space by default) to pan in any mode."));
ruler_button = memnew(Button);
ruler_button->set_flat(true);
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 5df6743f4c..677a5f1f2c 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -214,6 +214,7 @@ Ref<EditorSyntaxHighlighter> EditorPlainTextSyntaxHighlighter::_create() const {
void ScriptEditorBase::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_base_editor"), &ScriptEditorBase::get_base_editor);
+ ClassDB::bind_method(D_METHOD("add_syntax_highlighter", "highlighter"), &ScriptEditorBase::add_syntax_highlighter);
ADD_SIGNAL(MethodInfo("name_changed"));
ADD_SIGNAL(MethodInfo("edited_script_changed"));
@@ -762,20 +763,24 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tselected);
if (current) {
- Ref<Script> script = current->get_edited_resource();
- if (p_save && script.is_valid()) {
+ RES file = current->get_edited_resource();
+ if (p_save && file.is_valid()) {
// Do not try to save internal scripts, but prompt to save in-memory
// scripts which are not saved to disk yet (have empty path).
- if (script->get_path().find("local://") == -1 && script->get_path().find("::") == -1) {
+ if (file->get_path().find("local://") == -1 && file->get_path().find("::") == -1) {
save_current_script();
}
}
- if (script.is_valid()) {
- if (!script->get_path().is_empty()) {
+ if (file.is_valid()) {
+ if (!file->get_path().is_empty()) {
// Only saved scripts can be restored.
- previous_scripts.push_back(script->get_path());
+ previous_scripts.push_back(file->get_path());
+ }
+
+ Ref<Script> script = file;
+ if (script.is_valid()) {
+ notify_script_close(script);
}
- notify_script_close(script);
}
}
@@ -1079,7 +1084,6 @@ void ScriptEditor::_file_dialog_action(String p_file) {
memdelete(file);
if (EditorFileSystem::get_singleton()) {
- const Vector<String> textfile_extensions = ((String)(EditorSettings::get_singleton()->get("docks/filesystem/textfile_extensions"))).split(",", false);
if (textfile_extensions.has(p_file.get_extension())) {
EditorFileSystem::get_singleton()->update_file(p_file);
}
@@ -1167,9 +1171,8 @@ void ScriptEditor::_menu_option(int p_option) {
file_dialog_option = FILE_NEW_TEXTFILE;
file_dialog->clear_filters();
- const Vector<String> textfile_ext = ((String)(EditorSettings::get_singleton()->get("docks/filesystem/textfile_extensions"))).split(",", false);
- for (int i = 0; i < textfile_ext.size(); i++) {
- file_dialog->add_filter("*." + textfile_ext[i] + " ; " + textfile_ext[i].to_upper());
+ for (const String &E : textfile_extensions) {
+ file_dialog->add_filter("*." + E + " ; " + E.to_upper());
}
file_dialog->popup_file_dialog();
file_dialog->set_title(TTR("New Text File..."));
@@ -1187,9 +1190,8 @@ void ScriptEditor::_menu_option(int p_option) {
file_dialog->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
- const Vector<String> textfile_ext = ((String)(EditorSettings::get_singleton()->get("docks/filesystem/textfile_extensions"))).split(",", false);
- for (int i = 0; i < textfile_ext.size(); i++) {
- file_dialog->add_filter("*." + textfile_ext[i] + " ; " + textfile_ext[i].to_upper());
+ for (const String &E : textfile_extensions) {
+ file_dialog->add_filter("*." + E + " ; " + E.to_upper());
}
file_dialog->popup_file_dialog();
@@ -1542,6 +1544,7 @@ void ScriptEditor::_notification(int p_what) {
EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &ScriptEditor::_editor_settings_changed));
EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &ScriptEditor::_filesystem_changed));
+ _editor_settings_changed();
[[fallthrough]];
}
case NOTIFICATION_TRANSLATION_CHANGED:
@@ -2117,7 +2120,7 @@ void ScriptEditor::_update_script_connections() {
}
}
-Ref<TextFile> ScriptEditor::_load_text_file(const String &p_path, Error *r_error) {
+Ref<TextFile> ScriptEditor::_load_text_file(const String &p_path, Error *r_error) const {
if (r_error) {
*r_error = ERR_FILE_CANT_OPEN;
}
@@ -2601,6 +2604,12 @@ void ScriptEditor::_save_layout() {
}
void ScriptEditor::_editor_settings_changed() {
+ textfile_extensions.clear();
+ const Vector<String> textfile_ext = ((String)(EditorSettings::get_singleton()->get("docks/filesystem/textfile_extensions"))).split(",", false);
+ for (const String &E : textfile_ext) {
+ textfile_extensions.insert(E);
+ }
+
trim_trailing_whitespace_on_save = EditorSettings::get_singleton()->get("text_editor/behavior/files/trim_trailing_whitespace_on_save");
convert_indent_on_save = EditorSettings::get_singleton()->get("text_editor/behavior/files/convert_indent_on_save");
use_space_indentation = EditorSettings::get_singleton()->get("text_editor/behavior/indent/type");
@@ -2807,12 +2816,22 @@ bool ScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data
if (file == "" || !FileAccess::exists(file)) {
continue;
}
- Ref<Script> scr = ResourceLoader::load(file);
- if (scr.is_valid()) {
- return true;
+ if (ResourceLoader::exists(file, "Script")) {
+ Ref<Script> scr = ResourceLoader::load(file);
+ if (scr.is_valid()) {
+ return true;
+ }
+ }
+
+ if (textfile_extensions.has(file.get_extension())) {
+ Error err;
+ Ref<TextFile> text_file = _load_text_file(file, &err);
+ if (text_file.is_valid() && err == OK) {
+ return true;
+ }
}
}
- return true;
+ return false;
}
return false;
@@ -2877,9 +2896,13 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
if (file == "" || !FileAccess::exists(file)) {
continue;
}
- Ref<Script> scr = ResourceLoader::load(file);
- if (scr.is_valid()) {
- edit(scr);
+
+ if (!ResourceLoader::exists(file, "Script") && !textfile_extensions.has(file.get_extension())) {
+ continue;
+ }
+
+ RES res = open_file(file);
+ if (res.is_valid()) {
if (tab_container->get_child_count() > num_tabs_before) {
tab_container->move_child(tab_container->get_child(tab_container->get_child_count() - 1), new_index);
num_tabs_before = tab_container->get_child_count();
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index ce26699280..8caebc1c8c 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -453,7 +453,8 @@ class ScriptEditor : public PanelContainer {
Ref<Script> _get_current_script();
Array _get_open_scripts() const;
- Ref<TextFile> _load_text_file(const String &p_path, Error *r_error);
+ Set<String> textfile_extensions;
+ Ref<TextFile> _load_text_file(const String &p_path, Error *r_error) const;
Error _save_text_file(Ref<TextFile> p_text_file, const String &p_path);
void _on_find_in_files_requested(String text);
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 1c251075de..2c02389db2 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -1341,8 +1341,6 @@ void ScriptTextEditor::_bind_methods() {
ClassDB::bind_method("_get_drag_data_fw", &ScriptTextEditor::get_drag_data_fw);
ClassDB::bind_method("_can_drop_data_fw", &ScriptTextEditor::can_drop_data_fw);
ClassDB::bind_method("_drop_data_fw", &ScriptTextEditor::drop_data_fw);
-
- ClassDB::bind_method(D_METHOD("add_syntax_highlighter", "highlighter"), &ScriptTextEditor::add_syntax_highlighter);
}
Control *ScriptTextEditor::get_edit_menu() {
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index 06ba8a6168..1fc7eb98e0 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -407,10 +407,6 @@ void TextEditor::_convert_case(CodeTextEditor::CaseStyle p_case) {
code_editor->convert_case(p_case);
}
-void TextEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("add_syntax_highlighter", "highlighter"), &TextEditor::add_syntax_highlighter);
-}
-
static ScriptEditorBase *create_editor(const RES &p_resource) {
if (Object::cast_to<TextFile>(*p_resource)) {
return memnew(TextEditor);
diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h
index 9308fec210..7404557f46 100644
--- a/editor/plugins/text_editor.h
+++ b/editor/plugins/text_editor.h
@@ -87,8 +87,6 @@ private:
};
protected:
- static void _bind_methods();
-
void _edit_option(int p_op);
void _make_context_menu(bool p_selection, bool p_can_fold, bool p_is_folded, Vector2 p_position);
void _text_edit_gui_input(const Ref<InputEvent> &ev);