fixed review findings

This commit is contained in:
Joshua Hegedus 2023-11-06 08:38:34 +01:00
parent 40d081ee2d
commit b45d8c785c
No known key found for this signature in database
GPG Key ID: 331D6A883C797319
3 changed files with 48 additions and 0 deletions

View File

@ -78,6 +78,8 @@ namespace osu.Game.Tests.Visual.Online
Type = EdgeEffectType.Shadow, Radius = 1, Colour = Color4.Black.Opacity(0.2f),
},
},
new ClickableAvatar(),
new ClickableAvatar(),
},
};
});
@ -120,6 +122,30 @@ namespace osu.Game.Tests.Visual.Online
AddWaitStep("wait for tooltip to show", 5);
AddStep("Hover out", () => InputManager.MoveMouseTo(new Vector2(0)));
AddWaitStep("wait for tooltip to hide", 3);
AddStep($"click null user {4}. {nameof(ClickableAvatar)}", () =>
{
var targets = this.ChildrenOfType<ClickableAvatar>().ToList();
if (targets.Count < 4)
return;
InputManager.MoveMouseTo(targets[3]);
});
AddWaitStep("wait for tooltip to show", 5);
AddStep("Hover out", () => InputManager.MoveMouseTo(new Vector2(0)));
AddWaitStep("wait for tooltip to hide", 3);
AddStep($"click null user {5}. {nameof(ClickableAvatar)}", () =>
{
var targets = this.ChildrenOfType<ClickableAvatar>().ToList();
if (targets.Count < 5)
return;
InputManager.MoveMouseTo(targets[4]);
});
AddWaitStep("wait for tooltip to show", 5);
AddStep("Hover out", () => InputManager.MoveMouseTo(new Vector2(0)));
AddWaitStep("wait for tooltip to hide", 3);
}
}
}

View File

@ -1,12 +1,15 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Game.Graphics.Containers;
using osu.Game.Localisation;
using osu.Game.Online.API.Requests.Responses;
using osuTK;
@ -21,6 +24,24 @@ namespace osu.Game.Users.Drawables
Width = 300
};
public override LocalisableString TooltipText
{
get
{
if (!Enabled.Value)
return string.Empty;
return ShowUsernameTooltip ? (user?.Username ?? string.Empty) : ContextMenuStrings.ViewProfile;
}
set => throw new NotSupportedException();
}
/// <summary>
/// By default, the tooltip will show "view profile" as avatars are usually displayed next to a username.
/// Setting this to <c>true</c> exposes the username via tooltip for special cases where this is not true.
/// </summary>
public bool ShowUsernameTooltip { get; set; }
private readonly APIUser? user;
[Resolved]

View File

@ -75,6 +75,7 @@ namespace osu.Game.Users.Drawables
return new ClickableAvatar(user)
{
RelativeSizeAxes = Axes.Both,
ShowUsernameTooltip = showUsernameTooltip,
};
}
else