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