From d9b344381891a2771ad406d73adc0cfd2719c152 Mon Sep 17 00:00:00 2001 From: davevanegdom Date: Tue, 19 Sep 2023 01:09:05 +0200 Subject: [PATCH 1/5] Surface node body responds to mouse events --- Source/Editor/Surface/SurfaceNode.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/Surface/SurfaceNode.cs b/Source/Editor/Surface/SurfaceNode.cs index c24c47fbd..047e22476 100644 --- a/Source/Editor/Surface/SurfaceNode.cs +++ b/Source/Editor/Surface/SurfaceNode.cs @@ -878,7 +878,7 @@ namespace FlaxEditor.Surface /// public override bool CanSelect(ref Float2 location) { - return _headerRect.MakeOffsetted(Location).Contains(ref location); + return _headerRect.MakeOffsetted(Location).Contains(ref location) || new Rectangle(Float2.Zero, Size).MakeOffsetted(Location).Contains(ref location); } /// From 4257f1e2ac22c093498ae979b971ed6b04b973bc Mon Sep 17 00:00:00 2001 From: davevanegdom Date: Tue, 19 Sep 2023 14:10:25 +0200 Subject: [PATCH 2/5] Color settings for Debug and Output log --- Source/Editor/Options/InterfaceOptions.cs | 16 ++++++++++++ Source/Editor/Windows/DebugLogWindow.cs | 31 ++++++++++++++++++++--- Source/Editor/Windows/OutputLogWindow.cs | 9 ++++--- 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/Source/Editor/Options/InterfaceOptions.cs b/Source/Editor/Options/InterfaceOptions.cs index 5fd8c31c7..436c2d4bb 100644 --- a/Source/Editor/Options/InterfaceOptions.cs +++ b/Source/Editor/Options/InterfaceOptions.cs @@ -189,6 +189,22 @@ namespace FlaxEditor.Options [EditorDisplay("Output Log", "Text Shadow Offset"), EditorOrder(340), Tooltip("The output log text shadow offset. Set to 0 to disable this feature.")] public Float2 OutputLogTextShadowOffset { get; set; } = new Float2(1); + /// + /// Gets or sets the output log text color for warnings + /// + [DefaultValue(typeof(Color), "1,1,0,1")] + [EditorDisplay("Output Log", "Warning Color"), EditorOrder(341), 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(342), 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 49b03ede1..acb0ad619 100644 --- a/Source/Editor/Windows/DebugLogWindow.cs +++ b/Source/Editor/Windows/DebugLogWindow.cs @@ -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.ErrorColor : (Group == LogGroup.Warning ? _window.WarningColor : _window.InfoColor); + // 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,8 +305,12 @@ namespace FlaxEditor.Windows private LogType _iconType = LogType.Info; internal SpriteHandle IconInfo; + internal Color InfoColor; internal SpriteHandle IconWarning; + internal Color WarningColor; internal SpriteHandle IconError; + internal Color ErrorColor; + /// /// Initializes a new instance of the class. @@ -368,15 +373,33 @@ namespace FlaxEditor.Windows 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; + // Bind events Editor.Options.OptionsChanged += OnEditorOptionsChanged; + OnEditorOptionsChanged(Editor.Options.Options); + Debug.Logger.LogHandler.SendLog += LogHandlerOnSendLog; Debug.Logger.LogHandler.SendExceptionLog += LogHandlerOnSendExceptionLog; } 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; + + InfoColor = options.Interface.OutputLogTextColor; + WarningColor = options.Interface.OutputLogWarningTextColor; + ErrorColor = options.Interface.OutputLogErrorTextColor; } /// diff --git a/Source/Editor/Windows/OutputLogWindow.cs b/Source/Editor/Windows/OutputLogWindow.cs index 0b2249a33..4165aa378 100644 --- a/Source/Editor/Windows/OutputLogWindow.cs +++ b/Source/Editor/Windows/OutputLogWindow.cs @@ -274,7 +274,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 @@ -285,10 +287,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; From ad8d84bfd719c2e713caf36198eeaf6ee66c27a9 Mon Sep 17 00:00:00 2001 From: davevanegdom Date: Tue, 19 Sep 2023 14:16:40 +0200 Subject: [PATCH 3/5] Revert "Surface node body responds to mouse events" This reverts commit d9b344381891a2771ad406d73adc0cfd2719c152. --- Source/Editor/Surface/SurfaceNode.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/Surface/SurfaceNode.cs b/Source/Editor/Surface/SurfaceNode.cs index 047e22476..c24c47fbd 100644 --- a/Source/Editor/Surface/SurfaceNode.cs +++ b/Source/Editor/Surface/SurfaceNode.cs @@ -878,7 +878,7 @@ namespace FlaxEditor.Surface /// public override bool CanSelect(ref Float2 location) { - return _headerRect.MakeOffsetted(Location).Contains(ref location) || new Rectangle(Float2.Zero, Size).MakeOffsetted(Location).Contains(ref location); + return _headerRect.MakeOffsetted(Location).Contains(ref location); } /// From 9fbfc835357cecb3638fdb9961adc8661b5489c5 Mon Sep 17 00:00:00 2001 From: davevanegdom Date: Tue, 19 Sep 2023 14:19:38 +0200 Subject: [PATCH 4/5] Editor order cleanup --- Source/Editor/Options/InterfaceOptions.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/Editor/Options/InterfaceOptions.cs b/Source/Editor/Options/InterfaceOptions.cs index 436c2d4bb..aa268f4b2 100644 --- a/Source/Editor/Options/InterfaceOptions.cs +++ b/Source/Editor/Options/InterfaceOptions.cs @@ -186,14 +186,14 @@ namespace FlaxEditor.Options /// Gets or sets the output log text shadow offset. Set to 0 to disable this feature. /// [DefaultValue(typeof(Float2), "1,1")] - [EditorDisplay("Output Log", "Text Shadow Offset"), EditorOrder(340), Tooltip("The output log text shadow offset. Set to 0 to disable this feature.")] + [EditorDisplay("Output Log", "Text Shadow Offset"), EditorOrder(350), Tooltip("The output log text shadow offset. Set to 0 to disable this feature.")] public Float2 OutputLogTextShadowOffset { get; set; } = new Float2(1); /// /// Gets or sets the output log text color for warnings /// [DefaultValue(typeof(Color), "1,1,0,1")] - [EditorDisplay("Output Log", "Warning Color"), EditorOrder(341), Tooltip("The output log text color for warnings.")] + [EditorDisplay("Output Log", "Warning Color"), EditorOrder(360), Tooltip("The output log text color for warnings.")] public Color OutputLogWarningTextColor { get; set; } = Color.Yellow; @@ -201,7 +201,7 @@ namespace FlaxEditor.Options /// Gets or sets the output log text color for errors /// [DefaultValue(typeof(Color), "1,0,0,1")] - [EditorDisplay("Output Log", "Error Color"), EditorOrder(342), Tooltip("The output log text color for errors.")] + [EditorDisplay("Output Log", "Error Color"), EditorOrder(370), Tooltip("The output log text color for errors.")] public Color OutputLogErrorTextColor { get; set; } = Color.Red; @@ -209,14 +209,14 @@ namespace FlaxEditor.Options /// Gets or sets a value indicating whether auto-focus output log window on code compilation error. /// [DefaultValue(true)] - [EditorDisplay("Output Log", "Focus Output Log On Compilation Error"), EditorOrder(350), Tooltip("Determines whether auto-focus output log window on code compilation error.")] + [EditorDisplay("Output Log", "Focus Output Log On Compilation Error"), EditorOrder(380), Tooltip("Determines whether auto-focus output log window on code compilation error.")] public bool FocusOutputLogOnCompilationError { get; set; } = true; /// /// Gets or sets a value indicating whether auto-focus output log window on game build error. /// [DefaultValue(true)] - [EditorDisplay("Output Log", "Focus Output Log On Game Build Error"), EditorOrder(360), Tooltip("Determines whether auto-focus output log window on game build error.")] + [EditorDisplay("Output Log", "Focus Output Log On Game Build Error"), EditorOrder(390), Tooltip("Determines whether auto-focus output log window on game build error.")] public bool FocusOutputLogOnGameBuildError { get; set; } = true; /// From bae381430a14bcb056f230617c256da4a5235f82 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 23 Feb 2025 20:29:58 +0100 Subject: [PATCH 5/5] 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;