2020-02-14 19:42:14 +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.
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2020-07-07 18:23:11 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2020-02-14 19:42:14 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2020-02-19 16:37:01 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2020-02-14 19:42:14 +08:00
|
|
|
|
|
2020-12-25 23:50:00 +08:00
|
|
|
|
namespace osu.Game.Screens.OnlinePlay.Components
|
2020-02-14 19:42:14 +08:00
|
|
|
|
{
|
2020-12-26 00:12:33 +08:00
|
|
|
|
public partial class ParticipantsDisplay : OnlinePlayComposite
|
2020-02-14 19:42:14 +08:00
|
|
|
|
{
|
2020-07-07 18:23:11 +08:00
|
|
|
|
public Bindable<string> Details = new Bindable<string>();
|
2020-02-19 16:37:01 +08:00
|
|
|
|
|
2020-07-07 18:23:11 +08:00
|
|
|
|
public ParticipantsDisplay(Direction direction)
|
2020-02-14 19:42:14 +08:00
|
|
|
|
{
|
2020-02-19 16:37:01 +08:00
|
|
|
|
OsuScrollContainer scroll;
|
|
|
|
|
ParticipantsList list;
|
|
|
|
|
|
2020-07-07 18:23:11 +08:00
|
|
|
|
AddInternal(scroll = new OsuScrollContainer(direction)
|
2020-02-19 16:37:01 +08:00
|
|
|
|
{
|
|
|
|
|
Child = list = new ParticipantsList()
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
switch (direction)
|
|
|
|
|
{
|
|
|
|
|
case Direction.Horizontal:
|
2020-07-07 18:23:11 +08:00
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
|
2020-02-19 16:37:01 +08:00
|
|
|
|
scroll.RelativeSizeAxes = Axes.X;
|
2023-07-01 23:04:53 +08:00
|
|
|
|
scroll.Height = ParticipantsList.TILE_SIZE + OsuScrollContainer.SCROLL_BAR_WIDTH + OsuScrollContainer.SCROLL_BAR_PADDING * 2;
|
2020-07-07 18:23:11 +08:00
|
|
|
|
|
|
|
|
|
list.RelativeSizeAxes = Axes.Y;
|
|
|
|
|
list.AutoSizeAxes = Axes.X;
|
2020-02-19 16:37:01 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Direction.Vertical:
|
2020-07-07 18:23:11 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
2020-02-19 16:37:01 +08:00
|
|
|
|
scroll.RelativeSizeAxes = Axes.Both;
|
2020-07-07 18:23:11 +08:00
|
|
|
|
|
2020-02-19 16:37:01 +08:00
|
|
|
|
list.RelativeSizeAxes = Axes.X;
|
|
|
|
|
list.AutoSizeAxes = Axes.Y;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2020-02-14 19:42:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
ParticipantCount.BindValueChanged(_ => setParticipantCount());
|
2020-07-07 18:23:11 +08:00
|
|
|
|
MaxParticipants.BindValueChanged(_ => setParticipantCount(), true);
|
2020-02-14 19:42:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-07 18:23:11 +08:00
|
|
|
|
private void setParticipantCount() =>
|
|
|
|
|
Details.Value = MaxParticipants.Value != null ? $"{ParticipantCount.Value}/{MaxParticipants.Value}" : ParticipantCount.Value.ToString();
|
2020-02-14 19:42:14 +08:00
|
|
|
|
}
|
|
|
|
|
}
|