From 648504ceb113ba21d46b324f3e56acfd7e7772c6 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 15 Jun 2025 20:31:04 +0200 Subject: [PATCH] Format code #3544 --- Source/Editor/GUI/ToolStripButton.cs | 24 ++++++++--------- Source/Editor/Windows/DebugLogWindow.cs | 34 ++++++++++--------------- 2 files changed, 26 insertions(+), 32 deletions(-) diff --git a/Source/Editor/GUI/ToolStripButton.cs b/Source/Editor/GUI/ToolStripButton.cs index 56e798a2e..c49cddcbb 100644 --- a/Source/Editor/GUI/ToolStripButton.cs +++ b/Source/Editor/GUI/ToolStripButton.cs @@ -122,6 +122,14 @@ namespace FlaxEditor.GUI return this; } + private void OnClicked() + { + if (AutoCheck) + Checked = !Checked; + Clicked?.Invoke(); + (Parent as ToolStrip)?.OnButtonClicked(this); + } + /// public override void Draw() { @@ -196,11 +204,7 @@ namespace FlaxEditor.GUI if (button == MouseButton.Left && _primaryMouseDown) { _primaryMouseDown = false; - if (AutoCheck) - Checked = !Checked; - Clicked?.Invoke(); - (Parent as ToolStrip)?.OnButtonClicked(this); - + OnClicked(); return true; } if (button == MouseButton.Right && _secondaryMouseDown) @@ -218,16 +222,12 @@ namespace FlaxEditor.GUI /// public override bool OnMouseDoubleClick(Float2 location, MouseButton button) { - if(button == MouseButton.Left) + if (button == MouseButton.Left) { - if (AutoCheck) - Checked = !Checked; - Clicked?.Invoke(); - (Parent as ToolStrip)?.OnButtonClicked(this); - + OnClicked(); return true; } - + return false; } diff --git a/Source/Editor/Windows/DebugLogWindow.cs b/Source/Editor/Windows/DebugLogWindow.cs index d0680c3c0..b5d71f6a0 100644 --- a/Source/Editor/Windows/DebugLogWindow.cs +++ b/Source/Editor/Windows/DebugLogWindow.cs @@ -318,7 +318,7 @@ namespace FlaxEditor.Windows private Color _colorWarning; private Color _colorError; private bool _colorDebugLogText; - + /// /// Initializes a new instance of the class. /// @@ -353,11 +353,11 @@ namespace FlaxEditor.Windows }).SetAutoCheck(true).LinkTooltip("Performs auto pause on error"); toolstrip.AddSeparator(); _groupButtons[0] = (ToolStripButton)toolstrip.AddButton(editor.Icons.Error32, () => { OnGroupButtonPressed(0); }) - .SetAutoCheck(true).LinkTooltip("Shows/hides error messages"); + .SetAutoCheck(true).LinkTooltip("Shows/hides error messages"); _groupButtons[1] = (ToolStripButton)toolstrip.AddButton(editor.Icons.Warning32, () => { OnGroupButtonPressed(1); }) - .SetAutoCheck(true).LinkTooltip("Shows/hides warning messages"); + .SetAutoCheck(true).LinkTooltip("Shows/hides warning messages"); _groupButtons[2] = (ToolStripButton)toolstrip.AddButton(editor.Icons.Info32, () => { OnGroupButtonPressed(2); }) - .SetAutoCheck(true).LinkTooltip("Shows/hides info messages"); + .SetAutoCheck(true).LinkTooltip("Shows/hides info messages"); UpdateCount(); // Split panel @@ -409,21 +409,21 @@ namespace FlaxEditor.Windows private void OnGroupButtonPressed(int index) { UpdateLogTypeVisibility((LogGroup)index, _groupButtons[index].Checked); - if(Input.GetKey(KeyboardKeys.Shift)) + if (Input.GetKey(KeyboardKeys.Shift)) { - for(int i = 0; i < (int)LogGroup.Max; i++) + for (int i = 0; i < (int)LogGroup.Max; i++) { - if(i == index) + if (i == index) continue; - _groupButtons[i].Checked = !_groupButtons[index].Checked; UpdateLogTypeVisibility((LogGroup)i, _groupButtons[i].Checked); } } - Editor.Options.Options.Interface.DebugLogShowErrorMessages = _groupButtons[0].Checked; - Editor.Options.Options.Interface.DebugLogShowWarningMessages = _groupButtons[1].Checked; - Editor.Options.Options.Interface.DebugLogShowInfoMessages = _groupButtons[2].Checked; + var options = Editor.Options.Options.Interface; + options.DebugLogShowErrorMessages = _groupButtons[0].Checked; + options.DebugLogShowWarningMessages = _groupButtons[1].Checked; + options.DebugLogShowInfoMessages = _groupButtons[2].Checked; Editor.Options.Apply(Editor.Options.Options); } @@ -464,15 +464,9 @@ namespace FlaxEditor.Windows // Create new entry switch (_timestampsFormats) { - case InterfaceOptions.TimestampsFormats.Utc: - desc.Title = $"[{DateTime.UtcNow}] {desc.Title}"; - break; - case InterfaceOptions.TimestampsFormats.LocalTime: - desc.Title = $"[{DateTime.Now}] {desc.Title}"; - break; - case InterfaceOptions.TimestampsFormats.TimeSinceStartup: - desc.Title = string.Format("[{0:g}] ", TimeSpan.FromSeconds(Time.TimeSinceStartup)) + desc.Title; - break; + case InterfaceOptions.TimestampsFormats.Utc: desc.Title = $"[{DateTime.UtcNow}] {desc.Title}"; break; + case InterfaceOptions.TimestampsFormats.LocalTime: desc.Title = $"[{DateTime.Now}] {desc.Title}"; break; + case InterfaceOptions.TimestampsFormats.TimeSinceStartup: desc.Title = string.Format("[{0:g}] ", TimeSpan.FromSeconds(Time.TimeSinceStartup)) + desc.Title; break; } var newEntry = new LogEntry(this, ref desc);