Exemple #1
0
        public void DoWindow(int windowID)
        {
            if (Event.current.isMouse && (Event.current.button == 0) && (Event.current.type == EventType.MouseUp))
            {
                _popupUI.CloseAll();
            }

            GUILayout.BeginVertical();
            // fake label to get position
            GUILayout.Label(" ");
            if (Event.current.type == EventType.Repaint)
            {
                RectOffset rctOff   = GUI.skin.button.margin;
                Rect       lastRect = GUILayoutUtility.GetLastRect();
                _listRect.y      = lastRect.y;
                _mainRect.y      = lastRect.y;
                _listRect.height = _windowSize.y - 3 * lastRect.y - 3 * rctOff.vertical;
                _mainRect.height = _windowSize.y - 3 * lastRect.y - 3 * rctOff.vertical;
            }

            DisplayLeftPanel();

            if (_conditionIndex >= 0)
            {
                DisplayRightPanel();
            }

            GUILayout.FlexibleSpace();
            // Condition combination
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            _conditions.Combination = (ConditionCombination)_popupUI.GUILayoutPopup("CondCombination", Enum.GetNames(typeof(ConditionCombination)), (int)_conditions.Combination);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            // OK / CANCEL
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("OK")) // TODO
            {
                _triggerToConfigure.TriggerConditions = _conditions;
                Close();
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Cancel"))
            {
                Close();
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUI.DragWindow(new Rect(0, 0, 10000, 10000));

            // Tooltip
            if ((GUI.tooltip != "") && (Event.current.type == EventType.Repaint))
            {
                GUIContent content = new GUIContent(GUI.tooltip);
                GUI.Label(new Rect(Event.current.mousePosition, GUI.skin.box.CalcSize(content)), content);
            }
        }
Exemple #2
0
 public void DisplayLayout(PopupUI popup = null)
 {
     if (_valueDict != null)
     {
         if (popup != null)
         {
             string[] _entry = _valueDict.Keys.ToArray();
             int      index  = Array.IndexOf(_entry, ValueStr);
             int      newVal = popup.GUILayoutPopup(_name + "popup", _entry, index);
             if ((newVal >= 0) && (newVal < _entry.Length))
             {
                 ValueStr = _entry[newVal];
             }
         }
         else
         {
             ValueStr = GUILayout.TextField(ValueStr, IsValid ? Utils.TF_STYLE_VALID : Utils.TF_STYLE_INVALID);
         }
     }
     else if (_type != null)
     {
         if (_type.IsEnum && (popup != null))
         {
             int index  = (_value != null) ? (int)_value : -1;
             int newVal = popup.GUILayoutPopup(_name + "popup", Enum.GetNames(_type), index);
             ValueStr = newVal.ToString();
         }
         else if (_type == typeof(bool))
         {
             // in case of _value == null
             bool val    = (_value != null) && ((bool)_value);
             bool newVal = GUILayout.Toggle(val, val ? "True" : "False");
             ValueStr = newVal.ToString();
         }
         else
         {
             ValueStr = GUILayout.TextField(ValueStr, IsValid ? Utils.TF_STYLE_VALID : Utils.TF_STYLE_INVALID);
         }
     }
 }
Exemple #3
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;
            }
        }
Exemple #4
0
        private void DisplayPartConf()
        {
            if (_eventPart == null)
            {
                _eventPart = new TriggerEvent(TriggerEventType.Part, _vesselTriggers);
            }
            _currentEvent = _eventPart;
            // 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 triggering the event: ");
            GUILayout.EndHorizontal();
            // Property
            GUILayout.BeginHorizontal();
            GUILayout.Space(LEFT_MARGING);
            GUILayout.Label("Property to trigger: ");
            GUILayout.EndHorizontal();
            // Parameters
            if (((TriggerConditionPart)_eventPart.Condition).Parameters != null)
            {
                for (int i = 0; i < ((TriggerConditionPart)_eventPart.Condition).Parameters.Length; i++)
                {
                    TypedData param = ((TriggerConditionPart)_eventPart.Condition).Parameters[i];
                    if ((param != null) && param.Configurable)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(LEFT_MARGING);
                        GUILayout.Label(param.Name);
                        GUILayout.EndHorizontal();
                    }
                }
            }
            if (((TriggerConditionPart)_eventPart.Condition).TargetValue != null)
            {
                // Comparator
                GUILayout.BeginHorizontal();
                GUILayout.Space(LEFT_MARGING);
                GUILayout.Label("Comparator: ");
                GUILayout.EndHorizontal();
                // Target
                GUILayout.BeginHorizontal();
                GUILayout.Space(LEFT_MARGING);
                GUILayout.Label("Target value: ");
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
            GUILayout.EndScrollView();
            GUILayout.EndArea();

            // Right column
            GUILayout.BeginArea(_boxRightPos);
            _scrollVectPart = GUILayout.BeginScrollView(_scrollVectPart);
            GUILayout.BeginVertical();
            // Part
            GUILayout.BeginHorizontal();
            _partSelector.DisplayLayout(((TriggerConditionPart)_eventPart.Condition).ConditionPart);
            GUILayout.Space(RIGHT_MARGING);
            GUILayout.EndHorizontal();
            // Property
            GUILayout.BeginHorizontal();
            int newPropertyIndex = _popupUI.GUILayoutPopup("popupPartParam", ((TriggerConditionPart)_eventPart.Condition).PropertyList, ((TriggerConditionPart)_eventPart.Condition).PropertyIndex);

            GUILayout.Space(RIGHT_MARGING);
            GUILayout.EndHorizontal();
            // Parameters
            if (((TriggerConditionPart)_eventPart.Condition).Parameters != null)
            {
                for (int i = 0; i < ((TriggerConditionPart)_eventPart.Condition).Parameters.Length; i++)
                {
                    TypedData param = ((TriggerConditionPart)_eventPart.Condition).Parameters[i];
                    if ((param != null) && param.Configurable)
                    {
                        GUILayout.BeginHorizontal();
                        param.DisplayLayout(_popupUI);
                        GUILayout.Space(RIGHT_MARGING);
                        GUILayout.EndHorizontal();
                    }
                }
            }
            if (((TriggerConditionPart)_eventPart.Condition).TargetValue != null)
            {
                TypedData target = ((TriggerConditionPart)_eventPart.Condition).TargetValue;
                // Comparator
                GUILayout.BeginHorizontal();
                ((TriggerConditionPart)_eventPart.Condition).Comparator = (ComparatorType)_popupUI.GUILayoutPopup("popupPartOper", target.ComparatorList, (int)((TriggerConditionPart)_eventPart.Condition).Comparator);
                GUILayout.Space(RIGHT_MARGING);
                GUILayout.EndHorizontal();
                // Target
                GUILayout.BeginHorizontal();
                target.DisplayLayout(_popupUI);
                GUILayout.Space(RIGHT_MARGING);
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
            GUILayout.EndScrollView();
            GUILayout.EndArea();

            if (Event.current.type == EventType.Repaint)
            {
                ((TriggerConditionPart)_eventPart.Condition).PropertyIndex = newPropertyIndex;
            }
        }