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