add sln picker
This commit is contained in:
@@ -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(() =>
|
||||
|
||||
26
src/SharpIDE.Godot/Features/SlnPicker/SlnPicker.cs
Normal file
26
src/SharpIDE.Godot/Features/SlnPicker/SlnPicker.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
1
src/SharpIDE.Godot/Features/SlnPicker/SlnPicker.cs.uid
Normal file
1
src/SharpIDE.Godot/Features/SlnPicker/SlnPicker.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bjvwb6jg6jpsi
|
||||
21
src/SharpIDE.Godot/Features/SlnPicker/SlnPicker.tscn
Normal file
21
src/SharpIDE.Godot/Features/SlnPicker/SlnPicker.tscn
Normal 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
|
||||
Reference in New Issue
Block a user