Cleanup code

#1437
This commit is contained in:
Wojtek Figat
2025-02-23 20:29:58 +01:00
parent 1c3f7fcec0
commit bae381430a
2 changed files with 21 additions and 37 deletions

View File

@@ -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;
/// <summary>
/// Initializes a new instance of the <see cref="DebugLogWindow"/> 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;
}
/// <summary>
@@ -445,7 +430,6 @@ namespace FlaxEditor.Windows
{
if (_entriesPanel == null)
return;
RemoveEntries();
}

View File

@@ -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;