mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 08:22:56 +08:00
Show LoginOverlay if not logged-in when clicking on a pill
This commit is contained in:
parent
6379381f95
commit
20161aea6a
@ -8,6 +8,7 @@ using osu.Game.Online.API.Requests.Responses;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Online
|
namespace osu.Game.Tests.Visual.Online
|
||||||
{
|
{
|
||||||
@ -17,11 +18,30 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[Cached]
|
[Cached]
|
||||||
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
|
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
|
||||||
|
|
||||||
|
[Cached]
|
||||||
|
private LoginOverlay login;
|
||||||
|
|
||||||
private TestPill votePill;
|
private TestPill votePill;
|
||||||
|
private readonly Container pillContainer;
|
||||||
|
|
||||||
|
public TestSceneVotePill()
|
||||||
|
{
|
||||||
|
AddRange(new Drawable[]
|
||||||
|
{
|
||||||
|
pillContainer = new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
AutoSizeAxes = Axes.Both
|
||||||
|
},
|
||||||
|
login = new LoginOverlay()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestUserCommentPill()
|
public void TestUserCommentPill()
|
||||||
{
|
{
|
||||||
|
AddStep("Hide login overlay", () => login.Hide());
|
||||||
AddStep("Log in", logIn);
|
AddStep("Log in", logIn);
|
||||||
AddStep("User comment", () => addVotePill(getUserComment()));
|
AddStep("User comment", () => addVotePill(getUserComment()));
|
||||||
AddAssert("Background is transparent", () => votePill.Background.Alpha == 0);
|
AddAssert("Background is transparent", () => votePill.Background.Alpha == 0);
|
||||||
@ -32,9 +52,10 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestRandomCommentPill()
|
public void TestRandomCommentPill()
|
||||||
{
|
{
|
||||||
|
AddStep("Hide login overlay", () => login.Hide());
|
||||||
AddStep("Log in", logIn);
|
AddStep("Log in", logIn);
|
||||||
AddStep("Random comment", () => addVotePill(getRandomComment()));
|
AddStep("Random comment", () => addVotePill(getRandomComment()));
|
||||||
AddAssert("Background is not transparent", () => votePill.Background.Alpha == 1);
|
AddAssert("Background is visible", () => votePill.Background.Alpha == 1);
|
||||||
AddStep("Click", () => votePill.Click());
|
AddStep("Click", () => votePill.Click());
|
||||||
AddAssert("Loading", () => votePill.IsLoading);
|
AddAssert("Loading", () => votePill.IsLoading);
|
||||||
}
|
}
|
||||||
@ -42,10 +63,11 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestOfflineRandomCommentPill()
|
public void TestOfflineRandomCommentPill()
|
||||||
{
|
{
|
||||||
|
AddStep("Hide login overlay", () => login.Hide());
|
||||||
AddStep("Log out", API.Logout);
|
AddStep("Log out", API.Logout);
|
||||||
AddStep("Random comment", () => addVotePill(getRandomComment()));
|
AddStep("Random comment", () => addVotePill(getRandomComment()));
|
||||||
AddStep("Click", () => votePill.Click());
|
AddStep("Click", () => votePill.Click());
|
||||||
AddAssert("Not loading", () => !votePill.IsLoading);
|
AddAssert("Login overlay is visible", () => login.State.Value == Visibility.Visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logIn() => API.Login("localUser", "password");
|
private void logIn() => API.Login("localUser", "password");
|
||||||
@ -66,12 +88,12 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
|
|
||||||
private void addVotePill(Comment comment)
|
private void addVotePill(Comment comment)
|
||||||
{
|
{
|
||||||
Clear();
|
pillContainer.Clear();
|
||||||
Add(votePill = new TestPill(comment)
|
pillContainer.Child = votePill = new TestPill(comment)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestPill : VotePill
|
private class TestPill : VotePill
|
||||||
|
@ -33,6 +33,9 @@ namespace osu.Game.Overlays.Comments
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IAPIProvider api { get; set; }
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
|
[Resolved(canBeNull: true)]
|
||||||
|
private LoginOverlay login { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OverlayColourProvider colourProvider { get; set; }
|
private OverlayColourProvider colourProvider { get; set; }
|
||||||
|
|
||||||
@ -66,7 +69,7 @@ namespace osu.Game.Overlays.Comments
|
|||||||
|
|
||||||
var ownComment = api.LocalUser.Value.Id == comment.UserId;
|
var ownComment = api.LocalUser.Value.Id == comment.UserId;
|
||||||
|
|
||||||
if (api.IsLoggedIn && !ownComment)
|
if (!ownComment)
|
||||||
Action = onAction;
|
Action = onAction;
|
||||||
|
|
||||||
Background.Alpha = ownComment ? 0 : 1;
|
Background.Alpha = ownComment ? 0 : 1;
|
||||||
@ -83,6 +86,12 @@ namespace osu.Game.Overlays.Comments
|
|||||||
|
|
||||||
private void onAction()
|
private void onAction()
|
||||||
{
|
{
|
||||||
|
if (!api.IsLoggedIn)
|
||||||
|
{
|
||||||
|
login?.Show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
request = new CommentVoteRequest(comment.Id, isVoted.Value ? CommentVoteAction.UnVote : CommentVoteAction.Vote);
|
request = new CommentVoteRequest(comment.Id, isVoted.Value ? CommentVoteAction.UnVote : CommentVoteAction.Vote);
|
||||||
request.Success += onSuccess;
|
request.Success += onSuccess;
|
||||||
api.Queue(request);
|
api.Queue(request);
|
||||||
|
Loading…
Reference in New Issue
Block a user