mirror of
https://github.com/ppy/osu
synced 2024-12-28 18:02:53 +00:00
Rename variables and mak seconary tooltip type work again
This commit is contained in:
parent
615d8384ab
commit
7fc2050f72
@ -102,9 +102,9 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddWaitStep("wait for tooltip to hide", 3);
|
||||
}
|
||||
|
||||
private Drawable generateUser(string username, int id, CountryCode countryCode, string cover, bool onlyUsername, string? color = null)
|
||||
private Drawable generateUser(string username, int id, CountryCode countryCode, string cover, bool showPanel, string? color = null)
|
||||
{
|
||||
return new ClickableAvatar(new APIUser
|
||||
var user = new APIUser
|
||||
{
|
||||
Username = username,
|
||||
Id = id,
|
||||
@ -115,7 +115,9 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
Value = new UserStatusOnline()
|
||||
},
|
||||
})
|
||||
};
|
||||
|
||||
return new ClickableAvatar(user, showPanel)
|
||||
{
|
||||
Width = 50,
|
||||
Height = 50,
|
||||
@ -125,7 +127,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
Type = EdgeEffectType.Shadow, Radius = 1, Colour = Color4.Black.Opacity(0.2f),
|
||||
},
|
||||
ShowUsernameOnly = onlyUsername,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4Extensions.FromHex(@"27252d"),
|
||||
},
|
||||
avatar = new UpdateableAvatar(showUsernameOnly: true) { RelativeSizeAxes = Axes.Both },
|
||||
avatar = new UpdateableAvatar(showUserPanelOnHover: true) { RelativeSizeAxes = Axes.Both },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
set => avatar.User = value;
|
||||
}
|
||||
|
||||
private readonly UpdateableAvatar avatar = new UpdateableAvatar(showUsernameOnly: true) { RelativeSizeAxes = Axes.Both };
|
||||
private readonly UpdateableAvatar avatar = new UpdateableAvatar(showUserPanelOnHover: true) { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colours)
|
||||
|
@ -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.Linq;
|
||||
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.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osuTK;
|
||||
@ -15,15 +18,13 @@ namespace osu.Game.Users.Drawables
|
||||
{
|
||||
public partial class ClickableAvatar : OsuClickableContainer, IHasCustomTooltip<APIUser?>
|
||||
{
|
||||
// public ITooltip<APIUser> GetCustomTooltip() => new APIUserTooltip(user!) { ShowTooltip = TooltipEnabled };
|
||||
public ITooltip<APIUser?> GetCustomTooltip() => new UserCardTooltip();
|
||||
public ITooltip<APIUser?> GetCustomTooltip() => showCardOnHover ? new UserCardTooltip() : new NoCardTooltip();
|
||||
|
||||
public APIUser? TooltipContent { get; }
|
||||
|
||||
private readonly APIUser? user;
|
||||
|
||||
// TODO: reimplement.
|
||||
public bool ShowUsernameOnly { get; set; }
|
||||
private readonly bool showCardOnHover;
|
||||
|
||||
[Resolved]
|
||||
private OsuGame? game { get; set; }
|
||||
@ -32,12 +33,15 @@ namespace osu.Game.Users.Drawables
|
||||
/// A clickable avatar for the specified user, with UI sounds included.
|
||||
/// </summary>
|
||||
/// <param name="user">The user. A null value will get a placeholder avatar.</param>
|
||||
public ClickableAvatar(APIUser? user = null)
|
||||
/// <param name="showCardOnHover"></param>
|
||||
public ClickableAvatar(APIUser? user = null, bool showCardOnHover = false)
|
||||
{
|
||||
if (user?.Id != APIUser.SYSTEM_USER_ID)
|
||||
Action = openProfile;
|
||||
|
||||
TooltipContent = this.user = user;
|
||||
this.showCardOnHover = showCardOnHover;
|
||||
|
||||
TooltipContent = this.user = user ?? new GuestUser();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -65,23 +69,59 @@ namespace osu.Game.Users.Drawables
|
||||
public UserCardTooltip()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Masking = true;
|
||||
CornerRadius = 5;
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
this.FadeIn(20, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void PopOut() => this.FadeOut(80, Easing.OutQuint);
|
||||
protected override void PopIn() => this.FadeIn(150, Easing.OutQuint);
|
||||
protected override void PopOut() => this.Delay(150).FadeOut(500, Easing.OutQuint);
|
||||
|
||||
public void Move(Vector2 pos) => Position = pos;
|
||||
|
||||
public void SetContent(APIUser? content) => LoadComponentAsync(new UserGridPanel(content ?? new GuestUser())
|
||||
private APIUser? user;
|
||||
|
||||
public void SetContent(APIUser? content)
|
||||
{
|
||||
Width = 300,
|
||||
}, panel => Child = panel);
|
||||
if (content == user && Children.Any())
|
||||
return;
|
||||
|
||||
user = content;
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
LoadComponentAsync(new UserGridPanel(user)
|
||||
{
|
||||
Width = 300,
|
||||
}, panel => Child = panel);
|
||||
}
|
||||
else
|
||||
{
|
||||
var tooltip = new OsuTooltipContainer.OsuTooltip();
|
||||
tooltip.SetContent(ContextMenuStrings.ViewProfile);
|
||||
tooltip.Show();
|
||||
|
||||
Child = tooltip;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial class NoCardTooltip : VisibilityContainer, ITooltip<APIUser?>
|
||||
{
|
||||
public NoCardTooltip()
|
||||
{
|
||||
var tooltip = new OsuTooltipContainer.OsuTooltip();
|
||||
tooltip.SetContent(ContextMenuStrings.ViewProfile);
|
||||
tooltip.Show();
|
||||
|
||||
Child = tooltip;
|
||||
}
|
||||
|
||||
protected override void PopIn() => this.FadeIn(150, Easing.OutQuint);
|
||||
protected override void PopOut() => this.Delay(150).FadeOut(500, Easing.OutQuint);
|
||||
|
||||
public void Move(Vector2 pos) => Position = pos;
|
||||
|
||||
public void SetContent(APIUser? content)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,20 +47,20 @@ namespace osu.Game.Users.Drawables
|
||||
|
||||
private readonly bool isInteractive;
|
||||
private readonly bool showGuestOnNull;
|
||||
private readonly bool showUsernameOnly;
|
||||
private readonly bool showUserPanelOnHover;
|
||||
|
||||
/// <summary>
|
||||
/// Construct a new UpdateableAvatar.
|
||||
/// </summary>
|
||||
/// <param name="user">The initial user to display.</param>
|
||||
/// <param name="isInteractive">If set to true, hover/click sounds will play and clicking the avatar will open the user's profile.</param>
|
||||
/// <param name="showUsernameOnly">If set to true, the user status panel will be displayed in the tooltip.</param>
|
||||
/// <param name="showUserPanelOnHover">If set to true, the user status panel will be displayed in the tooltip.</param>
|
||||
/// <param name="showGuestOnNull">Whether to show a default guest representation on null user (as opposed to nothing).</param>
|
||||
public UpdateableAvatar(APIUser? user = null, bool isInteractive = true, bool showUsernameOnly = false, bool showGuestOnNull = true)
|
||||
public UpdateableAvatar(APIUser? user = null, bool isInteractive = true, bool showUserPanelOnHover = false, bool showGuestOnNull = true)
|
||||
{
|
||||
this.isInteractive = isInteractive;
|
||||
this.showGuestOnNull = showGuestOnNull;
|
||||
this.showUsernameOnly = showUsernameOnly;
|
||||
this.showUserPanelOnHover = showUserPanelOnHover;
|
||||
|
||||
User = user;
|
||||
}
|
||||
@ -72,10 +72,9 @@ namespace osu.Game.Users.Drawables
|
||||
|
||||
if (isInteractive)
|
||||
{
|
||||
return new ClickableAvatar(user)
|
||||
return new ClickableAvatar(user, showUserPanelOnHover)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ShowUsernameOnly = showUsernameOnly
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user