mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Properties Window: Combined "Save"- and "Apply"-Buttons into one "Save"-Button
This commit is contained in:
@@ -107,21 +107,31 @@ class PropertiesWindow : EditorWindow
|
||||
|
||||
_currentPropertiesEditor.ShowEditor();
|
||||
|
||||
if (ImGui.Button("Save Asset"))
|
||||
{
|
||||
Asset asset = _editor.ContentManager.GetAsset(null, _currentAssetHandle);
|
||||
_editor.ContentManager.SaveAsset(asset);
|
||||
}
|
||||
bool assetConfigChanged = assetFile.AssetConfig.Config.Changed;
|
||||
bool hasAssetSaver = (_editor.ContentManager.[Friend]GetAssetLoader(assetFile) is IAssetSaver);
|
||||
|
||||
if (!assetFile.AssetConfig.Config.Changed)
|
||||
// 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("Save"))
|
||||
{
|
||||
// Only save config if it changed
|
||||
if (assetConfigChanged)
|
||||
{
|
||||
assetFile.SaveAssetConfig();
|
||||
}
|
||||
|
||||
if (ImGui.Button("Apply"))
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user