Changed saved window layouts to be accessable from any project. added apply and delete buttons as well.

This commit is contained in:
Chandler Cox
2022-12-08 20:40:21 -06:00
parent 5a50656249
commit 2e055d1909
2 changed files with 11 additions and 5 deletions

View File

@@ -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;
}

View File

@@ -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);
}
}