Beispiel #1
0
        public static void      GoToLine(ILogContentGetter log, LogEntry logEntry, bool focus)
        {
            // Prefer using instanceID as much as possible, more reliable.
            // Try to reach the object, it might not be a TextAsset.
            if (logEntry.instanceID != 0)
            {
                string path = AssetDatabase.GetAssetPath(logEntry.instanceID);
                if (string.IsNullOrEmpty(path) == false)
                {
                    Object sourceFile = AssetDatabase.LoadAssetAtPath(path, typeof(TextAsset));
                    if (sourceFile != null)
                    {
                        RowUtility.GoToFileLine(path,
                                                logEntry.line,
                                                focus);
                        return;
                    }
                }
            }

            // Go to the first reachable frame.
            for (int j = 0; j < log.Frames.Length; j++)
            {
                if (log.Frames[j].fileExist == true)
                {
                    RowUtility.GoToFileLine(log.Frames[j].fileName,
                                            log.Frames[j].line,
                                            focus);
                    break;
                }
            }
        }
Beispiel #2
0
        private object  HandleKeyboard(object data)
        {
            RowsDrawer rowsDrawer = data as RowsDrawer;

            if (Event.current.type == EventType.KeyDown)
            {
                InputsManager inputsManager = HQ.Settings.Get <ConsoleSettings>().inputsManager;

                if (inputsManager.Check("Navigation", ConsoleConstants.CloseLogCommand) == true)
                {
                    if (rowsDrawer.rowsData.ContainsKey(this) == true)
                    {
                        rowsDrawer.rowsData.Remove(this);
                        rowsDrawer.InvalidateViewHeight();
                        RowUtility.drawingWindow.Repaint();
                        RowUtility.ClearPreview();
                    }
                }
                else if (inputsManager.Check("Navigation", ConsoleConstants.OpenLogCommand) == true)
                {
                    if (rowsDrawer.rowsData.ContainsKey(this) == false)
                    {
                        rowsDrawer.rowsData.Add(this, true);
                        rowsDrawer.InvalidateViewHeight();
                        RowUtility.drawingWindow.Repaint();
                        RowUtility.ClearPreview();
                    }
                }
                else if (inputsManager.Check("Navigation", ConsoleConstants.GoToLineCommand) == true &&
                         rowsDrawer.currentVars.CountSelection == 1 &&
                         this.Frames.Length > 0)
                {
                    string fileName = this.Frames[0].fileName;
                    int    line     = this.Frames[0].line;
                    bool   focus    = (Event.current.modifiers & HQ.Settings.Get <LogSettings>().forceFocusOnModifier) != 0;

                    RowUtility.GoToFileLine(fileName, line, focus);
                    RowUtility.drawingWindow.Repaint();
                    Event.current.Use();
                }
            }

            return(null);
        }
Beispiel #3
0
        public override void    DrawRow(RowsDrawer rowsDrawer, Rect r, int i, bool?collapse)
        {
            LogSettings settings    = HQ.Settings.Get <LogSettings>();
            float       originWidth = RowUtility.drawingWindow.position.width - rowsDrawer.verticalScrollbarWidth;

            // Draw highlight.
            r.x      = 0F;
            r.width  = originWidth;
            r.height = settings.height;

            this.DrawBackground(rowsDrawer, r, i);

            r.x    += 2F;
            r.width = 16F;

            bool  lastValue    = this.isOpened;
            Color foldoutColor = this.hasError == true ? ConsoleConstants.ErrorFoldoutColor : ConsoleConstants.WarningFoldoutColor;

            using (BgColorContentRestorer.Get(foldoutColor))
            {
                this.isOpened = EditorGUI.Foldout(r, this.isOpened, "");
            }
            if (lastValue != this.isOpened)
            {
                GUI.FocusControl(null);
                rowsDrawer.InvalidateViewHeight();
            }

            r.x    -= 2F;
            r.width = 3F;

            EditorGUI.DrawRect(r, foldoutColor);

            r.width = 16F;
            r.x    += r.width;
            r.width = originWidth - r.width;

            this.HandleDefaultSelection(rowsDrawer, r, i);

            // Toggle on middle-click.
            if (r.Contains(Event.current.mousePosition) == true &&
                Event.current.type == EventType.MouseDown &&
                Event.current.button == 2)
            {
                this.isOpened = !this.isOpened;
                rowsDrawer.InvalidateViewHeight();
                Event.current.Use();
            }
            else if (r.Contains(Event.current.mousePosition) == true &&
                     Event.current.type == EventType.MouseUp &&
                     Event.current.button == 0)
            {
                if (string.IsNullOrEmpty(this.file) == false &&
                    RowUtility.LastClickTime + Constants.DoubleClickTime > EditorApplication.timeSinceStartup)
                {
                    bool focus = false;

                    if ((Event.current.modifiers & settings.forceFocusOnModifier) != 0)
                    {
                        focus = true;
                    }

                    if (this.lastGoToFile < this.fileLines.Count)
                    {
                        RowUtility.GoToFileLine(this.file,
                                                this.fileLines[this.lastGoToFile].line,
                                                focus);

                        ++this.lastGoToFile;
                        if (this.lastGoToFile >= this.fileLines.Count)
                        {
                            this.lastGoToFile = 0;
                        }
                    }
                    else
                    {
                        this.lastGoToFile = 0;
                    }
                }

                RowUtility.LastClickTime = EditorApplication.timeSinceStartup;
            }

            GUI.Label(r, this.error + " (" + this.fileLines.Count + ")", settings.Style);
            r.y += settings.height;

            if (this.isOpened == true)
            {
                for (int j = 0; j < this.fileLines.Count; j++)
                {
                    r.x     = 0F;
                    r.width = originWidth;

                    if (Event.current.type == EventType.Repaint &&
                        this.selectedSubRow == j &&
                        rowsDrawer.currentVars.CountSelection > 0 &&
                        rowsDrawer.currentVars.GetSelection(0) == i)
                    {
                        EditorGUI.DrawRect(r, CompileRow.SubRowHighlightColor);
                    }

                    // Handle mouse inputs per log.
                    if (r.Contains(Event.current.mousePosition) == true)
                    {
                        // Toggle on middle click.
                        if (Event.current.type == EventType.MouseDown &&
                            Event.current.button == 0)
                        {
                            if (string.IsNullOrEmpty(this.file) == false &&
                                RowUtility.LastClickTime + Constants.DoubleClickTime > EditorApplication.timeSinceStartup)
                            {
                                bool focus = false;

                                if ((Event.current.modifiers & settings.forceFocusOnModifier) != 0)
                                {
                                    focus = true;
                                }

                                RowUtility.GoToFileLine(this.fileLines[j].file,
                                                        this.fileLines[j].line,
                                                        focus);
                            }
                            else
                            {
                                rowsDrawer.currentVars.ClearSelection();
                                rowsDrawer.currentVars.AddSelection(i);

                                this.selectedSubRow = j;

                                this.log.condition = this.fileLines[j].message;
                            }

                            RowUtility.LastClickTime = EditorApplication.timeSinceStartup;

                            Event.current.Use();
                        }
                    }

                    // Handle inputs.
                    if (this.fileLines[j].line > 0)
                    {
                        Utility.content.text = this.fileLines[j].line.ToString();
                        r.width = settings.Style.CalcSize(Utility.content).x;
                        GUI.Label(r,
                                  Utility.Color(Utility.content.text, HQ.Settings.Get <StackTraceSettings>().lineColor),
                                  settings.Style);
                        r.x += r.width;
                    }

                    r.width = originWidth - r.x;
                    GUI.Label(r, this.fileLines[j].message, settings.Style);

                    r.y += settings.height;
                }
            }
        }
Beispiel #4
0
        private static void     GoToLine(Rect r, Frame frame)
        {
            StackTraceSettings stackTrace = HQ.Settings.Get <StackTraceSettings>();

            if (Event.current.button == 0 &&
                frame.fileExist == true)
            {
                // Ping folder on click + modifiers.
                if ((Event.current.modifiers & stackTrace.pingFolderOnModifier) != 0)
                {
                    int i = frame.frameString.LastIndexOf('	') + 1;

                    Utility.content.text = frame.frameString.Substring(0, i);
                    var v = stackTrace.Style.CalcSize(Utility.content);

                    StringBuilder buffer = Utility.GetBuffer();

                    if (Event.current.mousePosition.x >= v.x)
                    {
                        int i2 = frame.frameString.IndexOf('/', i + 1);

                        // Skip Assets folder.
                        string folder = frame.frameString.Substring(i, i2 - i).Split('>')[1];

                        Utility.content.text += folder;
                        v = stackTrace.Style.CalcSize(Utility.content);

                        if (Event.current.mousePosition.x > v.x)
                        {
                            i = i2;
                            buffer.Append(folder);

                            while (Event.current.mousePosition.x >= v.x)
                            {
                                i2 = frame.frameString.IndexOf('/', i + 1);
                                if (i2 == -1)
                                {
                                    break;
                                }

                                folder = frame.frameString.Substring(i, i2 - i);
                                buffer.Append(folder);
                                Utility.content.text += folder;
                                v = stackTrace.Style.CalcSize(Utility.content);
                                i = i2;
                            }

                            EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath(buffer.ToString(), typeof(Object)));
                        }
                    }

                    Utility.RestoreBuffer(buffer);
                }
                // Or go to line.
                else
                {
                    bool focus = (Event.current.modifiers & HQ.Settings.Get <LogSettings>().forceFocusOnModifier) != 0;

                    RowUtility.GoToFileLine(frame.fileName, frame.line, focus);

                    Event.current.Use();
                }
            }
        }