diff --git a/osu.Game/Online/Multiplayer/MultiplayerClient.cs b/osu.Game/Online/Multiplayer/MultiplayerClient.cs index 3a9f728b41..6a7d460922 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerClient.cs @@ -846,7 +846,7 @@ namespace osu.Game.Online.Multiplayer APIRoom.Status = string.IsNullOrEmpty(Room.Settings.Password) ? new RoomStatusOpen() : new RoomStatusOpenPrivate(); APIRoom.Type = Room.Settings.MatchType; APIRoom.QueueMode = Room.Settings.QueueMode; - APIRoom.AutoStartDuration.Value = Room.Settings.AutoStartDuration; + APIRoom.AutoStartDuration = Room.Settings.AutoStartDuration; APIRoom.CurrentPlaylistItem = APIRoom.Playlist.Single(item => item.ID == settings.PlaylistItemId); APIRoom.AutoSkip = Room.Settings.AutoSkip; diff --git a/osu.Game/Online/Rooms/Room.cs b/osu.Game/Online/Rooms/Room.cs index b63ebd107d..61f944a728 100644 --- a/osu.Game/Online/Rooms/Room.cs +++ b/osu.Game/Online/Rooms/Room.cs @@ -131,6 +131,15 @@ namespace osu.Game.Online.Rooms set => SetField(ref autoSkip, value); } + /// + /// The amount of time before the match is automatically started. Only valid for multiplayer rooms. + /// + public TimeSpan AutoStartDuration + { + get => TimeSpan.FromSeconds(autoStartDuration); + set => SetField(ref autoStartDuration, (ushort)value.TotalSeconds); + } + /// /// Represents the current item selected within the room. /// @@ -197,6 +206,9 @@ namespace osu.Game.Online.Rooms [JsonProperty("auto_skip")] private bool autoSkip; + [JsonProperty("auto_start_duration")] + private ushort autoStartDuration; + [JsonProperty("current_playlist_item")] private PlaylistItem? currentPlaylistItem; @@ -225,16 +237,6 @@ namespace osu.Game.Online.Rooms [Cached] public readonly Bindable MaxAttempts = new Bindable(); - [Cached] - public readonly Bindable AutoStartDuration = new Bindable(); - - [JsonProperty("auto_start_duration")] - private ushort autoStartDuration - { - get => (ushort)AutoStartDuration.Value.TotalSeconds; - set => AutoStartDuration.Value = TimeSpan.FromSeconds(value); - } - [Cached] [JsonProperty("current_user_score")] public readonly Bindable UserScore = new Bindable(); @@ -308,7 +310,7 @@ namespace osu.Game.Online.Rooms EndDate.Value = other.EndDate.Value; UserScore.Value = other.UserScore.Value; QueueMode = other.QueueMode; - AutoStartDuration.Value = other.AutoStartDuration.Value; + AutoStartDuration = other.AutoStartDuration; DifficultyRange.Value = other.DifficultyRange.Value; PlaylistItemStats.Value = other.PlaylistItemStats.Value; CurrentPlaylistItem = other.CurrentPlaylistItem; diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/MultiplayerMatchSettingsOverlay.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/MultiplayerMatchSettingsOverlay.cs index 141bddc4d4..f883fde600 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/MultiplayerMatchSettingsOverlay.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/MultiplayerMatchSettingsOverlay.cs @@ -350,7 +350,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match }; TypePicker.Current.BindValueChanged(type => typeLabel.Text = type.NewValue.GetLocalisableDescription(), true); - AutoStartDuration.BindValueChanged(duration => startModeDropdown.Current.Value = (StartMode)(int)duration.NewValue.TotalSeconds, true); operationInProgress.BindTo(ongoingOperationTracker.InProgress); operationInProgress.BindValueChanged(v => @@ -377,6 +376,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match updateRoomPassword(); updateRoomAutoSkip(); updateRoomMaxParticipants(); + updateRoomAutoStartDuration(); } private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e) @@ -406,6 +406,10 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match case nameof(Room.MaxParticipants): updateRoomMaxParticipants(); break; + + case nameof(Room.AutoStartDuration): + updateRoomAutoStartDuration(); + break; } } @@ -427,6 +431,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match private void updateRoomMaxParticipants() => MaxParticipantsField.Text = room.MaxParticipants?.ToString(); + private void updateRoomAutoStartDuration() + => typeLabel.Text = room.AutoStartDuration.GetLocalisableDescription(); + protected override void Update() { base.Update(); @@ -445,8 +452,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match Debug.Assert(applyingSettingsOperation == null); applyingSettingsOperation = ongoingOperationTracker.BeginOperation(); - TimeSpan autoStartDuration = TimeSpan.FromSeconds((int)startModeDropdown.Current.Value); - // If the client is already in a room, update via the client. // Otherwise, update the room directly in preparation for it to be submitted to the API on match creation. if (client.Room != null) @@ -456,7 +461,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match password: PasswordTextBox.Text, matchType: TypePicker.Current.Value, queueMode: QueueModeDropdown.Current.Value, - autoStartDuration: autoStartDuration, + autoStartDuration: TimeSpan.FromSeconds((int)startModeDropdown.Current.Value), autoSkip: AutoSkipCheckbox.Current.Value) .ContinueWith(t => Schedule(() => { @@ -472,7 +477,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match room.Type = TypePicker.Current.Value; room.Password = PasswordTextBox.Current.Value; room.QueueMode = QueueModeDropdown.Current.Value; - room.AutoStartDuration.Value = autoStartDuration; + room.AutoStartDuration = TimeSpan.FromSeconds((int)startModeDropdown.Current.Value); room.AutoSkip = AutoSkipCheckbox.Current.Value; if (int.TryParse(MaxParticipantsField.Text, out int max)) diff --git a/osu.Game/Screens/OnlinePlay/OnlinePlayComposite.cs b/osu.Game/Screens/OnlinePlay/OnlinePlayComposite.cs index 7623cbabbd..70418d1a7e 100644 --- a/osu.Game/Screens/OnlinePlay/OnlinePlayComposite.cs +++ b/osu.Game/Screens/OnlinePlay/OnlinePlayComposite.cs @@ -41,8 +41,5 @@ namespace osu.Game.Screens.OnlinePlay [Resolved(typeof(Room))] protected Bindable Duration { get; private set; } = null!; - - [Resolved(typeof(Room))] - protected Bindable AutoStartDuration { get; private set; } = null!; } } diff --git a/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs b/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs index dcb6f2503d..29e62cb590 100644 --- a/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs +++ b/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs @@ -234,7 +234,7 @@ namespace osu.Game.Tests.Visual.Multiplayer MatchType = ServerAPIRoom.Type, Password = password ?? string.Empty, QueueMode = ServerAPIRoom.QueueMode, - AutoStartDuration = ServerAPIRoom.AutoStartDuration.Value + AutoStartDuration = ServerAPIRoom.AutoStartDuration }, Playlist = ServerAPIRoom.Playlist.Select(CreateMultiplayerPlaylistItem).ToList(), Users = { localUser },