Marge Visual Script groups for structures (eg. double ActionConfig group)
This commit is contained in:
@@ -113,6 +113,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The data for add property track buttons tag.
|
/// The data for add property track buttons tag.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[HideInEditor]
|
||||||
public struct AddMemberTag
|
public struct AddMemberTag
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -113,9 +113,9 @@ namespace FlaxEditor.Surface
|
|||||||
if (_cache.Count != 0)
|
if (_cache.Count != 0)
|
||||||
{
|
{
|
||||||
// Check if context menu doesn't have the recent cached groups
|
// Check if context menu doesn't have the recent cached groups
|
||||||
if (!contextMenu.Groups.Any(g => g.Archetype.Tag is int asInt && asInt == _version))
|
if (!contextMenu.Groups.Any(g => g.Archetypes[0].Tag is int asInt && asInt == _version))
|
||||||
{
|
{
|
||||||
var groups = contextMenu.Groups.Where(g => g.Archetype.Tag is int).ToArray();
|
var groups = contextMenu.Groups.Where(g => g.Archetypes[0].Tag is int).ToArray();
|
||||||
foreach (var g in groups)
|
foreach (var g in groups)
|
||||||
contextMenu.RemoveGroup(g);
|
contextMenu.RemoveGroup(g);
|
||||||
foreach (var g in _cache.Values)
|
foreach (var g in _cache.Values)
|
||||||
@@ -125,7 +125,7 @@ namespace FlaxEditor.Surface
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Remove any old groups from context menu
|
// Remove any old groups from context menu
|
||||||
var groups = contextMenu.Groups.Where(g => g.Archetype.Tag is int).ToArray();
|
var groups = contextMenu.Groups.Where(g => g.Archetypes[0].Tag is int).ToArray();
|
||||||
foreach (var g in groups)
|
foreach (var g in groups)
|
||||||
contextMenu.RemoveGroup(g);
|
contextMenu.RemoveGroup(g);
|
||||||
|
|
||||||
@@ -340,7 +340,7 @@ namespace FlaxEditor.Surface
|
|||||||
ParametersGetter = null,
|
ParametersGetter = null,
|
||||||
CustomNodesGroup = GetCustomNodes(),
|
CustomNodesGroup = GetCustomNodes(),
|
||||||
});
|
});
|
||||||
_cmStateMachineTransitionMenu.AddGroup(StateMachineTransitionGroupArchetype);
|
_cmStateMachineTransitionMenu.AddGroup(StateMachineTransitionGroupArchetype, false);
|
||||||
}
|
}
|
||||||
menu = _cmStateMachineTransitionMenu;
|
menu = _cmStateMachineTransitionMenu;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,11 +171,7 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
// Check if can create group for them
|
// Check if can create group for them
|
||||||
if (nodes.Count > 0)
|
if (nodes.Count > 0)
|
||||||
{
|
{
|
||||||
var group = new VisjectCMGroup(this, groupArchetype)
|
var group = CreateGroup(groupArchetype);
|
||||||
{
|
|
||||||
HeaderText = groupArchetype.Name
|
|
||||||
};
|
|
||||||
|
|
||||||
group.Close(false);
|
group.Close(false);
|
||||||
for (int i = 0; i < nodes.Count; i++)
|
for (int i = 0; i < nodes.Count; i++)
|
||||||
{
|
{
|
||||||
@@ -205,7 +201,7 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
VisjectCMGroup group = null;
|
VisjectCMGroup group = null;
|
||||||
for (int j = 0; j < _groups.Count; j++)
|
for (int j = 0; j < _groups.Count; j++)
|
||||||
{
|
{
|
||||||
if (string.Equals(_groups[j].Archetype.Name, groupName, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(_groups[j].Name, groupName, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
group = _groups[j];
|
group = _groups[j];
|
||||||
break;
|
break;
|
||||||
@@ -215,11 +211,7 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
// Create new group if name is unique
|
// Create new group if name is unique
|
||||||
if (group == null)
|
if (group == null)
|
||||||
{
|
{
|
||||||
group = new VisjectCMGroup(this, info.CustomNodesGroup)
|
group = CreateGroup(info.CustomNodesGroup, true, groupName);
|
||||||
{
|
|
||||||
HeaderText = groupName
|
|
||||||
};
|
|
||||||
|
|
||||||
group.Close(false);
|
group.Close(false);
|
||||||
group.Parent = _groupsPanel;
|
group.Parent = _groupsPanel;
|
||||||
_groups.Add(group);
|
_groups.Add(group);
|
||||||
@@ -241,18 +233,15 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
/// Adds the group archetype to add to the menu.
|
/// Adds the group archetype to add to the menu.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="groupArchetype">The group.</param>
|
/// <param name="groupArchetype">The group.</param>
|
||||||
public void AddGroup(GroupArchetype groupArchetype)
|
/// <param name="withGroupMerge">True if merge group items into any existing group of the same name.</param>
|
||||||
|
public void AddGroup(GroupArchetype groupArchetype, bool withGroupMerge = true)
|
||||||
{
|
{
|
||||||
// Check if can create group for them to be spawned via GUI
|
// Check if can create group for them to be spawned via GUI
|
||||||
if (groupArchetype.Archetypes.Any(x => (x.Flags & NodeFlags.NoSpawnViaGUI) == 0))
|
if (groupArchetype.Archetypes.Any(x => (x.Flags & NodeFlags.NoSpawnViaGUI) == 0))
|
||||||
{
|
{
|
||||||
Profiler.BeginEvent("VisjectCM.AddGroup");
|
Profiler.BeginEvent("VisjectCM.AddGroup");
|
||||||
|
|
||||||
var group = new VisjectCMGroup(this, groupArchetype)
|
var group = CreateGroup(groupArchetype, withGroupMerge);
|
||||||
{
|
|
||||||
HeaderText = groupArchetype.Name
|
|
||||||
};
|
|
||||||
|
|
||||||
group.Close(false);
|
group.Close(false);
|
||||||
|
|
||||||
foreach (var nodeArchetype in groupArchetype.Archetypes)
|
foreach (var nodeArchetype in groupArchetype.Archetypes)
|
||||||
@@ -286,7 +275,8 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
/// Adds the group archetypes to add to the menu.
|
/// Adds the group archetypes to add to the menu.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="groupArchetypes">The groups.</param>
|
/// <param name="groupArchetypes">The groups.</param>
|
||||||
public void AddGroups(IEnumerable<GroupArchetype> groupArchetypes)
|
/// <param name="withGroupMerge">True if merge group items into any existing group of the same name.</param>
|
||||||
|
public void AddGroups(IEnumerable<GroupArchetype> groupArchetypes, bool withGroupMerge = true)
|
||||||
{
|
{
|
||||||
// Check if can create group for them to be spawned via GUI
|
// Check if can create group for them to be spawned via GUI
|
||||||
if (groupArchetypes.Any(g => g.Archetypes.Any(x => (x.Flags & NodeFlags.NoSpawnViaGUI) == 0)))
|
if (groupArchetypes.Any(g => g.Archetypes.Any(x => (x.Flags & NodeFlags.NoSpawnViaGUI) == 0)))
|
||||||
@@ -299,11 +289,7 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
var groups = new List<VisjectCMGroup>();
|
var groups = new List<VisjectCMGroup>();
|
||||||
foreach (var groupArchetype in groupArchetypes)
|
foreach (var groupArchetype in groupArchetypes)
|
||||||
{
|
{
|
||||||
var group = new VisjectCMGroup(this, groupArchetype)
|
var group = CreateGroup(groupArchetype, withGroupMerge);
|
||||||
{
|
|
||||||
HeaderText = groupArchetype.Name
|
|
||||||
};
|
|
||||||
|
|
||||||
group.Close(false);
|
group.Close(false);
|
||||||
|
|
||||||
foreach (var nodeArchetype in groupArchetype.Archetypes)
|
foreach (var nodeArchetype in groupArchetype.Archetypes)
|
||||||
@@ -349,11 +335,25 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < _groups.Count; i++)
|
for (int i = 0; i < _groups.Count; i++)
|
||||||
{
|
{
|
||||||
if (_groups[i].Archetype == groupArchetype)
|
var group = _groups[i];
|
||||||
|
if (group.Archetypes.Remove(groupArchetype))
|
||||||
{
|
{
|
||||||
Profiler.BeginEvent("VisjectCM.RemoveGroup");
|
Profiler.BeginEvent("VisjectCM.RemoveGroup");
|
||||||
_groups[i].Dispose();
|
if (group.Archetypes.Count == 0)
|
||||||
_groups.RemoveAt(i);
|
{
|
||||||
|
Debug.Log("Remove");
|
||||||
|
_groups.RemoveAt(i);
|
||||||
|
group.Dispose();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var children = group.Children.ToArray();
|
||||||
|
foreach (var child in children)
|
||||||
|
{
|
||||||
|
if (child is VisjectCMItem item && item.GroupArchetype == groupArchetype)
|
||||||
|
item.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
Profiler.EndEvent();
|
Profiler.EndEvent();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -372,6 +372,24 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
Profiler.EndEvent();
|
Profiler.EndEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private VisjectCMGroup CreateGroup(GroupArchetype groupArchetype, bool withGroupMerge = true, string name = null)
|
||||||
|
{
|
||||||
|
if (name == null)
|
||||||
|
name = groupArchetype.Name;
|
||||||
|
if (withGroupMerge)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _groups.Count; i++)
|
||||||
|
{
|
||||||
|
if (string.Equals(_groups[i].HeaderText, name, StringComparison.Ordinal))
|
||||||
|
return _groups[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new VisjectCMGroup(this, groupArchetype)
|
||||||
|
{
|
||||||
|
HeaderText = name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private void OnSearchFilterChanged()
|
private void OnSearchFilterChanged()
|
||||||
{
|
{
|
||||||
// Skip events during setup or init stuff
|
// Skip events during setup or init stuff
|
||||||
@@ -522,11 +540,7 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
Archetypes = archetypes
|
Archetypes = archetypes
|
||||||
};
|
};
|
||||||
|
|
||||||
var group = new VisjectCMGroup(this, groupArchetype)
|
var group = CreateGroup(groupArchetype);
|
||||||
{
|
|
||||||
HeaderText = groupArchetype.Name
|
|
||||||
};
|
|
||||||
|
|
||||||
group.Close(false);
|
group.Close(false);
|
||||||
archetypeIndex = 0;
|
archetypeIndex = 0;
|
||||||
for (int i = 0; i < parameters.Count; i++)
|
for (int i = 0; i < parameters.Count; i++)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using FlaxEditor.Surface.Elements;
|
using FlaxEditor.Surface.Elements;
|
||||||
using FlaxEditor.Utilities;
|
using FlaxEditor.Utilities;
|
||||||
using FlaxEngine;
|
using FlaxEngine;
|
||||||
@@ -21,15 +22,20 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
public readonly VisjectCM ContextMenu;
|
public readonly VisjectCM ContextMenu;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The archetype.
|
/// The archetypes (one or more).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly GroupArchetype Archetype;
|
public readonly List<GroupArchetype> Archetypes = new List<GroupArchetype>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A computed score for the context menu order.
|
/// A computed score for the context menu order.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float SortScore;
|
public float SortScore;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The group name.
|
||||||
|
/// </summary>
|
||||||
|
public string Name;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="VisjectCMGroup"/> class.
|
/// Initializes a new instance of the <see cref="VisjectCMGroup"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -38,7 +44,8 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
public VisjectCMGroup(VisjectCM cm, GroupArchetype archetype)
|
public VisjectCMGroup(VisjectCM cm, GroupArchetype archetype)
|
||||||
{
|
{
|
||||||
ContextMenu = cm;
|
ContextMenu = cm;
|
||||||
Archetype = archetype;
|
Archetypes.Add(archetype);
|
||||||
|
Name = archetype.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -148,7 +155,7 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
int order = -1 * SortScore.CompareTo(otherGroup.SortScore);
|
int order = -1 * SortScore.CompareTo(otherGroup.SortScore);
|
||||||
if (order == 0)
|
if (order == 0)
|
||||||
{
|
{
|
||||||
order = string.Compare(Archetype.Name, otherGroup.Archetype.Name, StringComparison.InvariantCulture);
|
order = string.Compare(Name, otherGroup.Name, StringComparison.InvariantCulture);
|
||||||
}
|
}
|
||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,9 +77,9 @@ namespace FlaxEditor.Surface
|
|||||||
if (_cache.Count != 0)
|
if (_cache.Count != 0)
|
||||||
{
|
{
|
||||||
// Check if context menu doesn't have the recent cached groups
|
// Check if context menu doesn't have the recent cached groups
|
||||||
if (!contextMenu.Groups.Any(g => g.Archetype.Tag is int asInt && asInt == _version))
|
if (!contextMenu.Groups.Any(g => g.Archetypes[0].Tag is int asInt && asInt == _version))
|
||||||
{
|
{
|
||||||
var groups = contextMenu.Groups.Where(g => g.Archetype.Tag is int).ToArray();
|
var groups = contextMenu.Groups.Where(g => g.Archetypes[0].Tag is int).ToArray();
|
||||||
foreach (var g in groups)
|
foreach (var g in groups)
|
||||||
contextMenu.RemoveGroup(g);
|
contextMenu.RemoveGroup(g);
|
||||||
foreach (var g in _cache.Values)
|
foreach (var g in _cache.Values)
|
||||||
@@ -89,7 +89,7 @@ namespace FlaxEditor.Surface
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Remove any old groups from context menu
|
// Remove any old groups from context menu
|
||||||
var groups = contextMenu.Groups.Where(g => g.Archetype.Tag is int).ToArray();
|
var groups = contextMenu.Groups.Where(g => g.Archetypes[0].Tag is int).ToArray();
|
||||||
foreach (var g in groups)
|
foreach (var g in groups)
|
||||||
contextMenu.RemoveGroup(g);
|
contextMenu.RemoveGroup(g);
|
||||||
|
|
||||||
@@ -592,7 +592,7 @@ namespace FlaxEditor.Surface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
activeCM.AddGroup(_methodOverridesGroupArchetype);
|
activeCM.AddGroup(_methodOverridesGroupArchetype, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update nodes for invoke methods (async)
|
// Update nodes for invoke methods (async)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace FlaxEditor.Utilities
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Shunting-Yard algorithm parsing utilities.
|
/// The Shunting-Yard algorithm parsing utilities.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[HideInEditor]
|
||||||
public static class ShuntingYard
|
public static class ShuntingYard
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -33,6 +34,7 @@ namespace FlaxEditor.Utilities
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Types of possible tokens used in Shunting-Yard parser.
|
/// Types of possible tokens used in Shunting-Yard parser.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[HideInEditor]
|
||||||
public enum TokenType
|
public enum TokenType
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user