2018-05-29 11:51:56 +08:00
|
|
|
|
// 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;
|
2018-05-29 11:51:56 +08:00
|
|
|
|
|
|
|
|
|
public int Count
|
|
|
|
|
{
|
2018-06-01 14:45:09 +08:00
|
|
|
|
set => count.Text = value.ToString();
|
2018-05-29 11:51:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-02 01:28:24 +08:00
|
|
|
|
private int? max;
|
2018-05-29 11:51:56 +08:00
|
|
|
|
public int? Max
|
|
|
|
|
{
|
2018-06-02 01:28:24 +08:00
|
|
|
|
get => max;
|
2018-05-29 11:51:56 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2018-06-02 01:28:24 +08:00
|
|
|
|
if (value == max) return;
|
|
|
|
|
max = value;
|
|
|
|
|
|
|
|
|
|
updateMax();
|
2018-05-29 11:51:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
2018-05-29 11:51:56 +08:00
|
|
|
|
{
|
|
|
|
|
TextSize = text_size,
|
|
|
|
|
Font = @"Exo2.0-Light"
|
|
|
|
|
},
|
|
|
|
|
};
|
2018-06-01 17:08:57 +08:00
|
|
|
|
|
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);
|
|
|
|
|
}
|
2018-05-29 11:51:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|