Пример #1
0
    public static DropdownState Dropdown(Rect position, string[] options, DropdownState state, DropdownStyles styles = null)
    {
        setup();

        if (styles == null)
        {
            styles = defaultDropdownStyles_;
        }

        switch (state.currentStatus)
        {
        case DropdownState.status.Closed:
            return(closedDropdown(position, options, state, styles));

        case DropdownState.status.Opening:
            return(openingDropdown(position, options, state, styles));

        case DropdownState.status.Opened:
            return(openedDropdown(position, options, state, styles));

        case DropdownState.status.Closing:
            return(closingDropdown(position, options, state, styles));
        }

        return(state);
    }
Пример #2
0
        private DropdownState DropdownStateSelection(DropdownState value, bool isEnemy = false, bool showIdle = false)
        {
            using (new GUILayout.HorizontalScope())
            {
                DropdownState result = value;

                Button(Local["Menu_Btn_None"], DropdownState.None);
                Button(Local["Menu_Btn_Never"], DropdownState.Never);
                Button(Local[!isEnemy ? "Menu_Btn_InteractionPlayer" : "Menu_Btn_InteractionEnemy"], DropdownState.Interaction);
                Button(Local["Menu_Btn_ForcedShow"], DropdownState.ForcedShow);
                Button(Local["Menu_Btn_OnPause"], DropdownState.OnPause);
                Button(Local["Menu_Btn_Always"], DropdownState.Always);
                if (showIdle)
                {
                    Button(Local["Menu_Btn_Idleness"], DropdownState.Idleness);
                }

                void Button(string text, DropdownState state)
                {
                    if (GUILayout.Button(text, value == state ? _downButtonStyle : _buttonStyle, GUILayout.ExpandWidth(false)))
                    {
                        result = state;
                    }
                }

                return(result);
            }
        }
Пример #3
0
    static int drawDropdownList(Rect position, string[] options, DropdownState state, DropdownStyles styles)
    {
        int newSelect = -1;

        float offsetY           = position.yMax;
        float totalOptionHeight = position.height * options.Length;

        if (offsetY + totalOptionHeight > Screen.height)
        {
            offsetY = position.yMin - totalOptionHeight;
        }

        for (int i = 0; i < options.Length; i++)
        {
            var optionPosition = position;
            optionPosition.y = offsetY + position.height * i;
            string text = string.Format("{0}{1}", i == state.Select ? " ✓ " : "   ", options[i]);
            if (GUI.Button(optionPosition, text, styles.Option))
            {
                newSelect = i;
            }
        }

        return(newSelect);
    }
Пример #4
0
        /// <summary>
        /// Raises the MouseDown event.
        /// </summary>
        /// <param name="e">A MouseEventArgs that contains the event data.</param>
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            SetFlag(Mouse_Up, false);
            SetFlag(Mouse_Down, true);

            if (GetFlag(Disabled))
            {
                _dropdownState = DropdownState.Disabled;
                Invalidate();
                return;
            }

            if (e.Button == MouseButtons.Left)
            {
                if (_buttonRectangle.Contains(this.PointToClient(Cursor.Position)))
                {
                    SetFlag(NonButtonArea, false);
                    _dropdownState = DropdownState.Pressed;
                    Invalidate();
                }
                else
                {
                    SetFlag(NonButtonArea, true);
                    _dropdownState = DropdownState.Default;
                    Invalidate();
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Raises the MouseLeave event.
        /// </summary>
        /// <param name="e">A MouseEventArgs that contains the event data.</param>
        protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);

            SetFlag(Mouse_Enter, false);
            SetFlag(Mouse_Leave, true);

            if (GetFlag(Show_Popup))
            {// pop up is open
                _dropdownState = DropdownState.Pressed;
                Invalidate();
            }
            else
            {// pop up is closed
                if (GetFlag(Have_Focus))
                {
                    _dropdownState = DropdownState.Default;
                    Invalidate();
                }
                else
                {// lost focus
                    _dropdownState = DropdownState.Normal;
                    Invalidate();
                }
            }
        }
Пример #6
0
 public DisableCombatText()
 {
     ShowAvoidOnCombatText = SettingsRoot.Instance.ShowAvoidOnCombatText.CurrentState;
     ShowMissOnCombatText  = SettingsRoot.Instance.ShowMissOnCombatText.CurrentState;
     ShowAttackOfOpportunityOnCombatText = SettingsRoot.Instance.ShowAttackOfOpportunityOnCombatText.CurrentState;
     ShowCriticalHitOnCombatText         = SettingsRoot.Instance.ShowCriticalHitOnCombatText.CurrentState;
     ShowSneakAttackOnCombatText         = SettingsRoot.Instance.ShowSneakAttackOnCombatText.CurrentState;
     ShowDamageOnCombatText = SettingsRoot.Instance.ShowDamageOnCombatText.CurrentState;
     ShowSavesInCombatText  = SettingsRoot.Instance.ShowSavesInCombatText.CurrentState;
     ShowPartyActions       = SettingsRoot.Instance.ShowPartyActions.CurrentState;
     ShowEnemyActions       = SettingsRoot.Instance.ShowEnemyActions.CurrentState;
     ShowPartyHP            = SettingsRoot.Instance.ShowPartyHP.CurrentState;
     ShowEnemyHP            = SettingsRoot.Instance.ShowEnemyHP.CurrentState;
     SettingsRoot.Instance.ShowAvoidOnCombatText.CurrentState = DropdownState.None;
     SettingsRoot.Instance.ShowMissOnCombatText.CurrentState  = DropdownState.None;
     SettingsRoot.Instance.ShowAttackOfOpportunityOnCombatText.CurrentState = DropdownState.None;
     SettingsRoot.Instance.ShowCriticalHitOnCombatText.CurrentState         = DropdownState.None;
     SettingsRoot.Instance.ShowSneakAttackOnCombatText.CurrentState         = DropdownState.None;
     SettingsRoot.Instance.ShowDamageOnCombatText.CurrentState = DropdownState.None;
     SettingsRoot.Instance.ShowSavesInCombatText.CurrentState  = DropdownState.None;
     SettingsRoot.Instance.ShowPartyActions.CurrentState       = DropdownState.None;
     SettingsRoot.Instance.ShowEnemyActions.CurrentState       = DropdownState.None;
     SettingsRoot.Instance.ShowPartyHP.CurrentState            = DropdownState.None;
     SettingsRoot.Instance.ShowEnemyHP.CurrentState            = DropdownState.None;
 }
Пример #7
0
 static DropdownState closedDropdown(Rect position, string[] options, DropdownState state, DropdownStyles styles)
 {
     if (drawCaption(position, options, state, styles))
     {
         state.currentStatus = DropdownState.status.Opening;
     }
     return(state);
 }
Пример #8
0
        private void ControlLostFocus(object sender, EventArgs e)
        {
            SetFlag(Have_Focus, false);

            if (!GetFlag(Show_Popup) && GetFlag(Mouse_Leave))
            {
                _dropdownState = DropdownState.Normal;
                Invalidate();
            }
        }
Пример #9
0
        private static void DrawBackground(Graphics g, Rectangle bounds, DropdownState state, Color background)
        {
            Color c = background;

            if (state != DropdownState.Disabled)
            {
                g.FillRectangle(new SolidBrush(c), bounds);
            }
            else
            {
                g.FillRectangle(SystemBrushes.ControlLight, bounds);
            }
        }
Пример #10
0
        private static void DrawHighlight(Graphics g, Rectangle bounds, DropdownState state)
        {
            switch (state)
            {
            case DropdownState.Hot:
                g.FillRectangle(new SolidBrush(_FocusBackGroundColor), bounds);
                break;

            case DropdownState.Pressed:
                g.FillRectangle(new SolidBrush(_FocusPressedColor), bounds);
                break;
            }
        }
Пример #11
0
        /// <summary>
        /// Raises the MouseEnter event.
        /// </summary>
        /// <param name="e">A MouseEventArgs that contains the event data.</param>
        protected override void OnMouseEnter(EventArgs e)
        {
            base.OnMouseEnter(e);
            SetFlag(Mouse_Leave, false);

            if (GetFlag(Show_Popup))
            {
                return;
            }

            SetFlag(Popup_Shown, false);
            SetFlag(Mouse_Enter, true);
            _dropdownState = DropdownState.Hot;
            Invalidate();
        }
Пример #12
0
    static DropdownState openedDropdown(Rect position, string[] options, DropdownState state, DropdownStyles styles)
    {
        if (drawCaption(position, options, state, styles))
        {
            state.currentStatus = DropdownState.status.Closing;
        }
        int newSelect = drawDropdownList(position, options, state, styles);

        if (newSelect >= 0)
        {
            state.nextSelect    = newSelect;
            state.currentStatus = DropdownState.status.Closing;
        }
        return(state);
    }
Пример #13
0
        /// <summary>
        /// Raises the MouseMove event.
        /// </summary>
        /// <param name="e">A MouseEventArgs that contains the event data.</param>
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (GetFlag(Show_Popup))
            {
                return;
            }

            if (_buttonRectangle.Contains(this.PointToClient(Cursor.Position)))
            {// button area of control
                if (_dropdownState != DropdownState.Hot)
                {
                    _dropdownState = DropdownState.Hot;
                    Invalidate();
                }
            }
        }
Пример #14
0
        /// <summary>
        /// Raises the MouseUp event.
        /// </summary>
        /// <param name="e">A MouseEventArgs that contains the event data.</param>
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            SetFlag(Mouse_Down, false);
            SetFlag(Mouse_Up, true);

            if (!GetFlag(Have_Focus))
            {
                _dropdownState = DropdownState.Normal;
                Invalidate();
                return;
            }

            if (GetFlag(Mouse_Up) && GetFlag(Mouse_Enter) && GetFlag(Popup_Shown))
            {
                SetFlag(Popup_Shown, false);
                return;
            }

            if (GetFlag(Popup_Shown))
            {
                SetFlag(Popup_Shown, false);
                if (!GetFlag(Mouse_Enter))
                {
                    return;
                }
            }

            if (!GetFlag(Show_Popup) && !GetFlag(NonButtonArea))
            {
                _dropdownState = DropdownState.Pressed;
                Invalidate();
                OpenPopupWindow();
                AnimateDropdownControl();
            }
            else
            {
                _dropdownState = DropdownState.Hot;
                Invalidate();
            }
        }
Пример #15
0
        /// <summary>
        /// Initializes a new instance of the Dropdown Control class.
        /// </summary>
        public DropdownControl()
        {
            SetStyle(ControlStyles.ResizeRedraw |
                     ControlStyles.OptimizedDoubleBuffer |
                     ControlStyles.Selectable |
                     ControlStyles.UserMouse |
                     ControlStyles.UserPaint |
                     ControlStyles.AllPaintingInWmPaint,
                     true);

            _dropdownState  = DropdownState.Normal;
            _dockSide       = DockSide.Left;
            _hostControl    = null;
            _showDropShadow = true;

            ControlAdded += ClientControlAdded;
            LostFocus    += ControlLostFocus;
            GotFocus     += ControlGotFocus;
            TextChanged  += ControlTextChanged;
        }
Пример #16
0
    static DropdownState openingDropdown(Rect position, string[] options, DropdownState state, DropdownStyles styles)
    {
        const float fadeTime = 0.1f;

        float dt = Time.time - state.currentStatusStartTime;

        drawCaption(position, options, state, styles);

        var prevColor = GUI.color;

        GUI.color = new Color(1, 1, 1, dt / fadeTime);
        drawDropdownList(position, options, state, styles);
        GUI.color = prevColor;

        if (dt >= fadeTime)
        {
            state.currentStatus = DropdownState.status.Opened;
        }
        return(state);
    }
Пример #17
0
    static bool drawCaption(Rect position, string[] options, DropdownState state, DropdownStyles styles)
    {
        if (0 <= state.Select && state.Select < options.Length)
        {
            state.Caption = options[state.Select];
        }

        // Caption
        bool pushed = GUI.Button(position, state.Caption, styles.Caption);

        // Arrow
        var arrowPosition = new Rect(
            position.xMax - styles.ArrowMargin - styles.ArrowSize,
            position.center.y - styles.ArrowSize / 2,
            styles.ArrowSize, styles.ArrowSize);
        var prevColor = GUI.color;

        GUI.color = styles.ArrowColor;
        GUI.DrawTexture(arrowPosition, arrowTexture_);
        GUI.color = prevColor;

        return(pushed);
    }
Пример #18
0
        /// <summary>
        /// Draws a button with a chevron
        /// </summary>
        /// <param name="c">DropdownControl instance.</param>
        /// <param name="g">The graphics used to draw the button.</param>
        /// <param name="state">On of the DropdownState values that specifies the visual state of the button.</param>
        public static void DrawDropDownButton(DropdownControl c, Graphics g, DropdownState state)
        {
            Rectangle r = ButtonBounds(c.ClientRectangle, c.ButtonSide);

            r = new Rectangle(r.X, r.Y, r.Width - 1, r.Height - 1);
            DrawHighlight(g, r, state);

            // x,y offset to center image chevron on split button
            int XPos = ((r.Width / 2) - (_Chevron1.Width / 2));
            int YPos = (r.Height / 2) - (_Chevron1.Height / 2);

            switch (state)
            {
            case DropdownState.Normal:
            case DropdownState.Default:
                g.DrawImage(_Chevron1, r.X + XPos, YPos);
                break;

            case DropdownState.Disabled:
                g.DrawImage(_Chevron3, r.X + XPos, YPos);
                break;

            case DropdownState.Pressed:
                g.DrawImage(_Chevron2, r.X + XPos, YPos);
                g.DrawRectangle(new Pen(_FocusBorderColor), r);
                break;

            case DropdownState.Hot:
                g.DrawImage(_Chevron4, r.X + XPos, YPos);
                using (Pen p = new Pen(_FocusColor))
                {
                    g.DrawRectangle(p, r);
                }
                break;
            }
        }
Пример #19
0
        //
        static public int Dropdown(Rect position, DropdownState state)
        {
            int result = state.selected;

            GUIContent content = state.selected >= 0 && state.selected < state.items.Count ? state.items[state.selected] : GUIContent.none;

            if (GUI.Button(position, content, skin.GetStyle("dropdown")))
            {
                state.expanded = !state.expanded;
            }

            GUI.Label(position, state.expanded ? labelArrowUp : labelArrowDown, skin.GetStyle("dropdownbutton"));

            if (state.expanded)
            {
                GUIStyle verticalScrollbar = GUI.skin.verticalScrollbar;
                Rect     viewRect          = new Rect(0f, 0f, position.width, 0f);
                var      itemStyle         = skin.GetStyle("dropdownitem");
                bool     scrollbar         = false;
                for (int i = 0; i < state.items.Count; i++)
                {
                    viewRect.height += Mathf.Max(itemStyle.CalcHeight(state.items[i], viewRect.width), state.itemMinHeight);
                }
                if (viewRect.height > state.maxHeight)
                {
                    scrollbar = true;

                    // Recalculate viewRect height for new width without scrollbar
                    viewRect.width  = position.width - (verticalScrollbar.fixedWidth + verticalScrollbar.margin.left);
                    viewRect.height = 0f;
                    for (int i = 0; i < state.items.Count; i++)
                    {
                        viewRect.height += Mathf.Max(itemStyle.CalcHeight(state.items[i], viewRect.width), state.itemMinHeight);
                    }
                }

                // float clipWidth = viewRect.width;
                float clipHeight = Mathf.Min(viewRect.height, state.maxHeight);

                Event evt = Event.current;

                Rect scrollRect = new Rect(position.x, position.y + position.height, position.width, clipHeight);

                // Override scroll delta
                if (evt.rawType == EventType.ScrollWheel && scrollRect.Contains(evt.mousePosition))
                {
                    evt.delta = new Vector2(evt.delta.x, ((evt.delta.y > 0f ? 1f : -1f) * state.itemMinHeight) / 20f);
                }

                // Manually draw VerticalScrollbar to fix String.Concat garbage every frame in GUI.VerticalScrollbar
                if (scrollbar)
                {
                    var scrollbarRect = new Rect(scrollRect.x + scrollRect.width - verticalScrollbar.fixedWidth, scrollRect.y, verticalScrollbar.fixedWidth, scrollRect.height);
                    state.scrollPosition.y = GUI.VerticalScrollbar(scrollbarRect, state.scrollPosition.y, clipHeight, 0f, viewRect.height);
                }
                state.scrollPosition = GUI.BeginScrollView(scrollRect, state.scrollPosition, viewRect, GUIStyle.none, GUIStyle.none);

                // Clip y Min Max
                Vector2 clipY = new Vector2(state.scrollPosition.y, state.scrollPosition.y + clipHeight);

                float y = 0f;

                for (int i = 0; i < state.items.Count; i++)
                {
                    GUIContent item = state.items[i];
                    float      h    = Mathf.Max(itemStyle.CalcHeight(item, viewRect.width), state.itemMinHeight);

                    bool selected = i == state.selected;
                    if (DropdownItem(new Rect(0f, y, viewRect.width, h), clipY, item, selected, itemStyle))
                    {
                        result         = i;
                        state.expanded = false;
                    }
                    y += h;
                }

                GUI.EndScrollView(true);

                // Handle click outside of the scrollRect and Escape button
                if ((evt.rawType == EventType.MouseUp && !scrollRect.Contains(evt.mousePosition)) || (evt.rawType == EventType.KeyDown && evt.keyCode == KeyCode.Escape))
                {
                    state.expanded = false;
                }
            }

            return(result);
        }
Пример #20
0
 private void PopupWindowFormClosing(object sender, FormClosingEventArgs e)
 {
     _dropdownState = DropdownState.Default;
     Invalidate();
 }
Пример #21
0
 private void OnPopupWindowStateChange()
 {
     _dropdownState = DropdownState.Default;
     Invalidate();
 }
Пример #22
0
 /// <summary>
 /// Draws a text box with a button to one side.
 /// </summary>
 /// <param name="c">DropdownControl instance.</param>
 /// <param name="g">The Graphics used to draw the control.</param>
 /// <param name="state">One of the DropdownState values that specifies the visual state of the control.</param>
 public static void DrawDropDownControl(DropdownControl c, Graphics g, DropdownState state)
 {
     DrawDropDownControl(c, g, Flags, state);
 }
        public override void OnGUI(Rect window)
#endif
        {
            Event evt = Event.current;
            Rect  horizontalBarRect = new Rect(0, 30, 0, 0);
            Rect  backButtonRect    = new Rect(5, 0, 30, 30);
            Rect  refreshButtonRect = new Rect(window.width - 30 + k_Margin, 0, 30, 30);

            switch (state)
            {
            case DropdownState.None:
                EditorGUILayout.LabelField("Bundle Locations", dropdownTitleStyle);
                EditorGUILayout.Space(10);
                EditorGUI.LabelField(horizontalBarRect, "", new GUIStyle(horizontalBarStyle)
                {
                    fixedWidth = window.width
                });
                //List all options
                foreach (var option in options)
                {
                    option.Draw(() =>
                    {
                        state = option.state;
                        switch (option.state)
                        {
                        case DropdownState.BuiltIn:
                        case DropdownState.EditorHosted:
                            var args       = new DropdownWindowEventArgs();
                            args.GroupType = m_GroupType;
                            args.Option    = option;
                            args.IsCustom  = false;
                            OnValueChanged(args);
                            return;

                        case DropdownState.Custom:
                            var custom       = new DropdownWindowEventArgs();
                            custom.GroupType = m_GroupType;
                            custom.Option    = option;
                            custom.IsCustom  = true;
                            OnValueChanged(custom);
                            return;

                        default:
                            return;
                        }
                    });
                }
                return;

            case DropdownState.CCD:
                switch (CCDState)
                {
                case CCDDropdownState.Bucket:
                    EditorGUI.LabelField(backButtonRect, EditorGUIUtility.IconContent(backIcon));
                    if (evt.type == EventType.MouseDown && backButtonRect.Contains(evt.mousePosition))
                    {
                        state               = DropdownState.None;
                        CCDState            = CCDDropdownState.Bucket;
                        m_WindowRect.height = 120;
                        return;
                    }
#if (ENABLE_CCD && UNITY_2019_4_OR_NEWER)
                    if (CloudProjectSettings.projectId != String.Empty)
                    {
                        EditorGUI.LabelField(refreshButtonRect, EditorGUIUtility.IconContent(refreshIcon));
                        if (evt.type == EventType.MouseDown && refreshButtonRect.Contains(evt.mousePosition) && !m_isRefreshingCCDDataSources)
                        {
                            m_isRefreshingCCDDataSources = true;
                            await ProfileDataSourceSettings.UpdateCCDDataSourcesAsync(CloudProjectSettings.projectId, true);

                            SyncProfileGroupTypes();
                            m_isRefreshingCCDDataSources = false;
                            return;
                        }
                    }
#endif

                    EditorGUILayout.LabelField("Cloud Content Delivery Buckets", dropdownTitleStyle);
                    EditorGUILayout.Space(10);
                    EditorGUI.LabelField(horizontalBarRect, "", new GUIStyle(horizontalBarStyle)
                    {
                        fixedWidth = window.width
                    });

                    if (CloudProjectSettings.projectId == String.Empty)
                    {
                        EditorStyles.helpBox.fontSize = 12;
                        EditorGUILayout.LabelField("Connecting to Cloud Content Delivery requires enabling Cloud Project Settings in the Services Window.", EditorStyles.helpBox);
                    }
                    else
                    {
#if !ENABLE_CCD                 //Used to Display whether or not a user has the CCD Package
                        EditorStyles.helpBox.fontSize = 12;
                        EditorGUILayout.HelpBox("Connecting to Cloud Content Delivery requires the CCD Management SDK Package", MessageType.Warning);
                        var installPackageButton = GUILayout.Button("Install CCD Management SDK Package");
                        if (installPackageButton)
                        {
                            editorWindow.Close();
                            AddressableAssetUtility.InstallCCDPackage();
                        }
#else
                        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandHeight(true));

                        m_WindowRect.height = m_ProfileGroupTypes.Count > 0 ? k_MaxHeight : 80;


                        Dictionary <string, ProfileGroupType> buckets = new Dictionary <string, ProfileGroupType>();
                        m_ProfileGroupTypes.ForEach((groupType) =>
                        {
                            var parts      = groupType.GroupTypePrefix.Split(ProfileGroupType.k_PrefixSeparator);
                            var bucketId   = parts[2];
                            var bucketName = groupType.GetVariableBySuffix($"{nameof(CcdBucket)}{nameof(CcdBucket.Name)}");
                            if (!buckets.ContainsKey(bucketId))
                            {
                                buckets.Add(bucketId, groupType);
                            }
                        });

                        CCDOption.DrawBuckets(buckets,
                                              (KeyValuePair <string, ProfileGroupType> bucket) =>
                        {
                            CCDState   = CCDDropdownState.Badge;
                            m_BucketId = bucket.Key;
                            m_Bucket   = bucket.Value;
                        });
                        EditorGUILayout.EndScrollView();
#endif
                    }
                    break;

#if (ENABLE_CCD && UNITY_2019_4_OR_NEWER)
                case CCDDropdownState.Badge:
                    EditorGUI.LabelField(backButtonRect, EditorGUIUtility.IconContent(backIcon));
                    if (evt.type == EventType.MouseDown && backButtonRect.Contains(evt.mousePosition))
                    {
                        state               = DropdownState.CCD;
                        CCDState            = CCDDropdownState.Bucket;
                        m_WindowRect.height = 120;
                    }
                    EditorGUI.LabelField(refreshButtonRect, EditorGUIUtility.IconContent(refreshIcon));
                    if (evt.type == EventType.MouseDown && refreshButtonRect.Contains(evt.mousePosition) && !m_isRefreshingCCDDataSources)
                    {
                        m_isRefreshingCCDDataSources = true;
                        await ProfileDataSourceSettings.UpdateCCDDataSourcesAsync(CloudProjectSettings.projectId, true);

                        SyncProfileGroupTypes();
                        m_isRefreshingCCDDataSources = false;
                        return;
                    }
                    EditorGUILayout.LabelField(String.Format("{0} Badges", m_Bucket.GetVariableBySuffix($"{nameof(CcdBucket)}{nameof(CcdBucket.Name)}").Value), dropdownTitleStyle);
                    EditorGUILayout.Space(10);
                    EditorGUI.LabelField(horizontalBarRect, "", new GUIStyle(horizontalBarStyle)
                    {
                        fixedWidth = window.width
                    });
                    scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandHeight(true));
                    if (bool.Parse(m_Bucket.GetVariableBySuffix("PromoteOnly").Value))
                    {
                        const string promotionOnlyBucketInfo = "Using Build & Release directly to this bucket is not supported, but you can load content.";
                        EditorStyles.helpBox.fontSize = 11;
                        EditorStyles.helpBox.margin   = new RectOffset(20, 20, 5, 5);
                        EditorGUILayout.HelpBox(promotionOnlyBucketInfo, MessageType.Info);
                    }
                    var selectedProfileGroupTypes = m_ProfileGroupTypes.Where(groupType =>
                                                                              groupType.GroupTypePrefix.StartsWith(
                                                                                  String.Join(
                                                                                      ProfileGroupType.k_PrefixSeparator.ToString(), new string[] { "CCD", CloudProjectSettings.projectId, m_BucketId }
                                                                                      ))).ToList();

                    m_WindowRect.height = m_ProfileGroupTypes.Count > 0 ? k_MaxHeight : 80;

                    HashSet <ProfileGroupType> groupTypes = new HashSet <ProfileGroupType>();
                    selectedProfileGroupTypes.ForEach((groupType) =>
                    {
                        var parts     = groupType.GroupTypePrefix.Split(ProfileGroupType.k_PrefixSeparator);
                        var badgeName = String.Join(ProfileGroupType.k_PrefixSeparator.ToString(), parts, 3, parts.Length - 3);
                        if (!groupTypes.Contains(groupType))
                        {
                            groupTypes.Add(groupType);
                        }
                    });


                    CCDOption.DrawBadges(groupTypes, m_BucketId, (ProfileGroupType groupType) =>
                    {
                        var args              = new DropdownWindowEventArgs();
                        args.GroupType        = m_GroupType;
                        args.Option           = new CCDOption();
                        args.Option.BuildPath = groupType.GetVariableBySuffix("BuildPath").Value;
                        args.Option.LoadPath  = groupType.GetVariableBySuffix("LoadPath").Value;
                        args.IsCustom         = false;
                        OnValueChanged(args);
                        editorWindow.Close();
                    });
                    EditorGUILayout.EndScrollView();
                    break;

                default:
                    CCDState = CCDDropdownState.Bucket;
                    break;
#endif
                }
                break;

            case DropdownState.BuiltIn:
            case DropdownState.EditorHosted:
            default:
                editorWindow.Close();
                break;
            }
        }
Пример #24
0
        private static void DrawDropDownControl(DropdownControl c, Graphics g, TextFormatFlags flags, DropdownState state)
        {
            Rectangle bounds = c.ClientRectangle;

            if (_Chevron1 == null)
            {
                GetChevrons();
            }

            Rectangle r = new Rectangle(bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);

            DrawBackground(g, r, state, c.BackColor);

            if (state != DropdownState.Disabled)
            {
                if (state == DropdownState.Default || state == DropdownState.Pressed)
                {
                    g.DrawRectangle(new Pen(_FocusColor), r);
                }
                else
                {
                    g.DrawRectangle(new Pen(_BorderColor), r);
                }
            }
            else
            {
                g.DrawRectangle(new Pen(_DisabledBoarderColor), r);
            }

            DrawDropDownButton(c, g, state);
            DrawTextArea(g, r, c.ButtonSide);
            DrawText(g, _textBounds, c.Text, c.Font, c.ForeColor);
        }