1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 02:32:59 +08:00

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

View File

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

View File

@ -31,6 +31,10 @@ namespace osu.Game.Online.Multiplayer
[JsonProperty("playlist")]
public BindableList<PlaylistItem> Playlist { get; private set; } = new BindableList<PlaylistItem>();
[Cached]
[JsonIgnore]
public Bindable<PlaylistItem> CurrentItem { get; private set; } = new Bindable<PlaylistItem>();
[Cached]
[JsonProperty("channel_id")]
public Bindable<int> ChannelId { get; private set; } = new Bindable<int>();
@ -66,6 +70,18 @@ namespace osu.Game.Online.Multiplayer
[Cached]
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
[JsonProperty("participant_count")]
private int? participantCount

View File

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

View File

@ -5,6 +5,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Online.Multiplayer;
using osuTK;
namespace osu.Game.Screens.Multi.Components
@ -45,17 +46,17 @@ namespace osu.Game.Screens.Multi.Components
},
};
CurrentBeatmap.BindValueChanged(_ => updateBeatmap());
CurrentRuleset.BindValueChanged(_ => updateBeatmap(), true);
CurrentItem.BindValueChanged(updateBeatmap, 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.Child = new DifficultyIcon(CurrentBeatmap.Value, CurrentRuleset.Value) { Size = new Vector2(height) };
rulesetContainer.Child = new DifficultyIcon(item.Beatmap, item.Ruleset) { Size = new Vector2(height) };
}
else
rulesetContainer.FadeOut(transition_duration);

View File

@ -16,7 +16,7 @@ namespace osu.Game.Screens.Multi.Components
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 };

View File

@ -1,7 +1,6 @@
// 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.
using System;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
@ -23,16 +22,13 @@ namespace osu.Game.Screens.Multi.Lounge
protected readonly FilterControl Filter;
private readonly Container content;
private readonly Action<Screen> pushGameplayScreen;
private readonly ProcessingOverlay processingOverlay;
[Resolved]
private Bindable<Room> currentRoom { get; set; }
public LoungeSubScreen(Action<Screen> pushGameplayScreen)
public LoungeSubScreen()
{
this.pushGameplayScreen = pushGameplayScreen;
InternalChildren = new Drawable[]
{
Filter = new FilterControl { Depth = -1 },
@ -83,8 +79,8 @@ namespace osu.Game.Screens.Multi.Lounge
content.Padding = new MarginPadding
{
Top = Filter.DrawHeight,
Left = SearchableListOverlay.WIDTH_PADDING - DrawableRoom.SELECTION_BORDER_WIDTH + OsuScreen.HORIZONTAL_OVERFLOW_PADDING,
Right = SearchableListOverlay.WIDTH_PADDING + OsuScreen.HORIZONTAL_OVERFLOW_PADDING,
Left = SearchableListOverlay.WIDTH_PADDING - DrawableRoom.SELECTION_BORDER_WIDTH + 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)
{
processingOverlay.Show();
Manager?.JoinRoom(room, r =>
RoomManager?.JoinRoom(room, r =>
{
Open(room);
processingOverlay.Hide();
@ -132,7 +128,7 @@ namespace osu.Game.Screens.Multi.Lounge
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();
}

View File

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

View File

@ -14,7 +14,7 @@ namespace osu.Game.Screens.Multi.Match.Components
{
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))]
private Bindable<DateTimeOffset> endDate { get; set; }

View File

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

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
@ -11,11 +12,12 @@ using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Online.Multiplayer;
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.Play;
using osu.Game.Screens.Play;
using osu.Game.Screens.Select;
using PlaylistItem = osu.Game.Online.Multiplayer.PlaylistItem;
namespace osu.Game.Screens.Multi.Match
{
@ -33,223 +35,208 @@ namespace osu.Game.Screens.Multi.Match
[Resolved(typeof(Room), nameof(Room.Name))]
private Bindable<string> name { get; set; }
[Resolved(typeof(Room), nameof(Room.Playlist))]
private BindableList<PlaylistItem> playlist { get; set; }
[Resolved(typeof(Room), nameof(Room.Type))]
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;
}
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();
}
};
private readonly Action<Screen> pushGameplayScreen;
private MatchLeaderboard leaderboard;
[Resolved]
private BeatmapManager beatmapManager { get; set; }
[Resolved(CanBeNull = true)]
private OsuGame game { get; set; }
protected override void LoadComplete()
{
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)
{
Manager?.PartRoom();
RoomManager?.PartRoom();
return base.OnExiting(next);
}
private class Match : MultiplayerComposite
[BackgroundDependencyLoader]
private void load()
{
public Action RequestBeatmapSelection;
public Action RequestExit;
MatchChatDisplay chat;
Components.Header header;
Info info;
GridContainer bottomRow;
MatchSettingsOverlay settings;
private readonly Action<Screen> pushGameplayScreen;
private MatchLeaderboard leaderboard;
[Resolved]
private IBindableBeatmap gameBeatmap { get; set; }
[Resolved]
private BeatmapManager beatmapManager { get; set; }
[Resolved(CanBeNull = true)]
private OsuGame game { get; set; }
public Match(Action<Screen> pushGameplayScreen)
InternalChildren = new Drawable[]
{
this.pushGameplayScreen = pushGameplayScreen;
}
[BackgroundDependencyLoader]
private void load()
{
MatchChatDisplay chat;
Components.Header header;
Info info;
GridContainer bottomRow;
MatchSettingsOverlay settings;
InternalChildren = new Drawable[]
new GridContainer
{
new GridContainer
RelativeSizeAxes = Axes.Both,
Content = new[]
{
RelativeSizeAxes = Axes.Both,
Content = new[]
new Drawable[]
{
new Drawable[]
header = new Components.Header
{
header = new Components.Header
Depth = -1,
RequestBeatmapSelection = () =>
{
Depth = -1,
RequestBeatmapSelection = () => RequestBeatmapSelection?.Invoke()
}
},
new Drawable[] { info = new Info { OnStart = onStart } },
new Drawable[]
{
bottomRow = new GridContainer
{
RelativeSizeAxes = Axes.Both,
Content = new[]
this.Push(new MatchSongSelect
{
new Drawable[]
Selected = item =>
{
leaderboard = new MatchLeaderboard
Playlist.Clear();
Playlist.Add(item);
}
});
}
}
},
new Drawable[] { info = new Info { OnStart = onStart } },
new Drawable[]
{
bottomRow = new GridContainer
{
RelativeSizeAxes = Axes.Both,
Content = new[]
{
new Drawable[]
{
leaderboard = new MatchLeaderboard
{
Padding = new MarginPadding
{
Left = 10 + HORIZONTAL_OVERFLOW_PADDING,
Right = 10,
Vertical = 10,
},
RelativeSizeAxes = Axes.Both
},
new Container
{
Padding = new MarginPadding
{
Left = 10,
Right = 10 + HORIZONTAL_OVERFLOW_PADDING,
Vertical = 10,
},
RelativeSizeAxes = Axes.Both,
Child = chat = new MatchChatDisplay
{
Padding = new MarginPadding
{
Left = 10 + OsuScreen.HORIZONTAL_OVERFLOW_PADDING,
Right = 10,
Vertical = 10,
},
RelativeSizeAxes = Axes.Both
},
new Container
{
Padding = new MarginPadding
{
Left = 10,
Right = 10 + OsuScreen.HORIZONTAL_OVERFLOW_PADDING,
Vertical = 10,
},
RelativeSizeAxes = Axes.Both,
Child = chat = new MatchChatDisplay
{
RelativeSizeAxes = Axes.Both
}
},
}
},
},
}
},
},
}
},
RowDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize),
new Dimension(GridSizeMode.AutoSize),
new Dimension(GridSizeMode.Distributed),
}
},
new Container
RowDimensions = new[]
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = Components.Header.HEIGHT },
Child = settings = new MatchSettingsOverlay { RelativeSizeAxes = Axes.Both },
},
};
header.Tabs.Current.BindValueChanged(t =>
{
const float fade_duration = 500;
if (t is SettingsMatchPage)
{
settings.Show();
info.FadeOut(fade_duration, Easing.OutQuint);
bottomRow.FadeOut(fade_duration, Easing.OutQuint);
new Dimension(GridSizeMode.AutoSize),
new Dimension(GridSizeMode.AutoSize),
new Dimension(GridSizeMode.Distributed),
}
else
{
settings.Hide();
info.FadeIn(fade_duration, Easing.OutQuint);
bottomRow.FadeIn(fade_duration, Easing.OutQuint);
}
}, true);
chat.Exit += () => RequestExit?.Invoke();
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(() =>
{
if (gameBeatmap.Value != beatmapManager.DefaultBeatmap)
return;
if (CurrentBeatmap.Value == null)
return;
// Try to retrieve the corresponding local beatmap
var localBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == CurrentBeatmap.Value.OnlineBeatmapID);
if (localBeatmap != null)
game?.ForcefullySetBeatmap(beatmapManager.GetWorkingBeatmap(localBeatmap));
});
private void onStart()
{
gameBeatmap.Value.Mods.Value = CurrentMods.Value.ToArray();
switch (Type.Value)
},
new Container
{
default:
case GameTypeTimeshift _:
pushGameplayScreen?.Invoke(new PlayerLoader(() => new TimeshiftPlayer(Playlist.First())
{
Exited = () => leaderboard.RefreshScores()
}));
break;
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = Components.Header.HEIGHT },
Child = settings = new MatchSettingsOverlay { RelativeSizeAxes = Axes.Both },
},
};
header.Tabs.Current.BindValueChanged(t =>
{
const float fade_duration = 500;
if (t is SettingsMatchPage)
{
settings.Show();
info.FadeOut(fade_duration, Easing.OutQuint);
bottomRow.FadeOut(fade_duration, Easing.OutQuint);
}
}
else
{
settings.Hide();
info.FadeIn(fade_duration, Easing.OutQuint);
bottomRow.FadeIn(fade_duration, Easing.OutQuint);
}
}, true);
protected override void Dispose(bool isDisposing)
chat.Exit += () =>
{
base.Dispose(isDisposing);
if (this.IsCurrentScreen())
this.Exit();
};
if (beatmapManager != null)
beatmapManager.ItemAdded -= beatmapAdded;
beatmapManager.ItemAdded += beatmapAdded;
}
private void beatmapAdded(BeatmapSetInfo model, bool existing, bool silent) => Schedule(() =>
{
if (Beatmap.Value != beatmapManager.DefaultBeatmap)
return;
if (Beatmap.Value == null)
return;
// Try to retrieve the corresponding local beatmap
var localBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == CurrentItem.Value.Beatmap.OnlineBeatmapID);
if (localBeatmap != null)
Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
});
private void onStart()
{
//Beatmap.Value.Mods.Value = CurrentMods.Value.ToArray();
switch (type.Value)
{
default:
case GameTypeTimeshift _:
pushGameplayScreen?.Invoke(new PlayerLoader(() => new TimeshiftPlayer(CurrentItem)
{
Exited = () => leaderboard.RefreshScores()
}));
break;
}
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (beatmapManager != null)
beatmapManager.ItemAdded -= beatmapAdded;
}
}
}

View File

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

View File

@ -3,14 +3,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Online.Multiplayer;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Users;
namespace osu.Game.Screens.Multi
@ -35,6 +31,9 @@ namespace osu.Game.Screens.Multi
[Resolved(typeof(Room))]
protected BindableList<PlaylistItem> Playlist { get; private set; }
[Resolved(typeof(Room))]
protected Bindable<PlaylistItem> CurrentItem { get; private set; }
[Resolved(typeof(Room))]
protected Bindable<IEnumerable<User>> Participants { get; private set; }
@ -52,35 +51,5 @@ namespace osu.Game.Screens.Multi
[Resolved(typeof(Room))]
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.
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings;
using osu.Game.Overlays;
using osu.Game.Rulesets;
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 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 DisallowExternalBeatmapRulesetChanges => false;
public override bool RemoveWhenNotAlive => false;
public abstract string Title { get; }
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)]
protected OsuGame Game { get; private set; }
[Resolved(CanBeNull = true)]
protected IRoomManager Manager { get; private set; }
protected IRoomManager RoomManager { get; private set; }
protected MultiplayerSubScreen()
{
@ -61,14 +31,14 @@ namespace osu.Game.Screens.Multi
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.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.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
@ -76,19 +46,19 @@ namespace osu.Game.Screens.Multi
return false;
}
public virtual void OnResuming(IScreen last)
public override void OnResuming(IScreen last)
{
this.FadeIn(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.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
}
public virtual bool OnPressed(GlobalAction action)
public override bool OnPressed(GlobalAction action)
{
if (!this.IsCurrentScreen()) return false;