From 71620bfe267273ac37bb39eed5ca6629341cfc32 Mon Sep 17 00:00:00 2001 From: Salman Alshamrani Date: Tue, 29 Apr 2025 06:03:28 +0300 Subject: [PATCH] Bring back full mod icons --- .../SelectV2/BeatmapLeaderboardScore.cs | 121 ++---------------- .../BeatmapLeaderboardScore_Tooltip.cs | 7 +- 2 files changed, 13 insertions(+), 115 deletions(-) diff --git a/osu.Game/Screens/SelectV2/BeatmapLeaderboardScore.cs b/osu.Game/Screens/SelectV2/BeatmapLeaderboardScore.cs index c573239623..699a5216eb 100644 --- a/osu.Game/Screens/SelectV2/BeatmapLeaderboardScore.cs +++ b/osu.Game/Screens/SelectV2/BeatmapLeaderboardScore.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Extensions; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Graphics; @@ -25,7 +24,6 @@ using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; -using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Online.API; using osu.Game.Online.Leaderboards; using osu.Game.Overlays; @@ -106,7 +104,7 @@ namespace osu.Game.Screens.SelectV2 private Container rightContent = null!; - private FillFlowContainer modsContainer = null!; + private FillFlowContainer modsContainer = null!; private Box totalScoreBackground = null!; @@ -422,6 +420,7 @@ namespace osu.Game.Screens.SelectV2 Origin = Anchor.CentreLeft, Direction = FillDirection.Vertical, Padding = new MarginPadding { Horizontal = corner_radius }, + Spacing = new Vector2(0f, -2f), Children = new Drawable[] { new OsuSpriteText @@ -429,22 +428,22 @@ namespace osu.Game.Screens.SelectV2 Anchor = Anchor.TopRight, Origin = Anchor.TopRight, UseFullGlyphHeight = false, - Shear = sheared ? -OsuGame.SHEAR : Vector2.Zero, Current = scoreManager.GetBindableTotalScoreString(score), Spacing = new Vector2(-1.5f), Font = OsuFont.Style.Subtitle.With(weight: FontWeight.Light, fixedWidth: true), + Shear = sheared ? -OsuGame.SHEAR : Vector2.Zero, }, new InputBlockingContainer { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, AutoSizeAxes = Axes.Both, - Child = modsContainer = new FillFlowContainer + Child = modsContainer = new FillFlowContainer { - Shear = sheared ? -OsuGame.SHEAR : Vector2.Zero, AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, - Spacing = new Vector2(2f, 0f), + Spacing = new Vector2(-10, 0), + Shear = sheared ? -OsuGame.SHEAR : Vector2.Zero, }, }, } @@ -488,24 +487,15 @@ namespace osu.Game.Screens.SelectV2 private void updateModDisplay() { - int maxMods = scoringMode.Value == ScoringMode.Standardised ? 4 : 5; - if (score.Mods.Length > 0) { modsContainer.Padding = new MarginPadding { Top = 4f }; - modsContainer.ChildrenEnumerable = score.Mods.AsOrdered().Take(Math.Min(maxMods, score.Mods.Length)).Select(mod => new ColouredModSwitchTiny(mod) + modsContainer.ChildrenEnumerable = score.Mods.AsOrdered().Select(mod => new ModIcon(mod) { - Scale = new Vector2(0.3125f) + Scale = new Vector2(0.3f), + // trim mod icon height down to its true height for alignment purposes. + Height = ModIcon.MOD_ICON_SIZE.Y * 3 / 4f, }); - - if (score.Mods.Length > maxMods) - { - modsContainer.Remove(modsContainer[^1], true); - modsContainer.Add(new MoreModSwitchTiny(score.Mods) - { - Scale = new Vector2(0.3125f), - }); - } } } @@ -716,96 +706,5 @@ namespace osu.Game.Screens.SelectV2 public LocalisableString TooltipText { get; } } - - private sealed partial class ColouredModSwitchTiny : ModSwitchTiny, IHasCustomTooltip - { - [Resolved] - private OverlayColourProvider colourProvider { get; set; } = null!; - - public ColouredModSwitchTiny(Mod mod) - : base(mod) - { - Active.Value = true; - } - - public ITooltip GetCustomTooltip() => new ModTooltip(colourProvider); - - Mod IHasCustomTooltip.TooltipContent => (Mod)Mod; - } - - private sealed partial class MoreModSwitchTiny : CompositeDrawable, IHasPopover - { - private readonly IReadOnlyList mods; - - public MoreModSwitchTiny(IReadOnlyList mods) - { - this.mods = mods; - } - - [BackgroundDependencyLoader] - private void load(OverlayColourProvider colourProvider) - { - Size = new Vector2(ModSwitchTiny.WIDTH, ModSwitchTiny.DEFAULT_HEIGHT); - - InternalChild = new CircularContainer - { - Masking = true, - RelativeSizeAxes = Axes.Both, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = colourProvider.Background6, - }, - new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Shadow = false, - Font = OsuFont.Torus.With(size: 24, weight: FontWeight.Bold), - Text = ". . .", - Colour = Color4.White, - UseFullGlyphHeight = false, - Margin = new MarginPadding - { - Top = 4 - } - } - } - }; - } - - protected override bool OnClick(ClickEvent e) - { - this.ShowPopover(); - return true; - } - - protected override bool OnHover(HoverEvent e) => true; - - public Popover GetPopover() => new MoreModsPopover(mods); - - public partial class MoreModsPopover : OsuPopover - { - public MoreModsPopover(IReadOnlyList mods) - { - AutoSizeAxes = Axes.Both; - AllowableAnchors = new[] { Anchor.CentreLeft, Anchor.CentreRight }; - - Child = new FillFlowContainer - { - Width = 125f, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Full, - Spacing = new Vector2(2.5f), - ChildrenEnumerable = mods.AsOrdered().Select(m => new ColouredModSwitchTiny(m) - { - Scale = new Vector2(0.3125f), - }) - }; - } - } - } } } diff --git a/osu.Game/Screens/SelectV2/BeatmapLeaderboardScore_Tooltip.cs b/osu.Game/Screens/SelectV2/BeatmapLeaderboardScore_Tooltip.cs index 7f1997522e..5813864a82 100644 --- a/osu.Game/Screens/SelectV2/BeatmapLeaderboardScore_Tooltip.cs +++ b/osu.Game/Screens/SelectV2/BeatmapLeaderboardScore_Tooltip.cs @@ -257,12 +257,11 @@ namespace osu.Game.Screens.SelectV2 { Show(); - modsFlow.ChildrenEnumerable = mods.AsOrdered().Select(m => new ModSwitchTiny(m) + modsFlow.ChildrenEnumerable = mods.AsOrdered().Select(m => new ModIcon(m) { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Scale = new Vector2(0.3125f), - Active = { Value = true }, + Scale = new Vector2(0.3f), }); } } @@ -301,7 +300,7 @@ namespace osu.Game.Screens.SelectV2 AutoSizeAxes = Axes.Y, Margin = new MarginPadding { Bottom = 6f, Top = 6f + spacing }, Padding = new MarginPadding { Horizontal = 16f }, - Spacing = new Vector2(2.5f), + Spacing = new Vector2(2f, -4f), }, }; }