1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 15:27:24 +08:00

Use sheared text box with filter count in multi/playlists lounge

This commit is contained in:
Joseph Madamba 2024-09-16 22:34:51 -07:00
parent 007062496e
commit c19802e923
3 changed files with 43 additions and 5 deletions

View File

@ -9,6 +9,7 @@ using osu.Framework.Bindables;
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay.Lounge.Components;
using osu.Game.Screens.OnlinePlay.Playlists;
@ -91,6 +92,20 @@ namespace osu.Game.Tests.Visual.Playlists
AddAssert("selected room is disabled", () => loungeScreen.SelectedRoom.Disabled);
}
[Test]
public void TestFilterTextCount()
{
AddAssert("filter text is 0 matches", () => this.ChildrenOfType<ShearedFilterTextBox>().Single().FilterText.ToString(), () => Is.EqualTo("0 matches"));
AddStep("add 10 rooms", () => RoomManager.AddRooms(10));
AddAssert("filter text is 10 matches", () => this.ChildrenOfType<ShearedFilterTextBox>().Single().FilterText.ToString(), () => Is.EqualTo("10 matches"));
AddStep("search for room 1", () => this.ChildrenOfType<ShearedFilterTextBox>().Single().Current.Value = "room 1");
AddUntilStep("filter text is 1 match", () => this.ChildrenOfType<ShearedFilterTextBox>().Single().FilterText.ToString(), () => Is.EqualTo("1 match"));
}
private bool checkRoomVisible(DrawableRoom room) =>
loungeScreen.ChildrenOfType<OsuScrollContainer>().First().ScreenSpaceDrawQuad
.Contains(room.ScreenSpaceDrawQuad.Centre);

View File

@ -29,6 +29,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
public IReadOnlyList<DrawableRoom> Rooms => roomFlow.FlowingChildren.Cast<DrawableRoom>().ToArray();
public Bindable<int> VisibleRoomCount = new Bindable<int>();
private readonly IBindableList<Room> rooms = new BindableList<Room>();
private readonly FillFlowContainer<DrawableLoungeRoom> roomFlow;
@ -94,6 +96,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
}
});
VisibleRoomCount.Value = roomFlow.Count(r => r.MatchingFilter);
static bool matchPermissions(DrawableLoungeRoom room, RoomPermissionsFilter accessType)
{
switch (accessType)

View File

@ -85,7 +85,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
private PopoverContainer popoverContainer;
private LoadingLayer loadingLayer;
private RoomsContainer roomsContainer;
private SearchTextBox searchTextBox;
private ShearedFilterTextBox searchTextBox;
private Dropdown<RoomStatusFilter> statusDropdown;
[BackgroundDependencyLoader(true)]
@ -135,7 +135,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
{
RelativeSizeAxes = Axes.X,
Height = Header.HEIGHT,
Child = searchTextBox = new BasicSearchTextBox
Child = searchTextBox = new ShearedFilterTextBox
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
@ -196,10 +196,17 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
if (ongoingOperationTracker != null)
{
operationInProgress.BindTo(ongoingOperationTracker.InProgress);
operationInProgress.BindValueChanged(_ => updateLoadingLayer());
operationInProgress.BindValueChanged(_ => updateLoadingState());
}
ListingPollingComponent.InitialRoomsReceived.BindValueChanged(_ => updateLoadingLayer(), true);
ListingPollingComponent.InitialRoomsReceived.BindValueChanged(_ => updateLoadingState(), true);
roomsContainer.VisibleRoomCount.BindValueChanged(_ =>
{
if (operationInProgress.Value || !ListingPollingComponent.InitialRoomsReceived.Value) return;
updateFilterText();
}, true);
updateFilter();
}
@ -382,12 +389,24 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
this.Push(CreateRoomSubScreen(room));
}
private void updateLoadingLayer()
private void updateLoadingState()
{
if (operationInProgress.Value || !ListingPollingComponent.InitialRoomsReceived.Value)
{
loadingLayer.Show();
searchTextBox.FilterText = "loading...";
}
else
{
loadingLayer.Hide();
updateFilterText();
}
}
private void updateFilterText()
{
int visibleRoomCount = roomsContainer.VisibleRoomCount.Value;
searchTextBox.FilterText = visibleRoomCount != 1 ? $"{visibleRoomCount:#,0} matches" : $"{visibleRoomCount:#,0} match";
}
private void updatePollingRate(bool isCurrentScreen)