// --------------------
        static protected void SetupDigitalBinding(DigitalBinding binding, string axisName, KeyCode key)
        {
            binding.Clear();

            if (!string.IsNullOrEmpty(axisName))
            {
                binding.Enable();
                binding.AddAxis().SetAxis(axisName, true);
            }

            if (key != KeyCode.None)
            {
                binding.Enable();
                binding.AddKey(key);
            }
        }
コード例 #2
0
        // ------------------
        public void Draw(DigitalBinding bind, InputRig rig)
        {
            bool bindingEnabled = bind.enabled;

            EditorGUILayout.BeginVertical();

            if (bindingEnabled = EditorGUILayout.ToggleLeft(this.labelContent, bindingEnabled, GUILayout.MinWidth(30)))
            {
                CFGUI.BeginIndentedVertical(CFEditorStyles.Inst.transpSunkenBG);


                EditorGUILayout.BeginVertical(CFEditorStyles.Inst.transpSunkenBG);

                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField(new GUIContent("Axis Targets"), GUILayout.MinWidth(30), GUILayout.ExpandWidth(true));

                {
                    if (GUILayout.Button(new GUIContent(CFEditorStyles.Inst.texPlusSign, "Add Axis Target"), CFEditorStyles.Inst.iconButtonStyle))                             //, GUILayout.Width(20), GUILayout.Height(20)))
                    {
                        CFGUI.CreateUndo("Add new axis to Digital Binding.", this.undoObject);
                        bind.AddAxis();
                        CFGUI.EndUndo(this.undoObject);
                    }

                    if (GUILayout.Button(new GUIContent(CFEditorStyles.Inst.texMinusSign, "Remove Axis Target"), CFEditorStyles.Inst.iconButtonStyle))                             //, GUILayout.Width(20), GUILayout.Height(20)))
                    {
                        CFGUI.CreateUndo("Remove axis from Digital Binding.", this.undoObject);
                        bind.RemoveLastAxis();
                        CFGUI.EndUndo(this.undoObject);
                    }
                }

                EditorGUILayout.EndHorizontal();


                {
                    this.PrepareAxisElemInspList(bind.axisList.Count);

                    if (bind.axisList.Count == 0)
                    {
                        EditorGUILayout.LabelField("No axis targets defined...", CFEditorStyles.Inst.centeredTextTranspBG);
                    }
                    else
                    {
                        for (int i = 0; i < bind.axisList.Count; ++i)
                        {
                            this.axisElemInspList[i].DrawGUI(bind.axisList[i], rig);
                        }
                    }
                }

                EditorGUILayout.EndVertical();


                // Key targets...


                EditorGUILayout.BeginVertical(CFEditorStyles.Inst.transpSunkenBG);
                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField(new GUIContent("Key Targets"), GUILayout.MinWidth(30), GUILayout.ExpandWidth(true));

                {
                    if (GUILayout.Button(new GUIContent(CFEditorStyles.Inst.texPlusSign, "Add Key Target"), CFEditorStyles.Inst.iconButtonStyle))                             //, GUILayout.Width(20), GUILayout.Height(20)))
                    {
                        CFGUI.CreateUndo("Add new key to Digital Binding.", this.undoObject);
                        bind.AddKey(KeyCode.None);
                        CFGUI.EndUndo(this.undoObject);
                    }

                    if (GUILayout.Button(new GUIContent(CFEditorStyles.Inst.texMinusSign, "Remove Key Target"), CFEditorStyles.Inst.iconButtonStyle))                             //GUILayout.Width(20), GUILayout.Height(20)))
                    {
                        CFGUI.CreateUndo("Remove key from Digital Binding.", this.undoObject);
                        bind.RemoveLastKey();
                        CFGUI.EndUndo(this.undoObject);
                    }
                }

                EditorGUILayout.EndHorizontal();

                {
                    if (bind.keyList.Count == 0)
                    {
                        EditorGUILayout.LabelField("No key targets defined...", CFEditorStyles.Inst.centeredTextTranspBG);
                    }
                    else
                    {
                        EditorGUILayout.BeginVertical(CFEditorStyles.Inst.transpSunkenBG);

                        for (int i = 0; i < bind.keyList.Count; ++i)
                        {
                            KeyCode
                                keyOriginal = bind.keyList[i],
                                key         = keyOriginal;

                            key = (KeyCode)EditorGUILayout.EnumPopup("" /*"KeyCode"*/, key, GUILayout.MinWidth(30), GUILayout.ExpandWidth(false));

                            if (key != keyOriginal)
                            {
                                CFGUI.CreateUndo("Digital Binding Key modification.", this.undoObject);
                                bind.keyList[i] = key;
                                CFGUI.EndUndo(this.undoObject);
                            }
                        }

                        EditorGUILayout.EndVertical();
                    }
                }


                EditorGUILayout.EndVertical();



                CFGUI.EndIndentedVertical();
            }

            EditorGUILayout.EndVertical();


            if ((bindingEnabled != bind.enabled))
            {
                CFGUI.CreateUndo("Digital Binding modification.", this.undoObject);

                bind.enabled = bindingEnabled;

                CFGUI.EndUndo(this.undoObject);
            }
        }
コード例 #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();
                }
            }