mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 19:32:55 +08:00
Tidy up interaction toggling and add progress message
This commit is contained in:
parent
17e0105c2c
commit
c0de1f96ff
@ -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");
|
||||
|
||||
/// <summary>
|
||||
/// "Import content from stable"
|
||||
/// "Import content from previous version"
|
||||
/// </summary>
|
||||
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}";
|
||||
}
|
||||
|
@ -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<ImportCheckbox> contentCheckboxes => Content.Children.OfType<ImportCheckbox>();
|
||||
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user