From c0de1f96ff2158a293fc546a11b729d84ea4df77 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 17 May 2022 17:26:44 +0900 Subject: [PATCH] Tidy up interaction toggling and add progress message --- .../FirstRunSetupOverlayStrings.cs | 4 +- .../FirstRunSetup/ScreenImportFromStable.cs | 42 ++++++++++++------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/osu.Game/Localisation/FirstRunSetupOverlayStrings.cs b/osu.Game/Localisation/FirstRunSetupOverlayStrings.cs index 6b5ca7534d..181e35e4ce 100644 --- a/osu.Game/Localisation/FirstRunSetupOverlayStrings.cs +++ b/osu.Game/Localisation/FirstRunSetupOverlayStrings.cs @@ -80,9 +80,9 @@ We recommend you give the new defaults a try, but if you'd like to have things f public static LocalisableString ImportTitle => new TranslatableString(getKey(@"import_title"), @"Import"); /// - /// "Import content from stable" + /// "Import content from previous version" /// - public static LocalisableString ImportContentFromStable => new TranslatableString(getKey(@"import_content_from_stable"), @"Import content from osu!(stable)"); + public static LocalisableString ImportContentFromPreviousVersion => new TranslatableString(getKey(@"import_content_from_previous_version"), @"Import content from previous version"); private static string getKey(string key) => $@"{prefix}:{key}"; } diff --git a/osu.Game/Overlays/FirstRunSetup/ScreenImportFromStable.cs b/osu.Game/Overlays/FirstRunSetup/ScreenImportFromStable.cs index 7791c3614e..3b3cf4caf7 100644 --- a/osu.Game/Overlays/FirstRunSetup/ScreenImportFromStable.cs +++ b/osu.Game/Overlays/FirstRunSetup/ScreenImportFromStable.cs @@ -34,11 +34,11 @@ namespace osu.Game.Overlays.FirstRunSetup private ProgressRoundedButton importButton = null!; + private OsuTextFlowContainer progressText = null!; + [Resolved] private LegacyImportManager legacyImportManager { get; set; } = null!; - private CancellationTokenSource? stablePathUpdateCancellation; - private StableLocatorLabelledTextBox stableLocatorTextBox = null!; private IEnumerable contentCheckboxes => Content.Children.OfType(); @@ -70,9 +70,18 @@ namespace osu.Game.Overlays.FirstRunSetup Size = button_size, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - Text = FirstRunSetupOverlayStrings.ImportContentFromStable, + Text = FirstRunSetupOverlayStrings.ImportContentFromPreviousVersion, Action = runImport }, + progressText = new OsuTextFlowContainer(cp => cp.Font = OsuFont.Default.With(size: CONTENT_FONT_SIZE)) + { + Colour = OverlayColourProvider.Content1, + Text = + "Your import will continue in the background. Check on its progress in the notifications sidebar!", + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Alpha = 0, + }, }; stableLocatorTextBox.Current.BindValueChanged(_ => updateStablePath(), true); @@ -80,17 +89,14 @@ namespace osu.Game.Overlays.FirstRunSetup private void updateStablePath() { - stablePathUpdateCancellation?.Cancel(); - var storage = legacyImportManager.GetCurrentStableStorage(); if (storage == null) { - foreach (var c in contentCheckboxes) - c.Current.Disabled = true; + allowInteraction(false); + stableLocatorTextBox.Current.Disabled = false; stableLocatorTextBox.Current.Value = string.Empty; - importButton.Enabled.Value = false; return; } @@ -100,16 +106,15 @@ namespace osu.Game.Overlays.FirstRunSetup c.UpdateCount(); } + allowInteraction(true); stableLocatorTextBox.Current.Value = storage.GetFullPath(string.Empty); - - stablePathUpdateCancellation = new CancellationTokenSource(); importButton.Enabled.Value = true; } private void runImport() { - importButton.Enabled.Value = false; - stableLocatorTextBox.Current.Disabled = true; + allowInteraction(false); + progressText.FadeIn(1000, Easing.OutQuint); StableContent importableContent = 0; @@ -118,17 +123,26 @@ namespace osu.Game.Overlays.FirstRunSetup legacyImportManager.ImportFromStableAsync(importableContent, false).ContinueWith(t => Schedule(() => { + progressText.FadeOut(500, Easing.OutQuint); + if (t.IsCompletedSuccessfully) importButton.Complete(); else { - importButton.Enabled.Value = true; - stableLocatorTextBox.Current.Disabled = false; + allowInteraction(true); importButton.Abort(); } })); } + private void allowInteraction(bool allow) + { + importButton.Enabled.Value = allow; + stableLocatorTextBox.Current.Disabled = !allow; + foreach (var c in contentCheckboxes) + c.Current.Disabled = !allow; + } + private class ImportCheckbox : SettingsCheckbox { public readonly StableContent StableContent;