From 7e3e5208f0c719993f7bcc46809069979287509e Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 13 Nov 2024 18:52:04 +0900 Subject: [PATCH] Make `Room.Availability` non-bindable --- osu.Game/Online/Rooms/Room.cs | 17 +++++++++++++---- .../Screens/OnlinePlay/OnlinePlayComposite.cs | 3 --- .../Playlists/PlaylistsRoomSettingsOverlay.cs | 19 +++++++++++++++---- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/osu.Game/Online/Rooms/Room.cs b/osu.Game/Online/Rooms/Room.cs index 760580c003..d43d40bd66 100644 --- a/osu.Game/Online/Rooms/Room.cs +++ b/osu.Game/Online/Rooms/Room.cs @@ -87,6 +87,15 @@ namespace osu.Game.Online.Rooms set => SetField(ref status, value); } + /// + /// Describes which players are able to join the room. + /// + public RoomAvailability Availability + { + get => availability; + set => SetField(ref availability, value); + } + [JsonProperty("id")] private long? roomId; @@ -110,6 +119,9 @@ namespace osu.Game.Online.Rooms // Not serialised (see: GetRoomsRequest). private RoomStatus status = new RoomStatusOpen(); + // Not yet serialised (not implemented). + private RoomAvailability availability; + [Cached] [JsonProperty("playlist")] public readonly BindableList Playlist = new BindableList(); @@ -129,9 +141,6 @@ namespace osu.Game.Online.Rooms [Cached] public readonly Bindable MaxAttempts = new Bindable(); - [Cached] - public readonly Bindable Availability = new Bindable(); - [Cached] public readonly Bindable QueueMode = new Bindable(); @@ -241,7 +250,7 @@ namespace osu.Game.Online.Rooms ChannelId.Value = other.ChannelId.Value; Status = other.Status; - Availability.Value = other.Availability.Value; + Availability = other.Availability; HasPassword.Value = other.HasPassword.Value; Type = other.Type; MaxParticipants.Value = other.MaxParticipants.Value; diff --git a/osu.Game/Screens/OnlinePlay/OnlinePlayComposite.cs b/osu.Game/Screens/OnlinePlay/OnlinePlayComposite.cs index 82774abac7..d444067da6 100644 --- a/osu.Game/Screens/OnlinePlay/OnlinePlayComposite.cs +++ b/osu.Game/Screens/OnlinePlay/OnlinePlayComposite.cs @@ -46,9 +46,6 @@ namespace osu.Game.Screens.OnlinePlay [Resolved(typeof(Room))] protected Bindable EndDate { get; private set; } = null!; - [Resolved(typeof(Room))] - protected Bindable Availability { get; private set; } = null!; - [Resolved(typeof(Room))] public Bindable Password { get; private set; } = null!; diff --git a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomSettingsOverlay.cs b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomSettingsOverlay.cs index 84a4657693..aee26e544a 100644 --- a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomSettingsOverlay.cs +++ b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomSettingsOverlay.cs @@ -316,7 +316,6 @@ namespace osu.Game.Screens.OnlinePlay.Playlists loadingLayer = new LoadingLayer(true) }; - Availability.BindValueChanged(availability => AvailabilityPicker.Current.Value = availability.NewValue, true); MaxParticipants.BindValueChanged(count => MaxParticipantsField.Text = count.NewValue?.ToString(), true); MaxAttempts.BindValueChanged(count => MaxAttemptsField.Text = count.NewValue?.ToString(), true); Duration.BindValueChanged(duration => DurationField.Current.Value = duration.NewValue ?? TimeSpan.FromMinutes(30), true); @@ -346,17 +345,29 @@ namespace osu.Game.Screens.OnlinePlay.Playlists room.PropertyChanged += onRoomPropertyChanged; updateRoomName(); + updateRoomAvailability(); } private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e) { - if (e.PropertyName == nameof(Room.Name)) - updateRoomName(); + switch (e.PropertyName) + { + case nameof(Room.Name): + updateRoomName(); + break; + + case nameof(Room.Availability): + updateRoomAvailability(); + break; + } } private void updateRoomName() => NameField.Text = room.Name; + private void updateRoomAvailability() + => AvailabilityPicker.Current.Value = room.Availability; + private void populateDurations(ValueChangedEvent user) { // roughly correct (see https://github.com/Humanizr/Humanizer/blob/18167e56c082449cc4fe805b8429e3127a7b7f93/readme.md?plain=1#L427) @@ -405,7 +416,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists hideError(); room.Name = NameField.Text; - Availability.Value = AvailabilityPicker.Current.Value; + room.Availability = AvailabilityPicker.Current.Value; if (int.TryParse(MaxParticipantsField.Text, out int max)) MaxParticipants.Value = max;