1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 14:57:52 +08:00

Make VotePill background transparent for own comments

This commit is contained in:
Andrei Zavatski 2021-01-22 20:46:20 +03:00
parent 26779a9403
commit 6379381f95
2 changed files with 25 additions and 6 deletions

View File

@ -7,6 +7,7 @@ using osu.Game.Overlays.Comments;
using osu.Game.Online.API.Requests.Responses;
using osu.Framework.Allocation;
using osu.Game.Overlays;
using osu.Framework.Graphics.Shapes;
namespace osu.Game.Tests.Visual.Online
{
@ -16,13 +17,14 @@ namespace osu.Game.Tests.Visual.Online
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
private VotePill votePill;
private TestPill votePill;
[Test]
public void TestUserCommentPill()
{
AddStep("Log in", logIn);
AddStep("User comment", () => addVotePill(getUserComment()));
AddAssert("Background is transparent", () => votePill.Background.Alpha == 0);
AddStep("Click", () => votePill.Click());
AddAssert("Not loading", () => !votePill.IsLoading);
}
@ -32,6 +34,7 @@ namespace osu.Game.Tests.Visual.Online
{
AddStep("Log in", logIn);
AddStep("Random comment", () => addVotePill(getRandomComment()));
AddAssert("Background is not transparent", () => votePill.Background.Alpha == 1);
AddStep("Click", () => votePill.Click());
AddAssert("Loading", () => votePill.IsLoading);
}
@ -64,11 +67,21 @@ namespace osu.Game.Tests.Visual.Online
private void addVotePill(Comment comment)
{
Clear();
Add(votePill = new VotePill(comment)
Add(votePill = new TestPill(comment)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
});
}
private class TestPill : VotePill
{
public new Box Background => base.Background;
public TestPill(Comment comment)
: base(comment)
{
}
}
}
}

View File

@ -36,8 +36,10 @@ namespace osu.Game.Overlays.Comments
[Resolved]
private OverlayColourProvider colourProvider { get; set; }
protected Box Background { get; private set; }
private readonly Comment comment;
private Box background;
private Box hoverLayer;
private CircularContainer borderContainer;
private SpriteText sideNumber;
@ -62,8 +64,12 @@ namespace osu.Game.Overlays.Comments
AccentColour = borderContainer.BorderColour = sideNumber.Colour = colours.GreenLight;
hoverLayer.Colour = Color4.Black.Opacity(0.5f);
if (api.IsLoggedIn && api.LocalUser.Value.Id != comment.UserId)
var ownComment = api.LocalUser.Value.Id == comment.UserId;
if (api.IsLoggedIn && !ownComment)
Action = onAction;
Background.Alpha = ownComment ? 0 : 1;
}
protected override void LoadComplete()
@ -71,7 +77,7 @@ namespace osu.Game.Overlays.Comments
base.LoadComplete();
isVoted.Value = comment.IsVoted;
votesCount.Value = comment.VotesCount;
isVoted.BindValueChanged(voted => background.Colour = voted.NewValue ? AccentColour : colourProvider.Background6, true);
isVoted.BindValueChanged(voted => Background.Colour = voted.NewValue ? AccentColour : colourProvider.Background6, true);
votesCount.BindValueChanged(count => votesCounter.Text = $"+{count.NewValue}", true);
}
@ -102,7 +108,7 @@ namespace osu.Game.Overlays.Comments
Masking = true,
Children = new Drawable[]
{
background = new Box
Background = new Box
{
RelativeSizeAxes = Axes.Both
},