mirror of https://github.com/ppy/osu
Make `Room.Availability` non-bindable
This commit is contained in:
parent
5d4838a08b
commit
7e3e5208f0
|
@ -87,6 +87,15 @@ public RoomStatus Status
|
|||
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")]
|
||||
private long? roomId;
|
||||
|
||||
|
@ -110,6 +119,9 @@ public RoomStatus Status
|
|||
// Not serialised (see: GetRoomsRequest).
|
||||
private RoomStatus status = new RoomStatusOpen();
|
||||
|
||||
// Not yet serialised (not implemented).
|
||||
private RoomAvailability availability;
|
||||
|
||||
[Cached]
|
||||
[JsonProperty("playlist")]
|
||||
public readonly BindableList<PlaylistItem> Playlist = new BindableList<PlaylistItem>();
|
||||
|
@ -129,9 +141,6 @@ public RoomStatus Status
|
|||
[Cached]
|
||||
public readonly Bindable<int?> MaxAttempts = new Bindable<int?>();
|
||||
|
||||
[Cached]
|
||||
public readonly Bindable<RoomAvailability> Availability = new Bindable<RoomAvailability>();
|
||||
|
||||
[Cached]
|
||||
public readonly Bindable<QueueMode> QueueMode = new Bindable<QueueMode>();
|
||||
|
||||
|
@ -241,7 +250,7 @@ public void CopyFrom(Room other)
|
|||
|
||||
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;
|
||||
|
|
|
@ -46,9 +46,6 @@ public partial class OnlinePlayComposite : CompositeDrawable
|
|||
[Resolved(typeof(Room))]
|
||||
protected Bindable<DateTimeOffset?> EndDate { get; private set; } = null!;
|
||||
|
||||
[Resolved(typeof(Room))]
|
||||
protected Bindable<RoomAvailability> Availability { get; private set; } = null!;
|
||||
|
||||
[Resolved(typeof(Room))]
|
||||
public Bindable<string> Password { get; private set; } = null!;
|
||||
|
||||
|
|
|
@ -316,7 +316,6 @@ private void load(OverlayColourProvider colourProvider, OsuColour colours)
|
|||
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 @@ protected override void LoadComplete()
|
|||
room.PropertyChanged += onRoomPropertyChanged;
|
||||
|
||||
updateRoomName();
|
||||
updateRoomAvailability();
|
||||
}
|
||||
|
||||
private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(Room.Name))
|
||||
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<APIUser> user)
|
||||
{
|
||||
// roughly correct (see https://github.com/Humanizr/Humanizer/blob/18167e56c082449cc4fe805b8429e3127a7b7f93/readme.md?plain=1#L427)
|
||||
|
@ -405,7 +416,7 @@ private void apply()
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue