1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 10:33:01 +08:00
This commit is contained in:
Andrei Zavatski 2019-10-30 03:09:14 +03:00
parent 092d16bb64
commit 1502a6c631

View File

@ -43,14 +43,11 @@ namespace osu.Game.Overlays.Comments
private readonly BindableBool isVoted = new BindableBool(); private readonly BindableBool isVoted = new BindableBool();
private readonly BindableInt votesCount = new BindableInt(); private readonly BindableInt votesCount = new BindableInt();
private bool disabled;
public VotePill(Comment comment) public VotePill(Comment comment)
{ {
this.comment = comment; this.comment = comment;
Action = onAction;
AutoSizeAxes = Axes.X; AutoSizeAxes = Axes.X;
Height = 20; Height = 20;
LoadingAnimationSize = new Vector2(10); LoadingAnimationSize = new Vector2(10);
@ -62,7 +59,8 @@ namespace osu.Game.Overlays.Comments
AccentColour = borderContainer.BorderColour = sideNumber.Colour = colours.GreenLight; AccentColour = borderContainer.BorderColour = sideNumber.Colour = colours.GreenLight;
hoverLayer.Colour = Color4.Black.Opacity(0.5f); hoverLayer.Colour = Color4.Black.Opacity(0.5f);
disabled = api.LocalUser.Value.Id == comment.UserId; if (api.LocalUser.Value.Id != comment.UserId)
Action = onAction;
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -148,31 +146,19 @@ namespace osu.Game.Overlays.Comments
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)
{ {
if (disabled)
return false;
onHoverAction(); onHoverAction();
return base.OnHover(e); return base.OnHover(e);
} }
protected override void OnHoverLost(HoverLostEvent e) protected override void OnHoverLost(HoverLostEvent e)
{ {
if (disabled)
return;
updateDisplay(); updateDisplay();
base.OnHoverLost(e); base.OnHoverLost(e);
} }
protected override bool OnClick(ClickEvent e)
{
if (disabled)
return false;
return base.OnClick(e);
}
private void updateDisplay() private void updateDisplay()
{
if (Action != null)
{ {
if (isVoted.Value) if (isVoted.Value)
{ {
@ -184,6 +170,7 @@ namespace osu.Game.Overlays.Comments
borderContainer.BorderThickness = IsHovered ? 3 : 0; borderContainer.BorderThickness = IsHovered ? 3 : 0;
} }
}
private void onHoverAction() private void onHoverAction()
{ {