mirror of
https://github.com/ppy/osu
synced 2024-12-30 10:52:30 +00:00
35d3292200
I think this makes things a bit more readable. The only weird case is the transfer of details from the component to the `OverlinedHeader`, but bindables make it not too bad.
60 lines
2.0 KiB
C#
60 lines
2.0 KiB
C#
// 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;
|
|
using osu.Framework.Graphics;
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
namespace osu.Game.Screens.Multi.Components
|
|
{
|
|
public class ParticipantsDisplay : MultiplayerComposite
|
|
{
|
|
public Bindable<string> Details = new Bindable<string>();
|
|
|
|
public ParticipantsDisplay(Direction direction)
|
|
{
|
|
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_HEIGHT + 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;
|
|
}
|
|
}
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load()
|
|
{
|
|
ParticipantCount.BindValueChanged(_ => setParticipantCount());
|
|
MaxParticipants.BindValueChanged(_ => setParticipantCount(), true);
|
|
}
|
|
|
|
private void setParticipantCount() =>
|
|
Details.Value = MaxParticipants.Value != null ? $"{ParticipantCount.Value}/{MaxParticipants.Value}" : ParticipantCount.Value.ToString();
|
|
}
|
|
}
|