mirror of
https://github.com/ppy/osu.git
synced 2024-11-07 13:07:25 +08:00
Merge pull request #5 from MATRIX-feather/percydan-import-screen
This commit is contained in:
commit
5eeb4bcb48
@ -13,7 +13,6 @@ using osu.Framework.Screens;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.UserInterfaceV2;
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osu.Game.Overlays;
|
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -22,29 +21,32 @@ namespace osu.Game.Screens.Import
|
|||||||
{
|
{
|
||||||
public class FileImportScreen : OsuScreen
|
public class FileImportScreen : OsuScreen
|
||||||
{
|
{
|
||||||
private Container contentContainer;
|
|
||||||
private FileSelector fileSelector;
|
|
||||||
private Container fileSelectContainer;
|
|
||||||
|
|
||||||
public override bool HideOverlaysOnEnter => true;
|
public override bool HideOverlaysOnEnter => true;
|
||||||
|
|
||||||
private string defaultPath;
|
|
||||||
private readonly Bindable<FileInfo> currentFile = new Bindable<FileInfo>();
|
private readonly Bindable<FileInfo> currentFile = new Bindable<FileInfo>();
|
||||||
private readonly IBindable<DirectoryInfo> currentDirectory = new Bindable<DirectoryInfo>();
|
private readonly IBindable<DirectoryInfo> currentDirectory = new Bindable<DirectoryInfo>();
|
||||||
|
|
||||||
|
private FileSelector fileSelector;
|
||||||
|
private Container contentContainer;
|
||||||
private TextFlowContainer currentFileText;
|
private TextFlowContainer currentFileText;
|
||||||
private OsuScrollContainer fileNameScroll;
|
private OsuScrollContainer fileNameScroll;
|
||||||
private readonly OverlayColourProvider overlayColourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
|
|
||||||
|
private const float duration = 300;
|
||||||
|
private const float button_height = 50;
|
||||||
|
private const float button_vertical_margin = 15;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuGameBase gameBase { get; set; }
|
private OsuGameBase gameBase { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(Storage storage)
|
private void load(Storage storage)
|
||||||
{
|
{
|
||||||
storage.GetStorageForDirectory("imports");
|
storage.GetStorageForDirectory("imports");
|
||||||
var originalPath = storage.GetFullPath("imports", true);
|
var originalPath = storage.GetFullPath("imports", true);
|
||||||
string[] fileExtensions = { ".osk", ".osr", ".osz" };
|
string[] fileExtensions = { ".osk", ".osr", ".osz" };
|
||||||
defaultPath = originalPath;
|
|
||||||
|
|
||||||
InternalChild = contentContainer = new Container
|
InternalChild = contentContainer = new Container
|
||||||
{
|
{
|
||||||
@ -58,15 +60,13 @@ namespace osu.Game.Screens.Import
|
|||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
Colour = overlayColourProvider.Background5,
|
Colour = colours.GreySeafoamDark,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
},
|
},
|
||||||
fileSelectContainer = new Container
|
fileSelector = new FileSelector(initialPath: originalPath, validFileExtensions: fileExtensions)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Width = 0.65f,
|
Width = 0.65f
|
||||||
Anchor = Anchor.TopLeft,
|
|
||||||
Origin = Anchor.TopLeft,
|
|
||||||
},
|
},
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
@ -74,87 +74,48 @@ namespace osu.Game.Screens.Import
|
|||||||
Width = 0.35f,
|
Width = 0.35f,
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
Masking = true,
|
|
||||||
CornerRadius = 10,
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new GridContainer
|
new Box
|
||||||
|
{
|
||||||
|
Colour = colours.GreySeafoamDarker,
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
},
|
||||||
|
new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
RowDimensions = new[]
|
Padding = new MarginPadding { Bottom = button_height + button_vertical_margin * 2 },
|
||||||
|
Child = fileNameScroll = new OsuScrollContainer
|
||||||
{
|
{
|
||||||
new Dimension(),
|
RelativeSizeAxes = Axes.Both,
|
||||||
new Dimension(GridSizeMode.AutoSize),
|
Anchor = Anchor.TopCentre,
|
||||||
},
|
Origin = Anchor.TopCentre,
|
||||||
Content = new[]
|
Child = currentFileText = new TextFlowContainer(t => t.Font = OsuFont.Default.With(size: 30))
|
||||||
{
|
|
||||||
new Drawable[]
|
|
||||||
{
|
{
|
||||||
new Container
|
AutoSizeAxes = Axes.Y,
|
||||||
{
|
RelativeSizeAxes = Axes.X,
|
||||||
RelativeSizeAxes = Axes.Both,
|
Anchor = Anchor.Centre,
|
||||||
Anchor = Anchor.TopCentre,
|
Origin = Anchor.Centre,
|
||||||
Origin = Anchor.TopCentre,
|
TextAnchor = Anchor.Centre
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
Colour = overlayColourProvider.Background3,
|
|
||||||
RelativeSizeAxes = Axes.Both
|
|
||||||
},
|
|
||||||
fileNameScroll = new OsuScrollContainer
|
|
||||||
{
|
|
||||||
Masking = false,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Child = currentFileText = new TextFlowContainer(t => t.Font = OsuFont.Default.With(size: 30))
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
TextAnchor = Anchor.Centre
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
new Drawable[]
|
},
|
||||||
{
|
},
|
||||||
new Container
|
new TriangleButton
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
Text = "Import",
|
||||||
AutoSizeAxes = Axes.Y,
|
Anchor = Anchor.BottomCentre,
|
||||||
Margin = new MarginPadding { Bottom = 15, Top = 15 },
|
Origin = Anchor.BottomCentre,
|
||||||
Children = new Drawable[]
|
RelativeSizeAxes = Axes.X,
|
||||||
{
|
Height = button_height,
|
||||||
new FillFlowContainer
|
Width = 0.9f,
|
||||||
{
|
Margin = new MarginPadding { Vertical = button_vertical_margin },
|
||||||
RelativeSizeAxes = Axes.X,
|
Action = () =>
|
||||||
AutoSizeAxes = Axes.Y,
|
{
|
||||||
Children = new Drawable[]
|
var d = currentFile.Value?.FullName;
|
||||||
{
|
if (d != null)
|
||||||
new TriangleButton
|
startImport(d);
|
||||||
{
|
else
|
||||||
Text = "Import",
|
currentFileText.FlashColour(Color4.Red, 500);
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Height = 50,
|
|
||||||
Width = 0.9f,
|
|
||||||
Action = () =>
|
|
||||||
{
|
|
||||||
var d = currentFile.Value?.FullName;
|
|
||||||
if (d != null)
|
|
||||||
startImport(d);
|
|
||||||
else
|
|
||||||
currentFileText.FlashColour(Color4.Red, 500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,25 +126,15 @@ namespace osu.Game.Screens.Import
|
|||||||
fileNameScroll.ScrollContent.Origin = Anchor.Centre;
|
fileNameScroll.ScrollContent.Origin = Anchor.Centre;
|
||||||
|
|
||||||
currentFile.BindValueChanged(updateFileSelectionText, true);
|
currentFile.BindValueChanged(updateFileSelectionText, true);
|
||||||
currentDirectory.BindValueChanged(_ =>
|
currentDirectory.BindValueChanged(onCurrentDirectoryChanged);
|
||||||
{
|
|
||||||
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 onCurrentDirectoryChanged(ValueChangedEvent<DirectoryInfo> v)
|
||||||
|
{
|
||||||
|
currentFile.Value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFileSelectionText(ValueChangedEvent<FileInfo> v)
|
private void updateFileSelectionText(ValueChangedEvent<FileInfo> v)
|
||||||
@ -195,18 +146,16 @@ namespace osu.Game.Screens.Import
|
|||||||
{
|
{
|
||||||
base.OnEntering(last);
|
base.OnEntering(last);
|
||||||
|
|
||||||
contentContainer.FadeOut().Then().ScaleTo(0.8f).RotateTo(-15).MoveToX(300)
|
contentContainer.FadeOut().Then().ScaleTo(0.95f)
|
||||||
.Then()
|
.Then()
|
||||||
.ScaleTo(1, 1500, Easing.OutElastic)
|
.ScaleTo(1, duration, Easing.OutQuint)
|
||||||
.FadeIn(500)
|
.FadeIn(duration);
|
||||||
.MoveToX(0, 500, Easing.OutQuint)
|
|
||||||
.RotateTo(0, 500, Easing.OutQuint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool OnExiting(IScreen next)
|
public override bool OnExiting(IScreen next)
|
||||||
{
|
{
|
||||||
contentContainer.ScaleTo(0.8f, 500, Easing.OutExpo).RotateTo(-15, 500, Easing.OutExpo).MoveToX(300, 500, Easing.OutQuint).FadeOut(500);
|
contentContainer.ScaleTo(0.95f, duration, Easing.OutQuint);
|
||||||
this.FadeOut(500, Easing.OutExpo);
|
this.FadeOut(duration, Easing.OutQuint);
|
||||||
|
|
||||||
return base.OnExiting(next);
|
return base.OnExiting(next);
|
||||||
}
|
}
|
||||||
@ -218,8 +167,8 @@ namespace osu.Game.Screens.Import
|
|||||||
|
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
{
|
{
|
||||||
currentFileText.Text = "File not exist";
|
currentFileText.Text = "No such file";
|
||||||
currentFileText.FlashColour(Color4.Red, 500);
|
currentFileText.FlashColour(colours.Red, duration);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user