Exemple #1
0
        private void OnSetTypeButtonClicked(Button button)
        {
            var controlTypes = Editor.Instance.CodeEditing.GetControlTypes();

            if (controlTypes.Count == 0)
            {
                return;
            }

            // Show context menu with list of controls to add
            var cm = new ItemsListContextMenu(180);

            for (int i = 0; i < controlTypes.Count; i++)
            {
                var controlType = controlTypes[i];
                cm.ItemsPanel.AddChild(new ItemsListContextMenu.Item(controlType.Name, controlType)
                {
                    TooltipText = controlType.FullName,
                });
            }

            cm.ItemClicked += controlType => SetType((Type)controlType.Tag);
            cm.SortChildren();
            cm.Show(button.Parent, button.BottomLeft);
        }
Exemple #2
0
        private void AddScriptButtonOnClicked(Button button)
        {
            var scripts = Editor.Instance.CodeEditing.GetScripts();

            if (scripts.Count == 0)
            {
                // No scripts
                var cm1 = new ContextMenu();
                cm1.AddButton("No scripts in project");
                cm1.Show(this, button.BottomLeft);
                return;
            }

            // Show context menu with list of scripts to add
            var cm = new ItemsListContextMenu(180);

            for (int i = 0; i < scripts.Count; i++)
            {
                var script = scripts[i];
                cm.ItemsPanel.AddChild(new ItemsListContextMenu.Item(script.ScriptName, script));
            }

            cm.ItemClicked += script => AddScript((ScriptItem)script.Tag);
            cm.SortChildren();
            cm.Show(this, button.BottomLeft);
        }
        private void OnAddParameterButtonClicked(Button button)
        {
            var window            = (IVisjectSurfaceWindow)Values[0];
            var newParameterTypes = window.NewParameterTypes;

            // Show context menu with list of parameter types to add
            var cm = new ItemsListContextMenu(180);

            foreach (var newParameterType in newParameterTypes)
            {
                var name = newParameterType.Type != null?window.VisjectSurface.GetTypeName(newParameterType) : newParameterType.Name;

                var item = new ItemsListContextMenu.Item(name, newParameterType)
                {
                    TooltipText = newParameterType.TypeName,
                };
                var attributes       = newParameterType.GetAttributes(false);
                var tooltipAttribute = (TooltipAttribute)attributes.FirstOrDefault(x => x is TooltipAttribute);
                if (tooltipAttribute != null)
                {
                    item.TooltipText += '\n';
                    item.TooltipText += tooltipAttribute.Text;
                }
                cm.AddItem(item);
            }
            cm.ItemClicked += OnAddParameterItemClicked;
            cm.SortChildren();
            cm.Show(button.Parent, button.BottomLeft);
        }
        private void OnAddParameterButtonClicked(Button button)
        {
            var window            = (IVisjectSurfaceWindow)Values[0];
            var newParameterTypes = window.NewParameterTypes;

            // Show context menu with list of parameter types to add
            var cm = new ItemsListContextMenu(180);

            foreach (var newParameterType in newParameterTypes)
            {
                var item = new TypeSearchPopup.TypeItemView(newParameterType)
                {
                    Tag         = newParameterType,
                    TooltipText = newParameterType.TypeName,
                };
                if (newParameterType.Type != null)
                {
                    item.Name = window.VisjectSurface.GetTypeName(newParameterType);
                }
                cm.AddItem(item);
            }
            cm.ItemClicked += OnAddParameterItemClicked;
            cm.SortChildren();
            cm.Show(button.Parent, button.BottomLeft);
        }
Exemple #5
0
                private void OnAddModuleButtonClicked(Button button)
                {
                    var modules = ParticleModules.Nodes.Where(x => (ParticleModules.ModuleType)x.DefaultValues[1] == ModuleType);

                    // Show context menu with list of module types to add
                    var cm = new ItemsListContextMenu(180);

                    foreach (var module in modules)
                    {
                        cm.AddItem(new ItemsListContextMenu.Item(module.Title, module.TypeID)
                        {
                            TooltipText = module.Description,
                        });
                    }
                    cm.ItemClicked += item => AddModule((ushort)item.Tag);
                    cm.SortChildren();
                    cm.Show(this, button.BottomLeft);
                }
Exemple #6
0
        private void PickBone(Button button, Action <string> action, bool showOnlyExisting)
        {
            // Show context menu with list of bones to pick
            var cm            = new ItemsListContextMenu(280);
            var ragdoll       = (Ragdoll)Values[0];
            var bodies        = ragdoll.Children.Where(x => x is RigidBody && x.IsActive);
            var animatedModel = (AnimatedModel)ragdoll.Parent;

            animatedModel.SkinnedModel.WaitForLoaded();
            var nodes = animatedModel.SkinnedModel.Nodes;
            var bones = animatedModel.SkinnedModel.Bones;

            foreach (var bone in bones)
            {
                var node = nodes[bone.NodeIndex];
                if (showOnlyExisting && !bodies.Any(x => x.Name == node.Name))
                {
                    continue;
                }
                string prefix = string.Empty, tooltip = node.Name;
                var    boneParentIndex = bone.ParentIndex;
                while (boneParentIndex != -1)
                {
                    prefix         += "   ";
                    tooltip         = nodes[bones[boneParentIndex].NodeIndex].Name + " > " + tooltip;
                    boneParentIndex = bones[boneParentIndex].ParentIndex;
                }
                var item = new ItemsListContextMenu.Item
                {
                    Name        = prefix + node.Name,
                    TooltipText = tooltip,
                    Tag         = node.Name,
                };
                if (!showOnlyExisting && !bodies.Any(x => x.Name == node.Name))
                {
                    item.TintColor = new Color(1, 0.8f, 0.8f, 0.6f);
                }
                cm.AddItem(item);
            }
            cm.ItemClicked += item => action((string)item.Tag);
            cm.SortChildren();
            cm.Show(button.Parent, button.BottomLeft);
        }
        private void OnAddScriptButtonClicked(Button button)
        {
            var scripts = Editor.Instance.CodeEditing.Scripts.Get();

            if (scripts.Count == 0)
            {
                // No scripts
                var cm1 = new ContextMenu();
                cm1.AddButton("No scripts in project");
                cm1.Show(this, button.BottomLeft);
                return;
            }

            // Show context menu with list of scripts to add
            var cm = new ItemsListContextMenu(180);

            for (int i = 0; i < scripts.Count; i++)
            {
                cm.AddItem(new TypeSearchPopup.TypeItemView(scripts[i]));
            }
            cm.ItemClicked += item => AddScript((ScriptType)item.Tag);
            cm.SortItems();
            cm.Show(this, button.BottomLeft);
        }
Exemple #8
0
        private void AddScriptButtonOnClicked(Button button)
        {
            var scripts = Editor.Instance.CodeEditing.Scripts.Get();

            if (scripts.Count == 0)
            {
                // No scripts
                var cm1 = new ContextMenu();
                cm1.AddButton("No scripts in project");
                cm1.Show(this, button.BottomLeft);
                return;
            }

            // Show context menu with list of scripts to add
            var cm = new ItemsListContextMenu(180);

            for (int i = 0; i < scripts.Count; i++)
            {
                var scriptType = scripts[i];
                var item       = new ItemsListContextMenu.Item(scriptType.Name, scriptType)
                {
                    TooltipText = scriptType.TypeName,
                };
                var attributes       = scriptType.GetAttributes(false);
                var tooltipAttribute = (TooltipAttribute)attributes.FirstOrDefault(x => x is TooltipAttribute);
                if (tooltipAttribute != null)
                {
                    item.TooltipText += '\n';
                    item.TooltipText += tooltipAttribute.Text;
                }
                cm.AddItem(item);
            }
            cm.ItemClicked += item => AddScript((ScriptType)item.Tag);
            cm.SortChildren();
            cm.Show(this, button.BottomLeft);
        }