mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Show a spinner instead of the download button on the new card during beatmap download
This commit is contained in:
@ -54,6 +54,8 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
|||||||
|
|
||||||
protected readonly SpriteIcon Icon;
|
protected readonly SpriteIcon Icon;
|
||||||
|
|
||||||
|
protected override Container<Drawable> Content => content;
|
||||||
|
|
||||||
private readonly Container content;
|
private readonly Container content;
|
||||||
|
|
||||||
protected BeatmapCardIconButton()
|
protected BeatmapCardIconButton()
|
||||||
@ -61,7 +63,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
|||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
Anchor = Anchor.Centre;
|
Anchor = Anchor.Centre;
|
||||||
|
|
||||||
Child = content = new Container
|
base.Content.Add(content = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Masking = true,
|
Masking = true,
|
||||||
@ -75,7 +77,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
|||||||
Anchor = Anchor.Centre
|
Anchor = Anchor.Centre
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
Size = new Vector2(24);
|
Size = new Vector2(24);
|
||||||
IconSize = 12;
|
IconSize = 12;
|
||||||
|
@ -3,14 +3,17 @@
|
|||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online;
|
using osu.Game.Online;
|
||||||
using osu.Game.Resources.Localisation.Web;
|
using osu.Game.Resources.Localisation.Web;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
||||||
{
|
{
|
||||||
@ -23,6 +26,8 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
|||||||
|
|
||||||
private Bindable<bool> preferNoVideo = null!;
|
private Bindable<bool> preferNoVideo = null!;
|
||||||
|
|
||||||
|
private readonly LoadingSpinner spinner;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapModelDownloader beatmaps { get; set; } = null!;
|
private BeatmapModelDownloader beatmaps { get; set; } = null!;
|
||||||
|
|
||||||
@ -30,6 +35,8 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
|||||||
{
|
{
|
||||||
Icon.Icon = FontAwesome.Solid.Download;
|
Icon.Icon = FontAwesome.Solid.Download;
|
||||||
|
|
||||||
|
Content.Add(spinner = new LoadingSpinner { Size = new Vector2(IconSize) });
|
||||||
|
|
||||||
this.beatmapSet = beatmapSet;
|
this.beatmapSet = beatmapSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,8 +56,23 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
|||||||
|
|
||||||
private void updateState()
|
private void updateState()
|
||||||
{
|
{
|
||||||
this.FadeTo(state.Value != DownloadState.LocallyAvailable ? 1 : 0, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
|
switch (state.Value)
|
||||||
|
{
|
||||||
|
case DownloadState.Downloading:
|
||||||
|
case DownloadState.Importing:
|
||||||
|
Action = null;
|
||||||
|
TooltipText = string.Empty;
|
||||||
|
spinner.Show();
|
||||||
|
Icon.Hide();
|
||||||
|
return;
|
||||||
|
|
||||||
|
case DownloadState.LocallyAvailable:
|
||||||
|
Action = null;
|
||||||
|
TooltipText = string.Empty;
|
||||||
|
this.FadeOut(BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DownloadState.NotDownloaded:
|
||||||
if (beatmapSet.Availability.DownloadDisabled)
|
if (beatmapSet.Availability.DownloadDisabled)
|
||||||
{
|
{
|
||||||
Enabled.Value = false;
|
Enabled.Value = false;
|
||||||
@ -58,12 +80,20 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Action = () => beatmaps.Download(beatmapSet, preferNoVideo.Value);
|
||||||
|
this.FadeIn(BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
|
||||||
|
spinner.Hide();
|
||||||
|
Icon.Show();
|
||||||
|
|
||||||
if (!beatmapSet.HasVideo)
|
if (!beatmapSet.HasVideo)
|
||||||
TooltipText = BeatmapsetsStrings.PanelDownloadAll;
|
TooltipText = BeatmapsetsStrings.PanelDownloadAll;
|
||||||
else
|
else
|
||||||
TooltipText = preferNoVideo.Value ? BeatmapsetsStrings.PanelDownloadNoVideo : BeatmapsetsStrings.PanelDownloadVideo;
|
TooltipText = preferNoVideo.Value ? BeatmapsetsStrings.PanelDownloadNoVideo : BeatmapsetsStrings.PanelDownloadVideo;
|
||||||
|
break;
|
||||||
|
|
||||||
Action = () => beatmaps.Download(beatmapSet, preferNoVideo.Value);
|
default:
|
||||||
|
throw new InvalidOperationException($"Unknown {nameof(DownloadState)} specified.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user