diff --git a/osu.Game/Screens/OnlinePlay/FooterButtonFreeModsV2.cs b/osu.Game/Screens/OnlinePlay/FooterButtonFreeModsV2.cs index 4b94e8c36c..822af03c5f 100644 --- a/osu.Game/Screens/OnlinePlay/FooterButtonFreeModsV2.cs +++ b/osu.Game/Screens/OnlinePlay/FooterButtonFreeModsV2.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Effects; @@ -13,21 +12,19 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Utils; using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; using osu.Game.Localisation; using osu.Game.Overlays; using osu.Game.Overlays.Mods; using osu.Game.Rulesets.Mods; using osu.Game.Screens.Footer; using osu.Game.Screens.Play.HUD; +using osu.Game.Screens.SelectV2; using osuTK; namespace osu.Game.Screens.OnlinePlay { public partial class FooterButtonFreeModsV2 : ScreenFooterButton { - private const float bar_height = 30f; - public readonly Bindable> FreeMods = new Bindable>([]); public readonly Bindable Freestyle = new Bindable(); @@ -45,7 +42,7 @@ namespace osu.Game.Screens.OnlinePlay private Container modsWedge = null!; private ModDisplay modDisplay = null!; private Container modContainer = null!; - private ModCountText overflowModCountDisplay = null!; + private FooterButtonMods.ModCountText overflowModCountDisplay = null!; public FooterButtonFreeModsV2(ModSelectOverlay overlay) : base(overlay) @@ -66,7 +63,7 @@ namespace osu.Game.Screens.OnlinePlay Origin = Anchor.BottomLeft, Shear = OsuGame.SHEAR, CornerRadius = CORNER_RADIUS, - Size = new Vector2(BUTTON_WIDTH, bar_height), + Size = new Vector2(BUTTON_WIDTH, FooterButtonMods.BAR_HEIGHT), Masking = true, EdgeEffect = new EdgeEffectParameters { @@ -100,7 +97,7 @@ namespace osu.Game.Screens.OnlinePlay Current = { BindTarget = FreeMods }, ExpansionMode = ExpansionMode.AlwaysContracted, }, - overflowModCountDisplay = new ModCountText + overflowModCountDisplay = new FooterButtonMods.ModCountText { Mods = { BindTarget = FreeMods }, Freestyle = { BindTarget = Freestyle } @@ -145,56 +142,5 @@ namespace osu.Game.Screens.OnlinePlay else overflowModCountDisplay.Hide(); } - - private partial class ModCountText : VisibilityContainer - { - public readonly Bindable> Mods = new Bindable>(); - public readonly Bindable Freestyle = new Bindable(); - - private OsuSpriteText text = null!; - - [Resolved] - private OverlayColourProvider colourProvider { get; set; } = null!; - - protected override void LoadComplete() - { - base.LoadComplete(); - - RelativeSizeAxes = Axes.Both; - - InternalChildren = new Drawable[] - { - new Box - { - Colour = colourProvider.Background3, - Alpha = 0.8f, - RelativeSizeAxes = Axes.Both, - }, - text = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Font = OsuFont.Torus.With(size: 14f, weight: FontWeight.Bold), - Shear = -OsuGame.SHEAR, - } - }; - - Mods.BindValueChanged(_ => updateText()); - Freestyle.BindValueChanged(_ => updateText()); - - updateText(); - } - - protected override void PopIn() => this.FadeIn(300, Easing.OutExpo); - protected override void PopOut() => this.FadeOut(300, Easing.OutExpo); - - private void updateText() - { - if (Freestyle.Value) - text.Text = ModSelectOverlayStrings.AllMods.ToUpper(); - else - text.Text = ModSelectOverlayStrings.Mods(Mods.Value.Count).ToUpper(); - } - } } } diff --git a/osu.Game/Screens/SelectV2/FooterButtonMods.cs b/osu.Game/Screens/SelectV2/FooterButtonMods.cs index 112f53a53e..f9acf6cf10 100644 --- a/osu.Game/Screens/SelectV2/FooterButtonMods.cs +++ b/osu.Game/Screens/SelectV2/FooterButtonMods.cs @@ -36,7 +36,8 @@ namespace osu.Game.Screens.SelectV2 { public Action? RequestDeselectAllMods { get; init; } - private const float bar_height = 30f; + public const float BAR_HEIGHT = 30f; + private const float mod_display_portion = 0.65f; private readonly BindableWithCurrent> current = new BindableWithCurrent>(Array.Empty()); @@ -92,7 +93,7 @@ namespace osu.Game.Screens.SelectV2 Origin = Anchor.BottomLeft, Shear = OsuGame.SHEAR, CornerRadius = CORNER_RADIUS, - Size = new Vector2(BUTTON_WIDTH, bar_height), + Size = new Vector2(BUTTON_WIDTH, BAR_HEIGHT), Masking = true, EdgeEffect = new EdgeEffectParameters { @@ -257,9 +258,10 @@ namespace osu.Game.Screens.SelectV2 overflowModCountDisplay.Hide(); } - private partial class ModCountText : CompositeDrawable, IHasCustomTooltip> + public partial class ModCountText : VisibilityContainer, IHasCustomTooltip> { public readonly Bindable> Mods = new Bindable>(); + public readonly Bindable Freestyle = new Bindable(); private OsuSpriteText text = null!; @@ -289,13 +291,25 @@ namespace osu.Game.Screens.SelectV2 } }; - Mods.BindValueChanged(v => text.Text = ModSelectOverlayStrings.Mods(v.NewValue.Count).ToUpper(), true); + Freestyle.BindValueChanged(_ => updateText()); + Mods.BindValueChanged(_ => updateText(), true); } public ITooltip> GetCustomTooltip() => new ModOverflowTooltip(colourProvider); public IReadOnlyList? TooltipContent => Mods.Value; + protected override void PopIn() => this.FadeIn(300, Easing.OutExpo); + protected override void PopOut() => this.FadeOut(300, Easing.OutExpo); + + private void updateText() + { + if (Freestyle.Value) + text.Text = ModSelectOverlayStrings.AllMods.ToUpper(); + else + text.Text = ModSelectOverlayStrings.Mods(Mods.Value.Count).ToUpper(); + } + public partial class ModOverflowTooltip : VisibilityContainer, ITooltip> { private ModDisplay extendedModDisplay = null!; @@ -356,7 +370,7 @@ namespace osu.Game.Screens.SelectV2 Shear = OsuGame.SHEAR; CornerRadius = CORNER_RADIUS; AutoSizeAxes = Axes.X; - Height = bar_height; + Height = BAR_HEIGHT; Masking = true; BorderColour = Color4.White; BorderThickness = 2f;