mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 02:02:53 +08:00
Add processing overlay to room creation process
This commit is contained in:
parent
2e5cd8b4e3
commit
0c384417f1
@ -76,7 +76,7 @@ namespace osu.Game.Tests.Visual
|
||||
public readonly BindableCollection<Room> Rooms = new BindableCollection<Room>();
|
||||
IBindableCollection<Room> IRoomManager.Rooms => Rooms;
|
||||
|
||||
public void CreateRoom(Room room, Action<string> onError = null) => Rooms.Add(room);
|
||||
public void CreateRoom(Room room, Action onSuccess = null, Action<string> onError = null) => Rooms.Add(room);
|
||||
|
||||
public void JoinRoom(Room room) => RoomJoined?.Invoke(room);
|
||||
|
||||
|
@ -140,13 +140,15 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
public IBindableCollection<Room> Rooms { get; } = null;
|
||||
|
||||
public void CreateRoom(Room room, Action<string> onError = null)
|
||||
public void CreateRoom(Room room, Action onSuccess = null, Action<string> onError = null)
|
||||
{
|
||||
if (CreateRequested == null)
|
||||
return;
|
||||
|
||||
if (!CreateRequested.Invoke(room))
|
||||
onError?.Invoke(FAILED_TEXT);
|
||||
else
|
||||
onSuccess?.Invoke();
|
||||
}
|
||||
|
||||
public void JoinRoom(Room room) => throw new NotImplementedException();
|
||||
|
@ -24,8 +24,9 @@ namespace osu.Game.Screens.Multi
|
||||
/// Creates a new <see cref="Room"/>.
|
||||
/// </summary>
|
||||
/// <param name="room">The <see cref="Room"/> to create.</param>
|
||||
/// <param name="onSuccess">An action to be invoked if the creation succeeds.</param>
|
||||
/// <param name="onError">An action to be invoked if an error occurred.</param>
|
||||
void CreateRoom(Room room, Action<string> onError = null);
|
||||
void CreateRoom(Room room, Action onSuccess = null, Action<string> onError = null);
|
||||
|
||||
/// <summary>
|
||||
/// Joins a <see cref="Room"/>.
|
||||
|
@ -39,6 +39,8 @@ namespace osu.Game.Screens.Multi.Match.Components
|
||||
|
||||
protected readonly OsuSpriteText ErrorText;
|
||||
|
||||
private readonly ProcessingOverlay processingOverlay;
|
||||
|
||||
private readonly Room room;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
@ -231,7 +233,8 @@ namespace osu.Game.Screens.Multi.Match.Components
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
processingOverlay = new ProcessingOverlay { Alpha = 0 }
|
||||
},
|
||||
};
|
||||
|
||||
@ -264,7 +267,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
||||
ApplyButton.Enabled.Value = hasValidSettings;
|
||||
}
|
||||
|
||||
private bool hasValidSettings => NameField.Text.Length > 0 && bindings.Playlist.Count > 0;
|
||||
private bool hasValidSettings => bindings.Room.RoomID.Value == null && NameField.Text.Length > 0 && bindings.Playlist.Count > 0;
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
@ -291,15 +294,21 @@ namespace osu.Game.Screens.Multi.Match.Components
|
||||
|
||||
bindings.Duration.Value = DurationField.Current.Value;
|
||||
|
||||
manager?.CreateRoom(room, showError);
|
||||
manager?.CreateRoom(room, onSuccess, onError);
|
||||
|
||||
processingOverlay.Show();
|
||||
}
|
||||
|
||||
private void hideError() => ErrorText.FadeOut(50);
|
||||
|
||||
private void showError(string text)
|
||||
private void onSuccess() => processingOverlay.Hide();
|
||||
|
||||
private void onError(string text)
|
||||
{
|
||||
ErrorText.Text = text;
|
||||
ErrorText.FadeIn(50);
|
||||
|
||||
processingOverlay.Hide();
|
||||
}
|
||||
|
||||
private class SettingsTextBox : OsuTextBox
|
||||
|
@ -48,7 +48,7 @@ namespace osu.Game.Screens.Multi
|
||||
PartRoom();
|
||||
}
|
||||
|
||||
public void CreateRoom(Room room, Action<string> onError = null)
|
||||
public void CreateRoom(Room room, Action onSuccess = null, Action<string> onError = null)
|
||||
{
|
||||
room.Host.Value = api.LocalUser;
|
||||
|
||||
@ -57,6 +57,8 @@ namespace osu.Game.Screens.Multi
|
||||
{
|
||||
update(room, result);
|
||||
addRoom(room);
|
||||
|
||||
onSuccess?.Invoke();
|
||||
};
|
||||
|
||||
req.Failure += exception =>
|
||||
|
Loading…
Reference in New Issue
Block a user