예제 #1
0
 private void DisplayLeftPanel()
 {
     // Left panel: action list
     GUILayout.BeginArea(_listRect);
     _scrollVectAction = GUILayout.BeginScrollView(_scrollVectAction, false, true);
     GUILayout.BeginVertical();
     for (int i = 0; i < _actions.Count; i++)
     {
         string   tooltip;
         GUIStyle style;
         // Button to select action
         if ((i == _actionIndex) && (_currentAction != null) &&
             (_currentAction.Modified || (_currentAction.GetType() != _actions[i].GetType())))
         {
             tooltip = "Don't forget to apply";
             style   = Utils.BUTTON_STYLE_PENDING;
         }
         else
         {
             if ((_actions[i] == null) || !_actions[i].IsValid())
             {
                 tooltip = "To be configured";
                 style   = Utils.BUTTON_STYLE_INVALID;
             }
             else
             {
                 tooltip = _actions[i].ToString();
                 style   = Utils.BUTTON_STYLE_VALID;
             }
         }
         if (GUILayout.Button(new GUIContent(i.ToString(), tooltip), style))
         {
             if (_actionIndex != i)
             {
                 _partSelector.CancelSelect();
                 SelectAction(i);
             }
         }
     }
     if (GUILayout.Button(new GUIContent("+", "Add new action")))
     {
         _actions.Add(null);
         SelectAction(_actions.Count - 1);
     }
     GUILayout.EndVertical();
     GUILayout.EndScrollView();
     GUILayout.EndArea();
 }
예제 #2
0
        public void DoWindow(int windowID)
        {
            if (Event.current.isMouse && (Event.current.button == 0) && (Event.current.type == EventType.MouseUp))
            {
                _popupUI.CloseAll();
            }
            GUILayout.BeginVertical();
            int newIndexEvent = GUILayout.Toolbar(_eventIndexType, Enum.GetNames(typeof(TriggerEventType)));

            if (newIndexEvent != _eventIndexType)
            {
                _partSelector.CancelSelect();
                _eventIndexType = newIndexEvent;
            }
            if (Event.current.type == EventType.Repaint)
            {
                RectOffset rctOff   = GUI.skin.button.margin;
                Rect       lastRect = GUILayoutUtility.GetLastRect();
                float      nextY    = lastRect.y + lastRect.height + rctOff.bottom;
                // position of area computed using Toolbar position
                _boxLeftPos = new Rect(rctOff.left,
                                       nextY + rctOff.top,
                                       _windowSize.x / 2 - rctOff.horizontal,
                                       _windowSize.y - (2 * nextY + rctOff.vertical));
                _boxRightPos = new Rect(_windowSize.x / 2 + rctOff.left,
                                        nextY + rctOff.top,
                                        _windowSize.x / 2 - rctOff.horizontal,
                                        _windowSize.y - (2 * nextY + rctOff.vertical));
            }
            switch ((TriggerEventType)_eventIndexType)
            {
            case TriggerEventType.Part:
                DisplayPartConf();
                break;

            case TriggerEventType.Flight:
                DisplayFlightConf();
                break;

            case TriggerEventType.Timer:
                DisplayTimerConf();
                break;
            }
            GUILayout.FlexibleSpace();
            // OK / CANCEL
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("OK") && (_currentEvent != null))
            {
                if (_currentEvent.IsValid())
                {
                    _currentEvent.UpdatePersistentData();
                    _triggerToConfigure.TriggerEvent = _currentEvent;
                    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);
            }
        }