MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / ok_pressed

Method ok_pressed

editor/file_system/dependency_editor.cpp:585–665  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

583}
584
585void DependencyRemoveDialog::ok_pressed() {
586 HashMap<String, StringName> setting_path_map;
587 for (const StringName &setting : path_project_settings) {
588 const String path = ResourceUID::ensure_path(GLOBAL_GET(setting));
589 setting_path_map[path] = setting;
590 }
591
592 bool project_settings_modified = false;
593
594 for (const KeyValue<String, String> &E : all_remove_files) {
595 String file = E.key;
596
597 if (ResourceCache::has(file)) {
598 Ref<Resource> res = ResourceCache::get_ref(file);
599 emit_signal(SNAME("resource_removed"), res);
600 res->set_path("");
601 }
602
603 // If the file we are deleting for e.g. the main scene, default environment,
604 // or audio bus layout, we must clear its definition in Project Settings.
605 const StringName *setting_name = setting_path_map.getptr(file);
606 if (setting_name) {
607 ProjectSettings::get_singleton()->set(*setting_name, "");
608 project_settings_modified = true;
609 }
610 }
611
612 for (const String &file : files_to_delete) {
613 const String path = OS::get_singleton()->get_resource_dir() + file.replace_first("res://", "/");
614 print_verbose("Moving to trash: " + path);
615 Error err = OS::get_singleton()->move_to_trash(path);
616 if (err != OK) {
617 EditorNode::get_singleton()->add_io_error(TTR("Cannot remove:") + "\n" + file + "\n");
618 } else {
619 emit_signal(SNAME("file_removed"), file);
620 }
621 }
622 if (project_settings_modified) {
623 ProjectSettings::get_singleton()->save();
624 }
625
626 if (dirs_to_delete.is_empty()) {
627 // If we only deleted files we should only need to tell the file system about the files we touched.
628 for (int i = 0; i < files_to_delete.size(); ++i) {
629 EditorFileSystem::get_singleton()->update_file(files_to_delete[i]);
630 }
631 } else {
632 for (int i = 0; i < dirs_to_delete.size(); ++i) {
633 String path = OS::get_singleton()->get_resource_dir() + dirs_to_delete[i].replace_first("res://", "/");
634 print_verbose("Moving to trash: " + path);
635 Error err = OS::get_singleton()->move_to_trash(path);
636 if (err != OK) {
637 EditorNode::get_singleton()->add_io_error(TTR("Cannot remove:") + "\n" + dirs_to_delete[i] + "\n");
638 } else {
639 emit_signal(SNAME("folder_removed"), dirs_to_delete[i]);
640 }
641 }
642

Callers

nothing calls this directly

Calls 15

hasFunction · 0.85
TTRFunction · 0.85
vformatFunction · 0.85
replace_firstMethod · 0.80
add_io_errorMethod · 0.80
update_fileMethod · 0.80
scan_changesMethod · 0.80
get_favoritesMethod · 0.80
ends_withMethod · 0.80
set_favoritesMethod · 0.80
popup_centeredMethod · 0.80

Tested by

no test coverage detected