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.
|
2019-01-17 20:10:34 +08:00
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2019-06-12 01:31:01 +08:00
|
|
|
using osu.Game.Online;
|
2019-01-17 20:10:34 +08:00
|
|
|
using osuTK.Graphics;
|
|
|
|
|
2020-04-21 15:03:18 +08:00
|
|
|
namespace osu.Game.Overlays.BeatmapListing.Panels
|
2019-01-17 20:10:34 +08:00
|
|
|
{
|
2019-06-12 01:31:01 +08:00
|
|
|
public class DownloadProgressBar : BeatmapDownloadTrackingComposite
|
2019-01-17 20:10:34 +08:00
|
|
|
{
|
|
|
|
private readonly ProgressBar progressBar;
|
|
|
|
|
2019-01-18 13:28:06 +08:00
|
|
|
public DownloadProgressBar(BeatmapSetInfo beatmapSet)
|
|
|
|
: base(beatmapSet)
|
2019-01-17 20:10:34 +08:00
|
|
|
{
|
2021-01-18 15:46:48 +08:00
|
|
|
AddInternal(progressBar = new ProgressBar(false)
|
2019-01-17 20:10:34 +08:00
|
|
|
{
|
|
|
|
Height = 0,
|
|
|
|
Alpha = 0,
|
|
|
|
});
|
|
|
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader(true)]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
progressBar.FillColour = colours.Blue;
|
|
|
|
progressBar.BackgroundColour = Color4.Black.Opacity(0.7f);
|
2019-01-18 13:28:06 +08:00
|
|
|
progressBar.Current = Progress;
|
2019-01-17 20:10:34 +08:00
|
|
|
|
2019-02-22 19:13:38 +08:00
|
|
|
State.BindValueChanged(state =>
|
2019-01-18 13:28:06 +08:00
|
|
|
{
|
2019-02-22 19:13:38 +08:00
|
|
|
switch (state.NewValue)
|
2019-01-18 13:28:06 +08:00
|
|
|
{
|
|
|
|
case DownloadState.NotDownloaded:
|
|
|
|
progressBar.Current.Value = 0;
|
|
|
|
progressBar.FadeOut(500);
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
2019-01-18 13:28:06 +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
|
|
|
|
2021-01-13 23:04:29 +08:00
|
|
|
case DownloadState.Importing:
|
2019-01-31 18:09:04 +08:00
|
|
|
progressBar.FadeIn(400, Easing.OutQuint);
|
2019-01-31 18:15:17 +08:00
|
|
|
progressBar.ResizeHeightTo(4, 400, Easing.OutQuint);
|
|
|
|
|
2019-01-18 13:28:06 +08:00
|
|
|
progressBar.Current.Value = 1;
|
|
|
|
progressBar.FillColour = colours.Yellow;
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
2019-01-18 13:28:06 +08:00
|
|
|
case DownloadState.LocallyAvailable:
|
|
|
|
progressBar.FadeOut(500);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}, true);
|
2019-01-17 20:10:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|