diff --git a/Source/Editor/GUI/Timeline/Tracks/ObjectTrack.cs b/Source/Editor/GUI/Timeline/Tracks/ObjectTrack.cs index 447ecb646..40c3311cf 100644 --- a/Source/Editor/GUI/Timeline/Tracks/ObjectTrack.cs +++ b/Source/Editor/GUI/Timeline/Tracks/ObjectTrack.cs @@ -113,6 +113,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks /// /// The data for add property track buttons tag. /// + [HideInEditor] public struct AddMemberTag { /// diff --git a/Source/Editor/Surface/AnimGraphSurface.cs b/Source/Editor/Surface/AnimGraphSurface.cs index fac24da81..06087eca0 100644 --- a/Source/Editor/Surface/AnimGraphSurface.cs +++ b/Source/Editor/Surface/AnimGraphSurface.cs @@ -113,9 +113,9 @@ namespace FlaxEditor.Surface if (_cache.Count != 0) { // 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) contextMenu.RemoveGroup(g); foreach (var g in _cache.Values) @@ -125,7 +125,7 @@ namespace FlaxEditor.Surface else { // 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) contextMenu.RemoveGroup(g); @@ -340,7 +340,7 @@ namespace FlaxEditor.Surface ParametersGetter = null, CustomNodesGroup = GetCustomNodes(), }); - _cmStateMachineTransitionMenu.AddGroup(StateMachineTransitionGroupArchetype); + _cmStateMachineTransitionMenu.AddGroup(StateMachineTransitionGroupArchetype, false); } menu = _cmStateMachineTransitionMenu; } diff --git a/Source/Editor/Surface/ContextMenu/VisjectCM.cs b/Source/Editor/Surface/ContextMenu/VisjectCM.cs index f07cd867e..984e3e520 100644 --- a/Source/Editor/Surface/ContextMenu/VisjectCM.cs +++ b/Source/Editor/Surface/ContextMenu/VisjectCM.cs @@ -171,11 +171,7 @@ namespace FlaxEditor.Surface.ContextMenu // Check if can create group for them if (nodes.Count > 0) { - var group = new VisjectCMGroup(this, groupArchetype) - { - HeaderText = groupArchetype.Name - }; - + var group = CreateGroup(groupArchetype); group.Close(false); for (int i = 0; i < nodes.Count; i++) { @@ -205,7 +201,7 @@ namespace FlaxEditor.Surface.ContextMenu VisjectCMGroup group = null; 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]; break; @@ -215,11 +211,7 @@ namespace FlaxEditor.Surface.ContextMenu // Create new group if name is unique if (group == null) { - group = new VisjectCMGroup(this, info.CustomNodesGroup) - { - HeaderText = groupName - }; - + group = CreateGroup(info.CustomNodesGroup, true, groupName); group.Close(false); group.Parent = _groupsPanel; _groups.Add(group); @@ -241,18 +233,15 @@ namespace FlaxEditor.Surface.ContextMenu /// Adds the group archetype to add to the menu. /// /// The group. - public void AddGroup(GroupArchetype groupArchetype) + /// True if merge group items into any existing group of the same name. + public void AddGroup(GroupArchetype groupArchetype, bool withGroupMerge = true) { // Check if can create group for them to be spawned via GUI if (groupArchetype.Archetypes.Any(x => (x.Flags & NodeFlags.NoSpawnViaGUI) == 0)) { Profiler.BeginEvent("VisjectCM.AddGroup"); - var group = new VisjectCMGroup(this, groupArchetype) - { - HeaderText = groupArchetype.Name - }; - + var group = CreateGroup(groupArchetype, withGroupMerge); group.Close(false); foreach (var nodeArchetype in groupArchetype.Archetypes) @@ -286,7 +275,8 @@ namespace FlaxEditor.Surface.ContextMenu /// Adds the group archetypes to add to the menu. /// /// The groups. - public void AddGroups(IEnumerable groupArchetypes) + /// True if merge group items into any existing group of the same name. + public void AddGroups(IEnumerable groupArchetypes, bool withGroupMerge = true) { // 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))) @@ -299,11 +289,7 @@ namespace FlaxEditor.Surface.ContextMenu var groups = new List(); foreach (var groupArchetype in groupArchetypes) { - var group = new VisjectCMGroup(this, groupArchetype) - { - HeaderText = groupArchetype.Name - }; - + var group = CreateGroup(groupArchetype, withGroupMerge); group.Close(false); foreach (var nodeArchetype in groupArchetype.Archetypes) @@ -349,11 +335,25 @@ namespace FlaxEditor.Surface.ContextMenu { 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"); - _groups[i].Dispose(); - _groups.RemoveAt(i); + if (group.Archetypes.Count == 0) + { + 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(); break; } @@ -372,6 +372,24 @@ namespace FlaxEditor.Surface.ContextMenu 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() { // Skip events during setup or init stuff @@ -522,11 +540,7 @@ namespace FlaxEditor.Surface.ContextMenu Archetypes = archetypes }; - var group = new VisjectCMGroup(this, groupArchetype) - { - HeaderText = groupArchetype.Name - }; - + var group = CreateGroup(groupArchetype); group.Close(false); archetypeIndex = 0; for (int i = 0; i < parameters.Count; i++) diff --git a/Source/Editor/Surface/ContextMenu/VisjectCMGroup.cs b/Source/Editor/Surface/ContextMenu/VisjectCMGroup.cs index e2f107710..ddb9dd75e 100644 --- a/Source/Editor/Surface/ContextMenu/VisjectCMGroup.cs +++ b/Source/Editor/Surface/ContextMenu/VisjectCMGroup.cs @@ -1,6 +1,7 @@ // Copyright (c) 2012-2022 Wojciech Figat. All rights reserved. using System; +using System.Collections.Generic; using FlaxEditor.Surface.Elements; using FlaxEditor.Utilities; using FlaxEngine; @@ -21,15 +22,20 @@ namespace FlaxEditor.Surface.ContextMenu public readonly VisjectCM ContextMenu; /// - /// The archetype. + /// The archetypes (one or more). /// - public readonly GroupArchetype Archetype; + public readonly List Archetypes = new List(); /// /// A computed score for the context menu order. /// public float SortScore; + /// + /// The group name. + /// + public string Name; + /// /// Initializes a new instance of the class. /// @@ -38,7 +44,8 @@ namespace FlaxEditor.Surface.ContextMenu public VisjectCMGroup(VisjectCM cm, GroupArchetype archetype) { ContextMenu = cm; - Archetype = archetype; + Archetypes.Add(archetype); + Name = archetype.Name; } /// @@ -148,7 +155,7 @@ namespace FlaxEditor.Surface.ContextMenu int order = -1 * SortScore.CompareTo(otherGroup.SortScore); if (order == 0) { - order = string.Compare(Archetype.Name, otherGroup.Archetype.Name, StringComparison.InvariantCulture); + order = string.Compare(Name, otherGroup.Name, StringComparison.InvariantCulture); } return order; } diff --git a/Source/Editor/Surface/VisualScriptSurface.cs b/Source/Editor/Surface/VisualScriptSurface.cs index 7d340466c..ba4034ffb 100644 --- a/Source/Editor/Surface/VisualScriptSurface.cs +++ b/Source/Editor/Surface/VisualScriptSurface.cs @@ -77,9 +77,9 @@ namespace FlaxEditor.Surface if (_cache.Count != 0) { // 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) contextMenu.RemoveGroup(g); foreach (var g in _cache.Values) @@ -89,7 +89,7 @@ namespace FlaxEditor.Surface else { // 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) contextMenu.RemoveGroup(g); @@ -592,7 +592,7 @@ namespace FlaxEditor.Surface } } - activeCM.AddGroup(_methodOverridesGroupArchetype); + activeCM.AddGroup(_methodOverridesGroupArchetype, false); } // Update nodes for invoke methods (async) diff --git a/Source/Editor/Utilities/ShuntingYardParser.cs b/Source/Editor/Utilities/ShuntingYardParser.cs index 83994a6d2..fc76dfc31 100644 --- a/Source/Editor/Utilities/ShuntingYardParser.cs +++ b/Source/Editor/Utilities/ShuntingYardParser.cs @@ -12,6 +12,7 @@ namespace FlaxEditor.Utilities /// /// The Shunting-Yard algorithm parsing utilities. /// + [HideInEditor] public static class ShuntingYard { /// @@ -33,6 +34,7 @@ namespace FlaxEditor.Utilities /// /// Types of possible tokens used in Shunting-Yard parser. /// + [HideInEditor] public enum TokenType { ///