1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 22:32:55 +08:00

Simplify implementation

This commit is contained in:
MATRIX-feather 2020-12-04 03:14:07 +08:00
parent 579e61eab9
commit abe5a67bc5

View File

@ -45,6 +45,7 @@ namespace osu.Game.Screens.Import
var originalPath = storage.GetFullPath("imports", true); var originalPath = storage.GetFullPath("imports", true);
string[] fileExtensions = { ".osk", ".osr", ".osz" }; string[] fileExtensions = { ".osk", ".osr", ".osz" };
defaultPath = originalPath; defaultPath = originalPath;
var directory = currentDirectory.Value?.FullName ?? defaultPath;
InternalChild = contentContainer = new Container InternalChild = contentContainer = new Container
{ {
@ -67,6 +68,10 @@ namespace osu.Game.Screens.Import
Width = 0.65f, Width = 0.65f,
Anchor = Anchor.TopLeft, Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft, Origin = Anchor.TopLeft,
Child = fileSelector = new FileSelector(initialPath: directory, validFileExtensions: fileExtensions)
{
RelativeSizeAxes = Axes.Both
}
}, },
new Container new Container
{ {
@ -169,21 +174,9 @@ namespace osu.Game.Screens.Import
{ {
currentFile.Value = null; currentFile.Value = null;
}); });
currentFile.UnbindBindings();
currentDirectory.UnbindBindings();
fileSelector?.Expire();
var directory = currentDirectory.Value?.FullName ?? defaultPath;
fileSelector = new FileSelector(initialPath: directory, validFileExtensions: fileExtensions)
{
RelativeSizeAxes = Axes.Both
};
currentDirectory.BindTo(fileSelector.CurrentPath); currentDirectory.BindTo(fileSelector.CurrentPath);
currentFile.BindTo(fileSelector.CurrentFile); currentFile.BindTo(fileSelector.CurrentFile);
fileSelectContainer.Add(fileSelector);
} }
private void updateFileSelectionText(ValueChangedEvent<FileInfo> v) private void updateFileSelectionText(ValueChangedEvent<FileInfo> v)