summaryrefslogtreecommitdiff
path: root/editor/dependency_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/dependency_editor.cpp')
-rw-r--r--editor/dependency_editor.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp
index d64b02a605..aa9125915c 100644
--- a/editor/dependency_editor.cpp
+++ b/editor/dependency_editor.cpp
@@ -495,11 +495,19 @@ void DependencyRemoveDialog::ok_pressed() {
Resource *res = ResourceCache::get(files_to_delete[i]);
res->set_path("");
}
+
+ // If the file we are deleting is the main scene, clear its definition.
+ if (files_to_delete[i] == ProjectSettings::get_singleton()->get("application/run/main_scene")) {
+ ProjectSettings::get_singleton()->set("application/run/main_scene", "");
+ }
+
String path = OS::get_singleton()->get_resource_dir() + files_to_delete[i].replace_first("res://", "/");
print_verbose("Moving to trash: " + path);
Error err = OS::get_singleton()->move_to_trash(path);
if (err != OK) {
EditorNode::get_singleton()->add_io_error(TTR("Cannot remove:") + "\n" + files_to_delete[i] + "\n");
+ } else {
+ emit_signal("file_removed", files_to_delete[i]);
}
}
@@ -515,6 +523,8 @@ void DependencyRemoveDialog::ok_pressed() {
Error err = OS::get_singleton()->move_to_trash(path);
if (err != OK) {
EditorNode::get_singleton()->add_io_error(TTR("Cannot remove:") + "\n" + dirs_to_delete[i] + "\n");
+ } else {
+ emit_signal("folder_removed", dirs_to_delete[i]);
}
}
@@ -540,6 +550,11 @@ void DependencyRemoveDialog::ok_pressed() {
}
}
+void DependencyRemoveDialog::_bind_methods() {
+ ADD_SIGNAL(MethodInfo("file_removed", PropertyInfo(Variant::STRING, "file")));
+ ADD_SIGNAL(MethodInfo("folder_removed", PropertyInfo(Variant::STRING, "folder")));
+}
+
DependencyRemoveDialog::DependencyRemoveDialog() {
VBoxContainer *vb = memnew(VBoxContainer);
@@ -557,8 +572,9 @@ DependencyRemoveDialog::DependencyRemoveDialog() {
//////////////
-void DependencyErrorDialog::show(const String &p_for_file, const Vector<String> &report) {
+void DependencyErrorDialog::show(Mode p_mode, const String &p_for_file, const Vector<String> &report) {
+ mode = p_mode;
for_file = p_for_file;
set_title(TTR("Error loading:") + " " + p_for_file.get_file());
files->clear();
@@ -584,7 +600,14 @@ void DependencyErrorDialog::show(const String &p_for_file, const Vector<String>
void DependencyErrorDialog::ok_pressed() {
- EditorNode::get_singleton()->load_scene(for_file, true);
+ switch (mode) {
+ case MODE_SCENE:
+ EditorNode::get_singleton()->load_scene(for_file, true);
+ break;
+ case MODE_RESOURCE:
+ EditorNode::get_singleton()->load_resource(for_file, true);
+ break;
+ }
}
void DependencyErrorDialog::custom_action(const String &) {
@@ -599,7 +622,7 @@ DependencyErrorDialog::DependencyErrorDialog() {
files = memnew(Tree);
files->set_hide_root(true);
- vb->add_margin_child(TTR("Scene failed to load due to missing dependencies:"), files, true);
+ vb->add_margin_child(TTR("Load failed due to missing dependencies:"), files, true);
files->set_v_size_flags(SIZE_EXPAND_FILL);
files->set_custom_minimum_size(Size2(1, 200));
get_ok()->set_text(TTR("Open Anyway"));