2019-01-24 16:43:03 +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.
|
2018-05-29 08:01:56 +08:00
|
|
|
|
|
2019-04-10 16:13:12 +08:00
|
|
|
|
using System;
|
2020-02-13 17:12:47 +08:00
|
|
|
|
using System.Linq;
|
2018-12-06 11:21:30 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 18:04:31 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-05-29 09:11:01 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2018-05-29 13:42:52 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-12-17 10:51:28 +08:00
|
|
|
|
using osu.Framework.Screens;
|
2019-08-08 14:04:24 +08:00
|
|
|
|
using osu.Game.Audio;
|
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-12-26 15:46:50 +08:00
|
|
|
|
using osu.Game.Online.Multiplayer.GameTypes;
|
2019-02-11 18:11:34 +08:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2018-12-10 18:20:41 +08:00
|
|
|
|
using osu.Game.Screens.Multi.Match.Components;
|
2018-12-11 16:32:01 +08:00
|
|
|
|
using osu.Game.Screens.Multi.Play;
|
2019-02-11 18:11:34 +08:00
|
|
|
|
using PlaylistItem = osu.Game.Online.Multiplayer.PlaylistItem;
|
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
|
|
|
|
{
|
2019-08-13 16:38:21 +08:00
|
|
|
|
[Cached(typeof(IPreviewTrackOwner))]
|
2019-08-08 14:04:24 +08:00
|
|
|
|
public class MatchSubScreen : MultiplayerSubScreen, IPreviewTrackOwner
|
2018-05-29 08:01:56 +08:00
|
|
|
|
{
|
2019-02-01 14:42:15 +08:00
|
|
|
|
public override bool DisallowExternalBeatmapRulesetChanges => true;
|
2019-01-25 20:02:23 +08:00
|
|
|
|
|
2019-02-07 18:52:33 +08:00
|
|
|
|
public override string Title { get; }
|
2019-02-05 18:00:01 +08:00
|
|
|
|
|
2019-01-25 18:32:37 +08:00
|
|
|
|
public override string ShortTitle => "room";
|
2018-12-04 16:43:44 +08:00
|
|
|
|
|
2019-02-05 18:00:01 +08:00
|
|
|
|
[Resolved(typeof(Room), nameof(Room.RoomID))]
|
|
|
|
|
private Bindable<int?> roomId { get; set; }
|
2018-12-22 13:01:06 +08:00
|
|
|
|
|
2019-02-05 18:00:01 +08:00
|
|
|
|
[Resolved(typeof(Room), nameof(Room.Name))]
|
|
|
|
|
private Bindable<string> name { get; set; }
|
2018-12-25 16:14:56 +08:00
|
|
|
|
|
2019-02-11 18:11:34 +08:00
|
|
|
|
[Resolved(typeof(Room), nameof(Room.Type))]
|
|
|
|
|
private Bindable<GameType> type { get; set; }
|
2018-12-13 17:38:03 +08:00
|
|
|
|
|
2019-02-11 18:11:34 +08:00
|
|
|
|
[Resolved(typeof(Room))]
|
|
|
|
|
protected BindableList<PlaylistItem> Playlist { get; private set; }
|
2018-12-10 17:00:57 +08:00
|
|
|
|
|
2019-02-11 18:11:34 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private BeatmapManager beatmapManager { get; set; }
|
2018-05-29 09:11:01 +08:00
|
|
|
|
|
2019-08-08 14:04:24 +08:00
|
|
|
|
[Resolved]
|
2019-08-12 14:50:49 +08:00
|
|
|
|
private PreviewTrackManager previewTrackManager { get; set; }
|
2019-08-08 14:04:24 +08:00
|
|
|
|
|
2019-02-11 18:11:34 +08:00
|
|
|
|
[Resolved(CanBeNull = true)]
|
|
|
|
|
private OsuGame game { get; set; }
|
2018-12-07 15:20:05 +08:00
|
|
|
|
|
2020-02-13 17:48:28 +08:00
|
|
|
|
private readonly Bindable<PlaylistItem> selectedItem = new Bindable<PlaylistItem>();
|
2019-02-12 12:02:33 +08:00
|
|
|
|
private MatchLeaderboard leaderboard;
|
2019-02-11 18:11:34 +08:00
|
|
|
|
|
2019-02-12 12:02:33 +08:00
|
|
|
|
public MatchSubScreen(Room room)
|
2019-02-11 18:11:34 +08:00
|
|
|
|
{
|
2019-02-21 17:56:34 +08:00
|
|
|
|
Title = room.RoomID.Value == null ? "New room" : room.Name.Value;
|
2019-02-11 18:11:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
Components.Header header;
|
|
|
|
|
Info info;
|
|
|
|
|
GridContainer bottomRow;
|
|
|
|
|
MatchSettingsOverlay settings;
|
2019-02-05 18:00:01 +08:00
|
|
|
|
|
2019-02-11 18:11:34 +08:00
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new GridContainer
|
2018-05-29 13:42:52 +08:00
|
|
|
|
{
|
2019-02-11 18:11:34 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Content = new[]
|
2018-12-14 13:20:03 +08:00
|
|
|
|
{
|
2019-02-11 18:11:34 +08:00
|
|
|
|
new Drawable[]
|
2018-12-14 18:52:03 +08:00
|
|
|
|
{
|
2019-02-11 18:11:34 +08:00
|
|
|
|
header = new Components.Header
|
2018-12-14 18:52:03 +08:00
|
|
|
|
{
|
2019-02-11 18:11:34 +08:00
|
|
|
|
Depth = -1,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new Drawable[] { info = new Info { OnStart = onStart } },
|
|
|
|
|
new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
bottomRow = new GridContainer
|
2018-12-14 18:52:03 +08:00
|
|
|
|
{
|
2019-02-11 18:11:34 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Content = new[]
|
2018-12-14 18:52:03 +08:00
|
|
|
|
{
|
2019-02-11 18:11:34 +08:00
|
|
|
|
new Drawable[]
|
2018-12-14 18:52:03 +08:00
|
|
|
|
{
|
2019-02-11 18:11:34 +08:00
|
|
|
|
leaderboard = new MatchLeaderboard
|
2018-12-26 18:20:54 +08:00
|
|
|
|
{
|
2019-02-11 18:11:34 +08:00
|
|
|
|
Padding = new MarginPadding
|
2019-01-24 17:40:48 +08:00
|
|
|
|
{
|
2019-02-11 18:11:34 +08:00
|
|
|
|
Left = 10 + HORIZONTAL_OVERFLOW_PADDING,
|
|
|
|
|
Right = 10,
|
|
|
|
|
Vertical = 10,
|
2019-01-24 17:40:48 +08:00
|
|
|
|
},
|
2019-02-11 18:11:34 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Padding = new MarginPadding
|
2019-01-24 17:40:48 +08:00
|
|
|
|
{
|
2019-02-11 18:11:34 +08:00
|
|
|
|
Left = 10,
|
|
|
|
|
Right = 10 + HORIZONTAL_OVERFLOW_PADDING,
|
|
|
|
|
Vertical = 10,
|
2019-01-24 17:40:48 +08:00
|
|
|
|
},
|
2019-02-11 18:11:34 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-10-01 23:26:34 +08:00
|
|
|
|
Child = new MatchChatDisplay
|
2019-02-11 18:11:34 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
}
|
2018-12-26 18:20:54 +08:00
|
|
|
|
},
|
2018-12-14 18:52:03 +08:00
|
|
|
|
},
|
2019-02-11 18:11:34 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
2018-12-14 18:52:03 +08:00
|
|
|
|
},
|
2019-02-05 18:00:01 +08:00
|
|
|
|
},
|
2019-02-11 18:11:34 +08:00
|
|
|
|
RowDimensions = new[]
|
2019-02-05 18:00:01 +08:00
|
|
|
|
{
|
2019-02-11 18:11:34 +08:00
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
|
new Dimension(GridSizeMode.Distributed),
|
2019-02-05 18:00:01 +08:00
|
|
|
|
}
|
2019-02-11 18:11:34 +08:00
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Top = Components.Header.HEIGHT },
|
|
|
|
|
Child = settings = new MatchSettingsOverlay { RelativeSizeAxes = Axes.Both },
|
|
|
|
|
},
|
|
|
|
|
};
|
2018-12-13 17:38:03 +08:00
|
|
|
|
|
2019-02-11 18:11:34 +08:00
|
|
|
|
beatmapManager.ItemAdded += beatmapAdded;
|
|
|
|
|
}
|
2018-12-27 17:10:49 +08:00
|
|
|
|
|
2019-02-12 12:02:33 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2020-02-13 17:48:28 +08:00
|
|
|
|
Playlist.ItemsAdded += _ => updateSelectedItem();
|
|
|
|
|
Playlist.ItemsRemoved += _ => updateSelectedItem();
|
|
|
|
|
|
|
|
|
|
updateSelectedItem();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateSelectedItem()
|
|
|
|
|
{
|
|
|
|
|
selectedItem.Value = Playlist.FirstOrDefault();
|
|
|
|
|
currentItemChanged();
|
2019-02-12 12:02:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-12 12:29:41 +08:00
|
|
|
|
public override bool OnExiting(IScreen next)
|
|
|
|
|
{
|
|
|
|
|
RoomManager?.PartRoom();
|
2019-04-10 16:13:12 +08:00
|
|
|
|
Mods.Value = Array.Empty<Mod>();
|
2019-08-12 14:50:49 +08:00
|
|
|
|
previewTrackManager.StopAnyPlaying(this);
|
2019-08-08 14:04:24 +08:00
|
|
|
|
|
2019-02-12 12:29:41 +08:00
|
|
|
|
return base.OnExiting(next);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Handles propagation of the current playlist item's content to game-wide mechanisms.
|
|
|
|
|
/// </summary>
|
2020-02-13 17:48:28 +08:00
|
|
|
|
private void currentItemChanged()
|
2019-02-12 12:02:33 +08:00
|
|
|
|
{
|
2020-02-13 17:48:28 +08:00
|
|
|
|
var item = selectedItem.Value;
|
|
|
|
|
|
2019-02-12 12:02:33 +08:00
|
|
|
|
// Retrieve the corresponding local beatmap, since we can't directly use the playlist's beatmap info
|
2020-02-13 17:48:28 +08:00
|
|
|
|
var localBeatmap = item?.Beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == item.Beatmap.Value.OnlineBeatmapID);
|
2019-02-12 12:02:33 +08:00
|
|
|
|
|
|
|
|
|
Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
|
2020-02-13 17:48:28 +08:00
|
|
|
|
Mods.Value = item?.RequiredMods?.ToArray() ?? Array.Empty<Mod>();
|
2019-06-24 07:09:00 +08:00
|
|
|
|
|
2020-02-13 17:48:28 +08:00
|
|
|
|
if (item?.Ruleset != null)
|
|
|
|
|
Ruleset.Value = item.Ruleset.Value;
|
2019-08-08 17:25:46 +08:00
|
|
|
|
|
2019-08-12 14:50:49 +08:00
|
|
|
|
previewTrackManager.StopAnyPlaying(this);
|
2019-02-12 12:02:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-12 10:19:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Handle the case where a beatmap is imported (and can be used by this match).
|
|
|
|
|
/// </summary>
|
2019-06-26 10:40:33 +08:00
|
|
|
|
private void beatmapAdded(BeatmapSetInfo model) => Schedule(() =>
|
2019-02-11 18:11:34 +08:00
|
|
|
|
{
|
|
|
|
|
if (Beatmap.Value != beatmapManager.DefaultBeatmap)
|
|
|
|
|
return;
|
2018-12-27 17:10:49 +08:00
|
|
|
|
|
2020-02-13 17:48:28 +08:00
|
|
|
|
if (selectedItem.Value == null)
|
2019-02-11 18:11:34 +08:00
|
|
|
|
return;
|
2018-12-27 17:10:49 +08:00
|
|
|
|
|
2019-02-11 18:11:34 +08:00
|
|
|
|
// Try to retrieve the corresponding local beatmap
|
2020-02-13 17:48:28 +08:00
|
|
|
|
var localBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == selectedItem.Value.Beatmap.Value.OnlineBeatmapID);
|
2018-12-27 17:10:49 +08:00
|
|
|
|
|
2019-02-11 18:11:34 +08:00
|
|
|
|
if (localBeatmap != null)
|
|
|
|
|
Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
|
|
|
|
|
});
|
2018-12-11 16:32:01 +08:00
|
|
|
|
|
2019-02-12 10:19:34 +08:00
|
|
|
|
[Resolved(canBeNull: true)]
|
|
|
|
|
private Multiplayer multiplayer { get; set; }
|
|
|
|
|
|
2019-02-11 18:11:34 +08:00
|
|
|
|
private void onStart()
|
|
|
|
|
{
|
2019-08-12 14:50:49 +08:00
|
|
|
|
previewTrackManager.StopAnyPlaying(this);
|
2019-08-08 14:52:42 +08:00
|
|
|
|
|
2019-02-11 18:11:34 +08:00
|
|
|
|
switch (type.Value)
|
2018-12-11 16:32:01 +08:00
|
|
|
|
{
|
2019-02-11 18:11:34 +08:00
|
|
|
|
default:
|
|
|
|
|
case GameTypeTimeshift _:
|
2020-02-13 17:48:28 +08:00
|
|
|
|
multiplayer?.Start(() => new TimeshiftPlayer(selectedItem.Value)
|
2019-02-11 18:11:34 +08:00
|
|
|
|
{
|
|
|
|
|
Exited = () => leaderboard.RefreshScores()
|
2019-02-12 10:19:34 +08:00
|
|
|
|
});
|
2019-02-11 18:11:34 +08:00
|
|
|
|
break;
|
2018-12-11 16:32:01 +08:00
|
|
|
|
}
|
2019-02-11 18:11:34 +08:00
|
|
|
|
}
|
2018-12-27 17:10:49 +08:00
|
|
|
|
|
2019-02-11 18:11:34 +08:00
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(isDisposing);
|
2018-12-27 17:10:49 +08:00
|
|
|
|
|
2019-02-11 18:11:34 +08:00
|
|
|
|
if (beatmapManager != null)
|
|
|
|
|
beatmapManager.ItemAdded -= beatmapAdded;
|
2018-12-27 17:10:49 +08:00
|
|
|
|
}
|
2018-05-29 08:01:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|