1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 23:27:24 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/Components/ParticipantCountDisplay.cs

72 lines
2.3 KiB
C#
Raw Normal View History

// 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.
2019-02-05 18:00:01 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Screens.OnlinePlay.Components
{
public class ParticipantCountDisplay : OnlinePlayComposite
{
private const float text_size = 30;
private const float transition_duration = 100;
2019-02-05 18:00:01 +08:00
private OsuSpriteText slash, maxText;
2018-12-26 20:58:14 +08:00
public ParticipantCountDisplay()
{
AutoSizeAxes = Axes.Both;
2019-02-05 18:00:01 +08:00
}
2019-02-05 18:00:01 +08:00
[BackgroundDependencyLoader]
private void load()
{
OsuSpriteText count;
InternalChild = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
LayoutDuration = transition_duration,
Children = new[]
{
count = new OsuSpriteText
{
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: text_size)
},
slash = new OsuSpriteText
{
Text = @"/",
Font = OsuFont.GetFont(weight: FontWeight.Light, size: text_size)
},
maxText = new OsuSpriteText
{
Font = OsuFont.GetFont(weight: FontWeight.Light, size: text_size)
},
}
};
MaxParticipants.BindValueChanged(_ => updateMax(), true);
ParticipantCount.BindValueChanged(c => count.Text = c.NewValue.ToString("#,0"), true);
2018-06-02 01:28:24 +08:00
}
private void updateMax()
{
if (MaxParticipants.Value == null)
2018-06-02 01:28:24 +08:00
{
slash.FadeOut(transition_duration);
maxText.FadeOut(transition_duration);
}
else
{
slash.FadeIn(transition_duration);
maxText.Text = MaxParticipants.Value.ToString();
2018-06-02 01:28:24 +08:00
maxText.FadeIn(transition_duration);
}
}
}
}