mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Add tutorial download support and improve the visuals "slightly"
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user