add sln picker

This commit is contained in:
Matt Parker
2025-09-30 18:21:15 +10:00
parent e10ca304ac
commit 4473ab17a6
10 changed files with 149 additions and 15 deletions

View File

@@ -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(() =>

View File

@@ -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>("%FileDialog");
}
public async Task<string?> GetSelectedSolutionPath()
{
var tcs = new TaskCompletionSource<string?>(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;
}
}

View File

@@ -0,0 +1 @@
uid://bjvwb6jg6jpsi

View File

@@ -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