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