1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 12:03:21 +08:00

Make Room.AutoStartDuration non-bindable

This commit is contained in:
Dan Balasescu 2024-11-13 19:53:21 +09:00
parent b8bae30b66
commit 89de4f0f87
No known key found for this signature in database
5 changed files with 25 additions and 21 deletions

View File

@ -846,7 +846,7 @@ namespace osu.Game.Online.Multiplayer
APIRoom.Status = string.IsNullOrEmpty(Room.Settings.Password) ? new RoomStatusOpen() : new RoomStatusOpenPrivate(); APIRoom.Status = string.IsNullOrEmpty(Room.Settings.Password) ? new RoomStatusOpen() : new RoomStatusOpenPrivate();
APIRoom.Type = Room.Settings.MatchType; APIRoom.Type = Room.Settings.MatchType;
APIRoom.QueueMode = Room.Settings.QueueMode; 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.CurrentPlaylistItem = APIRoom.Playlist.Single(item => item.ID == settings.PlaylistItemId);
APIRoom.AutoSkip = Room.Settings.AutoSkip; APIRoom.AutoSkip = Room.Settings.AutoSkip;

View File

@ -131,6 +131,15 @@ namespace osu.Game.Online.Rooms
set => SetField(ref autoSkip, value); set => SetField(ref autoSkip, value);
} }
/// <summary>
/// The amount of time before the match is automatically started. Only valid for multiplayer rooms.
/// </summary>
public TimeSpan AutoStartDuration
{
get => TimeSpan.FromSeconds(autoStartDuration);
set => SetField(ref autoStartDuration, (ushort)value.TotalSeconds);
}
/// <summary> /// <summary>
/// Represents the current item selected within the room. /// Represents the current item selected within the room.
/// </summary> /// </summary>
@ -197,6 +206,9 @@ namespace osu.Game.Online.Rooms
[JsonProperty("auto_skip")] [JsonProperty("auto_skip")]
private bool autoSkip; private bool autoSkip;
[JsonProperty("auto_start_duration")]
private ushort autoStartDuration;
[JsonProperty("current_playlist_item")] [JsonProperty("current_playlist_item")]
private PlaylistItem? currentPlaylistItem; private PlaylistItem? currentPlaylistItem;
@ -225,16 +237,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<TimeSpan> AutoStartDuration = new Bindable<TimeSpan>();
[JsonProperty("auto_start_duration")]
private ushort autoStartDuration
{
get => (ushort)AutoStartDuration.Value.TotalSeconds;
set => AutoStartDuration.Value = TimeSpan.FromSeconds(value);
}
[Cached] [Cached]
[JsonProperty("current_user_score")] [JsonProperty("current_user_score")]
public readonly Bindable<PlaylistAggregateScore> UserScore = new Bindable<PlaylistAggregateScore>(); public readonly Bindable<PlaylistAggregateScore> UserScore = new Bindable<PlaylistAggregateScore>();
@ -308,7 +310,7 @@ namespace osu.Game.Online.Rooms
EndDate.Value = other.EndDate.Value; EndDate.Value = other.EndDate.Value;
UserScore.Value = other.UserScore.Value; UserScore.Value = other.UserScore.Value;
QueueMode = other.QueueMode; QueueMode = other.QueueMode;
AutoStartDuration.Value = other.AutoStartDuration.Value; AutoStartDuration = other.AutoStartDuration;
DifficultyRange.Value = other.DifficultyRange.Value; DifficultyRange.Value = other.DifficultyRange.Value;
PlaylistItemStats.Value = other.PlaylistItemStats.Value; PlaylistItemStats.Value = other.PlaylistItemStats.Value;
CurrentPlaylistItem = other.CurrentPlaylistItem; CurrentPlaylistItem = other.CurrentPlaylistItem;

View File

@ -350,7 +350,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
}; };
TypePicker.Current.BindValueChanged(type => typeLabel.Text = type.NewValue.GetLocalisableDescription(), true); 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.BindTo(ongoingOperationTracker.InProgress);
operationInProgress.BindValueChanged(v => operationInProgress.BindValueChanged(v =>
@ -377,6 +376,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
updateRoomPassword(); updateRoomPassword();
updateRoomAutoSkip(); updateRoomAutoSkip();
updateRoomMaxParticipants(); updateRoomMaxParticipants();
updateRoomAutoStartDuration();
} }
private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e) private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e)
@ -406,6 +406,10 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
case nameof(Room.MaxParticipants): case nameof(Room.MaxParticipants):
updateRoomMaxParticipants(); updateRoomMaxParticipants();
break; break;
case nameof(Room.AutoStartDuration):
updateRoomAutoStartDuration();
break;
} }
} }
@ -427,6 +431,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
private void updateRoomMaxParticipants() private void updateRoomMaxParticipants()
=> MaxParticipantsField.Text = room.MaxParticipants?.ToString(); => MaxParticipantsField.Text = room.MaxParticipants?.ToString();
private void updateRoomAutoStartDuration()
=> typeLabel.Text = room.AutoStartDuration.GetLocalisableDescription();
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
@ -445,8 +452,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
Debug.Assert(applyingSettingsOperation == null); Debug.Assert(applyingSettingsOperation == null);
applyingSettingsOperation = ongoingOperationTracker.BeginOperation(); applyingSettingsOperation = ongoingOperationTracker.BeginOperation();
TimeSpan autoStartDuration = TimeSpan.FromSeconds((int)startModeDropdown.Current.Value);
// If the client is already in a room, update via the client. // 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. // Otherwise, update the room directly in preparation for it to be submitted to the API on match creation.
if (client.Room != null) if (client.Room != null)
@ -456,7 +461,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
password: PasswordTextBox.Text, password: PasswordTextBox.Text,
matchType: TypePicker.Current.Value, matchType: TypePicker.Current.Value,
queueMode: QueueModeDropdown.Current.Value, queueMode: QueueModeDropdown.Current.Value,
autoStartDuration: autoStartDuration, autoStartDuration: TimeSpan.FromSeconds((int)startModeDropdown.Current.Value),
autoSkip: AutoSkipCheckbox.Current.Value) autoSkip: AutoSkipCheckbox.Current.Value)
.ContinueWith(t => Schedule(() => .ContinueWith(t => Schedule(() =>
{ {
@ -472,7 +477,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
room.Type = TypePicker.Current.Value; room.Type = TypePicker.Current.Value;
room.Password = PasswordTextBox.Current.Value; room.Password = PasswordTextBox.Current.Value;
room.QueueMode = QueueModeDropdown.Current.Value; room.QueueMode = QueueModeDropdown.Current.Value;
room.AutoStartDuration.Value = autoStartDuration; room.AutoStartDuration = TimeSpan.FromSeconds((int)startModeDropdown.Current.Value);
room.AutoSkip = AutoSkipCheckbox.Current.Value; room.AutoSkip = AutoSkipCheckbox.Current.Value;
if (int.TryParse(MaxParticipantsField.Text, out int max)) if (int.TryParse(MaxParticipantsField.Text, out int max))

View File

@ -41,8 +41,5 @@ namespace osu.Game.Screens.OnlinePlay
[Resolved(typeof(Room))] [Resolved(typeof(Room))]
protected Bindable<TimeSpan?> Duration { get; private set; } = null!; protected Bindable<TimeSpan?> Duration { get; private set; } = null!;
[Resolved(typeof(Room))]
protected Bindable<TimeSpan> AutoStartDuration { get; private set; } = null!;
} }
} }

View File

@ -234,7 +234,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
MatchType = ServerAPIRoom.Type, MatchType = ServerAPIRoom.Type,
Password = password ?? string.Empty, Password = password ?? string.Empty,
QueueMode = ServerAPIRoom.QueueMode, QueueMode = ServerAPIRoom.QueueMode,
AutoStartDuration = ServerAPIRoom.AutoStartDuration.Value AutoStartDuration = ServerAPIRoom.AutoStartDuration
}, },
Playlist = ServerAPIRoom.Playlist.Select(CreateMultiplayerPlaylistItem).ToList(), Playlist = ServerAPIRoom.Playlist.Select(CreateMultiplayerPlaylistItem).ToList(),
Users = { localUser }, Users = { localUser },