From e22cefc27d8139841f9adee55959493f21423b30 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 3 Dec 2018 20:50:40 +0900 Subject: [PATCH] Immediately select newly-created rooms --- osu.Game/Online/Multiplayer/Room.cs | 3 +- .../Screens/Multi/Components/DrawableRoom.cs | 20 +------ .../Multi/Components/RoomSettingsOverlay.cs | 15 ++++- .../Screens/Multi/Screens/Lounge/Lounge.cs | 59 +++++++++++-------- osu.Game/Screens/Multi/Screens/Match/Match.cs | 2 + .../Multi/Screens/Match/Participants.cs | 3 +- 6 files changed, 58 insertions(+), 44 deletions(-) diff --git a/osu.Game/Online/Multiplayer/Room.cs b/osu.Game/Online/Multiplayer/Room.cs index cb2979d733..f4885b6a4a 100644 --- a/osu.Game/Online/Multiplayer/Room.cs +++ b/osu.Game/Online/Multiplayer/Room.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; +using System.Linq; using osu.Framework.Configuration; using osu.Game.Beatmaps; using osu.Game.Users; @@ -17,6 +18,6 @@ namespace osu.Game.Online.Multiplayer public Bindable Type = new Bindable(new GameTypeVersus()); public Bindable Beatmap = new Bindable(); public Bindable MaxParticipants = new Bindable(); - public Bindable> Participants = new Bindable>(); + public Bindable> Participants = new Bindable>(Enumerable.Empty()); } } diff --git a/osu.Game/Screens/Multi/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Components/DrawableRoom.cs index 05ec2f0fac..c5fac7170f 100644 --- a/osu.Game/Screens/Multi/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Components/DrawableRoom.cs @@ -34,6 +34,8 @@ namespace osu.Game.Screens.Multi.Components private const float side_strip_width = 5; private const float cover_width = 145; + public Action SelectionRequested; + private readonly Box selectionBox; private readonly Bindable nameBind = new Bindable(); @@ -76,17 +78,6 @@ namespace osu.Game.Screens.Multi.Components } } - private Action action; - public new Action Action - { - get { return action; } - set - { - action = value; - Enabled.Value = action != null; - } - } - public event Action StateChanged; public DrawableRoom(Room room) @@ -248,12 +239,7 @@ namespace osu.Game.Screens.Multi.Components protected override bool OnClick(ClickEvent e) { - if (Enabled.Value) - { - Action?.Invoke(this); - State = SelectionState.Selected; - } - + State = SelectionState.Selected; return true; } } diff --git a/osu.Game/Screens/Multi/Components/RoomSettingsOverlay.cs b/osu.Game/Screens/Multi/Components/RoomSettingsOverlay.cs index df70e577d5..b3d7937433 100644 --- a/osu.Game/Screens/Multi/Components/RoomSettingsOverlay.cs +++ b/osu.Game/Screens/Multi/Components/RoomSettingsOverlay.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; @@ -21,6 +22,16 @@ namespace osu.Game.Screens.Multi.Components private const float transition_duration = 350; private const float field_padding = 45; + /// + /// Invoked when room settings were applied. + /// + public Action Applied; + + /// + /// The room which settings are being applied to. + /// + public readonly Room Room; + private readonly Bindable nameBind = new Bindable(); private readonly Bindable availabilityBind = new Bindable(); private readonly Bindable typeBind = new Bindable(); @@ -36,6 +47,8 @@ namespace osu.Game.Screens.Multi.Components public RoomSettingsOverlay(Room room) { + Room = room; + Masking = true; Child = content = new Container @@ -185,7 +198,7 @@ namespace osu.Game.Screens.Multi.Components else maxParticipantsBind.Value = null; - Hide(); + Applied?.Invoke(); } private class SettingsTextBox : OsuTextBox diff --git a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs index eb16524776..96728c01f9 100644 --- a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs +++ b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; -using System.Linq; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -30,29 +29,6 @@ namespace osu.Game.Screens.Multi.Screens.Lounge protected override Container TransitionContent => content; - private IEnumerable rooms; - public IEnumerable Rooms - { - get { return rooms; } - set - { - if (Equals(value, rooms)) return; - rooms = value; - - var enumerable = rooms.ToList(); - - RoomsContainer.Children = enumerable.Select(r => new DrawableRoom(r) - { - Action = didSelect, - }).ToList(); - - if (!enumerable.Contains(Inspector.Room)) - Inspector.Room = null; - - filterRooms(); - } - } - public Lounge() { Children = new Drawable[] @@ -108,6 +84,12 @@ namespace osu.Game.Screens.Multi.Screens.Lounge Filter.Search.Current.ValueChanged += s => filterRooms(); Filter.Tabs.Current.ValueChanged += t => filterRooms(); Filter.Search.Exit += Exit; + + settings.Applied = () => + { + var drawableRoom = addRoom(settings.Room); + drawableRoom.State = SelectionState.Selected; + }; } protected override void UpdateAfterChildren() @@ -122,6 +104,35 @@ namespace osu.Game.Screens.Multi.Screens.Lounge }; } + public IEnumerable Rooms + { + set + { + RoomsContainer.ForEach(r => r.Action = null); + RoomsContainer.Clear(); + + foreach (var room in value) + addRoom(room); + } + } + + private DrawableRoom addRoom(Room room) + { + var drawableRoom = new DrawableRoom(room); + + drawableRoom.StateChanged += s => + { + if (s == SelectionState.Selected) + didSelect(drawableRoom); + }; + + RoomsContainer.Add(drawableRoom); + + filterRooms(); + + return drawableRoom; + } + protected override void OnFocus(FocusEvent e) { GetContainingInputManager().ChangeFocus(Filter.Search); diff --git a/osu.Game/Screens/Multi/Screens/Match/Match.cs b/osu.Game/Screens/Multi/Screens/Match/Match.cs index 5bfc1f59bd..339db2e158 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Match.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Match.cs @@ -88,6 +88,8 @@ namespace osu.Game.Screens.Multi.Screens.Match header.Tabs.Current.Value = MatchHeaderPage.Room; }; + settings.Applied = () => settings.Hide(); + nameBind.BindTo(room.Name); nameBind.BindValueChanged(n => info.Name = n, true); diff --git a/osu.Game/Screens/Multi/Screens/Match/Participants.cs b/osu.Game/Screens/Multi/Screens/Match/Participants.cs index 55541a1acd..a5ac93fffc 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Participants.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Participants.cs @@ -19,7 +19,8 @@ namespace osu.Game.Screens.Multi.Screens.Match public IEnumerable Users { - set { + set + { usersFlow.Children = value.Select(u => new UserPanel(u) { Anchor = Anchor.TopCentre,