1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 10:57:27 +08:00
osu-lazer/osu.Game/Screens/Multi/Match/Components/HostInfo.cs

61 lines
1.9 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.
2019-02-21 18:04:31 +08:00
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Users;
using osuTK;
namespace osu.Game.Screens.Multi.Match.Components
{
public class HostInfo : CompositeDrawable
{
2018-12-25 17:07:19 +08:00
public readonly IBindable<User> Host = new Bindable<User>();
private readonly LinkFlowContainer linkContainer;
private readonly UpdateableAvatar avatar;
public HostInfo()
{
AutoSizeAxes = Axes.X;
Height = 50;
InternalChild = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5, 0),
Children = new Drawable[]
{
2018-12-25 17:07:19 +08:00
avatar = new UpdateableAvatar { Size = new Vector2(50) },
new FillFlowContainer
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
2018-12-20 17:21:55 +08:00
Child = linkContainer = new LinkFlowContainer { AutoSizeAxes = Axes.Both }
}
}
};
Host.BindValueChanged(host => updateHost(host.NewValue));
2018-12-25 17:07:19 +08:00
}
private void updateHost(User host)
{
avatar.User = host;
if (host != null)
2018-12-21 12:26:50 +08:00
{
linkContainer.AddText("hosted by");
linkContainer.NewLine();
2019-04-05 13:15:36 +08:00
linkContainer.AddUserLink(host, s => s.Font = s.Font.With(Typeface.Exo, weight: FontWeight.Bold, italics: true));
2018-12-21 12:26:50 +08:00
}
}
}
}