mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 08:02:55 +08:00
Hook up multiplayer search filter (#6857)
Hook up multiplayer search filter Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
commit
f6b25ba2f7
@ -74,7 +74,9 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
set
|
||||
{
|
||||
matchingFilter = value;
|
||||
this.FadeTo(MatchingFilter ? 1 : 0, 200);
|
||||
|
||||
if (IsLoaded)
|
||||
this.FadeTo(MatchingFilter ? 1 : 0, 200);
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,7 +205,11 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
this.FadeInFromZero(transition_duration);
|
||||
|
||||
if (matchingFilter)
|
||||
this.FadeInFromZero(transition_duration);
|
||||
else
|
||||
Alpha = 0;
|
||||
}
|
||||
|
||||
private class RoomName : OsuSpriteText
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System.ComponentModel;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Overlays.SearchableList;
|
||||
using osuTK.Graphics;
|
||||
@ -37,12 +38,22 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Search.Current.BindValueChanged(_ => updateFilter());
|
||||
Search.Current.BindValueChanged(_ => scheduleUpdateFilter());
|
||||
Tabs.Current.BindValueChanged(_ => updateFilter(), true);
|
||||
}
|
||||
|
||||
private ScheduledDelegate scheduledFilterUpdate;
|
||||
|
||||
private void scheduleUpdateFilter()
|
||||
{
|
||||
scheduledFilterUpdate?.Cancel();
|
||||
scheduledFilterUpdate = Scheduler.AddDelayed(updateFilter, 200);
|
||||
}
|
||||
|
||||
private void updateFilter()
|
||||
{
|
||||
scheduledFilterUpdate?.Cancel();
|
||||
|
||||
filter.Value = new FilterCriteria
|
||||
{
|
||||
SearchString = Search.Current.Value ?? string.Empty,
|
||||
|
@ -24,6 +24,9 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
private readonly FillFlowContainer<DrawableRoom> roomFlow;
|
||||
public IReadOnlyList<DrawableRoom> Rooms => roomFlow;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private Bindable<FilterCriteria> filter { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private Bindable<Room> currentRoom { get; set; }
|
||||
|
||||
@ -57,7 +60,10 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
addRooms(rooms);
|
||||
}
|
||||
|
||||
private FilterCriteria currentFilter;
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
filter?.BindValueChanged(f => Filter(f.NewValue), true);
|
||||
}
|
||||
|
||||
public void Filter(FilterCriteria criteria)
|
||||
{
|
||||
@ -74,15 +80,13 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
{
|
||||
default:
|
||||
case SecondaryFilter.Public:
|
||||
r.MatchingFilter = r.Room.Availability.Value == RoomAvailability.Public;
|
||||
matchingFilter &= r.Room.Availability.Value == RoomAvailability.Public;
|
||||
break;
|
||||
}
|
||||
|
||||
r.MatchingFilter = matchingFilter;
|
||||
}
|
||||
});
|
||||
|
||||
currentFilter = criteria;
|
||||
}
|
||||
|
||||
private void addRooms(IEnumerable<Room> rooms)
|
||||
@ -90,7 +94,8 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
foreach (var r in rooms)
|
||||
roomFlow.Add(new DrawableRoom(r) { Action = () => selectRoom(r) });
|
||||
|
||||
Filter(currentFilter);
|
||||
if (filter != null)
|
||||
Filter(filter.Value);
|
||||
}
|
||||
|
||||
private void removeRooms(IEnumerable<Room> rooms)
|
||||
|
Loading…
Reference in New Issue
Block a user