mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 07:02:54 +08:00
Expose CurrentDirectory bindable for consumption
This commit is contained in:
parent
75777d22d2
commit
6bb06e9d61
@ -28,11 +28,11 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
|||||||
private GameHost host { get; set; }
|
private GameHost host { get; set; }
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
private readonly Bindable<DirectoryInfo> currentDirectory = new Bindable<DirectoryInfo>();
|
public readonly Bindable<DirectoryInfo> CurrentDirectory = new Bindable<DirectoryInfo>();
|
||||||
|
|
||||||
public DirectorySelector(string initialPath = null)
|
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]
|
[BackgroundDependencyLoader]
|
||||||
@ -68,7 +68,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
currentDirectory.BindValueChanged(updateDisplay, true);
|
CurrentDirectory.BindValueChanged(updateDisplay, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDisplay(ValueChangedEvent<DirectoryInfo> directory)
|
private void updateDisplay(ValueChangedEvent<DirectoryInfo> directory)
|
||||||
@ -86,9 +86,9 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
|||||||
}
|
}
|
||||||
else
|
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)
|
if ((dir.Attributes & FileAttributes.Hidden) == 0)
|
||||||
directoryFlow.Add(new DirectoryPiece(dir));
|
directoryFlow.Add(new DirectoryPiece(dir));
|
||||||
@ -97,8 +97,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
|||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
currentDirectory.Value = directory.OldValue;
|
CurrentDirectory.Value = directory.OldValue;
|
||||||
|
|
||||||
this.FlashColour(Color4.Red, 300);
|
this.FlashColour(Color4.Red, 300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user