1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-21 06:42:54 +08:00

Disable setting apply button for duration of operation

This commit is contained in:
Bartłomiej Dach 2020-12-28 21:44:58 +01:00
parent af66e45311
commit 6dc0f6af50

View File

@ -68,6 +68,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
[Resolved] [Resolved]
private Bindable<RulesetInfo> ruleset { get; set; } private Bindable<RulesetInfo> ruleset { get; set; }
private readonly OngoingOperationTracker applyingSettingsTracker = new OngoingOperationTracker();
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
@ -274,13 +276,21 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
Type.BindValueChanged(type => TypePicker.Current.Value = type.NewValue, true); Type.BindValueChanged(type => TypePicker.Current.Value = type.NewValue, true);
MaxParticipants.BindValueChanged(count => MaxParticipantsField.Text = count.NewValue?.ToString(), true); MaxParticipants.BindValueChanged(count => MaxParticipantsField.Text = count.NewValue?.ToString(), true);
RoomID.BindValueChanged(roomId => initialBeatmapControl.Alpha = roomId.NewValue == null ? 1 : 0, true); RoomID.BindValueChanged(roomId => initialBeatmapControl.Alpha = roomId.NewValue == null ? 1 : 0, true);
applyingSettingsTracker.InProgress.BindValueChanged(v =>
{
if (v.NewValue)
loadingLayer.Show();
else
loadingLayer.Hide();
});
} }
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
ApplyButton.Enabled.Value = Playlist.Count > 0 && NameField.Text.Length > 0; ApplyButton.Enabled.Value = Playlist.Count > 0 && NameField.Text.Length > 0 && !applyingSettingsTracker.InProgress.Value;
} }
private void apply() private void apply()
@ -289,7 +299,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
return; return;
hideError(); hideError();
loadingLayer.Show(); applyingSettingsTracker.BeginOperation();
// 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.
@ -322,7 +332,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
private void onSuccess(Room room) private void onSuccess(Room room)
{ {
loadingLayer.Hide(); applyingSettingsTracker.EndOperation();
SettingsApplied?.Invoke(); SettingsApplied?.Invoke();
} }
@ -330,8 +340,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
{ {
ErrorText.Text = text; ErrorText.Text = text;
ErrorText.FadeIn(50); ErrorText.FadeIn(50);
applyingSettingsTracker.EndOperation();
loadingLayer.Hide();
} }
} }