1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 03:42:57 +08:00

Replace "X mods" text with a pill indicator

This commit is contained in:
Salman Ahmed 2024-05-25 16:11:24 +03:00
parent 35af518fdb
commit 5955378004
3 changed files with 65 additions and 39 deletions

View File

@ -161,15 +161,9 @@ namespace osu.Game.Tests.Visual.SongSelect
}
};
for (int i = 0; i < LeaderboardScoreV2.MAX_MODS - 1; i++)
scores[1].Mods = scores[1].Mods.Concat(new Mod[] { i % 2 == 0 ? new OsuModHidden() : new OsuModHalfTime() }).ToArray();
for (int i = 0; i < LeaderboardScoreV2.MAX_MODS; i++)
scores[2].Mods = scores[2].Mods.Concat(new Mod[] { i % 2 == 0 ? new OsuModHidden() : halfTime }).ToArray();
for (int i = 0; i < LeaderboardScoreV2.MAX_MODS + 1; i++)
scores[3].Mods = scores[3].Mods.Concat(new Mod[] { i % 2 == 0 ? new OsuModHidden() : new OsuModHalfTime() }).ToArray();
scores[1].Mods = new Mod[] { new OsuModHidden(), new OsuModDoubleTime(), new OsuModHardRock(), new OsuModFlashlight() };
scores[2].Mods = new Mod[] { new OsuModHidden(), new OsuModDoubleTime(), new OsuModHardRock(), new OsuModFlashlight(), new OsuModClassic() };
scores[3].Mods = new Mod[] { new OsuModHidden(), new OsuModDoubleTime(), new OsuModHardRock(), new OsuModFlashlight(), new OsuModClassic(), new OsuModDifficultyAdjust() };
scores[4].Mods = scores[4].BeatmapInfo!.Ruleset.CreateInstance().CreateAllMods().ToArray();
return scores;

View File

@ -17,6 +17,7 @@ using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Framework.Layout;
using osu.Framework.Localisation;
using osu.Framework.Utils;
using osu.Game.Extensions;
using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds;
@ -93,8 +94,7 @@ namespace osu.Game.Online.Leaderboards
protected Container RankContainer { get; private set; } = null!;
private FillFlowContainer flagBadgeAndDateContainer = null!;
private FillFlowContainer<ColouredModSwitchTiny> modsContainer = null!;
private OsuSpriteText modsCounter = null!;
private FillFlowContainer modsContainer = null!;
private OsuSpriteText scoreText = null!;
private Drawable scoreRank = null!;
@ -178,17 +178,23 @@ namespace osu.Game.Online.Leaderboards
innerAvatar.OnLoadComplete += d => d.FadeInFromZero(200);
if (score.Mods.Length > MAX_MODS)
modsCounter.Text = $"{score.Mods.Length} mods";
else if (score.Mods.Length > 0)
if (score.Mods.Length > 0)
{
modsContainer.ChildrenEnumerable = score.Mods.AsOrdered().Select(mod => new ColouredModSwitchTiny(mod)
modsContainer.Padding = new MarginPadding { Top = 4f };
modsContainer.ChildrenEnumerable = score.Mods.AsOrdered().Take(Math.Min(MAX_MODS, score.Mods.Length)).Select(mod => new ColouredModSwitchTiny(mod)
{
Scale = new Vector2(0.375f)
});
}
modsContainer.Padding = new MarginPadding { Top = score.Mods.Length > 0 ? 4 : 0 };
if (score.Mods.Length > MAX_MODS)
{
modsContainer.Remove(modsContainer[^1], true);
modsContainer.Add(new MoreModSwitchTiny(score.Mods.Length - MAX_MODS + 1)
{
Scale = new Vector2(0.375f),
});
}
}
}
private Container createCentreContent(APIUser user) => new Container
@ -436,7 +442,7 @@ namespace osu.Game.Online.Leaderboards
Current = scoreManager.GetBindableTotalScoreString(score),
Font = OsuFont.GetFont(size: 30, weight: FontWeight.Light),
},
modsContainer = new FillFlowContainer<ColouredModSwitchTiny>
modsContainer = new FillFlowContainer
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
@ -445,13 +451,6 @@ namespace osu.Game.Online.Leaderboards
Direction = FillDirection.Horizontal,
Spacing = new Vector2(2f, 0f),
},
modsCounter = new OsuSpriteText
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Shear = -shear,
Alpha = 0,
}
}
}
}
@ -495,8 +494,7 @@ namespace osu.Game.Online.Leaderboards
using (BeginDelayedSequence(50))
{
Drawable modsDrawable = score.Mods.Length > MAX_MODS ? modsCounter : modsContainer;
var drawables = new[] { flagBadgeAndDateContainer, modsDrawable }.Concat(statisticsLabels).ToArray();
var drawables = new Drawable[] { flagBadgeAndDateContainer, modsContainer }.Concat(statisticsLabels).ToArray();
for (int i = 0; i < drawables.Length; i++)
drawables[i].FadeIn(100 + i * 50);
}
@ -652,20 +650,54 @@ namespace osu.Game.Online.Leaderboards
{
this.mod = mod;
Active.Value = true;
Masking = true;
EdgeEffect = new EdgeEffectParameters
{
Roundness = 15,
Type = EdgeEffectType.Shadow,
Colour = Colour4.Black.Opacity(0.15f),
Radius = 3,
Offset = new Vector2(-2, 0)
};
}
public LocalisableString TooltipText => (mod as Mod)?.IconTooltip ?? mod.Name;
}
private sealed partial class MoreModSwitchTiny : CompositeDrawable
{
private readonly int count;
public MoreModSwitchTiny(int count)
{
this.count = count;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
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 = OsuColour.Gray(0.2f),
},
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Shadow = false,
Font = OsuFont.Numeric.With(size: 24, weight: FontWeight.Black),
Text = $"+{count}",
Colour = colours.Yellow,
Margin = new MarginPadding
{
Top = 4
}
}
}
};
}
}
#endregion
public MenuItem[] ContextMenuItems

View File

@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.UI
public BindableBool Active { get; } = new BindableBool();
public const float DEFAULT_HEIGHT = 30;
private const float width = 73;
public const float WIDTH = 73;
protected readonly IMod Mod;
private readonly bool showExtendedInformation;
@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.UI
Width = 100 + DEFAULT_HEIGHT / 2,
RelativeSizeAxes = Axes.Y,
Masking = true,
X = width,
X = WIDTH,
Margin = new MarginPadding { Left = -DEFAULT_HEIGHT },
Children = new Drawable[]
{
@ -77,7 +77,7 @@ namespace osu.Game.Rulesets.UI
},
new CircularContainer
{
Width = width,
Width = WIDTH,
RelativeSizeAxes = Axes.Y,
Masking = true,
Children = new Drawable[]