diff --git a/osu.Game/Screens/Multi/Components/DisableableTabControl.cs b/osu.Game/Screens/Multi/Components/DisableableTabControl.cs index 1ca61a2678..e2a44f7ff4 100644 --- a/osu.Game/Screens/Multi/Components/DisableableTabControl.cs +++ b/osu.Game/Screens/Multi/Components/DisableableTabControl.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; +using osu.Framework.Configuration; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input.Events; @@ -9,33 +9,33 @@ namespace osu.Game.Screens.Multi.Components { public abstract class DisableableTabControl : TabControl { - public IEnumerable DisabledItems + public readonly BindableBool ReadOnly = new BindableBool(); + + protected override void AddTabItem(TabItem tab, bool addToDropdown = true) { - set - { - foreach (var item in value) - (TabMap[item] as DisableableTabItem)?.Disable(); - } + if (tab is DisableableTabItem disableable) + disableable.ReadOnly.BindTo(ReadOnly); + base.AddTabItem(tab, addToDropdown); } protected abstract class DisableableTabItem : TabItem { + public readonly BindableBool ReadOnly = new BindableBool(); + protected DisableableTabItem(T value) : base(value) { + ReadOnly.BindValueChanged(updateReadOnly); } - private bool isDisabled; - - public void Disable() + private void updateReadOnly(bool readOnly) { - Alpha = 0.2f; - isDisabled = true; + Alpha = readOnly ? 0.2f : 1; } protected override bool OnClick(ClickEvent e) { - if (isDisabled) + if (ReadOnly) return true; return base.OnClick(e); } diff --git a/osu.Game/Screens/Multi/Components/RoomSettingsOverlay.cs b/osu.Game/Screens/Multi/Components/RoomSettingsOverlay.cs index 92a8fc8bb7..4e0a9ff3a2 100644 --- a/osu.Game/Screens/Multi/Components/RoomSettingsOverlay.cs +++ b/osu.Game/Screens/Multi/Components/RoomSettingsOverlay.cs @@ -40,6 +40,7 @@ public class RoomSettingsOverlay : FocusedOverlayContainer protected readonly RoomAvailabilityPicker AvailabilityPicker; protected readonly GameTypePicker TypePicker; protected readonly TriangleButton ApplyButton; + protected readonly OsuPasswordTextBox PasswordField; public RoomSettingsOverlay() { @@ -116,20 +117,16 @@ public RoomSettingsOverlay() { RelativeSizeAxes = Axes.X, TabbableContentContainer = this, - Alpha = 0.2f, - ReadOnly = true, OnCommit = (sender, text) => apply(), }, }, new Section("PASSWORD (OPTIONAL)") { - Child = new SettingsPasswordTextBox + Child = PasswordField = new SettingsPasswordTextBox { RelativeSizeAxes = Axes.X, TabbableContentContainer = this, - OnCommit = (sender, text) => apply(), - Alpha = 0.2f, - ReadOnly = true, + OnCommit = (sender, text) => apply() }, }, }, @@ -154,20 +151,6 @@ public RoomSettingsOverlay() typeBind.ValueChanged += t => TypePicker.Current.Value = t; maxParticipantsBind.ValueChanged += m => MaxParticipantsField.Text = m?.ToString(); - AvailabilityPicker.DisabledItems = new[] - { - RoomAvailability.FriendsOnly, - RoomAvailability.InviteOnly - }; - - TypePicker.DisabledItems = new GameType[] - { - new GameTypeTag(), - new GameTypeVersus(), - new GameTypeTagTeam(), - new GameTypeTeamVersus(), - }; - Room = new Room(); } @@ -177,6 +160,27 @@ private void load(OsuColour colours) typeLabel.Colour = colours.Yellow; } + private bool readOnly; + + public bool ReadOnly + { + get => readOnly; + set + { + if (readOnly == value) + return; + readOnly = value; + + NameField.ReadOnly = value; + MaxParticipantsField.ReadOnly = value; + PasswordField.ReadOnly = value; + AvailabilityPicker.ReadOnly.Value = value; + TypePicker.ReadOnly.Value = value; + ApplyButton.Enabled.Value = !value; + } + } + + private Room room; /// diff --git a/osu.Game/Screens/Multi/Components/CreateRoomOverlay.cs b/osu.Game/Screens/Multi/Screens/Lounge/CreateRoomOverlay.cs similarity index 69% rename from osu.Game/Screens/Multi/Components/CreateRoomOverlay.cs rename to osu.Game/Screens/Multi/Screens/Lounge/CreateRoomOverlay.cs index 3a6224da26..45acb7ebec 100644 --- a/osu.Game/Screens/Multi/Components/CreateRoomOverlay.cs +++ b/osu.Game/Screens/Multi/Screens/Lounge/CreateRoomOverlay.cs @@ -4,14 +4,23 @@ 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.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() { diff --git a/osu.Game/Screens/Multi/Screens/Match/Match.cs b/osu.Game/Screens/Multi/Screens/Match/Match.cs index 4f81ffd305..74e5bf0a85 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Match.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Match.cs @@ -75,7 +75,8 @@ public Match(Room room) { RelativeSizeAxes = Axes.Both, Height = 0.9f, - Room = room + Room = room, + ReadOnly = true }, }, };