Exemple #1
0
 public TriggerActionTimer(TriggerActionTimer other) : base(other)
 {
     _type  = TriggerActionType.Timer;
     _timer = null;
     // Automatic call of Name_set
     Name         = other.Name;
     _timerAction = other._timerAction;
     _modified    = false;
     UpdatePersistentData();
 }
Exemple #2
0
        public void OnLoad(ConfigNode node, VesselTriggers triggerConfig)
        {
            bool              dataFound  = false;
            ConfigNode        childNode  = null;
            int               nbItem     = 0;
            TriggerActionType actionType = (TriggerActionType)(-1);

            dataFound = node.TryGetValue(KEY_NB_ACTIONS, ref nbItem);
            if (dataFound)
            {
                for (int i = 0; i < nbItem; i++)
                {
                    TriggerAction action = null;
                    dataFound = node.TryGetNode(KEY_PREF_ACTION + i, ref childNode);
                    if (dataFound)
                    {
                        dataFound = childNode.TryGetEnum <TriggerActionType>("type", ref actionType, (TriggerActionType)(-1));
                        if (dataFound)
                        {
                            switch (actionType)
                            {
                            case TriggerActionType.Part:
                                action = new TriggerActionPart(triggerConfig);
                                break;

                            case TriggerActionType.Flight:
                                action = new TriggerActionFlight(triggerConfig);
                                break;

                            case TriggerActionType.Message:
                                action = new TriggerActionMessage(triggerConfig);
                                break;

                            case TriggerActionType.Timer:
                                action = new TriggerActionTimer(triggerConfig);
                                break;

                            default:
                                break;
                            }
                            if (action != null)
                            {
                                dataFound = ConfigNode.LoadObjectFromConfig(action, childNode);
                                if (dataFound)
                                {
                                    _actions.Add(action);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #3
0
 private void SelectAction(int actionIndex)
 {
     _actionIndex = actionIndex;
     _partSelector.CancelSelect();
     _popupUI.CloseAll();
     _actionPart    = null;
     _actionFlight  = null;
     _actionMessage = null;
     _actionTimer   = null;
     _currentAction = null;
     if (_actionIndex < 0)
     {
         return;
     }
     if (_actions[_actionIndex] == null)
     {
         _actionIndexType = (int)TriggerActionType.Flight;
     }
     else if (_actions[_actionIndex] is TriggerActionPart)
     {
         _actionIndexType = (int)TriggerActionType.Part;
         _actionPart      = new TriggerActionPart((TriggerActionPart)_actions[_actionIndex]);
     }
     else if (_actions[_actionIndex] is TriggerActionFlight)
     {
         _actionIndexType = (int)TriggerActionType.Flight;
         _actionFlight    = new TriggerActionFlight((TriggerActionFlight)_actions[_actionIndex]);
     }
     else if (_actions[_actionIndex] is TriggerActionMessage)
     {
         _actionIndexType = (int)TriggerActionType.Message;
         _actionMessage   = new TriggerActionMessage((TriggerActionMessage)_actions[_actionIndex]);
     }
     else if (_actions[_actionIndex] is TriggerActionTimer)
     {
         _actionIndexType = (int)TriggerActionType.Timer;
         _actionTimer     = new TriggerActionTimer((TriggerActionTimer)_actions[_actionIndex]);
     }
 }
Exemple #4
0
        private void DisplayTimerConf()
        {
            if (_actionTimer == null)
            {
                _actionTimer = new TriggerActionTimer(_vesselTriggers);
            }
            _currentAction = _actionTimer;
            // Left column
            GUILayout.BeginArea(_boxLeftPos);
            GUILayout.BeginVertical();
            // Name
            GUILayout.BeginHorizontal();
            GUILayout.Space(LEFT_MARGING);
            GUILayout.Label("Name: ");
            GUILayout.EndHorizontal();
            // Action
            GUILayout.BeginHorizontal();
            GUILayout.Space(LEFT_MARGING);
            GUILayout.Label("Action: ");
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUILayout.EndArea();

            // Right column
            GUILayout.BeginArea(_boxRightPos);
            GUILayout.BeginVertical();
            // Name
            GUILayout.BeginHorizontal();
            _actionTimer.Name = GUILayout.TextField(_actionTimer.Name, _actionTimer.TimerValid ? Utils.TF_STYLE_VALID : Utils.TF_STYLE_INVALID);
            GUILayout.Space(RIGHT_MARGING);
            GUILayout.EndHorizontal();
            // Action
            GUILayout.BeginHorizontal();
            _actionTimer.TimerAction = (TriggerActionTimer.TimerActionType)_popupUI.GUILayoutPopup("popupTimerAction", Enum.GetNames(typeof(TriggerActionTimer.TimerActionType)), (int)_actionTimer.TimerAction);
            GUILayout.Space(RIGHT_MARGING);
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUILayout.EndArea();
        }