Beispiel #1
0
 public void Dispose()
 {
     if (m_Disposed)
     {
         return;
     }
     LogEntries.EndGettingEntries();
     m_Disposed = true;
 }
        private void OnGUI()
        {
            Event current = Event.current;

            ConsoleWindow.LoadIcons();
            GUILayout.BeginHorizontal(ConsoleWindow.Constants.Toolbar, new GUILayoutOption[0]);
            if (GUILayout.Button("Clear", ConsoleWindow.Constants.MiniButton, new GUILayoutOption[0]))
            {
                LogEntries.Clear();
                GUIUtility.keyboardControl = 0;
            }
            int count = LogEntries.GetCount();

            if (this.m_ListView.totalRows != count && this.m_ListView.scrollPos.y >= (float)(this.m_ListView.rowHeight * this.m_ListView.totalRows - this.ms_LVHeight))
            {
                this.m_ListView.scrollPos.y = (float)(count * 32 - this.ms_LVHeight);
            }
            EditorGUILayout.Space();
            bool flag = this.HasFlag(ConsoleWindow.ConsoleFlags.Collapse);

            this.SetFlag(ConsoleWindow.ConsoleFlags.Collapse, GUILayout.Toggle(flag, "Collapse", ConsoleWindow.Constants.MiniButtonLeft, new GUILayoutOption[0]));
            bool flag2 = flag != this.HasFlag(ConsoleWindow.ConsoleFlags.Collapse);

            if (flag2)
            {
                this.m_ListView.row         = -1;
                this.m_ListView.scrollPos.y = (float)(LogEntries.GetCount() * 32);
            }
            this.SetFlag(ConsoleWindow.ConsoleFlags.ClearOnPlay, GUILayout.Toggle(this.HasFlag(ConsoleWindow.ConsoleFlags.ClearOnPlay), "Clear on Play", ConsoleWindow.Constants.MiniButtonMiddle, new GUILayoutOption[0]));
            this.SetFlag(ConsoleWindow.ConsoleFlags.ErrorPause, GUILayout.Toggle(this.HasFlag(ConsoleWindow.ConsoleFlags.ErrorPause), "Error Pause", ConsoleWindow.Constants.MiniButtonRight, new GUILayoutOption[0]));
            EditorGUILayout.Space();
            if (this.m_DevBuild)
            {
                GUILayout.FlexibleSpace();
                this.SetFlag(ConsoleWindow.ConsoleFlags.StopForAssert, GUILayout.Toggle(this.HasFlag(ConsoleWindow.ConsoleFlags.StopForAssert), "Stop for Assert", ConsoleWindow.Constants.MiniButtonLeft, new GUILayoutOption[0]));
                this.SetFlag(ConsoleWindow.ConsoleFlags.StopForError, GUILayout.Toggle(this.HasFlag(ConsoleWindow.ConsoleFlags.StopForError), "Stop for Error", ConsoleWindow.Constants.MiniButtonRight, new GUILayoutOption[0]));
            }
            GUILayout.FlexibleSpace();
            int num  = 0;
            int num2 = 0;
            int num3 = 0;

            LogEntries.GetCountsByType(ref num, ref num2, ref num3);
            bool val  = GUILayout.Toggle(this.HasFlag(ConsoleWindow.ConsoleFlags.LogLevelLog), new GUIContent((num3 > 999) ? "999+" : num3.ToString(), (num3 <= 0) ? ConsoleWindow.iconInfoMono : ConsoleWindow.iconInfoSmall), ConsoleWindow.Constants.MiniButtonRight, new GUILayoutOption[0]);
            bool val2 = GUILayout.Toggle(this.HasFlag(ConsoleWindow.ConsoleFlags.LogLevelWarning), new GUIContent((num2 > 999) ? "999+" : num2.ToString(), (num2 <= 0) ? ConsoleWindow.iconWarnMono : ConsoleWindow.iconWarnSmall), ConsoleWindow.Constants.MiniButtonMiddle, new GUILayoutOption[0]);
            bool val3 = GUILayout.Toggle(this.HasFlag(ConsoleWindow.ConsoleFlags.LogLevelError), new GUIContent((num > 999) ? "999+" : num.ToString(), (num <= 0) ? ConsoleWindow.iconErrorMono : ConsoleWindow.iconErrorSmall), ConsoleWindow.Constants.MiniButtonLeft, new GUILayoutOption[0]);

            this.SetFlag(ConsoleWindow.ConsoleFlags.LogLevelLog, val);
            this.SetFlag(ConsoleWindow.ConsoleFlags.LogLevelWarning, val2);
            this.SetFlag(ConsoleWindow.ConsoleFlags.LogLevelError, val3);
            GUILayout.EndHorizontal();
            this.m_ListView.totalRows = LogEntries.StartGettingEntries();
            SplitterGUILayout.BeginVerticalSplit(this.spl, new GUILayoutOption[0]);
            EditorGUIUtility.SetIconSize(new Vector2(32f, 32f));
            GUIContent gUIContent = new GUIContent();
            int        controlID  = GUIUtility.GetControlID(FocusType.Native);

            try
            {
                bool flag3 = false;
                bool flag4 = this.HasFlag(ConsoleWindow.ConsoleFlags.Collapse);
                foreach (ListViewElement listViewElement in ListViewGUI.ListView(this.m_ListView, ConsoleWindow.Constants.Box, new GUILayoutOption[0]))
                {
                    if (current.type == EventType.MouseDown && current.button == 0 && listViewElement.position.Contains(current.mousePosition))
                    {
                        if (current.clickCount == 2)
                        {
                            LogEntries.RowGotDoubleClicked(this.m_ListView.row);
                        }
                        flag3 = true;
                    }
                    if (current.type == EventType.Repaint)
                    {
                        int    mode = 0;
                        string text = null;
                        LogEntries.GetFirstTwoLinesEntryTextAndModeInternal(listViewElement.row, ref mode, ref text);
                        GUIStyle gUIStyle = (listViewElement.row % 2 != 0) ? ConsoleWindow.Constants.EvenBackground : ConsoleWindow.Constants.OddBackground;
                        gUIStyle.Draw(listViewElement.position, false, false, this.m_ListView.row == listViewElement.row, false);
                        gUIContent.text = text;
                        GUIStyle styleForErrorMode = ConsoleWindow.GetStyleForErrorMode(mode);
                        styleForErrorMode.Draw(listViewElement.position, gUIContent, controlID, this.m_ListView.row == listViewElement.row);
                        if (flag4)
                        {
                            Rect position = listViewElement.position;
                            gUIContent.text = LogEntries.GetEntryCount(listViewElement.row).ToString(CultureInfo.InvariantCulture);
                            Vector2 vector = ConsoleWindow.Constants.CountBadge.CalcSize(gUIContent);
                            position.xMin  = position.xMax - vector.x;
                            position.yMin += (position.yMax - position.yMin - vector.y) * 0.5f;
                            position.x    -= 5f;
                            GUI.Label(position, gUIContent, ConsoleWindow.Constants.CountBadge);
                        }
                    }
                }
                if (flag3 && this.m_ListView.scrollPos.y >= (float)(this.m_ListView.rowHeight * this.m_ListView.totalRows - this.ms_LVHeight))
                {
                    this.m_ListView.scrollPos.y = (float)(this.m_ListView.rowHeight * this.m_ListView.totalRows - this.ms_LVHeight - 1);
                }
                if (this.m_ListView.totalRows == 0 || this.m_ListView.row >= this.m_ListView.totalRows || this.m_ListView.row < 0)
                {
                    if (this.m_ActiveText.Length != 0)
                    {
                        this.SetActiveEntry(null);
                    }
                }
                else
                {
                    LogEntry logEntry = new LogEntry();
                    LogEntries.GetEntryInternal(this.m_ListView.row, logEntry);
                    this.SetActiveEntry(logEntry);
                    LogEntries.GetEntryInternal(this.m_ListView.row, logEntry);
                    if (this.m_ListView.selectionChanged || !this.m_ActiveText.Equals(logEntry.condition))
                    {
                        this.SetActiveEntry(logEntry);
                    }
                }
                if (GUIUtility.keyboardControl == this.m_ListView.ID && current.type == EventType.KeyDown && current.keyCode == KeyCode.Return && this.m_ListView.row != 0)
                {
                    LogEntries.RowGotDoubleClicked(this.m_ListView.row);
                    Event.current.Use();
                }
                if (current.type != EventType.Layout && ListViewGUI.ilvState.rectHeight != 1)
                {
                    this.ms_LVHeight = ListViewGUI.ilvState.rectHeight;
                }
            }
            finally
            {
                LogEntries.EndGettingEntries();
                EditorGUIUtility.SetIconSize(Vector2.zero);
            }
            this.m_TextScroll = GUILayout.BeginScrollView(this.m_TextScroll, ConsoleWindow.Constants.Box);
            float minHeight = ConsoleWindow.Constants.MessageStyle.CalcHeight(GUIContent.Temp(this.m_ActiveText), base.position.width);

            EditorGUILayout.SelectableLabel(this.m_ActiveText, ConsoleWindow.Constants.MessageStyle, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(true),
                GUILayout.ExpandHeight(true),
                GUILayout.MinHeight(minHeight)
            });
            GUILayout.EndScrollView();
            SplitterGUILayout.EndVerticalSplit();
            if ((current.type == EventType.ValidateCommand || current.type == EventType.ExecuteCommand) && current.commandName == "Copy" && this.m_ActiveText != string.Empty)
            {
                if (current.type == EventType.ExecuteCommand)
                {
                    EditorGUIUtility.systemCopyBuffer = this.m_ActiveText;
                }
                current.Use();
            }
        }
Beispiel #3
0
        private void OnGUI()
        {
            Event current = Event.current;

            LoadIcons();
            GUILayout.BeginHorizontal(Constants.Toolbar, new GUILayoutOption[0]);
            if (GUILayout.Button("Clear", Constants.MiniButton, new GUILayoutOption[0]))
            {
                LogEntries.Clear();
                GUIUtility.keyboardControl = 0;
            }
            int count = LogEntries.GetCount();

            if ((this.m_ListView.totalRows != count) && (this.m_ListView.scrollPos.y >= ((this.m_ListView.rowHeight * this.m_ListView.totalRows) - this.ms_LVHeight)))
            {
                this.m_ListView.scrollPos.y = (count * 0x20) - this.ms_LVHeight;
            }
            EditorGUILayout.Space();
            bool flag = this.HasFlag(ConsoleFlags.Collapse);

            this.SetFlag(ConsoleFlags.Collapse, GUILayout.Toggle(flag, "Collapse", Constants.MiniButtonLeft, new GUILayoutOption[0]));
            if (flag != this.HasFlag(ConsoleFlags.Collapse))
            {
                this.m_ListView.row         = -1;
                this.m_ListView.scrollPos.y = LogEntries.GetCount() * 0x20;
            }
            this.SetFlag(ConsoleFlags.ClearOnPlay, GUILayout.Toggle(this.HasFlag(ConsoleFlags.ClearOnPlay), "Clear on Play", Constants.MiniButtonMiddle, new GUILayoutOption[0]));
            this.SetFlag(ConsoleFlags.ErrorPause, GUILayout.Toggle(this.HasFlag(ConsoleFlags.ErrorPause), "Error Pause", Constants.MiniButtonRight, new GUILayoutOption[0]));
            EditorGUILayout.Space();
            if (this.m_DevBuild)
            {
                GUILayout.FlexibleSpace();
                this.SetFlag(ConsoleFlags.StopForAssert, GUILayout.Toggle(this.HasFlag(ConsoleFlags.StopForAssert), "Stop for Assert", Constants.MiniButtonLeft, new GUILayoutOption[0]));
                this.SetFlag(ConsoleFlags.StopForError, GUILayout.Toggle(this.HasFlag(ConsoleFlags.StopForError), "Stop for Error", Constants.MiniButtonRight, new GUILayoutOption[0]));
            }
            GUILayout.FlexibleSpace();
            int errorCount   = 0;
            int warningCount = 0;
            int logCount     = 0;

            LogEntries.GetCountsByType(ref errorCount, ref warningCount, ref logCount);
            bool val   = GUILayout.Toggle(this.HasFlag(ConsoleFlags.LogLevelLog), new GUIContent((logCount > 0x3e7) ? "999+" : logCount.ToString(), (logCount <= 0) ? iconInfoMono : iconInfoSmall), Constants.MiniButtonRight, new GUILayoutOption[0]);
            bool flag4 = GUILayout.Toggle(this.HasFlag(ConsoleFlags.LogLevelWarning), new GUIContent((warningCount > 0x3e7) ? "999+" : warningCount.ToString(), (warningCount <= 0) ? iconWarnMono : iconWarnSmall), Constants.MiniButtonMiddle, new GUILayoutOption[0]);
            bool flag5 = GUILayout.Toggle(this.HasFlag(ConsoleFlags.LogLevelError), new GUIContent((errorCount > 0x3e7) ? "999+" : errorCount.ToString(), (errorCount <= 0) ? iconErrorMono : iconErrorSmall), Constants.MiniButtonLeft, new GUILayoutOption[0]);

            this.SetFlag(ConsoleFlags.LogLevelLog, val);
            this.SetFlag(ConsoleFlags.LogLevelWarning, flag4);
            this.SetFlag(ConsoleFlags.LogLevelError, flag5);
            GUILayout.EndHorizontal();
            this.m_ListView.totalRows = LogEntries.StartGettingEntries();
            SplitterGUILayout.BeginVerticalSplit(this.spl, new GUILayoutOption[0]);
            EditorGUIUtility.SetIconSize(new Vector2(32f, 32f));
            GUIContent content   = new GUIContent();
            int        controlID = GUIUtility.GetControlID(FocusType.Native);

            try
            {
                bool        flag6      = false;
                bool        flag7      = this.HasFlag(ConsoleFlags.Collapse);
                IEnumerator enumerator = ListViewGUI.ListView(this.m_ListView, Constants.Box, new GUILayoutOption[0]).GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        ListViewElement element = (ListViewElement)enumerator.Current;
                        if (((current.type == EventType.MouseDown) && (current.button == 0)) && element.position.Contains(current.mousePosition))
                        {
                            if (current.clickCount == 2)
                            {
                                LogEntries.RowGotDoubleClicked(this.m_ListView.row);
                            }
                            flag6 = true;
                        }
                        if (current.type == EventType.Repaint)
                        {
                            int    mask      = 0;
                            string outString = null;
                            LogEntries.GetFirstTwoLinesEntryTextAndModeInternal(element.row, ref mask, ref outString);
                            (((element.row % 2) != 0) ? Constants.EvenBackground : Constants.OddBackground).Draw(element.position, false, false, this.m_ListView.row == element.row, false);
                            content.text = outString;
                            GetStyleForErrorMode(mask).Draw(element.position, content, controlID, this.m_ListView.row == element.row);
                            if (flag7)
                            {
                                Rect position = element.position;
                                content.text = LogEntries.GetEntryCount(element.row).ToString(CultureInfo.InvariantCulture);
                                Vector2 vector = Constants.CountBadge.CalcSize(content);
                                position.xMin  = position.xMax - vector.x;
                                position.yMin += ((position.yMax - position.yMin) - vector.y) * 0.5f;
                                position.x    -= 5f;
                                GUI.Label(position, content, Constants.CountBadge);
                            }
                        }
                    }
                }
                finally
                {
                    IDisposable disposable = enumerator as IDisposable;
                    if (disposable == null)
                    {
                    }
                    disposable.Dispose();
                }
                if (flag6 && (this.m_ListView.scrollPos.y >= ((this.m_ListView.rowHeight * this.m_ListView.totalRows) - this.ms_LVHeight)))
                {
                    this.m_ListView.scrollPos.y = ((this.m_ListView.rowHeight * this.m_ListView.totalRows) - this.ms_LVHeight) - 1;
                }
                if (((this.m_ListView.totalRows == 0) || (this.m_ListView.row >= this.m_ListView.totalRows)) || (this.m_ListView.row < 0))
                {
                    if (this.m_ActiveText.Length != 0)
                    {
                        this.SetActiveEntry(null);
                    }
                }
                else
                {
                    LogEntry outputEntry = new LogEntry();
                    LogEntries.GetEntryInternal(this.m_ListView.row, outputEntry);
                    this.SetActiveEntry(outputEntry);
                    LogEntries.GetEntryInternal(this.m_ListView.row, outputEntry);
                    if (this.m_ListView.selectionChanged || !this.m_ActiveText.Equals(outputEntry.condition))
                    {
                        this.SetActiveEntry(outputEntry);
                    }
                }
                if (((GUIUtility.keyboardControl == this.m_ListView.ID) && (current.type == EventType.KeyDown)) && ((current.keyCode == KeyCode.Return) && (this.m_ListView.row != 0)))
                {
                    LogEntries.RowGotDoubleClicked(this.m_ListView.row);
                    Event.current.Use();
                }
                if ((current.type != EventType.Layout) && (ListViewGUI.ilvState.rectHeight != 1))
                {
                    this.ms_LVHeight = ListViewGUI.ilvState.rectHeight;
                }
            }
            finally
            {
                LogEntries.EndGettingEntries();
                EditorGUIUtility.SetIconSize(Vector2.zero);
            }
            this.m_TextScroll = GUILayout.BeginScrollView(this.m_TextScroll, Constants.Box);
            float minHeight = Constants.MessageStyle.CalcHeight(GUIContent.Temp(this.m_ActiveText), base.position.width);

            GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true), GUILayout.MinHeight(minHeight) };
            EditorGUILayout.SelectableLabel(this.m_ActiveText, Constants.MessageStyle, options);
            GUILayout.EndScrollView();
            SplitterGUILayout.EndVerticalSplit();
            if (((current.type == EventType.ValidateCommand) || (current.type == EventType.ExecuteCommand)) && ((current.commandName == "Copy") && (this.m_ActiveText != string.Empty)))
            {
                if (current.type == EventType.ExecuteCommand)
                {
                    EditorGUIUtility.systemCopyBuffer = this.m_ActiveText;
                }
                current.Use();
            }
        }