Fix no unsaved indicator Save As resource

This commit is contained in:
Hilderin 2024-08-30 22:38:42 -04:00
parent 61598c5c88
commit b97c128b34
2 changed files with 20 additions and 0 deletions

View File

@ -175,6 +175,13 @@ void EditorResourcePicker::_file_quick_selected() {
_file_selected(quick_open->get_selected()); _file_selected(quick_open->get_selected());
} }
void EditorResourcePicker::_resource_saved(Object *p_resource) {
if (edited_resource.is_valid() && p_resource == edited_resource.ptr()) {
emit_signal(SNAME("resource_changed"), edited_resource);
_update_resource();
}
}
void EditorResourcePicker::_update_menu() { void EditorResourcePicker::_update_menu() {
_update_menu_items(); _update_menu_items();
@ -408,6 +415,10 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) {
if (edited_resource.is_null()) { if (edited_resource.is_null()) {
return; return;
} }
Callable resource_saved = callable_mp(this, &EditorResourcePicker::_resource_saved);
if (!EditorNode::get_singleton()->is_connected("resource_saved", resource_saved)) {
EditorNode::get_singleton()->connect("resource_saved", resource_saved);
}
EditorNode::get_singleton()->save_resource_as(edited_resource); EditorNode::get_singleton()->save_resource_as(edited_resource);
} break; } break;
@ -833,6 +844,13 @@ void EditorResourcePicker::_notification(int p_what) {
assign_button->queue_redraw(); assign_button->queue_redraw();
} }
} break; } break;
case NOTIFICATION_EXIT_TREE: {
Callable resource_saved = callable_mp(this, &EditorResourcePicker::_resource_saved);
if (EditorNode::get_singleton()->is_connected("resource_saved", resource_saved)) {
EditorNode::get_singleton()->disconnect("resource_saved", resource_saved);
}
} break;
} }
} }

View File

@ -91,6 +91,8 @@ class EditorResourcePicker : public HBoxContainer {
void _file_quick_selected(); void _file_quick_selected();
void _file_selected(const String &p_path); void _file_selected(const String &p_path);
void _resource_saved(Object *p_resource);
void _update_menu(); void _update_menu();
void _update_menu_items(); void _update_menu_items();
void _edit_menu_cbk(int p_which); void _edit_menu_cbk(int p_which);