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

118 lines
4.1 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-12-06 11:21:30 +08:00
using osu.Framework.Allocation;
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;
using osu.Game.Online.API;
2018-05-29 08:01:56 +08:00
using osu.Game.Online.Multiplayer;
2018-12-10 18:20:41 +08:00
using osu.Game.Screens.Multi.Match.Components;
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
2018-12-10 18:20:41 +08:00
namespace osu.Game.Screens.Multi.Match
2018-05-29 08:01:56 +08:00
{
2018-12-10 18:20:41 +08:00
public class MatchScreen : MultiplayerScreen
2018-05-29 08:01:56 +08:00
{
private readonly Participants participants;
2018-05-29 12:51:04 +08:00
private readonly Bindable<string> nameBind = new Bindable<string>();
2018-12-07 15:20:05 +08:00
private readonly Bindable<BeatmapInfo> beatmapBind = new Bindable<BeatmapInfo>();
2018-05-29 12:51:04 +08:00
private readonly Bindable<RoomStatus> statusBind = new Bindable<RoomStatus>();
private readonly Bindable<RoomAvailability> availabilityBind = new Bindable<RoomAvailability>();
private readonly Bindable<GameType> typeBind = new Bindable<GameType>();
private readonly Bindable<int?> maxParticipantsBind = new Bindable<int?>();
private readonly Bindable<IEnumerable<User>> participantsBind = new Bindable<IEnumerable<User>>();
2018-12-07 15:20:05 +08:00
protected override Drawable TransitionContent => participants;
2018-05-29 08:01:56 +08:00
public override string Title => room.Name.Value;
public override string ShortTitle => "room";
[Cached]
private readonly Room room;
2018-12-06 11:21:30 +08:00
[Resolved]
private BeatmapManager beatmapManager { get; set; }
[Resolved]
private APIAccess api { get; set; }
2018-12-10 18:20:41 +08:00
public MatchScreen(Room room)
2018-05-29 08:01:56 +08:00
{
this.room = room;
2018-12-06 11:21:30 +08:00
2018-12-07 15:20:05 +08:00
nameBind.BindTo(room.Name);
beatmapBind.BindTo(room.Beatmap);
statusBind.BindTo(room.Status);
availabilityBind.BindTo(room.Availability);
typeBind.BindTo(room.Type);
participantsBind.BindTo(room.Participants);
maxParticipantsBind.BindTo(room.MaxParticipants);
2018-12-10 18:20:41 +08:00
Components.Header header;
RoomSettingsOverlay settings;
2018-05-29 12:51:04 +08:00
Info info;
2018-05-29 09:11:01 +08:00
Children = new Drawable[]
{
2018-12-10 18:20:41 +08:00
header = new Components.Header
{
Depth = -1,
},
2018-05-29 12:51:04 +08:00
info = new Info
{
2018-12-10 18:20:41 +08:00
Margin = new MarginPadding { Top = Components.Header.HEIGHT },
2018-05-29 12:51:04 +08:00
},
participants = new Participants
{
RelativeSizeAxes = Axes.Both,
2018-12-10 18:20:41 +08:00
Padding = new MarginPadding { Top = Components.Header.HEIGHT + Info.HEIGHT },
},
new Container
{
RelativeSizeAxes = Axes.Both,
2018-12-10 18:20:41 +08:00
Padding = new MarginPadding { Top = Components.Header.HEIGHT },
Child = settings = new RoomSettingsOverlay
{
RelativeSizeAxes = Axes.Both,
Height = 0.9f,
},
},
2018-05-29 09:11:01 +08:00
};
header.OnRequestSelectBeatmap = () => Push(new MatchSongSelect());
2018-12-06 11:21:30 +08:00
header.Beatmap.BindTo(Beatmap);
2018-05-29 09:11:01 +08:00
header.Tabs.Current.ValueChanged += t =>
{
if (t is SettingsMatchPage)
settings.Show();
else
settings.Hide();
};
2018-12-07 15:20:05 +08:00
info.Beatmap.BindTo(beatmapBind);
info.Name.BindTo(nameBind);
info.Status.BindTo(statusBind);
info.Availability.BindTo(availabilityBind);
info.Type.BindTo(typeBind);
2018-12-07 15:20:05 +08:00
participants.Users.BindTo(participantsBind);
participants.MaxParticipants.BindTo(maxParticipantsBind);
2018-05-29 08:01:56 +08:00
}
2018-12-06 11:21:30 +08:00
[BackgroundDependencyLoader]
private void load()
{
2018-12-07 15:20:05 +08:00
beatmapBind.BindTo(room.Beatmap);
beatmapBind.BindValueChanged(b => Beatmap.Value = beatmapManager.GetWorkingBeatmap(room.Beatmap.Value), true);
Beatmap.BindValueChanged(b => beatmapBind.Value = b.BeatmapInfo);
2018-12-06 11:21:30 +08:00
}
2018-05-29 08:01:56 +08:00
}
}