From e287dae64b59aa1cf6f67f2485f7541b98a8cc44 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 29 Oct 2019 21:25:48 +0300 Subject: [PATCH] Fix VotePill can be activated by the comment sender --- osu.Game/Overlays/Comments/VotePill.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/osu.Game/Overlays/Comments/VotePill.cs b/osu.Game/Overlays/Comments/VotePill.cs index e8d9013fd9..b2c8c52bf3 100644 --- a/osu.Game/Overlays/Comments/VotePill.cs +++ b/osu.Game/Overlays/Comments/VotePill.cs @@ -43,6 +43,7 @@ namespace osu.Game.Overlays.Comments private readonly BindableBool isVoted = new BindableBool(); private readonly BindableInt votesCount = new BindableInt(); + private bool disabled; public VotePill(Comment comment) { @@ -69,6 +70,8 @@ namespace osu.Game.Overlays.Comments votesCount.Value = comment.VotesCount; isVoted.BindValueChanged(voted => background.Colour = voted.NewValue ? AccentColour : OsuColour.Gray(0.05f), true); votesCount.BindValueChanged(count => votesCounter.Text = $"+{count.NewValue}", true); + + api.LocalUser.BindValueChanged(user => disabled = user.NewValue?.Id == comment.UserId ? true : false, true); } private void onAction() @@ -145,16 +148,30 @@ namespace osu.Game.Overlays.Comments protected override bool OnHover(HoverEvent e) { + if (disabled) + return false; + onHoverAction(); return base.OnHover(e); } protected override void OnHoverLost(HoverLostEvent e) { + if (disabled) + return; + updateDisplay(); base.OnHoverLost(e); } + protected override bool OnClick(ClickEvent e) + { + if (disabled) + return false; + + return base.OnClick(e); + } + private void updateDisplay() { if (isVoted.Value)