Changed saved window layouts to be accessable from any project. added apply and delete buttons as well.
This commit is contained in:
@@ -738,7 +738,11 @@ namespace FlaxEditor.Modules
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Find layout to use
|
// 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 files = Directory.GetFiles(searchFolder, "Layout_*.xml", SearchOption.TopDirectoryOnly);
|
||||||
var layouts = _menuWindowApplyWindowLayout.ContextMenu;
|
var layouts = _menuWindowApplyWindowLayout.ContextMenu;
|
||||||
layouts.DisposeAllItems();
|
layouts.DisposeAllItems();
|
||||||
@@ -746,8 +750,10 @@ namespace FlaxEditor.Modules
|
|||||||
{
|
{
|
||||||
var file = files[i];
|
var file = files[i];
|
||||||
var name = file.Substring(searchFolder.Length + 8, file.Length - searchFolder.Length - 12);
|
var name = file.Substring(searchFolder.Length + 8, file.Length - searchFolder.Length - 12);
|
||||||
var button = layouts.AddButton(name, OnApplyLayoutButtonClicked);
|
var nameCM = layouts.AddChildMenu(name);
|
||||||
button.Tag = file;
|
var applyButton = nameCM.ContextMenu.AddButton("Apply", OnApplyLayoutButtonClicked);
|
||||||
|
nameCM.ContextMenu.AddButton("Delete", () => File.Delete(file));
|
||||||
|
applyButton.Tag = file;
|
||||||
}
|
}
|
||||||
_menuWindowApplyWindowLayout.Enabled = files.Length > 0;
|
_menuWindowApplyWindowLayout.Enabled = files.Length > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -555,8 +555,8 @@ namespace FlaxEditor.Modules
|
|||||||
}
|
}
|
||||||
|
|
||||||
base.OnSubmit();
|
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);
|
Editor.Instance.Windows.SaveLayout(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user