1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-20 11:02:54 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomInfo.cs

94 lines
3.3 KiB
C#
Raw Normal View History

2020-02-19 16:47:59 +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.
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Screens.OnlinePlay.Components;
2020-02-19 16:47:59 +08:00
using osuTK;
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
2020-02-19 16:47:59 +08:00
{
public class RoomInfo : OnlinePlayComposite
2020-02-19 16:47:59 +08:00
{
private readonly List<Drawable> statusElements = new List<Drawable>();
private readonly OsuTextFlowContainer roomName;
2020-02-19 16:47:59 +08:00
public RoomInfo()
{
AutoSizeAxes = Axes.Y;
RoomStatusInfo statusInfo;
ModeTypeInfo typeInfo;
ParticipantInfo participantInfo;
InternalChild = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 4),
Children = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
new FillFlowContainer
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
2020-02-19 16:47:59 +08:00
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
roomName = new OsuTextFlowContainer(t => t.Font = OsuFont.GetFont(size: 30))
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
},
2020-02-19 16:47:59 +08:00
statusInfo = new RoomStatusInfo(),
}
},
typeInfo = new ModeTypeInfo
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight
2020-02-19 16:47:59 +08:00
}
}
},
participantInfo = new ParticipantInfo(),
}
};
statusElements.AddRange(new Drawable[] { statusInfo, typeInfo, participantInfo });
}
protected override void LoadComplete()
{
base.LoadComplete();
if (RoomID.Value == null)
statusElements.ForEach(e => e.FadeOut());
RoomID.BindValueChanged(id =>
{
if (id.NewValue == null)
statusElements.ForEach(e => e.FadeOut(100));
else
statusElements.ForEach(e => e.FadeIn(100));
}, true);
RoomName.BindValueChanged(name =>
{
roomName.Text = name.NewValue ?? "No room selected";
}, true);
}
}
}