1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Add unsaved status for script and shader editors

This commit is contained in:
kobewi
2022-10-16 19:30:38 +02:00
parent 6dc5dc3479
commit 000471ee56
4 changed files with 49 additions and 0 deletions

View File

@@ -287,6 +287,22 @@ void ShaderEditorPlugin::get_window_layout(Ref<ConfigFile> p_layout) {
p_layout->set_value("ShaderEditor", "selected_shader", selected_shader);
}
String ShaderEditorPlugin::get_unsaved_status() const {
// 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(edited_shaders[i].shader_editor->get_name());
}
}
}
return String("\n").join(unsaved_shaders);
}
void ShaderEditorPlugin::save_external_data() {
for (EditedShader &edited_shader : edited_shaders) {
if (edited_shader.shader_editor) {