1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-21 07:53:38 +08:00
osu-lazer/osu.Game/Screens/Multi/Components/ParticipantCount.cs

80 lines
2.0 KiB
C#
Raw Normal View History

// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Screens.Multi.Components
{
public class ParticipantCount : FillFlowContainer
{
private const float text_size = 30;
private const float transition_duration = 100;
2018-06-02 01:28:24 +08:00
private readonly OsuSpriteText count, slash, maxText;
public int Count
{
2018-06-01 14:45:09 +08:00
set => count.Text = value.ToString();
}
2018-06-02 01:28:24 +08:00
private int? max;
public int? Max
{
2018-06-02 01:28:24 +08:00
get => max;
set
{
2018-06-02 01:28:24 +08:00
if (value == max) return;
max = value;
updateMax();
}
}
public ParticipantCount()
{
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"
},
2018-06-02 01:28:24 +08:00
maxText = new OsuSpriteText
{
TextSize = text_size,
Font = @"Exo2.0-Light"
},
};
2018-06-02 01:28:24 +08:00
updateMax();
}
private void updateMax()
{
if (Max == null)
{
slash.FadeOut(transition_duration);
maxText.FadeOut(transition_duration);
}
else
{
slash.FadeIn(transition_duration);
maxText.Text = Max.ToString();
maxText.FadeIn(transition_duration);
}
}
}
}