diff --git a/osu.Game.Tests/Visual/TestCaseRoomSettings.cs b/osu.Game.Tests/Visual/TestCaseRoomSettings.cs index 463002fbcb..b0b287fdb3 100644 --- a/osu.Game.Tests/Visual/TestCaseRoomSettings.cs +++ b/osu.Game.Tests/Visual/TestCaseRoomSettings.cs @@ -9,6 +9,7 @@ using osu.Framework.Testing.Input; using osu.Game.Online.Multiplayer; using osu.Game.Screens.Multi.Components; +using osu.Game.Screens.Multi.Screens.Match; using osuTK.Input; namespace osu.Game.Tests.Visual diff --git a/osu.Game/Online/Multiplayer/Room.cs b/osu.Game/Online/Multiplayer/Room.cs index 8395b7e638..67ddb60823 100644 --- a/osu.Game/Online/Multiplayer/Room.cs +++ b/osu.Game/Online/Multiplayer/Room.cs @@ -19,5 +19,7 @@ public class Room public Bindable Beatmap = new Bindable(); public Bindable MaxParticipants = new Bindable(); public Bindable> Participants = new Bindable>(Enumerable.Empty()); + + public Bindable Created = new Bindable(); } } diff --git a/osu.Game/Screens/Multi/Screens/Lounge/CreateRoomOverlay.cs b/osu.Game/Screens/Multi/Screens/Lounge/CreateRoomOverlay.cs deleted file mode 100644 index 45acb7ebec..0000000000 --- a/osu.Game/Screens/Multi/Screens/Lounge/CreateRoomOverlay.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Allocation; -using osu.Game.Online.API; -using osu.Game.Online.Multiplayer; -using osu.Game.Screens.Multi.Components; - -namespace osu.Game.Screens.Multi.Screens.Lounge -{ - public class CreateRoomOverlay : RoomSettingsOverlay - { - [Resolved] - private APIAccess api { get; set; } - - public CreateRoomOverlay() - { - MaxParticipantsField.ReadOnly = true; - AvailabilityPicker.ReadOnly.Value = true; - TypePicker.ReadOnly.Value = true; - PasswordField.ReadOnly = true; - } - - [BackgroundDependencyLoader] - private void load() - { - Room.Host.Value = api.LocalUser; - } - - public override Room Room - { - get => base.Room; - set - { - base.Room = value; - - if (api != null && value != null) - value.Host.Value = api.LocalUser; - } - } - } -} diff --git a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs index 140b3550c1..6fa254be05 100644 --- a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs +++ b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs @@ -19,7 +19,6 @@ public class Lounge : MultiplayerScreen { private readonly Container content; private readonly SearchContainer search; - private readonly CreateRoomOverlay createRoomOverlay; protected readonly FilterControl Filter; protected readonly FillFlowContainer RoomsContainer; @@ -68,16 +67,6 @@ public Lounge() RelativeSizeAxes = Axes.Both, Width = 0.45f, }, - new Container - { - RelativeSizeAxes = Axes.Both, - Child = createRoomOverlay = new CreateRoomOverlay - { - RelativeSizeAxes = Axes.Both, - Height = 0.9f, - Room = new Room() - }, - }, }, } }; @@ -85,8 +74,6 @@ public Lounge() Filter.Search.Current.ValueChanged += s => filterRooms(); Filter.Tabs.Current.ValueChanged += t => filterRooms(); Filter.Search.Exit += Exit; - - createRoomOverlay.Applied = () => createRoom(createRoomOverlay.Room); } protected override void UpdateAfterChildren() @@ -147,8 +134,6 @@ protected override void OnResuming(Screen last) { base.OnResuming(last); - createRoomOverlay.Room = new Room(); - Filter.Search.HoldFocus = true; } @@ -161,9 +146,10 @@ protected override void OnSuspending(Screen next) private void filterRooms() { if (Filter.Tabs.Current.Value == LoungeTab.Create) - createRoomOverlay.Show(); - else - createRoomOverlay.Hide(); + { + Filter.Tabs.Current.Value = LoungeTab.Public; + createRoom(new Room()); + } search.SearchTerm = Filter.Search.Current.Value ?? string.Empty; diff --git a/osu.Game/Screens/Multi/Screens/Match/Header.cs b/osu.Game/Screens/Multi/Screens/Match/Header.cs index 50db63e3e3..78a4a937a4 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Header.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Header.cs @@ -15,7 +15,6 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; -using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.SearchableList; using osuTK.Graphics; @@ -29,7 +28,7 @@ public class Header : Container private readonly Box tabStrip; - public readonly PageTabControl Tabs; + public readonly MatchTabControl Tabs; public Action OnRequestSelectBeatmap; @@ -78,11 +77,11 @@ public Header() RelativeSizeAxes = Axes.Both, }, }, - Tabs = new PageTabControl + Tabs = new MatchTabControl { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - RelativeSizeAxes = Axes.X, + RelativeSizeAxes = Axes.X }, }, }, diff --git a/osu.Game/Screens/Multi/Screens/Match/Match.cs b/osu.Game/Screens/Multi/Screens/Match/Match.cs index 74e5bf0a85..f444cb4073 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Match.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Match.cs @@ -7,8 +7,8 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; +using osu.Game.Online.API; using osu.Game.Online.Multiplayer; -using osu.Game.Screens.Multi.Components; using osu.Game.Screens.Select; using osu.Game.Users; @@ -16,7 +16,6 @@ namespace osu.Game.Screens.Multi.Screens.Match { public class Match : MultiplayerScreen { - private readonly Room room; private readonly Participants participants; private readonly Bindable nameBind = new Bindable(); @@ -33,9 +32,17 @@ public class Match : MultiplayerScreen public override string ShortTitle => "room"; + private readonly Header header; + + [Cached] + private readonly Room room; + [Resolved] private BeatmapManager beatmapManager { get; set; } + [Resolved] + private APIAccess api { get; set; } + public Match(Room room) { this.room = room; @@ -48,7 +55,6 @@ public Match(Room room) participantsBind.BindTo(room.Participants); maxParticipantsBind.BindTo(room.MaxParticipants); - Header header; RoomSettingsOverlay settings; Info info; @@ -86,7 +92,7 @@ public Match(Room room) header.Tabs.Current.ValueChanged += t => { - if (t == MatchHeaderPage.Settings) + if (t is SettingsMatchPage) settings.Show(); else settings.Hide(); @@ -95,7 +101,7 @@ public Match(Room room) settings.StateChanged += s => { if (s == Visibility.Hidden) - header.Tabs.Current.Value = MatchHeaderPage.Room; + header.Tabs.Current.Value = new RoomMatchPage(); }; settings.Applied = () => settings.Hide(); diff --git a/osu.Game/Screens/Multi/Screens/Match/MatchPage.cs b/osu.Game/Screens/Multi/Screens/Match/MatchPage.cs new file mode 100644 index 0000000000..710e41ec69 --- /dev/null +++ b/osu.Game/Screens/Multi/Screens/Match/MatchPage.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Configuration; + +namespace osu.Game.Screens.Multi.Screens.Match +{ + public abstract class MatchPage + { + public abstract string Name { get; } + + public readonly BindableBool Enabled = new BindableBool(true); + + public override string ToString() => Name; + public override int GetHashCode() => GetType().GetHashCode(); + public override bool Equals(object obj) => GetType() == obj?.GetType(); + } + + public class SettingsMatchPage : MatchPage + { + public override string Name => "Settings"; + } + + public class RoomMatchPage : MatchPage + { + public override string Name => "Room"; + } +} diff --git a/osu.Game/Screens/Multi/Screens/Match/MatchTabControl.cs b/osu.Game/Screens/Multi/Screens/Match/MatchTabControl.cs new file mode 100644 index 0000000000..5fd64179cd --- /dev/null +++ b/osu.Game/Screens/Multi/Screens/Match/MatchTabControl.cs @@ -0,0 +1,68 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Input.Events; +using osu.Game.Graphics.UserInterface; +using osu.Game.Online.Multiplayer; +using osuTK.Graphics; + +namespace osu.Game.Screens.Multi.Screens.Match +{ + public class MatchTabControl : PageTabControl + { + private readonly IBindable created = new Bindable(); + + [Resolved] + private Room room { get; set; } + + public MatchTabControl() + { + AddItem(new SettingsMatchPage()); + AddItem(new RoomMatchPage()); + } + + [BackgroundDependencyLoader] + private void load() + { + created.BindTo(room.Created); + created.BindValueChanged(v => + { + if (v) + { + Items.ForEach(t => t.Enabled.Value = !(t is SettingsMatchPage)); + Current.Value = new RoomMatchPage(); + } + else + { + Items.ForEach(t => t.Enabled.Value = t is SettingsMatchPage); + Current.Value = new SettingsMatchPage(); + } + }, true); + } + + protected override TabItem CreateTabItem(MatchPage value) => new TabItem(value); + + private class TabItem : PageTabItem + { + private readonly IBindable enabled = new BindableBool(); + + public TabItem(MatchPage value) + : base(value) + { + enabled.BindTo(value.Enabled); + enabled.BindValueChanged(v => Colour = v ? Color4.White : Color4.Gray); + } + + protected override bool OnClick(ClickEvent e) + { + if (!enabled.Value) + return true; + return base.OnClick(e); + } + } + } +} diff --git a/osu.Game/Screens/Multi/Components/RoomSettingsOverlay.cs b/osu.Game/Screens/Multi/Screens/Match/RoomSettingsOverlay.cs similarity index 99% rename from osu.Game/Screens/Multi/Components/RoomSettingsOverlay.cs rename to osu.Game/Screens/Multi/Screens/Match/RoomSettingsOverlay.cs index 4e0a9ff3a2..7fba56b2d3 100644 --- a/osu.Game/Screens/Multi/Components/RoomSettingsOverlay.cs +++ b/osu.Game/Screens/Multi/Screens/Match/RoomSettingsOverlay.cs @@ -12,10 +12,11 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Online.Multiplayer; using osu.Game.Overlays.SearchableList; +using osu.Game.Screens.Multi.Components; using osuTK; using osuTK.Graphics; -namespace osu.Game.Screens.Multi.Components +namespace osu.Game.Screens.Multi.Screens.Match { public class RoomSettingsOverlay : FocusedOverlayContainer {