mirror of
https://github.com/ppy/osu
synced 2024-12-14 02:46:27 +00:00
Merge pull request #9217 from smoogipoo/multi-room-load-spinner
Show a loading spinner on multiplayer lounge loads
This commit is contained in:
commit
e06e9a8bc5
@ -141,6 +141,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
}
|
||||
|
||||
public readonly BindableList<Room> Rooms = new BindableList<Room>();
|
||||
|
||||
public Bindable<bool> InitialRoomsReceived { get; } = new Bindable<bool>(true);
|
||||
|
||||
IBindableList<Room> IRoomManager.Rooms => Rooms;
|
||||
|
||||
public void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null) => Rooms.Add(room);
|
||||
|
@ -133,6 +133,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
remove { }
|
||||
}
|
||||
|
||||
public Bindable<bool> InitialRoomsReceived { get; } = new Bindable<bool>(true);
|
||||
|
||||
public IBindableList<Room> Rooms { get; } = null;
|
||||
|
||||
public void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
||||
|
@ -140,6 +140,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
remove => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Bindable<bool> InitialRoomsReceived { get; } = new Bindable<bool>(true);
|
||||
|
||||
public IBindableList<Room> Rooms { get; } = new BindableList<Room>();
|
||||
|
||||
public void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
||||
|
@ -14,6 +14,11 @@ namespace osu.Game.Screens.Multi
|
||||
/// </summary>
|
||||
event Action RoomsUpdated;
|
||||
|
||||
/// <summary>
|
||||
/// Whether an initial listing of rooms has been received.
|
||||
/// </summary>
|
||||
Bindable<bool> InitialRoomsReceived { get; }
|
||||
|
||||
/// <summary>
|
||||
/// All the active <see cref="Room"/>s.
|
||||
/// </summary>
|
||||
|
@ -22,12 +22,16 @@ namespace osu.Game.Screens.Multi.Lounge
|
||||
|
||||
protected readonly FilterControl Filter;
|
||||
|
||||
private readonly Bindable<bool> initialRoomsReceived = new Bindable<bool>();
|
||||
|
||||
private readonly Container content;
|
||||
private readonly LoadingLayer loadingLayer;
|
||||
|
||||
[Resolved]
|
||||
private Bindable<Room> selectedRoom { get; set; }
|
||||
|
||||
private bool joiningRoom;
|
||||
|
||||
public LoungeSubScreen()
|
||||
{
|
||||
SearchContainer searchContainer;
|
||||
@ -73,6 +77,14 @@ namespace osu.Game.Screens.Multi.Lounge
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
initialRoomsReceived.BindTo(RoomManager.InitialRoomsReceived);
|
||||
initialRoomsReceived.BindValueChanged(onInitialRoomsReceivedChanged, true);
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
@ -126,12 +138,29 @@ namespace osu.Game.Screens.Multi.Lounge
|
||||
|
||||
private void joinRequested(Room room)
|
||||
{
|
||||
loadingLayer.Show();
|
||||
joiningRoom = true;
|
||||
updateLoadingLayer();
|
||||
|
||||
RoomManager?.JoinRoom(room, r =>
|
||||
{
|
||||
Open(room);
|
||||
joiningRoom = false;
|
||||
updateLoadingLayer();
|
||||
}, _ =>
|
||||
{
|
||||
joiningRoom = false;
|
||||
updateLoadingLayer();
|
||||
});
|
||||
}
|
||||
|
||||
private void onInitialRoomsReceivedChanged(ValueChangedEvent<bool> received) => updateLoadingLayer();
|
||||
|
||||
private void updateLoadingLayer()
|
||||
{
|
||||
if (joiningRoom || !initialRoomsReceived.Value)
|
||||
loadingLayer.Show();
|
||||
else
|
||||
loadingLayer.Hide();
|
||||
}, _ => loadingLayer.Hide());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -25,6 +25,9 @@ namespace osu.Game.Screens.Multi
|
||||
public event Action RoomsUpdated;
|
||||
|
||||
private readonly BindableList<Room> rooms = new BindableList<Room>();
|
||||
|
||||
public Bindable<bool> InitialRoomsReceived { get; } = new Bindable<bool>();
|
||||
|
||||
public IBindableList<Room> Rooms => rooms;
|
||||
|
||||
public double TimeBetweenListingPolls
|
||||
@ -62,7 +65,11 @@ namespace osu.Game.Screens.Multi
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
listingPollingComponent = new ListingPollingComponent { RoomsReceived = onListingReceived },
|
||||
listingPollingComponent = new ListingPollingComponent
|
||||
{
|
||||
InitialRoomsReceived = { BindTarget = InitialRoomsReceived },
|
||||
RoomsReceived = onListingReceived
|
||||
},
|
||||
selectionPollingComponent = new SelectionPollingComponent { RoomReceived = onSelectedRoomReceived }
|
||||
};
|
||||
}
|
||||
@ -262,6 +269,8 @@ namespace osu.Game.Screens.Multi
|
||||
{
|
||||
public Action<List<Room>> RoomsReceived;
|
||||
|
||||
public readonly Bindable<bool> InitialRoomsReceived = new Bindable<bool>();
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
@ -273,6 +282,8 @@ namespace osu.Game.Screens.Multi
|
||||
{
|
||||
currentFilter.BindValueChanged(_ =>
|
||||
{
|
||||
InitialRoomsReceived.Value = false;
|
||||
|
||||
if (IsLoaded)
|
||||
PollImmediately();
|
||||
});
|
||||
@ -292,6 +303,7 @@ namespace osu.Game.Screens.Multi
|
||||
|
||||
pollReq.Success += result =>
|
||||
{
|
||||
InitialRoomsReceived.Value = true;
|
||||
RoomsReceived?.Invoke(result);
|
||||
tcs.SetResult(true);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user