diff --git a/Source/Editor/Options/InterfaceOptions.cs b/Source/Editor/Options/InterfaceOptions.cs index 4cd76adc6..a9d5d18ca 100644 --- a/Source/Editor/Options/InterfaceOptions.cs +++ b/Source/Editor/Options/InterfaceOptions.cs @@ -379,6 +379,22 @@ namespace FlaxEditor.Options } } + /// + /// Gets or sets the output log text color for warnings + /// + [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; + + + /// + /// Gets or sets the output log text color for errors + /// + [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; + + /// /// Gets or sets a value indicating whether auto-focus output log window on code compilation error. /// diff --git a/Source/Editor/Windows/DebugLogWindow.cs b/Source/Editor/Windows/DebugLogWindow.cs index 88c19dc32..6eddcb81c 100644 --- a/Source/Editor/Windows/DebugLogWindow.cs +++ b/Source/Editor/Windows/DebugLogWindow.cs @@ -95,15 +95,15 @@ namespace FlaxEditor.Windows { case LogType.Warning: Group = LogGroup.Warning; - Icon = _window.IconWarning; + Icon = _window._iconWarning; break; case LogType.Info: Group = LogGroup.Info; - Icon = _window.IconInfo; + Icon = _window._iconInfo; break; default: Group = LogGroup.Error; - Icon = _window.IconError; + Icon = _window._iconError; break; } } @@ -131,20 +131,21 @@ namespace FlaxEditor.Windows else if (index % 2 == 0) Render2D.FillRectangle(clientRect, style.Background * 0.9f); + var color = Group == LogGroup.Error ? _window._colorError : (Group == LogGroup.Warning ? _window._colorWarning : _window._colorInfo); + // Icon - var iconColor = Group == LogGroup.Error ? Color.Red : (Group == LogGroup.Warning ? Color.Yellow : style.Foreground); - Render2D.DrawSprite(Icon, new Rectangle(5, 0, 32, 32), iconColor); + Render2D.DrawSprite(Icon, new Rectangle(5, 0, 32, 32), color); // Title var textRect = new Rectangle(38, 2, clientRect.Width - 40, clientRect.Height - 10); Render2D.PushClip(ref clientRect); if (LogCount == 1) { - Render2D.DrawText(style.FontMedium, Desc.Title, textRect, style.Foreground); + Render2D.DrawText(style.FontMedium, Desc.Title, textRect, color); } 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(); } @@ -304,10 +305,12 @@ namespace FlaxEditor.Windows private readonly ToolStripButton[] _groupButtons = new ToolStripButton[3]; private LogType _iconType = LogType.Info; - - internal SpriteHandle IconInfo; - internal SpriteHandle IconWarning; - internal SpriteHandle IconError; + private SpriteHandle _iconInfo; + private SpriteHandle _iconWarning; + private SpriteHandle _iconError; + private Color _colorInfo; + private Color _colorWarning; + private Color _colorError; /// /// Initializes a new instance of the class. @@ -317,7 +320,7 @@ namespace FlaxEditor.Windows : base(editor, true, ScrollBars.None) { Title = "Debug Log"; - Icon = IconInfo; + Icon = _iconInfo; FlaxEditor.Utilities.Utils.SetupCommonInputActions(this); // Toolstrip @@ -361,7 +364,6 @@ namespace FlaxEditor.Windows editor.Options.Apply(editor.Options.Options); }).SetAutoCheck(true).LinkTooltip("Shows/hides info messages"); UpdateCount(); - OnEditorOptionsChanged(Editor.Options.Options); // Split panel _split = new SplitPanel(Orientation.Vertical, ScrollBars.Vertical, ScrollBars.Both) @@ -394,14 +396,17 @@ namespace FlaxEditor.Windows }; // Cache entries icons - IconInfo = Editor.Icons.Info64; - IconWarning = Editor.Icons.Warning64; - IconError = Editor.Icons.Error64; + _iconInfo = Editor.Icons.Info64; + _iconWarning = Editor.Icons.Warning64; + _iconError = Editor.Icons.Error64; // Bind events Editor.Options.OptionsChanged += OnEditorOptionsChanged; Debug.Logger.LogHandler.SendLog += LogHandlerOnSendLog; Debug.Logger.LogHandler.SendExceptionLog += LogHandlerOnSendExceptionLog; + + // Init editor options + OnEditorOptionsChanged(Editor.Options.Options); } private void OnEditorOptionsChanged(EditorOptions options) @@ -413,6 +418,9 @@ namespace FlaxEditor.Windows _groupButtons[0].Checked = options.Interface.DebugLogShowErrorMessages; _groupButtons[1].Checked = options.Interface.DebugLogShowWarningMessages; _groupButtons[2].Checked = options.Interface.DebugLogShowInfoMessages; + _colorInfo = options.Interface.OutputLogTextColor; + _colorWarning = options.Interface.OutputLogWarningTextColor; + _colorError = options.Interface.OutputLogErrorTextColor; } /// @@ -422,7 +430,6 @@ namespace FlaxEditor.Windows { if (_entriesPanel == null) return; - RemoveEntries(); } diff --git a/Source/Editor/Windows/OutputLogWindow.cs b/Source/Editor/Windows/OutputLogWindow.cs index 1ce17218e..8db89581a 100644 --- a/Source/Editor/Windows/OutputLogWindow.cs +++ b/Source/Editor/Windows/OutputLogWindow.cs @@ -286,7 +286,9 @@ namespace FlaxEditor.Windows _output.DefaultStyle.Font == options.Interface.OutputLogTextFont && _output.DefaultStyle.Color == options.Interface.OutputLogTextColor && _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; _output.DefaultStyle = new TextBlockStyle @@ -297,10 +299,11 @@ namespace FlaxEditor.Windows ShadowOffset = options.Interface.OutputLogTextShadowOffset, BackgroundSelectedBrush = new SolidColorBrush(Style.Current.BackgroundSelected), }; + _output.WarningStyle = _output.DefaultStyle; - _output.WarningStyle.Color = Color.Yellow; + _output.WarningStyle.Color = options.Interface.OutputLogWarningTextColor; _output.ErrorStyle = _output.DefaultStyle; - _output.ErrorStyle.Color = Color.Red; + _output.ErrorStyle.Color = options.Interface.OutputLogErrorTextColor; _timestampsFormats = options.Interface.OutputLogTimestampsFormat; _showLogType = options.Interface.OutputLogShowLogType; @@ -601,7 +604,7 @@ namespace FlaxEditor.Windows var cachedScrollValue = _vScroll.Value; var cachedSelection = _output.SelectionRange; 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.TargetViewOffset = cachedOutputTargetViewOffset; _textBufferCount = _entries.Count;