From abe5a67bc5329702dd7b0176655b8796c1419c0b Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Fri, 4 Dec 2020 03:14:07 +0800 Subject: [PATCH 1/4] Simplify implementation --- osu.Game/Screens/Import/FileImportScreen.cs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/osu.Game/Screens/Import/FileImportScreen.cs b/osu.Game/Screens/Import/FileImportScreen.cs index a59688a2a948..211605e5c977 100644 --- a/osu.Game/Screens/Import/FileImportScreen.cs +++ b/osu.Game/Screens/Import/FileImportScreen.cs @@ -45,6 +45,7 @@ private void load(Storage storage) var originalPath = storage.GetFullPath("imports", true); string[] fileExtensions = { ".osk", ".osr", ".osz" }; defaultPath = originalPath; + var directory = currentDirectory.Value?.FullName ?? defaultPath; InternalChild = contentContainer = new Container { @@ -67,6 +68,10 @@ private void load(Storage storage) Width = 0.65f, Anchor = Anchor.TopLeft, Origin = Anchor.TopLeft, + Child = fileSelector = new FileSelector(initialPath: directory, validFileExtensions: fileExtensions) + { + RelativeSizeAxes = Axes.Both + } }, new Container { @@ -169,21 +174,9 @@ private void load(Storage storage) { 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); currentFile.BindTo(fileSelector.CurrentFile); - - fileSelectContainer.Add(fileSelector); } private void updateFileSelectionText(ValueChangedEvent v) From 85de1a1d20cc5299a3c9443ff422da320d92d384 Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Fri, 4 Dec 2020 03:19:20 +0800 Subject: [PATCH 2/4] Animation changes --- osu.Game/Screens/Import/FileImportScreen.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Import/FileImportScreen.cs b/osu.Game/Screens/Import/FileImportScreen.cs index 211605e5c977..9fb8e22977a9 100644 --- a/osu.Game/Screens/Import/FileImportScreen.cs +++ b/osu.Game/Screens/Import/FileImportScreen.cs @@ -188,17 +188,16 @@ public override void OnEntering(IScreen last) { base.OnEntering(last); - contentContainer.FadeOut().Then().ScaleTo(0.8f).RotateTo(-15).MoveToX(300) + contentContainer.FadeOut().Then().ScaleTo(0.95f) .Then() - .ScaleTo(1, 1500, Easing.OutElastic) - .FadeIn(500) - .MoveToX(0, 500, Easing.OutQuint) - .RotateTo(0, 500, Easing.OutQuint); + .ScaleTo(1, 300, Easing.OutQuint) + .FadeIn(300); } 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, 300, Easing.OutQuint) + .FadeOut(300); this.FadeOut(500, Easing.OutExpo); return base.OnExiting(next); From fb080284d2a03c3861d8c2430436c8a30c48d9a2 Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Fri, 4 Dec 2020 04:10:08 +0800 Subject: [PATCH 3/4] Simplify UI implementation --- osu.Game/Screens/Import/FileImportScreen.cs | 153 +++++++------------- 1 file changed, 54 insertions(+), 99 deletions(-) diff --git a/osu.Game/Screens/Import/FileImportScreen.cs b/osu.Game/Screens/Import/FileImportScreen.cs index 9fb8e22977a9..9af87887b230 100644 --- a/osu.Game/Screens/Import/FileImportScreen.cs +++ b/osu.Game/Screens/Import/FileImportScreen.cs @@ -13,7 +13,6 @@ using osu.Game.Graphics; using osu.Game.Graphics.UserInterfaceV2; using osuTK; -using osu.Game.Overlays; using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.Containers; using osuTK.Graphics; @@ -22,30 +21,32 @@ namespace osu.Game.Screens.Import { public class FileImportScreen : OsuScreen { - private Container contentContainer; - private FileSelector fileSelector; - private Container fileSelectContainer; - public override bool HideOverlaysOnEnter => true; - private string defaultPath; private readonly Bindable currentFile = new Bindable(); private readonly IBindable currentDirectory = new Bindable(); + + private FileSelector fileSelector; + private Container contentContainer; private TextFlowContainer currentFileText; 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] private OsuGameBase gameBase { get; set; } + [Resolved] + private OsuColour colours { get; set; } + [BackgroundDependencyLoader(true)] private void load(Storage storage) { storage.GetStorageForDirectory("imports"); var originalPath = storage.GetFullPath("imports", true); string[] fileExtensions = { ".osk", ".osr", ".osz" }; - defaultPath = originalPath; - var directory = currentDirectory.Value?.FullName ?? defaultPath; InternalChild = contentContainer = new Container { @@ -59,19 +60,13 @@ private void load(Storage storage) { new Box { - Colour = overlayColourProvider.Background5, + Colour = colours.GreySeafoamDark, RelativeSizeAxes = Axes.Both, }, - fileSelectContainer = new Container + fileSelector = new FileSelector(initialPath: originalPath, validFileExtensions: fileExtensions) { RelativeSizeAxes = Axes.Both, - Width = 0.65f, - Anchor = Anchor.TopLeft, - Origin = Anchor.TopLeft, - Child = fileSelector = new FileSelector(initialPath: directory, validFileExtensions: fileExtensions) - { - RelativeSizeAxes = Axes.Both - } + Width = 0.65f }, new Container { @@ -79,87 +74,48 @@ private void load(Storage storage) Width = 0.35f, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, - Masking = true, - CornerRadius = 10, Children = new Drawable[] { - new GridContainer + new Box + { + Colour = colours.GreySeafoamDarker, + RelativeSizeAxes = Axes.Both + }, + new Container { RelativeSizeAxes = Axes.Both, - RowDimensions = new[] - { - new Dimension(), - new Dimension(GridSizeMode.AutoSize), - }, - Content = new[] + Padding = new MarginPadding { Bottom = button_height + button_vertical_margin * 2 }, + Child = fileNameScroll = new OsuScrollContainer { - new Drawable[] + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Child = currentFileText = new TextFlowContainer(t => t.Font = OsuFont.Default.With(size: 30)) { - new Container - { - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - 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 - }, - }, - } - }, + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + TextAnchor = Anchor.Centre }, - new Drawable[] - { - new Container - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Margin = new MarginPadding { Bottom = 15, Top = 15 }, - Children = new Drawable[] - { - new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Children = new Drawable[] - { - new TriangleButton - { - Text = "Import", - 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); - } - } - } - } - } - } - } + }, + }, + new TriangleButton + { + Text = "Import", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + Height = button_height, + Width = 0.9f, + Margin = new MarginPadding { Vertical = button_vertical_margin }, + Action = () => + { + var d = currentFile.Value?.FullName; + if (d != null) + startImport(d); + else + currentFileText.FlashColour(Color4.Red, 500); } } } @@ -190,15 +146,14 @@ public override void OnEntering(IScreen last) contentContainer.FadeOut().Then().ScaleTo(0.95f) .Then() - .ScaleTo(1, 300, Easing.OutQuint) - .FadeIn(300); + .ScaleTo(1, duration, Easing.OutQuint) + .FadeIn(duration); } public override bool OnExiting(IScreen next) { - contentContainer.ScaleTo(0.95f, 300, Easing.OutQuint) - .FadeOut(300); - this.FadeOut(500, Easing.OutExpo); + contentContainer.ScaleTo(0.95f, duration, Easing.OutQuint); + this.FadeOut(duration, Easing.OutQuint); return base.OnExiting(next); } @@ -210,8 +165,8 @@ private void startImport(string path) if (!File.Exists(path)) { - currentFileText.Text = "File not exist"; - currentFileText.FlashColour(Color4.Red, 500); + currentFileText.Text = "No such file"; + currentFileText.FlashColour(colours.Red, duration); return; } From 7104230ae3645392e051e1b998fb6c4bb809aabb Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Fri, 4 Dec 2020 19:52:25 +0800 Subject: [PATCH 4/4] Add "onCurrentDirectoryChanged" --- osu.Game/Screens/Import/FileImportScreen.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Import/FileImportScreen.cs b/osu.Game/Screens/Import/FileImportScreen.cs index 9af87887b230..e2e2b699f527 100644 --- a/osu.Game/Screens/Import/FileImportScreen.cs +++ b/osu.Game/Screens/Import/FileImportScreen.cs @@ -126,15 +126,17 @@ private void load(Storage storage) fileNameScroll.ScrollContent.Origin = Anchor.Centre; currentFile.BindValueChanged(updateFileSelectionText, true); - currentDirectory.BindValueChanged(_ => - { - currentFile.Value = null; - }); + currentDirectory.BindValueChanged(onCurrentDirectoryChanged); currentDirectory.BindTo(fileSelector.CurrentPath); currentFile.BindTo(fileSelector.CurrentFile); } + private void onCurrentDirectoryChanged(ValueChangedEvent v) + { + currentFile.Value = null; + } + private void updateFileSelectionText(ValueChangedEvent v) { currentFileText.Text = v.NewValue?.Name ?? "Select a file";