diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneSongSelectFooterV2.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneSongSelectFooterV2.cs index 0c7725db5a..93402e42ce 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneSongSelectFooterV2.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneSongSelectFooterV2.cs @@ -78,6 +78,12 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("four mods", () => SelectedMods.Value = new List { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime(), new OsuModClassic() }); AddStep("five mods", () => SelectedMods.Value = new List { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime(), new OsuModClassic(), new OsuModDifficultyAdjust() }); + AddStep("modified", () => SelectedMods.Value = new List { new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } }); + AddStep("modified + one", () => SelectedMods.Value = new List { new OsuModHidden(), new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } }); + AddStep("modified + two", () => SelectedMods.Value = new List { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } }); + AddStep("modified + three", () => SelectedMods.Value = new List { new OsuModHidden(), new OsuModHardRock(), new OsuModClassic(), new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } }); + AddStep("modified + four", () => SelectedMods.Value = new List { new OsuModHidden(), new OsuModHardRock(), new OsuModClassic(), new OsuModDifficultyAdjust(), new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } }); + AddStep("clear mods", () => SelectedMods.Value = Array.Empty()); AddWaitStep("wait", 3); AddStep("one mod", () => SelectedMods.Value = new List { new OsuModHidden() }); diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneFooterButtonModsV2.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneFooterButtonModsV2.cs index 7e8bba6573..af2eea6062 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneFooterButtonModsV2.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneFooterButtonModsV2.cs @@ -44,6 +44,10 @@ namespace osu.Game.Tests.Visual.UserInterface AddStep("four mods", () => changeMods(new List { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime(), new OsuModClassic() })); AddStep("five mods", () => changeMods(new List { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime(), new OsuModClassic(), new OsuModDifficultyAdjust() })); + AddStep("modified", () => changeMods(new List { new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } })); + AddStep("modified + one", () => changeMods(new List { new OsuModHidden(), new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } })); + AddStep("modified + two", () => changeMods(new List { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } })); + AddStep("clear mods", () => changeMods(Array.Empty())); AddWaitStep("wait", 3); AddStep("one mod", () => changeMods(new List { new OsuModHidden() })); diff --git a/osu.Game/Localisation/FooterButtonModsV2Strings.cs b/osu.Game/Localisation/FooterButtonModsV2Strings.cs new file mode 100644 index 0000000000..2cb297d8ef --- /dev/null +++ b/osu.Game/Localisation/FooterButtonModsV2Strings.cs @@ -0,0 +1,19 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Localisation; + +namespace osu.Game.Localisation +{ + public static class FooterButtonModsV2Strings + { + private const string prefix = @"osu.Game.Resources.Localisation.FooterButtonModsV2"; + + /// + /// "{0} mods" + /// + public static LocalisableString Mods(int count) => new TranslatableString(getKey(@"mods"), @"{0} mods", count); + + private static string getKey(string key) => $@"{prefix}:{key}"; + } +} diff --git a/osu.Game/Screens/Select/FooterV2/FooterButtonModsV2.cs b/osu.Game/Screens/Select/FooterV2/FooterButtonModsV2.cs index f9d923ddcf..7beadd1576 100644 --- a/osu.Game/Screens/Select/FooterV2/FooterButtonModsV2.cs +++ b/osu.Game/Screens/Select/FooterV2/FooterButtonModsV2.cs @@ -9,12 +9,14 @@ using osu.Framework.Bindables; using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Game.Configuration; using osu.Game.Graphics; +using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Localisation; using osu.Game.Overlays; @@ -155,15 +157,16 @@ namespace osu.Game.Screens.Select.FooterV2 Origin = Anchor.Centre, Shear = -barShear, Scale = new Vector2(0.6f), - Current = { Value = new List { new ModCinema() } }, + Current = { BindTarget = Current }, ExpansionMode = ExpansionMode.AlwaysContracted, }, - modCountText = new OsuSpriteText + modCountText = new ModCountText { Anchor = Anchor.Centre, Origin = Anchor.Centre, Shear = -barShear, Font = OsuFont.Torus.With(size: 14 * torus_scale_factor, weight: FontWeight.Bold), + Mods = { BindTarget = Current }, } } }, @@ -216,13 +219,11 @@ namespace osu.Game.Screens.Select.FooterV2 { if (Current.Value.Count >= 5) { - modCountText.Text = $"{Current.Value.Count} MODS"; modCountText.FadeIn(duration, easing); modDisplay.FadeOut(duration, easing); } else { - modDisplay.Current.Value = Current.Value; modDisplay.FadeIn(duration, easing); modCountText.FadeOut(duration, easing); } @@ -257,5 +258,58 @@ namespace osu.Game.Screens.Select.FooterV2 else MultiplierText.FadeColour(Color4.White, duration, easing); } + + private partial class ModCountText : OsuSpriteText, IHasCustomTooltip> + { + public readonly Bindable> Mods = new Bindable>(); + + protected override void LoadComplete() + { + base.LoadComplete(); + Mods.BindValueChanged(v => Text = FooterButtonModsV2Strings.Mods(v.NewValue.Count).ToUpper(), true); + } + + public ITooltip> GetCustomTooltip() => new ModTooltip(); + + public IReadOnlyList? TooltipContent => Mods.Value; + + public partial class ModTooltip : VisibilityContainer, ITooltip> + { + private ModDisplay extendedModDisplay = null!; + + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) + { + AutoSizeAxes = Axes.Both; + CornerRadius = CORNER_RADIUS; + Masking = true; + + InternalChildren = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colourProvider.Background5, + }, + extendedModDisplay = new ModDisplay + { + Margin = new MarginPadding { Vertical = 2f, Horizontal = 10f }, + Scale = new Vector2(0.6f), + ExpansionMode = ExpansionMode.AlwaysExpanded, + }, + }; + } + + public void SetContent(IReadOnlyList content) + { + extendedModDisplay.Current.Value = content; + } + + public void Move(Vector2 pos) => Position = pos; + + protected override void PopIn() => this.FadeIn(240, Easing.OutQuint); + protected override void PopOut() => this.FadeOut(240, Easing.OutQuint); + } + } } }