Esempio n. 1
0
        private void JoystickSetupComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if (this.JoystickSetupComboBox.SelectedIndex >= 0)
            {
                InteractiveJoystickSetupType setup = EnumHelper.GetEnumValueFromString <InteractiveJoystickSetupType>((string)this.JoystickSetupComboBox.SelectedItem);
                if (setup == InteractiveJoystickSetupType.MapToIndividualKeys)
                {
                    this.UpKeyComboBox.IsEnabled     = this.RightKeyComboBox.IsEnabled = this.DownKeyComboBox.IsEnabled = this.LeftKeyComboBox.IsEnabled = true;
                    this.UpKeyComboBox.SelectedIndex = this.RightKeyComboBox.SelectedIndex = this.DownKeyComboBox.SelectedIndex = this.LeftKeyComboBox.SelectedIndex = -1;
                }
                else
                {
                    this.UpKeyComboBox.IsEnabled = this.RightKeyComboBox.IsEnabled = this.DownKeyComboBox.IsEnabled = this.LeftKeyComboBox.IsEnabled = false;
                    if (setup == InteractiveJoystickSetupType.WASD)
                    {
                        this.UpKeyComboBox.SelectedItem    = EnumHelper.GetEnumName(InputKeyEnum.W);
                        this.RightKeyComboBox.SelectedItem = EnumHelper.GetEnumName(InputKeyEnum.D);
                        this.DownKeyComboBox.SelectedItem  = EnumHelper.GetEnumName(InputKeyEnum.S);
                        this.LeftKeyComboBox.SelectedItem  = EnumHelper.GetEnumName(InputKeyEnum.A);
                    }
                    else if (setup == InteractiveJoystickSetupType.DirectionalArrows || setup == InteractiveJoystickSetupType.MouseMovement)
                    {
                        this.UpKeyComboBox.SelectedItem    = EnumHelper.GetEnumName(InputKeyEnum.Up);
                        this.RightKeyComboBox.SelectedItem = EnumHelper.GetEnumName(InputKeyEnum.Right);
                        this.DownKeyComboBox.SelectedItem  = EnumHelper.GetEnumName(InputKeyEnum.Down);
                        this.LeftKeyComboBox.SelectedItem  = EnumHelper.GetEnumName(InputKeyEnum.Left);
                    }
                }

                this.MouseMovementMultiplierTextBox.Visibility = (setup == InteractiveJoystickSetupType.MouseMovement) ? Visibility.Visible : Visibility.Collapsed;
            }
        }
Esempio n. 2
0
        public override async Task <bool> Validate()
        {
            if (this.JoystickSetupComboBox.SelectedIndex < 0)
            {
                await MessageBoxHelper.ShowMessageDialog("A Joystick Setup must be selected");

                return(false);
            }
            InteractiveJoystickSetupType setup = EnumHelper.GetEnumValueFromString <InteractiveJoystickSetupType>((string)this.JoystickSetupComboBox.SelectedItem);

            if (!int.TryParse(this.JoystickDeadZoneTextBox.Text, out int deadzone) || deadzone < 0 || deadzone > 100)
            {
                await MessageBoxHelper.ShowMessageDialog("A valid Joystick Dead Zone must be entered between 0 & 100");

                return(false);
            }

            if (setup == InteractiveJoystickSetupType.MouseMovement)
            {
                if (!double.TryParse(this.MouseMovementMultiplierTextBox.Text, out double mouseMultiplier) || mouseMultiplier < 1.0)
                {
                    await MessageBoxHelper.ShowMessageDialog("A valid Movement Multiplier must be entered that is 1.0 or greater");

                    return(false);
                }
            }

            if (!await this.Requirements.Validate())
            {
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
        public override async Task <CommandBase> GetNewCommand()
        {
            if (await this.Validate())
            {
                InteractiveJoystickSetupType setup = EnumHelper.GetEnumValueFromString <InteractiveJoystickSetupType>((string)this.JoystickSetupComboBox.SelectedItem);

                RequirementViewModel requirements = this.Requirements.GetRequirements();

                if (this.command == null)
                {
                    this.command = new InteractiveJoystickCommand(this.Game, this.Scene, this.Control, requirements);
                    ChannelSession.Settings.InteractiveCommands.Add(this.command);
                }
                this.command.InitializeAction();

                this.command.SetupType = setup;
                this.command.DeadZone  = (double.Parse(this.JoystickDeadZoneTextBox.Text) / 100.0);
                this.command.MappedKeys.Clear();

                if (setup == InteractiveJoystickSetupType.MouseMovement)
                {
                    this.command.MouseMovementMultiplier = double.Parse(this.MouseMovementMultiplierTextBox.Text);
                }
                else if (setup == InteractiveJoystickSetupType.MapToIndividualKeys)
                {
                    if (this.UpKeyComboBox.SelectedIndex >= 0)
                    {
                        this.command.MappedKeys.Add(EnumHelper.GetEnumValueFromString <InputKeyEnum>((string)this.UpKeyComboBox.SelectedItem));
                    }
                    else
                    {
                        this.command.MappedKeys.Add(null);
                    }
                    if (this.RightKeyComboBox.SelectedIndex >= 0)
                    {
                        this.command.MappedKeys.Add(EnumHelper.GetEnumValueFromString <InputKeyEnum>((string)this.RightKeyComboBox.SelectedItem));
                    }
                    else
                    {
                        this.command.MappedKeys.Add(null);
                    }
                    if (this.DownKeyComboBox.SelectedIndex >= 0)
                    {
                        this.command.MappedKeys.Add(EnumHelper.GetEnumValueFromString <InputKeyEnum>((string)this.DownKeyComboBox.SelectedItem));
                    }
                    else
                    {
                        this.command.MappedKeys.Add(null);
                    }
                    if (this.LeftKeyComboBox.SelectedIndex >= 0)
                    {
                        this.command.MappedKeys.Add(EnumHelper.GetEnumValueFromString <InputKeyEnum>((string)this.LeftKeyComboBox.SelectedItem));
                    }
                    else
                    {
                        this.command.MappedKeys.Add(null);
                    }
                }

                this.command.Unlocked     = this.UnlockedControl.Unlocked;
                this.command.Requirements = requirements;

                return(this.command);
            }
            return(null);
        }