示例#1
0
        /// <summary>
        /// Adds <paramref name="command"/> in the given <paramref name="group"/> if not in already.
        /// </summary>
        /// <param name="group"></param>
        /// <param name="command"></param>
        public void     AddCommand(string group, InputCommand command)
        {
            for (int i = 0; i < this.groups.Count; i++)
            {
                if (this.groups[i].name == group)
                {
                    if (this.groups[i].ExistCommand(command) == false)
                    {
                        this.groups[i].commands.Add(command);
                    }
                    return;
                }
            }

            this.groups.Add(new InputsGroup(group, command));
        }
示例#2
0
        private static void     DrawInputCommand(InputCommand command)
        {
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.Label(LC.G("Input_" + command.name), GeneralStyles.Title1, GUILayoutOptionPool.ExpandWidthFalse);

                if (ConsoleSettingsEditor.registeringCommand == command)
                {
                    if (Event.current.type == EventType.KeyUp)
                    {
                        if (Event.current.keyCode == KeyCode.LeftControl || Event.current.keyCode == KeyCode.RightControl)
                        {
                            command.modifiers ^= InputCommand.Control;
                        }
                        else if (Event.current.keyCode == KeyCode.LeftShift || Event.current.keyCode == KeyCode.RightShift)
                        {
                            command.modifiers ^= InputCommand.Shift;
                        }
                        else if (Event.current.keyCode == KeyCode.LeftAlt || Event.current.keyCode == KeyCode.RightAlt)
                        {
                            command.modifiers ^= InputCommand.Alt;
                        }
                        else
                        {
                            command.keyCode = Event.current.keyCode;
                        }

                        Event.current.Use();
                    }
                    else if (Event.current.shift == true)
                    {
                        ConsoleSettingsEditor.shiftPressed = true;
                    }
                    else if (ConsoleSettingsEditor.shiftPressed == true)
                    {
                        command.modifiers ^= InputCommand.Shift;
                        ConsoleSettingsEditor.shiftPressed = false;
                    }

                    if (GUILayout.Button(LC.G("Stop"), GUILayoutOptionPool.MaxWidth(80F)) == true)
                    {
                        registeringCommand = null;
                    }

                    GUILayout.Label(LC.G("ConsoleSettings_PressAny"));

                    // Force repaint to handle shift input.
                    //ConsoleSettingsEditor.Repaint();
                }
                else if (GUILayout.Button(LC.G("Edit"), GUILayoutOptionPool.MaxWidth(80F)) == true)
                {
                    Utility.content.text = LC.G("InputsWizard_PressAnythingToEditCommand");
                    registeringCommand   = command;
                    ConsoleSettingsEditor.shiftPressed = false;
                }
            }
            EditorGUILayout.EndHorizontal();

            string description = LC.G("Input_" + command.name + InputCommand.DescriptionLocalizationSuffix);

            if (string.IsNullOrEmpty(description) == false)
            {
                EditorGUILayout.LabelField(description, GeneralStyles.WrapLabel);
            }

            EditorGUILayout.BeginHorizontal();
            {
                command.keyCode = (KeyCode)EditorGUILayout.EnumPopup(command.keyCode, GUILayoutOptionPool.Width(130F));

                EditorGUI.BeginChangeCheck();
                GUILayout.Toggle((command.modifiers & InputCommand.Control) != 0, "Ctrl", ConsoleSettingsEditor.menuButtonStyle, GUILayoutOptionPool.Width(50F));
                if (EditorGUI.EndChangeCheck() == true)
                {
                    command.modifiers ^= InputCommand.Control;
                }

                EditorGUI.BeginChangeCheck();
                GUILayout.Toggle((command.modifiers & InputCommand.Shift) != 0, "Shift", ConsoleSettingsEditor.menuButtonStyle, GUILayoutOptionPool.Width(50F));
                if (EditorGUI.EndChangeCheck() == true)
                {
                    command.modifiers ^= InputCommand.Shift;
                }

                EditorGUI.BeginChangeCheck();
                GUILayout.Toggle((command.modifiers & InputCommand.Alt) != 0, "Alt", ConsoleSettingsEditor.menuButtonStyle, GUILayoutOptionPool.Width(50F));
                if (EditorGUI.EndChangeCheck() == true)
                {
                    command.modifiers ^= InputCommand.Alt;
                }
            }
            EditorGUILayout.EndHorizontal();
        }
示例#3
0
 public bool     ExistCommand(InputCommand command)
 {
     return(this.ExistCommand(command.name));
 }
示例#4
0
 public InputsGroup(string name, InputCommand command)
 {
     this.name     = name;
     this.commands = new List <InputCommand>();
     this.commands.Add(command);
 }