mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 09:57:21 +09:00
Add ParticipantCount to share with the Match screen.
This commit is contained in:
parent
852d7ef48d
commit
d090323c00
67
osu.Game/Screens/Multi/Components/ParticipantCount.cs
Normal file
67
osu.Game/Screens/Multi/Components/ParticipantCount.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
// 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;
|
||||||
|
|
||||||
|
private readonly OsuSpriteText count, slash, max;
|
||||||
|
|
||||||
|
public int Count
|
||||||
|
{
|
||||||
|
set { count.Text = value.ToString(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int? Max
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
slash.FadeOut(transition_duration);
|
||||||
|
max.FadeOut(transition_duration);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
slash.FadeIn(transition_duration);
|
||||||
|
max.FadeIn(transition_duration);
|
||||||
|
max.Text = value.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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"
|
||||||
|
},
|
||||||
|
max = new OsuSpriteText
|
||||||
|
{
|
||||||
|
TextSize = text_size,
|
||||||
|
Font = @"Exo2.0-Light"
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -38,7 +38,8 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
private OsuColour colours;
|
private OsuColour colours;
|
||||||
private Box statusStrip;
|
private Box statusStrip;
|
||||||
private UpdateableBeatmapSetCover cover;
|
private UpdateableBeatmapSetCover cover;
|
||||||
private FillFlowContainer topFlow, participantsFlow, participantNumbersFlow;
|
private ParticipantCount participantCount;
|
||||||
|
private FillFlowContainer topFlow, participantsFlow;
|
||||||
private OsuSpriteText name, status;
|
private OsuSpriteText name, status;
|
||||||
private BeatmapTypeInfo beatmapTypeInfo;
|
private BeatmapTypeInfo beatmapTypeInfo;
|
||||||
private ScrollContainer participantsScroll;
|
private ScrollContainer participantsScroll;
|
||||||
@ -81,9 +82,6 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
{
|
{
|
||||||
this.colours = colours;
|
this.colours = colours;
|
||||||
|
|
||||||
ModeTypeInfo modeTypeInfo;
|
|
||||||
OsuSpriteText participants, participantsSlash, maxParticipants, beatmapAuthor;
|
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
@ -120,32 +118,10 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
Padding = new MarginPadding(20),
|
Padding = new MarginPadding(20),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
participantNumbersFlow = new FillFlowContainer
|
participantCount = new ParticipantCount
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Direction = FillDirection.Horizontal,
|
|
||||||
LayoutDuration = transition_duration,
|
|
||||||
Children = new[]
|
|
||||||
{
|
|
||||||
participants = new OsuSpriteText
|
|
||||||
{
|
|
||||||
TextSize = 30,
|
|
||||||
Font = @"Exo2.0-Bold"
|
|
||||||
},
|
|
||||||
participantsSlash = new OsuSpriteText
|
|
||||||
{
|
|
||||||
Text = @"/",
|
|
||||||
TextSize = 30,
|
|
||||||
Font = @"Exo2.0-Light"
|
|
||||||
},
|
|
||||||
maxParticipants = new OsuSpriteText
|
|
||||||
{
|
|
||||||
TextSize = 30,
|
|
||||||
Font = @"Exo2.0-Light"
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
name = new OsuSpriteText
|
name = new OsuSpriteText
|
||||||
{
|
{
|
||||||
@ -227,6 +203,7 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
nameBind.ValueChanged += n => name.Text = n;
|
nameBind.ValueChanged += n => name.Text = n;
|
||||||
hostBind.ValueChanged += h => participantInfo.Host = h;
|
hostBind.ValueChanged += h => participantInfo.Host = h;
|
||||||
typeBind.ValueChanged += t => beatmapTypeInfo.Type = t;
|
typeBind.ValueChanged += t => beatmapTypeInfo.Type = t;
|
||||||
|
maxParticipantsBind.ValueChanged += m => participantCount.Max = m;
|
||||||
statusBind.ValueChanged += displayStatus;
|
statusBind.ValueChanged += displayStatus;
|
||||||
|
|
||||||
beatmapBind.ValueChanged += b =>
|
beatmapBind.ValueChanged += b =>
|
||||||
@ -235,24 +212,9 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
beatmapTypeInfo.Beatmap = b;
|
beatmapTypeInfo.Beatmap = b;
|
||||||
};
|
};
|
||||||
|
|
||||||
maxParticipantsBind.ValueChanged += m =>
|
|
||||||
{
|
|
||||||
if (m == null)
|
|
||||||
{
|
|
||||||
participantsSlash.FadeOut(transition_duration);
|
|
||||||
maxParticipants.FadeOut(transition_duration);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
participantsSlash.FadeIn(transition_duration);
|
|
||||||
maxParticipants.FadeIn(transition_duration);
|
|
||||||
maxParticipants.Text = m.ToString();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
participantsBind.ValueChanged += p =>
|
participantsBind.ValueChanged += p =>
|
||||||
{
|
{
|
||||||
participants.Text = p.Length.ToString();
|
participantCount.Count = p.Length;
|
||||||
participantInfo.Participants = p;
|
participantInfo.Participants = p;
|
||||||
participantsFlow.ChildrenEnumerable = p.Select(u => new UserTile(u));
|
participantsFlow.ChildrenEnumerable = p.Select(u => new UserTile(u));
|
||||||
};
|
};
|
||||||
@ -282,7 +244,7 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
{
|
{
|
||||||
cover.BeatmapSet = null;
|
cover.BeatmapSet = null;
|
||||||
participantsFlow.FadeOut(transition_duration);
|
participantsFlow.FadeOut(transition_duration);
|
||||||
participantNumbersFlow.FadeOut(transition_duration);
|
participantCount.FadeOut(transition_duration);
|
||||||
beatmapTypeInfo.FadeOut(transition_duration);
|
beatmapTypeInfo.FadeOut(transition_duration);
|
||||||
name.FadeOut(transition_duration);
|
name.FadeOut(transition_duration);
|
||||||
participantInfo.FadeOut(transition_duration);
|
participantInfo.FadeOut(transition_duration);
|
||||||
@ -292,7 +254,7 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
participantsFlow.FadeIn(transition_duration);
|
participantsFlow.FadeIn(transition_duration);
|
||||||
participantNumbersFlow.FadeIn(transition_duration);
|
participantCount.FadeIn(transition_duration);
|
||||||
beatmapTypeInfo.FadeIn(transition_duration);
|
beatmapTypeInfo.FadeIn(transition_duration);
|
||||||
name.FadeIn(transition_duration);
|
name.FadeIn(transition_duration);
|
||||||
participantInfo.FadeIn(transition_duration);
|
participantInfo.FadeIn(transition_duration);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user