1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-08 09:27:32 +08:00
osu-lazer/osu.Game/Screens/Multi/Components/ParticipantCount.cs
2019-02-06 13:52:48 +09:00

74 lines
2.2 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.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Screens.Multi.Components
{
public class ParticipantCountDisplay : MultiplayerComposite
{
private const float text_size = 30;
private const float transition_duration = 100;
private OsuSpriteText slash, maxText;
public ParticipantCountDisplay()
{
AutoSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load()
{
OsuSpriteText count;
InternalChild = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
LayoutDuration = transition_duration,
Children = new[]
{
count = new OsuSpriteText
{
TextSize = text_size,
Font = @"Exo2.0-Bold"
},
slash = new OsuSpriteText
{
Text = @"/",
TextSize = text_size,
Font = @"Exo2.0-Light"
},
maxText = new OsuSpriteText
{
TextSize = text_size,
Font = @"Exo2.0-Light"
},
}
};
MaxParticipants.BindValueChanged(_ => updateMax(), true);
ParticipantCount.BindValueChanged(v => count.Text = v.ToString("#,0"), true);
}
private void updateMax()
{
if (MaxParticipants.Value == null)
{
slash.FadeOut(transition_duration);
maxText.FadeOut(transition_duration);
}
else
{
slash.FadeIn(transition_duration);
maxText.Text = MaxParticipants.Value.ToString();
maxText.FadeIn(transition_duration);
}
}
}
}