1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-21 07:43:01 +08:00
osu-lazer/osu.Game/Beatmaps/Drawables/DownloadProgressBar.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

75 lines
2.4 KiB
C#
Raw Normal View History

2019-01-31 18:17:42 +08:00
// 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.
2022-06-17 15:37:17 +08:00
#nullable disable
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online;
using osuTK.Graphics;
namespace osu.Game.Beatmaps.Drawables
{
public class DownloadProgressBar : CompositeDrawable
{
private readonly ProgressBar progressBar;
private readonly BeatmapDownloadTracker downloadTracker;
public DownloadProgressBar(IBeatmapSetInfo beatmapSet)
{
InternalChildren = new Drawable[]
{
progressBar = new ProgressBar(false)
{
Height = 0,
Alpha = 0,
},
downloadTracker = new BeatmapDownloadTracker(beatmapSet),
};
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
}
[BackgroundDependencyLoader(true)]
private void load(OsuColour colours)
{
progressBar.FillColour = colours.Blue;
progressBar.BackgroundColour = Color4.Black.Opacity(0.7f);
progressBar.Current.BindTarget = downloadTracker.Progress;
downloadTracker.State.BindValueChanged(state =>
{
switch (state.NewValue)
{
case DownloadState.NotDownloaded:
progressBar.Current.Value = 0;
progressBar.FadeOut(500);
break;
2019-04-01 11:44:46 +08:00
case DownloadState.Downloading:
progressBar.FadeIn(400, Easing.OutQuint);
progressBar.ResizeHeightTo(4, 400, Easing.OutQuint);
break;
2019-04-01 11:44:46 +08:00
case DownloadState.Importing:
2019-01-31 18:09:04 +08:00
progressBar.FadeIn(400, Easing.OutQuint);
progressBar.ResizeHeightTo(4, 400, Easing.OutQuint);
progressBar.Current.Value = 1;
progressBar.FillColour = colours.Yellow;
break;
2019-04-01 11:44:46 +08:00
case DownloadState.LocallyAvailable:
progressBar.FadeOut(500);
break;
}
}, true);
}
}
}