mirror of
https://github.com/ppy/osu.git
synced 2025-02-05 07:53:22 +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");
|
public static LocalisableString ImportTitle => new TranslatableString(getKey(@"import_title"), @"Import");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// "Import content from stable"
|
/// "Import content from previous version"
|
||||||
/// </summary>
|
/// </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}";
|
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||||
}
|
}
|
||||||
|
@ -34,11 +34,11 @@ namespace osu.Game.Overlays.FirstRunSetup
|
|||||||
|
|
||||||
private ProgressRoundedButton importButton = null!;
|
private ProgressRoundedButton importButton = null!;
|
||||||
|
|
||||||
|
private OsuTextFlowContainer progressText = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private LegacyImportManager legacyImportManager { get; set; } = null!;
|
private LegacyImportManager legacyImportManager { get; set; } = null!;
|
||||||
|
|
||||||
private CancellationTokenSource? stablePathUpdateCancellation;
|
|
||||||
|
|
||||||
private StableLocatorLabelledTextBox stableLocatorTextBox = null!;
|
private StableLocatorLabelledTextBox stableLocatorTextBox = null!;
|
||||||
|
|
||||||
private IEnumerable<ImportCheckbox> contentCheckboxes => Content.Children.OfType<ImportCheckbox>();
|
private IEnumerable<ImportCheckbox> contentCheckboxes => Content.Children.OfType<ImportCheckbox>();
|
||||||
@ -70,9 +70,18 @@ namespace osu.Game.Overlays.FirstRunSetup
|
|||||||
Size = button_size,
|
Size = button_size,
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
Text = FirstRunSetupOverlayStrings.ImportContentFromStable,
|
Text = FirstRunSetupOverlayStrings.ImportContentFromPreviousVersion,
|
||||||
Action = runImport
|
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);
|
stableLocatorTextBox.Current.BindValueChanged(_ => updateStablePath(), true);
|
||||||
@ -80,17 +89,14 @@ namespace osu.Game.Overlays.FirstRunSetup
|
|||||||
|
|
||||||
private void updateStablePath()
|
private void updateStablePath()
|
||||||
{
|
{
|
||||||
stablePathUpdateCancellation?.Cancel();
|
|
||||||
|
|
||||||
var storage = legacyImportManager.GetCurrentStableStorage();
|
var storage = legacyImportManager.GetCurrentStableStorage();
|
||||||
|
|
||||||
if (storage == null)
|
if (storage == null)
|
||||||
{
|
{
|
||||||
foreach (var c in contentCheckboxes)
|
allowInteraction(false);
|
||||||
c.Current.Disabled = true;
|
|
||||||
|
|
||||||
|
stableLocatorTextBox.Current.Disabled = false;
|
||||||
stableLocatorTextBox.Current.Value = string.Empty;
|
stableLocatorTextBox.Current.Value = string.Empty;
|
||||||
importButton.Enabled.Value = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,16 +106,15 @@ namespace osu.Game.Overlays.FirstRunSetup
|
|||||||
c.UpdateCount();
|
c.UpdateCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
allowInteraction(true);
|
||||||
stableLocatorTextBox.Current.Value = storage.GetFullPath(string.Empty);
|
stableLocatorTextBox.Current.Value = storage.GetFullPath(string.Empty);
|
||||||
|
|
||||||
stablePathUpdateCancellation = new CancellationTokenSource();
|
|
||||||
importButton.Enabled.Value = true;
|
importButton.Enabled.Value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runImport()
|
private void runImport()
|
||||||
{
|
{
|
||||||
importButton.Enabled.Value = false;
|
allowInteraction(false);
|
||||||
stableLocatorTextBox.Current.Disabled = true;
|
progressText.FadeIn(1000, Easing.OutQuint);
|
||||||
|
|
||||||
StableContent importableContent = 0;
|
StableContent importableContent = 0;
|
||||||
|
|
||||||
@ -118,17 +123,26 @@ namespace osu.Game.Overlays.FirstRunSetup
|
|||||||
|
|
||||||
legacyImportManager.ImportFromStableAsync(importableContent, false).ContinueWith(t => Schedule(() =>
|
legacyImportManager.ImportFromStableAsync(importableContent, false).ContinueWith(t => Schedule(() =>
|
||||||
{
|
{
|
||||||
|
progressText.FadeOut(500, Easing.OutQuint);
|
||||||
|
|
||||||
if (t.IsCompletedSuccessfully)
|
if (t.IsCompletedSuccessfully)
|
||||||
importButton.Complete();
|
importButton.Complete();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
importButton.Enabled.Value = true;
|
allowInteraction(true);
|
||||||
stableLocatorTextBox.Current.Disabled = false;
|
|
||||||
importButton.Abort();
|
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
|
private class ImportCheckbox : SettingsCheckbox
|
||||||
{
|
{
|
||||||
public readonly StableContent StableContent;
|
public readonly StableContent StableContent;
|
||||||
|
Loading…
Reference in New Issue
Block a user