1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:17:26 +08:00

Merge pull request #8441 from EVAST9919/fix-panel-message

Fix last seen date being visible in user panel when it shouldn't
This commit is contained in:
Dean Herbert 2020-03-26 10:15:23 +09:00 committed by GitHub
commit a141e2e8b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 6 deletions

View File

@ -28,7 +28,7 @@ namespace osu.Game.Tests.Visual.Online
private readonly Bindable<UserStatus> status = new Bindable<UserStatus>();
private UserGridPanel peppy;
private UserListPanel evast;
private TestUserListPanel evast;
[Resolved]
private RulesetStore rulesetStore { get; set; }
@ -38,6 +38,9 @@ namespace osu.Game.Tests.Visual.Online
{
UserGridPanel flyte;
activity.Value = null;
status.Value = null;
Child = new FillFlowContainer
{
Anchor = Anchor.Centre,
@ -63,7 +66,7 @@ namespace osu.Game.Tests.Visual.Online
IsSupporter = true,
SupportLevel = 3,
}) { Width = 300 },
evast = new UserListPanel(new User
evast = new TestUserListPanel(new User
{
Username = @"Evast",
Id = 8195163,
@ -96,7 +99,7 @@ namespace osu.Game.Tests.Visual.Online
[Test]
public void TestUserActivity()
{
AddStep("set online status", () => peppy.Status.Value = evast.Status.Value = new UserStatusOnline());
AddStep("set online status", () => status.Value = new UserStatusOnline());
AddStep("idle", () => activity.Value = null);
AddStep("spectating", () => activity.Value = new UserActivity.Spectating());
@ -109,6 +112,29 @@ namespace osu.Game.Tests.Visual.Online
AddStep("modding", () => activity.Value = new UserActivity.Modding());
}
[Test]
public void TestUserActivityChange()
{
AddAssert("visit message is visible", () => evast.LastVisitMessage.IsPresent);
AddStep("set online status", () => status.Value = new UserStatusOnline());
AddAssert("visit message is not visible", () => !evast.LastVisitMessage.IsPresent);
AddStep("set choosing activity", () => activity.Value = new UserActivity.ChoosingBeatmap());
AddStep("set offline status", () => status.Value = new UserStatusOffline());
AddAssert("visit message is visible", () => evast.LastVisitMessage.IsPresent);
AddStep("set online status", () => status.Value = new UserStatusOnline());
AddAssert("visit message is not visible", () => !evast.LastVisitMessage.IsPresent);
}
private UserActivity soloGameStatusForRuleset(int rulesetId) => new UserActivity.SoloGame(null, rulesetStore.GetRuleset(rulesetId));
private class TestUserListPanel : UserListPanel
{
public TestUserListPanel(User user)
: base(user)
{
}
public new TextFlowContainer LastVisitMessage => base.LastVisitMessage;
}
}
}

View File

@ -36,9 +36,10 @@ namespace osu.Game.Users
protected DelayedLoadUnloadWrapper Background { get; private set; }
protected TextFlowContainer LastVisitMessage { get; private set; }
private SpriteIcon statusIcon;
private OsuSpriteText statusMessage;
private TextFlowContainer lastVisitMessage;
protected UserPanel(User user)
{
@ -153,7 +154,7 @@ namespace osu.Game.Users
var alignment = rightAlignedChildren ? Anchor.CentreRight : Anchor.CentreLeft;
statusContainer.Add(lastVisitMessage = new TextFlowContainer(t => t.Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold)).With(text =>
statusContainer.Add(LastVisitMessage = new TextFlowContainer(t => t.Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold)).With(text =>
{
text.Anchor = alignment;
text.Origin = alignment;
@ -184,6 +185,8 @@ namespace osu.Game.Users
{
if (status != null)
{
LastVisitMessage.FadeTo(status is UserStatusOffline && User.LastVisit.HasValue ? 1 : 0);
// Set status message based on activity (if we have one) and status is not offline
if (activity != null && !(status is UserStatusOffline))
{
@ -193,7 +196,6 @@ namespace osu.Game.Users
}
// Otherwise use only status
lastVisitMessage.FadeTo(status is UserStatusOffline && User.LastVisit.HasValue ? 1 : 0);
statusMessage.Text = status.Message;
statusIcon.FadeColour(status.GetAppropriateColour(colours), 500, Easing.OutQuint);