From eb88897a2abd31927ff0491feabf5a1f40061e45 Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Tue, 30 Sep 2025 19:43:49 +1000 Subject: [PATCH] Move Godot events to instance --- .../BottomPanel/BottomPanelManager.cs | 8 +++--- .../Features/CodeEditor/CodeEditorPanel.cs | 4 +-- .../Features/LeftSideBar/LeftSideBar.cs | 12 ++++----- .../Features/Problems/ProblemsPanel.cs | 2 +- .../Features/Run/RunMenuItem.cs | 4 +-- .../Features/Search/SearchResultComponent.cs | 2 +- .../SolutionExplorer/SolutionExplorerPanel.cs | 6 ++--- src/SharpIDE.Godot/GodotGlobalEvents.cs | 27 ++++++++++--------- src/SharpIDE.Godot/IdeRoot.cs | 14 +++++++--- 9 files changed, 43 insertions(+), 36 deletions(-) diff --git a/src/SharpIDE.Godot/Features/BottomPanel/BottomPanelManager.cs b/src/SharpIDE.Godot/Features/BottomPanel/BottomPanelManager.cs index 12c07d0..09a8eb5 100644 --- a/src/SharpIDE.Godot/Features/BottomPanel/BottomPanelManager.cs +++ b/src/SharpIDE.Godot/Features/BottomPanel/BottomPanelManager.cs @@ -42,12 +42,12 @@ public partial class BottomPanelManager : Panel { BottomPanelType.IdeDiagnostics, _ideDiagnosticsPanel } }; - GodotGlobalEvents.BottomPanelTabSelected += OnBottomPanelTabSelected; + GodotGlobalEvents.Instance.BottomPanelTabSelected += OnBottomPanelTabSelected; } public override void _ExitTree() { - GodotGlobalEvents.BottomPanelTabSelected -= OnBottomPanelTabSelected; + GodotGlobalEvents.Instance.BottomPanelTabSelected -= OnBottomPanelTabSelected; } private async Task OnBottomPanelTabSelected(BottomPanelType? type) @@ -56,11 +56,11 @@ public partial class BottomPanelManager : Panel { if (type == null) { - GodotGlobalEvents.InvokeBottomPanelVisibilityChangeRequested(false); + GodotGlobalEvents.Instance.InvokeBottomPanelVisibilityChangeRequested(false); } else { - GodotGlobalEvents.InvokeBottomPanelVisibilityChangeRequested(true); + GodotGlobalEvents.Instance.InvokeBottomPanelVisibilityChangeRequested(true); } foreach (var kvp in _panelTypeMap) { diff --git a/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs b/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs index 9b60c67..08a40b1 100644 --- a/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs +++ b/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs @@ -39,7 +39,7 @@ public partial class CodeEditorPanel : MarginContainer private void OnTabClicked(long tab) { var sharpIdeFile = _tabContainer.GetChild((int)tab).SharpIdeFile; - GodotGlobalEvents.InvokeFileExternallySelected(sharpIdeFile); + GodotGlobalEvents.Instance.InvokeFileExternallySelected(sharpIdeFile); } private void OnTabClosePressed(long tabIndex) @@ -87,7 +87,7 @@ public partial class CodeEditorPanel : MarginContainer if (executionStopInfo.FilePath != currentSharpIdeFile?.Path) { var file = Solution.AllFiles.Single(s => s.Path == executionStopInfo.FilePath); - await GodotGlobalEvents.InvokeFileExternallySelectedAndWait(file).ConfigureAwait(false); + await GodotGlobalEvents.Instance.InvokeFileExternallySelectedAndWait(file).ConfigureAwait(false); } var lineInt = executionStopInfo.Line - 1; // Debugging is 1-indexed, Godot is 0-indexed Guard.Against.Negative(lineInt, nameof(lineInt)); diff --git a/src/SharpIDE.Godot/Features/LeftSideBar/LeftSideBar.cs b/src/SharpIDE.Godot/Features/LeftSideBar/LeftSideBar.cs index 1f95ceb..4034527 100644 --- a/src/SharpIDE.Godot/Features/LeftSideBar/LeftSideBar.cs +++ b/src/SharpIDE.Godot/Features/LeftSideBar/LeftSideBar.cs @@ -21,12 +21,12 @@ public partial class LeftSideBar : Panel _debugButton = GetNode