1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-17 07:12:55 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/Components/ParticipantsDisplay.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

60 lines
2.0 KiB
C#
Raw Normal View History

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;
using osu.Framework.Bindables;
2020-02-14 19:42:14 +08:00
using osu.Framework.Graphics;
using osu.Game.Graphics.Containers;
2020-02-14 19:42:14 +08:00
namespace osu.Game.Screens.OnlinePlay.Components
2020-02-14 19:42:14 +08:00
{
public partial class ParticipantsDisplay : OnlinePlayComposite
2020-02-14 19:42:14 +08:00
{
public Bindable<string> Details = new Bindable<string>();
public ParticipantsDisplay(Direction direction)
2020-02-14 19:42:14 +08:00
{
OsuScrollContainer scroll;
ParticipantsList list;
AddInternal(scroll = new OsuScrollContainer(direction)
{
Child = list = new ParticipantsList()
});
switch (direction)
{
case Direction.Horizontal:
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
scroll.RelativeSizeAxes = Axes.X;
scroll.Height = ParticipantsList.TILE_SIZE + OsuScrollContainer.SCROLL_BAR_WIDTH + OsuScrollContainer.SCROLL_BAR_PADDING * 2;
list.RelativeSizeAxes = Axes.Y;
list.AutoSizeAxes = Axes.X;
break;
case Direction.Vertical:
RelativeSizeAxes = Axes.Both;
scroll.RelativeSizeAxes = Axes.Both;
list.RelativeSizeAxes = Axes.X;
list.AutoSizeAxes = Axes.Y;
break;
}
2020-02-14 19:42:14 +08:00
}
[BackgroundDependencyLoader]
private void load()
{
ParticipantCount.BindValueChanged(_ => setParticipantCount());
MaxParticipants.BindValueChanged(_ => setParticipantCount(), true);
2020-02-14 19:42:14 +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
}
}