예제 #1
0
 private void SelectCondition(int conditionIndex)
 {
     _conditionIndex = conditionIndex;
     _partSelector.CancelSelect();
     _popupUI.CloseAll();
     _conditionPart    = null;
     _conditionFlight  = null;
     _conditionTimer   = null;
     _currentCondition = null;
     if ((_conditionIndex < 0) || (_conditionIndex >= _conditions.Count))
     {
         return;
     }
     if (_conditions[_conditionIndex] == null)
     {
         _conditionIndexType = (int)TriggerConditionType.Flight;
     }
     else if (_conditions[_conditionIndex] is TriggerConditionPart)
     {
         _conditionIndexType = (int)TriggerConditionType.Part;
         _conditionPart      = new TriggerConditionPart((TriggerConditionPart)_conditions[_conditionIndex]);
     }
     else if (_conditions[_conditionIndex] is TriggerConditionFlight)
     {
         _conditionIndexType = (int)TriggerConditionType.Flight;
         _conditionFlight    = new TriggerConditionFlight((TriggerConditionFlight)_conditions[_conditionIndex]);
     }
     else if (_conditions[_conditionIndex] is TriggerConditionTimer)
     {
         _conditionIndexType = (int)TriggerConditionType.Timer;
         _conditionTimer     = new TriggerConditionTimer((TriggerConditionTimer)_conditions[_conditionIndex]);
     }
 }
예제 #2
0
 public TriggerConditionTimer(TriggerConditionTimer other) : base(other)
 {
     _type  = TriggerConditionType.Timer;
     _timer = null;
     // Automatic call of Name_set
     Name = other.Name;
     _targetDate.ValueStr = other._targetDate.ValueStr;
     UpdatePersistentData();
 }
예제 #3
0
        public void OnLoad(ConfigNode node, VesselTriggers triggerConfig)
        {
            bool                 dataFound     = false;
            ConfigNode           childNode     = null;
            int                  nbItem        = 0;
            TriggerConditionType conditionType = (TriggerConditionType)(-1);

            dataFound = node.TryGetValue(KEY_NB_CONDITIONS, ref nbItem);
            if (dataFound)
            {
                for (int i = 0; i < nbItem; i++)
                {
                    TriggerCondition condition = null;
                    dataFound = node.TryGetNode(KEY_PREF_CONDITION + i, ref childNode);
                    if (dataFound)
                    {
                        dataFound = childNode.TryGetEnum <TriggerConditionType>("type", ref conditionType, (TriggerConditionType)(-1));
                        if (dataFound)
                        {
                            switch (conditionType)
                            {
                            case TriggerConditionType.Part:
                                condition = new TriggerConditionPart(triggerConfig);
                                break;

                            case TriggerConditionType.Flight:
                                condition = new TriggerConditionFlight(triggerConfig);
                                break;

                            case TriggerConditionType.Timer:
                                condition = new TriggerConditionTimer(triggerConfig);
                                break;

                            default:
                                break;
                            }
                            if (condition != null)
                            {
                                dataFound = ConfigNode.LoadObjectFromConfig(condition, childNode);
                                if (dataFound)
                                {
                                    _conditions.Add(condition);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #4
0
        private void DisplayTimerConf()
        {
            if (_conditionTimer == null)
            {
                _conditionTimer = new TriggerConditionTimer(_vesselTriggers);
            }
            _currentCondition = _conditionTimer;
            // Left column
            GUILayout.BeginArea(_boxLeftPos);
            GUILayout.BeginVertical();
            // Name
            GUILayout.BeginHorizontal();
            GUILayout.Space(LEFT_MARGING);
            GUILayout.Label("Name: ");
            GUILayout.EndHorizontal();
            // TargetDate
            GUILayout.BeginHorizontal();
            GUILayout.Space(LEFT_MARGING);
            GUILayout.Label("Date reached: ");
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUILayout.EndArea();

            // Right column
            GUILayout.BeginArea(_boxRightPos);
            GUILayout.BeginVertical();
            // Name
            GUILayout.BeginHorizontal();
            _conditionTimer.Name = GUILayout.TextField(_conditionTimer.Name, _conditionTimer.TimerValid ? Utils.TF_STYLE_VALID : Utils.TF_STYLE_INVALID);
            GUILayout.Space(RIGHT_MARGING);
            GUILayout.EndHorizontal();
            // TargetDate / InitDate
            GUILayout.BeginHorizontal();
            _conditionTimer.TargetDate.DisplayLayout(_popupUI);
            GUILayout.Space(RIGHT_MARGING);
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUILayout.EndArea();
        }