1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-06 22:47:20 +08:00

80 lines
2.5 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-05-28 22:11:01 -03:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
2020-02-14 20:07:52 +09:00
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Users.Drawables;
2018-12-20 15:17:33 +09:00
using osuTK;
2018-05-28 22:11:01 -03:00
2018-12-10 19:20:41 +09:00
namespace osu.Game.Screens.Multi.Match.Components
2018-05-28 22:11:01 -03:00
{
2019-02-05 19:00:01 +09:00
public class Header : MultiplayerComposite
2018-05-28 22:11:01 -03:00
{
2020-02-14 20:07:52 +09:00
public const float HEIGHT = 50;
2018-05-29 01:51:04 -03:00
2020-02-14 20:07:52 +09:00
private UpdateableAvatar avatar;
private LinkFlowContainer hostText;
2019-08-08 07:08:51 +03:00
2019-02-05 19:00:01 +09:00
public Header()
2018-05-28 22:11:01 -03:00
{
RelativeSizeAxes = Axes.X;
2018-05-29 01:51:04 -03:00
Height = HEIGHT;
2019-02-05 19:00:01 +09:00
}
2018-05-28 22:11:01 -03:00
2019-02-05 19:00:01 +09:00
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
2020-02-14 20:07:52 +09:00
InternalChild = new FillFlowContainer
2018-05-28 22:11:01 -03:00
{
2020-02-14 20:07:52 +09:00
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(10, 0),
Children = new Drawable[]
2018-05-28 22:11:01 -03:00
{
2020-02-14 20:07:52 +09:00
avatar = new UpdateableAvatar
2018-12-20 15:17:33 +09:00
{
2020-02-14 20:07:52 +09:00
Size = new Vector2(50),
Masking = true,
CornerRadius = 10,
},
new FillFlowContainer
2018-05-28 22:11:01 -03:00
{
2020-02-14 20:07:52 +09:00
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Children = new Drawable[]
2018-12-20 15:17:33 +09:00
{
2020-02-14 20:07:52 +09:00
new OsuSpriteText
2018-12-20 15:17:33 +09:00
{
2020-02-14 20:07:52 +09:00
Font = OsuFont.GetFont(size: 30),
Current = { BindTarget = RoomName }
2018-05-28 22:11:01 -03:00
},
2020-02-14 20:07:52 +09:00
hostText = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 20, weight: FontWeight.SemiBold))
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
}
}
}
}
2018-05-28 22:11:01 -03:00
};
2020-02-14 20:07:52 +09:00
Host.BindValueChanged(host =>
2018-05-28 22:11:01 -03:00
{
2020-02-14 20:07:52 +09:00
avatar.User = host.NewValue;
2020-02-14 20:07:52 +09:00
hostText.Clear();
2020-02-14 20:07:52 +09:00
if (host.NewValue != null)
{
hostText.AddText("hosted by ");
hostText.AddUserLink(host.NewValue);
}
}, true);
}
2018-05-28 22:11:01 -03:00
}
}