mirror of
https://github.com/osukey/osukey.git
synced 2025-05-08 07:07:18 +09:00
112 lines
4.8 KiB
C#
112 lines
4.8 KiB
C#
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
#nullable enable
|
|
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Extensions;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Localisation;
|
|
using osu.Game.Database;
|
|
using osu.Game.Graphics;
|
|
using osu.Game.Graphics.Containers;
|
|
using osu.Game.Localisation;
|
|
using osu.Game.Overlays.Settings;
|
|
using osuTK;
|
|
|
|
namespace osu.Game.Overlays.FirstRunSetup
|
|
{
|
|
[LocalisableDescription(typeof(FirstRunSetupOverlayStrings), nameof(FirstRunSetupOverlayStrings.ImportTitle))]
|
|
public class ScreenImportFromStable : FirstRunSetupScreen
|
|
{
|
|
private ProgressRoundedButton importButton = null!;
|
|
|
|
private SettingsCheckbox checkboxSkins = null!;
|
|
private SettingsCheckbox checkboxBeatmaps = null!;
|
|
private SettingsCheckbox checkboxScores = null!;
|
|
private SettingsCheckbox checkboxCollections = null!;
|
|
|
|
[Resolved]
|
|
private OsuColour colours { get; set; } = null!;
|
|
|
|
[Resolved]
|
|
private LegacyImportManager legacyImportManager { get; set; } = null!;
|
|
|
|
[BackgroundDependencyLoader(permitNulls: true)]
|
|
private void load()
|
|
{
|
|
Vector2 buttonSize = new Vector2(400, 50);
|
|
|
|
Content.Children = new Drawable[]
|
|
{
|
|
new OsuTextFlowContainer(cp => cp.Font = OsuFont.Default.With(size: CONTENT_FONT_SIZE))
|
|
{
|
|
Colour = OverlayColourProvider.Content1,
|
|
Text =
|
|
"If you have an installation of a previous osu! version, you can choose to migrate your existing content. Note that this will create a copy, and not affect your existing installation.",
|
|
RelativeSizeAxes = Axes.X,
|
|
AutoSizeAxes = Axes.Y
|
|
},
|
|
checkboxBeatmaps = new SettingsCheckbox
|
|
{
|
|
LabelText = "Beatmaps",
|
|
Current = { Value = true }
|
|
},
|
|
checkboxScores = new SettingsCheckbox
|
|
{
|
|
LabelText = "Scores",
|
|
Current = { Value = true }
|
|
},
|
|
checkboxSkins = new SettingsCheckbox
|
|
{
|
|
LabelText = "Skins",
|
|
Current = { Value = true }
|
|
},
|
|
checkboxCollections = new SettingsCheckbox
|
|
{
|
|
LabelText = "Collections",
|
|
Current = { Value = true }
|
|
},
|
|
importButton = new ProgressRoundedButton
|
|
{
|
|
Size = buttonSize,
|
|
Anchor = Anchor.TopCentre,
|
|
Origin = Anchor.TopCentre,
|
|
BackgroundColour = colours.Blue3,
|
|
Text = FirstRunSetupOverlayStrings.ImportContentFromStable,
|
|
Action = runImport
|
|
},
|
|
};
|
|
|
|
legacyImportManager.GetImportCount(StableContent.Beatmaps).ContinueWith(task => Schedule(() => checkboxBeatmaps.LabelText += $" ({task.GetResultSafely()} items)"));
|
|
legacyImportManager.GetImportCount(StableContent.Scores).ContinueWith(task => Schedule(() => checkboxScores.LabelText += $" ({task.GetResultSafely()} items)"));
|
|
legacyImportManager.GetImportCount(StableContent.Skins).ContinueWith(task => Schedule(() => checkboxSkins.LabelText += $" ({task.GetResultSafely()} items)"));
|
|
legacyImportManager.GetImportCount(StableContent.Collections).ContinueWith(task => Schedule(() => checkboxCollections.LabelText += $" ({task.GetResultSafely()} items)"));
|
|
}
|
|
|
|
private void runImport()
|
|
{
|
|
importButton.Enabled.Value = false;
|
|
|
|
StableContent importableContent = 0;
|
|
|
|
if (checkboxBeatmaps.Current.Value) importableContent |= StableContent.Beatmaps;
|
|
if (checkboxScores.Current.Value) importableContent |= StableContent.Scores;
|
|
if (checkboxSkins.Current.Value) importableContent |= StableContent.Skins;
|
|
if (checkboxCollections.Current.Value) importableContent |= StableContent.Collections;
|
|
|
|
legacyImportManager.ImportFromStableAsync(importableContent)
|
|
.ContinueWith(t => Schedule(() =>
|
|
{
|
|
if (t.IsCompletedSuccessfully)
|
|
importButton.Complete();
|
|
else
|
|
{
|
|
importButton.Enabled.Value = true;
|
|
importButton.Abort();
|
|
}
|
|
}));
|
|
}
|
|
}
|
|
}
|