mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Make button text a property
This commit is contained in:
@ -36,7 +36,10 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
private class TestButton : CommentRepliesButton
|
private class TestButton : CommentRepliesButton
|
||||||
{
|
{
|
||||||
protected override string GetText() => "sample text";
|
public TestButton()
|
||||||
|
{
|
||||||
|
Text = "sample text";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,20 @@ namespace osu.Game.Overlays.Comments.Buttons
|
|||||||
{
|
{
|
||||||
public Action Action { get; set; }
|
public Action Action { get; set; }
|
||||||
|
|
||||||
|
protected string Text
|
||||||
|
{
|
||||||
|
get => text.Text;
|
||||||
|
set => text.Text = value;
|
||||||
|
}
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OverlayColourProvider colourProvider { get; set; }
|
private OverlayColourProvider colourProvider { get; set; }
|
||||||
|
|
||||||
protected SpriteIcon Icon;
|
protected readonly SpriteIcon Icon;
|
||||||
private Box background;
|
private readonly Box background;
|
||||||
|
private readonly OsuSpriteText text;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
public CommentRepliesButton()
|
||||||
private void load()
|
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
Margin = new MarginPadding
|
Margin = new MarginPadding
|
||||||
@ -43,8 +49,7 @@ namespace osu.Game.Overlays.Comments.Buttons
|
|||||||
{
|
{
|
||||||
background = new Box
|
background = new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both
|
||||||
Colour = colourProvider.Background2
|
|
||||||
},
|
},
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
@ -63,20 +68,18 @@ namespace osu.Game.Overlays.Comments.Buttons
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new OsuSpriteText
|
text = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold),
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold)
|
||||||
Text = GetText()
|
|
||||||
},
|
},
|
||||||
Icon = new SpriteIcon
|
Icon = new SpriteIcon
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Size = new Vector2(7.5f),
|
Size = new Vector2(7.5f),
|
||||||
Icon = FontAwesome.Solid.ChevronDown,
|
Icon = FontAwesome.Solid.ChevronDown
|
||||||
Colour = colourProvider.Foreground1
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,7 +90,12 @@ namespace osu.Game.Overlays.Comments.Buttons
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract string GetText();
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
background.Colour = colourProvider.Background2;
|
||||||
|
Icon.Colour = colourProvider.Foreground1;
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,9 @@ namespace osu.Game.Overlays.Comments.Buttons
|
|||||||
{
|
{
|
||||||
public class LoadRepliesButton : CommentRepliesButton
|
public class LoadRepliesButton : CommentRepliesButton
|
||||||
{
|
{
|
||||||
protected override string GetText() => "load replies";
|
public LoadRepliesButton()
|
||||||
|
{
|
||||||
|
Text = "load replies";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,9 @@ namespace osu.Game.Overlays.Comments.Buttons
|
|||||||
{
|
{
|
||||||
public readonly BindableBool Expanded = new BindableBool(true);
|
public readonly BindableBool Expanded = new BindableBool(true);
|
||||||
|
|
||||||
private readonly int count;
|
|
||||||
|
|
||||||
public ShowRepliesButton(int count)
|
public ShowRepliesButton(int count)
|
||||||
{
|
{
|
||||||
this.count = count;
|
Text = "reply".ToQuantity(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -36,7 +34,5 @@ namespace osu.Game.Overlays.Comments.Buttons
|
|||||||
Expanded.Toggle();
|
Expanded.Toggle();
|
||||||
return base.OnClick(e);
|
return base.OnClick(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string GetText() => "reply".ToQuantity(count);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user