mirror of
https://github.com/ppy/osu.git
synced 2024-12-17 16:52:57 +08:00
Refactor DrawableOsuMenuItem
to remove a hack
This commit is contained in:
parent
ef1add3ebb
commit
3531f646f2
@ -124,7 +124,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
protected sealed override Drawable CreateContent() => text = CreateTextContainer();
|
protected sealed override Drawable CreateContent() => text = CreateTextContainer();
|
||||||
protected virtual TextContainer CreateTextContainer() => new TextContainer();
|
protected virtual TextContainer CreateTextContainer() => new TextContainer();
|
||||||
|
|
||||||
protected partial class TextContainer : Container, IHasText
|
protected partial class TextContainer : FillFlowContainer, IHasText
|
||||||
{
|
{
|
||||||
public LocalisableString Text
|
public LocalisableString Text
|
||||||
{
|
{
|
||||||
@ -145,7 +145,15 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Origin = Anchor.CentreLeft;
|
Origin = Anchor.CentreLeft;
|
||||||
|
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
|
Spacing = new Vector2(10);
|
||||||
|
Direction = FillDirection.Horizontal;
|
||||||
|
|
||||||
|
Child = new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Margin = new MarginPadding { Horizontal = MARGIN_HORIZONTAL, Vertical = MARGIN_VERTICAL },
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
NormalText = new OsuSpriteText
|
NormalText = new OsuSpriteText
|
||||||
@ -154,7 +162,6 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Font = OsuFont.GetFont(size: text_size),
|
Font = OsuFont.GetFont(size: text_size),
|
||||||
Margin = new MarginPadding { Horizontal = MARGIN_HORIZONTAL, Vertical = MARGIN_VERTICAL },
|
|
||||||
},
|
},
|
||||||
BoldText = new OsuSpriteText
|
BoldText = new OsuSpriteText
|
||||||
{
|
{
|
||||||
@ -163,7 +170,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold),
|
Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold),
|
||||||
Margin = new MarginPadding { Horizontal = MARGIN_HORIZONTAL, Vertical = MARGIN_VERTICAL },
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Size = new Vector2(10),
|
Size = new Vector2(10),
|
||||||
Margin = new MarginPadding { Horizontal = MARGIN_HORIZONTAL },
|
Margin = new MarginPadding { Left = -MARGIN_HORIZONTAL, Right = MARGIN_HORIZONTAL },
|
||||||
AlwaysPresent = true,
|
AlwaysPresent = true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -62,14 +62,6 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
state.BindValueChanged(updateState, true);
|
state.BindValueChanged(updateState, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
|
|
||||||
// Todo: This is bad. This can maybe be done better with a refactor of DrawableOsuMenuItem.
|
|
||||||
stateIcon.X = BoldText.DrawWidth + 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateState(ValueChangedEvent<object> state)
|
private void updateState(ValueChangedEvent<object> state)
|
||||||
{
|
{
|
||||||
var icon = menuItem.GetIconForState(state.NewValue);
|
var icon = menuItem.GetIconForState(state.NewValue);
|
||||||
|
Loading…
Reference in New Issue
Block a user