Restructure

This commit is contained in:
Dean Herbert 2019-02-11 19:11:34 +09:00
parent e2e615cc5c
commit 88ffc78103
16 changed files with 243 additions and 323 deletions

View File

@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual
{ {
} }
protected override IEnumerable<IResultPageInfo> CreateResultPages() => new[] { new TestRoomLeaderboardPageInfo(Score, Beatmap.Value, room) }; protected override IEnumerable<IResultPageInfo> CreateResultPages() => new[] { new TestRoomLeaderboardPageInfo(Score, Beatmap.Value) };
} }
private class TestRoomLeaderboardPageInfo : RoomLeaderboardPageInfo private class TestRoomLeaderboardPageInfo : RoomLeaderboardPageInfo

View File

@ -13,7 +13,7 @@ namespace osu.Game.Beatmaps.Drawables
/// </summary> /// </summary>
public class UpdateableBeatmapBackgroundSprite : ModelBackedDrawable<BeatmapInfo> public class UpdateableBeatmapBackgroundSprite : ModelBackedDrawable<BeatmapInfo>
{ {
public readonly IBindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>(); public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
[Resolved] [Resolved]
private BeatmapManager beatmaps { get; set; } private BeatmapManager beatmaps { get; set; }

View File

@ -31,6 +31,10 @@ namespace osu.Game.Online.Multiplayer
[JsonProperty("playlist")] [JsonProperty("playlist")]
public BindableList<PlaylistItem> Playlist { get; private set; } = new BindableList<PlaylistItem>(); public BindableList<PlaylistItem> Playlist { get; private set; } = new BindableList<PlaylistItem>();
[Cached]
[JsonIgnore]
public Bindable<PlaylistItem> CurrentItem { get; private set; } = new Bindable<PlaylistItem>();
[Cached] [Cached]
[JsonProperty("channel_id")] [JsonProperty("channel_id")]
public Bindable<int> ChannelId { get; private set; } = new Bindable<int>(); public Bindable<int> ChannelId { get; private set; } = new Bindable<int>();
@ -66,6 +70,18 @@ namespace osu.Game.Online.Multiplayer
[Cached] [Cached]
public Bindable<int> ParticipantCount { get; private set; } = new Bindable<int>(); public Bindable<int> ParticipantCount { get; private set; } = new Bindable<int>();
public Room()
{
Playlist.ItemsAdded += updateCurrent;
Playlist.ItemsRemoved += updateCurrent;
updateCurrent(Playlist);
}
private void updateCurrent(IEnumerable<PlaylistItem> playlist)
{
CurrentItem.Value = playlist.FirstOrDefault();
}
// todo: TEMPORARY // todo: TEMPORARY
[JsonProperty("participant_count")] [JsonProperty("participant_count")]
private int? participantCount private int? participantCount

View File

@ -25,7 +25,7 @@ namespace osu.Game.Screens.Multi.Components
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
CurrentBeatmap.BindValueChanged(v => updateText(), true); CurrentItem.BindValueChanged(v => updateText(), true);
} }
private float textSize = OsuSpriteText.FONT_SIZE; private float textSize = OsuSpriteText.FONT_SIZE;
@ -53,7 +53,9 @@ namespace osu.Game.Screens.Multi.Components
textFlow.Clear(); textFlow.Clear();
if (CurrentBeatmap.Value == null) var beatmap = CurrentItem.Value?.Beatmap;
if (beatmap == null)
textFlow.AddText("No beatmap selected", s => textFlow.AddText("No beatmap selected", s =>
{ {
s.TextSize = TextSize; s.TextSize = TextSize;
@ -65,7 +67,7 @@ namespace osu.Game.Screens.Multi.Components
{ {
new OsuSpriteText new OsuSpriteText
{ {
Text = new LocalisedString((CurrentBeatmap.Value.Metadata.ArtistUnicode, CurrentBeatmap.Value.Metadata.Artist)), Text = new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist)),
TextSize = TextSize, TextSize = TextSize,
}, },
new OsuSpriteText new OsuSpriteText
@ -75,10 +77,10 @@ namespace osu.Game.Screens.Multi.Components
}, },
new OsuSpriteText new OsuSpriteText
{ {
Text = new LocalisedString((CurrentBeatmap.Value.Metadata.TitleUnicode, CurrentBeatmap.Value.Metadata.Title)), Text = new LocalisedString((beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title)),
TextSize = TextSize, TextSize = TextSize,
} }
}, null, LinkAction.OpenBeatmap, CurrentBeatmap.Value.OnlineBeatmapID.ToString(), "Open beatmap"); }, null, LinkAction.OpenBeatmap, beatmap.OnlineBeatmapID.ToString(), "Open beatmap");
} }
} }
} }

View File

@ -51,14 +51,16 @@ namespace osu.Game.Screens.Multi.Components
} }
}; };
CurrentBeatmap.BindValueChanged(v => CurrentItem.BindValueChanged(item =>
{ {
beatmapAuthor.Clear(); beatmapAuthor.Clear();
if (v != null) var beatmap = item?.Beatmap;
if (beatmap != null)
{ {
beatmapAuthor.AddText("mapped by ", s => s.Colour = OsuColour.Gray(0.8f)); beatmapAuthor.AddText("mapped by ", s => s.Colour = OsuColour.Gray(0.8f));
beatmapAuthor.AddLink(v.Metadata.Author.Username, null, LinkAction.OpenUserProfile, v.Metadata.Author.Id.ToString(), "View Profile"); beatmapAuthor.AddLink(beatmap.Metadata.Author.Username, null, LinkAction.OpenUserProfile, beatmap.Metadata.Author.Id.ToString(), "View Profile");
} }
}, true); }, true);
} }

View File

@ -5,6 +5,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps.Drawables; using osu.Game.Beatmaps.Drawables;
using osu.Game.Online.Multiplayer;
using osuTK; using osuTK;
namespace osu.Game.Screens.Multi.Components namespace osu.Game.Screens.Multi.Components
@ -45,17 +46,17 @@ namespace osu.Game.Screens.Multi.Components
}, },
}; };
CurrentBeatmap.BindValueChanged(_ => updateBeatmap()); CurrentItem.BindValueChanged(updateBeatmap, true);
CurrentRuleset.BindValueChanged(_ => updateBeatmap(), true);
Type.BindValueChanged(v => gameTypeContainer.Child = new DrawableGameType(v) { Size = new Vector2(height) }, true); Type.BindValueChanged(v => gameTypeContainer.Child = new DrawableGameType(v) { Size = new Vector2(height) }, true);
} }
private void updateBeatmap() private void updateBeatmap(PlaylistItem item)
{ {
if (CurrentBeatmap.Value != null) if (item?.Beatmap != null)
{ {
rulesetContainer.FadeIn(transition_duration); rulesetContainer.FadeIn(transition_duration);
rulesetContainer.Child = new DifficultyIcon(CurrentBeatmap.Value, CurrentRuleset.Value) { Size = new Vector2(height) }; rulesetContainer.Child = new DifficultyIcon(item.Beatmap, item.Ruleset) { Size = new Vector2(height) };
} }
else else
rulesetContainer.FadeOut(transition_duration); rulesetContainer.FadeOut(transition_duration);

View File

@ -16,7 +16,7 @@ namespace osu.Game.Screens.Multi.Components
InternalChild = sprite = CreateBackgroundSprite(); InternalChild = sprite = CreateBackgroundSprite();
sprite.Beatmap.BindTo(CurrentBeatmap); CurrentItem.BindValueChanged(i => sprite.Beatmap.Value = i?.Beatmap, true);
} }
protected virtual UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new UpdateableBeatmapBackgroundSprite { RelativeSizeAxes = Axes.Both }; protected virtual UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new UpdateableBeatmapBackgroundSprite { RelativeSizeAxes = Axes.Both };

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -23,16 +22,13 @@ namespace osu.Game.Screens.Multi.Lounge
protected readonly FilterControl Filter; protected readonly FilterControl Filter;
private readonly Container content; private readonly Container content;
private readonly Action<Screen> pushGameplayScreen;
private readonly ProcessingOverlay processingOverlay; private readonly ProcessingOverlay processingOverlay;
[Resolved] [Resolved]
private Bindable<Room> currentRoom { get; set; } private Bindable<Room> currentRoom { get; set; }
public LoungeSubScreen(Action<Screen> pushGameplayScreen) public LoungeSubScreen()
{ {
this.pushGameplayScreen = pushGameplayScreen;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
Filter = new FilterControl { Depth = -1 }, Filter = new FilterControl { Depth = -1 },
@ -83,8 +79,8 @@ namespace osu.Game.Screens.Multi.Lounge
content.Padding = new MarginPadding content.Padding = new MarginPadding
{ {
Top = Filter.DrawHeight, Top = Filter.DrawHeight,
Left = SearchableListOverlay.WIDTH_PADDING - DrawableRoom.SELECTION_BORDER_WIDTH + OsuScreen.HORIZONTAL_OVERFLOW_PADDING, Left = SearchableListOverlay.WIDTH_PADDING - DrawableRoom.SELECTION_BORDER_WIDTH + HORIZONTAL_OVERFLOW_PADDING,
Right = SearchableListOverlay.WIDTH_PADDING + OsuScreen.HORIZONTAL_OVERFLOW_PADDING, Right = SearchableListOverlay.WIDTH_PADDING + HORIZONTAL_OVERFLOW_PADDING,
}; };
} }
@ -114,7 +110,7 @@ namespace osu.Game.Screens.Multi.Lounge
private void joinRequested(Room room) private void joinRequested(Room room)
{ {
processingOverlay.Show(); processingOverlay.Show();
Manager?.JoinRoom(room, r => RoomManager?.JoinRoom(room, r =>
{ {
Open(room); Open(room);
processingOverlay.Hide(); processingOverlay.Hide();
@ -132,7 +128,7 @@ namespace osu.Game.Screens.Multi.Lounge
currentRoom.Value = room; currentRoom.Value = room;
this.Push(new MatchSubScreen(room, s => pushGameplayScreen?.Invoke(s))); this.Push(new MatchSubScreen(room));
} }
} }
} }

View File

@ -108,7 +108,7 @@ namespace osu.Game.Screens.Multi.Match.Components
}, },
}; };
CurrentMods.BindValueChanged(m => modDisplay.Current.Value = m, true); CurrentItem.BindValueChanged(i => modDisplay.Current.Value = i?.RequiredMods, true);
beatmapButton.Action = () => RequestBeatmapSelection?.Invoke(); beatmapButton.Action = () => RequestBeatmapSelection?.Invoke();
} }

View File

@ -92,8 +92,12 @@ namespace osu.Game.Screens.Multi.Match.Components
}, },
}; };
viewBeatmapButton.Beatmap.BindTo(CurrentBeatmap); CurrentItem.BindValueChanged(item =>
readyButton.Beatmap.BindTo(CurrentBeatmap); {
viewBeatmapButton.Beatmap.Value = item?.Beatmap;
readyButton.Beatmap.Value = item?.Beatmap;
}, true);
hostInfo.Host.BindTo(Host); hostInfo.Host.BindTo(Host);
} }
} }

View File

@ -14,7 +14,7 @@ namespace osu.Game.Screens.Multi.Match.Components
{ {
public class ReadyButton : HeaderButton public class ReadyButton : HeaderButton
{ {
public readonly IBindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>(); public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
[Resolved(typeof(Room), nameof(Room.EndDate))] [Resolved(typeof(Room), nameof(Room.EndDate))]
private Bindable<DateTimeOffset> endDate { get; set; } private Bindable<DateTimeOffset> endDate { get; set; }

View File

@ -11,7 +11,7 @@ namespace osu.Game.Screens.Multi.Match.Components
{ {
public class ViewBeatmapButton : HeaderButton public class ViewBeatmapButton : HeaderButton
{ {
public readonly IBindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>(); public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
private OsuGame osuGame { get; set; } private OsuGame osuGame { get; set; }

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
@ -11,11 +12,12 @@ using osu.Framework.Screens;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Online.Multiplayer.GameTypes; using osu.Game.Online.Multiplayer.GameTypes;
using osu.Game.Rulesets; using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Multi.Match.Components; using osu.Game.Screens.Multi.Match.Components;
using osu.Game.Screens.Multi.Play; using osu.Game.Screens.Multi.Play;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using osu.Game.Screens.Select; using osu.Game.Screens.Select;
using PlaylistItem = osu.Game.Online.Multiplayer.PlaylistItem;
namespace osu.Game.Screens.Multi.Match namespace osu.Game.Screens.Multi.Match
{ {
@ -33,59 +35,55 @@ namespace osu.Game.Screens.Multi.Match
[Resolved(typeof(Room), nameof(Room.Name))] [Resolved(typeof(Room), nameof(Room.Name))]
private Bindable<string> name { get; set; } private Bindable<string> name { get; set; }
[Resolved(typeof(Room), nameof(Room.Playlist))] [Resolved(typeof(Room), nameof(Room.Type))]
private BindableList<PlaylistItem> playlist { get; set; } private Bindable<GameType> type { get; set; }
public MatchSubScreen(Room room, Action<Screen> pushGameplayScreen) [Resolved(typeof(Room))]
protected BindableList<PlaylistItem> Playlist { get; private set; }
[Resolved(typeof(Room))]
protected Bindable<PlaylistItem> CurrentItem { get; private set; }
[Resolved]
protected Bindable<IEnumerable<Mod>> CurrentMods { get; private set; }
public MatchSubScreen(Room room)
{ {
Title = room.RoomID.Value == null ? "New room" : room.Name; Title = room.RoomID.Value == null ? "New room" : room.Name;
InternalChild = new Match(pushGameplayScreen)
{
RelativeSizeAxes = Axes.Both,
RequestBeatmapSelection = () => this.Push(new MatchSongSelect
{
Selected = item =>
{
playlist.Clear();
playlist.Add(item);
},
}),
RequestExit = () =>
{
if (this.IsCurrentScreen())
this.Exit();
} }
};
}
public override bool OnExiting(IScreen next)
{
Manager?.PartRoom();
return base.OnExiting(next);
}
private class Match : MultiplayerComposite
{
public Action RequestBeatmapSelection;
public Action RequestExit;
private readonly Action<Screen> pushGameplayScreen; private readonly Action<Screen> pushGameplayScreen;
private MatchLeaderboard leaderboard; private MatchLeaderboard leaderboard;
[Resolved]
private IBindableBeatmap gameBeatmap { get; set; }
[Resolved] [Resolved]
private BeatmapManager beatmapManager { get; set; } private BeatmapManager beatmapManager { get; set; }
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
private OsuGame game { get; set; } private OsuGame game { get; set; }
public Match(Action<Screen> pushGameplayScreen) protected override void LoadComplete()
{ {
this.pushGameplayScreen = pushGameplayScreen; base.LoadComplete();
CurrentItem.BindValueChanged(currentItemChanged, true);
}
private void currentItemChanged(PlaylistItem item)
{
// Retrieve the corresponding local beatmap, since we can't directly use the playlist's beatmap info
var localBeatmap = item?.Beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == item.Beatmap.OnlineBeatmapID);
Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
CurrentMods.Value = item?.RequiredMods ?? Enumerable.Empty<Mod>();
if (item?.Ruleset != null)
Ruleset.Value = item.Ruleset;
}
public override bool OnExiting(IScreen next)
{
RoomManager?.PartRoom();
return base.OnExiting(next);
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -109,7 +107,17 @@ namespace osu.Game.Screens.Multi.Match
header = new Components.Header header = new Components.Header
{ {
Depth = -1, Depth = -1,
RequestBeatmapSelection = () => RequestBeatmapSelection?.Invoke() RequestBeatmapSelection = () =>
{
this.Push(new MatchSongSelect
{
Selected = item =>
{
Playlist.Clear();
Playlist.Add(item);
}
});
}
} }
}, },
new Drawable[] { info = new Info { OnStart = onStart } }, new Drawable[] { info = new Info { OnStart = onStart } },
@ -126,7 +134,7 @@ namespace osu.Game.Screens.Multi.Match
{ {
Padding = new MarginPadding Padding = new MarginPadding
{ {
Left = 10 + OsuScreen.HORIZONTAL_OVERFLOW_PADDING, Left = 10 + HORIZONTAL_OVERFLOW_PADDING,
Right = 10, Right = 10,
Vertical = 10, Vertical = 10,
}, },
@ -137,7 +145,7 @@ namespace osu.Game.Screens.Multi.Match
Padding = new MarginPadding Padding = new MarginPadding
{ {
Left = 10, Left = 10,
Right = 10 + OsuScreen.HORIZONTAL_OVERFLOW_PADDING, Right = 10 + HORIZONTAL_OVERFLOW_PADDING,
Vertical = 10, Vertical = 10,
}, },
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
@ -183,59 +191,39 @@ namespace osu.Game.Screens.Multi.Match
} }
}, true); }, true);
chat.Exit += () => RequestExit?.Invoke(); chat.Exit += () =>
{
if (this.IsCurrentScreen())
this.Exit();
};
beatmapManager.ItemAdded += beatmapAdded; beatmapManager.ItemAdded += beatmapAdded;
} }
protected override void LoadComplete()
{
base.LoadComplete();
CurrentBeatmap.BindValueChanged(setBeatmap, true);
CurrentRuleset.BindValueChanged(setRuleset, true);
}
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);
game?.ForcefullySetBeatmap(beatmapManager.GetWorkingBeatmap(localBeatmap));
}
private void setRuleset(RulesetInfo ruleset)
{
if (ruleset == null)
return;
game?.ForcefullySetRuleset(ruleset);
}
private void beatmapAdded(BeatmapSetInfo model, bool existing, bool silent) => Schedule(() => private void beatmapAdded(BeatmapSetInfo model, bool existing, bool silent) => Schedule(() =>
{ {
if (gameBeatmap.Value != beatmapManager.DefaultBeatmap) if (Beatmap.Value != beatmapManager.DefaultBeatmap)
return; return;
if (CurrentBeatmap.Value == null) if (Beatmap.Value == null)
return; return;
// Try to retrieve the corresponding local beatmap // Try to retrieve the corresponding local beatmap
var localBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == CurrentBeatmap.Value.OnlineBeatmapID); var localBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == CurrentItem.Value.Beatmap.OnlineBeatmapID);
if (localBeatmap != null) if (localBeatmap != null)
game?.ForcefullySetBeatmap(beatmapManager.GetWorkingBeatmap(localBeatmap)); Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
}); });
private void onStart() private void onStart()
{ {
gameBeatmap.Value.Mods.Value = CurrentMods.Value.ToArray(); //Beatmap.Value.Mods.Value = CurrentMods.Value.ToArray();
switch (Type.Value) switch (type.Value)
{ {
default: default:
case GameTypeTimeshift _: case GameTypeTimeshift _:
pushGameplayScreen?.Invoke(new PlayerLoader(() => new TimeshiftPlayer(Playlist.First()) pushGameplayScreen?.Invoke(new PlayerLoader(() => new TimeshiftPlayer(CurrentItem)
{ {
Exited = () => leaderboard.RefreshScores() Exited = () => leaderboard.RefreshScores()
})); }));
@ -251,5 +239,4 @@ namespace osu.Game.Screens.Multi.Match
beatmapManager.ItemAdded -= beatmapAdded; beatmapManager.ItemAdded -= beatmapAdded;
} }
} }
}
} }

View File

@ -8,7 +8,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
@ -16,9 +15,7 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Input; using osu.Game.Input;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Overlays;
using osu.Game.Overlays.BeatmapSet.Buttons; using osu.Game.Overlays.BeatmapSet.Buttons;
using osu.Game.Rulesets;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using osu.Game.Screens.Multi.Lounge; using osu.Game.Screens.Multi.Lounge;
using osu.Game.Screens.Multi.Lounge.Components; using osu.Game.Screens.Multi.Lounge.Components;
@ -28,19 +25,9 @@ using osuTK;
namespace osu.Game.Screens.Multi namespace osu.Game.Screens.Multi
{ {
[Cached] [Cached]
public class Multiplayer : CompositeDrawable, IOsuScreen, IOnlineComponent public class Multiplayer : OsuScreen, IOnlineComponent
{ {
public bool DisallowExternalBeatmapRulesetChanges => false; public override bool CursorVisible => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.CursorVisible ?? true;
public bool CursorVisible => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.CursorVisible ?? true;
public bool HideOverlaysOnEnter => false;
public OverlayActivation InitialOverlayActivationMode => OverlayActivation.All;
public float BackgroundParallaxAmount => 1;
public bool ValidForResume { get; set; } = true;
public bool ValidForPush { get; set; } = true;
public override bool RemoveWhenNotAlive => false; public override bool RemoveWhenNotAlive => false;
@ -70,20 +57,6 @@ namespace osu.Game.Screens.Multi
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
private OsuLogo logo { get; set; } private OsuLogo logo { get; set; }
public Bindable<WorkingBeatmap> Beatmap { get; set; }
public Bindable<RulesetInfo> Ruleset { get; set; }
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
var deps = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, base.CreateChildDependencies(parent));
Beatmap = deps.Beatmap;
Ruleset = deps.Ruleset;
return deps;
}
public Multiplayer() public Multiplayer()
{ {
Anchor = Anchor.Centre; Anchor = Anchor.Centre;
@ -95,8 +68,8 @@ namespace osu.Game.Screens.Multi
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}; };
screenStack = new ScreenStack(loungeSubScreen = new LoungeSubScreen(pushGameplayScreen)) { RelativeSizeAxes = Axes.Both }; screenStack = new ScreenStack(loungeSubScreen = new LoungeSubScreen()) { RelativeSizeAxes = Axes.Both };
Padding = new MarginPadding { Horizontal = -OsuScreen.HORIZONTAL_OVERFLOW_PADDING }; Padding = new MarginPadding { Horizontal = -HORIZONTAL_OVERFLOW_PADDING };
waves.AddRange(new Drawable[] waves.AddRange(new Drawable[]
{ {
@ -136,7 +109,7 @@ namespace osu.Game.Screens.Multi
Margin = new MarginPadding Margin = new MarginPadding
{ {
Top = 10, Top = 10,
Right = 10 + OsuScreen.HORIZONTAL_OVERFLOW_PADDING, Right = 10 + HORIZONTAL_OVERFLOW_PADDING,
}, },
Text = "Create room", Text = "Create room",
Action = () => loungeSubScreen.Open(new Room Action = () => loungeSubScreen.Open(new Room
@ -207,14 +180,14 @@ namespace osu.Game.Screens.Multi
} }
} }
public void OnEntering(IScreen last) public override void OnEntering(IScreen last)
{ {
this.FadeIn(); this.FadeIn();
waves.Show(); waves.Show();
} }
public bool OnExiting(IScreen next) public override bool OnExiting(IScreen next)
{ {
waves.Hide(); waves.Hide();
@ -233,17 +206,17 @@ namespace osu.Game.Screens.Multi
return false; return false;
} }
public void OnResuming(IScreen last) public override void OnResuming(IScreen last)
{ {
this.FadeIn(250); this.FadeIn(250);
this.ScaleTo(1, 250, Easing.OutSine); this.ScaleTo(1, 250, Easing.OutSine);
logo?.AppendAnimatingAction(() => OsuScreen.ApplyLogoArrivingDefaults(logo), true); logo?.AppendAnimatingAction(() => ApplyLogoArrivingDefaults(logo), true);
updatePollingRate(isIdle.Value); updatePollingRate(isIdle.Value);
} }
public void OnSuspending(IScreen next) public override void OnSuspending(IScreen next)
{ {
this.ScaleTo(1.1f, 250, Easing.InSine); this.ScaleTo(1.1f, 250, Easing.InSine);
this.FadeOut(250); this.FadeOut(250);
@ -254,7 +227,7 @@ namespace osu.Game.Screens.Multi
private void cancelLooping() private void cancelLooping()
{ {
var track = beatmap?.Value?.Track; var track = Beatmap?.Value?.Track;
if (track != null) if (track != null)
track.Looping = false; track.Looping = false;

View File

@ -3,14 +3,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Users; using osu.Game.Users;
namespace osu.Game.Screens.Multi namespace osu.Game.Screens.Multi
@ -35,6 +31,9 @@ namespace osu.Game.Screens.Multi
[Resolved(typeof(Room))] [Resolved(typeof(Room))]
protected BindableList<PlaylistItem> Playlist { get; private set; } protected BindableList<PlaylistItem> Playlist { get; private set; }
[Resolved(typeof(Room))]
protected Bindable<PlaylistItem> CurrentItem { get; private set; }
[Resolved(typeof(Room))] [Resolved(typeof(Room))]
protected Bindable<IEnumerable<User>> Participants { get; private set; } protected Bindable<IEnumerable<User>> Participants { get; private set; }
@ -52,35 +51,5 @@ namespace osu.Game.Screens.Multi
[Resolved(typeof(Room))] [Resolved(typeof(Room))]
protected Bindable<TimeSpan> Duration { get; private set; } protected Bindable<TimeSpan> Duration { get; private set; }
private readonly Bindable<BeatmapInfo> currentBeatmap = new Bindable<BeatmapInfo>();
protected IBindable<BeatmapInfo> CurrentBeatmap => currentBeatmap;
private readonly Bindable<IEnumerable<Mod>> currentMods = new Bindable<IEnumerable<Mod>>();
protected IBindable<IEnumerable<Mod>> CurrentMods => currentMods;
private readonly Bindable<RulesetInfo> currentRuleset = new Bindable<RulesetInfo>();
protected IBindable<RulesetInfo> CurrentRuleset => currentRuleset;
protected override void LoadComplete()
{
base.LoadComplete();
Playlist.ItemsAdded += _ => updatePlaylist();
Playlist.ItemsRemoved += _ => updatePlaylist();
updatePlaylist();
}
private void updatePlaylist()
{
// Todo: We only ever have one playlist item for now. In the future, this will be user-settable
var playlistItem = Playlist.FirstOrDefault();
currentBeatmap.Value = playlistItem?.Beatmap;
currentMods.Value = playlistItem?.RequiredMods ?? Enumerable.Empty<Mod>();
currentRuleset.Value = playlistItem?.Ruleset;
}
} }
} }

View File

@ -2,57 +2,27 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
using osu.Game.Overlays;
using osu.Game.Rulesets;
namespace osu.Game.Screens.Multi namespace osu.Game.Screens.Multi
{ {
public abstract class MultiplayerSubScreen : CompositeDrawable, IMultiplayerSubScreen, IKeyBindingHandler<GlobalAction> public abstract class MultiplayerSubScreen : OsuScreen, IMultiplayerSubScreen, IKeyBindingHandler<GlobalAction>
{ {
public virtual bool DisallowExternalBeatmapRulesetChanges => false; public override bool DisallowExternalBeatmapRulesetChanges => false;
public bool CursorVisible => true;
public bool HideOverlaysOnEnter => false;
public OverlayActivation InitialOverlayActivationMode => OverlayActivation.All;
public float BackgroundParallaxAmount => 1;
public bool ValidForResume { get; set; } = true;
public bool ValidForPush { get; set; } = true;
public override bool RemoveWhenNotAlive => false; public override bool RemoveWhenNotAlive => false;
public abstract string Title { get; }
public virtual string ShortTitle => Title; public virtual string ShortTitle => Title;
public Bindable<WorkingBeatmap> Beatmap { get; set; }
public Bindable<RulesetInfo> Ruleset { get; set; }
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
var deps = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, base.CreateChildDependencies(parent));
Beatmap = deps.Beatmap;
Ruleset = deps.Ruleset;
return deps;
}
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
protected OsuGame Game { get; private set; } protected OsuGame Game { get; private set; }
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
protected IRoomManager Manager { get; private set; } protected IRoomManager RoomManager { get; private set; }
protected MultiplayerSubScreen() protected MultiplayerSubScreen()
{ {
@ -61,14 +31,14 @@ namespace osu.Game.Screens.Multi
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
} }
public virtual void OnEntering(IScreen last) public override void OnEntering(IScreen last)
{ {
this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint); this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint); this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
this.MoveToX(200).MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint); this.MoveToX(200).MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
} }
public virtual bool OnExiting(IScreen next) public override bool OnExiting(IScreen next)
{ {
this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
this.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); this.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
@ -76,19 +46,19 @@ namespace osu.Game.Screens.Multi
return false; return false;
} }
public virtual void OnResuming(IScreen last) public override void OnResuming(IScreen last)
{ {
this.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint); this.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
this.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint); this.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
} }
public virtual void OnSuspending(IScreen next) public override void OnSuspending(IScreen next)
{ {
this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
this.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); this.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
} }
public virtual bool OnPressed(GlobalAction action) public override bool OnPressed(GlobalAction action)
{ {
if (!this.IsCurrentScreen()) return false; if (!this.IsCurrentScreen()) return false;