mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 19:22:56 +08: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 readonly BindableList<Room> Rooms = new BindableList<Room>();
|
||||||
|
|
||||||
|
public Bindable<bool> InitialRoomsReceived { get; } = new Bindable<bool>(true);
|
||||||
|
|
||||||
IBindableList<Room> IRoomManager.Rooms => Rooms;
|
IBindableList<Room> IRoomManager.Rooms => Rooms;
|
||||||
|
|
||||||
public void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null) => Rooms.Add(room);
|
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 { }
|
remove { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Bindable<bool> InitialRoomsReceived { get; } = new Bindable<bool>(true);
|
||||||
|
|
||||||
public IBindableList<Room> Rooms { get; } = null;
|
public IBindableList<Room> Rooms { get; } = null;
|
||||||
|
|
||||||
public void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = 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();
|
remove => throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Bindable<bool> InitialRoomsReceived { get; } = new Bindable<bool>(true);
|
||||||
|
|
||||||
public IBindableList<Room> Rooms { get; } = new BindableList<Room>();
|
public IBindableList<Room> Rooms { get; } = new BindableList<Room>();
|
||||||
|
|
||||||
public void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
public void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
||||||
|
@ -14,6 +14,11 @@ namespace osu.Game.Screens.Multi
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
event Action RoomsUpdated;
|
event Action RoomsUpdated;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether an initial listing of rooms has been received.
|
||||||
|
/// </summary>
|
||||||
|
Bindable<bool> InitialRoomsReceived { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All the active <see cref="Room"/>s.
|
/// All the active <see cref="Room"/>s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -22,12 +22,16 @@ namespace osu.Game.Screens.Multi.Lounge
|
|||||||
|
|
||||||
protected readonly FilterControl Filter;
|
protected readonly FilterControl Filter;
|
||||||
|
|
||||||
|
private readonly Bindable<bool> initialRoomsReceived = new Bindable<bool>();
|
||||||
|
|
||||||
private readonly Container content;
|
private readonly Container content;
|
||||||
private readonly LoadingLayer loadingLayer;
|
private readonly LoadingLayer loadingLayer;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private Bindable<Room> selectedRoom { get; set; }
|
private Bindable<Room> selectedRoom { get; set; }
|
||||||
|
|
||||||
|
private bool joiningRoom;
|
||||||
|
|
||||||
public LoungeSubScreen()
|
public LoungeSubScreen()
|
||||||
{
|
{
|
||||||
SearchContainer searchContainer;
|
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()
|
protected override void UpdateAfterChildren()
|
||||||
{
|
{
|
||||||
base.UpdateAfterChildren();
|
base.UpdateAfterChildren();
|
||||||
@ -126,12 +138,29 @@ namespace osu.Game.Screens.Multi.Lounge
|
|||||||
|
|
||||||
private void joinRequested(Room room)
|
private void joinRequested(Room room)
|
||||||
{
|
{
|
||||||
loadingLayer.Show();
|
joiningRoom = true;
|
||||||
|
updateLoadingLayer();
|
||||||
|
|
||||||
RoomManager?.JoinRoom(room, r =>
|
RoomManager?.JoinRoom(room, r =>
|
||||||
{
|
{
|
||||||
Open(room);
|
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();
|
||||||
}, _ => loadingLayer.Hide());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -25,6 +25,9 @@ namespace osu.Game.Screens.Multi
|
|||||||
public event Action RoomsUpdated;
|
public event Action RoomsUpdated;
|
||||||
|
|
||||||
private readonly BindableList<Room> rooms = new BindableList<Room>();
|
private readonly BindableList<Room> rooms = new BindableList<Room>();
|
||||||
|
|
||||||
|
public Bindable<bool> InitialRoomsReceived { get; } = new Bindable<bool>();
|
||||||
|
|
||||||
public IBindableList<Room> Rooms => rooms;
|
public IBindableList<Room> Rooms => rooms;
|
||||||
|
|
||||||
public double TimeBetweenListingPolls
|
public double TimeBetweenListingPolls
|
||||||
@ -62,7 +65,11 @@ namespace osu.Game.Screens.Multi
|
|||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
listingPollingComponent = new ListingPollingComponent { RoomsReceived = onListingReceived },
|
listingPollingComponent = new ListingPollingComponent
|
||||||
|
{
|
||||||
|
InitialRoomsReceived = { BindTarget = InitialRoomsReceived },
|
||||||
|
RoomsReceived = onListingReceived
|
||||||
|
},
|
||||||
selectionPollingComponent = new SelectionPollingComponent { RoomReceived = onSelectedRoomReceived }
|
selectionPollingComponent = new SelectionPollingComponent { RoomReceived = onSelectedRoomReceived }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -262,6 +269,8 @@ namespace osu.Game.Screens.Multi
|
|||||||
{
|
{
|
||||||
public Action<List<Room>> RoomsReceived;
|
public Action<List<Room>> RoomsReceived;
|
||||||
|
|
||||||
|
public readonly Bindable<bool> InitialRoomsReceived = new Bindable<bool>();
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IAPIProvider api { get; set; }
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
@ -273,6 +282,8 @@ namespace osu.Game.Screens.Multi
|
|||||||
{
|
{
|
||||||
currentFilter.BindValueChanged(_ =>
|
currentFilter.BindValueChanged(_ =>
|
||||||
{
|
{
|
||||||
|
InitialRoomsReceived.Value = false;
|
||||||
|
|
||||||
if (IsLoaded)
|
if (IsLoaded)
|
||||||
PollImmediately();
|
PollImmediately();
|
||||||
});
|
});
|
||||||
@ -292,6 +303,7 @@ namespace osu.Game.Screens.Multi
|
|||||||
|
|
||||||
pollReq.Success += result =>
|
pollReq.Success += result =>
|
||||||
{
|
{
|
||||||
|
InitialRoomsReceived.Value = true;
|
||||||
RoomsReceived?.Invoke(result);
|
RoomsReceived?.Invoke(result);
|
||||||
tcs.SetResult(true);
|
tcs.SetResult(true);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user