From 36f6b4fc3fe530adf191f8b3239d1b961fe2dcc7 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 19 Dec 2018 18:02:05 +0900 Subject: [PATCH] Hook up participated filter Very early stages, implementation will change. --- .../Multi/Lounge/Components/RoomsContainer.cs | 1 + osu.Game/Screens/Multi/Lounge/LoungeScreen.cs | 6 +++- osu.Game/Screens/Multi/RoomManager.cs | 36 ++++++++++++++++++- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Multi/Lounge/Components/RoomsContainer.cs b/osu.Game/Screens/Multi/Lounge/Components/RoomsContainer.cs index af66f5bfe8..71d39cd270 100644 --- a/osu.Game/Screens/Multi/Lounge/Components/RoomsContainer.cs +++ b/osu.Game/Screens/Multi/Lounge/Components/RoomsContainer.cs @@ -79,6 +79,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components r.MatchingFilter = matchingFilter; } }); + currentFilter = criteria; } diff --git a/osu.Game/Screens/Multi/Lounge/LoungeScreen.cs b/osu.Game/Screens/Multi/Lounge/LoungeScreen.cs index 81a478b778..408c02f805 100644 --- a/osu.Game/Screens/Multi/Lounge/LoungeScreen.cs +++ b/osu.Game/Screens/Multi/Lounge/LoungeScreen.cs @@ -120,7 +120,11 @@ namespace osu.Game.Screens.Multi.Lounge Filter.Search.HoldFocus = false; } - private void filterRooms() => rooms.Filter(Filter.CreateCriteria()); + private void filterRooms() + { + rooms.Filter(Filter.CreateCriteria()); + manager.Filter(Filter.CreateCriteria()); + } public void Open(Room room) { diff --git a/osu.Game/Screens/Multi/RoomManager.cs b/osu.Game/Screens/Multi/RoomManager.cs index 7e29aacaf4..7d3e4f5657 100644 --- a/osu.Game/Screens/Multi/RoomManager.cs +++ b/osu.Game/Screens/Multi/RoomManager.cs @@ -15,6 +15,7 @@ using osu.Game.Online; using osu.Game.Online.API; using osu.Game.Online.Multiplayer; using osu.Game.Rulesets; +using osu.Game.Screens.Multi.Lounge.Components; namespace osu.Game.Screens.Multi { @@ -25,6 +26,8 @@ namespace osu.Game.Screens.Multi public readonly Bindable Current = new Bindable(); + private FilterCriteria currentFilter = new FilterCriteria(); + [Resolved] private APIAccess api { get; set; } @@ -50,6 +53,12 @@ namespace osu.Game.Screens.Multi api.Queue(req); } + public void Filter(FilterCriteria criteria) + { + currentFilter = criteria; + PollImmediately(); + } + protected override Task Poll() { if (!api.IsLoggedIn) @@ -57,10 +66,18 @@ namespace osu.Game.Screens.Multi var tcs = new TaskCompletionSource(); - var pollReq = new GetRoomsRequest(); + var pollReq = new GetRoomsRequest(currentFilter.PrimaryFilter); pollReq.Success += result => { + // Remove past matches + foreach (var r in rooms.ToList()) + { + if (result.All(e => e.RoomID.Value != r.RoomID.Value)) + rooms.Remove(r); + } + + // Add new matches, or update existing foreach (var r in result) { processPlaylist(r); @@ -126,6 +143,23 @@ namespace osu.Game.Screens.Multi private class GetRoomsRequest : APIRequest> { + private readonly PrimaryFilter primaryFilter; + + public GetRoomsRequest(PrimaryFilter primaryFilter) + { + this.primaryFilter = primaryFilter; + } + + protected override WebRequest CreateWebRequest() + { + var req = base.CreateWebRequest(); + + if (primaryFilter == PrimaryFilter.Participated) + req.AddParameter("participated", "1"); + + return req; + } + protected override string Target => "rooms"; } }