From 2e055d190918e8312e95595d706b8656d0887500 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 8 Dec 2022 20:40:21 -0600 Subject: [PATCH 1/5] 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); } } From ffc5a4d24fc660dd38d42631e89676ba0e47698b Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 8 Dec 2022 20:42:39 -0600 Subject: [PATCH 2/5] Style fix --- Source/Editor/Modules/UIModule.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/Editor/Modules/UIModule.cs b/Source/Editor/Modules/UIModule.cs index 5d0b6ff09..83ff4a74b 100644 --- a/Source/Editor/Modules/UIModule.cs +++ b/Source/Editor/Modules/UIModule.cs @@ -740,9 +740,7 @@ namespace FlaxEditor.Modules // Find layout to use 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(); From a45f7a86f23ee74351d919620ae9eecae617ff09 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 8 Dec 2022 21:21:03 -0600 Subject: [PATCH 3/5] Added Tooltips --- Source/Editor/Modules/UIModule.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Modules/UIModule.cs b/Source/Editor/Modules/UIModule.cs index 83ff4a74b..80f0bb97c 100644 --- a/Source/Editor/Modules/UIModule.cs +++ b/Source/Editor/Modules/UIModule.cs @@ -750,7 +750,8 @@ namespace FlaxEditor.Modules var name = file.Substring(searchFolder.Length + 8, file.Length - searchFolder.Length - 12); var nameCM = layouts.AddChildMenu(name); var applyButton = nameCM.ContextMenu.AddButton("Apply", OnApplyLayoutButtonClicked); - nameCM.ContextMenu.AddButton("Delete", () => File.Delete(file)); + applyButton.TooltipText = "Applies the selected layout."; + nameCM.ContextMenu.AddButton("Delete", () => File.Delete(file)).TooltipText = "Permanently deletes the selected layout."; applyButton.Tag = file; } _menuWindowApplyWindowLayout.Enabled = files.Length > 0; From de79e43fb19925da9fda8837674602beb97ea197 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 14 Dec 2022 08:30:44 -0600 Subject: [PATCH 4/5] Code Style Fix --- Source/Editor/Modules/WindowsModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/Modules/WindowsModule.cs b/Source/Editor/Modules/WindowsModule.cs index 04182f81d..993d51778 100644 --- a/Source/Editor/Modules/WindowsModule.cs +++ b/Source/Editor/Modules/WindowsModule.cs @@ -555,7 +555,7 @@ namespace FlaxEditor.Modules } base.OnSubmit(); - + var path = StringUtils.CombinePaths(Editor.LocalCachePath, "LayoutsCache", "Layout_" + name + ".xml"); Editor.Instance.Windows.SaveLayout(path); } From 5bccd010cb8f3958307cdf45cf85eda8fa2e0b08 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 27 Dec 2022 19:22:17 +0100 Subject: [PATCH 5/5] Code style fix --- Source/Editor/Modules/UIModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/Modules/UIModule.cs b/Source/Editor/Modules/UIModule.cs index 80f0bb97c..a0b9ca19b 100644 --- a/Source/Editor/Modules/UIModule.cs +++ b/Source/Editor/Modules/UIModule.cs @@ -738,7 +738,7 @@ namespace FlaxEditor.Modules return; // Find layout to use - var searchFolder = StringUtils.CombinePaths(Editor.LocalCachePath, "LayoutsCache") ; + var searchFolder = StringUtils.CombinePaths(Editor.LocalCachePath, "LayoutsCache"); if (!Directory.Exists(searchFolder)) Directory.CreateDirectory(searchFolder); var files = Directory.GetFiles(searchFolder, "Layout_*.xml", SearchOption.TopDirectoryOnly);