From c565b76b6e54e08b0bb2f6627540edd4ffd9ef50 Mon Sep 17 00:00:00 2001 From: Salman Alshamrani Date: Tue, 20 May 2025 00:40:56 +0300 Subject: [PATCH] Add property to allow disabling status pill animation --- .../TestSceneBeatmapSetOnlineStatusPill.cs | 10 ++++++++- .../SongSelectV2/TestSceneBeatmapCarousel.cs | 22 +++++++++++++++++++ .../Drawables/BeatmapSetOnlineStatusPill.cs | 16 ++++++++++---- osu.Game/Screens/SelectV2/PanelBeatmapSet.cs | 1 + 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapSetOnlineStatusPill.cs b/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapSetOnlineStatusPill.cs index 82e02a9b6f..1651adc08f 100644 --- a/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapSetOnlineStatusPill.cs +++ b/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapSetOnlineStatusPill.cs @@ -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)); } diff --git a/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarousel.cs index 21030e0b88..ae3d95451e 100644 --- a/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapCarousel.cs @@ -1,7 +1,9 @@ // Copyright (c) ppy Pty Ltd . 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().MinBy(_ => RNG.Next()); + + if (i % 2 == 0) + set.Status = BeatmapOnlineStatus.None; + + BeatmapSets.Add(set); + } + }); + } + [Test] [Explicit] public void TestPerformanceWithManyBeatmaps() diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs index c6a3c7db3c..b10ea4fa75 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs @@ -24,6 +24,11 @@ namespace osu.Game.Beatmaps.Drawables /// public bool ShowUnknownStatus { get; init; } + /// + /// Whether changing status performs transition transforms. + /// + 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; diff --git a/osu.Game/Screens/SelectV2/PanelBeatmapSet.cs b/osu.Game/Screens/SelectV2/PanelBeatmapSet.cs index 7f5aa6ffe8..23afe96133 100644 --- a/osu.Game/Screens/SelectV2/PanelBeatmapSet.cs +++ b/osu.Game/Screens/SelectV2/PanelBeatmapSet.cs @@ -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 {