1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 02:52:54 +08:00

Make Room.Availability non-bindable

This commit is contained in:
Dan Balasescu 2024-11-13 18:52:04 +09:00
parent 5d4838a08b
commit 7e3e5208f0
No known key found for this signature in database
3 changed files with 28 additions and 11 deletions

View File

@ -87,6 +87,15 @@ namespace osu.Game.Online.Rooms
set => SetField(ref status, value); set => SetField(ref status, value);
} }
/// <summary>
/// Describes which players are able to join the room.
/// </summary>
public RoomAvailability Availability
{
get => availability;
set => SetField(ref availability, value);
}
[JsonProperty("id")] [JsonProperty("id")]
private long? roomId; private long? roomId;
@ -110,6 +119,9 @@ namespace osu.Game.Online.Rooms
// Not serialised (see: GetRoomsRequest). // Not serialised (see: GetRoomsRequest).
private RoomStatus status = new RoomStatusOpen(); private RoomStatus status = new RoomStatusOpen();
// Not yet serialised (not implemented).
private RoomAvailability availability;
[Cached] [Cached]
[JsonProperty("playlist")] [JsonProperty("playlist")]
public readonly BindableList<PlaylistItem> Playlist = new BindableList<PlaylistItem>(); public readonly BindableList<PlaylistItem> Playlist = new BindableList<PlaylistItem>();
@ -129,9 +141,6 @@ namespace osu.Game.Online.Rooms
[Cached] [Cached]
public readonly Bindable<int?> MaxAttempts = new Bindable<int?>(); public readonly Bindable<int?> MaxAttempts = new Bindable<int?>();
[Cached]
public readonly Bindable<RoomAvailability> Availability = new Bindable<RoomAvailability>();
[Cached] [Cached]
public readonly Bindable<QueueMode> QueueMode = new Bindable<QueueMode>(); public readonly Bindable<QueueMode> QueueMode = new Bindable<QueueMode>();
@ -241,7 +250,7 @@ namespace osu.Game.Online.Rooms
ChannelId.Value = other.ChannelId.Value; ChannelId.Value = other.ChannelId.Value;
Status = other.Status; Status = other.Status;
Availability.Value = other.Availability.Value; Availability = other.Availability;
HasPassword.Value = other.HasPassword.Value; HasPassword.Value = other.HasPassword.Value;
Type = other.Type; Type = other.Type;
MaxParticipants.Value = other.MaxParticipants.Value; MaxParticipants.Value = other.MaxParticipants.Value;

View File

@ -46,9 +46,6 @@ namespace osu.Game.Screens.OnlinePlay
[Resolved(typeof(Room))] [Resolved(typeof(Room))]
protected Bindable<DateTimeOffset?> EndDate { get; private set; } = null!; protected Bindable<DateTimeOffset?> EndDate { get; private set; } = null!;
[Resolved(typeof(Room))]
protected Bindable<RoomAvailability> Availability { get; private set; } = null!;
[Resolved(typeof(Room))] [Resolved(typeof(Room))]
public Bindable<string> Password { get; private set; } = null!; public Bindable<string> Password { get; private set; } = null!;

View File

@ -316,7 +316,6 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
loadingLayer = new LoadingLayer(true) loadingLayer = new LoadingLayer(true)
}; };
Availability.BindValueChanged(availability => AvailabilityPicker.Current.Value = availability.NewValue, true);
MaxParticipants.BindValueChanged(count => MaxParticipantsField.Text = count.NewValue?.ToString(), true); MaxParticipants.BindValueChanged(count => MaxParticipantsField.Text = count.NewValue?.ToString(), true);
MaxAttempts.BindValueChanged(count => MaxAttemptsField.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); 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; room.PropertyChanged += onRoomPropertyChanged;
updateRoomName(); updateRoomName();
updateRoomAvailability();
} }
private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e) private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e)
{ {
if (e.PropertyName == nameof(Room.Name)) switch (e.PropertyName)
updateRoomName(); {
case nameof(Room.Name):
updateRoomName();
break;
case nameof(Room.Availability):
updateRoomAvailability();
break;
}
} }
private void updateRoomName() private void updateRoomName()
=> NameField.Text = room.Name; => NameField.Text = room.Name;
private void updateRoomAvailability()
=> AvailabilityPicker.Current.Value = room.Availability;
private void populateDurations(ValueChangedEvent<APIUser> user) private void populateDurations(ValueChangedEvent<APIUser> user)
{ {
// roughly correct (see https://github.com/Humanizr/Humanizer/blob/18167e56c082449cc4fe805b8429e3127a7b7f93/readme.md?plain=1#L427) // 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(); hideError();
room.Name = NameField.Text; room.Name = NameField.Text;
Availability.Value = AvailabilityPicker.Current.Value; room.Availability = AvailabilityPicker.Current.Value;
if (int.TryParse(MaxParticipantsField.Text, out int max)) if (int.TryParse(MaxParticipantsField.Text, out int max))
MaxParticipants.Value = max; MaxParticipants.Value = max;