コード例 #1
0
        private ExpressionsMenuHierarchyItem[] Sweep(ExpressionsMenuHierarchyItem currentItem)
        {
            _visited.Add(currentItem);

            foreach (var item in currentItem.AllActiveSubMenuItems())
            {
                if (item.type != Emh.EmhType.SubMenu)
                {
                    continue;
                }

                switch (item.subMenuSource)
                {
                case Emh.EmhSubMenuSource.HierarchyChildren:
                    SweepIfApplicable(item.transform);
                    break;

                case Emh.EmhSubMenuSource.ExpressionMenuAsset:
                    break;

                case Emh.EmhSubMenuSource.HierarchyReference:
                    SweepIfApplicable(item.subMenuHierarchyReference);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            return(_visited.ToArray());
        }
コード例 #2
0
        private VRCExpressionsMenu.Control.Parameter[] SubParams(ExpressionsMenuHierarchyItem currentItem)
        {
            switch (currentItem.type)
            {
            case Emh.EmhType.TwoAxisPuppet:
                return(new[]
                {
                    new VRCExpressionsMenu.Control.Parameter {
                        name = currentItem.puppetParameter0
                    },
                    new VRCExpressionsMenu.Control.Parameter {
                        name = currentItem.puppetParameter1
                    },
                });

            case Emh.EmhType.FourAxisPuppet:
                return(new[]
                {
                    new VRCExpressionsMenu.Control.Parameter {
                        name = currentItem.puppetParameter0
                    },
                    new VRCExpressionsMenu.Control.Parameter {
                        name = currentItem.puppetParameter1
                    },
                    new VRCExpressionsMenu.Control.Parameter {
                        name = currentItem.puppetParameter2
                    },
                    new VRCExpressionsMenu.Control.Parameter {
                        name = currentItem.puppetParameter3
                    },
                });

            case Emh.EmhType.RadialPuppet:
                return(new[]
                {
                    new VRCExpressionsMenu.Control.Parameter {
                        name = currentItem.puppetParameter0
                    },
                });

            case Emh.EmhType.SubMenu:
            case Emh.EmhType.Button:
            case Emh.EmhType.Toggle:
                return(new VRCExpressionsMenu.Control.Parameter[0]);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #3
0
        private void CreateDiscardMenuItem(ExpressionsMenuHierarchyItem item, VRCExpressionsMenu destination, Emh.EmhDiscardType currentDiscard)
        {
            switch (currentDiscard)
            {
            case Emh.EmhDiscardType.BlankOut:
                destination.controls.Add(new VRCExpressionsMenu.Control
                {
                    type      = VRCExpressionsMenu.Control.ControlType.Button,
                    name      = "",
                    icon      = BlankIcon(),
                    value     = 1,
                    parameter = new VRCExpressionsMenu.Control.Parameter
                    {
                        name = ""
                    },
                    subMenu       = null,
                    subParameters = new VRCExpressionsMenu.Control.Parameter[0],
                    labels        = new VRCExpressionsMenu.Control.Label[0],
                });
                break;

            case Emh.EmhDiscardType.GrayOut:
                var iconNullable      = item.icon != null ? item.icon : _defaultIconOptional;
                var finalIconNullable = iconNullable != null && item.shader != null?CreateOrGetIcon(iconNullable, item.shader) : iconNullable;

                var grayedOutIcon = finalIconNullable != null?CreateOrGetIcon(finalIconNullable, _discardGrayOut) : null;

                destination.controls.Add(new VRCExpressionsMenu.Control
                {
                    type      = VRCExpressionsMenu.Control.ControlType.Button,
                    name      = item.ResolveName(),
                    icon      = grayedOutIcon,
                    value     = 1,
                    parameter = new VRCExpressionsMenu.Control.Parameter
                    {
                        name = ""
                    },
                    subMenu       = null,
                    subParameters = new VRCExpressionsMenu.Control.Parameter[0],
                    labels        = new VRCExpressionsMenu.Control.Label[0],
                });
                break;

            case Emh.EmhDiscardType.Remove:
            case Emh.EmhDiscardType.Default:
            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #4
0
        public EmhCompose(ExpressionsMenuHierarchyCompiler compiler)
        {
            _mainAssetContainer           = compiler.generatedMenu;
            _defaultIconOptional          = compiler.defaultIcon;
            _mainMenu                     = compiler.mainMenu;
            _generatedMenu                = compiler.generatedMenu;
            _expressionParametersOptional = compiler.expressionParameters;
            _discardTags                  = !string.IsNullOrEmpty(compiler.discardTags) ? compiler.discardTags.Split(',') : new string[0];
            _compilerDiscardType          = compiler.discardType == Emh.EmhDiscardType.Default ? Emh.EmhDiscardType.GrayOut : compiler.discardType;
            _discardGrayOut               = compiler.discardGrayOut == null
                ? new Material(Shader.Find("Hai/ExpressionsMenuHierarchyEditorGrayOut"))
                : compiler.discardGrayOut;

            // Last operation (depends on the previous lines)
            _discardApplicable = compiler.autoDiscard && (_expressionParametersOptional != null || _discardTags.Length != 0);
        }
コード例 #5
0
        private VRCExpressionsMenu.Control.Label[] SubLabels(ExpressionsMenuHierarchyItem currentItem)
        {
            switch (currentItem.type)
            {
            case Emh.EmhType.TwoAxisPuppet:
            case Emh.EmhType.FourAxisPuppet:
                return(new[]
                {
                    EmhDecompose.LabelOf(currentItem.puppetLabelUp), EmhDecompose.LabelOf(currentItem.puppetLabelRight), EmhDecompose.LabelOf(currentItem.puppetLabelDown), EmhDecompose.LabelOf(currentItem.puppetLabelLeft),
                });

            case Emh.EmhType.RadialPuppet:
            case Emh.EmhType.SubMenu:
            case Emh.EmhType.Button:
            case Emh.EmhType.Toggle:
                return(new VRCExpressionsMenu.Control.Label[0]);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #6
0
        private void CreateNormalMenuItem(VRCExpressionsMenu destination, ExpressionsMenuHierarchyItem item)
        {
            var iconNullable      = item.icon != null ? item.icon : _defaultIconOptional;
            var finalIconNullable = iconNullable != null && item.shader != null?CreateOrGetIcon(iconNullable, item.shader) : iconNullable;

            destination.controls.Add(new VRCExpressionsMenu.Control
            {
                type      = TypeIn(item.type),
                name      = item.ResolveName(),
                icon      = finalIconNullable,
                value     = item.value,
                parameter = new VRCExpressionsMenu.Control.Parameter
                {
                    name = item.parameter
                },
                // style = control.style,
                subMenu       = SubMenu(item, _visited),
                subParameters = SubParams(item),
                labels        = SubLabels(item),
            });
        }
コード例 #7
0
        private VRCExpressionsMenu SubMenu(ExpressionsMenuHierarchyItem currentItem, Dictionary <ExpressionsMenuHierarchyItem, VRCExpressionsMenu> mappings)
        {
            if (currentItem.type != Emh.EmhType.SubMenu)
            {
                return(null);
            }
            switch (currentItem.subMenuSource)
            {
            case Emh.EmhSubMenuSource.HierarchyChildren:
                return(mappings[currentItem]);

            case Emh.EmhSubMenuSource.ExpressionMenuAsset:
                return(currentItem.subMenuAsset);

            case Emh.EmhSubMenuSource.HierarchyReference:
                var subControl = currentItem.subMenuHierarchyReference.GetComponent <ExpressionsMenuHierarchyItem>();
                return(currentItem.subMenuHierarchyReference != null && subControl != null ? mappings[subControl] : null);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #8
0
        private bool ShouldBeDiscarded(ExpressionsMenuHierarchyItem item)
        {
            var qualify = item.Qualify(_expressionParametersOptional, _discardTags);

            return(qualify != Emh.EmhQualification.ElementIsAesthetic && qualify != Emh.EmhQualification.ElementIsFunctional);
        }
コード例 #9
0
 public ExpressionsMenuHierarchyItem[] Analyze(ExpressionsMenuHierarchyItem mainMenu)
 {
     return(Sweep(mainMenu));
 }
コード例 #10
0
 private static void SelectSubMenu(ExpressionsMenuHierarchyItem focusTargetObject)
 {
     Selection.SetActiveObjectWithContext(focusTargetObject, null);
 }