Move filter to LoungeSubScreen

This commit is contained in:
smoogipoo 2021-08-17 09:36:43 +09:00
parent 97d5b80834
commit 352949069a
10 changed files with 35 additions and 52 deletions

View File

@ -115,11 +115,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddUntilStep("4 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 4);
AddStep("filter one room", () => container.Filter(new FilterCriteria { SearchString = "1" }));
AddStep("filter one room", () => container.Filter.Value = new FilterCriteria { SearchString = "1" });
AddUntilStep("1 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 1);
AddStep("remove filter", () => container.Filter(null));
AddStep("remove filter", () => container.Filter.Value = null);
AddUntilStep("4 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 4);
}
@ -131,13 +131,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("add rooms", () => RoomManager.AddRooms(3, new CatchRuleset().RulesetInfo));
// Todo: What even is this case...?
AddStep("set empty filter criteria", () => container.Filter(null));
AddStep("set empty filter criteria", () => container.Filter.Value = null);
AddUntilStep("5 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 5);
AddStep("filter osu! rooms", () => container.Filter(new FilterCriteria { Ruleset = new OsuRuleset().RulesetInfo }));
AddStep("filter osu! rooms", () => container.Filter.Value = new FilterCriteria { Ruleset = new OsuRuleset().RulesetInfo });
AddUntilStep("2 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 2);
AddStep("filter catch rooms", () => container.Filter(new FilterCriteria { Ruleset = new CatchRuleset().RulesetInfo }));
AddStep("filter catch rooms", () => container.Filter.Value = new FilterCriteria { Ruleset = new CatchRuleset().RulesetInfo });
AddUntilStep("3 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 3);
}

View File

@ -132,11 +132,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Test]
public void TestExitMidJoin()
{
Room room = null;
AddStep("create room", () =>
{
room = new Room
multiplayerScreen.RoomManager.AddRoom(new Room
{
Name = { Value = "Test Room" },
Playlist =
@ -147,14 +145,16 @@ namespace osu.Game.Tests.Visual.Multiplayer
Ruleset = { Value = new OsuRuleset().RulesetInfo },
}
}
};
});
});
AddStep("refresh rooms", () => multiplayerScreen.RoomManager.Filter.Value = new FilterCriteria());
AddStep("refresh rooms", () => this.ChildrenOfType<LoungeSubScreen>().Single().UpdateFilter());
AddUntilStep("wait for room", () => this.ChildrenOfType<DrawableRoom>().Any());
AddStep("select room", () => InputManager.Key(Key.Down));
AddStep("join room and immediately exit", () =>
AddStep("join room and immediately exit select", () =>
{
multiplayerScreen.ChildrenOfType<LoungeSubScreen>().Single().Open(room);
InputManager.Key(Key.Enter);
Schedule(() => Stack.CurrentScreen.Exit());
});
}
@ -178,7 +178,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
});
});
AddStep("refresh rooms", () => multiplayerScreen.RoomManager.Filter.Value = new FilterCriteria());
AddStep("refresh rooms", () => this.ChildrenOfType<LoungeSubScreen>().Single().UpdateFilter());
AddUntilStep("wait for room", () => this.ChildrenOfType<DrawableRoom>().Any());
AddStep("select room", () => InputManager.Key(Key.Down));
AddStep("join room", () => InputManager.Key(Key.Enter));
@ -226,7 +228,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
});
});
AddStep("refresh rooms", () => multiplayerScreen.RoomManager.Filter.Value = new FilterCriteria());
AddStep("refresh rooms", () => this.ChildrenOfType<LoungeSubScreen>().Single().UpdateFilter());
AddUntilStep("wait for room", () => this.ChildrenOfType<DrawableRoom>().Any());
AddStep("select room", () => InputManager.Key(Key.Down));
AddStep("join room", () => InputManager.Key(Key.Enter));

View File

@ -18,8 +18,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
public IBindable<bool> InitialRoomsReceived => initialRoomsReceived;
private readonly Bindable<bool> initialRoomsReceived = new Bindable<bool>();
[Resolved]
private Bindable<FilterCriteria> currentFilter { get; set; }
public readonly Bindable<FilterCriteria> Filter = new Bindable<FilterCriteria>();
[Resolved]
private Bindable<Room> selectedRoom { get; set; }
@ -27,7 +26,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
[BackgroundDependencyLoader]
private void load()
{
currentFilter.BindValueChanged(_ =>
Filter.BindValueChanged(_ =>
{
RoomManager.ClearRooms();
initialRoomsReceived.Value = false;
@ -44,10 +43,13 @@ namespace osu.Game.Screens.OnlinePlay.Components
if (!API.IsLoggedIn)
return base.Poll();
if (Filter.Value == null)
return base.Poll();
var tcs = new TaskCompletionSource<bool>();
pollReq?.Cancel();
pollReq = new GetRoomsRequest(currentFilter.Value.Status, currentFilter.Value.Category);
pollReq = new GetRoomsRequest(Filter.Value.Status, Filter.Value.Category);
pollReq.Success += result =>
{

View File

@ -30,8 +30,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
public IReadOnlyList<DrawableRoom> Rooms => roomFlow.FlowingChildren.Cast<DrawableRoom>().ToArray();
[Resolved(CanBeNull = true)]
private Bindable<FilterCriteria> filter { get; set; }
public readonly Bindable<FilterCriteria> Filter = new Bindable<FilterCriteria>();
[Resolved]
private Bindable<Room> selectedRoom { get; set; }
@ -74,7 +73,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
rooms.BindTo(roomManager.Rooms);
filter?.BindValueChanged(criteria => Filter(criteria.NewValue));
Filter?.BindValueChanged(criteria => applyFilterCriteria(criteria.NewValue), true);
selectedRoom.BindValueChanged(selection =>
{
@ -85,7 +84,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
private void updateSelection() =>
roomFlow.Children.ForEach(r => r.State = r.Room == selectedRoom.Value ? SelectionState.Selected : SelectionState.NotSelected);
public void Filter(FilterCriteria criteria)
private void applyFilterCriteria(FilterCriteria criteria)
{
roomFlow.Children.ForEach(r =>
{
@ -126,7 +125,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
roomFlow.Add(new DrawableRoom(room));
}
Filter(filter?.Value);
applyFilterCriteria(Filter?.Value);
updateSelection();
}

View File

@ -56,9 +56,6 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
[Resolved(CanBeNull = true)]
private OngoingOperationTracker ongoingOperationTracker { get; set; }
[Resolved(CanBeNull = true)]
private Bindable<FilterCriteria> filter { get; set; }
[Resolved]
private IBindable<RulesetInfo> ruleset { get; set; }
@ -68,6 +65,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
[CanBeNull]
private LeasedBindable<Room> selectionLease;
private readonly Bindable<FilterCriteria> filter = new Bindable<FilterCriteria>(new FilterCriteria());
private readonly IBindable<bool> operationInProgress = new Bindable<bool>();
private readonly IBindable<bool> isIdle = new BindableBool();
private LoadingLayer loadingLayer;
@ -81,13 +79,11 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
if (idleTracker != null)
isIdle.BindTo(idleTracker.IsIdle);
filter ??= new Bindable<FilterCriteria>(new FilterCriteria());
OsuScrollContainer scrollContainer;
InternalChildren = new Drawable[]
{
ListingPollingComponent = CreatePollingComponent(),
ListingPollingComponent = CreatePollingComponent().With(c => c.Filter.BindTarget = filter),
loadingLayer = new LoadingLayer(true),
new Container
{
@ -161,7 +157,10 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
{
RelativeSizeAxes = Axes.Both,
ScrollbarOverlapsContent = false,
Child = roomsContainer = new RoomsContainer()
Child = roomsContainer = new RoomsContainer
{
Filter = { BindTarget = filter }
}
},
}
},
@ -202,7 +201,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
#region Filtering
protected void UpdateFilter() => Scheduler.AddOnce(updateFilter);
public void UpdateFilter() => Scheduler.AddOnce(updateFilter);
private ScheduledDelegate scheduledFilterUpdate;

View File

@ -20,7 +20,6 @@ using osu.Game.Overlays;
using osu.Game.Screens.Menu;
using osu.Game.Screens.OnlinePlay.Components;
using osu.Game.Screens.OnlinePlay.Lounge;
using osu.Game.Screens.OnlinePlay.Lounge.Components;
using osu.Game.Users;
using osuTK;
using osuTK.Graphics;
@ -49,9 +48,6 @@ namespace osu.Game.Screens.OnlinePlay
[Cached]
private readonly Bindable<Room> selectedRoom = new Bindable<Room>();
[Cached]
private readonly Bindable<FilterCriteria> currentFilter = new Bindable<FilterCriteria>(new FilterCriteria());
[Cached]
private readonly OngoingOperationTracker ongoingOperationTracker = new OngoingOperationTracker();

View File

@ -5,14 +5,12 @@ using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.Rooms;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Screens.OnlinePlay.Components;
using osu.Game.Screens.OnlinePlay.Lounge.Components;
using osu.Game.Screens.OnlinePlay.Multiplayer;
namespace osu.Game.Tests.Visual.Multiplayer
@ -32,9 +30,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Resolved]
private OsuGameBase game { get; set; }
[Cached]
public readonly Bindable<FilterCriteria> Filter = new Bindable<FilterCriteria>(new FilterCriteria());
public new readonly List<Room> Rooms = new List<Room>();
private int currentRoomId;

View File

@ -4,7 +4,6 @@
using osu.Framework.Bindables;
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay;
using osu.Game.Screens.OnlinePlay.Lounge.Components;
namespace osu.Game.Tests.Visual.OnlinePlay
{
@ -23,11 +22,6 @@ namespace osu.Game.Tests.Visual.OnlinePlay
/// </summary>
IRoomManager RoomManager { get; }
/// <summary>
/// The cached <see cref="FilterCriteria"/>.
/// </summary>
Bindable<FilterCriteria> Filter { get; }
/// <summary>
/// The cached <see cref="OngoingOperationTracker"/>.
/// </summary>

View File

@ -9,7 +9,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay;
using osu.Game.Screens.OnlinePlay.Lounge.Components;
namespace osu.Game.Tests.Visual.OnlinePlay
{
@ -20,7 +19,6 @@ namespace osu.Game.Tests.Visual.OnlinePlay
{
public Bindable<Room> SelectedRoom => OnlinePlayDependencies?.SelectedRoom;
public IRoomManager RoomManager => OnlinePlayDependencies?.RoomManager;
public Bindable<FilterCriteria> Filter => OnlinePlayDependencies?.Filter;
public OngoingOperationTracker OngoingOperationTracker => OnlinePlayDependencies?.OngoingOperationTracker;
public OnlinePlayBeatmapAvailabilityTracker AvailabilityTracker => OnlinePlayDependencies?.AvailabilityTracker;

View File

@ -9,7 +9,6 @@ using osu.Framework.Graphics;
using osu.Game.Online.Rooms;
using osu.Game.Overlays;
using osu.Game.Screens.OnlinePlay;
using osu.Game.Screens.OnlinePlay.Lounge.Components;
namespace osu.Game.Tests.Visual.OnlinePlay
{
@ -20,7 +19,6 @@ namespace osu.Game.Tests.Visual.OnlinePlay
{
public Bindable<Room> SelectedRoom { get; }
public IRoomManager RoomManager { get; }
public Bindable<FilterCriteria> Filter { get; }
public OngoingOperationTracker OngoingOperationTracker { get; }
public OnlinePlayBeatmapAvailabilityTracker AvailabilityTracker { get; }
@ -36,7 +34,6 @@ namespace osu.Game.Tests.Visual.OnlinePlay
{
SelectedRoom = new Bindable<Room>();
RoomManager = CreateRoomManager();
Filter = new Bindable<FilterCriteria>(new FilterCriteria());
OngoingOperationTracker = new OngoingOperationTracker();
AvailabilityTracker = new OnlinePlayBeatmapAvailabilityTracker();
@ -44,7 +41,6 @@ namespace osu.Game.Tests.Visual.OnlinePlay
CacheAs(SelectedRoom);
CacheAs(RoomManager);
CacheAs(Filter);
CacheAs(OngoingOperationTracker);
CacheAs(AvailabilityTracker);
CacheAs(new OverlayColourProvider(OverlayColourScheme.Plum));