1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Check for unsaved changes when closing a scene

This commit is contained in:
kobewi
2023-04-05 15:45:41 +02:00
parent 000471ee56
commit b883f32188
8 changed files with 98 additions and 30 deletions

View File

@@ -287,14 +287,19 @@ void ShaderEditorPlugin::get_window_layout(Ref<ConfigFile> p_layout) {
p_layout->set_value("ShaderEditor", "selected_shader", selected_shader);
}
String ShaderEditorPlugin::get_unsaved_status() const {
String ShaderEditorPlugin::get_unsaved_status(const String &p_for_scene) const {
if (!p_for_scene.is_empty()) {
// TODO: handle built-in shaders.
return String();
}
// TODO: This should also include visual shaders and shader includes, but save_external_data() doesn't seem to save them...
PackedStringArray unsaved_shaders;
for (uint32_t i = 0; i < edited_shaders.size(); i++) {
if (edited_shaders[i].shader_editor) {
if (edited_shaders[i].shader_editor->is_unsaved()) {
if (unsaved_shaders.is_empty()) {
unsaved_shaders.append("Save changes to the following shaders(s) before quitting?");
unsaved_shaders.append(TTR("Save changes to the following shaders(s) before quitting?"));
}
unsaved_shaders.append(edited_shaders[i].shader_editor->get_name());
}