Пример #1
0
        private int DoQualityLevelSelection(int currentQualitylevel, IList <QualitySettingsEditor.QualitySetting> qualitySettings, Dictionary <string, int> platformDefaultQualitySettings)
        {
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            int num = currentQualitylevel;

            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            Rect rect = GUILayoutUtility.GetRect(GUIContent.none, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(false),
                GUILayout.Width(80f),
                GUILayout.Height(20f)
            });

            rect.x     += EditorGUI.indent;
            rect.width -= EditorGUI.indent;
            GUI.Label(rect, "Levels", EditorStyles.boldLabel);
            foreach (BuildPlatform current in this.m_ValidPlatforms)
            {
                Rect rect2 = GUILayoutUtility.GetRect(GUIContent.none, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[]
                {
                    GUILayout.MinWidth(15f),
                    GUILayout.MaxWidth(20f),
                    GUILayout.Height(20f)
                });
                GUIContent gUIContent = EditorGUIUtility.TempContent(current.smallIcon);
                gUIContent.tooltip = current.title.text;
                GUI.Label(rect2, gUIContent);
                gUIContent.tooltip = "";
            }
            GUILayoutUtility.GetRect(GUIContent.none, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[]
            {
                GUILayout.MinWidth(15f),
                GUILayout.MaxWidth(20f),
                GUILayout.Height(20f)
            });
            GUILayout.EndHorizontal();
            Event current2 = Event.current;

            for (int i = 0; i < qualitySettings.Count; i++)
            {
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUIStyle gUIStyle = (i % 2 != 0) ? QualitySettingsEditor.Styles.kListOddBg : QualitySettingsEditor.Styles.kListEvenBg;
                bool     on       = num == i;
                Rect     rect3    = GUILayoutUtility.GetRect(GUIContent.none, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[]
                {
                    GUILayout.ExpandWidth(false),
                    GUILayout.Width(80f)
                });
                switch (current2.type)
                {
                case EventType.MouseDown:
                    if (rect3.Contains(current2.mousePosition))
                    {
                        num = i;
                        GUIUtility.keyboardControl = 0;
                        GUIUtility.hotControl      = this.m_QualityElementHash;
                        GUI.changed     = true;
                        this.m_Dragging = new QualitySettingsEditor.Dragging
                        {
                            m_StartPosition = i,
                            m_Position      = i
                        };
                        current2.Use();
                    }
                    break;

                case EventType.MouseUp:
                    if (GUIUtility.hotControl == this.m_QualityElementHash)
                    {
                        GUIUtility.hotControl = 0;
                        current2.Use();
                    }
                    break;

                case EventType.MouseDrag:
                    if (GUIUtility.hotControl == this.m_QualityElementHash)
                    {
                        if (rect3.Contains(current2.mousePosition))
                        {
                            this.m_Dragging.m_Position = i;
                            current2.Use();
                        }
                    }
                    break;

                case EventType.KeyDown:
                    if (current2.keyCode == KeyCode.UpArrow || current2.keyCode == KeyCode.DownArrow)
                    {
                        num += ((current2.keyCode != KeyCode.UpArrow) ? 1 : -1);
                        num  = Mathf.Clamp(num, 0, qualitySettings.Count - 1);
                        GUIUtility.keyboardControl = 0;
                        GUI.changed = true;
                        current2.Use();
                    }
                    break;

                case EventType.Repaint:
                    gUIStyle.Draw(rect3, GUIContent.none, false, false, on, false);
                    GUI.Label(rect3, EditorGUIUtility.TempContent(qualitySettings[i].m_Name));
                    break;
                }
                foreach (BuildPlatform current3 in this.m_ValidPlatforms)
                {
                    bool flag = false;
                    if (platformDefaultQualitySettings.ContainsKey(current3.name) && platformDefaultQualitySettings[current3.name] == i)
                    {
                        flag = true;
                    }
                    Rect rect4 = GUILayoutUtility.GetRect(QualitySettingsEditor.Styles.kPlatformTooltip, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[]
                    {
                        GUILayout.MinWidth(15f),
                        GUILayout.MaxWidth(20f)
                    });
                    if (Event.current.type == EventType.Repaint)
                    {
                        gUIStyle.Draw(rect4, GUIContent.none, false, false, on, false);
                    }
                    Color backgroundColor = GUI.backgroundColor;
                    if (flag && !EditorApplication.isPlayingOrWillChangePlaymode)
                    {
                        GUI.backgroundColor = Color.green;
                    }
                    bool flag2 = !qualitySettings[i].m_ExcludedPlatforms.Contains(current3.name);
                    bool flag3 = GUI.Toggle(rect4, flag2, QualitySettingsEditor.Styles.kPlatformTooltip, (!flag) ? QualitySettingsEditor.Styles.kToggle : QualitySettingsEditor.Styles.kDefaultToggle);
                    if (flag2 != flag3)
                    {
                        if (flag3)
                        {
                            qualitySettings[i].m_ExcludedPlatforms.Remove(current3.name);
                        }
                        else
                        {
                            qualitySettings[i].m_ExcludedPlatforms.Add(current3.name);
                        }
                    }
                    GUI.backgroundColor = backgroundColor;
                }
                Rect rect5 = GUILayoutUtility.GetRect(GUIContent.none, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[]
                {
                    GUILayout.MinWidth(15f),
                    GUILayout.MaxWidth(20f)
                });
                if (Event.current.type == EventType.Repaint)
                {
                    gUIStyle.Draw(rect5, GUIContent.none, false, false, on, false);
                }
                if (GUI.Button(rect5, QualitySettingsEditor.Styles.kIconTrash, GUIStyle.none))
                {
                    this.m_DeleteLevel = i;
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayoutUtility.GetRect(GUIContent.none, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[]
            {
                GUILayout.MinWidth(15f),
                GUILayout.MaxWidth(20f),
                GUILayout.Height(1f)
            });
            QualitySettingsEditor.DrawHorizontalDivider();
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            Rect rect6 = GUILayoutUtility.GetRect(GUIContent.none, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(false),
                GUILayout.Width(80f),
                GUILayout.Height(20f)
            });

            rect6.x     += EditorGUI.indent;
            rect6.width -= EditorGUI.indent;
            GUI.Label(rect6, "Default", EditorStyles.boldLabel);
            foreach (BuildPlatform current4 in this.m_ValidPlatforms)
            {
                Rect rect7 = GUILayoutUtility.GetRect(GUIContent.none, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[]
                {
                    GUILayout.MinWidth(15f),
                    GUILayout.MaxWidth(20f),
                    GUILayout.Height(20f)
                });
                int num2;
                if (!platformDefaultQualitySettings.TryGetValue(current4.name, out num2))
                {
                    platformDefaultQualitySettings.Add(current4.name, 0);
                }
                num2 = EditorGUI.Popup(rect7, num2, (from x in qualitySettings
                                                     select x.m_Name).ToArray <string>(), QualitySettingsEditor.Styles.kDefaultDropdown);
                platformDefaultQualitySettings[current4.name] = num2;
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(10f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayoutUtility.GetRect(GUIContent.none, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[]
            {
                GUILayout.MinWidth(15f),
                GUILayout.MaxWidth(20f),
                GUILayout.Height(20f)
            });
            Rect rect8 = GUILayoutUtility.GetRect(QualitySettingsEditor.Styles.kAddQualityLevel, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(true)
            });

            if (GUI.Button(rect8, QualitySettingsEditor.Styles.kAddQualityLevel))
            {
                this.m_ShouldAddNewLevel = true;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            return(num);
        }
        private int DoQualityLevelSelection(int currentQualitylevel, IList <QualitySettingsEditor.QualitySetting> qualitySettings, Dictionary <string, int> platformDefaultQualitySettings)
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.BeginVertical();
            int num = currentQualitylevel;

            GUILayout.BeginHorizontal();
            Rect rect1 = GUILayoutUtility.GetRect(GUIContent.none, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[3] {
                GUILayout.ExpandWidth(false), GUILayout.Width(80f), GUILayout.Height(20f)
            });

            rect1.x     += EditorGUI.indent;
            rect1.width -= EditorGUI.indent;
            GUI.Label(rect1, "Levels", EditorStyles.boldLabel);
            using (List <BuildPlayerWindow.BuildPlatform> .Enumerator enumerator = this.m_ValidPlatforms.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    BuildPlayerWindow.BuildPlatform current = enumerator.Current;
                    Rect rect2 = GUILayoutUtility.GetRect(GUIContent.none, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[3] {
                        GUILayout.MinWidth(15f), GUILayout.MaxWidth(20f), GUILayout.Height(20f)
                    });
                    GUIContent content = EditorGUIUtility.TempContent((Texture)current.smallIcon);
                    content.tooltip = current.name;
                    GUI.Label(rect2, content);
                    content.tooltip = string.Empty;
                }
            }
            GUILayoutUtility.GetRect(GUIContent.none, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[3]
            {
                GUILayout.MinWidth(15f),
                GUILayout.MaxWidth(20f),
                GUILayout.Height(20f)
            });
            GUILayout.EndHorizontal();
            Event current1 = Event.current;

            for (int index = 0; index < qualitySettings.Count; ++index)
            {
                GUILayout.BeginHorizontal();
                GUIStyle guiStyle = index % 2 != 0 ? QualitySettingsEditor.Styles.kListOddBg : QualitySettingsEditor.Styles.kListEvenBg;
                bool     on       = num == index;
                Rect     rect2    = GUILayoutUtility.GetRect(GUIContent.none, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[2] {
                    GUILayout.ExpandWidth(false), GUILayout.Width(80f)
                });
                switch (current1.type)
                {
                case EventType.MouseDown:
                    if (rect2.Contains(current1.mousePosition))
                    {
                        num = index;
                        GUIUtility.keyboardControl = 0;
                        GUIUtility.hotControl      = this.m_QualityElementHash;
                        this.m_Dragging            = new QualitySettingsEditor.Dragging()
                        {
                            m_StartPosition = index,
                            m_Position      = index
                        };
                        current1.Use();
                        break;
                    }
                    break;

                case EventType.MouseUp:
                    if (GUIUtility.hotControl == this.m_QualityElementHash)
                    {
                        GUIUtility.hotControl = 0;
                        current1.Use();
                        break;
                    }
                    break;

                case EventType.MouseDrag:
                    if (GUIUtility.hotControl == this.m_QualityElementHash && rect2.Contains(current1.mousePosition))
                    {
                        this.m_Dragging.m_Position = index;
                        current1.Use();
                        break;
                    }
                    break;

                case EventType.KeyDown:
                    if (current1.keyCode == KeyCode.UpArrow || current1.keyCode == KeyCode.DownArrow)
                    {
                        num = Mathf.Clamp(num + (current1.keyCode != KeyCode.UpArrow ? 1 : -1), 0, qualitySettings.Count - 1);
                        GUIUtility.keyboardControl = 0;
                        current1.Use();
                        break;
                    }
                    break;

                case EventType.Repaint:
                    guiStyle.Draw(rect2, GUIContent.none, false, false, on, false);
                    GUI.Label(rect2, EditorGUIUtility.TempContent(qualitySettings[index].m_Name));
                    break;
                }
                using (List <BuildPlayerWindow.BuildPlatform> .Enumerator enumerator = this.m_ValidPlatforms.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        BuildPlayerWindow.BuildPlatform current2 = enumerator.Current;
                        bool flag1 = false;
                        if (platformDefaultQualitySettings.ContainsKey(current2.name) && platformDefaultQualitySettings[current2.name] == index)
                        {
                            flag1 = true;
                        }
                        Rect rect3 = GUILayoutUtility.GetRect(QualitySettingsEditor.Styles.kPlatformTooltip, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[2] {
                            GUILayout.MinWidth(15f), GUILayout.MaxWidth(20f)
                        });
                        if (Event.current.type == EventType.Repaint)
                        {
                            guiStyle.Draw(rect3, GUIContent.none, false, false, on, false);
                        }
                        Color backgroundColor = GUI.backgroundColor;
                        if (flag1 && !EditorApplication.isPlayingOrWillChangePlaymode)
                        {
                            GUI.backgroundColor = Color.green;
                        }
                        bool flag2 = !qualitySettings[index].m_ExcludedPlatforms.Contains(current2.name);
                        bool flag3 = GUI.Toggle(rect3, flag2, QualitySettingsEditor.Styles.kPlatformTooltip, !flag1 ? QualitySettingsEditor.Styles.kToggle : QualitySettingsEditor.Styles.kDefaultToggle);
                        if (flag2 != flag3)
                        {
                            if (flag3)
                            {
                                qualitySettings[index].m_ExcludedPlatforms.Remove(current2.name);
                            }
                            else
                            {
                                qualitySettings[index].m_ExcludedPlatforms.Add(current2.name);
                            }
                        }
                        GUI.backgroundColor = backgroundColor;
                    }
                }
                Rect rect4 = GUILayoutUtility.GetRect(GUIContent.none, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[2] {
                    GUILayout.MinWidth(15f), GUILayout.MaxWidth(20f)
                });
                if (Event.current.type == EventType.Repaint)
                {
                    guiStyle.Draw(rect4, GUIContent.none, false, false, on, false);
                }
                if (GUI.Button(rect4, QualitySettingsEditor.Styles.kIconTrash, GUIStyle.none))
                {
                    this.m_DeleteLevel = index;
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.BeginHorizontal();
            GUILayoutUtility.GetRect(GUIContent.none, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[3]
            {
                GUILayout.MinWidth(15f),
                GUILayout.MaxWidth(20f),
                GUILayout.Height(1f)
            });
            QualitySettingsEditor.DrawHorizontalDivider();
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            Rect rect5 = GUILayoutUtility.GetRect(GUIContent.none, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[3] {
                GUILayout.ExpandWidth(false), GUILayout.Width(80f), GUILayout.Height(20f)
            });

            rect5.x     += EditorGUI.indent;
            rect5.width -= EditorGUI.indent;
            GUI.Label(rect5, "Default", EditorStyles.boldLabel);
            using (List <BuildPlayerWindow.BuildPlatform> .Enumerator enumerator = this.m_ValidPlatforms.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    BuildPlayerWindow.BuildPlatform current2 = enumerator.Current;
                    Rect rect2 = GUILayoutUtility.GetRect(GUIContent.none, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[3] {
                        GUILayout.MinWidth(15f), GUILayout.MaxWidth(20f), GUILayout.Height(20f)
                    });
                    int selectedIndex;
                    if (!platformDefaultQualitySettings.TryGetValue(current2.name, out selectedIndex))
                    {
                        platformDefaultQualitySettings.Add(current2.name, 0);
                    }
                    selectedIndex = EditorGUI.Popup(rect2, selectedIndex, qualitySettings.Select <QualitySettingsEditor.QualitySetting, string>((Func <QualitySettingsEditor.QualitySetting, string>)(x => x.m_Name)).ToArray <string>(), QualitySettingsEditor.Styles.kDefaultDropdown);
                    platformDefaultQualitySettings[current2.name] = selectedIndex;
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(10f);
            GUILayout.BeginHorizontal();
            GUILayoutUtility.GetRect(GUIContent.none, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[3]
            {
                GUILayout.MinWidth(15f),
                GUILayout.MaxWidth(20f),
                GUILayout.Height(20f)
            });
            if (GUI.Button(GUILayoutUtility.GetRect(GUIContent.none, QualitySettingsEditor.Styles.kToggle, new GUILayoutOption[1] {
                GUILayout.ExpandWidth(true)
            }), EditorGUIUtility.TempContent("Add Quality Level")))
            {
                this.m_ShouldAddNewLevel = true;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            return(num);
        }