Exemplo n.º 1
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);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 public TriggerActionFlight(TriggerActionFlight other) : base(other)
 {
     _type = TriggerActionType.Flight;
     // Automatic call of ActionIndex_set
     ActionIndex = other._actionIndex;
     if (_methodParameter != null)
     {
         for (int i = 0; i < _methodParameter.Length; i++)
         {
             _methodParameter[i].ValueStr = other._methodParameter[i].ValueStr;
         }
         _methodParameter.Acquit();
     }
     UpdatePersistentData();
     _modified = false;
 }
Exemplo n.º 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]);
     }
 }
Exemplo n.º 4
0
        private void DisplayFlightConf()
        {
            if (_actionFlight == null)
            {
                _actionFlight = new TriggerActionFlight(_vesselTriggers);
            }
            _currentAction = _actionFlight;
            // Left column
            GUILayout.BeginArea(_boxLeftPos);
            _scrollVectVessel = GUILayout.BeginScrollView(_scrollVectVessel, GUIStyle.none, GUIStyle.none);
            GUILayout.BeginVertical();
            // Action
            GUILayout.BeginHorizontal();
            GUILayout.Space(LEFT_MARGING);
            GUILayout.Label("Action: ");
            GUILayout.EndHorizontal();
            // Parameters
            if (_actionFlight.Parameters != null)
            {
                for (int i = 0; i < _actionFlight.Parameters.Length; i++)
                {
                    TypedData param = _actionFlight.Parameters[i];
                    if ((param != null) && param.Configurable)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(LEFT_MARGING);
                        GUILayout.Label(param.Name);
                        GUILayout.EndHorizontal();
                    }
                }
            }
            GUILayout.EndVertical();
            GUILayout.EndScrollView();
            GUILayout.EndArea();

            // Right column
            GUILayout.BeginArea(_boxRightPos);
            _scrollVectVessel = GUILayout.BeginScrollView(_scrollVectVessel);
            GUILayout.BeginVertical();
            // Action
            GUILayout.BeginHorizontal();
            int newActionIndex = _popupUI.GUILayoutPopup("popupFlightMetho", TriggerActionFlight.ActionList, _actionFlight.ActionIndex);

            GUILayout.Space(RIGHT_MARGING);
            GUILayout.EndHorizontal();
            // Parameters
            if (_actionFlight.Parameters != null)
            {
                for (int i = 0; i < _actionFlight.Parameters.Length; i++)
                {
                    TypedData param = _actionFlight.Parameters[i];
                    if ((param != null) && param.Configurable)
                    {
                        GUILayout.BeginHorizontal();
                        param.DisplayLayout(_popupUI);
                        GUILayout.Space(RIGHT_MARGING);
                        GUILayout.EndHorizontal();
                    }
                }
            }
            GUILayout.EndVertical();
            GUILayout.EndScrollView();
            GUILayout.EndArea();

            if (Event.current.type == EventType.Repaint)
            {
                _actionFlight.ActionIndex = newActionIndex;
            }
        }