2019-01-24 16:43:03 +08:00
|
|
|
|
// 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
|
|
|
|
|
2018-12-26 20:58:14 +08:00
|
|
|
|
using Humanizer;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics;
|
2018-12-20 17:04:35 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2019-06-18 01:57:57 +08:00
|
|
|
|
using osu.Game.Users.Drawables;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-12-25 23:50:00 +08:00
|
|
|
|
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-12-26 00:12:33 +08:00
|
|
|
|
public class ParticipantInfo : OnlinePlayComposite
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-12-26 19:31:04 +08:00
|
|
|
|
public ParticipantInfo()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Height = 15f;
|
2019-02-05 18:00:01 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-02-05 18:00:01 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
OsuSpriteText summary;
|
2018-12-07 18:38:46 +08:00
|
|
|
|
Container flagContainer;
|
2018-12-20 17:04:35 +08:00
|
|
|
|
LinkFlowContainer hostText;
|
2018-12-07 18:38:46 +08:00
|
|
|
|
|
2019-02-05 18:00:01 +08:00
|
|
|
|
InternalChildren = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Spacing = new Vector2(5f, 0f),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
flagContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
Width = 22f,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
},
|
2018-12-20 17:04:35 +08:00
|
|
|
|
hostText = new LinkFlowContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2018-12-20 17:04:35 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
2019-02-05 18:00:01 +08:00
|
|
|
|
new FillFlowContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
2019-02-05 18:00:01 +08:00
|
|
|
|
Colour = colours.Gray9,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
2018-12-26 20:58:14 +08:00
|
|
|
|
summary = new OsuSpriteText
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-12-26 19:31:04 +08:00
|
|
|
|
Text = "0 participants",
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
2018-12-07 18:38:46 +08:00
|
|
|
|
|
2019-02-22 17:09:23 +08:00
|
|
|
|
Host.BindValueChanged(host =>
|
2018-12-07 18:38:46 +08:00
|
|
|
|
{
|
2018-12-20 17:04:35 +08:00
|
|
|
|
hostText.Clear();
|
2019-01-17 17:44:22 +08:00
|
|
|
|
flagContainer.Clear();
|
2018-12-20 17:04:35 +08:00
|
|
|
|
|
2019-02-22 17:09:23 +08:00
|
|
|
|
if (host.NewValue != null)
|
2019-01-17 17:44:22 +08:00
|
|
|
|
{
|
|
|
|
|
hostText.AddText("hosted by ");
|
2020-03-13 12:32:16 +08:00
|
|
|
|
hostText.AddUserLink(host.NewValue, s => s.Font = s.Font.With(Typeface.Torus, weight: FontWeight.Bold, italics: true));
|
2019-04-05 13:15:36 +08:00
|
|
|
|
|
2019-06-18 01:57:57 +08:00
|
|
|
|
flagContainer.Child = new UpdateableFlag(host.NewValue.Country) { RelativeSizeAxes = Axes.Both };
|
2019-01-17 17:44:22 +08:00
|
|
|
|
}
|
2019-02-05 18:00:01 +08:00
|
|
|
|
}, true);
|
2018-12-07 18:38:46 +08:00
|
|
|
|
|
2019-02-28 13:55:45 +08:00
|
|
|
|
ParticipantCount.BindValueChanged(count => summary.Text = "participant".ToQuantity(count.NewValue), true);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|