2018-05-29 00:01:56 +00: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-12-18 03:56:16 +00:00
|
|
|
|
using System;
|
2018-12-12 05:38:03 +00:00
|
|
|
|
using System.Linq;
|
2018-12-06 03:21:30 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2018-05-29 01:11:01 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2018-05-29 05:42:52 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-12-17 02:51:28 +00:00
|
|
|
|
using osu.Framework.Screens;
|
2018-05-29 01:11:01 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
2019-01-25 08:44:33 +00:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2018-05-29 00:01:56 +00:00
|
|
|
|
using osu.Game.Online.Multiplayer;
|
2018-12-26 07:46:50 +00:00
|
|
|
|
using osu.Game.Online.Multiplayer.GameTypes;
|
2018-12-22 05:01:06 +00:00
|
|
|
|
using osu.Game.Rulesets;
|
2018-12-10 10:20:41 +00:00
|
|
|
|
using osu.Game.Screens.Multi.Match.Components;
|
2018-12-11 08:32:01 +00:00
|
|
|
|
using osu.Game.Screens.Multi.Play;
|
|
|
|
|
using osu.Game.Screens.Play;
|
2018-05-29 01:11:01 +00:00
|
|
|
|
using osu.Game.Screens.Select;
|
2018-05-29 00:01:56 +00:00
|
|
|
|
|
2018-12-10 10:20:41 +00:00
|
|
|
|
namespace osu.Game.Screens.Multi.Match
|
2018-05-29 00:01:56 +00:00
|
|
|
|
{
|
2019-01-25 08:44:33 +00:00
|
|
|
|
public class MatchSubScreen : CompositeDrawable, IMultiplayerSubScreen
|
2018-05-29 00:01:56 +00:00
|
|
|
|
{
|
2019-01-25 08:44:33 +00:00
|
|
|
|
public bool AllowBeatmapRulesetChange => false;
|
|
|
|
|
public bool AllowExternalScreenChange => true;
|
|
|
|
|
public bool CursorVisible => true;
|
|
|
|
|
|
|
|
|
|
public string Title => room.RoomID.Value == null ? "New room" : room.Name.Value;
|
|
|
|
|
public string ShortTitle => "room";
|
|
|
|
|
|
|
|
|
|
public bool ValidForResume { get; set; } = true;
|
|
|
|
|
public bool ValidForPush { get; set; } = true;
|
|
|
|
|
|
|
|
|
|
public override bool RemoveWhenNotAlive => false;
|
2018-12-04 08:43:44 +00:00
|
|
|
|
|
2018-12-22 05:01:06 +00:00
|
|
|
|
private readonly RoomBindings bindings = new RoomBindings();
|
|
|
|
|
|
2018-12-17 02:51:28 +00:00
|
|
|
|
private readonly MatchLeaderboard leaderboard;
|
2018-12-25 08:14:56 +00:00
|
|
|
|
|
2018-12-18 03:56:16 +00:00
|
|
|
|
private readonly Action<Screen> pushGameplayScreen;
|
2018-12-13 09:38:03 +00:00
|
|
|
|
|
2018-12-10 09:00:57 +00:00
|
|
|
|
[Cached]
|
|
|
|
|
private readonly Room room;
|
|
|
|
|
|
2019-01-25 08:44:33 +00:00
|
|
|
|
[Resolved]
|
|
|
|
|
private IBindableBeatmap beatmap { get; set; }
|
|
|
|
|
|
2018-12-06 03:21:30 +00:00
|
|
|
|
[Resolved]
|
|
|
|
|
private BeatmapManager beatmapManager { get; set; }
|
|
|
|
|
|
2018-12-22 05:38:46 +00:00
|
|
|
|
[Resolved(CanBeNull = true)]
|
2018-12-18 09:09:46 +00:00
|
|
|
|
private OsuGame game { get; set; }
|
|
|
|
|
|
2018-12-20 11:58:34 +00:00
|
|
|
|
[Resolved(CanBeNull = true)]
|
2018-12-25 02:45:50 +00:00
|
|
|
|
private IRoomManager manager { get; set; }
|
2018-12-20 11:58:34 +00:00
|
|
|
|
|
2018-12-26 11:05:57 +00:00
|
|
|
|
public MatchSubScreen(Room room, Action<Screen> pushGameplayScreen)
|
2018-05-29 00:01:56 +00:00
|
|
|
|
{
|
|
|
|
|
this.room = room;
|
2018-12-18 03:56:16 +00:00
|
|
|
|
this.pushGameplayScreen = pushGameplayScreen;
|
2018-12-06 03:21:30 +00:00
|
|
|
|
|
2019-01-25 08:44:33 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
2018-12-22 05:01:06 +00:00
|
|
|
|
bindings.Room = room;
|
2018-12-07 07:20:05 +00:00
|
|
|
|
|
2018-12-25 08:14:56 +00:00
|
|
|
|
MatchChatDisplay chat;
|
2018-12-22 05:01:06 +00:00
|
|
|
|
Components.Header header;
|
2019-01-17 08:27:34 +00:00
|
|
|
|
Info info;
|
|
|
|
|
GridContainer bottomRow;
|
2018-12-26 07:11:40 +00:00
|
|
|
|
MatchSettingsOverlay settings;
|
2018-05-29 01:11:01 +00:00
|
|
|
|
|
2019-01-23 11:52:00 +00:00
|
|
|
|
InternalChildren = new Drawable[]
|
2018-05-29 01:11:01 +00:00
|
|
|
|
{
|
2018-12-14 05:20:03 +00:00
|
|
|
|
new GridContainer
|
2018-05-29 05:42:52 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2018-12-14 05:20:03 +00:00
|
|
|
|
Content = new[]
|
|
|
|
|
{
|
2018-12-20 06:17:33 +00:00
|
|
|
|
new Drawable[] { header = new Components.Header(room) { Depth = -1 } },
|
2019-01-17 08:27:34 +00:00
|
|
|
|
new Drawable[] { info = new Info(room) { OnStart = onStart } },
|
2018-12-14 10:52:03 +00:00
|
|
|
|
new Drawable[]
|
|
|
|
|
{
|
2019-01-17 08:27:34 +00:00
|
|
|
|
bottomRow = new GridContainer
|
2018-12-14 10:52:03 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Content = new[]
|
|
|
|
|
{
|
|
|
|
|
new Drawable[]
|
|
|
|
|
{
|
2019-01-08 10:24:55 +00:00
|
|
|
|
leaderboard = new MatchLeaderboard
|
2018-12-26 10:20:54 +00:00
|
|
|
|
{
|
|
|
|
|
Padding = new MarginPadding(10),
|
2019-01-08 10:24:55 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Room = room
|
2018-12-26 10:20:54 +00:00
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Padding = new MarginPadding(10),
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Child = chat = new MatchChatDisplay(room)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
}
|
|
|
|
|
},
|
2018-12-14 10:52:03 +00:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
2018-12-14 05:20:03 +00:00
|
|
|
|
},
|
|
|
|
|
RowDimensions = new[]
|
|
|
|
|
{
|
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
|
new Dimension(GridSizeMode.Distributed),
|
|
|
|
|
}
|
2018-05-29 05:42:52 +00:00
|
|
|
|
},
|
2018-06-06 07:27:53 +00:00
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2018-12-10 10:20:41 +00:00
|
|
|
|
Padding = new MarginPadding { Top = Components.Header.HEIGHT },
|
2018-12-26 07:11:40 +00:00
|
|
|
|
Child = settings = new MatchSettingsOverlay(room) { RelativeSizeAxes = Axes.Both },
|
2018-06-06 07:27:53 +00:00
|
|
|
|
},
|
2018-05-29 01:11:01 +00:00
|
|
|
|
};
|
|
|
|
|
|
2019-01-23 11:52:00 +00:00
|
|
|
|
header.OnRequestSelectBeatmap = () => this.Push(new MatchSongSelect { Selected = addPlaylistItem });
|
2018-06-06 07:27:53 +00:00
|
|
|
|
header.Tabs.Current.ValueChanged += t =>
|
|
|
|
|
{
|
2019-01-17 09:13:05 +00:00
|
|
|
|
const float fade_duration = 500;
|
2018-12-10 09:00:57 +00:00
|
|
|
|
if (t is SettingsMatchPage)
|
2019-01-17 08:27:34 +00:00
|
|
|
|
{
|
2018-06-06 07:27:53 +00:00
|
|
|
|
settings.Show();
|
2019-01-17 09:13:05 +00:00
|
|
|
|
info.FadeOut(fade_duration, Easing.OutQuint);
|
|
|
|
|
bottomRow.FadeOut(fade_duration, Easing.OutQuint);
|
2019-01-17 08:27:34 +00:00
|
|
|
|
}
|
2018-06-06 07:27:53 +00:00
|
|
|
|
else
|
2019-01-17 08:27:34 +00:00
|
|
|
|
{
|
2018-06-06 07:27:53 +00:00
|
|
|
|
settings.Hide();
|
2019-01-17 09:13:05 +00:00
|
|
|
|
info.FadeIn(fade_duration, Easing.OutQuint);
|
|
|
|
|
bottomRow.FadeIn(fade_duration, Easing.OutQuint);
|
2019-01-17 08:27:34 +00:00
|
|
|
|
}
|
2018-06-06 07:27:53 +00:00
|
|
|
|
};
|
2018-12-25 08:14:56 +00:00
|
|
|
|
|
2019-01-23 11:52:00 +00:00
|
|
|
|
chat.Exit += this.Exit;
|
2018-05-29 00:01:56 +00:00
|
|
|
|
}
|
2018-12-06 03:21:30 +00:00
|
|
|
|
|
2018-12-27 09:10:49 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
beatmapManager.ItemAdded += beatmapAdded;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-25 08:44:33 +00:00
|
|
|
|
public void OnEntering(IScreen last)
|
|
|
|
|
{
|
|
|
|
|
this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
|
|
|
|
this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
|
|
|
|
this.MoveToX(200).MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool OnExiting(IScreen next)
|
2018-12-26 11:05:57 +00:00
|
|
|
|
{
|
|
|
|
|
manager?.PartRoom();
|
2019-01-25 08:44:33 +00:00
|
|
|
|
|
|
|
|
|
this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
|
|
|
|
|
this.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnResuming(IScreen last)
|
|
|
|
|
{
|
|
|
|
|
this.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
|
|
|
|
this.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnSuspending(IScreen next)
|
|
|
|
|
{
|
|
|
|
|
this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
|
|
|
|
|
this.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
|
2018-12-26 11:05:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-18 08:08:02 +00:00
|
|
|
|
protected override void LoadComplete()
|
2018-12-06 03:21:30 +00:00
|
|
|
|
{
|
2018-12-18 08:08:02 +00:00
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2018-12-22 05:01:06 +00:00
|
|
|
|
bindings.CurrentBeatmap.BindValueChanged(setBeatmap, true);
|
|
|
|
|
bindings.CurrentRuleset.BindValueChanged(setRuleset, true);
|
2018-12-13 09:38:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-22 05:01:06 +00:00
|
|
|
|
private void setBeatmap(BeatmapInfo beatmap)
|
|
|
|
|
{
|
|
|
|
|
// 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);
|
|
|
|
|
|
2018-12-22 05:38:46 +00:00
|
|
|
|
game?.ForcefullySetBeatmap(beatmapManager.GetWorkingBeatmap(localBeatmap));
|
2018-12-22 05:01:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setRuleset(RulesetInfo ruleset)
|
2018-12-13 09:38:03 +00:00
|
|
|
|
{
|
2018-12-22 05:01:06 +00:00
|
|
|
|
if (ruleset == null)
|
2018-12-13 09:38:03 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2018-12-22 05:38:46 +00:00
|
|
|
|
game?.ForcefullySetRuleset(ruleset);
|
2018-12-22 05:01:06 +00:00
|
|
|
|
}
|
2018-12-14 08:35:18 +00:00
|
|
|
|
|
2018-12-27 09:10:49 +00:00
|
|
|
|
private void beatmapAdded(BeatmapSetInfo model, bool existing, bool silent) => Schedule(() =>
|
|
|
|
|
{
|
2019-01-25 08:44:33 +00:00
|
|
|
|
if (beatmap.Value != beatmapManager.DefaultBeatmap)
|
2018-12-27 09:10:49 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (bindings.CurrentBeatmap.Value == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Try to retrieve the corresponding local beatmap
|
|
|
|
|
var localBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == bindings.CurrentBeatmap.Value.OnlineBeatmapID);
|
|
|
|
|
|
|
|
|
|
if (localBeatmap != null)
|
|
|
|
|
game?.ForcefullySetBeatmap(beatmapManager.GetWorkingBeatmap(localBeatmap));
|
|
|
|
|
});
|
|
|
|
|
|
2018-12-22 05:01:06 +00:00
|
|
|
|
private void addPlaylistItem(PlaylistItem item)
|
|
|
|
|
{
|
|
|
|
|
bindings.Playlist.Clear();
|
|
|
|
|
bindings.Playlist.Add(item);
|
2018-12-06 03:21:30 +00:00
|
|
|
|
}
|
2018-12-11 08:32:01 +00:00
|
|
|
|
|
|
|
|
|
private void onStart()
|
|
|
|
|
{
|
2019-01-25 08:44:33 +00:00
|
|
|
|
beatmap.Value.Mods.Value = bindings.CurrentMods.Value.ToArray();
|
2018-12-27 12:59:43 +00:00
|
|
|
|
|
2018-12-22 05:01:06 +00:00
|
|
|
|
switch (bindings.Type.Value)
|
2018-12-11 08:32:01 +00:00
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case GameTypeTimeshift _:
|
2019-01-23 11:52:00 +00:00
|
|
|
|
pushGameplayScreen?.Invoke(new PlayerLoader(() => new TimeshiftPlayer(room, room.Playlist.First().ID)
|
|
|
|
|
{
|
|
|
|
|
Exited = () => leaderboard.RefreshScores()
|
2018-12-26 13:16:35 +00:00
|
|
|
|
}));
|
2018-12-11 08:32:01 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-12-27 09:10:49 +00:00
|
|
|
|
|
2019-01-25 09:38:48 +00:00
|
|
|
|
public override string ToString() => Title;
|
|
|
|
|
|
2018-12-27 09:10:49 +00:00
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
|
|
|
|
|
if (beatmapManager != null)
|
|
|
|
|
beatmapManager.ItemAdded -= beatmapAdded;
|
|
|
|
|
}
|
2018-05-29 00:01:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|