diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableLoungeRoom.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableLoungeRoom.cs index 5875ad74e7..abb491ca31 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableLoungeRoom.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableLoungeRoom.cs @@ -31,7 +31,7 @@ namespace osu.Game.Tests.Visual.Multiplayer [Cached] protected readonly OverlayColourProvider ColourProvider = new OverlayColourProvider(OverlayColourScheme.Pink); - private DrawableLoungeRoom drawableRoom = null!; + private LoungeRoomPanel panel = null!; private SearchTextBox searchTextBox = null!; private readonly ManualResetEventSlim allowResponseCallback = new ManualResetEventSlim(); @@ -74,7 +74,7 @@ namespace osu.Game.Tests.Visual.Multiplayer Width = 500, Depth = float.MaxValue }, - drawableRoom = new DrawableLoungeRoom(room) + panel = new LoungeRoomPanel(room) { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -88,16 +88,16 @@ namespace osu.Game.Tests.Visual.Multiplayer [Test] public void TestFocusViaKeyboardCommit() { - DrawableLoungeRoom.PasswordEntryPopover? popover = null; + LoungeRoomPanel.PasswordEntryPopover? popover = null; AddAssert("search textbox has focus", () => checkFocus(searchTextBox)); AddStep("click room twice", () => { - InputManager.MoveMouseTo(drawableRoom); + InputManager.MoveMouseTo(panel); InputManager.Click(MouseButton.Left); InputManager.Click(MouseButton.Left); }); - AddUntilStep("wait for popover", () => (popover = InputManager.ChildrenOfType().SingleOrDefault()) != null); + AddUntilStep("wait for popover", () => (popover = InputManager.ChildrenOfType().SingleOrDefault()) != null); AddAssert("textbox has focus", () => checkFocus(popover.ChildrenOfType().Single())); @@ -123,16 +123,16 @@ namespace osu.Game.Tests.Visual.Multiplayer [Test] public void TestFocusViaMouseCommit() { - DrawableLoungeRoom.PasswordEntryPopover? popover = null; + LoungeRoomPanel.PasswordEntryPopover? popover = null; AddAssert("search textbox has focus", () => checkFocus(searchTextBox)); AddStep("click room twice", () => { - InputManager.MoveMouseTo(drawableRoom); + InputManager.MoveMouseTo(panel); InputManager.Click(MouseButton.Left); InputManager.Click(MouseButton.Left); }); - AddUntilStep("wait for popover", () => (popover = InputManager.ChildrenOfType().SingleOrDefault()) != null); + AddUntilStep("wait for popover", () => (popover = InputManager.ChildrenOfType().SingleOrDefault()) != null); AddAssert("textbox has focus", () => checkFocus(popover.ChildrenOfType().Single())); diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs index ae939c7b9e..64cc41d0fb 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs @@ -269,7 +269,7 @@ namespace osu.Game.Tests.Visual.Multiplayer }); AddStep("refresh rooms", () => this.ChildrenOfType().Single().UpdateFilter()); - AddUntilStep("wait for room", () => this.ChildrenOfType().Any()); + AddUntilStep("wait for room", () => this.ChildrenOfType().Any()); AddStep("select room", () => InputManager.Key(Key.Down)); AddStep("join room and immediately exit select", () => @@ -298,7 +298,7 @@ namespace osu.Game.Tests.Visual.Multiplayer }); AddStep("refresh rooms", () => this.ChildrenOfType().Single().UpdateFilter()); - AddUntilStep("wait for room", () => this.ChildrenOfType().Any()); + AddUntilStep("wait for room", () => this.ChildrenOfType().Any()); AddStep("select room", () => InputManager.Key(Key.Down)); AddStep("join room", () => InputManager.Key(Key.Enter)); @@ -349,13 +349,13 @@ namespace osu.Game.Tests.Visual.Multiplayer }); AddStep("refresh rooms", () => this.ChildrenOfType().Single().UpdateFilter()); - AddUntilStep("wait for room", () => this.ChildrenOfType().Any()); + AddUntilStep("wait for room", () => this.ChildrenOfType().Any()); AddStep("select room", () => InputManager.Key(Key.Down)); AddStep("join room", () => InputManager.Key(Key.Enter)); - DrawableLoungeRoom.PasswordEntryPopover? passwordEntryPopover = null; - AddUntilStep("password prompt appeared", () => (passwordEntryPopover = InputManager.ChildrenOfType().FirstOrDefault()) != null); + LoungeRoomPanel.PasswordEntryPopover? passwordEntryPopover = null; + AddUntilStep("password prompt appeared", () => (passwordEntryPopover = InputManager.ChildrenOfType().FirstOrDefault()) != null); AddStep("enter password in text box", () => passwordEntryPopover.ChildrenOfType().First().Text = "password"); AddStep("press join room button", () => passwordEntryPopover.ChildrenOfType().First().TriggerClick()); @@ -802,7 +802,7 @@ namespace osu.Game.Tests.Visual.Multiplayer }); AddStep("refresh rooms", () => this.ChildrenOfType().Single().UpdateFilter()); - AddUntilStep("wait for room", () => this.ChildrenOfType().Any()); + AddUntilStep("wait for room", () => this.ChildrenOfType().Any()); AddStep("select room", () => InputManager.Key(Key.Down)); AddStep("disable polling", () => this.ChildrenOfType().Single().TimeBetweenPolls.Value = 0); diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerLoungeSubScreen.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerLoungeSubScreen.cs index 56187f8778..f1915233e0 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerLoungeSubScreen.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerLoungeSubScreen.cs @@ -45,7 +45,7 @@ namespace osu.Game.Tests.Visual.Multiplayer AddStep("select room", () => InputManager.Key(Key.Down)); AddStep("attempt join room", () => InputManager.Key(Key.Enter)); - AddUntilStep("password prompt appeared", () => InputManager.ChildrenOfType().Any()); + AddUntilStep("password prompt appeared", () => InputManager.ChildrenOfType().Any()); AddAssert("textbox has focus", () => InputManager.FocusedDrawable is OsuPasswordTextBox); @@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual.Multiplayer AddAssert("textbox lost focus", () => InputManager.FocusedDrawable is SearchTextBox); AddStep("hit escape", () => InputManager.Key(Key.Escape)); - AddUntilStep("password prompt hidden", () => !InputManager.ChildrenOfType().Any()); + AddUntilStep("password prompt hidden", () => !InputManager.ChildrenOfType().Any()); AddAssert("room not joined", () => !MultiplayerClient.RoomJoined); } @@ -65,9 +65,9 @@ namespace osu.Game.Tests.Visual.Multiplayer AddStep("select room", () => InputManager.Key(Key.Down)); AddStep("attempt join room", () => InputManager.Key(Key.Enter)); - AddUntilStep("password prompt appeared", () => InputManager.ChildrenOfType().Any()); + AddUntilStep("password prompt appeared", () => InputManager.ChildrenOfType().Any()); AddStep("exit screen", () => Stack.Exit()); - AddUntilStep("password prompt hidden", () => !InputManager.ChildrenOfType().Any()); + AddUntilStep("password prompt hidden", () => !InputManager.ChildrenOfType().Any()); AddAssert("room not joined", () => !MultiplayerClient.RoomJoined); } @@ -75,12 +75,12 @@ namespace osu.Game.Tests.Visual.Multiplayer [Test] public void TestJoinRoomWithIncorrectPasswordViaButton() { - DrawableLoungeRoom.PasswordEntryPopover? passwordEntryPopover = null; + LoungeRoomPanel.PasswordEntryPopover? passwordEntryPopover = null; createRooms(GenerateRooms(1, withPassword: true)); AddStep("select room", () => InputManager.Key(Key.Down)); AddStep("attempt join room", () => InputManager.Key(Key.Enter)); - AddUntilStep("password prompt appeared", () => (passwordEntryPopover = InputManager.ChildrenOfType().FirstOrDefault()) != null); + AddUntilStep("password prompt appeared", () => (passwordEntryPopover = InputManager.ChildrenOfType().FirstOrDefault()) != null); AddStep("enter password in text box", () => passwordEntryPopover.ChildrenOfType().First().Text = "wrong"); AddStep("press join room button", () => passwordEntryPopover.ChildrenOfType().First().TriggerClick()); @@ -94,12 +94,12 @@ namespace osu.Game.Tests.Visual.Multiplayer [Test] public void TestJoinRoomWithIncorrectPasswordViaEnter() { - DrawableLoungeRoom.PasswordEntryPopover? passwordEntryPopover = null; + LoungeRoomPanel.PasswordEntryPopover? passwordEntryPopover = null; createRooms(GenerateRooms(1, withPassword: true)); AddStep("select room", () => InputManager.Key(Key.Down)); AddStep("attempt join room", () => InputManager.Key(Key.Enter)); - AddUntilStep("password prompt appeared", () => (passwordEntryPopover = InputManager.ChildrenOfType().FirstOrDefault()) != null); + AddUntilStep("password prompt appeared", () => (passwordEntryPopover = InputManager.ChildrenOfType().FirstOrDefault()) != null); AddStep("enter password in text box", () => passwordEntryPopover.ChildrenOfType().First().Text = "wrong"); AddStep("press enter", () => InputManager.Key(Key.Enter)); @@ -113,12 +113,12 @@ namespace osu.Game.Tests.Visual.Multiplayer [Test] public void TestJoinRoomWithCorrectPassword() { - DrawableLoungeRoom.PasswordEntryPopover? passwordEntryPopover = null; + LoungeRoomPanel.PasswordEntryPopover? passwordEntryPopover = null; createRooms(GenerateRooms(1, withPassword: true)); AddStep("select room", () => InputManager.Key(Key.Down)); AddStep("attempt join room", () => InputManager.Key(Key.Enter)); - AddUntilStep("password prompt appeared", () => (passwordEntryPopover = InputManager.ChildrenOfType().FirstOrDefault()) != null); + AddUntilStep("password prompt appeared", () => (passwordEntryPopover = InputManager.ChildrenOfType().FirstOrDefault()) != null); AddStep("enter password in text box", () => passwordEntryPopover.ChildrenOfType().First().Text = "password"); AddStep("press join room button", () => passwordEntryPopover.ChildrenOfType().First().TriggerClick()); @@ -128,12 +128,12 @@ namespace osu.Game.Tests.Visual.Multiplayer [Test] public void TestJoinRoomWithPasswordViaKeyboardOnly() { - DrawableLoungeRoom.PasswordEntryPopover? passwordEntryPopover = null; + LoungeRoomPanel.PasswordEntryPopover? passwordEntryPopover = null; createRooms(GenerateRooms(1, withPassword: true)); AddStep("select room", () => InputManager.Key(Key.Down)); AddStep("attempt join room", () => InputManager.Key(Key.Enter)); - AddUntilStep("password prompt appeared", () => (passwordEntryPopover = InputManager.ChildrenOfType().FirstOrDefault()) != null); + AddUntilStep("password prompt appeared", () => (passwordEntryPopover = InputManager.ChildrenOfType().FirstOrDefault()) != null); AddStep("enter password in text box", () => passwordEntryPopover.ChildrenOfType().First().Text = "password"); AddStep("press enter", () => InputManager.Key(Key.Enter)); diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSubScreen.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSubScreen.cs index e5e4921a17..e51ea12e83 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSubScreen.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSubScreen.cs @@ -330,10 +330,10 @@ namespace osu.Game.Tests.Visual.Multiplayer AddUntilStep("wait for join", () => RoomJoined); - AddUntilStep("button visible", () => this.ChildrenOfType().Single().ChangeSettingsButton?.Alpha, () => Is.GreaterThan(0)); + AddUntilStep("button visible", () => this.ChildrenOfType().Single().ChangeSettingsButton.Alpha, () => Is.GreaterThan(0)); AddStep("join other user", void () => MultiplayerClient.AddUser(new APIUser { Id = PLAYER_1_ID })); AddStep("make other user host", () => MultiplayerClient.TransferHost(PLAYER_1_ID)); - AddAssert("button hidden", () => this.ChildrenOfType().Single().ChangeSettingsButton?.Alpha, () => Is.EqualTo(0)); + AddAssert("button hidden", () => this.ChildrenOfType().Single().ChangeSettingsButton.Alpha, () => Is.EqualTo(0)); } private partial class TestMultiplayerMatchSubScreen : MultiplayerMatchSubScreen diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneRoomListing.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneRoomListing.cs index 27c5758afa..58473f5fa2 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneRoomListing.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneRoomListing.cs @@ -201,6 +201,6 @@ namespace osu.Game.Tests.Visual.Multiplayer private bool checkRoomSelected(Room? room) => selectedRoom.Value == room; private Room? getRoomInFlow(int index) => - (container.ChildrenOfType>().First().FlowingChildren.ElementAt(index) as DrawableRoom)?.Room; + (container.ChildrenOfType>().First().FlowingChildren.ElementAt(index) as RoomPanel)?.Room; } } diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoom.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneRoomPanel.cs similarity index 84% rename from osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoom.cs rename to osu.Game.Tests/Visual/Multiplayer/TestSceneRoomPanel.cs index 021c0abf1d..fee5e62958 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoom.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneRoomPanel.cs @@ -18,13 +18,13 @@ using osu.Game.Overlays; using osu.Game.Rulesets.Osu; using osu.Game.Screens.OnlinePlay.Lounge; using osu.Game.Screens.OnlinePlay.Lounge.Components; -using osu.Game.Screens.OnlinePlay.Match; +using osu.Game.Screens.OnlinePlay.Multiplayer; using osu.Game.Tests.Beatmaps; using osuTK; namespace osu.Game.Tests.Visual.Multiplayer { - public partial class TestSceneDrawableRoom : OsuTestScene + public partial class TestSceneRoomPanel : OsuTestScene { [Cached] protected readonly OverlayColourProvider ColourProvider = new OverlayColourProvider(OverlayColourScheme.Plum); @@ -129,24 +129,24 @@ namespace osu.Game.Tests.Visual.Multiplayer [Test] public void TestEnableAndDisablePassword() { - DrawableRoom drawableRoom = null!; + RoomPanel panel = null!; Room room = null!; - AddStep("create room", () => Child = drawableRoom = createLoungeRoom(room = new Room + AddStep("create room", () => Child = panel = createLoungeRoom(room = new Room { Name = "Room with password", Type = MatchType.HeadToHead, })); - AddUntilStep("wait for panel load", () => drawableRoom.ChildrenOfType().Any()); + AddUntilStep("wait for panel load", () => panel.ChildrenOfType().Any()); - AddAssert("password icon hidden", () => Precision.AlmostEquals(0, drawableRoom.ChildrenOfType().Single().Alpha)); + AddAssert("password icon hidden", () => Precision.AlmostEquals(0, panel.ChildrenOfType().Single().Alpha)); AddStep("set password", () => room.Password = "password"); - AddAssert("password icon visible", () => Precision.AlmostEquals(1, drawableRoom.ChildrenOfType().Single().Alpha)); + AddAssert("password icon visible", () => Precision.AlmostEquals(1, panel.ChildrenOfType().Single().Alpha)); AddStep("unset password", () => room.Password = string.Empty); - AddAssert("password icon hidden", () => Precision.AlmostEquals(0, drawableRoom.ChildrenOfType().Single().Alpha)); + AddAssert("password icon hidden", () => Precision.AlmostEquals(0, panel.ChildrenOfType().Single().Alpha)); } [Test] @@ -160,38 +160,29 @@ namespace osu.Game.Tests.Visual.Multiplayer Spacing = new Vector2(5), Children = new[] { - new DrawableMatchRoom(new Room + new MultiplayerRoomPanel(new Room { Name = "A host-only room", QueueMode = QueueMode.HostOnly, Type = MatchType.HeadToHead, - }) - { - SelectedItem = new Bindable() - }, - new DrawableMatchRoom(new Room + }), + new MultiplayerRoomPanel(new Room { Name = "An all-players, team-versus room", QueueMode = QueueMode.AllPlayers, Type = MatchType.TeamVersus - }) - { - SelectedItem = new Bindable() - }, - new DrawableMatchRoom(new Room + }), + new MultiplayerRoomPanel(new Room { Name = "A round-robin room", QueueMode = QueueMode.AllPlayersRoundRobin, Type = MatchType.HeadToHead - }) - { - SelectedItem = new Bindable() - }, + }), } }); } - private DrawableRoom createLoungeRoom(Room room) + private RoomPanel createLoungeRoom(Room room) { room.Host ??= new APIUser { Username = "peppy", Id = 2 }; @@ -204,7 +195,7 @@ namespace osu.Game.Tests.Visual.Multiplayer }).ToArray(); } - return new DrawableLoungeRoom(room) + return new LoungeRoomPanel(room) { MatchingFilter = true, SelectedRoom = selectedRoom diff --git a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsLoungeSubScreen.cs b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsLoungeSubScreen.cs index ceb3a32402..f2eeb5363a 100644 --- a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsLoungeSubScreen.cs +++ b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsLoungeSubScreen.cs @@ -61,9 +61,9 @@ namespace osu.Game.Tests.Visual.Playlists AddUntilStep("last room is not masked", () => checkRoomVisible(roomListing.DrawableRooms[^1])); } - private bool checkRoomVisible(DrawableRoom room) => + private bool checkRoomVisible(RoomPanel panel) => loungeScreen.ChildrenOfType().First().ScreenSpaceDrawQuad - .Contains(room.ScreenSpaceDrawQuad.Centre); + .Contains(panel.ScreenSpaceDrawQuad.Centre); private void createRooms(params Room[] rooms) { diff --git a/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomListing.cs b/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomListing.cs index 0276601656..14edd13ec5 100644 --- a/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomListing.cs +++ b/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomListing.cs @@ -40,10 +40,10 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components private readonly Bindable selectedRoom = new Bindable(); - public IReadOnlyList DrawableRooms => roomFlow.FlowingChildren.Cast().ToArray(); + public IReadOnlyList DrawableRooms => roomFlow.FlowingChildren.Cast().ToArray(); private readonly ScrollContainer scroll; - private readonly FillFlowContainer roomFlow; + private readonly FillFlowContainer roomFlow; private const float display_scale = 0.8f; @@ -65,7 +65,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Child = roomFlow = new FillFlowContainer + Child = roomFlow = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, @@ -128,7 +128,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components return true; } - static bool matchPermissions(DrawableLoungeRoom room, RoomPermissionsFilter accessType) + static bool matchPermissions(LoungeRoomPanel room, RoomPermissionsFilter accessType) { switch (accessType) { @@ -183,7 +183,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components { foreach (var room in rooms) { - var drawableRoom = new DrawableLoungeRoom(room) + var drawableRoom = new LoungeRoomPanel(room) { SelectedRoom = selectedRoom, Anchor = Anchor.Centre, diff --git a/osu.Game/Screens/OnlinePlay/Lounge/Components/DrawableRoom.cs b/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomPanel.cs similarity index 99% rename from osu.Game/Screens/OnlinePlay/Lounge/Components/DrawableRoom.cs rename to osu.Game/Screens/OnlinePlay/Lounge/Components/RoomPanel.cs index 491d8071f1..b9fe45d227 100644 --- a/osu.Game/Screens/OnlinePlay/Lounge/Components/DrawableRoom.cs +++ b/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomPanel.cs @@ -35,7 +35,7 @@ using Container = osu.Framework.Graphics.Containers.Container; namespace osu.Game.Screens.OnlinePlay.Lounge.Components { - public abstract partial class DrawableRoom : CompositeDrawable, IHasContextMenu + public abstract partial class RoomPanel : CompositeDrawable, IHasContextMenu { protected const float CORNER_RADIUS = 10; private const float height = 100; @@ -63,7 +63,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components private UpdateableBeatmapBackgroundSprite background = null!; private DelayedLoadWrapper wrapper = null!; - protected DrawableRoom(Room room) + protected RoomPanel(Room room) { Room = room; diff --git a/osu.Game/Screens/OnlinePlay/Lounge/DrawableLoungeRoom.cs b/osu.Game/Screens/OnlinePlay/Lounge/LoungeRoomPanel.cs similarity index 97% rename from osu.Game/Screens/OnlinePlay/Lounge/DrawableLoungeRoom.cs rename to osu.Game/Screens/OnlinePlay/Lounge/LoungeRoomPanel.cs index 339780b517..3ff27a14bb 100644 --- a/osu.Game/Screens/OnlinePlay/Lounge/DrawableLoungeRoom.cs +++ b/osu.Game/Screens/OnlinePlay/Lounge/LoungeRoomPanel.cs @@ -37,9 +37,9 @@ using Container = osu.Framework.Graphics.Containers.Container; namespace osu.Game.Screens.OnlinePlay.Lounge { /// - /// A with lounge-specific interactions such as selection and hover sounds. + /// A with lounge-specific interactions such as selection and hover sounds. /// - public partial class DrawableLoungeRoom : DrawableRoom, IFilterable, IHasPopover, IKeyBindingHandler + public partial class LoungeRoomPanel : RoomPanel, IFilterable, IHasPopover, IKeyBindingHandler { private const float transition_duration = 60; private const float selection_border_width = 4; @@ -64,7 +64,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge private Sample? sampleJoin; private Drawable selectionBox = null!; - public DrawableLoungeRoom(Room room) + public LoungeRoomPanel(Room room) : base(room) { } diff --git a/osu.Game/Screens/OnlinePlay/Match/DrawableMatchRoom.cs b/osu.Game/Screens/OnlinePlay/Match/DrawableMatchRoom.cs deleted file mode 100644 index b10e83a05c..0000000000 --- a/osu.Game/Screens/OnlinePlay/Match/DrawableMatchRoom.cs +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using System; -using System.ComponentModel; -using osu.Framework.Allocation; -using osu.Framework.Bindables; -using osu.Framework.Graphics; -using osu.Game.Beatmaps.Drawables; -using osu.Game.Online.API; -using osu.Game.Online.Rooms; -using osu.Game.Screens.OnlinePlay.Lounge.Components; -using osu.Game.Screens.OnlinePlay.Match.Components; -using osuTK; - -namespace osu.Game.Screens.OnlinePlay.Match -{ - public partial class DrawableMatchRoom : DrawableRoom - { - public Action? OnEdit; - - public new required Bindable SelectedItem - { - get => selectedItem; - set => selectedItem.Current = value; - } - - public Drawable? ChangeSettingsButton { get; private set; } - - [Resolved] - private IAPIProvider api { get; set; } = null!; - - private readonly BindableWithCurrent selectedItem = new BindableWithCurrent(); - private readonly bool allowEdit; - - public DrawableMatchRoom(Room room, bool allowEdit = true) - : base(room) - { - this.allowEdit = allowEdit; - - base.SelectedItem.BindTo(SelectedItem); - } - - [BackgroundDependencyLoader] - private void load() - { - if (allowEdit) - { - ButtonsContainer.Add(ChangeSettingsButton = new PurpleRoundedButton - { - RelativeSizeAxes = Axes.Y, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(120, 0.7f), - Text = "Change settings", - Action = () => OnEdit?.Invoke() - }); - } - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - Room.PropertyChanged += onRoomPropertyChanged; - updateRoomHost(); - } - - private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e) - { - if (e.PropertyName == nameof(Room.Host)) - updateRoomHost(); - } - - private void updateRoomHost() - { - if (ChangeSettingsButton != null) - ChangeSettingsButton.Alpha = Room.Host?.Equals(api.LocalUser.Value) == true ? 1 : 0; - } - - protected override UpdateableBeatmapBackgroundSprite CreateBackground() => base.CreateBackground().With(d => - { - d.BackgroundLoadDelay = 0; - }); - - protected override void Dispose(bool isDisposing) - { - base.Dispose(isDisposing); - Room.PropertyChanged -= onRoomPropertyChanged; - } - } -} diff --git a/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs b/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs index eca59c8393..0750ca6b8e 100644 --- a/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs @@ -100,7 +100,6 @@ namespace osu.Game.Screens.OnlinePlay.Match protected IBindable BeatmapAvailability => beatmapAvailabilityTracker.Availability; public readonly Room Room; - private readonly bool allowEdit; internal ModSelectOverlay UserModsSelectOverlay { get; private set; } = null!; @@ -112,12 +111,9 @@ namespace osu.Game.Screens.OnlinePlay.Match /// Creates a new . /// /// The . - /// Whether to allow editing room settings post-creation. - protected RoomSubScreen(Room room, bool allowEdit = true) + protected RoomSubScreen(Room room) { Room = room; - this.allowEdit = allowEdit; - Padding = new MarginPadding { Top = Header.HEIGHT }; } @@ -172,10 +168,9 @@ namespace osu.Game.Screens.OnlinePlay.Match { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Child = new DrawableMatchRoom(Room, allowEdit) + Child = new MultiplayerRoomPanel(Room) { OnEdit = () => settingsOverlay.Show(), - SelectedItem = SelectedItem } } }, diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerRoomPanel.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerRoomPanel.cs new file mode 100644 index 0000000000..e52133b46b --- /dev/null +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerRoomPanel.cs @@ -0,0 +1,78 @@ +// Copyright (c) ppy Pty Ltd . 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.Extensions.ObjectExtensions; +using osu.Framework.Graphics; +using osu.Game.Beatmaps.Drawables; +using osu.Game.Online.Multiplayer; +using osu.Game.Online.Rooms; +using osu.Game.Screens.OnlinePlay.Lounge.Components; +using osu.Game.Screens.OnlinePlay.Match.Components; +using osuTK; + +namespace osu.Game.Screens.OnlinePlay.Multiplayer +{ + /// + /// A to be displayed in a multiplayer lobby. + /// + public partial class MultiplayerRoomPanel : RoomPanel + { + public Action? OnEdit { get; set; } + + public Drawable ChangeSettingsButton { get; private set; } = null!; + + [Resolved] + private MultiplayerClient client { get; set; } = null!; + + public MultiplayerRoomPanel(Room room) + : base(room) + { + } + + [BackgroundDependencyLoader] + private void load() + { + ButtonsContainer.Add(ChangeSettingsButton = new PurpleRoundedButton + { + RelativeSizeAxes = Axes.Y, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(120, 0.7f), + Text = "Change settings", + Action = () => OnEdit?.Invoke() + }); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + client.RoomUpdated += onRoomUpdated; + onRoomUpdated(); + } + + private void onRoomUpdated() => Scheduler.AddOnce(() => + { + if (client.Room == null || client.LocalUser == null) + return; + + ChangeSettingsButton.Alpha = client.IsHost ? 1 : 0; + SelectedItem.Value = new PlaylistItem(client.Room.CurrentPlaylistItem); + }); + + protected override UpdateableBeatmapBackgroundSprite CreateBackground() => base.CreateBackground().With(d => + { + d.BackgroundLoadDelay = 0; + }); + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + if (client.IsNotNull()) + client.RoomUpdated -= onRoomUpdated; + } + } +} diff --git a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomPanel.cs b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomPanel.cs new file mode 100644 index 0000000000..d6c0f4dcbc --- /dev/null +++ b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomPanel.cs @@ -0,0 +1,36 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Game.Beatmaps.Drawables; +using osu.Game.Online.Rooms; +using osu.Game.Screens.OnlinePlay.Lounge.Components; + +namespace osu.Game.Screens.OnlinePlay.Playlists +{ + /// + /// A to be displayed in a playlists lobby. + /// + public partial class PlaylistsRoomPanel : RoomPanel + { + public new required Bindable SelectedItem + { + get => selectedItem.Current; + set => selectedItem.Current = value; + } + + private readonly BindableWithCurrent selectedItem = new BindableWithCurrent(); + + public PlaylistsRoomPanel(Room room) + : base(room) + { + base.SelectedItem.BindTo(SelectedItem); + } + + protected override UpdateableBeatmapBackgroundSprite CreateBackground() => base.CreateBackground().With(d => + { + d.BackgroundLoadDelay = 0; + }); + } +} diff --git a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomSubScreen.cs b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomSubScreen.cs index 89416e66bf..e843f50e19 100644 --- a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomSubScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomSubScreen.cs @@ -191,9 +191,8 @@ namespace osu.Game.Screens.OnlinePlay.Playlists { new Drawable[] { - new DrawableMatchRoom(room, false) + new PlaylistsRoomPanel(room) { - OnEdit = () => settingsOverlay.Show(), SelectedItem = SelectedItem } },