Пример #1
0
        protected override void RowGUI(RowGUIArgs args)
        {
            var item = (UCL_TreeViewItem)args.item;

            var logLine = item.Log;

            InitStylesIfNeeded();
            var style = defaultLineStyle;

            if (args.selected)
            {
                style = selecredLineStyle;
            }


            GUI.Label(args.rowRect, logLine.LineGUIContent, style);

            if (UCL_LogEntries.HasFlag(UCL_ConsoleFlags.Collapse))
            {
                var badgeContent = new GUIContent(logLine.EntryCount.ToString());
                var size         = CountBadge.CalcSize(badgeContent);


                Rect badgeRect = new Rect();
                badgeRect.width  = size.x;
                badgeRect.height = size.y;


                badgeRect.x  = args.rowRect.x + args.rowRect.width;
                badgeRect.x -= badgeRect.width;
                badgeRect.x -= 5f;
                badgeRect.y  = args.rowRect.y + (args.rowRect.height - badgeRect.height) / 2f;
                GUI.Label(badgeRect, badgeContent, CountBadge);
            }
        }
        //--------------------------------------
        // Logs Tracking
        //--------------------------------------


        private void OnEditorUpdate()
        {
            var logsCount = UCL_LogEntries.GetCount();

            if (m_lastLogsCount == logsCount)
            {
                return;
            }
            m_lastLogsCount = logsCount;
            RebuildLogsView();
        }
        private void SetupUI()
        {
            InitStyles();

            HandleInputEvents();

            UCL_LogEntries.SetFlag(UCL_ConsoleFlags.LogLevelLog, true);
            UCL_LogEntries.SetFlag(UCL_ConsoleFlags.LogLevelWarning, true);
            UCL_LogEntries.SetFlag(UCL_ConsoleFlags.LogLevelError, true);

            if (!EditorGUIUtility.isProSkin)
            {
                GUI.DrawTexture(new Rect(0, 0, position.width, position.height), SA_IconManager.GetIconFromHtmlColorString("#DFDFDFFF"));
            }
        }
        private void RebuildLogsView()
        {
            m_state = UCL_Settings.ConsoleWindowState;

            var logs           = UCL_LogEntries.GetLog();
            var preFiltredLogs = new List <UCL_LogInfo>();

            foreach (var log in logs)
            {
                var tag = UCL_Settings.Instance.GetTag(log.TagName);
                if (m_state.IsTagEnabled(tag))
                {
                    preFiltredLogs.Add(log);
                }
            }

            m_logsView.RebuildLogsView(preFiltredLogs);

            m_tagsMessagesCount = new Dictionary <string, int>();
            foreach (var log in logs)
            {
                IncrementMessagesCountForTag(log.TagName);
            }
        }
        private void DrawToolbar()
        {
            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            {
                bool clear = GUILayout.Button("Clear", EditorStyles.toolbarButton);
                if (clear)
                {
                    UCL_LogEntries.Clear();
                }

                GUILayout.Space(6);


                bool val = false;
                if (m_state.DisplayCollapse)
                {
                    val = UCL_LogEntries.HasFlag(UCL_ConsoleFlags.Collapse);
                    val = GUILayout.Toggle(val, "Collapse", EditorStyles.toolbarButton);
                    UCL_LogEntries.SetFlag(UCL_ConsoleFlags.Collapse, val);
                }

                if (m_state.DisplayClearOnPlay)
                {
                    val = UCL_LogEntries.HasFlag(UCL_ConsoleFlags.ClearOnPlay);
                    val = GUILayout.Toggle(val, "Clear on Play", EditorStyles.toolbarButton);
                    UCL_LogEntries.SetFlag(UCL_ConsoleFlags.ClearOnPlay, val);
                }

                if (m_state.DisplayPauseOnError)
                {
                    val = UCL_LogEntries.HasFlag(UCL_ConsoleFlags.ErrorPause);
                    val = GUILayout.Toggle(val, "Error Pause", EditorStyles.toolbarButton);
                    UCL_LogEntries.SetFlag(UCL_ConsoleFlags.ErrorPause, val);
                }


                if (UnDockedUsedTagsCount > 0)
                {
                    if (GUILayout.Button("Tags (" + UnDockedUsedTagsCount + ")", EditorStyles.toolbarDropDown))
                    {
                        GenericMenu toolsMenu = new GenericMenu();

                        foreach (var pair in m_tagsMessagesCount)
                        {
                            var tag = UCL_Settings.Instance.GetTag(pair.Key);
                            if (m_state.IsTagDocked(tag))
                            {
                                continue;
                            }

                            bool enabled = m_state.IsTagEnabled(tag);
                            toolsMenu.AddItem(new GUIContent(tag.Name + " (" + pair.Value + ")"), enabled, () => {
                                enabled = !enabled;
                                m_state.SetTagEnabledState(tag, enabled);
                                UCL_Settings.SaveConsoleWindowState(m_state);
                            });
                        }
                        toolsMenu.ShowAsContext();
                    }
                }


                GUILayout.FlexibleSpace();
                if (m_state.DisplaySearchBar)
                {
                    GUILayout.BeginHorizontal(m_toolbarStyle);
                    {
                        GUI.SetNextControlName(SEARCH_BAR_CONTROL_NAME);
                        m_searchString = EditorGUILayout.TextField(m_searchString, m_toolbarSearchTextFieldStyle, GUILayout.MinWidth(200f));

                        if (GUILayout.Button("", m_toolbarSearchCancelButtonStyle))
                        {
                            m_searchString = "";
                            GUI.FocusControl(null);
                        }

                        m_logsView.SerSearthcString(m_searchString);
                    }
                    GUILayout.EndHorizontal();
                }


                for (int i = UCL_Settings.Instance.Tags.Count - 1; i >= 0; i--)
                {
                    var tag = UCL_Settings.Instance.Tags[i];
                    //just a stupid workaround we have to make
                    // since gui list plgun an add a null balue to the tags list just for a second
                    if (tag == null)
                    {
                        continue;
                    }
                    if (m_state.IsTagDocked(tag))
                    {
                        var content = new GUIContent(GetMessagesCountForTag(tag.Name).ToString(), tag.Icon);

                        EditorGUI.BeginChangeCheck();
                        bool enabled = GUILayout.Toggle(m_state.IsTagEnabled(tag), content, EditorStyles.toolbarButton);
                        if (EditorGUI.EndChangeCheck())
                        {
                            m_state.SetTagEnabledState(tag, enabled);
                            UCL_Settings.SaveConsoleWindowState(m_state);
                        }
                    }
                }
            }
            GUILayout.EndHorizontal();
        }