예제 #1
0
        /// <summary>
        /// Adds the group archetype to add to the menu.
        /// </summary>
        /// <param name="groupArchetype">The group.</param>
        public void AddGroup(GroupArchetype groupArchetype)
        {
            // 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);
                group.HeaderText = groupArchetype.Name;
                group.Close(false);
                foreach (var nodeArchetype in groupArchetype.Archetypes)
                {
                    var item = new VisjectCMItem(group, groupArchetype, nodeArchetype);
                    item.Parent = group;
                }
                group.SortChildren();
                group.Parent = _groupsPanel;
                _groups.Add(group);

                if (!IsLayoutLocked)
                {
                    group.UnlockChildrenRecursive();
                    SortGroups();
                    group.PerformLayout();
                    if (_searchBox.TextLength != 0)
                    {
                        OnSearchFilterChanged();
                    }
                }

                Profiler.EndEvent();
            }
        }
예제 #2
0
        /// <summary>
        /// Updates the surface parameters group.
        /// </summary>
        private void UpdateSurfaceParametersGroup()
        {
            // Remove the old one
            if (_surfaceParametersGroup != null)
            {
                _groups.Remove(_surfaceParametersGroup);
                _surfaceParametersGroup.Dispose();
                _surfaceParametersGroup = null;
            }

            // Check if surface has any parameters
            var parameters = _parametersGetter != null?_parametersGetter() : null;

            int count = parameters?.Count(x => x.IsPublic) ?? 0;

            if (count > 0)
            {
                // TODO: cache the allocated memory to reduce dynamic allocations
                var archetypes     = new NodeArchetype[count];
                int archetypeIndex = 0;

                // ReSharper disable once PossibleNullReferenceException
                for (int i = 0; i < parameters.Count; i++)
                {
                    if (!parameters[i].IsPublic)
                    {
                        continue;
                    }

                    var node = (NodeArchetype)_parameterGetNodeArchetype.Clone();
                    node.Title                   = "Get " + parameters[i].Name;
                    node.DefaultValues[0]        = parameters[i].ID;
                    archetypes[archetypeIndex++] = node;
                }

                var groupArchetype = new GroupArchetype
                {
                    GroupID    = 6,
                    Name       = "Surface Parameters",
                    Color      = new Color(52, 73, 94),
                    Archetypes = archetypes
                };

                var group = new VisjectCMGroup(this, groupArchetype);
                group.HeaderText = groupArchetype.Name;
                group.Close(false);
                archetypeIndex = 0;
                for (int i = 0; i < parameters.Count; i++)
                {
                    if (!parameters[i].IsPublic)
                    {
                        continue;
                    }

                    var item = new VisjectCMItem(group, groupArchetype, archetypes[archetypeIndex++]);
                    item.Parent = group;
                }
                group.SortChildren();
                group.UnlockChildrenRecursive();
                group.Parent = _groupsPanel;
                _groups.Add(group);
                _surfaceParametersGroup = group;
            }
        }
예제 #3
0
        /// <summary>
        /// Updates the surface parameters group.
        /// </summary>
        private void UpdateSurfaceParametersGroup()
        {
            // Remove the old one
            if (_surfaceParametersGroup != null)
            {
                _groups.Remove(_surfaceParametersGroup);
                _surfaceParametersGroup.Dispose();
                _surfaceParametersGroup = null;
            }

            // Check if surface has any parameters
            var parameters = _parametersGetter != null?_parametersGetter() : null;

            int count = parameters?.Count(x => x.IsPublic) ?? 0;

            if (count > 0)
            {
                // TODO: cache the allocated memory to reduce dynamic allocations
                var archetypes     = new NodeArchetype[count];
                int archetypeIndex = 0;

                // ReSharper disable once PossibleNullReferenceException
                for (int i = 0; i < parameters.Count; i++)
                {
                    if (!parameters[i].IsPublic)
                    {
                        continue;
                    }

                    archetypes[archetypeIndex++] = new NodeArchetype
                    {
                        TypeID        = 1,
                        Create        = Archetypes.Parameters.CreateGetNode,
                        Title         = "Get " + parameters[i].Name,
                        Description   = "Parameter value getter",
                        Size          = new Vector2(140, 60),
                        DefaultValues = new object[]
                        {
                            parameters[i].ID
                        },
                        Elements = new[]
                        {
                            NodeElementArchetype.Factory.ComboBox(2, 0, 116)
                        }
                    };
                }

                var groupArchetype = new GroupArchetype
                {
                    GroupID    = 6,
                    Name       = "Surface Parameters",
                    Color      = new Color(52, 73, 94),
                    Archetypes = archetypes
                };

                var group = new VisjectCMGroup(this, groupArchetype);
                group.HeaderText = groupArchetype.Name;
                group.Close(false);
                archetypeIndex = 0;
                for (int i = 0; i < parameters.Count; i++)
                {
                    if (!parameters[i].IsPublic)
                    {
                        continue;
                    }

                    var item = new VisjectCMItem(group, groupArchetype, archetypes[archetypeIndex++]);
                    item.Parent = group;
                }
                group.SortChildren();
                group.UnlockChildrenRecursive();
                group.Parent = _groupsPanel;
                _groups.Add(group);
                _surfaceParametersGroup = group;
            }
        }