move godot events to wrapper
This commit is contained in:
@@ -42,12 +42,12 @@ public partial class BottomPanelManager : Panel
|
||||
{ BottomPanelType.IdeDiagnostics, _ideDiagnosticsPanel }
|
||||
};
|
||||
|
||||
GodotGlobalEvents.Instance.BottomPanelTabSelected += OnBottomPanelTabSelected;
|
||||
GodotGlobalEvents.Instance.BottomPanelTabSelected.Subscribe(OnBottomPanelTabSelected);
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
GodotGlobalEvents.Instance.BottomPanelTabSelected -= OnBottomPanelTabSelected;
|
||||
GodotGlobalEvents.Instance.BottomPanelTabSelected.Subscribe(OnBottomPanelTabSelected);
|
||||
}
|
||||
|
||||
private async Task OnBottomPanelTabSelected(BottomPanelType? type)
|
||||
@@ -56,11 +56,11 @@ public partial class BottomPanelManager : Panel
|
||||
{
|
||||
if (type == null)
|
||||
{
|
||||
GodotGlobalEvents.Instance.InvokeBottomPanelVisibilityChangeRequested(false);
|
||||
GodotGlobalEvents.Instance.BottomPanelVisibilityChangeRequested.InvokeParallelFireAndForget(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
GodotGlobalEvents.Instance.InvokeBottomPanelVisibilityChangeRequested(true);
|
||||
GodotGlobalEvents.Instance.BottomPanelVisibilityChangeRequested.InvokeParallelFireAndForget(true);
|
||||
}
|
||||
foreach (var kvp in _panelTypeMap)
|
||||
{
|
||||
|
||||
10
src/SharpIDE.Godot/Features/BottomPanel/BottomPanelType.cs
Normal file
10
src/SharpIDE.Godot/Features/BottomPanel/BottomPanelType.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace SharpIDE.Godot.Features.BottomPanel;
|
||||
|
||||
public enum BottomPanelType
|
||||
{
|
||||
Run,
|
||||
Debug,
|
||||
Build,
|
||||
Problems,
|
||||
IdeDiagnostics
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public partial class CodeEditorPanel : MarginContainer
|
||||
private void OnTabClicked(long tab)
|
||||
{
|
||||
var sharpIdeFile = _tabContainer.GetChild<SharpIdeCodeEdit>((int)tab).SharpIdeFile;
|
||||
GodotGlobalEvents.Instance.InvokeFileExternallySelected(sharpIdeFile);
|
||||
GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(sharpIdeFile, null);
|
||||
}
|
||||
|
||||
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.Instance.InvokeFileExternallySelectedAndWait(file).ConfigureAwait(false);
|
||||
await GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelAsync(file, null).ConfigureAwait(false);
|
||||
}
|
||||
var lineInt = executionStopInfo.Line - 1; // Debugging is 1-indexed, Godot is 0-indexed
|
||||
Guard.Against.Negative(lineInt, nameof(lineInt));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Godot;
|
||||
using SharpIDE.Godot.Features.BottomPanel;
|
||||
|
||||
namespace SharpIDE.Godot.Features.LeftSideBar;
|
||||
|
||||
@@ -21,12 +22,12 @@ public partial class LeftSideBar : Panel
|
||||
_debugButton = GetNode<Button>("%DebugButton");
|
||||
_ideDiagnosticsButton = GetNode<Button>("%IdeDiagnosticsButton");
|
||||
|
||||
_problemsButton.Toggled += toggledOn => GodotGlobalEvents.Instance.InvokeBottomPanelTabSelected(toggledOn ? BottomPanelType.Problems : null);
|
||||
_runButton.Toggled += toggledOn => GodotGlobalEvents.Instance.InvokeBottomPanelTabSelected(toggledOn ? BottomPanelType.Run : null);
|
||||
_buildButton.Toggled += toggledOn => GodotGlobalEvents.Instance.InvokeBottomPanelTabSelected(toggledOn ? BottomPanelType.Build : null);
|
||||
_debugButton.Toggled += toggledOn => GodotGlobalEvents.Instance.InvokeBottomPanelTabSelected(toggledOn ? BottomPanelType.Debug : null);
|
||||
_ideDiagnosticsButton.Toggled += toggledOn => GodotGlobalEvents.Instance.InvokeBottomPanelTabSelected(toggledOn ? BottomPanelType.IdeDiagnostics : null);
|
||||
GodotGlobalEvents.Instance.BottomPanelTabExternallySelected += OnBottomPanelTabExternallySelected;
|
||||
_problemsButton.Toggled += toggledOn => GodotGlobalEvents.Instance.BottomPanelTabSelected.InvokeParallelFireAndForget(toggledOn ? BottomPanelType.Problems : null);
|
||||
_runButton.Toggled += toggledOn => GodotGlobalEvents.Instance.BottomPanelTabSelected.InvokeParallelFireAndForget(toggledOn ? BottomPanelType.Run : null);
|
||||
_buildButton.Toggled += toggledOn => GodotGlobalEvents.Instance.BottomPanelTabSelected.InvokeParallelFireAndForget(toggledOn ? BottomPanelType.Build : null);
|
||||
_debugButton.Toggled += toggledOn => GodotGlobalEvents.Instance.BottomPanelTabSelected.InvokeParallelFireAndForget(toggledOn ? BottomPanelType.Debug : null);
|
||||
_ideDiagnosticsButton.Toggled += toggledOn => GodotGlobalEvents.Instance.BottomPanelTabSelected.InvokeParallelFireAndForget(toggledOn ? BottomPanelType.IdeDiagnostics : null);
|
||||
GodotGlobalEvents.Instance.BottomPanelTabExternallySelected.Subscribe(OnBottomPanelTabExternallySelected);
|
||||
}
|
||||
|
||||
private async Task OnBottomPanelTabExternallySelected(BottomPanelType arg)
|
||||
|
||||
@@ -124,6 +124,6 @@ public partial class ProblemsPanel : Control
|
||||
var file = projectModel.Files
|
||||
.Concat(projectModel.Folders.SelectMany(f => f.GetAllFiles()))
|
||||
.Single(s => s.Path == diagnostic.Location.SourceTree?.GetMappedLineSpan(diagnostic.Location.SourceSpan).Path);
|
||||
GodotGlobalEvents.Instance.InvokeFileExternallySelected(file);
|
||||
GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(file, null);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using Godot;
|
||||
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
||||
using SharpIDE.Godot.Features.BottomPanel;
|
||||
|
||||
namespace SharpIDE.Godot.Features.Run;
|
||||
|
||||
@@ -51,13 +52,13 @@ public partial class RunMenuItem : HBoxContainer
|
||||
|
||||
private async void OnRunButtonPressed()
|
||||
{
|
||||
GodotGlobalEvents.Instance.InvokeBottomPanelTabExternallySelected(BottomPanelType.Run);
|
||||
GodotGlobalEvents.Instance.BottomPanelTabExternallySelected.InvokeParallelFireAndForget(BottomPanelType.Run);
|
||||
await Singletons.RunService.RunProject(Project).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async void OnDebugButtonPressed()
|
||||
{
|
||||
GodotGlobalEvents.Instance.InvokeBottomPanelTabExternallySelected(BottomPanelType.Debug);
|
||||
GodotGlobalEvents.Instance.BottomPanelTabExternallySelected.InvokeParallelFireAndForget(BottomPanelType.Debug);
|
||||
await Singletons.RunService.RunProject(Project, true).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public partial class SearchResultComponent : MarginContainer
|
||||
private void OnButtonPressed()
|
||||
{
|
||||
var fileLinePosition = new SharpIdeFileLinePosition { Line = Result.Line, Column = Result.StartColumn };
|
||||
GodotGlobalEvents.Instance.InvokeFileExternallySelected(Result.File, fileLinePosition);
|
||||
GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(Result.File, fileLinePosition);
|
||||
ParentSearchWindow.Hide();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public partial class SolutionExplorerPanel : MarginContainer
|
||||
{
|
||||
_tree = GetNode<Tree>("Tree");
|
||||
_tree.ItemMouseSelected += TreeOnItemMouseSelected;
|
||||
GodotGlobalEvents.Instance.FileExternallySelected += OnFileExternallySelected;
|
||||
GodotGlobalEvents.Instance.FileExternallySelected.Subscribe(OnFileExternallySelected);
|
||||
}
|
||||
|
||||
private void TreeOnItemMouseSelected(Vector2 mousePosition, long mouseButtonIndex)
|
||||
@@ -37,13 +37,13 @@ public partial class SolutionExplorerPanel : MarginContainer
|
||||
if (sharpIdeFileContainer is null) return;
|
||||
var sharpIdeFile = sharpIdeFileContainer.Item;
|
||||
Guard.Against.Null(sharpIdeFile, nameof(sharpIdeFile));
|
||||
GodotGlobalEvents.Instance.InvokeFileSelected(sharpIdeFile);
|
||||
GodotGlobalEvents.Instance.FileSelected.InvokeParallelFireAndForget(sharpIdeFile, null);
|
||||
}
|
||||
|
||||
private async Task OnFileExternallySelected(SharpIdeFile file, SharpIdeFileLinePosition? fileLinePosition)
|
||||
{
|
||||
await Task.CompletedTask.ConfigureAwait(ConfigureAwaitOptions.ForceYielding);
|
||||
var task = GodotGlobalEvents.Instance.InvokeFileSelectedAndWait(file, fileLinePosition);
|
||||
var task = GodotGlobalEvents.Instance.FileSelected.InvokeParallelAsync(file, fileLinePosition);
|
||||
var item = FindItemRecursive(_tree.GetRoot(), file);
|
||||
if (item is not null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user