2019-01-24 17:43:03 +09: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-28 21:01:56 -03:00
|
|
|
|
|
2019-04-10 17:13:12 +09:00
|
|
|
|
using System;
|
2020-05-28 22:25:00 +09:00
|
|
|
|
using System.Diagnostics;
|
2020-02-13 18:12:47 +09:00
|
|
|
|
using System.Linq;
|
2018-12-06 12:21:30 +09:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 19:04:31 +09:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-05-28 22:11:01 -03:00
|
|
|
|
using osu.Framework.Graphics;
|
2018-05-29 02:42:52 -03:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-12-17 11:51:28 +09:00
|
|
|
|
using osu.Framework.Screens;
|
2019-08-08 09:04:24 +03:00
|
|
|
|
using osu.Game.Audio;
|
2018-05-28 22:11:01 -03:00
|
|
|
|
using osu.Game.Beatmaps;
|
2020-05-26 18:12:19 +09:00
|
|
|
|
using osu.Game.Online.API;
|
2018-05-28 21:01:56 -03:00
|
|
|
|
using osu.Game.Online.Multiplayer;
|
2018-12-26 16:46:50 +09:00
|
|
|
|
using osu.Game.Online.Multiplayer.GameTypes;
|
2019-02-11 19:11:34 +09:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2020-02-20 18:15:40 +09:00
|
|
|
|
using osu.Game.Screens.Multi.Components;
|
2018-12-10 19:20:41 +09:00
|
|
|
|
using osu.Game.Screens.Multi.Match.Components;
|
2018-12-11 17:32:01 +09:00
|
|
|
|
using osu.Game.Screens.Multi.Play;
|
2020-05-28 22:25:00 +09:00
|
|
|
|
using osu.Game.Screens.Multi.Ranking;
|
2020-06-03 15:57:01 +09:00
|
|
|
|
using osu.Game.Screens.Play;
|
2020-02-14 20:48:09 +09:00
|
|
|
|
using osu.Game.Screens.Select;
|
|
|
|
|
using Footer = osu.Game.Screens.Multi.Match.Components.Footer;
|
2018-05-28 21:01:56 -03:00
|
|
|
|
|
2018-12-10 19:20:41 +09:00
|
|
|
|
namespace osu.Game.Screens.Multi.Match
|
2018-05-28 21:01:56 -03:00
|
|
|
|
{
|
2019-08-13 17:38:21 +09:00
|
|
|
|
[Cached(typeof(IPreviewTrackOwner))]
|
2019-08-08 09:04:24 +03:00
|
|
|
|
public class MatchSubScreen : MultiplayerSubScreen, IPreviewTrackOwner
|
2018-05-28 21:01:56 -03:00
|
|
|
|
{
|
2019-02-01 15:42:15 +09:00
|
|
|
|
public override bool DisallowExternalBeatmapRulesetChanges => true;
|
2019-01-25 21:02:23 +09:00
|
|
|
|
|
2019-02-07 19:52:33 +09:00
|
|
|
|
public override string Title { get; }
|
2019-02-05 19:00:01 +09:00
|
|
|
|
|
2019-01-25 19:32:37 +09:00
|
|
|
|
public override string ShortTitle => "room";
|
2018-12-04 17:43:44 +09:00
|
|
|
|
|
2019-02-05 19:00:01 +09:00
|
|
|
|
[Resolved(typeof(Room), nameof(Room.RoomID))]
|
|
|
|
|
private Bindable<int?> roomId { get; set; }
|
2018-12-22 14:01:06 +09:00
|
|
|
|
|
2019-02-11 19:11:34 +09:00
|
|
|
|
[Resolved(typeof(Room), nameof(Room.Type))]
|
|
|
|
|
private Bindable<GameType> type { get; set; }
|
2018-12-13 18:38:03 +09:00
|
|
|
|
|
2020-02-14 20:48:09 +09:00
|
|
|
|
[Resolved(typeof(Room), nameof(Room.Playlist))]
|
|
|
|
|
private BindableList<PlaylistItem> playlist { get; set; }
|
2018-12-10 18:00:57 +09:00
|
|
|
|
|
2019-02-11 19:11:34 +09:00
|
|
|
|
[Resolved]
|
|
|
|
|
private BeatmapManager beatmapManager { get; set; }
|
2018-05-28 22:11:01 -03:00
|
|
|
|
|
2020-02-14 20:48:09 +09:00
|
|
|
|
[Resolved(canBeNull: true)]
|
|
|
|
|
private Multiplayer multiplayer { get; set; }
|
2018-12-07 16:20:05 +09:00
|
|
|
|
|
2020-02-14 23:39:39 +09:00
|
|
|
|
protected readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
|
|
|
|
|
|
2020-02-14 20:48:09 +09:00
|
|
|
|
private MatchSettingsOverlay settingsOverlay;
|
2020-07-07 19:23:11 +09:00
|
|
|
|
private MatchLeaderboard leaderboard;
|
2019-02-11 19:11:34 +09:00
|
|
|
|
|
2020-05-27 16:08:47 +09:00
|
|
|
|
private IBindable<WeakReference<BeatmapSetInfo>> managerUpdated;
|
2020-07-07 19:23:11 +09:00
|
|
|
|
private OverlinedHeader participantsHeader;
|
2020-05-19 16:44:22 +09:00
|
|
|
|
|
2019-02-12 13:02:33 +09:00
|
|
|
|
public MatchSubScreen(Room room)
|
2019-02-11 19:11:34 +09:00
|
|
|
|
{
|
2019-02-21 18:56:34 +09:00
|
|
|
|
Title = room.RoomID.Value == null ? "New room" : room.Name.Value;
|
2019-02-11 19:11:34 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new GridContainer
|
2018-05-29 02:42:52 -03:00
|
|
|
|
{
|
2019-02-11 19:11:34 +09:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Content = new[]
|
2018-12-14 14:20:03 +09:00
|
|
|
|
{
|
2019-02-11 19:11:34 +09:00
|
|
|
|
new Drawable[]
|
2018-12-14 19:52:03 +09:00
|
|
|
|
{
|
2020-02-14 20:48:09 +09:00
|
|
|
|
new Container
|
2018-12-14 19:52:03 +09:00
|
|
|
|
{
|
2019-02-11 19:11:34 +09:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-02-14 20:48:09 +09:00
|
|
|
|
Padding = new MarginPadding
|
2018-12-14 19:52:03 +09:00
|
|
|
|
{
|
2020-02-14 20:48:09 +09:00
|
|
|
|
Horizontal = 105,
|
|
|
|
|
Vertical = 20
|
|
|
|
|
},
|
|
|
|
|
Child = new GridContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-07-07 19:23:11 +09:00
|
|
|
|
RowDimensions = new[]
|
|
|
|
|
{
|
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
|
new Dimension(),
|
|
|
|
|
},
|
2020-02-14 20:48:09 +09:00
|
|
|
|
Content = new[]
|
2018-12-14 19:52:03 +09:00
|
|
|
|
{
|
2020-07-07 19:23:11 +09:00
|
|
|
|
new Drawable[] { new Components.Header() },
|
2020-06-25 18:59:14 +09:00
|
|
|
|
new Drawable[]
|
|
|
|
|
{
|
2020-07-07 19:23:11 +09:00
|
|
|
|
participantsHeader = new OverlinedHeader("Participants")
|
|
|
|
|
{
|
|
|
|
|
ShowLine = false
|
|
|
|
|
}
|
2020-06-25 18:59:14 +09:00
|
|
|
|
},
|
2020-02-14 20:48:09 +09:00
|
|
|
|
new Drawable[]
|
2019-02-11 19:11:34 +09:00
|
|
|
|
{
|
2020-02-14 20:48:09 +09:00
|
|
|
|
new Container
|
2020-06-25 20:53:48 +09:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2020-07-07 19:23:11 +09:00
|
|
|
|
Margin = new MarginPadding { Top = 5 },
|
|
|
|
|
Child = new ParticipantsDisplay(Direction.Horizontal)
|
2020-06-25 20:53:48 +09:00
|
|
|
|
{
|
2020-07-07 19:23:11 +09:00
|
|
|
|
Details = { BindTarget = participantsHeader.Details }
|
2020-06-25 20:53:48 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new GridContainer
|
2019-01-24 17:40:48 +08:00
|
|
|
|
{
|
2020-02-14 20:48:09 +09:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-06-25 20:53:48 +09:00
|
|
|
|
Content = new[]
|
2020-02-14 20:48:09 +09:00
|
|
|
|
{
|
2020-06-25 20:53:48 +09:00
|
|
|
|
new Drawable[]
|
2020-02-14 20:48:09 +09:00
|
|
|
|
{
|
2020-06-25 20:53:48 +09:00
|
|
|
|
new Container
|
2020-02-14 20:48:09 +09:00
|
|
|
|
{
|
2020-06-25 20:53:48 +09:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Right = 5 },
|
2020-06-25 22:22:19 +09:00
|
|
|
|
Child = new GridContainer
|
2020-02-14 20:48:09 +09:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-06-25 22:22:19 +09:00
|
|
|
|
Content = new[]
|
|
|
|
|
{
|
2020-07-10 15:37:08 +09:00
|
|
|
|
new Drawable[] { new OverlinedHeader("Playlist"), },
|
2020-06-25 22:22:19 +09:00
|
|
|
|
new Drawable[]
|
|
|
|
|
{
|
2020-07-10 19:37:27 +09:00
|
|
|
|
new DrawableRoomPlaylistWithResults
|
2020-06-25 22:22:19 +09:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-07-07 19:23:11 +09:00
|
|
|
|
Items = { BindTarget = playlist },
|
2020-07-10 19:37:27 +09:00
|
|
|
|
SelectedItem = { BindTarget = SelectedItem },
|
|
|
|
|
RequestShowResults = item =>
|
|
|
|
|
{
|
|
|
|
|
Debug.Assert(roomId.Value != null);
|
|
|
|
|
multiplayer?.Push(new TimeshiftResultsScreen(null, roomId.Value.Value, item, false));
|
|
|
|
|
}
|
2020-06-25 22:22:19 +09:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
RowDimensions = new[]
|
|
|
|
|
{
|
2020-07-10 15:37:08 +09:00
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
2020-06-25 22:22:19 +09:00
|
|
|
|
new Dimension(),
|
|
|
|
|
}
|
2020-02-14 20:48:09 +09:00
|
|
|
|
}
|
|
|
|
|
},
|
2020-07-07 18:28:43 +09:00
|
|
|
|
null,
|
|
|
|
|
new GridContainer
|
2020-06-25 20:53:48 +09:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-07-07 18:28:43 +09:00
|
|
|
|
Content = new[]
|
|
|
|
|
{
|
2020-07-07 19:23:11 +09:00
|
|
|
|
new Drawable[] { new OverlinedHeader("Leaderboard"), },
|
|
|
|
|
new Drawable[] { leaderboard = new MatchLeaderboard { RelativeSizeAxes = Axes.Both }, },
|
|
|
|
|
new Drawable[] { new OverlinedHeader("Chat"), },
|
|
|
|
|
new Drawable[] { new MatchChatDisplay { RelativeSizeAxes = Axes.Both } }
|
2020-07-07 18:28:43 +09:00
|
|
|
|
},
|
|
|
|
|
RowDimensions = new[]
|
|
|
|
|
{
|
2020-07-07 19:23:11 +09:00
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
2020-07-07 18:28:43 +09:00
|
|
|
|
new Dimension(),
|
2020-07-07 19:23:11 +09:00
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
2020-08-31 20:21:57 +09:00
|
|
|
|
new Dimension(GridSizeMode.Relative, size: 0.4f, minSize: 120),
|
2020-07-07 18:28:43 +09:00
|
|
|
|
}
|
2020-06-25 20:53:48 +09:00
|
|
|
|
},
|
2020-07-07 18:28:43 +09:00
|
|
|
|
null
|
2020-06-25 20:53:48 +09:00
|
|
|
|
},
|
2020-07-07 18:28:43 +09:00
|
|
|
|
},
|
|
|
|
|
ColumnDimensions = new[]
|
|
|
|
|
{
|
|
|
|
|
new Dimension(GridSizeMode.Relative, size: 0.5f, maxSize: 400),
|
|
|
|
|
new Dimension(),
|
|
|
|
|
new Dimension(GridSizeMode.Relative, size: 0.5f, maxSize: 600),
|
|
|
|
|
new Dimension(),
|
2020-02-14 20:48:09 +09:00
|
|
|
|
}
|
2019-02-11 19:11:34 +09:00
|
|
|
|
}
|
2020-02-14 20:48:09 +09:00
|
|
|
|
}
|
2018-12-14 19:52:03 +09:00
|
|
|
|
},
|
2020-02-14 20:48:09 +09:00
|
|
|
|
}
|
2019-02-11 19:11:34 +09:00
|
|
|
|
}
|
2018-12-14 19:52:03 +09:00
|
|
|
|
},
|
2020-02-14 20:48:09 +09:00
|
|
|
|
new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Footer
|
|
|
|
|
{
|
|
|
|
|
OnStart = onStart,
|
2020-02-14 23:39:39 +09:00
|
|
|
|
SelectedItem = { BindTarget = SelectedItem }
|
2020-02-14 20:48:09 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-02-05 19:00:01 +09:00
|
|
|
|
},
|
2019-02-11 19:11:34 +09:00
|
|
|
|
RowDimensions = new[]
|
2019-02-05 19:00:01 +09:00
|
|
|
|
{
|
2020-02-14 20:48:09 +09:00
|
|
|
|
new Dimension(),
|
2019-02-11 19:11:34 +09:00
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
2019-02-05 19:00:01 +09:00
|
|
|
|
}
|
2019-02-11 19:11:34 +09:00
|
|
|
|
},
|
2020-02-14 20:48:09 +09:00
|
|
|
|
settingsOverlay = new MatchSettingsOverlay
|
2019-02-11 19:11:34 +09:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-02-14 20:48:09 +09:00
|
|
|
|
EditPlaylist = () => this.Push(new MatchSongSelect()),
|
|
|
|
|
State = { Value = roomId.Value == null ? Visibility.Visible : Visibility.Hidden }
|
|
|
|
|
}
|
2019-02-11 19:11:34 +09:00
|
|
|
|
};
|
|
|
|
|
}
|
2018-12-27 18:10:49 +09:00
|
|
|
|
|
2020-05-26 18:12:19 +09:00
|
|
|
|
[Resolved]
|
|
|
|
|
private IAPIProvider api { get; set; }
|
|
|
|
|
|
2019-02-12 13:02:33 +09:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2020-02-14 20:48:09 +09:00
|
|
|
|
roomId.BindValueChanged(id =>
|
|
|
|
|
{
|
|
|
|
|
if (id.NewValue == null)
|
|
|
|
|
settingsOverlay.Show();
|
|
|
|
|
else
|
2020-02-14 23:39:39 +09:00
|
|
|
|
{
|
2020-02-14 20:48:09 +09:00
|
|
|
|
settingsOverlay.Hide();
|
2020-02-14 23:39:39 +09:00
|
|
|
|
|
|
|
|
|
// Set the first playlist item.
|
|
|
|
|
// This is scheduled since updating the room and playlist may happen in an arbitrary order (via Room.CopyFrom()).
|
|
|
|
|
Schedule(() => SelectedItem.Value = playlist.FirstOrDefault());
|
|
|
|
|
}
|
2020-02-14 20:48:09 +09:00
|
|
|
|
}, true);
|
2020-02-13 18:48:28 +09:00
|
|
|
|
|
2020-02-15 15:29:33 +09:00
|
|
|
|
SelectedItem.BindValueChanged(_ => Scheduler.AddOnce(selectedItemChanged));
|
2020-02-14 23:39:39 +09:00
|
|
|
|
SelectedItem.Value = playlist.FirstOrDefault();
|
2020-02-13 18:48:28 +09:00
|
|
|
|
|
2020-05-27 16:08:47 +09:00
|
|
|
|
managerUpdated = beatmapManager.ItemUpdated.GetBoundCopy();
|
|
|
|
|
managerUpdated.BindValueChanged(beatmapUpdated);
|
2019-02-12 13:02:33 +09:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-12 13:29:41 +09:00
|
|
|
|
public override bool OnExiting(IScreen next)
|
|
|
|
|
{
|
|
|
|
|
RoomManager?.PartRoom();
|
2019-04-10 17:13:12 +09:00
|
|
|
|
Mods.Value = Array.Empty<Mod>();
|
2019-08-08 09:04:24 +03:00
|
|
|
|
|
2019-02-12 13:29:41 +09:00
|
|
|
|
return base.OnExiting(next);
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-15 15:29:33 +09:00
|
|
|
|
private void selectedItemChanged()
|
2019-02-12 13:02:33 +09:00
|
|
|
|
{
|
2020-02-14 20:48:09 +09:00
|
|
|
|
updateWorkingBeatmap();
|
2020-02-13 18:48:28 +09:00
|
|
|
|
|
2020-02-15 15:29:33 +09:00
|
|
|
|
var item = SelectedItem.Value;
|
2019-02-12 13:02:33 +09:00
|
|
|
|
|
2020-02-13 18:48:28 +09:00
|
|
|
|
Mods.Value = item?.RequiredMods?.ToArray() ?? Array.Empty<Mod>();
|
2019-06-24 02:09:00 +03:00
|
|
|
|
|
2020-02-13 18:48:28 +09:00
|
|
|
|
if (item?.Ruleset != null)
|
|
|
|
|
Ruleset.Value = item.Ruleset.Value;
|
2020-02-14 20:48:09 +09:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-02 17:02:01 +09:00
|
|
|
|
private void beatmapUpdated(ValueChangedEvent<WeakReference<BeatmapSetInfo>> weakSet) => Schedule(updateWorkingBeatmap);
|
|
|
|
|
|
2020-02-14 20:48:09 +09:00
|
|
|
|
private void updateWorkingBeatmap()
|
|
|
|
|
{
|
2020-02-14 23:39:39 +09:00
|
|
|
|
var beatmap = SelectedItem.Value?.Beatmap.Value;
|
2019-06-24 02:09:00 +03:00
|
|
|
|
|
2020-02-14 20:48:09 +09:00
|
|
|
|
// Retrieve the corresponding local beatmap, since we can't directly use the playlist's beatmap info
|
|
|
|
|
var localBeatmap = beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == beatmap.OnlineBeatmapID);
|
2019-08-08 12:25:46 +03:00
|
|
|
|
|
2020-02-14 20:48:09 +09:00
|
|
|
|
Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
|
2019-02-12 13:02:33 +09:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-11 19:11:34 +09:00
|
|
|
|
private void onStart()
|
|
|
|
|
{
|
|
|
|
|
switch (type.Value)
|
2018-12-11 17:32:01 +09:00
|
|
|
|
{
|
2019-02-11 19:11:34 +09:00
|
|
|
|
default:
|
|
|
|
|
case GameTypeTimeshift _:
|
2020-06-03 15:57:01 +09:00
|
|
|
|
multiplayer?.Push(new PlayerLoader(() => new TimeshiftPlayer(SelectedItem.Value)
|
2019-02-11 19:11:34 +09:00
|
|
|
|
{
|
2020-06-25 18:59:14 +09:00
|
|
|
|
Exited = () => leaderboard.RefreshScores()
|
2020-06-03 15:57:01 +09:00
|
|
|
|
}));
|
2019-02-11 19:11:34 +09:00
|
|
|
|
break;
|
2018-12-11 17:32:01 +09:00
|
|
|
|
}
|
2019-02-11 19:11:34 +09:00
|
|
|
|
}
|
2018-05-28 21:01:56 -03:00
|
|
|
|
}
|
|
|
|
|
}
|