1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 02:17:46 +08:00

Adjust sizing to work better with expansion (no more centre anchoring)

This commit is contained in:
Dean Herbert 2023-09-27 19:03:02 +09:00
parent 16e752e07d
commit 192eb541c0

View File

@ -60,6 +60,8 @@ namespace osu.Game.Rulesets.UI
private OsuSpriteText extendedText; private OsuSpriteText extendedText;
private Container extendedContent;
/// <summary> /// <summary>
/// Construct a new instance. /// Construct a new instance.
/// </summary> /// </summary>
@ -67,6 +69,9 @@ namespace osu.Game.Rulesets.UI
/// <param name="showTooltip">Whether a tooltip describing the mod should display on hover.</param> /// <param name="showTooltip">Whether a tooltip describing the mod should display on hover.</param>
public ModIcon(IMod mod, bool showTooltip = true) public ModIcon(IMod mod, bool showTooltip = true)
{ {
AutoSizeAxes = Axes.X;
Height = size;
this.mod = mod ?? throw new ArgumentNullException(nameof(mod)); this.mod = mod ?? throw new ArgumentNullException(nameof(mod));
this.showTooltip = showTooltip; this.showTooltip = showTooltip;
} }
@ -74,52 +79,68 @@ namespace osu.Game.Rulesets.UI
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(TextureStore textures) private void load(TextureStore textures)
{ {
AutoSizeAxes = Axes.Both;
Children = new Drawable[] Children = new Drawable[]
{ {
background = new SpriteIcon new Container
{ {
Origin = Anchor.Centre, Anchor = Anchor.CentreLeft,
Anchor = Anchor.Centre, Origin = Anchor.CentreLeft,
Name = "main content",
Size = new Vector2(size), Size = new Vector2(size),
Icon = OsuIcon.ModBg, Children = new Drawable[]
Shadow = true, {
background = new SpriteIcon
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Size = new Vector2(size),
Icon = OsuIcon.ModBg,
Shadow = true,
},
modAcronym = new OsuSpriteText
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Colour = OsuColour.Gray(84),
Alpha = 0,
Font = OsuFont.Numeric.With(null, 22f),
UseFullGlyphHeight = false,
Text = mod.Acronym
},
modIcon = new SpriteIcon
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Colour = OsuColour.Gray(84),
Size = new Vector2(45),
Icon = FontAwesome.Solid.Question
},
}
}, },
extendedBackground = new Sprite extendedContent = new Container
{ {
Anchor = Anchor.Centre, Name = "extended content",
Origin = Anchor.Centre, Anchor = Anchor.CentreLeft,
Texture = textures.Get("Icons/BeatmapDetails/mod-icon-extender"), Origin = Anchor.CentreLeft,
X = size - 3,
Size = new Vector2(120, 55), Size = new Vector2(120, 55),
}, X = size - 23,
extendedText = new OsuSpriteText Children = new Drawable[]
{ {
Origin = Anchor.Centre, extendedBackground = new Sprite
Anchor = Anchor.Centre, {
Font = OsuFont.Default.With(size: 30f, weight: FontWeight.Bold), Texture = textures.Get("Icons/BeatmapDetails/mod-icon-extender"),
UseFullGlyphHeight = false, Size = new Vector2(120, 55),
X = size, },
Text = mod.ExtendedIconInformation, extendedText = new OsuSpriteText
}, {
modAcronym = new OsuSpriteText Font = OsuFont.Default.With(size: 30f, weight: FontWeight.Bold),
{ UseFullGlyphHeight = false,
Origin = Anchor.Centre, Text = mod.ExtendedIconInformation,
Anchor = Anchor.Centre, X = 5,
Colour = OsuColour.Gray(84), Anchor = Anchor.Centre,
Alpha = 0, Origin = Anchor.Centre,
Font = OsuFont.Numeric.With(null, 22f), },
UseFullGlyphHeight = false, }
Text = mod.Acronym
},
modIcon = new SpriteIcon
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Colour = OsuColour.Gray(84),
Size = new Vector2(45),
Icon = FontAwesome.Solid.Question
}, },
}; };
} }
@ -151,6 +172,12 @@ namespace osu.Game.Rulesets.UI
backgroundColour = colours.ForModType(value.Type); backgroundColour = colours.ForModType(value.Type);
updateColour(); updateColour();
bool hasExtended = !string.IsNullOrEmpty(mod.ExtendedIconInformation);
extendedContent.Alpha = hasExtended ? 1 : 0;
extendedText.Text = mod.ExtendedIconInformation;
} }
private void updateColour() private void updateColour()