Merge branch 'davevanegdom-DebugOutputImprovements'

This commit is contained in:
Wojtek Figat
2025-02-23 20:30:01 +01:00
3 changed files with 47 additions and 21 deletions

View File

@@ -379,6 +379,22 @@ namespace FlaxEditor.Options
} }
} }
/// <summary>
/// Gets or sets the output log text color for warnings
/// </summary>
[DefaultValue(typeof(Color), "1,1,0,1")]
[EditorDisplay("Output Log", "Warning Color"), EditorOrder(446), Tooltip("The output log text color for warnings.")]
public Color OutputLogWarningTextColor { get; set; } = Color.Yellow;
/// <summary>
/// Gets or sets the output log text color for errors
/// </summary>
[DefaultValue(typeof(Color), "1,0,0,1")]
[EditorDisplay("Output Log", "Error Color"), EditorOrder(445), Tooltip("The output log text color for errors.")]
public Color OutputLogErrorTextColor { get; set; } = Color.Red;
/// <summary> /// <summary>
/// Gets or sets a value indicating whether auto-focus output log window on code compilation error. /// Gets or sets a value indicating whether auto-focus output log window on code compilation error.
/// </summary> /// </summary>

View File

@@ -95,15 +95,15 @@ namespace FlaxEditor.Windows
{ {
case LogType.Warning: case LogType.Warning:
Group = LogGroup.Warning; Group = LogGroup.Warning;
Icon = _window.IconWarning; Icon = _window._iconWarning;
break; break;
case LogType.Info: case LogType.Info:
Group = LogGroup.Info; Group = LogGroup.Info;
Icon = _window.IconInfo; Icon = _window._iconInfo;
break; break;
default: default:
Group = LogGroup.Error; Group = LogGroup.Error;
Icon = _window.IconError; Icon = _window._iconError;
break; break;
} }
} }
@@ -131,20 +131,21 @@ namespace FlaxEditor.Windows
else if (index % 2 == 0) else if (index % 2 == 0)
Render2D.FillRectangle(clientRect, style.Background * 0.9f); Render2D.FillRectangle(clientRect, style.Background * 0.9f);
var color = Group == LogGroup.Error ? _window._colorError : (Group == LogGroup.Warning ? _window._colorWarning : _window._colorInfo);
// Icon // Icon
var iconColor = Group == LogGroup.Error ? Color.Red : (Group == LogGroup.Warning ? Color.Yellow : style.Foreground); Render2D.DrawSprite(Icon, new Rectangle(5, 0, 32, 32), color);
Render2D.DrawSprite(Icon, new Rectangle(5, 0, 32, 32), iconColor);
// Title // Title
var textRect = new Rectangle(38, 2, clientRect.Width - 40, clientRect.Height - 10); var textRect = new Rectangle(38, 2, clientRect.Width - 40, clientRect.Height - 10);
Render2D.PushClip(ref clientRect); Render2D.PushClip(ref clientRect);
if (LogCount == 1) if (LogCount == 1)
{ {
Render2D.DrawText(style.FontMedium, Desc.Title, textRect, style.Foreground); Render2D.DrawText(style.FontMedium, Desc.Title, textRect, color);
} }
else if (LogCount > 1) else if (LogCount > 1)
{ {
Render2D.DrawText(style.FontMedium, $"{Desc.Title} ({LogCount})", textRect, style.Foreground); Render2D.DrawText(style.FontMedium, $"{Desc.Title} ({LogCount})", textRect, color);
} }
Render2D.PopClip(); Render2D.PopClip();
} }
@@ -304,10 +305,12 @@ namespace FlaxEditor.Windows
private readonly ToolStripButton[] _groupButtons = new ToolStripButton[3]; private readonly ToolStripButton[] _groupButtons = new ToolStripButton[3];
private LogType _iconType = LogType.Info; private LogType _iconType = LogType.Info;
private SpriteHandle _iconInfo;
internal SpriteHandle IconInfo; private SpriteHandle _iconWarning;
internal SpriteHandle IconWarning; private SpriteHandle _iconError;
internal SpriteHandle IconError; private Color _colorInfo;
private Color _colorWarning;
private Color _colorError;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="DebugLogWindow"/> class. /// Initializes a new instance of the <see cref="DebugLogWindow"/> class.
@@ -317,7 +320,7 @@ namespace FlaxEditor.Windows
: base(editor, true, ScrollBars.None) : base(editor, true, ScrollBars.None)
{ {
Title = "Debug Log"; Title = "Debug Log";
Icon = IconInfo; Icon = _iconInfo;
FlaxEditor.Utilities.Utils.SetupCommonInputActions(this); FlaxEditor.Utilities.Utils.SetupCommonInputActions(this);
// Toolstrip // Toolstrip
@@ -361,7 +364,6 @@ namespace FlaxEditor.Windows
editor.Options.Apply(editor.Options.Options); editor.Options.Apply(editor.Options.Options);
}).SetAutoCheck(true).LinkTooltip("Shows/hides info messages"); }).SetAutoCheck(true).LinkTooltip("Shows/hides info messages");
UpdateCount(); UpdateCount();
OnEditorOptionsChanged(Editor.Options.Options);
// Split panel // Split panel
_split = new SplitPanel(Orientation.Vertical, ScrollBars.Vertical, ScrollBars.Both) _split = new SplitPanel(Orientation.Vertical, ScrollBars.Vertical, ScrollBars.Both)
@@ -394,14 +396,17 @@ namespace FlaxEditor.Windows
}; };
// Cache entries icons // Cache entries icons
IconInfo = Editor.Icons.Info64; _iconInfo = Editor.Icons.Info64;
IconWarning = Editor.Icons.Warning64; _iconWarning = Editor.Icons.Warning64;
IconError = Editor.Icons.Error64; _iconError = Editor.Icons.Error64;
// Bind events // Bind events
Editor.Options.OptionsChanged += OnEditorOptionsChanged; Editor.Options.OptionsChanged += OnEditorOptionsChanged;
Debug.Logger.LogHandler.SendLog += LogHandlerOnSendLog; Debug.Logger.LogHandler.SendLog += LogHandlerOnSendLog;
Debug.Logger.LogHandler.SendExceptionLog += LogHandlerOnSendExceptionLog; Debug.Logger.LogHandler.SendExceptionLog += LogHandlerOnSendExceptionLog;
// Init editor options
OnEditorOptionsChanged(Editor.Options.Options);
} }
private void OnEditorOptionsChanged(EditorOptions options) private void OnEditorOptionsChanged(EditorOptions options)
@@ -413,6 +418,9 @@ namespace FlaxEditor.Windows
_groupButtons[0].Checked = options.Interface.DebugLogShowErrorMessages; _groupButtons[0].Checked = options.Interface.DebugLogShowErrorMessages;
_groupButtons[1].Checked = options.Interface.DebugLogShowWarningMessages; _groupButtons[1].Checked = options.Interface.DebugLogShowWarningMessages;
_groupButtons[2].Checked = options.Interface.DebugLogShowInfoMessages; _groupButtons[2].Checked = options.Interface.DebugLogShowInfoMessages;
_colorInfo = options.Interface.OutputLogTextColor;
_colorWarning = options.Interface.OutputLogWarningTextColor;
_colorError = options.Interface.OutputLogErrorTextColor;
} }
/// <summary> /// <summary>
@@ -422,7 +430,6 @@ namespace FlaxEditor.Windows
{ {
if (_entriesPanel == null) if (_entriesPanel == null)
return; return;
RemoveEntries(); RemoveEntries();
} }

View File

@@ -286,7 +286,9 @@ namespace FlaxEditor.Windows
_output.DefaultStyle.Font == options.Interface.OutputLogTextFont && _output.DefaultStyle.Font == options.Interface.OutputLogTextFont &&
_output.DefaultStyle.Color == options.Interface.OutputLogTextColor && _output.DefaultStyle.Color == options.Interface.OutputLogTextColor &&
_output.DefaultStyle.ShadowColor == options.Interface.OutputLogTextShadowColor && _output.DefaultStyle.ShadowColor == options.Interface.OutputLogTextShadowColor &&
_output.DefaultStyle.ShadowOffset == options.Interface.OutputLogTextShadowOffset) _output.DefaultStyle.ShadowOffset == options.Interface.OutputLogTextShadowOffset &&
_output.WarningStyle.Color == options.Interface.OutputLogWarningTextColor &&
_output.ErrorStyle.Color == options.Interface.OutputLogErrorTextColor)
return; return;
_output.DefaultStyle = new TextBlockStyle _output.DefaultStyle = new TextBlockStyle
@@ -297,10 +299,11 @@ namespace FlaxEditor.Windows
ShadowOffset = options.Interface.OutputLogTextShadowOffset, ShadowOffset = options.Interface.OutputLogTextShadowOffset,
BackgroundSelectedBrush = new SolidColorBrush(Style.Current.BackgroundSelected), BackgroundSelectedBrush = new SolidColorBrush(Style.Current.BackgroundSelected),
}; };
_output.WarningStyle = _output.DefaultStyle; _output.WarningStyle = _output.DefaultStyle;
_output.WarningStyle.Color = Color.Yellow; _output.WarningStyle.Color = options.Interface.OutputLogWarningTextColor;
_output.ErrorStyle = _output.DefaultStyle; _output.ErrorStyle = _output.DefaultStyle;
_output.ErrorStyle.Color = Color.Red; _output.ErrorStyle.Color = options.Interface.OutputLogErrorTextColor;
_timestampsFormats = options.Interface.OutputLogTimestampsFormat; _timestampsFormats = options.Interface.OutputLogTimestampsFormat;
_showLogType = options.Interface.OutputLogShowLogType; _showLogType = options.Interface.OutputLogShowLogType;
@@ -601,7 +604,7 @@ namespace FlaxEditor.Windows
var cachedScrollValue = _vScroll.Value; var cachedScrollValue = _vScroll.Value;
var cachedSelection = _output.SelectionRange; var cachedSelection = _output.SelectionRange;
var cachedOutputTargetViewOffset = _output.TargetViewOffset; var cachedOutputTargetViewOffset = _output.TargetViewOffset;
var isBottomScroll = _vScroll.Value >= _vScroll.Maximum - (_scrollSize*2) || wasEmpty; var isBottomScroll = _vScroll.Value >= _vScroll.Maximum - (_scrollSize * 2) || wasEmpty;
_output.Text = _textBuffer.ToString(); _output.Text = _textBuffer.ToString();
_output.TargetViewOffset = cachedOutputTargetViewOffset; _output.TargetViewOffset = cachedOutputTargetViewOffset;
_textBufferCount = _entries.Count; _textBufferCount = _entries.Count;