1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 06:47:25 +08:00
osu-lazer/osu.Game/Screens/Multi/Screens/Match/Match.cs

82 lines
3.0 KiB
C#
Raw Normal View History

2018-05-29 08:01:56 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
2018-05-29 09:11:01 +08:00
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2018-05-29 09:11:01 +08:00
using osu.Game.Beatmaps;
2018-05-29 08:01:56 +08:00
using osu.Game.Online.Multiplayer;
2018-05-29 09:11:01 +08:00
using osu.Game.Screens.Select;
using osu.Game.Users;
2018-05-29 08:01:56 +08:00
namespace osu.Game.Screens.Multi.Screens.Match
{
public class Match : MultiplayerScreen
{
private readonly Room room;
private readonly Participants participants;
2018-05-29 12:51:04 +08:00
private readonly Bindable<string> nameBind = new Bindable<string>();
private readonly Bindable<RoomStatus> statusBind = new Bindable<RoomStatus>();
private readonly Bindable<RoomAvailability> availabilityBind = new Bindable<RoomAvailability>();
private readonly Bindable<GameType> typeBind = new Bindable<GameType>();
2018-05-29 09:11:01 +08:00
private readonly Bindable<BeatmapInfo> beatmapBind = new Bindable<BeatmapInfo>();
private readonly Bindable<int?> maxParticipantsBind = new Bindable<int?>();
private readonly Bindable<IEnumerable<User>> participantsBind = new Bindable<IEnumerable<User>>();
protected override Container<Drawable> TransitionContent => participants;
2018-05-29 08:01:56 +08:00
2018-06-02 04:16:35 +08:00
public override string Type => "room";
2018-05-29 08:01:56 +08:00
public override string Title => room.Name.Value;
public Match(Room room)
{
this.room = room;
2018-05-29 09:11:01 +08:00
Header header;
2018-05-29 12:51:04 +08:00
Info info;
2018-05-29 09:11:01 +08:00
Children = new Drawable[]
{
header = new Header(),
2018-05-29 12:51:04 +08:00
info = new Info
{
Margin = new MarginPadding { Top = Header.HEIGHT },
},
participants = new Participants
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = Header.HEIGHT + Info.HEIGHT },
},
2018-05-29 09:11:01 +08:00
};
header.OnWantsSelectBeatmap = () => Push(new MatchSongSelect());
2018-05-29 09:11:01 +08:00
beatmapBind.BindTo(room.Beatmap);
beatmapBind.BindValueChanged(b =>
2018-05-29 09:11:01 +08:00
{
2018-05-29 15:16:19 +08:00
header.BeatmapSet = b?.BeatmapSet;
2018-05-29 12:51:04 +08:00
info.Beatmap = b;
}, true);
2018-05-29 09:11:01 +08:00
2018-05-29 12:51:04 +08:00
nameBind.BindTo(room.Name);
nameBind.BindValueChanged(n => info.Name = n, true);
2018-05-29 12:51:04 +08:00
statusBind.BindTo(room.Status);
statusBind.BindValueChanged(s => info.Status = s, true);
2018-05-29 12:51:04 +08:00
availabilityBind.BindTo(room.Availability);
availabilityBind.BindValueChanged(a => info.Availability = a, true);
2018-05-29 12:51:04 +08:00
typeBind.BindTo(room.Type);
typeBind.BindValueChanged(t => info.Type = t, true);
maxParticipantsBind.BindTo(room.MaxParticipants);
maxParticipantsBind.BindValueChanged(m => { participants.Max = m; }, true);
participantsBind.BindTo(room.Participants);
participantsBind.BindValueChanged(p => participants.Users = p, true);
2018-05-29 08:01:56 +08:00
}
}
}