1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 17:32:54 +08:00

Fix file chooser path not opening home directory initially

This commit is contained in:
Salman Ahmed 2022-06-16 20:48:17 +03:00
parent 47d0ecf5e8
commit db02cb81c5

View File

@ -36,6 +36,8 @@ namespace osu.Game.Screens.Edit.Setup
[Resolved]
private OsuGameBase game { get; set; } = null!;
private string? chooserPath;
private readonly BindableWithCurrent<FileInfo?> current = new BindableWithCurrent<FileInfo?>();
public Bindable<FileInfo?> Current
@ -73,6 +75,8 @@ namespace osu.Game.Screens.Edit.Setup
{
if (file.NewValue != null)
this.HidePopover();
chooserPath = file.NewValue?.DirectoryName;
}
Task ICanAcceptFiles.Import(params string[] paths)
@ -100,16 +104,16 @@ namespace osu.Game.Screens.Edit.Setup
OnFocused = this.ShowPopover,
};
public Popover GetPopover() => new FileChooserPopover(handledExtensions, Current);
public Popover GetPopover() => new FileChooserPopover(handledExtensions, Current, chooserPath);
private class FileChooserPopover : OsuPopover
{
public FileChooserPopover(string[] handledExtensions, Bindable<FileInfo?> currentFile)
public FileChooserPopover(string[] handledExtensions, Bindable<FileInfo?> currentFile, string? chooserPath)
{
Child = new Container
{
Size = new Vector2(600, 400),
Child = new OsuFileSelector(currentFile.Value?.DirectoryName, handledExtensions)
Child = new OsuFileSelector(chooserPath, handledExtensions)
{
RelativeSizeAxes = Axes.Both,
CurrentFile = { BindTarget = currentFile }