1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Add animation support for beatmap status pills

To be used in conjunction with https://github.com/ppy/osu/pull/22116
This commit is contained in:
Dean Herbert 2023-09-06 15:04:25 +09:00
parent 4dafd4c4a2
commit 034c887dcb
2 changed files with 53 additions and 5 deletions

View File

@ -47,7 +47,35 @@ namespace osu.Game.Tests.Visual.Beatmaps
pill.AutoSizeAxes = Axes.Y;
pill.Width = 90;
}));
AddStep("unset fixed width", () => statusPills.ForEach(pill => pill.AutoSizeAxes = Axes.Both));
}
[Test]
public void TestChangeLabels()
{
AddStep("Change labels", () =>
{
foreach (var pill in this.ChildrenOfType<BeatmapSetOnlineStatusPill>())
{
switch (pill.Status)
{
// cycle at end
case BeatmapOnlineStatus.Loved:
pill.Status = BeatmapOnlineStatus.LocallyModified;
break;
// skip none
case BeatmapOnlineStatus.LocallyModified:
pill.Status = BeatmapOnlineStatus.Graveyard;
break;
default:
pill.Status = (pill.Status + 1);
break;
}
}
});
}
}
}

View File

@ -19,6 +19,8 @@ namespace osu.Game.Beatmaps.Drawables
{
public partial class BeatmapSetOnlineStatusPill : CircularContainer, IHasTooltip
{
private const double animation_duration = 400;
private BeatmapOnlineStatus status;
public BeatmapOnlineStatus Status
@ -32,7 +34,12 @@ namespace osu.Game.Beatmaps.Drawables
status = value;
if (IsLoaded)
{
AutoSizeDuration = (float)animation_duration;
AutoSizeEasing = Easing.OutQuint;
updateState();
}
}
}
@ -61,6 +68,8 @@ namespace osu.Game.Beatmaps.Drawables
{
Masking = true;
Alpha = 0;
Children = new Drawable[]
{
background = new Box
@ -83,21 +92,32 @@ namespace osu.Game.Beatmaps.Drawables
protected override void LoadComplete()
{
base.LoadComplete();
updateState();
FinishTransforms(true);
}
private void updateState()
{
Alpha = Status == BeatmapOnlineStatus.None ? 0 : 1;
if (Status == BeatmapOnlineStatus.None)
{
this.FadeOut(animation_duration, Easing.OutQuint);
return;
}
statusText.Text = Status.GetLocalisableDescription().ToUpper();
this.FadeIn(animation_duration, Easing.OutQuint);
Color4 statusTextColour;
if (colourProvider != null)
statusText.Colour = status == BeatmapOnlineStatus.Graveyard ? colourProvider.Background1 : colourProvider.Background3;
statusTextColour = status == BeatmapOnlineStatus.Graveyard ? colourProvider.Background1 : colourProvider.Background3;
else
statusText.Colour = status == BeatmapOnlineStatus.Graveyard ? colours.GreySeaFoamLight : Color4.Black;
statusTextColour = status == BeatmapOnlineStatus.Graveyard ? colours.GreySeaFoamLight : Color4.Black;
background.Colour = OsuColour.ForBeatmapSetOnlineStatus(Status) ?? colourProvider?.Light1 ?? colours.GreySeaFoamLighter;
statusText.FadeColour(statusTextColour, animation_duration, Easing.OutQuint);
background.FadeColour(OsuColour.ForBeatmapSetOnlineStatus(Status) ?? colourProvider?.Light1 ?? colours.GreySeaFoamLighter, animation_duration, Easing.OutQuint);
statusText.Text = Status.GetLocalisableDescription().ToUpper();
}
public LocalisableString TooltipText