Various improvements for Editor
This commit is contained in:
@@ -271,18 +271,7 @@ namespace FlaxEditor.Content
|
||||
/// <summary>
|
||||
/// Gets the asset name relative to the project root folder (without asset file extension)
|
||||
/// </summary>
|
||||
public string NamePath
|
||||
{
|
||||
get
|
||||
{
|
||||
string result = Path;
|
||||
if (result.StartsWith(Globals.ProjectFolder))
|
||||
{
|
||||
result = result.Substring(Globals.ProjectFolder.Length + 1);
|
||||
}
|
||||
return StringUtils.GetPathWithoutExtension(result);
|
||||
}
|
||||
}
|
||||
public string NamePath => FlaxEditor.Utilities.Utils.GetAssetNamePath(Path);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default name of the content item thumbnail. Returns null if not used.
|
||||
|
||||
@@ -56,6 +56,11 @@ namespace FlaxEditor.GUI.Docking
|
||||
/// </summary>
|
||||
public bool IsSelected => _dockedTo?.SelectedTab == this;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this window is hidden from the user (eg. not shown or hidden on closed).
|
||||
/// </summary>
|
||||
public bool IsHidden => !Visible || _dockedTo == null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default window size.
|
||||
/// </summary>
|
||||
|
||||
@@ -48,11 +48,6 @@ namespace FlaxEditor.Modules
|
||||
private List<QuickAction> _quickActions;
|
||||
private ContentFinder _finder;
|
||||
|
||||
/// <summary>
|
||||
/// The content finding context menu.
|
||||
/// </summary>
|
||||
internal ContentFinder Finder => _finder ?? (_finder = new ContentFinder());
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ContentFindingModule"/> class.
|
||||
/// </summary>
|
||||
@@ -81,12 +76,12 @@ namespace FlaxEditor.Modules
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the finder.
|
||||
/// Shows the content finder popup.
|
||||
/// </summary>
|
||||
/// <param name="control">The target control to show finder over it.</param>
|
||||
public void ShowFinder(Control control)
|
||||
{
|
||||
var finder = Finder;
|
||||
var finder = _finder ?? (_finder = new ContentFinder());
|
||||
var position = (control.Size - new Vector2(finder.Width, 300.0f)) * 0.5f;
|
||||
finder.Show(control, position);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,11 @@ namespace FlaxEditor.Surface
|
||||
/// </summary>
|
||||
IEnumerable<ScriptType> NewParameterTypes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Event called when surface gets loaded (eg. after opening the window).
|
||||
/// </summary>
|
||||
event Action SurfaceLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// Called when parameter rename undo action is performed.
|
||||
/// </summary>
|
||||
@@ -974,6 +979,7 @@ namespace FlaxEditor.Surface
|
||||
_showWholeGraphOnLoad = false;
|
||||
_surface.ShowWholeGraph();
|
||||
}
|
||||
SurfaceLoaded?.Invoke();
|
||||
}
|
||||
else if (_refreshPropertiesOnLoad && _asset.IsLoaded)
|
||||
{
|
||||
@@ -1023,6 +1029,9 @@ namespace FlaxEditor.Surface
|
||||
/// <inheritdoc />
|
||||
public abstract IEnumerable<ScriptType> NewParameterTypes { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public event Action SurfaceLoaded;
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual void OnParamRenameUndo()
|
||||
{
|
||||
|
||||
@@ -897,5 +897,19 @@ namespace FlaxEditor.Utilities
|
||||
};
|
||||
return menu;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the asset name relative to the project root folder (without asset file extension)
|
||||
/// </summary>
|
||||
/// <param name="path">The asset path.</param>
|
||||
/// <returns>The processed name path.</returns>
|
||||
public static string GetAssetNamePath(string path)
|
||||
{
|
||||
if (path.StartsWith(Globals.ProjectFolder))
|
||||
{
|
||||
path = path.Substring(Globals.ProjectFolder.Length + 1);
|
||||
}
|
||||
return StringUtils.GetPathWithoutExtension(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1322,6 +1322,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
_surface.ShowWholeGraph();
|
||||
}
|
||||
LoadBreakpoints();
|
||||
SurfaceLoaded?.Invoke();
|
||||
Editor.VisualScriptingDebugFlow += OnDebugFlow;
|
||||
}
|
||||
else if (_refreshPropertiesOnLoad && _asset.IsLoaded)
|
||||
@@ -1381,6 +1382,9 @@ namespace FlaxEditor.Windows.Assets
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ScriptType> NewParameterTypes => Editor.CodeEditing.VisualScriptPropertyTypes.Get();
|
||||
|
||||
/// <inheritdoc />
|
||||
public event Action SurfaceLoaded;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnParamRenameUndo()
|
||||
{
|
||||
|
||||
@@ -220,7 +220,7 @@ namespace FlaxEditor.Windows
|
||||
filterButton.Checked = _viewDropdown.IsSelected(filterButton.Text);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var sortBy = menu.AddChildMenu("Sort by");
|
||||
sortBy.ContextMenu.AddButton("Alphabetic Order", OnSortByButtonClicked).Tag = SortType.AlphabeticOrder;
|
||||
sortBy.ContextMenu.AddButton("Alphabetic Reverse", OnSortByButtonClicked).Tag = SortType.AlphabeticReverse;
|
||||
@@ -260,10 +260,12 @@ namespace FlaxEditor.Windows
|
||||
{
|
||||
switch ((SortType)button.Tag)
|
||||
{
|
||||
case SortType.AlphabeticOrder: _sortType = SortType.AlphabeticOrder;
|
||||
break;
|
||||
case SortType.AlphabeticReverse: _sortType = SortType.AlphabeticReverse;
|
||||
break;
|
||||
case SortType.AlphabeticOrder:
|
||||
_sortType = SortType.AlphabeticOrder;
|
||||
break;
|
||||
case SortType.AlphabeticReverse:
|
||||
_sortType = SortType.AlphabeticReverse;
|
||||
break;
|
||||
}
|
||||
RefreshView(SelectedNode);
|
||||
}
|
||||
@@ -446,14 +448,15 @@ namespace FlaxEditor.Windows
|
||||
/// <param name="items">The items to delete.</param>
|
||||
public void Delete(List<ContentItem> items)
|
||||
{
|
||||
if (items.Count == 0) return;
|
||||
if (items.Count == 0)
|
||||
return;
|
||||
|
||||
// TODO: remove items that depend on different items in the list: use wants to remove `folderA` and `folderA/asset.x`, we should just remove `folderA`
|
||||
var toDelete = new List<ContentItem>(items);
|
||||
|
||||
string msg = toDelete.Count == 1 ?
|
||||
string.Format("Are you sure to delete \'{0}\'?\nThis action cannot be undone. Files will be deleted permanently.", items[0].Path)
|
||||
: string.Format("Are you sure to delete {0} selected items?\nThis action cannot be undone. Files will be deleted permanently.", items.Count);
|
||||
string msg = toDelete.Count == 1
|
||||
? string.Format("Are you sure to delete \'{0}\'?\nThis action cannot be undone. Files will be deleted permanently.", items[0].Path)
|
||||
: string.Format("Are you sure to delete {0} selected items?\nThis action cannot be undone. Files will be deleted permanently.", items.Count);
|
||||
|
||||
// Ask user
|
||||
if (MessageBox.Show(msg, "Delete asset(s)", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
||||
@@ -767,12 +770,6 @@ namespace FlaxEditor.Windows
|
||||
_navigateUpButton.Enabled = folder != null && _tree.SelectedNode != _root;
|
||||
}
|
||||
|
||||
private void AddFolder2Root(ContentTreeNode node)
|
||||
{
|
||||
// Add to the root
|
||||
_root.AddChild(node);
|
||||
}
|
||||
|
||||
private void RemoveFolder2Root(ContentTreeNode node)
|
||||
{
|
||||
// Remove from the root
|
||||
@@ -790,7 +787,7 @@ namespace FlaxEditor.Windows
|
||||
_root.Expand(true);
|
||||
|
||||
foreach (var project in Editor.ContentDatabase.Projects)
|
||||
AddFolder2Root(project);
|
||||
_root.AddChild(project);
|
||||
|
||||
Editor.ContentDatabase.Game?.Expand(true);
|
||||
_tree.Margin = new Margin(0.0f, 0.0f, -16.0f, 2.0f); // Hide root node
|
||||
@@ -842,7 +839,7 @@ namespace FlaxEditor.Windows
|
||||
{
|
||||
while (_root.HasChildren)
|
||||
{
|
||||
RemoveFolder2Root((ContentTreeNode)_root.GetChild(0));
|
||||
_root.RemoveChild((ContentTreeNode)_root.GetChild(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user