mirror of
https://github.com/ppy/osu.git
synced 2025-02-14 17:45:20 +08:00
Make Room.AutoStartDuration
non-bindable
This commit is contained in:
parent
b8bae30b66
commit
89de4f0f87
@ -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;
|
||||
|
||||
|
@ -131,6 +131,15 @@ namespace osu.Game.Online.Rooms
|
||||
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>
|
||||
/// Represents the current item selected within the room.
|
||||
/// </summary>
|
||||
@ -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<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]
|
||||
[JsonProperty("current_user_score")]
|
||||
public readonly Bindable<PlaylistAggregateScore> UserScore = new Bindable<PlaylistAggregateScore>();
|
||||
@ -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;
|
||||
|
@ -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))
|
||||
|
@ -41,8 +41,5 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
|
||||
[Resolved(typeof(Room))]
|
||||
protected Bindable<TimeSpan?> Duration { get; private set; } = null!;
|
||||
|
||||
[Resolved(typeof(Room))]
|
||||
protected Bindable<TimeSpan> AutoStartDuration { get; private set; } = null!;
|
||||
}
|
||||
}
|
||||
|
@ -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 },
|
||||
|
Loading…
Reference in New Issue
Block a user