mirror of https://github.com/ppy/osu
UI implementation
This commit is contained in:
parent
38dcd42d08
commit
1f28c00594
|
@ -17,6 +17,10 @@
|
|||
using osu.Game.Online.Chat;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays.Comments
|
||||
{
|
||||
|
@ -57,7 +61,7 @@ public DrawableComment(Comment comment)
|
|||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Padding = new MarginPadding(margin),
|
||||
Padding = new MarginPadding(margin) { Left = margin + 5 },
|
||||
Child = content = new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
|
@ -336,10 +340,15 @@ private string getParentMessage()
|
|||
}
|
||||
}
|
||||
|
||||
private class VotePill : CircularContainer
|
||||
private class VotePill : Container, IHasAccentColour
|
||||
{
|
||||
public Color4 AccentColour { get; set; }
|
||||
|
||||
private readonly Box background;
|
||||
private readonly Box hoverLayer;
|
||||
private readonly Comment comment;
|
||||
private readonly CircularContainer borderContainer;
|
||||
private readonly SpriteText sideNumber;
|
||||
|
||||
public VotePill(Comment comment)
|
||||
{
|
||||
|
@ -347,12 +356,24 @@ public VotePill(Comment comment)
|
|||
|
||||
AutoSizeAxes = Axes.X;
|
||||
Height = 20;
|
||||
Masking = true;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
borderContainer = new CircularContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
hoverLayer = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0
|
||||
}
|
||||
}
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
|
@ -361,14 +382,49 @@ public VotePill(Comment comment)
|
|||
Margin = new MarginPadding { Horizontal = margin },
|
||||
Font = OsuFont.GetFont(size: 14),
|
||||
Text = $"+{comment.VotesCount}"
|
||||
}
|
||||
},
|
||||
sideNumber = new SpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreRight,
|
||||
Text = "+1",
|
||||
Font = OsuFont.GetFont(size: 14),
|
||||
Margin = new MarginPadding { Right = 3 },
|
||||
Alpha = 0,
|
||||
},
|
||||
new HoverClickSounds(),
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
background.Colour = comment.IsVoted ? colours.GreenLight : OsuColour.Gray(0.05f);
|
||||
AccentColour = borderContainer.BorderColour = sideNumber.Colour = colours.GreenLight;
|
||||
background.Colour = comment.IsVoted ? AccentColour : OsuColour.Gray(0.05f);
|
||||
hoverLayer.Colour = Color4.Black.Opacity(0.5f);
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
if (comment.IsVoted)
|
||||
hoverLayer.Show();
|
||||
else
|
||||
sideNumber.Show();
|
||||
|
||||
borderContainer.BorderThickness = 3;
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
base.OnHoverLost(e);
|
||||
|
||||
if (comment.IsVoted)
|
||||
hoverLayer.Hide();
|
||||
else
|
||||
sideNumber.Hide();
|
||||
|
||||
borderContainer.BorderThickness = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue