From 2d0f4d38598c3fbbd05f6423298d36f6a1bbb830 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 25 Oct 2017 19:26:46 +0900 Subject: [PATCH 1/4] Fix OnlineBeatmapSetID not being correctly populated --- osu.Game/Beatmaps/BeatmapMetadata.cs | 1 + osu.Game/Online/API/Requests/GetBeatmapSetsResponse.cs | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapMetadata.cs b/osu.Game/Beatmaps/BeatmapMetadata.cs index 747ffd0a40..89f9ebf47a 100644 --- a/osu.Game/Beatmaps/BeatmapMetadata.cs +++ b/osu.Game/Beatmaps/BeatmapMetadata.cs @@ -17,6 +17,7 @@ namespace osu.Game.Beatmaps private int? onlineBeatmapSetID; [NotMapped] + [JsonProperty(@"id")] public int? OnlineBeatmapSetID { get { return onlineBeatmapSetID; } diff --git a/osu.Game/Online/API/Requests/GetBeatmapSetsResponse.cs b/osu.Game/Online/API/Requests/GetBeatmapSetsResponse.cs index b3bdab2616..f2ca0c1a2f 100644 --- a/osu.Game/Online/API/Requests/GetBeatmapSetsResponse.cs +++ b/osu.Game/Online/API/Requests/GetBeatmapSetsResponse.cs @@ -9,7 +9,7 @@ using osu.Game.Rulesets; namespace osu.Game.Online.API.Requests { - public class GetBeatmapSetsResponse : BeatmapMetadata + public class GetBeatmapSetsResponse : BeatmapMetadata // todo: this is a bit wrong... { [JsonProperty(@"covers")] private BeatmapSetOnlineCovers covers { get; set; } @@ -23,9 +23,6 @@ namespace osu.Game.Online.API.Requests [JsonProperty(@"favourite_count")] private int favouriteCount { get; set; } - [JsonProperty(@"id")] - private int onlineId { get; set; } - [JsonProperty(@"user_id")] private long creatorId { set { Author.Id = value; } @@ -38,7 +35,7 @@ namespace osu.Game.Online.API.Requests { return new BeatmapSetInfo { - OnlineBeatmapSetID = onlineId, + OnlineBeatmapSetID = OnlineBeatmapSetID, Metadata = this, OnlineInfo = new BeatmapSetOnlineInfo { From 90af47271778c86b44cfc1c19fa9d4d939cb2568 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 25 Oct 2017 22:14:36 +0900 Subject: [PATCH 2/4] Cache available rulesets as they are pretty static for now --- osu.Game/Rulesets/RulesetStore.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/RulesetStore.cs b/osu.Game/Rulesets/RulesetStore.cs index 4208d0edad..7aba62e4f1 100644 --- a/osu.Game/Rulesets/RulesetStore.cs +++ b/osu.Game/Rulesets/RulesetStore.cs @@ -41,7 +41,7 @@ namespace osu.Game.Rulesets /// /// All available rulesets. /// - public IEnumerable AvailableRulesets => GetContext().RulesetInfo.Where(r => r.Available); + public IEnumerable AvailableRulesets; private static Assembly currentDomain_AssemblyResolve(object sender, ResolveEventArgs args) => loaded_assemblies.Keys.FirstOrDefault(a => a.FullName == args.Name); @@ -93,6 +93,8 @@ namespace osu.Game.Rulesets } context.SaveChanges(); + + AvailableRulesets = context.RulesetInfo.Where(r => r.Available).ToList(); } private static void loadRulesetFromFile(string file) From ed84cd2035a1d4624c0ef15014249ee8ba03c699 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 25 Oct 2017 19:32:00 +0900 Subject: [PATCH 3/4] Greatly improve performance of direct panel loading Still needs to be async'd --- osu.Game/Overlays/DirectOverlay.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 14110724ea..5fbb78f82e 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -274,11 +274,12 @@ namespace osu.Game.Overlays Filter.DisplayStyleControl.Dropdown.Current.Value, Filter.Tabs.Current.Value); //todo: sort direction (?) - getSetsRequest.Success += r => + getSetsRequest.Success += response => { - BeatmapSets = r?. - Select(response => response.ToBeatmapSet(rulesets)). - Where(b => beatmaps.QueryBeatmapSet(q => q.OnlineBeatmapSetID == b.OnlineBeatmapSetID) == null); + var onlineIds = response.Select(r => r.OnlineBeatmapSetID); + var presentOnlineIds = beatmaps.QueryBeatmapSets(s => onlineIds.Contains(s.OnlineBeatmapSetID)).Select(r => r.OnlineBeatmapSetID).ToList(); + + BeatmapSets = response.Select(r => r.ToBeatmapSet(rulesets)).Where(b => !presentOnlineIds.Contains(b.OnlineBeatmapSetID)); recreatePanels(Filter.DisplayStyleControl.DisplayStyle.Value); }; From da01e81fc47a06cdbc4d9854e74cd705aa872703 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 25 Oct 2017 19:43:14 +0900 Subject: [PATCH 4/4] Async direct panel lookup --- osu.Game/Overlays/DirectOverlay.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 5fbb78f82e..d11f2342cd 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using OpenTK; using osu.Framework.Allocation; using osu.Framework.Configuration; @@ -65,9 +66,7 @@ namespace osu.Game.Overlays ResultAmounts = new ResultCounts(distinctCount(artists), distinctCount(songs), distinctCount(tags)); - if (beatmapSets.Any() && panels == null) - // real use case? currently only seems to be for test case - recreatePanels(Filter.DisplayStyleControl.DisplayStyle.Value); + recreatePanels(Filter.DisplayStyleControl.DisplayStyle.Value); } } @@ -276,12 +275,15 @@ namespace osu.Game.Overlays getSetsRequest.Success += response => { - var onlineIds = response.Select(r => r.OnlineBeatmapSetID); - var presentOnlineIds = beatmaps.QueryBeatmapSets(s => onlineIds.Contains(s.OnlineBeatmapSetID)).Select(r => r.OnlineBeatmapSetID).ToList(); + Task.Run(() => + { + var onlineIds = response.Select(r => r.OnlineBeatmapSetID).ToList(); + var presentOnlineIds = beatmaps.QueryBeatmapSets(s => onlineIds.Contains(s.OnlineBeatmapSetID)).Select(r => r.OnlineBeatmapSetID).ToList(); + var sets = response.Select(r => r.ToBeatmapSet(rulesets)).Where(b => !presentOnlineIds.Contains(b.OnlineBeatmapSetID)).ToList(); - BeatmapSets = response.Select(r => r.ToBeatmapSet(rulesets)).Where(b => !presentOnlineIds.Contains(b.OnlineBeatmapSetID)); - - recreatePanels(Filter.DisplayStyleControl.DisplayStyle.Value); + // may not need scheduling; loads async internally. + Schedule(() => BeatmapSets = sets); + }); }; api.Queue(getSetsRequest);