|
@@ -609,10 +609,6 @@ void EditorNode::_notification(int p_what) {
|
|
} break;
|
|
} break;
|
|
|
|
|
|
case NOTIFICATION_PROCESS: {
|
|
case NOTIFICATION_PROCESS: {
|
|
- if (opening_prev && !confirmation->is_visible()) {
|
|
|
|
- opening_prev = false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
bool global_unsaved = EditorUndoRedoManager::get_singleton()->is_history_unsaved(EditorUndoRedoManager::GLOBAL_HISTORY);
|
|
bool global_unsaved = EditorUndoRedoManager::get_singleton()->is_history_unsaved(EditorUndoRedoManager::GLOBAL_HISTORY);
|
|
bool scene_or_global_unsaved = global_unsaved || EditorUndoRedoManager::get_singleton()->is_history_unsaved(editor_data.get_current_edited_scene_history_id());
|
|
bool scene_or_global_unsaved = global_unsaved || EditorUndoRedoManager::get_singleton()->is_history_unsaved(editor_data.get_current_edited_scene_history_id());
|
|
if (unsaved_cache != scene_or_global_unsaved) {
|
|
if (unsaved_cache != scene_or_global_unsaved) {
|
|
@@ -1343,7 +1339,7 @@ Error EditorNode::load_resource(const String &p_resource, bool p_ignore_broken_d
|
|
for (const String &E : dependency_errors[p_resource]) {
|
|
for (const String &E : dependency_errors[p_resource]) {
|
|
errors.push_back(E);
|
|
errors.push_back(E);
|
|
}
|
|
}
|
|
- dependency_error->show(DependencyErrorDialog::MODE_RESOURCE, p_resource, errors);
|
|
|
|
|
|
+ dependency_error->show(p_resource, errors);
|
|
dependency_errors.erase(p_resource);
|
|
dependency_errors.erase(p_resource);
|
|
|
|
|
|
return ERR_FILE_MISSING_DEPENDENCIES;
|
|
return ERR_FILE_MISSING_DEPENDENCIES;
|
|
@@ -1353,6 +1349,16 @@ Error EditorNode::load_resource(const String &p_resource, bool p_ignore_broken_d
|
|
return OK;
|
|
return OK;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+Error EditorNode::load_scene_or_resource(const String &p_path, bool p_ignore_broken_deps, bool p_change_scene_tab_if_already_open) {
|
|
|
|
+ if (ClassDB::is_parent_class(ResourceLoader::get_resource_type(p_path), "PackedScene")) {
|
|
|
|
+ if (!p_change_scene_tab_if_already_open && EditorNode::get_singleton()->is_scene_open(p_path)) {
|
|
|
|
+ return OK;
|
|
|
|
+ }
|
|
|
|
+ return EditorNode::get_singleton()->load_scene(p_path, p_ignore_broken_deps);
|
|
|
|
+ }
|
|
|
|
+ return EditorNode::get_singleton()->load_resource(p_path, p_ignore_broken_deps);
|
|
|
|
+}
|
|
|
|
+
|
|
void EditorNode::edit_node(Node *p_node) {
|
|
void EditorNode::edit_node(Node *p_node) {
|
|
push_item(p_node);
|
|
push_item(p_node);
|
|
}
|
|
}
|
|
@@ -2796,13 +2802,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
|
quick_open_dialog->popup_dialog({ "Script" }, callable_mp(this, &EditorNode::_quick_opened));
|
|
quick_open_dialog->popup_dialog({ "Script" }, callable_mp(this, &EditorNode::_quick_opened));
|
|
} break;
|
|
} break;
|
|
case FILE_OPEN_PREV: {
|
|
case FILE_OPEN_PREV: {
|
|
- if (previous_scenes.is_empty()) {
|
|
|
|
- break;
|
|
|
|
|
|
+ if (!prev_closed_scenes.is_empty()) {
|
|
|
|
+ load_scene(prev_closed_scenes.back()->get());
|
|
}
|
|
}
|
|
- opening_prev = true;
|
|
|
|
- open_request(previous_scenes.back()->get());
|
|
|
|
- previous_scenes.pop_back();
|
|
|
|
-
|
|
|
|
} break;
|
|
} break;
|
|
case EditorSceneTabs::SCENE_CLOSE_OTHERS: {
|
|
case EditorSceneTabs::SCENE_CLOSE_OTHERS: {
|
|
tab_closing_menu_option = -1;
|
|
tab_closing_menu_option = -1;
|
|
@@ -3458,10 +3460,7 @@ void EditorNode::_discard_changes(const String &p_str) {
|
|
case SCENE_TAB_CLOSE: {
|
|
case SCENE_TAB_CLOSE: {
|
|
Node *scene = editor_data.get_edited_scene_root(tab_closing_idx);
|
|
Node *scene = editor_data.get_edited_scene_root(tab_closing_idx);
|
|
if (scene != nullptr) {
|
|
if (scene != nullptr) {
|
|
- String scene_filename = scene->get_scene_file_path();
|
|
|
|
- if (!scene_filename.is_empty()) {
|
|
|
|
- previous_scenes.push_back(scene_filename);
|
|
|
|
- }
|
|
|
|
|
|
+ _update_prev_closed_scenes(scene->get_scene_file_path(), true);
|
|
}
|
|
}
|
|
|
|
|
|
// Don't close tabs when exiting the editor (required for "restore_scenes_on_load" setting).
|
|
// Don't close tabs when exiting the editor (required for "restore_scenes_on_load" setting).
|
|
@@ -3519,14 +3518,9 @@ void EditorNode::_update_file_menu_opened() {
|
|
file_menu->set_item_disabled(file_menu->get_item_index(FILE_SAVE_ALL_SCENES), true);
|
|
file_menu->set_item_disabled(file_menu->get_item_index(FILE_SAVE_ALL_SCENES), true);
|
|
file_menu->set_item_tooltip(file_menu->get_item_index(FILE_SAVE_ALL_SCENES), TTR("All scenes are already saved."));
|
|
file_menu->set_item_tooltip(file_menu->get_item_index(FILE_SAVE_ALL_SCENES), TTR("All scenes are already saved."));
|
|
}
|
|
}
|
|
- file_menu->set_item_disabled(file_menu->get_item_index(FILE_OPEN_PREV), previous_scenes.is_empty());
|
|
|
|
_update_undo_redo_allowed();
|
|
_update_undo_redo_allowed();
|
|
}
|
|
}
|
|
|
|
|
|
-void EditorNode::_update_file_menu_closed() {
|
|
|
|
- file_menu->set_item_disabled(file_menu->get_item_index(FILE_OPEN_PREV), false);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
void EditorNode::_palette_quick_open_dialog() {
|
|
void EditorNode::_palette_quick_open_dialog() {
|
|
quick_open_color_palette->popup_dialog({ "ColorPalette" }, palette_file_selected_callback);
|
|
quick_open_color_palette->popup_dialog({ "ColorPalette" }, palette_file_selected_callback);
|
|
quick_open_color_palette->set_title(TTR("Quick Open Color Palette..."));
|
|
quick_open_color_palette->set_title(TTR("Quick Open Color Palette..."));
|
|
@@ -4044,6 +4038,8 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
|
|
}
|
|
}
|
|
|
|
|
|
String lpath = ProjectSettings::get_singleton()->localize_path(ResourceUID::ensure_path(p_scene));
|
|
String lpath = ProjectSettings::get_singleton()->localize_path(ResourceUID::ensure_path(p_scene));
|
|
|
|
+ _update_prev_closed_scenes(lpath, false);
|
|
|
|
+
|
|
if (!p_set_inherited) {
|
|
if (!p_set_inherited) {
|
|
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
|
|
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
|
|
if (editor_data.get_scene_path(i) == lpath) {
|
|
if (editor_data.get_scene_path(i) == lpath) {
|
|
@@ -4063,7 +4059,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
|
|
|
|
|
|
if (!lpath.begins_with("res://")) {
|
|
if (!lpath.begins_with("res://")) {
|
|
show_accept(TTR("Error loading scene, it must be inside the project path. Use 'Import' to open the scene, then save it inside the project path."), TTR("OK"));
|
|
show_accept(TTR("Error loading scene, it must be inside the project path. Use 'Import' to open the scene, then save it inside the project path."), TTR("OK"));
|
|
- opening_prev = false;
|
|
|
|
return ERR_FILE_NOT_FOUND;
|
|
return ERR_FILE_NOT_FOUND;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -4093,8 +4088,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
|
|
for (const String &E : dependency_errors[lpath]) {
|
|
for (const String &E : dependency_errors[lpath]) {
|
|
errors.push_back(E);
|
|
errors.push_back(E);
|
|
}
|
|
}
|
|
- dependency_error->show(DependencyErrorDialog::MODE_SCENE, lpath, errors);
|
|
|
|
- opening_prev = false;
|
|
|
|
|
|
+ dependency_error->show(lpath, errors);
|
|
|
|
|
|
if (prev != -1 && prev != idx) {
|
|
if (prev != -1 && prev != idx) {
|
|
_set_current_scene(prev);
|
|
_set_current_scene(prev);
|
|
@@ -4105,7 +4099,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
|
|
|
|
|
|
if (sdata.is_null()) {
|
|
if (sdata.is_null()) {
|
|
_dialog_display_load_error(lpath, err);
|
|
_dialog_display_load_error(lpath, err);
|
|
- opening_prev = false;
|
|
|
|
|
|
|
|
if (prev != -1 && prev != idx) {
|
|
if (prev != -1 && prev != idx) {
|
|
_set_current_scene(prev);
|
|
_set_current_scene(prev);
|
|
@@ -4138,11 +4131,9 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
|
|
}
|
|
}
|
|
|
|
|
|
Node *new_scene = sdata->instantiate(p_set_inherited ? PackedScene::GEN_EDIT_STATE_MAIN_INHERITED : PackedScene::GEN_EDIT_STATE_MAIN);
|
|
Node *new_scene = sdata->instantiate(p_set_inherited ? PackedScene::GEN_EDIT_STATE_MAIN_INHERITED : PackedScene::GEN_EDIT_STATE_MAIN);
|
|
-
|
|
|
|
if (!new_scene) {
|
|
if (!new_scene) {
|
|
sdata.unref();
|
|
sdata.unref();
|
|
_dialog_display_load_error(lpath, ERR_FILE_CORRUPT);
|
|
_dialog_display_load_error(lpath, ERR_FILE_CORRUPT);
|
|
- opening_prev = false;
|
|
|
|
if (prev != -1 && prev != idx) {
|
|
if (prev != -1 && prev != idx) {
|
|
_set_current_scene(prev);
|
|
_set_current_scene(prev);
|
|
editor_data.remove_scene(idx);
|
|
editor_data.remove_scene(idx);
|
|
@@ -4176,8 +4167,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
|
|
editor_folding.save_scene_folding(new_scene, lpath);
|
|
editor_folding.save_scene_folding(new_scene, lpath);
|
|
}
|
|
}
|
|
|
|
|
|
- opening_prev = false;
|
|
|
|
-
|
|
|
|
EditorDebuggerNode::get_singleton()->update_live_edit_root();
|
|
EditorDebuggerNode::get_singleton()->update_live_edit_root();
|
|
|
|
|
|
if (restoring_scenes) {
|
|
if (restoring_scenes) {
|
|
@@ -4558,19 +4547,8 @@ void EditorNode::replace_history_reimported_nodes(Node *p_original_root_node, No
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void EditorNode::open_request(const String &p_path, bool p_set_inherited) {
|
|
|
|
- if (!opening_prev) {
|
|
|
|
- List<String>::Element *prev_scene_item = previous_scenes.find(p_path);
|
|
|
|
- if (prev_scene_item != nullptr) {
|
|
|
|
- prev_scene_item->erase();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- load_scene(p_path, false, p_set_inherited); // As it will be opened in separate tab.
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-bool EditorNode::has_previous_scenes() const {
|
|
|
|
- return !previous_scenes.is_empty();
|
|
|
|
|
|
+bool EditorNode::has_previous_closed_scenes() const {
|
|
|
|
+ return !prev_closed_scenes.is_empty();
|
|
}
|
|
}
|
|
|
|
|
|
void EditorNode::edit_foreign_resource(Ref<Resource> p_resource) {
|
|
void EditorNode::edit_foreign_resource(Ref<Resource> p_resource) {
|
|
@@ -4651,6 +4629,17 @@ void EditorNode::_show_messages() {
|
|
center_split->set_split_offset(old_split_ofs);
|
|
center_split->set_split_offset(old_split_ofs);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void EditorNode::_update_prev_closed_scenes(const String &p_scene_path, bool p_add_scene) {
|
|
|
|
+ if (!p_scene_path.is_empty()) {
|
|
|
|
+ if (p_add_scene) {
|
|
|
|
+ prev_closed_scenes.push_back(p_scene_path);
|
|
|
|
+ } else {
|
|
|
|
+ prev_closed_scenes.erase(p_scene_path);
|
|
|
|
+ }
|
|
|
|
+ file_menu->set_item_disabled(file_menu->get_item_index(FILE_OPEN_PREV), prev_closed_scenes.is_empty());
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
void EditorNode::_add_to_recent_scenes(const String &p_scene) {
|
|
void EditorNode::_add_to_recent_scenes(const String &p_scene) {
|
|
Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scenes", Array());
|
|
Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scenes", Array());
|
|
if (rc.has(p_scene)) {
|
|
if (rc.has(p_scene)) {
|
|
@@ -4697,11 +4686,7 @@ void EditorNode::_update_recent_scenes() {
|
|
}
|
|
}
|
|
|
|
|
|
void EditorNode::_quick_opened(const String &p_file_path) {
|
|
void EditorNode::_quick_opened(const String &p_file_path) {
|
|
- if (ClassDB::is_parent_class(ResourceLoader::get_resource_type(p_file_path), "PackedScene")) {
|
|
|
|
- open_request(p_file_path);
|
|
|
|
- } else {
|
|
|
|
- load_resource(p_file_path);
|
|
|
|
- }
|
|
|
|
|
|
+ load_scene_or_resource(p_file_path);
|
|
}
|
|
}
|
|
|
|
|
|
void EditorNode::_project_run_started() {
|
|
void EditorNode::_project_run_started() {
|
|
@@ -7896,7 +7881,6 @@ EditorNode::EditorNode() {
|
|
|
|
|
|
file_menu->connect(SceneStringName(id_pressed), callable_mp(this, &EditorNode::_menu_option));
|
|
file_menu->connect(SceneStringName(id_pressed), callable_mp(this, &EditorNode::_menu_option));
|
|
file_menu->connect("about_to_popup", callable_mp(this, &EditorNode::_update_file_menu_opened));
|
|
file_menu->connect("about_to_popup", callable_mp(this, &EditorNode::_update_file_menu_opened));
|
|
- file_menu->connect("popup_hide", callable_mp(this, &EditorNode::_update_file_menu_closed));
|
|
|
|
|
|
|
|
settings_menu->connect(SceneStringName(id_pressed), callable_mp(this, &EditorNode::_menu_option));
|
|
settings_menu->connect(SceneStringName(id_pressed), callable_mp(this, &EditorNode::_menu_option));
|
|
|
|
|