diff --git a/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapSetOnlineStatusPill.cs b/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapSetOnlineStatusPill.cs index dcc4654437..82e02a9b6f 100644 --- a/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapSetOnlineStatusPill.cs +++ b/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapSetOnlineStatusPill.cs @@ -19,6 +19,8 @@ namespace osu.Game.Tests.Visual.Beatmaps { public partial class TestSceneBeatmapSetOnlineStatusPill : ThemeComparisonTestScene { + private bool showUnknownStatus; + protected override Drawable CreateContent() => new FillFlowContainer { AutoSizeAxes = Axes.Both, @@ -26,12 +28,20 @@ namespace osu.Game.Tests.Visual.Beatmaps Origin = Anchor.Centre, Direction = FillDirection.Vertical, Spacing = new Vector2(0, 10), - ChildrenEnumerable = Enum.GetValues(typeof(BeatmapOnlineStatus)).Cast().Select(status => new BeatmapSetOnlineStatusPill + ChildrenEnumerable = Enum.GetValues(typeof(BeatmapOnlineStatus)).Cast().Select(status => new Container { - AutoSizeAxes = Axes.Both, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Status = status + RelativeSizeAxes = Axes.X, + Height = 20, + Children = new Drawable[] + { + new BeatmapSetOnlineStatusPill + { + ShowUnknownStatus = showUnknownStatus, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Status = status + } + } }) }; @@ -48,6 +58,12 @@ namespace osu.Game.Tests.Visual.Beatmaps pill.Width = 90; })); + AddStep("toggle show unknown", () => + { + showUnknownStatus = !showUnknownStatus; + CreateThemedContent(OverlayColourScheme.Red); + }); + AddStep("unset fixed width", () => statusPills.ForEach(pill => pill.AutoSizeAxes = Axes.Both)); } @@ -65,11 +81,6 @@ namespace osu.Game.Tests.Visual.Beatmaps pill.Status = BeatmapOnlineStatus.LocallyModified; break; - // skip none - case BeatmapOnlineStatus.LocallyModified: - pill.Status = BeatmapOnlineStatus.Graveyard; - break; - default: pill.Status = (pill.Status + 1); break; diff --git a/osu.Game/Beatmaps/BeatmapOnlineStatus.cs b/osu.Game/Beatmaps/BeatmapOnlineStatus.cs index 41393a8a39..d489aeda3f 100644 --- a/osu.Game/Beatmaps/BeatmapOnlineStatus.cs +++ b/osu.Game/Beatmaps/BeatmapOnlineStatus.cs @@ -14,10 +14,10 @@ namespace osu.Game.Beatmaps /// This is a special status given when local changes are made via the editor. /// Once in this state, online status changes should be ignored unless the beatmap is reverted or submitted. /// - [Description("Local")] [LocalisableDescription(typeof(SongSelectStrings), nameof(SongSelectStrings.LocallyModified))] LocallyModified = -4, + [Description("Unknown")] None = -3, [LocalisableDescription(typeof(BeatmapsetsStrings), nameof(BeatmapsetsStrings.ShowStatusGraveyard))] diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs index 7b99ad40de..7b3067e8d6 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs @@ -19,9 +19,10 @@ namespace osu.Game.Beatmaps.Drawables { public partial class BeatmapSetOnlineStatusPill : CircularContainer, IHasTooltip { - private const double animation_duration = 400; - - private BeatmapOnlineStatus status; + /// + /// Whether to show as "unknown" instead of fading out. + /// + public bool ShowUnknownStatus { get; init; } public BeatmapOnlineStatus Status { @@ -34,30 +35,27 @@ namespace osu.Game.Beatmaps.Drawables status = value; if (IsLoaded) - { - AutoSizeDuration = (float)animation_duration; - AutoSizeEasing = Easing.OutQuint; - updateState(); - } } } + private BeatmapOnlineStatus status; + public float TextSize { - get => statusText.Font.Size; - set => statusText.Font = statusText.Font.With(size: value); + init => statusText.Font = statusText.Font.With(size: value); } public MarginPadding TextPadding { - get => statusText.Padding; - set => statusText.Padding = value; + init => statusText.Padding = value; } private readonly OsuSpriteText statusText; private readonly Box background; + private const double animation_duration = 400; + [Resolved] private OsuColour colours { get; set; } = null!; @@ -66,6 +64,7 @@ namespace osu.Game.Beatmaps.Drawables public BeatmapSetOnlineStatusPill() { + AutoSizeAxes = Axes.Both; Masking = true; Alpha = 0; @@ -99,14 +98,27 @@ namespace osu.Game.Beatmaps.Drawables private void updateState() { - if (Status == BeatmapOnlineStatus.None) + if (Status == BeatmapOnlineStatus.None && !ShowUnknownStatus) { Hide(); return; } + // The autosize animation on this component is intended to animate horizontal sizing only. + // To avoid vertical autosize animating from zero to non-zero, only apply the duration + // after we have a valid size. + if (Height > 0) + { + AutoSizeDuration = (float)animation_duration; + AutoSizeEasing = Easing.OutQuint; + } + this.FadeIn(animation_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; + Color4 statusTextColour; if (colourProvider != null) @@ -114,8 +126,8 @@ namespace osu.Game.Beatmaps.Drawables else statusTextColour = status == BeatmapOnlineStatus.Graveyard ? colours.GreySeaFoamLight : Color4.Black; - statusText.FadeColour(statusTextColour, animation_duration, Easing.OutQuint); - background.FadeColour(OsuColour.ForBeatmapSetOnlineStatus(Status) ?? colourProvider?.Light1 ?? colours.GreySeaFoamLighter, animation_duration, Easing.OutQuint); + statusText.FadeColour(statusTextColour, duration, Easing.OutQuint); + background.FadeColour(OsuColour.ForBeatmapSetOnlineStatus(Status) ?? colourProvider?.Light1 ?? colours.GreySeaFoamLighter, duration, Easing.OutQuint); statusText.Text = Status.GetLocalisableDescription().ToUpper(); } diff --git a/osu.Game/Beatmaps/Drawables/Cards/BeatmapCardExtraInfoRow.cs b/osu.Game/Beatmaps/Drawables/Cards/BeatmapCardExtraInfoRow.cs index 41513ec7a2..ee2f682708 100644 --- a/osu.Game/Beatmaps/Drawables/Cards/BeatmapCardExtraInfoRow.cs +++ b/osu.Game/Beatmaps/Drawables/Cards/BeatmapCardExtraInfoRow.cs @@ -30,7 +30,6 @@ namespace osu.Game.Beatmaps.Drawables.Cards { new BeatmapSetOnlineStatusPill { - AutoSizeAxes = Axes.Both, Status = beatmapSet.Status, Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, diff --git a/osu.Game/Graphics/OsuColour.cs b/osu.Game/Graphics/OsuColour.cs index 5adecc7182..dd5e19e167 100644 --- a/osu.Game/Graphics/OsuColour.cs +++ b/osu.Game/Graphics/OsuColour.cs @@ -123,6 +123,9 @@ namespace osu.Game.Graphics { switch (status) { + case BeatmapOnlineStatus.None: + return Color4.RosyBrown; + case BeatmapOnlineStatus.LocallyModified: return Color4.OrangeRed; diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs index c72c2a6698..9b10f6156d 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs @@ -177,7 +177,6 @@ namespace osu.Game.Overlays.BeatmapSet { onlineStatusPill = new BeatmapSetOnlineStatusPill { - AutoSizeAxes = Axes.Both, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, TextSize = 14, diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index fd1c944689..5a09780943 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -263,7 +263,6 @@ namespace osu.Game.Screens.Select }, new BeatmapSetOnlineStatusPill { - AutoSizeAxes = Axes.Both, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Shear = -wedged_container_shear, diff --git a/osu.Game/Screens/Select/Carousel/SetPanelContent.cs b/osu.Game/Screens/Select/Carousel/SetPanelContent.cs index 8d6fbbf256..c3ded16bd2 100644 --- a/osu.Game/Screens/Select/Carousel/SetPanelContent.cs +++ b/osu.Game/Screens/Select/Carousel/SetPanelContent.cs @@ -77,7 +77,6 @@ namespace osu.Game.Screens.Select.Carousel }, new BeatmapSetOnlineStatusPill { - AutoSizeAxes = Axes.Both, Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, TextSize = 11, diff --git a/osu.Game/Screens/SelectV2/PanelBeatmapSet.cs b/osu.Game/Screens/SelectV2/PanelBeatmapSet.cs index c599c3e534..9e9ef612ea 100644 --- a/osu.Game/Screens/SelectV2/PanelBeatmapSet.cs +++ b/osu.Game/Screens/SelectV2/PanelBeatmapSet.cs @@ -97,7 +97,6 @@ namespace osu.Game.Screens.SelectV2 }, statusPill = new BeatmapSetOnlineStatusPill { - AutoSizeAxes = Axes.Both, Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, TextSize = 11, diff --git a/osu.Game/Screens/SelectV2/PanelBeatmapStandalone.cs b/osu.Game/Screens/SelectV2/PanelBeatmapStandalone.cs index 948311a86e..f893bb0caf 100644 --- a/osu.Game/Screens/SelectV2/PanelBeatmapStandalone.cs +++ b/osu.Game/Screens/SelectV2/PanelBeatmapStandalone.cs @@ -117,7 +117,6 @@ namespace osu.Game.Screens.SelectV2 }, statusPill = new BeatmapSetOnlineStatusPill { - AutoSizeAxes = Axes.Both, Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, TextSize = 11,