handle optional window for sln picker
This commit is contained in:
@@ -14,9 +14,21 @@ public partial class SlnPicker : Control
|
||||
_fileDialog = GetNode<FileDialog>("%FileDialog");
|
||||
_openSlnButton = GetNode<Button>("%OpenSlnButton");
|
||||
_openSlnButton.Pressed += () => _fileDialog.PopupCentered();
|
||||
_fileDialog.FileSelected += path => _tcs.SetResult(path);
|
||||
var windowParent = GetParentOrNull<Window>();
|
||||
_fileDialog.FileSelected += path =>
|
||||
{
|
||||
_tcs.SetResult(path);
|
||||
windowParent?.Hide();
|
||||
};
|
||||
_fileDialog.Canceled += () => _tcs.SetResult(null);
|
||||
windowParent?.CloseRequested += OnCloseRequested;
|
||||
}
|
||||
|
||||
private void OnCloseRequested()
|
||||
{
|
||||
_tcs.SetResult(null);
|
||||
}
|
||||
|
||||
public async Task<string?> GetSelectedSolutionPath()
|
||||
{
|
||||
return await _tcs.Task;
|
||||
|
||||
@@ -47,7 +47,7 @@ public partial class IdeRoot : Control
|
||||
_runMenuButton.Pressed += OnRunMenuButtonPressed;
|
||||
GodotGlobalEvents.FileSelected += OnSolutionExplorerPanelOnFileSelected;
|
||||
_fileDialog.FileSelected += SetSlnFilePath;
|
||||
_openSlnButton.Pressed += IdeWindow.PickSolution;
|
||||
_openSlnButton.Pressed += () => IdeWindow.PickSolution();
|
||||
_buildSlnButton.Pressed += OnBuildSlnButtonPressed;
|
||||
GodotGlobalEvents.BottomPanelVisibilityChangeRequested += async show => await this.InvokeAsync(() => _invertedVSplitContainer.InvertedSetCollapsed(!show));
|
||||
_nodeReadyTcs.SetResult();
|
||||
|
||||
@@ -23,14 +23,29 @@ public partial class IdeWindow : Control
|
||||
GodotServiceDefaults.AddServiceDefaults();
|
||||
//GetWindow().SetMinSize(new Vector2I(1152, 648));
|
||||
|
||||
PickSolution();
|
||||
PickSolution(true);
|
||||
}
|
||||
|
||||
public void PickSolution()
|
||||
|
||||
public void PickSolution(bool fullscreen = false)
|
||||
{
|
||||
if (_slnPicker is not null) throw new InvalidOperationException("Solution picker is already active");
|
||||
_slnPicker = _solutionPickerScene.Instantiate<SlnPicker>();
|
||||
AddChild(_slnPicker);
|
||||
if (fullscreen)
|
||||
{
|
||||
AddChild(_slnPicker);
|
||||
}
|
||||
else
|
||||
{
|
||||
var window = GetNode<Window>("Window");
|
||||
window.Title = "Open Solution";
|
||||
window.AddChild(_slnPicker);
|
||||
window.Popup();
|
||||
window.CloseRequested += () =>
|
||||
{
|
||||
window.Hide();
|
||||
//window.QueueFreeChildren();
|
||||
};
|
||||
}
|
||||
_ = Task.GodotRun(async () =>
|
||||
{
|
||||
var slnPathTask = _slnPicker.GetSelectedSolutionPath();
|
||||
@@ -48,7 +63,7 @@ public partial class IdeWindow : Control
|
||||
|
||||
await this.InvokeAsync(() =>
|
||||
{
|
||||
RemoveChild(_slnPicker);
|
||||
_slnPicker.GetParent().RemoveChild(_slnPicker);
|
||||
_slnPicker.QueueFree();
|
||||
_slnPicker = null;
|
||||
if (_ideRoot is not null)
|
||||
|
||||
@@ -10,3 +10,11 @@ anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_3do1e")
|
||||
|
||||
[node name="Window" type="Window" parent="."]
|
||||
oversampling_override = 1.0
|
||||
title = "Open Solution"
|
||||
initial_position = 2
|
||||
visible = false
|
||||
wrap_controls = true
|
||||
popup_window = true
|
||||
|
||||
@@ -36,7 +36,7 @@ public static class NodeExtensions
|
||||
{
|
||||
extension(Node node)
|
||||
{
|
||||
public void ClearChildren()
|
||||
public void QueueFreeChildren()
|
||||
{
|
||||
foreach (var child in node.GetChildren())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user