mirror of
https://github.com/ppy/osu.git
synced 2026-05-23 15:00:46 +08:00
Add property to allow disabling status pill animation
This commit is contained in:
committed by
Dean Herbert
Unverified
parent
9d438bac29
commit
c565b76b6e
@@ -20,6 +20,7 @@ namespace osu.Game.Tests.Visual.Beatmaps
|
||||
public partial class TestSceneBeatmapSetOnlineStatusPill : ThemeComparisonTestScene
|
||||
{
|
||||
private bool showUnknownStatus;
|
||||
private bool animated = true;
|
||||
|
||||
protected override Drawable CreateContent() => new FillFlowContainer
|
||||
{
|
||||
@@ -37,10 +38,11 @@ namespace osu.Game.Tests.Visual.Beatmaps
|
||||
new BeatmapSetOnlineStatusPill
|
||||
{
|
||||
ShowUnknownStatus = showUnknownStatus,
|
||||
Animated = animated,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Status = status
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
};
|
||||
@@ -64,6 +66,12 @@ namespace osu.Game.Tests.Visual.Beatmaps
|
||||
CreateThemedContent(OverlayColourScheme.Red);
|
||||
});
|
||||
|
||||
AddStep("toggle animate", () =>
|
||||
{
|
||||
animated = !animated;
|
||||
CreateThemedContent(OverlayColourScheme.Red);
|
||||
});
|
||||
|
||||
AddStep("unset fixed width", () => statusPills.ForEach(pill => pill.AutoSizeAxes = Axes.Both));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Utils;
|
||||
@@ -62,6 +64,26 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
AddStep("enable masking", () => Scroll.Masking = true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Explicit]
|
||||
public void TestRandomStatus()
|
||||
{
|
||||
SortBy(SortMode.Title);
|
||||
AddStep("add beatmaps", () =>
|
||||
{
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
var set = TestResources.CreateTestBeatmapSetInfo();
|
||||
set.Status = Enum.GetValues<BeatmapOnlineStatus>().MinBy(_ => RNG.Next());
|
||||
|
||||
if (i % 2 == 0)
|
||||
set.Status = BeatmapOnlineStatus.None;
|
||||
|
||||
BeatmapSets.Add(set);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Explicit]
|
||||
public void TestPerformanceWithManyBeatmaps()
|
||||
|
||||
@@ -24,6 +24,11 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
/// </summary>
|
||||
public bool ShowUnknownStatus { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether changing status performs transition transforms.
|
||||
/// </summary>
|
||||
public bool Animated { get; init; } = true;
|
||||
|
||||
public BeatmapOnlineStatus Status
|
||||
{
|
||||
get => status;
|
||||
@@ -98,9 +103,11 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
double duration = Animated ? animation_duration : 0;
|
||||
|
||||
if (Status == BeatmapOnlineStatus.None && !ShowUnknownStatus)
|
||||
{
|
||||
this.FadeOut(animation_duration, Easing.OutQuint);
|
||||
this.FadeOut(duration, Easing.OutQuint);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -109,15 +116,16 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
// after we have a valid size.
|
||||
if (Height > 0)
|
||||
{
|
||||
AutoSizeDuration = (float)animation_duration;
|
||||
AutoSizeDuration = (float)duration;
|
||||
AutoSizeEasing = Easing.OutQuint;
|
||||
}
|
||||
|
||||
this.FadeIn(animation_duration, Easing.OutQuint);
|
||||
this.FadeIn(duration, Easing.OutQuint);
|
||||
|
||||
// Handle the case where transition from hidden to non-hidden may cause
|
||||
// a fade from a colour that doesn't make sense (due to not being able to see the previous colour).
|
||||
double duration = Alpha > 0 ? animation_duration : 0;
|
||||
if (Alpha == 0)
|
||||
duration = 0;
|
||||
|
||||
Color4 statusTextColour;
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
Anchor = Anchor.CentreLeft,
|
||||
TextSize = OsuFont.Style.Caption2.Size,
|
||||
Margin = new MarginPadding { Right = 5f },
|
||||
Animated = false,
|
||||
},
|
||||
difficultiesDisplay = new DifficultySpectrumDisplay
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user