diff --git a/src/SharpIDE.Godot/Features/BottomPanel/BottomPanelManager.cs b/src/SharpIDE.Godot/Features/BottomPanel/BottomPanelManager.cs index 093ebf6..12c07d0 100644 --- a/src/SharpIDE.Godot/Features/BottomPanel/BottomPanelManager.cs +++ b/src/SharpIDE.Godot/Features/BottomPanel/BottomPanelManager.cs @@ -45,6 +45,11 @@ public partial class BottomPanelManager : Panel GodotGlobalEvents.BottomPanelTabSelected += OnBottomPanelTabSelected; } + public override void _ExitTree() + { + GodotGlobalEvents.BottomPanelTabSelected -= OnBottomPanelTabSelected; + } + private async Task OnBottomPanelTabSelected(BottomPanelType? type) { await this.InvokeAsync(() => diff --git a/src/SharpIDE.Godot/Features/SlnPicker/SlnPicker.cs b/src/SharpIDE.Godot/Features/SlnPicker/SlnPicker.cs new file mode 100644 index 0000000..011ae88 --- /dev/null +++ b/src/SharpIDE.Godot/Features/SlnPicker/SlnPicker.cs @@ -0,0 +1,26 @@ +using Godot; + +namespace SharpIDE.Godot.Features.SlnPicker; + +public partial class SlnPicker : Control +{ + private FileDialog _fileDialog = null!; + + public override void _Ready() + { + _fileDialog = GetNode("%FileDialog"); + } + public async Task GetSelectedSolutionPath() + { + var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + await this.InvokeAsync(() => + { + _fileDialog.FileSelected += path => tcs.SetResult(path); + _fileDialog.Canceled += () => tcs.SetResult(null); + _fileDialog.PopupCentered(); + }); + + var selectedPath = await tcs.Task; + return selectedPath; + } +} \ No newline at end of file diff --git a/src/SharpIDE.Godot/Features/SlnPicker/SlnPicker.cs.uid b/src/SharpIDE.Godot/Features/SlnPicker/SlnPicker.cs.uid new file mode 100644 index 0000000..ca7273a --- /dev/null +++ b/src/SharpIDE.Godot/Features/SlnPicker/SlnPicker.cs.uid @@ -0,0 +1 @@ +uid://bjvwb6jg6jpsi diff --git a/src/SharpIDE.Godot/Features/SlnPicker/SlnPicker.tscn b/src/SharpIDE.Godot/Features/SlnPicker/SlnPicker.tscn new file mode 100644 index 0000000..b9f0eea --- /dev/null +++ b/src/SharpIDE.Godot/Features/SlnPicker/SlnPicker.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=2 format=3 uid="uid://cwvhbsd1mdl2x"] + +[ext_resource type="Script" uid="uid://bjvwb6jg6jpsi" path="res://Features/SlnPicker/SlnPicker.cs" id="1_ciq0g"] + +[node name="SlnPicker" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_ciq0g") + +[node name="FileDialog" type="FileDialog" parent="."] +unique_name_in_owner = true +oversampling_override = 1.0 +title = "Open a File" +file_mode = 0 +access = 2 +filters = PackedStringArray("*.sln,*.slnx;Solution Files") +use_native_dialog = true diff --git a/src/SharpIDE.Godot/IdeRoot.cs b/src/SharpIDE.Godot/IdeRoot.cs index 45fcc80..fef8d57 100644 --- a/src/SharpIDE.Godot/IdeRoot.cs +++ b/src/SharpIDE.Godot/IdeRoot.cs @@ -15,6 +15,7 @@ namespace SharpIDE.Godot; public partial class IdeRoot : Control { + public IdeWindow IdeWindow { get; set; } = null!; private Button _openSlnButton = null!; private Button _buildSlnButton = null!; private FileDialog _fileDialog = null!; @@ -28,11 +29,9 @@ public partial class IdeRoot : Control private BottomPanelManager _bottomPanelManager = null!; private readonly PackedScene _runMenuItemScene = ResourceLoader.Load("res://Features/Run/RunMenuItem.tscn"); + private TaskCompletionSource _nodeReadyTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); public override void _Ready() { - MSBuildLocator.RegisterDefaults(); - GodotServiceDefaults.AddServiceDefaults(); - _openSlnButton = GetNode