1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 21:52:55 +08:00

Add TopLevelContent layer for applying external transforms on footer buttons

This commit is contained in:
Salman Ahmed 2024-05-16 06:23:07 +03:00
parent 820cfbcb00
commit a2794922d5
3 changed files with 99 additions and 67 deletions

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics;
using osu.Framework.Testing;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Screens.SelectV2.Footer;
@ -26,12 +27,12 @@ namespace osu.Game.Tests.Visual.UserInterface
public TestSceneScreenFooterButtonMods()
{
Add(footerButtonMods = new TestScreenFooterButtonMods
Add(footerButtonMods = new TestScreenFooterButtonMods(new TestModSelectOverlay())
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreLeft,
X = -100,
Action = () => { },
X = -100,
});
}
@ -112,9 +113,19 @@ namespace osu.Game.Tests.Visual.UserInterface
return expectedValue == footerButtonMods.MultiplierText.Current.Value;
}
private partial class TestModSelectOverlay : UserModSelectOverlay
{
protected override bool ShowPresets => true;
}
private partial class TestScreenFooterButtonMods : ScreenFooterButtonMods
{
public new OsuSpriteText MultiplierText => base.MultiplierText;
public TestScreenFooterButtonMods(ModSelectOverlay overlay)
: base(overlay)
{
}
}
}
}

View File

@ -55,7 +55,7 @@ namespace osu.Game.Screens.Footer
set => icon.Icon = value;
}
protected LocalisableString Text
public LocalisableString Text
{
set => text.Text = value;
}
@ -69,11 +69,21 @@ namespace osu.Game.Screens.Footer
private readonly Box glowBox;
private readonly Box flashLayer;
public ScreenFooterButton()
public readonly Container TopLevelContent;
public readonly OverlayContainer? Overlay;
public ScreenFooterButton(OverlayContainer? overlay = null)
{
Overlay = overlay;
Size = new Vector2(BUTTON_WIDTH, BUTTON_HEIGHT);
Child = new Container
Child = TopLevelContent = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new Container
{
EdgeEffect = new EdgeEffectParameters
{
@ -150,6 +160,8 @@ namespace osu.Game.Screens.Footer
Alpha = 0,
},
},
}
}
};
}
@ -157,6 +169,9 @@ namespace osu.Game.Screens.Footer
{
base.LoadComplete();
if (Overlay != null)
OverlayState.BindTo(Overlay.State);
OverlayState.BindValueChanged(_ => updateDisplay());
Enabled.BindValueChanged(_ => updateDisplay(), true);

View File

@ -20,6 +20,7 @@ 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;
@ -59,6 +60,11 @@ namespace osu.Game.Screens.SelectV2.Footer
[Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;
public ScreenFooterButtonMods(ModSelectOverlay overlay)
: base(overlay)
{
}
[BackgroundDependencyLoader]
private void load()
{
@ -66,7 +72,7 @@ namespace osu.Game.Screens.SelectV2.Footer
Icon = FontAwesome.Solid.ExchangeAlt;
AccentColour = colours.Lime1;
AddRange(new[]
TopLevelContent.AddRange(new[]
{
unrankedBadge = new UnrankedBadge(),
modDisplayBar = new Container