mirror of
https://github.com/ppy/osu.git
synced 2025-02-06 07:43:24 +08:00
General refactorings from PR review
This commit is contained in:
parent
81f9442471
commit
b6a2020c59
@ -15,8 +15,8 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ListingPollingComponent : RoomPollingComponent
|
public class ListingPollingComponent : RoomPollingComponent
|
||||||
{
|
{
|
||||||
public IBindable<bool> HasPolledOnce => hasPolledOnce;
|
public IBindable<bool> InitialRoomsReceived => initialRoomsReceived;
|
||||||
private readonly Bindable<bool> hasPolledOnce = new Bindable<bool>();
|
private readonly Bindable<bool> initialRoomsReceived = new Bindable<bool>();
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private Bindable<FilterCriteria> currentFilter { get; set; }
|
private Bindable<FilterCriteria> currentFilter { get; set; }
|
||||||
@ -30,7 +30,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
currentFilter.BindValueChanged(_ =>
|
currentFilter.BindValueChanged(_ =>
|
||||||
{
|
{
|
||||||
RoomManager.ClearRooms();
|
RoomManager.ClearRooms();
|
||||||
hasPolledOnce.Value = false;
|
initialRoomsReceived.Value = false;
|
||||||
|
|
||||||
if (IsLoaded)
|
if (IsLoaded)
|
||||||
PollImmediately();
|
PollImmediately();
|
||||||
@ -60,7 +60,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
foreach (var incoming in result)
|
foreach (var incoming in result)
|
||||||
RoomManager.AddOrUpdateRoom(incoming);
|
RoomManager.AddOrUpdateRoom(incoming);
|
||||||
|
|
||||||
hasPolledOnce.Value = true;
|
initialRoomsReceived.Value = true;
|
||||||
tcs.SetResult(true);
|
tcs.SetResult(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,6 +45,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
|||||||
AutoSizeAxes = Axes.Both
|
AutoSizeAxes = Axes.Both
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected ListingPollingComponent ListingPollingComponent { get; private set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private Bindable<Room> selectedRoom { get; set; }
|
private Bindable<Room> selectedRoom { get; set; }
|
||||||
|
|
||||||
@ -72,7 +74,6 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
|||||||
private RoomsContainer roomsContainer;
|
private RoomsContainer roomsContainer;
|
||||||
private SearchTextBox searchTextBox;
|
private SearchTextBox searchTextBox;
|
||||||
private Dropdown<RoomStatusFilter> statusDropdown;
|
private Dropdown<RoomStatusFilter> statusDropdown;
|
||||||
private ListingPollingComponent listingPollingComponent;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load([CanBeNull] IdleTracker idleTracker)
|
private void load([CanBeNull] IdleTracker idleTracker)
|
||||||
@ -86,7 +87,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
|||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
listingPollingComponent = CreatePollingComponent(),
|
ListingPollingComponent = CreatePollingComponent(),
|
||||||
loadingLayer = new LoadingLayer(true),
|
loadingLayer = new LoadingLayer(true),
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
@ -186,7 +187,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
|||||||
searchTextBox.Current.BindValueChanged(_ => updateFilterDebounced());
|
searchTextBox.Current.BindValueChanged(_ => updateFilterDebounced());
|
||||||
ruleset.BindValueChanged(_ => UpdateFilter());
|
ruleset.BindValueChanged(_ => UpdateFilter());
|
||||||
|
|
||||||
listingPollingComponent.HasPolledOnce.BindValueChanged(_ => updateLoadingLayer());
|
ListingPollingComponent.InitialRoomsReceived.BindValueChanged(_ => updateLoadingLayer());
|
||||||
|
|
||||||
isIdle.BindValueChanged(_ => updatePollingRate(this.IsCurrentScreen()), true);
|
isIdle.BindValueChanged(_ => updatePollingRate(this.IsCurrentScreen()), true);
|
||||||
|
|
||||||
@ -337,7 +338,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
|||||||
|
|
||||||
private void updateLoadingLayer()
|
private void updateLoadingLayer()
|
||||||
{
|
{
|
||||||
if (operationInProgress.Value || !listingPollingComponent.HasPolledOnce.Value)
|
if (operationInProgress.Value || !ListingPollingComponent.InitialRoomsReceived.Value)
|
||||||
loadingLayer.Show();
|
loadingLayer.Show();
|
||||||
else
|
else
|
||||||
loadingLayer.Hide();
|
loadingLayer.Hide();
|
||||||
@ -346,11 +347,11 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
|||||||
private void updatePollingRate(bool isCurrentScreen)
|
private void updatePollingRate(bool isCurrentScreen)
|
||||||
{
|
{
|
||||||
if (!isCurrentScreen)
|
if (!isCurrentScreen)
|
||||||
listingPollingComponent.TimeBetweenPolls.Value = 0;
|
ListingPollingComponent.TimeBetweenPolls.Value = 0;
|
||||||
else
|
else
|
||||||
listingPollingComponent.TimeBetweenPolls.Value = isIdle.Value ? 120000 : 15000;
|
ListingPollingComponent.TimeBetweenPolls.Value = isIdle.Value ? 120000 : 15000;
|
||||||
|
|
||||||
Logger.Log($"Polling adjusted (listing: {listingPollingComponent.TimeBetweenPolls.Value})");
|
Logger.Log($"Polling adjusted (listing: {ListingPollingComponent.TimeBetweenPolls.Value})");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract OsuButton CreateNewRoomButton();
|
protected abstract OsuButton CreateNewRoomButton();
|
||||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private MultiplayerClient client { get; set; }
|
private MultiplayerClient client { get; set; }
|
||||||
|
|
||||||
private MultiplayerListingPollingComponent listingPollingComponent;
|
private MultiplayerListingPollingComponent multiplayerListingPollingComponent => (MultiplayerListingPollingComponent)ListingPollingComponent;
|
||||||
|
|
||||||
private readonly IBindable<bool> isConnected = new Bindable<bool>();
|
private readonly IBindable<bool> isConnected = new Bindable<bool>();
|
||||||
|
|
||||||
@ -34,8 +34,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
isConnected.BindTo(client.IsConnected);
|
isConnected.BindTo(client.IsConnected);
|
||||||
isConnected.BindValueChanged(c => Scheduler.AddOnce(() => listingPollingComponent.AllowPolling = c.NewValue));
|
isConnected.BindValueChanged(c => Scheduler.AddOnce(() => multiplayerListingPollingComponent.AllowPolling = c.NewValue));
|
||||||
listingPollingComponent.AllowPolling = isConnected.Value;
|
multiplayerListingPollingComponent.AllowPolling = isConnected.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnResuming(IScreen last)
|
public override void OnResuming(IScreen last)
|
||||||
@ -47,7 +47,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
if (last is MultiplayerMatchSubScreen match)
|
if (last is MultiplayerMatchSubScreen match)
|
||||||
{
|
{
|
||||||
RoomManager.RemoveRoom(match.Room);
|
RoomManager.RemoveRoom(match.Room);
|
||||||
listingPollingComponent.PollImmediately();
|
multiplayerListingPollingComponent.PollImmediately();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
|
|
||||||
protected override RoomSubScreen CreateRoomSubScreen(Room room) => new MultiplayerMatchSubScreen(room);
|
protected override RoomSubScreen CreateRoomSubScreen(Room room) => new MultiplayerMatchSubScreen(room);
|
||||||
|
|
||||||
protected override ListingPollingComponent CreatePollingComponent() => listingPollingComponent = new MultiplayerListingPollingComponent();
|
protected override ListingPollingComponent CreatePollingComponent() => new MultiplayerListingPollingComponent();
|
||||||
|
|
||||||
protected override void OpenNewRoom(Room room)
|
protected override void OpenNewRoom(Room room)
|
||||||
{
|
{
|
||||||
@ -104,7 +104,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Task Poll() => !AllowPolling ? Task.CompletedTask : base.Poll();
|
protected override Task Poll() => AllowPolling ? base.Poll() : Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user