Ejemplo n.º 1
0
        private static void     DrawStackFrameCode(int i, bool mainLine, string content)
        {
            StackTraceSettings settings = HQ.Settings.Get <StackTraceSettings>();
            Rect r = GUILayoutUtility.GetRect(0F, settings.previewHeight, settings.PreviewSourceCodeStyle);

            if (Event.current.type == EventType.Repaint)
            {
                if (mainLine == false)
                {
                    EditorGUI.DrawRect(r, settings.previewSourceCodeBackgroundColor);
                }
                else
                {
                    EditorGUI.DrawRect(r, settings.previewSourceCodeMainLineBackgroundColor);
                }
            }

            GUI.Label(r, Utility.Color(i.ToString(), settings.previewLineColor) + ConsoleUtility.ColorLine(content), settings.PreviewSourceCodeStyle);
            r.y += r.height;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Finds the cached version or populates a new entry.
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public string[] GetFile(string fileName)
        {
            int hash = fileName.GetHashCode();

            // Check if cached.
            for (int i = 0; i < this.indexLeft; i++)
            {
                if (this.files[i].hash == hash)
                {
                    return(this.files[i].lines);
                }
            }

            try
            {
                // Populate new file.
                HashFile hashFile = new HashFile(hash);

                hashFile.lines = File.ReadAllLines(fileName);

                InternalNGDebug.Assert(HQ.Settings != null, "NGSettings is null.");

                for (int i = 0; i < hashFile.lines.Length; i++)
                {
                    hashFile.lines[i] = Utility.Color((i + 1).ToString(), HQ.Settings.Get <StackTraceSettings>().previewLineColor) + ConsoleUtility.ColorLine(hashFile.lines[i]);
                }

                // Check array overflow.
                if (this.indexLeft == this.files.Length)
                {
                    Array.Resize(ref this.files, this.files.Length << 1);
                }

                this.files[this.indexLeft] = hashFile;
                ++this.indexLeft;

                //Debug.Log("Cached file:" + fileName);
                return(hashFile.lines);
            }
            catch (Exception ex)
            {
                InternalNGDebug.LogException(ex);
            }

            return(null);
        }