From f001cce24adcea7dfce18d8a1ce41bd8f494f660 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 13 Nov 2024 19:15:29 +0900 Subject: [PATCH] Make `Room.AutoSkip` non-bindable --- .../Online/Multiplayer/MultiplayerClient.cs | 2 +- osu.Game/Online/Rooms/Room.cs | 19 +++++++++++++------ .../Match/MultiplayerMatchSettingsOverlay.cs | 11 +++++++++-- .../Multiplayer/MultiplayerPlayer.cs | 4 ++-- .../Screens/OnlinePlay/OnlinePlayComposite.cs | 3 --- 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/osu.Game/Online/Multiplayer/MultiplayerClient.cs b/osu.Game/Online/Multiplayer/MultiplayerClient.cs index db35f228fe..a9c0108661 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerClient.cs @@ -848,7 +848,7 @@ private void updateLocalRoomSettings(MultiplayerRoomSettings settings) APIRoom.QueueMode = Room.Settings.QueueMode; APIRoom.AutoStartDuration.Value = Room.Settings.AutoStartDuration; APIRoom.CurrentPlaylistItem = APIRoom.Playlist.Single(item => item.ID == settings.PlaylistItemId); - APIRoom.AutoSkip.Value = Room.Settings.AutoSkip; + APIRoom.AutoSkip = Room.Settings.AutoSkip; RoomUpdated?.Invoke(); } diff --git a/osu.Game/Online/Rooms/Room.cs b/osu.Game/Online/Rooms/Room.cs index 3f50611372..b945d1b886 100644 --- a/osu.Game/Online/Rooms/Room.cs +++ b/osu.Game/Online/Rooms/Room.cs @@ -104,6 +104,15 @@ public QueueMode QueueMode set => SetField(ref queueMode, value); } + /// + /// Whether to automatically skip map intros. Only valid for multiplayer rooms. + /// + public bool AutoSkip + { + get => autoSkip; + set => SetField(ref autoSkip, value); + } + /// /// Represents the current item selected within the room. /// @@ -134,7 +143,6 @@ public RoomAvailability Availability set => SetField(ref availability, value); } - [JsonProperty("id")] private long? roomId; @@ -162,6 +170,9 @@ public RoomAvailability Availability [JsonProperty("queue_mode")] private QueueMode queueMode; + [JsonProperty("auto_skip")] + private bool autoSkip; + [JsonProperty("current_playlist_item")] private PlaylistItem? currentPlaylistItem; @@ -253,10 +264,6 @@ private int? maxAttempts set => MaxAttempts.Value = value; } - [Cached] - [JsonProperty("auto_skip")] - public readonly Bindable AutoSkip = new Bindable(); - /// /// Copies values from another into this one. /// @@ -288,7 +295,7 @@ public void CopyFrom(Room other) DifficultyRange.Value = other.DifficultyRange.Value; PlaylistItemStats.Value = other.PlaylistItemStats.Value; CurrentPlaylistItem = other.CurrentPlaylistItem; - AutoSkip.Value = other.AutoSkip.Value; + AutoSkip = other.AutoSkip; other.RemoveExpiredPlaylistItems(); diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/MultiplayerMatchSettingsOverlay.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/MultiplayerMatchSettingsOverlay.cs index a3441fbd09..62d6459487 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/MultiplayerMatchSettingsOverlay.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/MultiplayerMatchSettingsOverlay.cs @@ -352,7 +352,6 @@ private void load(OverlayColourProvider colourProvider, OsuColour colours) TypePicker.Current.BindValueChanged(type => typeLabel.Text = type.NewValue.GetLocalisableDescription(), true); MaxParticipants.BindValueChanged(count => MaxParticipantsField.Text = count.NewValue?.ToString(), true); AutoStartDuration.BindValueChanged(duration => startModeDropdown.Current.Value = (StartMode)(int)duration.NewValue.TotalSeconds, true); - AutoSkip.BindValueChanged(autoSkip => AutoSkipCheckbox.Current.Value = autoSkip.NewValue, true); operationInProgress.BindTo(ongoingOperationTracker.InProgress); operationInProgress.BindValueChanged(v => @@ -377,6 +376,7 @@ protected override void LoadComplete() updateRoomType(); updateRoomQueueMode(); updateRoomPassword(); + updateRoomAutoSkip(); } private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e) @@ -398,6 +398,10 @@ private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e) case nameof(Room.Password): updateRoomPassword(); break; + + case nameof(Room.AutoSkip): + updateRoomAutoSkip(); + break; } } @@ -413,6 +417,9 @@ private void updateRoomQueueMode() private void updateRoomPassword() => PasswordTextBox.Text = room.Password ?? string.Empty; + private void updateRoomAutoSkip() + => AutoSkipCheckbox.Current.Value = room.AutoSkip; + protected override void Update() { base.Update(); @@ -459,7 +466,7 @@ private void apply() room.Password = PasswordTextBox.Current.Value; room.QueueMode = QueueModeDropdown.Current.Value; room.AutoStartDuration.Value = autoStartDuration; - room.AutoSkip.Value = AutoSkipCheckbox.Current.Value; + room.AutoSkip = AutoSkipCheckbox.Current.Value; if (int.TryParse(MaxParticipantsField.Text, out int max)) room.MaxParticipants.Value = max; diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPlayer.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPlayer.cs index d444af2fd3..c058699b0e 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPlayer.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPlayer.cs @@ -50,8 +50,8 @@ public MultiplayerPlayer(Room room, PlaylistItem playlistItem, MultiplayerRoomUs AllowPause = false, AllowRestart = false, AllowFailAnimation = false, - AllowSkipping = room.AutoSkip.Value, - AutomaticallySkipIntro = room.AutoSkip.Value, + AllowSkipping = room.AutoSkip, + AutomaticallySkipIntro = room.AutoSkip, AlwaysShowLeaderboard = true, }) { diff --git a/osu.Game/Screens/OnlinePlay/OnlinePlayComposite.cs b/osu.Game/Screens/OnlinePlay/OnlinePlayComposite.cs index 93abc23e55..2b1c9cf00a 100644 --- a/osu.Game/Screens/OnlinePlay/OnlinePlayComposite.cs +++ b/osu.Game/Screens/OnlinePlay/OnlinePlayComposite.cs @@ -50,8 +50,5 @@ public partial class OnlinePlayComposite : CompositeDrawable [Resolved(typeof(Room))] protected Bindable AutoStartDuration { get; private set; } = null!; - - [Resolved(typeof(Room))] - protected Bindable AutoSkip { get; private set; } = null!; } }