/// <summary> /// Draws the module in the header. The default behaviour is to draw a simple tab button. /// </summary> /// <param name="focusedModuleID">ID of the focused module.</param> public virtual Rect DrawMenu(Rect r, int focusedModuleID) { GeneralSettings settings = HQ.Settings.Get <GeneralSettings>(); Utility.content.text = this.name; r.width = settings.MenuButtonStyle.CalcSize(Utility.content).x; EditorGUI.BeginChangeCheck(); NGEditorGUILayout.OutlineToggle(r, this.name, this.id == focusedModuleID, settings.MenuButtonStyle); if (EditorGUI.EndChangeCheck() == true) { if (Event.current.button == 1 || Event.current.control == true) { ConsoleUtility.OpenModuleInWindow(this.console, this, Event.current.control); } else if (this.id != focusedModuleID) { this.Focus(); } } r.x += r.width; return(r); }
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; }
/// <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); }