From bae381430a14bcb056f230617c256da4a5235f82 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 23 Feb 2025 20:29:58 +0100 Subject: [PATCH] Cleanup code #1437 --- Source/Editor/Windows/DebugLogWindow.cs | 56 +++++++++--------------- Source/Editor/Windows/OutputLogWindow.cs | 2 +- 2 files changed, 21 insertions(+), 37 deletions(-) diff --git a/Source/Editor/Windows/DebugLogWindow.cs b/Source/Editor/Windows/DebugLogWindow.cs index 7d326a0c3..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,7 +131,7 @@ namespace FlaxEditor.Windows else if (index % 2 == 0) Render2D.FillRectangle(clientRect, style.Background * 0.9f); - var color = Group == LogGroup.Error ? _window.ErrorColor : (Group == LogGroup.Warning ? _window.WarningColor : _window.InfoColor); + var color = Group == LogGroup.Error ? _window._colorError : (Group == LogGroup.Warning ? _window._colorWarning : _window._colorInfo); // Icon Render2D.DrawSprite(Icon, new Rectangle(5, 0, 32, 32), color); @@ -305,14 +305,12 @@ namespace FlaxEditor.Windows private readonly ToolStripButton[] _groupButtons = new ToolStripButton[3]; private LogType _iconType = LogType.Info; - - internal SpriteHandle IconInfo; - internal Color InfoColor; - internal SpriteHandle IconWarning; - internal Color WarningColor; - internal SpriteHandle IconError; - internal Color ErrorColor; - + 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. @@ -322,7 +320,7 @@ namespace FlaxEditor.Windows : base(editor, true, ScrollBars.None) { Title = "Debug Log"; - Icon = IconInfo; + Icon = _iconInfo; FlaxEditor.Utilities.Utils.SetupCommonInputActions(this); // Toolstrip @@ -366,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) @@ -399,32 +396,21 @@ namespace FlaxEditor.Windows }; // Cache entries icons - IconInfo = Editor.Icons.Info64; - IconWarning = Editor.Icons.Warning64; - IconError = Editor.Icons.Error64; - - //Cache entries color - var interfaceOptions = Editor.Options.Options.Interface; - InfoColor = interfaceOptions.OutputLogTextColor; - WarningColor = interfaceOptions.OutputLogWarningTextColor; - ErrorColor = interfaceOptions.OutputLogErrorTextColor; + _iconInfo = Editor.Icons.Info64; + _iconWarning = Editor.Icons.Warning64; + _iconError = Editor.Icons.Error64; // Bind events Editor.Options.OptionsChanged += OnEditorOptionsChanged; - OnEditorOptionsChanged(Editor.Options.Options); - Debug.Logger.LogHandler.SendLog += LogHandlerOnSendLog; Debug.Logger.LogHandler.SendExceptionLog += LogHandlerOnSendExceptionLog; + + // Init editor options + OnEditorOptionsChanged(Editor.Options.Options); } private void OnEditorOptionsChanged(EditorOptions options) { - if (_timestampsFormats == options.Interface.DebugLogTimestampsFormat && - InfoColor == options.Interface.OutputLogTextColor && - WarningColor == options.Interface.OutputLogWarningTextColor && - ErrorColor == options.Interface.OutputLogErrorTextColor) - return; - _timestampsFormats = options.Interface.DebugLogTimestampsFormat; _clearOnPlayButton.Checked = options.Interface.DebugLogClearOnPlay; _collapseLogsButton.Checked = options.Interface.DebugLogCollapse; @@ -432,10 +418,9 @@ namespace FlaxEditor.Windows _groupButtons[0].Checked = options.Interface.DebugLogShowErrorMessages; _groupButtons[1].Checked = options.Interface.DebugLogShowWarningMessages; _groupButtons[2].Checked = options.Interface.DebugLogShowInfoMessages; - - InfoColor = options.Interface.OutputLogTextColor; - WarningColor = options.Interface.OutputLogWarningTextColor; - ErrorColor = options.Interface.OutputLogErrorTextColor; + _colorInfo = options.Interface.OutputLogTextColor; + _colorWarning = options.Interface.OutputLogWarningTextColor; + _colorError = options.Interface.OutputLogErrorTextColor; } /// @@ -445,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 e3168521f..8db89581a 100644 --- a/Source/Editor/Windows/OutputLogWindow.cs +++ b/Source/Editor/Windows/OutputLogWindow.cs @@ -604,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;