mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 22:22:55 +08:00
Disable setting apply button for duration of operation
This commit is contained in:
parent
af66e45311
commit
6dc0f6af50
@ -68,6 +68,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
[Resolved]
|
||||
private Bindable<RulesetInfo> ruleset { get; set; }
|
||||
|
||||
private readonly OngoingOperationTracker applyingSettingsTracker = new OngoingOperationTracker();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
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);
|
||||
MaxParticipants.BindValueChanged(count => MaxParticipantsField.Text = count.NewValue?.ToString(), 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()
|
||||
{
|
||||
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()
|
||||
@ -289,7 +299,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
return;
|
||||
|
||||
hideError();
|
||||
loadingLayer.Show();
|
||||
applyingSettingsTracker.BeginOperation();
|
||||
|
||||
// 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.
|
||||
@ -322,7 +332,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
|
||||
private void onSuccess(Room room)
|
||||
{
|
||||
loadingLayer.Hide();
|
||||
applyingSettingsTracker.EndOperation();
|
||||
SettingsApplied?.Invoke();
|
||||
}
|
||||
|
||||
@ -330,8 +340,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
{
|
||||
ErrorText.Text = text;
|
||||
ErrorText.FadeIn(50);
|
||||
|
||||
loadingLayer.Hide();
|
||||
applyingSettingsTracker.EndOperation();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user