Exemplo n.º 1
0
            // --------------------
            public void DrawGUI(DigitalBinding.AxisElem target, InputRig rig)
            {
                string axisName         = target.axisName;
                bool   axisPositiveSide = target.axisPositiveSide;

                EditorGUILayout.BeginHorizontal(CFEditorStyles.Inst.transpSunkenBG);

                axisPositiveSide = CFGUI.PushButton(new GUIContent("", CFEditorStyles.Inst.texPlusSign, "Bind to positive side of target axis."),
                                                    new GUIContent("", CFEditorStyles.Inst.texMinusSign, "Bind to negative side of target axis"), axisPositiveSide, CFEditorStyles.Inst.iconButtonStyle, GUILayout.Width(16));

                axisName = this.axisField.Draw("", axisName, rig);

                EditorGUILayout.EndHorizontal();


                if ((axisName != target.axisName) ||
                    (axisPositiveSide != target.axisPositiveSide))
                {
                    CFGUI.CreateUndo("Digital Binding Axis modification.", this.parent.undoObject);

                    target.axisName         = axisName;
                    target.axisPositiveSide = axisPositiveSide;

                    CFGUI.EndUndo(this.parent.undoObject);
                }
            }
Exemplo n.º 2
0
            // --------------------
            static private void AddDigitalBindingAxisSubMenu(GenericMenu menu, string axis, BindingDescription desc, System.Action onRefreshCallback)
            {
                DigitalBinding digiBinding = (DigitalBinding)desc.binding;

                string menuPath = desc.menuPath + desc.nameFormatted + "/";

                for (int i = -1; i < digiBinding.axisList.Count; ++i)
                {
                    string menuItemPath = "";

                    DigitalBinding.AxisElem axisElem = digiBinding.GetAxisElem(i);

                    if (i < 0)
                    {
                        menuItemPath = menuPath + "Add as new axis target/";
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(axisElem.axisName))
                        {
                            menuItemPath = menuPath + "Replace EMPTY (" + i + ")/";
                        }
                        else
                        {
                            menuItemPath = menuPath + "Replace \"" + axisElem.axisName + "\" (" + (axisElem.axisPositiveSide ? "Positive" : "Negative") + ") (" + i + ")/";
                        }
                    }

                    for (int sideIndex = 0; sideIndex < 2; ++sideIndex)
                    {
                        UniversalBindingAssignment o = new UniversalBindingAssignment();

                        o.undoLabel              = "Bind " + axis + " axis to " + desc.name;
                        o.undoObject             = desc.undoObject;
                        o.binding                = desc.binding;
                        o.onRefreshCallback      = onRefreshCallback;
                        o.digiAxisName           = axis;
                        o.digiAxisElemId         = i;
                        o.digiBindToPositiveAxis = ((sideIndex == 0) ? true : false);

                        menu.AddItem(new GUIContent(menuItemPath + ((sideIndex == 0) ? "As Positive" : "As Negative")), false, o.Execute);
                    }


                    if ((i < 0) && (digiBinding.keyList.Count > 0))
                    {
                        menu.AddSeparator(menuPath);
                    }
                }
            }
Exemplo n.º 3
0
            // ---------------
            public void Execute()
            {
                if (this.binding == null)
                {
                    return;
                }

                CFGUI.CreateUndo(this.undoLabel, this.undoObject);

                DigitalBinding       digiBinding   = (this.binding as DigitalBinding);
                AxisBinding          analogBinding = (this.binding as AxisBinding);
                EmuTouchBinding      touchBinding  = (this.binding as EmuTouchBinding);
                MousePositionBinding mouseBinding  = (this.binding as MousePositionBinding);

                //JoystickNameBinding		joyNameBinding	= (this.binding as JoystickNameBinding);

                // Digi binding...

                if (digiBinding != null)
                {
                    if (this.digiKey != KeyCode.None)
                    {
                        digiBinding.Enable();

                        if (this.digiKeyElemId < 0)
                        {
                            digiBinding.AddKey(this.digiKey);
                        }
                        else
                        {
                            digiBinding.ReplaceKey(this.digiKeyElemId, this.digiKey);
                        }
                    }

                    if (!string.IsNullOrEmpty(this.digiAxisName))
                    {
                        digiBinding.Enable();

                        DigitalBinding.AxisElem elem = null;


                        if (this.digiAxisElemId < 0)
                        {
                            elem = digiBinding.AddAxis();
                        }
                        else
                        {
                            elem = digiBinding.GetAxisElem(this.digiAxisElemId);
                        }

                        if (elem != null)
                        {
                            elem.SetAxis(this.digiAxisName, this.digiBindToPositiveAxis);
                        }
                    }
                }


                // Analog Binding...

                else if (analogBinding != null)
                {
                    if (!string.IsNullOrEmpty(this.analogAxisName))
                    {
                        analogBinding.Enable();

                        AxisBinding.TargetElem elem = null;

                        if (this.analogElemId < 0)
                        {
                            elem = analogBinding.AddTarget();
                        }
                        else
                        {
                            elem = analogBinding.GetTarget(this.analogElemId);
                        }

                        if (elem != null)
                        {
                            if (this.analogSeparate)
                            {
                                elem.SetSeparateAxis(this.analogAxisName, this.analogPositiveSide, !this.analogFlip);
                            }
                            else
                            {
                                elem.SetSingleAxis(this.analogAxisName, this.analogFlip);
                            }
                        }
                    }
                }

                // Touch Binding...

                else if (touchBinding != null)
                {
                    touchBinding.Enable();
                }

                // Mouse Binding...

                else if (mouseBinding != null)
                {
                    mouseBinding.Enable();
                }


                CFGUI.EndUndo(this.undoObject);

                if (this.onRefreshCallback != null)
                {
                    this.onRefreshCallback();
                }
            }