Пример #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);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
 public TriggerActionPart(TriggerActionPart other) : base(other)
 {
     _type = TriggerActionType.Part;
     _part = null;
     // Automatic call of Part_set
     ActionPart = other._part;
     // 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;
 }
Пример #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]);
     }
 }
Пример #4
0
        private void DisplayPartConf()
        {
            if (_actionPart == null)
            {
                _actionPart = new TriggerActionPart(_vesselTriggers);
            }
            _currentAction = _actionPart;
            // Left column
            GUILayout.BeginArea(_boxLeftPos);
            _scrollVectPart = GUILayout.BeginScrollView(_scrollVectPart, GUIStyle.none, GUIStyle.none);
            GUILayout.BeginVertical();
            // Part
            GUILayout.BeginHorizontal();
            GUILayout.Space(LEFT_MARGING);
            GUILayout.Label("Part to act on: ");
            GUILayout.EndHorizontal();
            // Action
            GUILayout.BeginHorizontal();
            GUILayout.Space(LEFT_MARGING);
            GUILayout.Label("Action: ");
            GUILayout.EndHorizontal();
            // Parameters
            if (_actionPart.Parameters != null)
            {
                for (int i = 0; i < _actionPart.Parameters.Length; i++)
                {
                    TypedData param = _actionPart.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);
            _scrollVectPart = GUILayout.BeginScrollView(_scrollVectPart);
            GUILayout.BeginVertical();
            // Part
            GUILayout.BeginHorizontal();
            _partSelector.DisplayLayout(_actionPart.ActionPart);
            GUILayout.Space(RIGHT_MARGING);
            GUILayout.EndHorizontal();
            // Action
            GUILayout.BeginHorizontal();
            int newActionIndex = _popupUI.GUILayoutPopup("popupPartMetho", _actionPart.ActionList, _actionPart.ActionIndex);

            GUILayout.Space(RIGHT_MARGING);
            GUILayout.EndHorizontal();
            // Parameters
            if (_actionPart.Parameters != null)
            {
                for (int i = 0; i < _actionPart.Parameters.Length; i++)
                {
                    TypedData param = _actionPart.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)
            {
                _actionPart.ActionIndex = newActionIndex;
            }
        }