mirror of
https://github.com/ppy/osu.git
synced 2026-06-03 22:54:23 +08:00
Adjust button styling
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Overlays;
|
||||
@@ -16,20 +17,36 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
[Cached]
|
||||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Aquamarine);
|
||||
|
||||
private readonly FooterButtonFreeModsV2 button;
|
||||
|
||||
public TestSceneFooterButtonFreeModsV2()
|
||||
{
|
||||
ModSelectOverlay modSelectOverlay;
|
||||
Add(modSelectOverlay = new TestModSelectOverlay());
|
||||
|
||||
FooterButtonFreeModsV2 button;
|
||||
Add(button = new FooterButtonFreeModsV2(modSelectOverlay)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.CentreLeft,
|
||||
X = -100,
|
||||
});
|
||||
}
|
||||
|
||||
button.FreeMods.Value = new OsuRuleset().CreateAllMods().ToArray();
|
||||
[Test]
|
||||
public void TestAllMods()
|
||||
{
|
||||
AddStep("all mods", () => button.FreeMods.Value = new OsuRuleset().CreateAllMods().ToArray());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNoMods()
|
||||
{
|
||||
AddStep("no mods", () => button.FreeMods.Value = []);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFreestyle()
|
||||
{
|
||||
AddToggleStep("toggle freestyle", v => button.Freestyle.Value = v);
|
||||
}
|
||||
|
||||
private partial class TestModSelectOverlay : UserModSelectOverlay
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
{
|
||||
private const float bar_height = 30f;
|
||||
|
||||
public readonly Bindable<IReadOnlyList<Mod>> FreeMods = new Bindable<IReadOnlyList<Mod>>();
|
||||
public readonly IBindable<bool> Freestyle = new Bindable<bool>();
|
||||
public readonly Bindable<IReadOnlyList<Mod>> FreeMods = new Bindable<IReadOnlyList<Mod>>([]);
|
||||
public readonly Bindable<bool> Freestyle = new Bindable<bool>();
|
||||
|
||||
public new Action Action
|
||||
{
|
||||
@@ -104,7 +104,11 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
Current = { BindTarget = FreeMods },
|
||||
ExpansionMode = ExpansionMode.AlwaysContracted,
|
||||
},
|
||||
overflowModCountDisplay = new ModCountText { Mods = { BindTarget = FreeMods }, },
|
||||
overflowModCountDisplay = new ModCountText
|
||||
{
|
||||
Mods = { BindTarget = FreeMods },
|
||||
Freestyle = { BindTarget = Freestyle }
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -135,6 +139,7 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
private partial class ModCountText : CompositeDrawable
|
||||
{
|
||||
public readonly Bindable<IReadOnlyList<Mod>> Mods = new Bindable<IReadOnlyList<Mod>>();
|
||||
public readonly Bindable<bool> Freestyle = new Bindable<bool>();
|
||||
|
||||
private OsuSpriteText text = null!;
|
||||
|
||||
@@ -164,7 +169,18 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
}
|
||||
};
|
||||
|
||||
Mods.BindValueChanged(v => text.Text = ModSelectOverlayStrings.Mods(v.NewValue.Count).ToUpper(), true);
|
||||
Mods.BindValueChanged(_ => updateText());
|
||||
Freestyle.BindValueChanged(_ => updateText());
|
||||
|
||||
updateText();
|
||||
}
|
||||
|
||||
private void updateText()
|
||||
{
|
||||
if (Freestyle.Value)
|
||||
text.Text = "ALL MODS";
|
||||
else
|
||||
text.Text = ModSelectOverlayStrings.Mods(Mods.Value.Count).ToUpper();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Screens.Footer;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay
|
||||
{
|
||||
@@ -34,6 +35,9 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||
|
||||
private Drawable statusBackground = null!;
|
||||
private OsuSpriteText statusText = null!;
|
||||
|
||||
public FooterButtonFreestyleV2()
|
||||
{
|
||||
// Overwrite any external behaviour as we delegate the main toggle action to a sub-button.
|
||||
@@ -66,56 +70,44 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
Colour = Colour4.Black.Opacity(0.25f),
|
||||
Offset = new Vector2(0, 2),
|
||||
},
|
||||
Children = new Drawable[]
|
||||
Children = new[]
|
||||
{
|
||||
new Box
|
||||
statusBackground = new Box
|
||||
{
|
||||
Colour = colourProvider.Background3,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new StatusText { Freestyle = { BindTarget = Freestyle } }
|
||||
statusText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = OsuFont.Torus.With(size: 14f, weight: FontWeight.Bold),
|
||||
Shear = -OsuGame.SHEAR,
|
||||
},
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private partial class StatusText : CompositeDrawable
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
public readonly Bindable<bool> Freestyle = new Bindable<bool>();
|
||||
base.LoadComplete();
|
||||
|
||||
private OsuSpriteText text = null!;
|
||||
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||
|
||||
protected override void LoadComplete()
|
||||
Freestyle.BindValueChanged(v =>
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
if (v.NewValue)
|
||||
{
|
||||
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,
|
||||
}
|
||||
};
|
||||
|
||||
Freestyle.BindValueChanged(v =>
|
||||
statusBackground.Colour = colours.Yellow;
|
||||
statusText.Text = "ON";
|
||||
statusText.Colour = Color4.Black;
|
||||
}
|
||||
else
|
||||
{
|
||||
text.Text = v.NewValue ? "ON" : "OFF";
|
||||
}, true);
|
||||
}
|
||||
statusBackground.Colour = colourProvider.Background3;
|
||||
statusText.Text = "OFF";
|
||||
statusText.Colour = Color4.White;
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user