Merge branch 'Tryibion-editor-layout-cache'

This commit is contained in:
Wojtek Figat
2022-12-27 19:22:33 +01:00
2 changed files with 9 additions and 4 deletions

View File

@@ -738,7 +738,9 @@ 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 +748,11 @@ 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);
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;
}

View File

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