summaryrefslogtreecommitdiffstats
path: root/editor/editor_node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r--editor/editor_node.cpp73
1 files changed, 54 insertions, 19 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 4fb1a86ce2..5b24fb1559 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -771,6 +771,12 @@ void EditorNode::_notification(int p_what) {
EditorFileDialog::set_default_display_mode((EditorFileDialog::DisplayMode)EDITOR_GET("filesystem/file_dialog/display_mode").operator int());
}
+ if (EDITOR_GET("interface/editor/import_resources_when_unfocused")) {
+ scan_changes_timer->start();
+ } else {
+ scan_changes_timer->stop();
+ }
+
follow_system_theme = EDITOR_GET("interface/theme/follow_system_theme");
use_system_accent_color = EDITOR_GET("interface/theme/use_system_accent_color");
@@ -1445,6 +1451,9 @@ void EditorNode::_dialog_display_load_error(String p_file, Error p_error) {
case ERR_FILE_NOT_FOUND: {
show_accept(vformat(TTR("Missing file '%s' or one of its dependencies."), p_file.get_file()), TTR("OK"));
} break;
+ case ERR_FILE_UNRECOGNIZED: {
+ show_accept(vformat(TTR("File '%s' is saved in a format that is newer than the formats supported by this version of Godot, so it can't be opened."), p_file.get_file()), TTR("OK"));
+ } break;
default: {
show_accept(vformat(TTR("Error while loading file '%s'."), p_file.get_file()), TTR("OK"));
} break;
@@ -2355,7 +2364,13 @@ static bool overrides_external_editor(Object *p_object) {
void EditorNode::_add_to_history(const Object *p_object, const String &p_property, bool p_inspector_only) {
ObjectID id = p_object->get_instance_id();
- if (id != editor_history.get_current()) {
+ ObjectID history_id = editor_history.get_current();
+ if (id != history_id) {
+ const MultiNodeEdit *multi_node_edit = Object::cast_to<const MultiNodeEdit>(p_object);
+ const MultiNodeEdit *history_multi_node_edit = Object::cast_to<const MultiNodeEdit>(ObjectDB::get_instance(history_id));
+ if (multi_node_edit && history_multi_node_edit && multi_node_edit->is_same_selection(history_multi_node_edit)) {
+ return;
+ }
if (p_inspector_only) {
editor_history.add_object(id, String(), true);
} else if (p_property.is_empty()) {
@@ -2449,6 +2464,7 @@ void EditorNode::_edit_current(bool p_skip_foreign, bool p_skip_inspector_update
if (current_node->is_inside_tree()) {
NodeDock::get_singleton()->set_node(current_node);
SceneTreeDock::get_singleton()->set_selected(current_node);
+ SceneTreeDock::get_singleton()->set_selection({ current_node });
InspectorDock::get_singleton()->update(current_node);
if (!inspector_only && !skip_main_plugin) {
skip_main_plugin = stay_in_script_editor_on_node_selected && !ScriptEditor::get_singleton()->is_editor_floating() && ScriptEditor::get_singleton()->is_visible_in_tree();
@@ -2470,13 +2486,13 @@ void EditorNode::_edit_current(bool p_skip_foreign, bool p_skip_inspector_update
} else {
Node *selected_node = nullptr;
+ Vector<Node *> multi_nodes;
if (current_obj->is_class("MultiNodeEdit")) {
Node *scene = get_edited_scene();
if (scene) {
MultiNodeEdit *multi_node_edit = Object::cast_to<MultiNodeEdit>(current_obj);
int node_count = multi_node_edit->get_node_count();
if (node_count > 0) {
- List<Node *> multi_nodes;
for (int node_index = 0; node_index < node_count; ++node_index) {
Node *node = scene->get_node(multi_node_edit->get_node(node_index));
if (node) {
@@ -2486,7 +2502,7 @@ void EditorNode::_edit_current(bool p_skip_foreign, bool p_skip_inspector_update
if (!multi_nodes.is_empty()) {
// Pick the top-most node.
multi_nodes.sort_custom<Node::Comparator>();
- selected_node = multi_nodes.front()->get();
+ selected_node = multi_nodes[0];
}
}
}
@@ -2495,6 +2511,7 @@ void EditorNode::_edit_current(bool p_skip_foreign, bool p_skip_inspector_update
InspectorDock::get_inspector_singleton()->edit(current_obj);
NodeDock::get_singleton()->set_node(nullptr);
SceneTreeDock::get_singleton()->set_selected(selected_node);
+ SceneTreeDock::get_singleton()->set_selection(multi_nodes);
InspectorDock::get_singleton()->update(nullptr);
}
@@ -3055,8 +3072,8 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
case HELP_DOCS: {
OS::get_singleton()->shell_open(VERSION_DOCS_URL "/");
} break;
- case HELP_QA: {
- OS::get_singleton()->shell_open("https://godotengine.org/qa/");
+ case HELP_FORUM: {
+ OS::get_singleton()->shell_open("https://forum.godotengine.org/");
} break;
case HELP_REPORT_A_BUG: {
OS::get_singleton()->shell_open("https://github.com/godotengine/godot/issues");
@@ -3832,6 +3849,8 @@ void EditorNode::_set_current_scene_nocheck(int p_idx) {
if (tabs_to_close.is_empty()) {
callable_mp(this, &EditorNode::_set_main_scene_state).call_deferred(state, get_edited_scene()); // Do after everything else is done setting up.
}
+
+ _update_undo_redo_allowed();
}
void EditorNode::setup_color_picker(ColorPicker *p_picker) {
@@ -3917,14 +3936,18 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
}
int prev = editor_data.get_edited_scene();
- int idx = editor_data.add_edited_scene(-1);
+ int idx = prev;
- if (!editor_data.get_edited_scene_root() && editor_data.get_edited_scene_count() == 2) {
- _remove_edited_scene();
- } else if (p_silent_change_tab) {
- _set_current_scene_nocheck(idx);
+ if (prev == -1 || editor_data.get_edited_scene_root() || !editor_data.get_scene_path(prev).is_empty()) {
+ idx = editor_data.add_edited_scene(-1);
+
+ if (p_silent_change_tab) {
+ _set_current_scene_nocheck(idx);
+ } else {
+ _set_current_scene(idx);
+ }
} else {
- _set_current_scene(idx);
+ EditorUndoRedoManager::get_singleton()->clear_history(false, editor_data.get_current_edited_scene_history_id());
}
dependency_errors.clear();
@@ -3941,7 +3964,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
dependency_error->show(DependencyErrorDialog::MODE_SCENE, lpath, errors);
opening_prev = false;
- if (prev != -1) {
+ if (prev != -1 && prev != idx) {
_set_current_scene(prev);
editor_data.remove_scene(idx);
}
@@ -3952,7 +3975,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
_dialog_display_load_error(lpath, err);
opening_prev = false;
- if (prev != -1) {
+ if (prev != -1 && prev != idx) {
_set_current_scene(prev);
editor_data.remove_scene(idx);
}
@@ -3988,7 +4011,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
sdata.unref();
_dialog_display_load_error(lpath, ERR_FILE_CORRUPT);
opening_prev = false;
- if (prev != -1) {
+ if (prev != -1 && prev != idx) {
_set_current_scene(prev);
editor_data.remove_scene(idx);
}
@@ -4014,10 +4037,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
_load_editor_plugin_states_from_config(editor_state_cf);
}
- _update_title();
- scene_tabs->update_scene_tabs();
- _add_to_recent_scenes(lpath);
-
if (editor_folding.has_folding_data(lpath)) {
editor_folding.load_scene_folding(new_scene, lpath);
} else if (EDITOR_GET("interface/inspector/auto_unfold_foreign_scenes")) {
@@ -4057,6 +4076,14 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
save_editor_layout_delayed();
}
+ if (p_set_inherited) {
+ EditorUndoRedoManager::get_singleton()->set_history_as_unsaved(editor_data.get_current_edited_scene_history_id());
+ }
+
+ _update_title();
+ scene_tabs->update_scene_tabs();
+ _add_to_recent_scenes(lpath);
+
return OK;
}
@@ -6574,6 +6601,12 @@ EditorNode::EditorNode() {
editor_layout_save_delay_timer->set_one_shot(true);
editor_layout_save_delay_timer->connect("timeout", callable_mp(this, &EditorNode::_save_editor_layout));
+ scan_changes_timer = memnew(Timer);
+ scan_changes_timer->set_wait_time(0.5);
+ scan_changes_timer->set_autostart(EDITOR_GET("interface/editor/import_resources_when_unfocused"));
+ scan_changes_timer->connect("timeout", callable_mp(EditorFileSystem::get_singleton(), &EditorFileSystem::scan_changes));
+ add_child(scan_changes_timer);
+
top_split = memnew(VSplitContainer);
center_split->add_child(top_split);
top_split->set_v_size_flags(Control::SIZE_EXPAND_FILL);
@@ -6642,6 +6675,8 @@ EditorNode::EditorNode() {
main_menu->set_menu_tooltip(0, TTR("Operations with scene files."));
accept = memnew(AcceptDialog);
+ accept->set_autowrap(true);
+ accept->set_min_size(Vector2i(600, 0));
accept->set_unparent_when_invisible(true);
save_accept = memnew(AcceptDialog);
@@ -6886,7 +6921,7 @@ EditorNode::EditorNode() {
help_menu->add_icon_shortcut(theme->get_icon(SNAME("HelpSearch"), EditorStringName(EditorIcons)), ED_GET_SHORTCUT("editor/editor_help"), HELP_SEARCH);
help_menu->add_separator();
help_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/online_docs", TTR("Online Documentation")), HELP_DOCS);
- help_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/q&a", TTR("Questions & Answers")), HELP_QA);
+ help_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/forum", TTR("Forum")), HELP_FORUM);
help_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/community", TTR("Community")), HELP_COMMUNITY);
help_menu->add_separator();
help_menu->add_icon_shortcut(theme->get_icon(SNAME("ActionCopy"), EditorStringName(EditorIcons)), ED_SHORTCUT_AND_COMMAND("editor/copy_system_info", TTR("Copy System Info")), HELP_COPY_SYSTEM_INFO);