1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 17:13:06 +08:00

Decouple match info from match screen

This commit is contained in:
smoogipoo 2018-12-22 14:08:00 +09:00
parent d93421b796
commit c06cf5d379
2 changed files with 13 additions and 23 deletions

View File

@ -3,12 +3,10 @@
using System; using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
@ -26,11 +24,7 @@ namespace osu.Game.Screens.Multi.Match.Components
private OsuColour colours; private OsuColour colours;
public readonly IBindable<string> Name = new Bindable<string>(); private readonly RoomBindings bindings = new RoomBindings();
public readonly IBindable<RoomAvailability> Availability = new Bindable<RoomAvailability>();
public readonly IBindable<RoomStatus> Status = new Bindable<RoomStatus>();
public readonly IBindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
public readonly IBindable<DateTimeOffset> EndDate = new Bindable<DateTimeOffset>();
public Info(Room room) public Info(Room room)
{ {
@ -99,13 +93,15 @@ namespace osu.Game.Screens.Multi.Match.Components
}, },
}; };
viewBeatmapButton.Beatmap.BindTo(Beatmap); viewBeatmapButton.Beatmap.BindTo(bindings.CurrentBeatmap);
readyButton.Beatmap.BindTo(Beatmap); readyButton.Beatmap.BindTo(bindings.CurrentBeatmap);
Availability.BindValueChanged(_ => updateAvailabilityStatus()); bindings.Availability.BindValueChanged(_ => updateAvailabilityStatus());
Status.BindValueChanged(_ => updateAvailabilityStatus()); bindings.Status.BindValueChanged(_ => updateAvailabilityStatus());
Name.BindValueChanged(n => name.Text = n); bindings.Name.BindValueChanged(n => name.Text = n);
EndDate.BindValueChanged(d => endDate.Date = d); bindings.EndDate.BindValueChanged(d => endDate.Date = d);
bindings.Room = room;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -126,10 +122,10 @@ namespace osu.Game.Screens.Multi.Match.Components
if (!IsLoaded) if (!IsLoaded)
return; return;
if (Status.Value != null) if (bindings.Status.Value != null)
{ {
availabilityStatus.FadeColour(Status.Value.GetAppropriateColour(colours), 100); availabilityStatus.FadeColour(bindings.Status.Value.GetAppropriateColour(colours), 100);
availabilityStatus.Text = $"{Availability.Value.GetDescription()}, {Status.Value.Message}"; availabilityStatus.Text = $"{bindings.Availability.Value.GetDescription()}, {bindings.Status.Value.Message}";
} }
} }
} }

View File

@ -49,7 +49,6 @@ namespace osu.Game.Screens.Multi.Match
bindings.Room = room; bindings.Room = room;
Info info;
Components.Header header; Components.Header header;
RoomSettingsOverlay settings; RoomSettingsOverlay settings;
@ -61,7 +60,7 @@ namespace osu.Game.Screens.Multi.Match
Content = new[] Content = new[]
{ {
new Drawable[] { header = new Components.Header(room) { Depth = -1 } }, new Drawable[] { header = new Components.Header(room) { Depth = -1 } },
new Drawable[] { info = new Info(room) { OnStart = onStart } }, new Drawable[] { new Info(room) { OnStart = onStart } },
new Drawable[] new Drawable[]
{ {
new GridContainer new GridContainer
@ -106,11 +105,6 @@ namespace osu.Game.Screens.Multi.Match
settings.Hide(); settings.Hide();
}; };
info.Name.BindTo(bindings.Name);
info.Status.BindTo(bindings.Status);
info.Availability.BindTo(bindings.Availability);
info.EndDate.BindTo(bindings.EndDate);
info.Beatmap.BindTo(bindings.CurrentBeatmap);
header.Type.BindTo(bindings.Type); header.Type.BindTo(bindings.Type);
header.Beatmap.BindTo(bindings.CurrentBeatmap); header.Beatmap.BindTo(bindings.CurrentBeatmap);
header.Mods.BindTo(bindings.CurrentMods); header.Mods.BindTo(bindings.CurrentMods);