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