From 44d821172ab2d60069e95c9986d94eda5f7b1e07 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Tue, 9 Jan 2018 16:29:12 +0100 Subject: [PATCH] tidying up --- osu.Game/Overlays/Social/FilterControl.cs | 1 - osu.Game/Overlays/Social/Header.cs | 13 +++-- osu.Game/Overlays/SocialOverlay.cs | 59 ++++++++++------------- 3 files changed, 31 insertions(+), 42 deletions(-) diff --git a/osu.Game/Overlays/Social/FilterControl.cs b/osu.Game/Overlays/Social/FilterControl.cs index c05c3eb530..382b3fd0e7 100644 --- a/osu.Game/Overlays/Social/FilterControl.cs +++ b/osu.Game/Overlays/Social/FilterControl.cs @@ -21,7 +21,6 @@ namespace osu.Game.Overlays.Social public enum SocialSortCriteria { - Relevance, Rank, Name, Location, diff --git a/osu.Game/Overlays/Social/Header.cs b/osu.Game/Overlays/Social/Header.cs index 5d243ad36f..0767e0aec0 100644 --- a/osu.Game/Overlays/Social/Header.cs +++ b/osu.Game/Overlays/Social/Header.cs @@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Social protected override Color4 BackgroundColour => OsuColour.FromHex(@"38202e"); protected override float TabStripWidth => 438; - protected override SocialTab DefaultTab => SocialTab.OnlinePlayers; + protected override SocialTab DefaultTab => SocialTab.AllPlayers; protected override FontAwesome Icon => FontAwesome.fa_users; protected override Drawable CreateHeaderText() @@ -54,13 +54,12 @@ namespace osu.Game.Overlays.Social public enum SocialTab { - Search, - [Description("Players")] - OnlinePlayers = SocialSortCriteria.Rank, + [Description("All Players")] + AllPlayers = SocialSortCriteria.Rank, [Description("Friends")] - OnlineFriends = SocialSortCriteria.Name, - //[Description("Online Team Members")] - //OnlineTeamMembers, + Friends = SocialSortCriteria.Name, + //[Description("Team Members")] + //TeamMembers, //[Description("Chat Channels")] //ChatChannels, } diff --git a/osu.Game/Overlays/SocialOverlay.cs b/osu.Game/Overlays/SocialOverlay.cs index 95e588942c..6fffd37456 100644 --- a/osu.Game/Overlays/SocialOverlay.cs +++ b/osu.Game/Overlays/SocialOverlay.cs @@ -55,37 +55,35 @@ namespace osu.Game.Overlays Filter.Search.Current.ValueChanged += text => { - if (text != string.Empty) + if (!string.IsNullOrEmpty(text)) { - Header.Tabs.Current.Value = SocialTab.Search; + // force searching in players until searching for friends is supported + Header.Tabs.Current.Value = SocialTab.AllPlayers; - if (Filter.Tabs.Current.Value == SocialSortCriteria.Rank) - Filter.Tabs.Current.Value = SocialSortCriteria.Relevance; - } - else - { - Header.Tabs.Current.Value = SocialTab.OnlinePlayers; - - if (Filter.Tabs.Current.Value == SocialSortCriteria.Relevance) + if (Filter.Tabs.Current.Value != SocialSortCriteria.Rank) Filter.Tabs.Current.Value = SocialSortCriteria.Rank; } }; - Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels; - - // TODO sort our list in some way (either locally or with API call) - //Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += sortOrder => Scheduler.AddOnce(updateSearch); - Header.Tabs.Current.ValueChanged += tab => { - if (tab != SocialTab.Search) - { - //currentQuery.Value = string.Empty; - Filter.Tabs.Current.Value = (SocialSortCriteria)Header.Tabs.Current.Value; - Scheduler.AddOnce(updateSearch); - } + //currentQuery.Value = string.Empty; + Filter.Tabs.Current.Value = (SocialSortCriteria)Header.Tabs.Current.Value; + Scheduler.AddOnce(updateSearch); }; + Filter.Tabs.Current.ValueChanged += sortCriteria => + { + // force searching in players until searching for friends is supported + if (Header.Tabs.Current.Value != SocialTab.AllPlayers && sortCriteria != (SocialSortCriteria)Header.Tabs.Current.Value) + Header.Tabs.Current.Value = SocialTab.AllPlayers; + + Scheduler.AddOnce(updateSearch); + }; + + Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels; + Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += sortOrder => Scheduler.AddOnce(updateSearch); + //currentQuery.ValueChanged += v => //{ // queryChangedDebounce?.Cancel(); @@ -97,14 +95,6 @@ namespace osu.Game.Overlays //}; //currentQuery.BindTo(Filter.Search.Current); - - Filter.Tabs.Current.ValueChanged += sortCriteria => - { - if (Header.Tabs.Current.Value != SocialTab.Search && sortCriteria != (SocialSortCriteria)Header.Tabs.Current.Value) - Header.Tabs.Current.Value = SocialTab.Search; - - Scheduler.AddOnce(updateSearch); - }; } [BackgroundDependencyLoader] @@ -148,11 +138,12 @@ namespace osu.Game.Overlays }) }; - LoadComponentAsync(newPanels, p => + LoadComponentAsync(newPanels, f => { if(panels != null) ScrollFlow.Remove(panels); + // delay new panels so they don't get added before the old ones are gone Scheduler.AddDelayed(() => ScrollFlow.Add(panels = newPanels), 200); }); } @@ -190,13 +181,13 @@ namespace osu.Game.Overlays switch (Header.Tabs.Current.Value) { - case SocialTab.OnlineFriends: - var friendRequest = new GetFriendsRequest(); + case SocialTab.Friends: + var friendRequest = new GetFriendsRequest(); // TODO filter arguments? friendRequest.Success += updateUsers; api.Queue(getUsersRequest = friendRequest); break; default: - var userRequest = new GetUsersRequest(); // TODO filter??? + var userRequest = new GetUsersRequest(); // TODO filter arguments! userRequest.Success += response => updateUsers(response.Select(r => r.User)); api.Queue(getUsersRequest = userRequest); break; @@ -223,7 +214,7 @@ namespace osu.Game.Overlays break; default: Users = null; - recreatePanels(Filter.DisplayStyleControl.DisplayStyle.Value); + clearPanels(); break; } }