From 2e055d190918e8312e95595d706b8656d0887500 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 8 Dec 2022 20:40:21 -0600 Subject: [PATCH] Changed saved window layouts to be accessable from any project. added apply and delete buttons as well. --- Source/Editor/Modules/UIModule.cs | 12 +++++++++--- Source/Editor/Modules/WindowsModule.cs | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Source/Editor/Modules/UIModule.cs b/Source/Editor/Modules/UIModule.cs index 7c71c5628..5d0b6ff09 100644 --- a/Source/Editor/Modules/UIModule.cs +++ b/Source/Editor/Modules/UIModule.cs @@ -738,7 +738,11 @@ namespace FlaxEditor.Modules return; // Find layout to use - var searchFolder = Globals.ProjectCacheFolder; + var searchFolder = StringUtils.CombinePaths(Editor.LocalCachePath, "LayoutsCache") ; + if (!Directory.Exists(searchFolder)) + { + Directory.CreateDirectory(searchFolder); + } var files = Directory.GetFiles(searchFolder, "Layout_*.xml", SearchOption.TopDirectoryOnly); var layouts = _menuWindowApplyWindowLayout.ContextMenu; layouts.DisposeAllItems(); @@ -746,8 +750,10 @@ namespace FlaxEditor.Modules { var file = files[i]; var name = file.Substring(searchFolder.Length + 8, file.Length - searchFolder.Length - 12); - var button = layouts.AddButton(name, OnApplyLayoutButtonClicked); - button.Tag = file; + var nameCM = layouts.AddChildMenu(name); + var applyButton = nameCM.ContextMenu.AddButton("Apply", OnApplyLayoutButtonClicked); + nameCM.ContextMenu.AddButton("Delete", () => File.Delete(file)); + applyButton.Tag = file; } _menuWindowApplyWindowLayout.Enabled = files.Length > 0; } diff --git a/Source/Editor/Modules/WindowsModule.cs b/Source/Editor/Modules/WindowsModule.cs index 0e341581f..04182f81d 100644 --- a/Source/Editor/Modules/WindowsModule.cs +++ b/Source/Editor/Modules/WindowsModule.cs @@ -555,8 +555,8 @@ namespace FlaxEditor.Modules } base.OnSubmit(); - - var path = StringUtils.CombinePaths(Globals.ProjectCacheFolder, "Layout_" + name + ".xml"); + + var path = StringUtils.CombinePaths(Editor.LocalCachePath, "LayoutsCache", "Layout_" + name + ".xml"); Editor.Instance.Windows.SaveLayout(path); } }