mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Rename button class and add basic progress display
This commit is contained in:
@ -72,7 +72,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new UpdateRequiredIcon(beatmapSet),
|
new UpdateBeatmapSetButton(beatmapSet),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new BeatmapSetOnlineStatusPill
|
new BeatmapSetOnlineStatusPill
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -12,15 +13,18 @@ using osu.Game.Graphics;
|
|||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select.Carousel
|
namespace osu.Game.Screens.Select.Carousel
|
||||||
{
|
{
|
||||||
public class UpdateRequiredIcon : OsuAnimatedButton
|
public class UpdateBeatmapSetButton : OsuAnimatedButton
|
||||||
{
|
{
|
||||||
private readonly BeatmapSetInfo beatmapSetInfo;
|
private readonly BeatmapSetInfo beatmapSetInfo;
|
||||||
private SpriteIcon icon;
|
private SpriteIcon icon;
|
||||||
|
|
||||||
public UpdateRequiredIcon(BeatmapSetInfo beatmapSetInfo)
|
private Box progressFill;
|
||||||
|
|
||||||
|
public UpdateBeatmapSetButton(BeatmapSetInfo beatmapSetInfo)
|
||||||
{
|
{
|
||||||
this.beatmapSetInfo = beatmapSetInfo;
|
this.beatmapSetInfo = beatmapSetInfo;
|
||||||
|
|
||||||
@ -31,7 +35,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapModelDownloader beatmaps { get; set; } = null!;
|
private BeatmapModelDownloader beatmapDownloader { get; set; } = null!;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
@ -43,6 +47,14 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
|
|
||||||
Content.AddRange(new Drawable[]
|
Content.AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
|
progressFill = new Box
|
||||||
|
{
|
||||||
|
Colour = Color4.White,
|
||||||
|
Alpha = 0.2f,
|
||||||
|
Blending = BlendingParameters.Additive,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Width = 0,
|
||||||
|
},
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
Padding = new MarginPadding { Horizontal = 5, Vertical = 3 },
|
Padding = new MarginPadding { Horizontal = 5, Vertical = 3 },
|
||||||
@ -80,7 +92,12 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
|
|
||||||
TooltipText = "Update beatmap with online changes";
|
TooltipText = "Update beatmap with online changes";
|
||||||
|
|
||||||
Action = () => beatmaps.Download(beatmapSetInfo);
|
Action = () =>
|
||||||
|
{
|
||||||
|
beatmapDownloader.Download(beatmapSetInfo);
|
||||||
|
|
||||||
|
attachExistingDownload();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -90,6 +107,19 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
icon.Spin(4000, RotationDirection.Clockwise);
|
icon.Spin(4000, RotationDirection.Clockwise);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void attachExistingDownload()
|
||||||
|
{
|
||||||
|
var download = beatmapDownloader.GetExistingDownload(beatmapSetInfo);
|
||||||
|
|
||||||
|
if (download != null)
|
||||||
|
{
|
||||||
|
Enabled.Value = false;
|
||||||
|
TooltipText = string.Empty;
|
||||||
|
|
||||||
|
download.DownloadProgressed += progress => progressFill.ResizeWidthTo(progress, 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
icon.Spin(400, RotationDirection.Clockwise);
|
icon.Spin(400, RotationDirection.Clockwise);
|
Reference in New Issue
Block a user