1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-24 21:52:56 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomInfo.cs

87 lines
2.9 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;
RoomLocalUserInfo localUserInfo;
2020-02-19 16:47:59 +08:00
RoomStatusInfo statusInfo;
ModeTypeInfo typeInfo;
ParticipantInfo participantInfo;
InternalChild = new FillFlowContainer
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
2020-02-19 16:47:59 +08:00
RelativeSizeAxes = Axes.X,
Spacing = new Vector2(0, 10),
2020-02-19 16:47:59 +08:00
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
roomName = new OsuTextFlowContainer(t => t.Font = OsuFont.GetFont(size: 30))
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
},
participantInfo = new ParticipantInfo(),
2020-02-19 16:47:59 +08:00
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
statusInfo = new RoomStatusInfo(),
2020-02-19 16:47:59 +08:00
typeInfo = new ModeTypeInfo
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight
2020-02-19 16:47:59 +08:00
}
}
},
localUserInfo = new RoomLocalUserInfo(),
2020-02-19 16:47:59 +08:00
}
};
statusElements.AddRange(new Drawable[]
{
statusInfo, typeInfo, participantInfo, localUserInfo
});
2020-02-19 16:47:59 +08:00
}
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);
}
}
}