1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 05:02:55 +08:00

Expose CurrentDirectory bindable for consumption

This commit is contained in:
Dean Herbert 2020-05-13 22:57:31 +09:00
parent 75777d22d2
commit 6bb06e9d61

View File

@ -28,11 +28,11 @@ namespace osu.Game.Graphics.UserInterfaceV2
private GameHost host { get; set; }
[Cached]
private readonly Bindable<DirectoryInfo> currentDirectory = new Bindable<DirectoryInfo>();
public readonly Bindable<DirectoryInfo> CurrentDirectory = new Bindable<DirectoryInfo>();
public DirectorySelector(string initialPath = null)
{
currentDirectory.Value = new DirectoryInfo(initialPath ?? Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
CurrentDirectory.Value = new DirectoryInfo(initialPath ?? Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
}
[BackgroundDependencyLoader]
@ -68,7 +68,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
},
};
currentDirectory.BindValueChanged(updateDisplay, true);
CurrentDirectory.BindValueChanged(updateDisplay, true);
}
private void updateDisplay(ValueChangedEvent<DirectoryInfo> directory)
@ -86,9 +86,9 @@ namespace osu.Game.Graphics.UserInterfaceV2
}
else
{
directoryFlow.Add(new ParentDirectoryPiece(currentDirectory.Value.Parent));
directoryFlow.Add(new ParentDirectoryPiece(CurrentDirectory.Value.Parent));
foreach (var dir in currentDirectory.Value.GetDirectories().OrderBy(d => d.Name))
foreach (var dir in CurrentDirectory.Value.GetDirectories().OrderBy(d => d.Name))
{
if ((dir.Attributes & FileAttributes.Hidden) == 0)
directoryFlow.Add(new DirectoryPiece(dir));
@ -97,8 +97,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
}
catch (Exception)
{
currentDirectory.Value = directory.OldValue;
CurrentDirectory.Value = directory.OldValue;
this.FlashColour(Color4.Red, 300);
}
}