mirror of
https://github.com/ppy/osu
synced 2024-12-29 02:12:43 +00:00
Add tutorial download support and improve the visuals "slightly"
This commit is contained in:
parent
b424d20f26
commit
58399a5113
@ -17,7 +17,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddStep("Create downloader", () =>
|
||||
{
|
||||
downloader?.Expire();
|
||||
Add(downloader = new BundledBeatmapDownloader());
|
||||
Add(downloader = new BundledBeatmapDownloader(false));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -22,15 +22,34 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
|
||||
private readonly List<BeatmapDownloadTracker> downloadTrackers = new List<BeatmapDownloadTracker>();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(BeatmapManager beatmapManager, IAPIProvider api, INotificationOverlay notifications)
|
||||
{
|
||||
var beatmapDownloader = new BundledBeatmapModelDownloader(beatmapManager, api)
|
||||
{
|
||||
PostNotification = notifications.Post
|
||||
};
|
||||
private readonly List<string> downloadableFilenames = new List<string>();
|
||||
|
||||
foreach (string filename in bundled_beatmap_filenames.OrderBy(_ => RNG.NextSingle()).Take(10))
|
||||
private BundledBeatmapModelDownloader beatmapDownloader;
|
||||
|
||||
public BundledBeatmapDownloader(bool onlyTutorial)
|
||||
{
|
||||
if (onlyTutorial)
|
||||
downloadableFilenames.Add(tutorial_filename);
|
||||
else
|
||||
downloadableFilenames.AddRange(bundled_beatmap_filenames);
|
||||
}
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
var localDependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||
|
||||
localDependencies.CacheAs<BeatmapModelDownloader>(beatmapDownloader = new BundledBeatmapModelDownloader(parent.Get<BeatmapManager>(), parent.Get<IAPIProvider>())
|
||||
{
|
||||
PostNotification = parent.Get<INotificationOverlay>().Post
|
||||
});
|
||||
|
||||
return localDependencies;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
foreach (string filename in downloadableFilenames.OrderBy(_ => RNG.NextSingle()).Take(10))
|
||||
{
|
||||
var match = Regex.Match(filename, @"([0-9]*) (.*) - (.*)\.osz");
|
||||
|
||||
@ -49,6 +68,8 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
}
|
||||
}
|
||||
|
||||
private const string tutorial_filename = "1011011 nekodex - new beginnings.osz";
|
||||
|
||||
private static readonly string[] bundled_beatmap_filenames =
|
||||
{
|
||||
"682286 Yuyoyuppe - Emerald Galaxy.osz",
|
||||
|
@ -9,64 +9,122 @@ using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Online;
|
||||
using osuTK.Graphics;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.FirstRunSetup
|
||||
{
|
||||
[Description("Bundled Beatmaps")]
|
||||
public class ScreenBundledBeatmaps : FirstRunSetupScreen
|
||||
{
|
||||
private TriangleButton downloadButton;
|
||||
private RoundedButton downloadBundledButton;
|
||||
|
||||
private ProgressBar progressBar;
|
||||
private BundledBeatmapDownloader downloader;
|
||||
private ProgressBar progressBarBundled;
|
||||
|
||||
private RoundedButton downloadTutorialButton;
|
||||
private ProgressBar progressBarTutorial;
|
||||
|
||||
private BundledBeatmapDownloader tutorialDownloader;
|
||||
private BundledBeatmapDownloader bundledDownloader;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Vector2 buttonSize = new Vector2(500, 80);
|
||||
|
||||
Content.Children = new Drawable[]
|
||||
{
|
||||
new OsuTextFlowContainer(cp => cp.Font = OsuFont.Default.With(size: 20))
|
||||
{
|
||||
Text = "osu! doesn't come with any beatmaps pre-loaded. To get started, we have some recommended beatmaps.",
|
||||
Text =
|
||||
"osu! doesn't come with any beatmaps pre-loaded. To get started, we have some recommended beatmaps. You can obtain more beatmaps from the main menu \"browse\" button at any time.",
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y
|
||||
},
|
||||
downloadButton = new TriangleButton
|
||||
downloadTutorialButton = new RoundedButton
|
||||
{
|
||||
Width = 300,
|
||||
Size = buttonSize,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Text = "Download beatmap selection",
|
||||
Action = download
|
||||
BackgroundColour = colours.Pink3,
|
||||
Text = "Download tutorial",
|
||||
Action = downloadTutorial
|
||||
},
|
||||
downloadBundledButton = new RoundedButton
|
||||
{
|
||||
Size = buttonSize,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
BackgroundColour = colours.Blue3,
|
||||
Text = "Download beatmap selection",
|
||||
Action = downloadBundled
|
||||
},
|
||||
// TODO: add stable import button if a stable install is detected.
|
||||
};
|
||||
|
||||
downloadButton.Add(progressBar = new ProgressBar(false)
|
||||
downloadTutorialButton.Add(progressBarTutorial = new ProgressBar(false)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Blending = BlendingParameters.Additive,
|
||||
FillColour = Color4.Aqua,
|
||||
FillColour = downloadTutorialButton.BackgroundColour,
|
||||
Alpha = 0.5f,
|
||||
Depth = float.MinValue
|
||||
});
|
||||
|
||||
downloadBundledButton.Add(progressBarBundled = new ProgressBar(false)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Blending = BlendingParameters.Additive,
|
||||
FillColour = downloadBundledButton.BackgroundColour,
|
||||
Alpha = 0.5f,
|
||||
Depth = float.MinValue
|
||||
});
|
||||
}
|
||||
|
||||
private void download()
|
||||
private void downloadTutorial()
|
||||
{
|
||||
AddInternal(downloader = new BundledBeatmapDownloader());
|
||||
downloadButton.Enabled.Value = false;
|
||||
if (tutorialDownloader != null)
|
||||
return;
|
||||
|
||||
foreach (var tracker in downloader.DownloadTrackers)
|
||||
tracker.State.BindValueChanged(_ => updateProgress());
|
||||
tutorialDownloader = new BundledBeatmapDownloader(true);
|
||||
|
||||
AddInternal(tutorialDownloader);
|
||||
|
||||
var downloadTracker = tutorialDownloader.DownloadTrackers.First();
|
||||
|
||||
downloadTracker.Progress.BindValueChanged(progress =>
|
||||
{
|
||||
progressBarTutorial.Current.Value = progress.NewValue;
|
||||
|
||||
if (progress.NewValue == 1)
|
||||
downloadTutorialButton.Enabled.Value = false;
|
||||
}, true);
|
||||
}
|
||||
|
||||
private void updateProgress()
|
||||
private void downloadBundled()
|
||||
{
|
||||
double progress = (double)downloader.DownloadTrackers.Count(t => t.State.Value == DownloadState.LocallyAvailable) / downloader.DownloadTrackers.Count();
|
||||
if (bundledDownloader != null)
|
||||
return;
|
||||
|
||||
this.TransformBindableTo(progressBar.Current, progress, 1000, Easing.OutQuint);
|
||||
// downloadBundledButton.Enabled.Value = false;
|
||||
|
||||
bundledDownloader = new BundledBeatmapDownloader(false);
|
||||
|
||||
AddInternal(bundledDownloader);
|
||||
|
||||
foreach (var tracker in bundledDownloader.DownloadTrackers)
|
||||
tracker.State.BindValueChanged(_ => updateProgress(), true);
|
||||
|
||||
void updateProgress()
|
||||
{
|
||||
double progress = (double)bundledDownloader.DownloadTrackers.Count(t => t.State.Value == DownloadState.LocallyAvailable) / bundledDownloader.DownloadTrackers.Count();
|
||||
|
||||
this.TransformBindableTo(progressBarBundled.Current, progress, 1000, Easing.OutQuint);
|
||||
|
||||
if (progress == 1)
|
||||
downloadBundledButton.Enabled.Value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user