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
|
|
|
|
|
|
2018-05-29 13:42:52 +08:00
|
|
|
|
using System.Collections.Generic;
|
2018-05-29 09:11:01 +08:00
|
|
|
|
using osu.Framework.Configuration;
|
|
|
|
|
using osu.Framework.Graphics;
|
2018-05-29 13:42:52 +08:00
|
|
|
|
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;
|
2018-05-29 13:42:52 +08:00
|
|
|
|
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;
|
2018-05-29 13:42:52 +08:00
|
|
|
|
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>();
|
2018-05-29 13:42:52 +08:00
|
|
|
|
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 },
|
|
|
|
|
},
|
2018-05-29 13:42:52 +08:00
|
|
|
|
participants = new Participants
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Top = Header.HEIGHT + Info.HEIGHT },
|
|
|
|
|
},
|
2018-05-29 09:11:01 +08:00
|
|
|
|
};
|
|
|
|
|
|
2018-06-02 03:23:11 +08:00
|
|
|
|
header.OnWantsSelectBeatmap = () => Push(new MatchSongSelect());
|
2018-05-29 09:11:01 +08:00
|
|
|
|
|
2018-06-20 16:06:02 +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;
|
2018-06-20 16:06:02 +08:00
|
|
|
|
}, true);
|
2018-05-29 09:11:01 +08:00
|
|
|
|
|
2018-05-29 12:51:04 +08:00
|
|
|
|
nameBind.BindTo(room.Name);
|
2018-06-20 16:06:02 +08:00
|
|
|
|
nameBind.BindValueChanged(n => info.Name = n, true);
|
|
|
|
|
|
2018-05-29 12:51:04 +08:00
|
|
|
|
statusBind.BindTo(room.Status);
|
2018-06-20 16:06:02 +08:00
|
|
|
|
statusBind.BindValueChanged(s => info.Status = s, true);
|
|
|
|
|
|
2018-05-29 12:51:04 +08:00
|
|
|
|
availabilityBind.BindTo(room.Availability);
|
2018-06-20 16:06:02 +08:00
|
|
|
|
availabilityBind.BindValueChanged(a => info.Availability = a, true);
|
|
|
|
|
|
2018-05-29 12:51:04 +08:00
|
|
|
|
typeBind.BindTo(room.Type);
|
2018-06-20 16:06:02 +08:00
|
|
|
|
typeBind.BindValueChanged(t => info.Type = t, true);
|
|
|
|
|
|
2018-05-29 13:42:52 +08:00
|
|
|
|
maxParticipantsBind.BindTo(room.MaxParticipants);
|
2018-06-20 16:06:02 +08:00
|
|
|
|
maxParticipantsBind.BindValueChanged(m => { participants.Max = m; }, true);
|
|
|
|
|
|
2018-05-29 13:42:52 +08:00
|
|
|
|
participantsBind.BindTo(room.Participants);
|
2018-06-20 16:06:02 +08:00
|
|
|
|
participantsBind.BindValueChanged(p => participants.Users = p, true);
|
2018-05-29 08:01:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|