From d32bc6c475e72cb57dad4193845380f6f909e05d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20L=C3=BCbe=C3=9F?= Date: Fri, 29 Sep 2023 18:51:21 +0200 Subject: [PATCH] Properties Window: Combined "Save"- and "Apply"-Buttons into one "Save"-Button --- .../src/EditWindows/PropertiesWindow.bf | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/GlitchyEditor/src/EditWindows/PropertiesWindow.bf b/GlitchyEditor/src/EditWindows/PropertiesWindow.bf index a4195f8..8ceb635 100644 --- a/GlitchyEditor/src/EditWindows/PropertiesWindow.bf +++ b/GlitchyEditor/src/EditWindows/PropertiesWindow.bf @@ -106,22 +106,32 @@ class PropertiesWindow : EditorWindow return; _currentPropertiesEditor.ShowEditor(); - - if (ImGui.Button("Save Asset")) - { - Asset asset = _editor.ContentManager.GetAsset(null, _currentAssetHandle); - _editor.ContentManager.SaveAsset(asset); - } - if (!assetFile.AssetConfig.Config.Changed) + bool assetConfigChanged = assetFile.AssetConfig.Config.Changed; + bool hasAssetSaver = (_editor.ContentManager.[Friend]GetAssetLoader(assetFile) is IAssetSaver); + + // If the asset can't be saved and it's config didn't change disable save button + if (!hasAssetSaver && !assetConfigChanged) { ImGui.BeginDisabled(); defer:: { ImGui.EndDisabled(); } } - - ImGui.Separator(); - if (ImGui.Button("Apply")) - assetFile.SaveAssetConfig(); + if (ImGui.Button("Save")) + { + // Only save config if it changed + if (assetConfigChanged) + { + assetFile.SaveAssetConfig(); + } + + // If the asset type has an asset saver, also save the asset + // TODO: Check whether or not the asset was changed? + if (hasAssetSaver) + { + Asset asset = _editor.ContentManager.GetAsset(null, _currentAssetHandle); + _editor.ContentManager.SaveAsset(asset); + } + } } }