Add auto-skip setting

Default to auto skip
This commit is contained in:
Dan Balasescu 2022-08-31 19:49:04 +09:00
parent 8c202ce141
commit b5ec7d06dd
5 changed files with 31 additions and 4 deletions

View File

@ -265,8 +265,9 @@ namespace osu.Game.Online.Multiplayer
/// <param name="matchType">The type of the match, if any.</param> /// <param name="matchType">The type of the match, if any.</param>
/// <param name="queueMode">The new queue mode, if any.</param> /// <param name="queueMode">The new queue mode, if any.</param>
/// <param name="autoStartDuration">The new auto-start countdown duration, if any.</param> /// <param name="autoStartDuration">The new auto-start countdown duration, if any.</param>
/// <param name="autoSkip">The new auto-skip setting.</param>
public Task ChangeSettings(Optional<string> name = default, Optional<string> password = default, Optional<MatchType> matchType = default, Optional<QueueMode> queueMode = default, public Task ChangeSettings(Optional<string> name = default, Optional<string> password = default, Optional<MatchType> matchType = default, Optional<QueueMode> queueMode = default,
Optional<TimeSpan> autoStartDuration = default) Optional<TimeSpan> autoStartDuration = default, Optional<bool> autoSkip = default)
{ {
if (Room == null) if (Room == null)
throw new InvalidOperationException("Must be joined to a match to change settings."); throw new InvalidOperationException("Must be joined to a match to change settings.");
@ -278,6 +279,7 @@ namespace osu.Game.Online.Multiplayer
MatchType = matchType.GetOr(Room.Settings.MatchType), MatchType = matchType.GetOr(Room.Settings.MatchType),
QueueMode = queueMode.GetOr(Room.Settings.QueueMode), QueueMode = queueMode.GetOr(Room.Settings.QueueMode),
AutoStartDuration = autoStartDuration.GetOr(Room.Settings.AutoStartDuration), AutoStartDuration = autoStartDuration.GetOr(Room.Settings.AutoStartDuration),
AutoSkip = autoSkip.GetOr(Room.Settings.AutoSkip)
}); });
} }
@ -739,6 +741,7 @@ namespace osu.Game.Online.Multiplayer
APIRoom.QueueMode.Value = Room.Settings.QueueMode; APIRoom.QueueMode.Value = Room.Settings.QueueMode;
APIRoom.AutoStartDuration.Value = Room.Settings.AutoStartDuration; APIRoom.AutoStartDuration.Value = Room.Settings.AutoStartDuration;
APIRoom.CurrentPlaylistItem.Value = APIRoom.Playlist.Single(item => item.ID == settings.PlaylistItemId); APIRoom.CurrentPlaylistItem.Value = APIRoom.Playlist.Single(item => item.ID == settings.PlaylistItemId);
APIRoom.AutoSkip.Value = Room.Settings.AutoSkip;
RoomUpdated?.Invoke(); RoomUpdated?.Invoke();
} }

View File

@ -29,6 +29,9 @@ namespace osu.Game.Online.Multiplayer
[Key(5)] [Key(5)]
public TimeSpan AutoStartDuration { get; set; } public TimeSpan AutoStartDuration { get; set; }
[Key(6)]
public bool AutoSkip { get; set; }
[IgnoreMember] [IgnoreMember]
public bool AutoStartEnabled => AutoStartDuration != TimeSpan.Zero; public bool AutoStartEnabled => AutoStartDuration != TimeSpan.Zero;
@ -42,7 +45,8 @@ namespace osu.Game.Online.Multiplayer
&& PlaylistItemId == other.PlaylistItemId && PlaylistItemId == other.PlaylistItemId
&& MatchType == other.MatchType && MatchType == other.MatchType
&& QueueMode == other.QueueMode && QueueMode == other.QueueMode
&& AutoStartDuration == other.AutoStartDuration; && AutoStartDuration == other.AutoStartDuration
&& AutoSkip == other.AutoSkip;
} }
public override string ToString() => $"Name:{Name}" public override string ToString() => $"Name:{Name}"
@ -50,6 +54,7 @@ namespace osu.Game.Online.Multiplayer
+ $" Type:{MatchType}" + $" Type:{MatchType}"
+ $" Item:{PlaylistItemId}" + $" Item:{PlaylistItemId}"
+ $" Queue:{QueueMode}" + $" Queue:{QueueMode}"
+ $" Start:{AutoStartDuration}"; + $" Start:{AutoStartDuration}"
+ $" AutoSkip:{AutoSkip}";
} }
} }

View File

@ -159,6 +159,10 @@ namespace osu.Game.Online.Rooms
set => MaxAttempts.Value = value; set => MaxAttempts.Value = value;
} }
[Cached]
[JsonProperty("auto_skip")]
public readonly Bindable<bool> AutoSkip = new Bindable<bool>(true);
public Room() public Room()
{ {
Password.BindValueChanged(p => HasPassword.Value = !string.IsNullOrEmpty(p.NewValue)); Password.BindValueChanged(p => HasPassword.Value = !string.IsNullOrEmpty(p.NewValue));
@ -195,6 +199,7 @@ namespace osu.Game.Online.Rooms
DifficultyRange.Value = other.DifficultyRange.Value; DifficultyRange.Value = other.DifficultyRange.Value;
PlaylistItemStats.Value = other.PlaylistItemStats.Value; PlaylistItemStats.Value = other.PlaylistItemStats.Value;
CurrentPlaylistItem.Value = other.CurrentPlaylistItem.Value; CurrentPlaylistItem.Value = other.CurrentPlaylistItem.Value;
AutoSkip.Value = other.AutoSkip.Value;
if (EndDate.Value != null && DateTimeOffset.Now >= EndDate.Value) if (EndDate.Value != null && DateTimeOffset.Now >= EndDate.Value)
Status.Value = new RoomStatusEnded(); Status.Value = new RoomStatusEnded();

View File

@ -63,6 +63,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
public MatchTypePicker TypePicker; public MatchTypePicker TypePicker;
public OsuEnumDropdown<QueueMode> QueueModeDropdown; public OsuEnumDropdown<QueueMode> QueueModeDropdown;
public OsuTextBox PasswordTextBox; public OsuTextBox PasswordTextBox;
public OsuCheckbox AutoSkipCheckbox;
public TriangleButton ApplyButton; public TriangleButton ApplyButton;
public OsuSpriteText ErrorText; public OsuSpriteText ErrorText;
@ -249,6 +250,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
LengthLimit = 255, LengthLimit = 255,
}, },
}, },
new Section("Other")
{
Child = AutoSkipCheckbox = new OsuCheckbox
{
LabelText = "Automatically skip the beatmap intro"
}
}
} }
} }
}, },
@ -343,6 +351,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
Password.BindValueChanged(password => PasswordTextBox.Text = password.NewValue ?? string.Empty, true); Password.BindValueChanged(password => PasswordTextBox.Text = password.NewValue ?? string.Empty, true);
QueueMode.BindValueChanged(mode => QueueModeDropdown.Current.Value = mode.NewValue, true); QueueMode.BindValueChanged(mode => QueueModeDropdown.Current.Value = mode.NewValue, true);
AutoStartDuration.BindValueChanged(duration => startModeDropdown.Current.Value = (StartMode)(int)duration.NewValue.TotalSeconds, 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.BindTo(ongoingOperationTracker.InProgress);
operationInProgress.BindValueChanged(v => operationInProgress.BindValueChanged(v =>
@ -390,7 +399,8 @@ 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: autoStartDuration,
autoSkip: AutoSkipCheckbox.Current.Value)
.ContinueWith(t => Schedule(() => .ContinueWith(t => Schedule(() =>
{ {
if (t.IsCompletedSuccessfully) if (t.IsCompletedSuccessfully)
@ -406,6 +416,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
room.Password.Value = PasswordTextBox.Current.Value; room.Password.Value = PasswordTextBox.Current.Value;
room.QueueMode.Value = QueueModeDropdown.Current.Value; room.QueueMode.Value = QueueModeDropdown.Current.Value;
room.AutoStartDuration.Value = autoStartDuration; room.AutoStartDuration.Value = autoStartDuration;
room.AutoSkip.Value = AutoSkipCheckbox.Current.Value;
if (int.TryParse(MaxParticipantsField.Text, out int max)) if (int.TryParse(MaxParticipantsField.Text, out int max))
room.MaxParticipants.Value = max; room.MaxParticipants.Value = max;

View File

@ -86,6 +86,9 @@ namespace osu.Game.Screens.OnlinePlay
[Resolved(typeof(Room))] [Resolved(typeof(Room))]
protected Bindable<TimeSpan> AutoStartDuration { get; private set; } protected Bindable<TimeSpan> AutoStartDuration { get; private set; }
[Resolved(typeof(Room))]
protected Bindable<bool> AutoSkip { get; private set; }
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
private IBindable<PlaylistItem> subScreenSelectedItem { get; set; } private IBindable<PlaylistItem> subScreenSelectedItem { get; set; }