You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 12:50:35 +00:00
Better warnings when resources can't be saved. Fixes #26531
This commit is contained in:
@@ -619,7 +619,11 @@ void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const St
|
||||
Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
|
||||
|
||||
if (err != OK) {
|
||||
show_accept(TTR("Error saving resource!"), TTR("OK"));
|
||||
if (ResourceLoader::is_imported(p_resource->get_path())) {
|
||||
show_accept(TTR("Imported resources can't be saved."), TTR("OK"));
|
||||
} else {
|
||||
show_accept(TTR("Error saving resource!"), TTR("OK"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -639,6 +643,18 @@ void EditorNode::save_resource(const Ref<Resource> &p_resource) {
|
||||
|
||||
void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String &p_at_path) {
|
||||
|
||||
{
|
||||
String path = p_resource->get_path();
|
||||
int srpos = path.find("::");
|
||||
if (srpos != -1) {
|
||||
String base = path.substr(0, srpos);
|
||||
if (!get_edited_scene() || get_edited_scene()->get_filename() != base) {
|
||||
show_warning(TTR("This resource can't be saved because it does not belong to the edited scene. Make it unique first."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
|
||||
saving_resource = p_resource;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user