1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 08:12:55 +08:00
osu-lazer/osu.Game/Overlays/BeatmapSet/Scores/ClickableUsername.cs

59 lines
1.4 KiB
C#
Raw Normal View History

// 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.
2018-04-13 17:19:50 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
2018-10-02 11:02:47 +08:00
using osu.Framework.Input.Events;
using osu.Game.Graphics;
2018-04-13 17:19:50 +08:00
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Users;
namespace osu.Game.Overlays.BeatmapSet.Scores
{
public class ClickableUsername : OsuHoverContainer
{
private readonly OsuSpriteText text;
private UserProfileOverlay profile;
private User user;
2019-02-28 12:31:40 +08:00
2018-04-13 17:19:50 +08:00
public User User
{
get => user;
2018-04-13 17:19:50 +08:00
set
{
if (user == value) return;
2019-02-28 12:31:40 +08:00
2018-04-13 17:19:50 +08:00
user = value;
text.Text = user.Username;
}
}
public float TextSize
{
get => text.Font.Size;
set => text.Font = text.Font.With(size: value);
2018-04-13 17:19:50 +08:00
}
public ClickableUsername()
{
AutoSizeAxes = Axes.Both;
Child = text = new OsuSpriteText { Font = OsuFont.GetFont(weight: FontWeight.Bold, italics: true) };
2018-04-13 17:19:50 +08:00
}
[BackgroundDependencyLoader(true)]
private void load(UserProfileOverlay profile)
{
this.profile = profile;
}
2018-10-02 11:02:47 +08:00
protected override bool OnClick(ClickEvent e)
2018-04-13 17:19:50 +08:00
{
profile?.ShowUser(user);
return true;
}
}
}