Exemplo n.º 1
0
            private void ShowContextMenuOfBind(ChangerPlate parent, CombinationBinds bind)
            {
                var menu = new GenericMenu();

                var menuItems = new List <string> {
                    ChangerCondKey.CONTAINS,
                    ChangerCondKey.NOTCONTAINS,
                    ChangerCondKey.CONTAINSALL,
                    ChangerCondKey.NOTCONTAINSALL,
                };

                foreach (var combinationBind in menuItems.Select((val, index) => new { index, val }))
                {
                    var currentIndex = combinationBind.index;
                    menu.AddItem(
                        new GUIContent(combinationBind.val),
                        false,
                        () =>
                    {
                        parent.EmitUndo("Change Branch Combination");
                        bind.bindKind = menuItems[currentIndex];
                        parent.EmitSave();
                    }
                        );
                }

                menu.ShowAsContext();
            }
Exemplo n.º 2
0
            private void ShowContextMenuOfType(ChangerPlate parent, ConditionTypeValuePair typeValuePair)
            {
                var conditionType = typeValuePair.conditionType;
                var menu          = new GenericMenu();

                // update parent:ChangerPlate's conditions to latest.
                ChangerPlate.Emit(new OnChangerEvent(OnChangerEvent.EventType.EVENT_REFRESHCONDITIONS, parent.changerId));

                var menuItems = parent.conditions
                                .Select(conditonData => conditonData.conditionType)
                                .Where(type => type != conditionType)
                                .ToList();

                // current.
                menu.AddDisabledItem(
                    new GUIContent(conditionType)
                    );

                menu.AddSeparator(string.Empty);

                // new.
                menu.AddItem(
                    new GUIContent("Add New Type"),
                    false,
                    () =>
                {
                    ChangerPlate.Emit(new OnChangerEvent(OnChangerEvent.EventType.EVENT_ADDNEWTYPE, parent.changerId));
                }
                    );

                menu.AddSeparator(string.Empty);

                // other.
                foreach (var conditonData in menuItems.Select((val, index) => new { index, val }))
                {
                    var currentType = conditonData.val;

                    menu.AddItem(
                        new GUIContent(currentType),
                        false,
                        () =>
                    {
                        parent.EmitUndo("Change Combination Type");
                        typeValuePair.conditionType = currentType;
                        parent.EmitSave();
                    }
                        );
                }

                menu.ShowAsContext();
            }
Exemplo n.º 3
0
            private void ShowContextMenuOfValue(ChangerPlate parent, ConditionTypeValuePair typeValuePair)
            {
                var conditionType  = typeValuePair.conditionType;
                var conditionValue = typeValuePair.conditionValue;

                var menu = new GenericMenu();

                // update parent:ChangerPlate's conditions to latest.
                ChangerPlate.Emit(new OnChangerEvent(OnChangerEvent.EventType.EVENT_REFRESHCONDITIONS, parent.changerId));

                var menuItems = parent.conditions
                                .Where(data => data.conditionType == conditionType)
                                .FirstOrDefault();

                // current.
                if (!string.IsNullOrEmpty(conditionValue))
                {
                    menu.AddDisabledItem(
                        new GUIContent(conditionValue)
                        );
                    menu.AddSeparator(string.Empty);
                }

                // new.
                if (string.IsNullOrEmpty(conditionType))
                {
                    menu.AddItem(
                        new GUIContent("Add New Type & Value"),
                        false,
                        () =>
                    {
                        ChangerPlate.Emit(new OnChangerEvent(OnChangerEvent.EventType.EVENT_ADDNEWTYPEVALUE, parent.changerId));
                    }
                        );
                }
                else
                {
                    menu.AddItem(
                        new GUIContent("Add New Value"),
                        false,
                        () =>
                    {
                        ChangerPlate.Emit(new OnChangerEvent(OnChangerEvent.EventType.EVENT_ADDNEWVALUE, parent.changerId));
                    }
                        );
                }


                // show other conditionValues.
                if (menuItems != null)
                {
                    // remove current.
                    menuItems.conditionValues.Remove(conditionValue);

                    menu.AddSeparator(string.Empty);

                    // other.
                    foreach (var currentConditionValue in menuItems.conditionValues.Select((val, index) => new { index, val }))
                    {
                        // var currentType = conditionType;

                        var currentValue = currentConditionValue.val;
                        var currentIndex = currentConditionValue.index;

                        menu.AddItem(
                            new GUIContent(currentValue),
                            false,
                            () =>
                        {
                            parent.EmitUndo("Change Combination Value");
                            typeValuePair.conditionValue = menuItems.conditionValues[currentIndex];
                            parent.EmitSave();
                        }
                            );
                    }
                }

                menu.ShowAsContext();
            }