Add selection polling component to PlaylistsRoomSubScreen

This commit is contained in:
smoogipoo
2021-08-13 18:11:52 +09:00
parent 7cbf4c48ed
commit 83935540ca
2 changed files with 26 additions and 14 deletions

View File

@ -59,9 +59,6 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
[Resolved]
private IBindable<RulesetInfo> ruleset { get; set; }
[Resolved(CanBeNull = true)]
private IdleTracker idleTracker { get; set; }
[CanBeNull]
private IDisposable joiningRoomOperation { get; set; }
@ -73,9 +70,12 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
private Dropdown<RoomStatusFilter> statusDropdown;
private ListingPollingComponent listingPollingComponent;
[BackgroundDependencyLoader]
private void load()
[BackgroundDependencyLoader(true)]
private void load([CanBeNull] IdleTracker idleTracker)
{
if (idleTracker != null)
isIdle.BindTo(idleTracker.IsIdle);
filter ??= new Bindable<FilterCriteria>(new FilterCriteria());
OsuScrollContainer scrollContainer;
@ -184,11 +184,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
listingPollingComponent.HasPolledOnce.BindValueChanged(_ => updateLoadingLayer());
if (idleTracker != null)
{
isIdle.BindTo(idleTracker.IsIdle);
isIdle.BindValueChanged(_ => updatePollingRate(), true);
}
isIdle.BindValueChanged(_ => updatePollingRate(), true);
if (ongoingOperationTracker != null)
{

View File

@ -3,11 +3,14 @@
using System.Diagnostics;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Logging;
using osu.Framework.Screens;
using osu.Game.Input;
using osu.Game.Online.API;
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay.Components;
@ -33,12 +36,13 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
[Resolved(typeof(Room), nameof(Room.Playlist))]
private BindableList<PlaylistItem> playlist { get; set; }
private readonly IBindable<bool> isIdle = new BindableBool();
private MatchSettingsOverlay settingsOverlay;
private MatchLeaderboard leaderboard;
private OverlinedHeader participantsHeader;
private GridContainer mainContent;
private SelectionPollingComponent selectionPollingComponent;
public PlaylistsRoomSubScreen(Room room)
{
@ -46,11 +50,15 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
Activity.Value = new UserActivity.InLobby(room);
}
[BackgroundDependencyLoader]
private void load()
[BackgroundDependencyLoader(true)]
private void load([CanBeNull] IdleTracker idleTracker)
{
if (idleTracker != null)
isIdle.BindTo(idleTracker.IsIdle);
AddRangeInternal(new Drawable[]
{
selectionPollingComponent = new SelectionPollingComponent(),
mainContent = new GridContainer
{
RelativeSizeAxes = Axes.Both,
@ -260,6 +268,8 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
{
base.LoadComplete();
isIdle.BindValueChanged(_ => updatePollingRate(), true);
roomId.BindValueChanged(id =>
{
if (id.NewValue == null)
@ -275,6 +285,12 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
}, true);
}
private void updatePollingRate()
{
selectionPollingComponent.TimeBetweenPolls.Value = isIdle.Value ? 30000 : 5000;
Logger.Log($"Polling adjusted (selection: {selectionPollingComponent.TimeBetweenPolls.Value})");
}
protected override Screen CreateGameplayScreen() => new PlayerLoader(() => new PlaylistsPlayer(SelectedItem.Value)
{
Exited = () => leaderboard.RefreshScores()