Esempio n. 1
0
        public override async Task <CommandBase> GetNewCommand()
        {
            if (await this.Validate())
            {
                if (this.command == null)
                {
                    this.command = new ActionGroupCommand(this.NameTextBox.Text);
                    ChannelSession.Settings.ActionGroupCommands.Add(this.command);
                }
                else
                {
                    this.command.Name = this.NameTextBox.Text;
                }
                this.command.Unlocked     = this.UnlockedControl.Unlocked;
                this.command.IsRandomized = this.RunOneRandomlyToggleButton.IsChecked.GetValueOrDefault();

                this.command.GroupName = !string.IsNullOrEmpty(this.CommandGroupComboBox.Text) ? this.CommandGroupComboBox.Text : null;
                if (!string.IsNullOrEmpty(this.CommandGroupComboBox.Text))
                {
                    if (!ChannelSession.Settings.CommandGroups.ContainsKey(this.CommandGroupComboBox.Text))
                    {
                        ChannelSession.Settings.CommandGroups[this.CommandGroupComboBox.Text] = new CommandGroupSettings(this.CommandGroupComboBox.Text);
                    }
                    ChannelSession.Settings.CommandGroups[this.CommandGroupComboBox.Text].Name = this.CommandGroupComboBox.Text;
                }

                return(this.command);
            }
            return(null);
        }
Esempio n. 2
0
 public override ActionBase GetAction()
 {
     if (this.ActionGroupNameComboBox.SelectedIndex >= 0)
     {
         ActionGroupCommand command = (ActionGroupCommand)this.ActionGroupNameComboBox.SelectedItem;
         return(new ActionGroupAction(command));
     }
     return(null);
 }
        protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments)
        {
            ActionGroupCommand command = ChannelSession.Settings.ActionGroupCommands.FirstOrDefault(c => c.Name.Equals(this.ActionGroupName));

            if (command != null)
            {
                await command.Perform(user, arguments, this.GetExtraSpecialIdentifiers());
            }
        }
Esempio n. 4
0
        protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments)
        {
            ActionGroupCommand command = this.GetCommand();

            if (command != null)
            {
                this.ActionGroupID = command.ID;
                await command.Perform(user, arguments, this.GetExtraSpecialIdentifiers());
            }
        }
        private void CommandButtons_EditClicked(object sender, RoutedEventArgs e)
        {
            CommandButtonsControl commandButtonsControl = (CommandButtonsControl)sender;
            ActionGroupCommand    command = commandButtonsControl.GetCommandFromCommandButtons <ActionGroupCommand>(sender);

            if (command != null)
            {
                CommandWindow window = new CommandWindow(new ActionGroupCommandDetailsControl(command));
                window.Closed += Window_Closed;
                window.Show();
            }
        }
 private async void CommandButtons_DeleteClicked(object sender, RoutedEventArgs e)
 {
     await this.Window.RunAsyncOperation(async() =>
     {
         CommandButtonsControl commandButtonsControl = (CommandButtonsControl)sender;
         ActionGroupCommand command = commandButtonsControl.GetCommandFromCommandButtons <ActionGroupCommand>(sender);
         if (command != null)
         {
             ChannelSession.Settings.ActionGroupCommands.Remove(command);
             await ChannelSession.SaveSettings();
             this.RefreshList();
         }
     });
 }
Esempio n. 7
0
        private static void ActivateActionGroup(KSPActionGroup ag)
        {
            var satellite = RTCore.Instance.Satellites[FlightGlobals.ActiveVessel];

            if (satellite != null && satellite.FlightComputer != null)
            {
                satellite.SignalProcessor.FlightComputer.Enqueue(ActionGroupCommand.WithGroup(ag));
            }
            else if (satellite == null || (satellite != null && satellite.HasLocalControl))
            {
                if (FlightGlobals.ActiveVessel.IsControllable)
                {
                    FlightGlobals.ActiveVessel.ActionGroups.ToggleGroup(ag);
                }
            }
        }
Esempio n. 8
0
 public override async Task <CommandBase> GetNewCommand()
 {
     if (await this.Validate())
     {
         if (this.command == null)
         {
             this.command = new ActionGroupCommand(this.NameTextBox.Text);
             ChannelSession.Settings.ActionGroupCommands.Add(this.command);
         }
         else
         {
             this.command.Name = this.NameTextBox.Text;
         }
         return(this.command);
     }
     return(null);
 }
Esempio n. 9
0
 public override async Task <CommandBase> GetNewCommand()
 {
     if (await this.Validate())
     {
         if (this.command == null)
         {
             this.command = new ActionGroupCommand(this.NameTextBox.Text);
             ChannelSession.Settings.ActionGroupCommands.Add(this.command);
         }
         else
         {
             this.command.Name = this.NameTextBox.Text;
         }
         this.command.Unlocked     = this.UnlockedControl.Unlocked;
         this.command.IsRandomized = this.RunOneRandomlyToggleButton.IsChecked.GetValueOrDefault();
         return(this.command);
     }
     return(null);
 }
Esempio n. 10
0
        /// <summary>
        /// Called when an action group button, from the KSP GUI, is pressed.
        /// </summary>
        /// <param name="ag">The action group that was pressed.</param>
        private static void ActivateActionGroup(KSPActionGroup ag)
        {
            var satellite = RTCore.Instance.Satellites[FlightGlobals.ActiveVessel];

            if (satellite != null && satellite.FlightComputer != null)
            {
                satellite.SignalProcessor.FlightComputer.Enqueue(ActionGroupCommand.WithGroup(ag));
            }
            else if (satellite == null || (satellite != null && satellite.HasLocalControl))
            {
                if (!FlightGlobals.ready)
                {
                    return;
                }

                if (FlightGlobals.ActiveVessel.IsControllable)
                {
                    // check if EVA or not (as we removed the default KSP listener).
                    if (!FlightGlobals.ActiveVessel.isEVA)
                    {
                        FlightGlobals.ActiveVessel.ActionGroups.ToggleGroup(ag);
                    }
                    else // it's an EVA
                    {
                        if (ag == KSPActionGroup.RCS)
                        {
                            FlightGlobals.ActiveVessel.evaController.ToggleJetpack();
                        }
                        else if (ag == KSPActionGroup.Light)
                        {
                            FlightGlobals.ActiveVessel.evaController.ToggleLamp();
                        }
                    }
                }
            }
        }
 public ActionGroupAction(ActionGroupCommand command)
     : this()
 {
     this.ActionGroupName = command.Name;
 }
Esempio n. 12
0
 public ActionGroupCommandDetailsControl(ActionGroupCommand command)
 {
     this.command = command;
     InitializeComponent();
 }
Esempio n. 13
0
 public ActionGroupAction(ActionGroupCommand command)
     : this()
 {
     this.ActionGroupID = command.ID;
 }