From ab32e962ca90a4a73ce88e7ec9f90f0dd4de7ff8 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sun, 28 May 2017 00:37:55 -0300 Subject: [PATCH 01/28] Make BeatmapOnlineInfo and BeatmapSetOnlineInfo separate classes, -OnlineWorkingBeatmap --- .../Tests/TestCaseDirect.cs | 56 +++++++++---------- osu.Game/Database/BeatmapMetadata.cs | 6 +- osu.Game/Database/BeatmapOnlineInfo.cs | 20 ++----- osu.Game/Database/BeatmapSetInfo.cs | 3 + osu.Game/Database/BeatmapSetOnlineInfo.cs | 38 +++++++++++++ osu.Game/Database/OnlineWorkingBeatmap.cs | 37 ------------ osu.Game/Overlays/Direct/DirectGridPanel.cs | 4 +- osu.Game/Overlays/Direct/DirectListPanel.cs | 4 +- osu.Game/Overlays/Direct/DirectPanel.cs | 20 ++++++- osu.Game/osu.Game.csproj | 2 +- 10 files changed, 102 insertions(+), 88 deletions(-) create mode 100644 osu.Game/Database/BeatmapSetOnlineInfo.cs delete mode 100644 osu.Game/Database/OnlineWorkingBeatmap.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs index 4cda14559f..9315e75254 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs @@ -48,6 +48,13 @@ namespace osu.Desktop.VisualTests.Tests Author = @"RLC", Source = @"", }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new[] { @"https://assets.ppy.sh//beatmaps/578332/covers/cover.jpg?1494591390" }, + Preview = @"https://b.ppy.sh/preview/578332.mp3", + PlayCount = 97, + FavouriteCount = 72, + }, Beatmaps = new List { new BeatmapInfo @@ -55,13 +62,6 @@ namespace osu.Desktop.VisualTests.Tests Ruleset = ruleset, StarDifficulty = 5.35f, Metadata = new BeatmapMetadata(), - OnlineInfo = new BeatmapOnlineInfo - { - Covers = new[] { @"https://assets.ppy.sh//beatmaps/578332/covers/cover.jpg?1494591390" }, - Preview = @"https://b.ppy.sh/preview/578332.mp3", - PlayCount = 97, - FavouriteCount = 72, - }, }, }, }, @@ -74,6 +74,13 @@ namespace osu.Desktop.VisualTests.Tests Author = @"Sotarks", Source = @"ぎんぎつね", }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new[] { @"https://assets.ppy.sh//beatmaps/599627/covers/cover.jpg?1494539318" }, + Preview = @"https//b.ppy.sh/preview/599627.mp3", + PlayCount = 3082, + FavouriteCount = 14, + }, Beatmaps = new List { new BeatmapInfo @@ -81,13 +88,6 @@ namespace osu.Desktop.VisualTests.Tests Ruleset = ruleset, StarDifficulty = 5.81f, Metadata = new BeatmapMetadata(), - OnlineInfo = new BeatmapOnlineInfo - { - Covers = new[] { @"https://assets.ppy.sh//beatmaps/599627/covers/cover.jpg?1494539318" }, - Preview = @"https//b.ppy.sh/preview/599627.mp3", - PlayCount = 3082, - FavouriteCount = 14, - }, }, }, }, @@ -100,6 +100,13 @@ namespace osu.Desktop.VisualTests.Tests Author = @"Cerulean Veyron", Source = @"", }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new[] { @"https://assets.ppy.sh//beatmaps/513268/covers/cover.jpg?1494502863" }, + Preview = @"https//b.ppy.sh/preview/513268.mp3", + PlayCount = 2762, + FavouriteCount = 15, + }, Beatmaps = new List { new BeatmapInfo @@ -107,13 +114,6 @@ namespace osu.Desktop.VisualTests.Tests Ruleset = ruleset, StarDifficulty = 0.9f, Metadata = new BeatmapMetadata(), - OnlineInfo = new BeatmapOnlineInfo - { - Covers = new[] { @"https://assets.ppy.sh//beatmaps/513268/covers/cover.jpg?1494502863" }, - Preview = @"https//b.ppy.sh/preview/513268.mp3", - PlayCount = 2762, - FavouriteCount = 15, - }, }, new BeatmapInfo { @@ -141,6 +141,13 @@ namespace osu.Desktop.VisualTests.Tests Author = @"[Kamiya]", Source = @"小林さんちのメイドラゴン", }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new[] { @"https://assets.ppy.sh//beatmaps/586841/covers/cover.jpg?1494052741" }, + Preview = @"https//b.ppy.sh/preview/586841.mp3", + PlayCount = 62317, + FavouriteCount = 161, + }, Beatmaps = new List { new BeatmapInfo @@ -148,13 +155,6 @@ namespace osu.Desktop.VisualTests.Tests Ruleset = ruleset, StarDifficulty = 1.26f, Metadata = new BeatmapMetadata(), - OnlineInfo = new BeatmapOnlineInfo - { - Covers = new[] { @"https://assets.ppy.sh//beatmaps/586841/covers/cover.jpg?1494052741" }, - Preview = @"https//b.ppy.sh/preview/586841.mp3", - PlayCount = 62317, - FavouriteCount = 161, - }, }, new BeatmapInfo { diff --git a/osu.Game/Database/BeatmapMetadata.cs b/osu.Game/Database/BeatmapMetadata.cs index 04700b3caa..a038b9cd19 100644 --- a/osu.Game/Database/BeatmapMetadata.cs +++ b/osu.Game/Database/BeatmapMetadata.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Linq; +using Newtonsoft.Json; using SQLite.Net.Attributes; namespace osu.Game.Database @@ -17,7 +18,10 @@ namespace osu.Game.Database public string TitleUnicode { get; set; } public string Artist { get; set; } public string ArtistUnicode { get; set; } + + [JsonProperty(@"creator")] public string Author { get; set; } + public string Source { get; set; } public string Tags { get; set; } public int PreviewTime { get; set; } @@ -35,4 +39,4 @@ namespace osu.Game.Database Tags }.Where(s => !string.IsNullOrEmpty(s)).ToArray(); } -} \ No newline at end of file +} diff --git a/osu.Game/Database/BeatmapOnlineInfo.cs b/osu.Game/Database/BeatmapOnlineInfo.cs index bcb2ef16ac..7740545d6e 100644 --- a/osu.Game/Database/BeatmapOnlineInfo.cs +++ b/osu.Game/Database/BeatmapOnlineInfo.cs @@ -11,28 +11,16 @@ namespace osu.Game.Database /// public class BeatmapOnlineInfo { - /// - /// The different sizes of cover art for this beatmap: cover, cover@2x, card, card@2x, list, list@2x. - /// - [JsonProperty(@"covers")] - public IEnumerable Covers { get; set; } - - /// - /// A small sample clip of this beatmap's song. - /// - [JsonProperty(@"previewUrl")] - public string Preview { get; set; } - /// /// The amount of plays this beatmap has. /// - [JsonProperty(@"play_count")] + [JsonProperty(@"playcount")] public int PlayCount { get; set; } /// - /// The amount of people who have favourited this map. + /// The amount of passes this beatmap has. /// - [JsonProperty(@"favourite_count")] - public int FavouriteCount { get; set; } + [JsonProperty(@"passcount")] + public int PassCount { get; set; } } } diff --git a/osu.Game/Database/BeatmapSetInfo.cs b/osu.Game/Database/BeatmapSetInfo.cs index 0875d3c01f..cf983d18d7 100644 --- a/osu.Game/Database/BeatmapSetInfo.cs +++ b/osu.Game/Database/BeatmapSetInfo.cs @@ -24,6 +24,9 @@ namespace osu.Game.Database [OneToMany(CascadeOperations = CascadeOperation.All)] public List Beatmaps { get; set; } + [Ignore] + public BeatmapSetOnlineInfo OnlineInfo { get; set; } + public double MaxStarDifficulty => Beatmaps.Max(b => b.StarDifficulty); [Indexed] diff --git a/osu.Game/Database/BeatmapSetOnlineInfo.cs b/osu.Game/Database/BeatmapSetOnlineInfo.cs new file mode 100644 index 0000000000..b1807868ad --- /dev/null +++ b/osu.Game/Database/BeatmapSetOnlineInfo.cs @@ -0,0 +1,38 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace osu.Game.Database +{ + /// + /// Beatmap set info retrieved for previewing locally without having the set downloaded. + /// + public class BeatmapSetOnlineInfo + { + /// + /// The different sizes of cover art for this beatmap: cover, cover@2x, card, card@2x, list, list@2x. + /// + [JsonProperty(@"covers")] + public IEnumerable Covers { get; set; } + + /// + /// A small sample clip of this beatmap's song. + /// + [JsonProperty(@"previewUrl")] + public string Preview { get; set; } + + /// + /// The amount of plays this set has. + /// + [JsonProperty(@"play_count")] + public int PlayCount { get; set; } + + /// + /// The amount of people who have favourited this map. + /// + [JsonProperty(@"favourite_count")] + public int FavouriteCount { get; set; } + } +} diff --git a/osu.Game/Database/OnlineWorkingBeatmap.cs b/osu.Game/Database/OnlineWorkingBeatmap.cs deleted file mode 100644 index 1465c59434..0000000000 --- a/osu.Game/Database/OnlineWorkingBeatmap.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System.Linq; -using osu.Framework.Audio.Track; -using osu.Framework.Graphics.Textures; -using osu.Game.Beatmaps; - -namespace osu.Game.Database -{ - internal class OnlineWorkingBeatmap : WorkingBeatmap - { - private readonly TextureStore textures; - private readonly TrackManager tracks; - - public OnlineWorkingBeatmap(BeatmapInfo beatmapInfo, TextureStore textures, TrackManager tracks) : base(beatmapInfo) - { - this.textures = textures; - this.tracks = tracks; - } - - protected override Beatmap GetBeatmap() - { - return new Beatmap(); - } - - protected override Texture GetBackground() - { - return textures.Get(BeatmapInfo.OnlineInfo.Covers.FirstOrDefault()); - } - - protected override Track GetTrack() - { - return tracks.Get(BeatmapInfo.OnlineInfo.Preview); - } - } -} diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 4be68157d7..1301d961f3 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -180,11 +180,11 @@ namespace osu.Game.Overlays.Direct Margin = new MarginPadding { Top = vertical_padding, Right = vertical_padding }, Children = new[] { - new Statistic(FontAwesome.fa_play_circle, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.PlayCount ?? 0) + new Statistic(FontAwesome.fa_play_circle, SetInfo.OnlineInfo?.PlayCount ?? 0) { Margin = new MarginPadding { Right = 1 }, }, - new Statistic(FontAwesome.fa_heart, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.FavouriteCount ?? 0), + new Statistic(FontAwesome.fa_heart, SetInfo.OnlineInfo?.FavouriteCount ?? 0), }, }, }; diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index 48636a5228..aae906a644 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -104,11 +104,11 @@ namespace osu.Game.Overlays.Direct Margin = new MarginPadding { Right = height - vertical_padding * 2 + vertical_padding }, Children = new Drawable[] { - new Statistic(FontAwesome.fa_play_circle, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.PlayCount ?? 0) + new Statistic(FontAwesome.fa_play_circle, SetInfo.OnlineInfo?.PlayCount ?? 0) { Margin = new MarginPadding { Right = 1 }, }, - new Statistic(FontAwesome.fa_heart, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.FavouriteCount ?? 0), + new Statistic(FontAwesome.fa_heart, SetInfo.OnlineInfo?.FavouriteCount ?? 0), new FillFlowContainer { Anchor = Anchor.TopRight, diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index 8a56cf392e..61cdbf1b4c 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using OpenTK; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -36,7 +37,7 @@ namespace osu.Game.Overlays.Direct protected Drawable GetBackground(TextureStore textures) { - return new AsyncLoadWrapper(new BeatmapBackgroundSprite(new OnlineWorkingBeatmap(SetInfo.Beatmaps.FirstOrDefault(), textures, null)) + return new AsyncLoadWrapper(new BeatmapSetBackgroundSprite(SetInfo) { FillMode = FillMode.Fill, OnLoadComplete = d => d.FadeInFromZero(400, EasingTypes.Out), @@ -84,5 +85,22 @@ namespace osu.Game.Overlays.Direct Value = value; } } + + private class BeatmapSetBackgroundSprite : Sprite + { + private readonly BeatmapSetInfo set; + + public BeatmapSetBackgroundSprite(BeatmapSetInfo set) + { + this.set = set; + } + + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + if (set.OnlineInfo?.Covers.FirstOrDefault() != null) + Texture = textures.Get(set.OnlineInfo.Covers.First()); + } + } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 25b692151f..0481044c3c 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -445,11 +445,11 @@ - + From 8745948a01ceb49d34af56f754f6ea72d05e0f08 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sun, 28 May 2017 02:26:25 -0300 Subject: [PATCH 02/28] Basic searching in osu!direct, move BeatmapSetOnlineInfo covers into their own class --- .../Tests/TestCaseDirect.cs | 8 +- osu.Game/Database/BeatmapSetOnlineInfo.cs | 22 ++++- .../API/Requests/GetBeatmapSetsRequest.cs | 86 +++++++++++++++++++ osu.Game/Overlays/Direct/DirectPanel.cs | 4 +- osu.Game/Overlays/Direct/FilterControl.cs | 2 + osu.Game/Overlays/DirectOverlay.cs | 36 +++++++- osu.Game/osu.Game.csproj | 1 + 7 files changed, 150 insertions(+), 9 deletions(-) create mode 100644 osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs index 9315e75254..0531ab0aaa 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs @@ -50,7 +50,7 @@ namespace osu.Desktop.VisualTests.Tests }, OnlineInfo = new BeatmapSetOnlineInfo { - Covers = new[] { @"https://assets.ppy.sh//beatmaps/578332/covers/cover.jpg?1494591390" }, + Covers = new BeatmapSetOnlineCovers { Card = @"https://assets.ppy.sh//beatmaps/578332/covers/cover.jpg?1494591390" }, Preview = @"https://b.ppy.sh/preview/578332.mp3", PlayCount = 97, FavouriteCount = 72, @@ -76,7 +76,7 @@ namespace osu.Desktop.VisualTests.Tests }, OnlineInfo = new BeatmapSetOnlineInfo { - Covers = new[] { @"https://assets.ppy.sh//beatmaps/599627/covers/cover.jpg?1494539318" }, + Covers = new BeatmapSetOnlineCovers { Card = @"https://assets.ppy.sh//beatmaps/599627/covers/cover.jpg?1494539318" }, Preview = @"https//b.ppy.sh/preview/599627.mp3", PlayCount = 3082, FavouriteCount = 14, @@ -102,7 +102,7 @@ namespace osu.Desktop.VisualTests.Tests }, OnlineInfo = new BeatmapSetOnlineInfo { - Covers = new[] { @"https://assets.ppy.sh//beatmaps/513268/covers/cover.jpg?1494502863" }, + Covers = new BeatmapSetOnlineCovers { Card = @"https://assets.ppy.sh//beatmaps/513268/covers/cover.jpg?1494502863" }, Preview = @"https//b.ppy.sh/preview/513268.mp3", PlayCount = 2762, FavouriteCount = 15, @@ -143,7 +143,7 @@ namespace osu.Desktop.VisualTests.Tests }, OnlineInfo = new BeatmapSetOnlineInfo { - Covers = new[] { @"https://assets.ppy.sh//beatmaps/586841/covers/cover.jpg?1494052741" }, + Covers = new BeatmapSetOnlineCovers { Card = @"https://assets.ppy.sh//beatmaps/586841/covers/cover.jpg?1494052741" }, Preview = @"https//b.ppy.sh/preview/586841.mp3", PlayCount = 62317, FavouriteCount = 161, diff --git a/osu.Game/Database/BeatmapSetOnlineInfo.cs b/osu.Game/Database/BeatmapSetOnlineInfo.cs index b1807868ad..87859bf761 100644 --- a/osu.Game/Database/BeatmapSetOnlineInfo.cs +++ b/osu.Game/Database/BeatmapSetOnlineInfo.cs @@ -12,10 +12,10 @@ namespace osu.Game.Database public class BeatmapSetOnlineInfo { /// - /// The different sizes of cover art for this beatmap: cover, cover@2x, card, card@2x, list, list@2x. + /// The different sizes of cover art for this beatmap. /// [JsonProperty(@"covers")] - public IEnumerable Covers { get; set; } + public BeatmapSetOnlineCovers Covers { get; set; } /// /// A small sample clip of this beatmap's song. @@ -35,4 +35,22 @@ namespace osu.Game.Database [JsonProperty(@"favourite_count")] public int FavouriteCount { get; set; } } + + public class BeatmapSetOnlineCovers + { + public string Cover { get; set; } + + [JsonProperty(@"cover@2x")] + public string Cover2x { get; set; } + + public string Card { get; set; } + + [JsonProperty(@"card@2x")] + public string Card2x { get; set; } + + public string List { get; set; } + + [JsonProperty(@"list@2x")] + public string List2x { get; set; } + } } diff --git a/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs new file mode 100644 index 0000000000..5bdf3062cf --- /dev/null +++ b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs @@ -0,0 +1,86 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; +using System.Linq; +using Newtonsoft.Json; +using osu.Game.Database; + +namespace osu.Game.Online.API.Requests +{ + public class GetBeatmapSetsRequest : APIRequest> + { + private readonly string query; + + public GetBeatmapSetsRequest(string query) + { + this.query = System.Uri.EscapeDataString(query); + } + + protected override string Target => $@"beatmapsets/search?q={query}"; + } + + public class GetBeatmapSetsResponse : BeatmapMetadata + { + [JsonProperty(@"covers")] + private BeatmapSetOnlineCovers covers { get; set; } + + [JsonProperty(@"previewUrl")] + private string preview { get; set; } + + [JsonProperty(@"play_count")] + private int playCount { get; set; } + + [JsonProperty(@"favourite_count")] + private int favouriteCount { get; set; } + + [JsonProperty(@"beatmaps")] + private IEnumerable beatmaps { get; set; } + + public BeatmapSetInfo ToSetInfo(RulesetDatabase rulesets) + { + return new BeatmapSetInfo + { + Metadata = this, + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = covers, + Preview = preview, + PlayCount = playCount, + FavouriteCount = favouriteCount, + }, + Beatmaps = beatmaps.Select(b => b.ToBeatmap(rulesets)).ToList(), + }; + } + + private class GetBeatmapSetsBeatmapResponse : BeatmapMetadata + { + [JsonProperty(@"playcount")] + private int playCount { get; set; } + + [JsonProperty(@"passcount")] + private int passCount { get; set; } + + [JsonProperty(@"mode_int")] + private int ruleset { get; set; } + + [JsonProperty(@"difficulty_rating")] + private double starDifficulty { get; set; } + + public BeatmapInfo ToBeatmap(RulesetDatabase rulesets) + { + return new BeatmapInfo + { + Metadata = this, + Ruleset = rulesets.GetRuleset(ruleset), + StarDifficulty = starDifficulty, + OnlineInfo = new BeatmapOnlineInfo + { + PlayCount = playCount, + PassCount = passCount, + }, + }; + } + } + } +} diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index 61cdbf1b4c..cf969df303 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -98,8 +98,8 @@ namespace osu.Game.Overlays.Direct [BackgroundDependencyLoader] private void load(TextureStore textures) { - if (set.OnlineInfo?.Covers.FirstOrDefault() != null) - Texture = textures.Get(set.OnlineInfo.Covers.First()); + if (set.OnlineInfo?.Covers?.Card != null) + Texture = textures.Get(set.OnlineInfo.Covers.Card); } } } diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index 735e14b8c1..db2adbb462 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -129,6 +129,8 @@ namespace osu.Game.Overlays.Direct protected override Color4 BackgroundUnfocused => backgroundColour; protected override Color4 BackgroundFocused => backgroundColour; + protected override bool AllowCommit => true; + private Color4 backgroundColour; [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 0930c825b6..9dab21e428 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -13,6 +13,8 @@ using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Sprites; +using osu.Game.Online.API; +using osu.Game.Online.API.Requests; using osu.Game.Overlays.Direct; using Container = osu.Framework.Graphics.Containers.Container; @@ -24,6 +26,9 @@ namespace osu.Game.Overlays public static readonly int WIDTH_PADDING = 80; private const float panel_padding = 10f; + private APIAccess api; + private RulesetDatabase rulesets; + private readonly FilterControl filter; private readonly FillFlowContainer resultCountsContainer; private readonly OsuSpriteText resultCountsText; @@ -38,6 +43,17 @@ namespace osu.Game.Overlays if (beatmapSets?.Equals(value) ?? false) return; beatmapSets = value; + if (BeatmapSets == null) + { + foreach (var p in panels.Children) + { + p.FadeOut(200); + p.Expire(); + } + + return; + } + recreatePanels(filter.DisplayStyle.Value); } } @@ -155,14 +171,17 @@ namespace osu.Game.Overlays filter.Search.Exit = Hide; filter.Search.Current.ValueChanged += text => { if (text != string.Empty) header.Tabs.Current.Value = DirectTab.Search; }; + filter.Search.OnCommit = (sender, text) => updateSets(); filter.DisplayStyle.ValueChanged += recreatePanels; updateResultCounts(); } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OsuColour colours, APIAccess api, RulesetDatabase rulesets) { + this.api = api; + this.rulesets = rulesets; resultCountsContainer.Colour = colours.Yellow; } @@ -187,6 +206,21 @@ namespace osu.Game.Overlays panels.Children = BeatmapSets.Select(b => displayStyle == PanelDisplayStyle.Grid ? (DirectPanel)new DirectGridPanel(b) { Width = 400 } : new DirectListPanel(b)); } + private GetBeatmapSetsRequest getSetsRequest; + private void updateSets() + { + if (!IsLoaded) return; + + BeatmapSets = null; + getSetsRequest?.Cancel(); + + if (api == null || filter.Search.Text == string.Empty) return; + + getSetsRequest = new GetBeatmapSetsRequest(filter.Search.Text); + getSetsRequest.Success += r => BeatmapSets = r?.Select(response => response.ToSetInfo(rulesets)); + api.Queue(getSetsRequest); + } + protected override bool OnFocus(InputState state) { filter.Search.TriggerFocus(); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 0481044c3c..092e1c0509 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -450,6 +450,7 @@ + From 95cfce29509a25045417df9b4b0a93fa86eefd5d Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sun, 28 May 2017 02:43:37 -0300 Subject: [PATCH 03/28] Rank status filtering --- osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs | 6 ++++-- osu.Game/Overlays/DirectOverlay.cs | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs index 5bdf3062cf..ce5c9f0939 100644 --- a/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs +++ b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs @@ -11,13 +11,15 @@ namespace osu.Game.Online.API.Requests public class GetBeatmapSetsRequest : APIRequest> { private readonly string query; + private readonly RankStatus rankStatus; - public GetBeatmapSetsRequest(string query) + public GetBeatmapSetsRequest(string query, RankStatus rankStatus = RankStatus.Any) { this.query = System.Uri.EscapeDataString(query); + this.rankStatus = rankStatus; } - protected override string Target => $@"beatmapsets/search?q={query}"; + protected override string Target => $@"beatmapsets/search?q={query}&s={(int)rankStatus}"; } public class GetBeatmapSetsResponse : BeatmapMetadata diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 9dab21e428..41b58b7282 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -172,6 +172,7 @@ namespace osu.Game.Overlays filter.Search.Exit = Hide; filter.Search.Current.ValueChanged += text => { if (text != string.Empty) header.Tabs.Current.Value = DirectTab.Search; }; filter.Search.OnCommit = (sender, text) => updateSets(); + filter.RankStatusDropdown.Current.ValueChanged += rankStatus => updateSets(); filter.DisplayStyle.ValueChanged += recreatePanels; updateResultCounts(); @@ -216,7 +217,7 @@ namespace osu.Game.Overlays if (api == null || filter.Search.Text == string.Empty) return; - getSetsRequest = new GetBeatmapSetsRequest(filter.Search.Text); + getSetsRequest = new GetBeatmapSetsRequest(filter.Search.Text, filter.RankStatusDropdown.Current.Value); getSetsRequest.Success += r => BeatmapSets = r?.Select(response => response.ToSetInfo(rulesets)); api.Queue(getSetsRequest); } From 94b3320e58df6801d1d4ccb2430d3da2388cc5c2 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 7 Jun 2017 09:45:12 -0300 Subject: [PATCH 04/28] Center direct panel covers --- osu.Game/Overlays/Direct/DirectPanel.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index cf969df303..f7ff88c24a 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -39,6 +39,8 @@ namespace osu.Game.Overlays.Direct { return new AsyncLoadWrapper(new BeatmapSetBackgroundSprite(SetInfo) { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, FillMode = FillMode.Fill, OnLoadComplete = d => d.FadeInFromZero(400, EasingTypes.Out), }) { RelativeSizeAxes = Axes.Both }; From 3ed740676fce10ae90c1508827e150ffdbbf69ed Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 7 Jun 2017 10:19:17 -0300 Subject: [PATCH 05/28] DirectSortCritera -> DirectSortCriteria --- osu.Game/Overlays/Direct/FilterControl.cs | 6 +++--- osu.Game/Overlays/DirectOverlay.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index 455d0ab77b..ac9b7b1a1e 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -13,12 +13,12 @@ using osu.Game.Overlays.SearchableList; namespace osu.Game.Overlays.Direct { - public class FilterControl : SearchableListFilterControl + public class FilterControl : SearchableListFilterControl { private FillFlowContainer modeButtons; protected override Color4 BackgroundColour => OsuColour.FromHex(@"384552"); - protected override DirectSortCritera DefaultTab => DirectSortCritera.Title; + protected override DirectSortCriteria DefaultTab => DirectSortCriteria.Title; protected override Drawable CreateSupplementaryControls() { modeButtons = new FillFlowContainer @@ -94,7 +94,7 @@ namespace osu.Game.Overlays.Direct } } - public enum DirectSortCritera + public enum DirectSortCriteria { Title, Artist, diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index fb33c72b5e..c7c8a1f0ed 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -16,7 +16,7 @@ using osu.Game.Overlays.Direct; using osu.Game.Overlays.SearchableList; using OpenTK.Graphics; -namespace osu.Game.Overlays +namespace osu.Game.Overlaysi { public class DirectOverlay : SearchableListOverlay { @@ -29,7 +29,7 @@ namespace osu.Game.Overlays private readonly OsuSpriteText resultCountsText; private readonly FillFlowContainer panels; - protected override Color4 BackgroundColour => OsuColour.FromHex(@"485e74"); + protected override Color4 BackgroundColour => OsuColour.FromHexi(@"485e74"); protected override Color4 TrianglesColourLight => OsuColour.FromHex(@"465b71"); protected override Color4 TrianglesColourDark => OsuColour.FromHex(@"3f5265"); From f7f4f5e1552e2d52a88c5754685b6262e498a2a4 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 7 Jun 2017 10:40:18 -0300 Subject: [PATCH 06/28] Request sorting, fix VS Code's "refactoring" --- .../Online/API/Requests/GetBeatmapSetsRequest.cs | 13 +++++++++++-- osu.Game/Overlays/Direct/FilterControl.cs | 2 +- osu.Game/Overlays/DirectOverlay.cs | 11 ++++++----- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs index ce5c9f0939..536da0cc1c 100644 --- a/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs +++ b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs @@ -5,6 +5,8 @@ using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; using osu.Game.Database; +using osu.Game.Overlays; +using osu.Game.Overlays.Direct; namespace osu.Game.Online.API.Requests { @@ -12,14 +14,21 @@ namespace osu.Game.Online.API.Requests { private readonly string query; private readonly RankStatus rankStatus; + private readonly DirectSortCriteria sortCriteria; + private readonly SortDirection direction; + private string directionString => direction == SortDirection.Descending ? @"desc" : @"asc"; - public GetBeatmapSetsRequest(string query, RankStatus rankStatus = RankStatus.Any) + public GetBeatmapSetsRequest(string query, RankStatus rankStatus = RankStatus.Any, DirectSortCriteria sortCriteria = DirectSortCriteria.Ranked, SortDirection direction = SortDirection.Descending) { this.query = System.Uri.EscapeDataString(query); this.rankStatus = rankStatus; + this.sortCriteria = sortCriteria; + this.direction = direction; + + System.Console.WriteLine(Target); } - protected override string Target => $@"beatmapsets/search?q={query}&s={(int)rankStatus}"; + protected override string Target => $@"beatmapsets/search?q={query}&s={(int)rankStatus}&sort={sortCriteria.ToString().ToLower()}_{directionString}"; } public class GetBeatmapSetsResponse : BeatmapMetadata diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index ac9b7b1a1e..31727e2adc 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Direct private FillFlowContainer modeButtons; protected override Color4 BackgroundColour => OsuColour.FromHex(@"384552"); - protected override DirectSortCriteria DefaultTab => DirectSortCriteria.Title; + protected override DirectSortCriteria DefaultTab => DirectSortCriteria.Ranked; protected override Drawable CreateSupplementaryControls() { modeButtons = new FillFlowContainer diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index c7c8a1f0ed..c1ef6930b2 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -16,9 +16,9 @@ using osu.Game.Overlays.Direct; using osu.Game.Overlays.SearchableList; using OpenTK.Graphics; -namespace osu.Game.Overlaysi +namespace osu.Game.Overlays { - public class DirectOverlay : SearchableListOverlay + public class DirectOverlay : SearchableListOverlay { private const float panel_padding = 10f; @@ -29,12 +29,12 @@ namespace osu.Game.Overlaysi private readonly OsuSpriteText resultCountsText; private readonly FillFlowContainer panels; - protected override Color4 BackgroundColour => OsuColour.FromHexi(@"485e74"); + protected override Color4 BackgroundColour => OsuColour.FromHex(@"485e74"); protected override Color4 TrianglesColourLight => OsuColour.FromHex(@"465b71"); protected override Color4 TrianglesColourDark => OsuColour.FromHex(@"3f5265"); protected override SearchableListHeader CreateHeader() => new Header(); - protected override SearchableListFilterControl CreateFilterControl() => new FilterControl(); + protected override SearchableListFilterControl CreateFilterControl() => new FilterControl(); private IEnumerable beatmapSets; public IEnumerable BeatmapSets @@ -117,6 +117,7 @@ namespace osu.Game.Overlaysi Header.Tabs.Current.ValueChanged += tab => { if (tab != DirectTab.Search) Filter.Search.Text = string.Empty; }; Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) Header.Tabs.Current.Value = DirectTab.Search; }; Filter.Search.OnCommit = (sender, text) => updateSets(); + Filter.Tabs.Current.ValueChanged += sortCriteria => updateSets(); Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels; Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += rankStatus => updateSets(); @@ -162,7 +163,7 @@ namespace osu.Game.Overlaysi if (api == null || Filter.Search.Text == string.Empty) return; - getSetsRequest = new GetBeatmapSetsRequest(Filter.Search.Text, Filter.DisplayStyleControl.Dropdown.Current.Value); + getSetsRequest = new GetBeatmapSetsRequest(Filter.Search.Text, Filter.DisplayStyleControl.Dropdown.Current.Value, Filter.Tabs.Current.Value); //todo: sort direction getSetsRequest.Success += r => BeatmapSets = r?.Select(response => response.ToSetInfo(rulesets)); api.Queue(getSetsRequest); } From 312fd16631559871a425888834c60de79c6e5c2e Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 7 Jun 2017 11:00:05 -0300 Subject: [PATCH 07/28] Ruleset filtering --- osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs | 8 ++++---- osu.Game/Overlays/Direct/FilterControl.cs | 6 ++++-- osu.Game/Overlays/DirectOverlay.cs | 7 ++++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs index 536da0cc1c..f3f670138a 100644 --- a/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs +++ b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs @@ -13,22 +13,22 @@ namespace osu.Game.Online.API.Requests public class GetBeatmapSetsRequest : APIRequest> { private readonly string query; + private readonly RulesetInfo ruleset; private readonly RankStatus rankStatus; private readonly DirectSortCriteria sortCriteria; private readonly SortDirection direction; private string directionString => direction == SortDirection.Descending ? @"desc" : @"asc"; - public GetBeatmapSetsRequest(string query, RankStatus rankStatus = RankStatus.Any, DirectSortCriteria sortCriteria = DirectSortCriteria.Ranked, SortDirection direction = SortDirection.Descending) + public GetBeatmapSetsRequest(string query, RulesetInfo ruleset, RankStatus rankStatus = RankStatus.Any, DirectSortCriteria sortCriteria = DirectSortCriteria.Ranked, SortDirection direction = SortDirection.Descending) { this.query = System.Uri.EscapeDataString(query); + this.ruleset = ruleset; this.rankStatus = rankStatus; this.sortCriteria = sortCriteria; this.direction = direction; - - System.Console.WriteLine(Target); } - protected override string Target => $@"beatmapsets/search?q={query}&s={(int)rankStatus}&sort={sortCriteria.ToString().ToLower()}_{directionString}"; + protected override string Target => $@"beatmapsets/search?q={query}&m={ruleset.ID ?? 0}&s={(int)rankStatus}&sort={sortCriteria.ToString().ToLower()}_{directionString}"; } public class GetBeatmapSetsResponse : BeatmapMetadata diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index 31727e2adc..b6682a2768 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -10,11 +10,13 @@ using osu.Framework.Graphics.Containers; using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Overlays.SearchableList; +using osu.Game.Rulesets; namespace osu.Game.Overlays.Direct { public class FilterControl : SearchableListFilterControl { + public readonly Bindable Ruleset = new Bindable(); private FillFlowContainer modeButtons; protected override Color4 BackgroundColour => OsuColour.FromHex(@"384552"); @@ -35,10 +37,10 @@ namespace osu.Game.Overlays.Direct { DisplayStyleControl.Dropdown.AccentColour = colours.BlueDark; - var b = new Bindable(); //backup bindable incase the game is null + Ruleset.BindTo(game?.Ruleset ?? new Bindable()); foreach (var r in rulesets.AllRulesets) { - modeButtons.Add(new RulesetToggleButton(game?.Ruleset ?? b, r)); + modeButtons.Add(new RulesetToggleButton(Ruleset, r)); } } diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index c1ef6930b2..a487bc6af3 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -117,6 +117,7 @@ namespace osu.Game.Overlays Header.Tabs.Current.ValueChanged += tab => { if (tab != DirectTab.Search) Filter.Search.Text = string.Empty; }; Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) Header.Tabs.Current.Value = DirectTab.Search; }; Filter.Search.OnCommit = (sender, text) => updateSets(); + ((FilterControl)Filter).Ruleset.ValueChanged += ruleset => updateSets(); Filter.Tabs.Current.ValueChanged += sortCriteria => updateSets(); Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels; Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += rankStatus => updateSets(); @@ -163,7 +164,11 @@ namespace osu.Game.Overlays if (api == null || Filter.Search.Text == string.Empty) return; - getSetsRequest = new GetBeatmapSetsRequest(Filter.Search.Text, Filter.DisplayStyleControl.Dropdown.Current.Value, Filter.Tabs.Current.Value); //todo: sort direction + getSetsRequest = new GetBeatmapSetsRequest(Filter.Search.Text, + ((FilterControl)Filter).Ruleset.Value, + Filter.DisplayStyleControl.Dropdown.Current.Value, + Filter.Tabs.Current.Value); //todo: sort direction + getSetsRequest.Success += r => BeatmapSets = r?.Select(response => response.ToSetInfo(rulesets)); api.Queue(getSetsRequest); } From a4be5c8a785c9af8c91ddbc619d9057682ebe5d5 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 7 Jun 2017 11:13:12 -0300 Subject: [PATCH 08/28] Fix being able to start typing something, change other filters, and have the search use the currently typing query --- osu.Game/Overlays/DirectOverlay.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index a487bc6af3..c2c7c0e306 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -116,7 +116,11 @@ namespace osu.Game.Overlays Header.Tabs.Current.ValueChanged += tab => { if (tab != DirectTab.Search) Filter.Search.Text = string.Empty; }; Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) Header.Tabs.Current.Value = DirectTab.Search; }; - Filter.Search.OnCommit = (sender, text) => updateSets(); + Filter.Search.OnCommit = (sender, text) => + { + lastQuery = Filter.Search.Text; + updateSets(); + }; ((FilterControl)Filter).Ruleset.ValueChanged += ruleset => updateSets(); Filter.Tabs.Current.ValueChanged += sortCriteria => updateSets(); Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels; @@ -155,6 +159,7 @@ namespace osu.Game.Overlays } private GetBeatmapSetsRequest getSetsRequest; + private string lastQuery; private void updateSets() { if (!IsLoaded) return; @@ -164,7 +169,7 @@ namespace osu.Game.Overlays if (api == null || Filter.Search.Text == string.Empty) return; - getSetsRequest = new GetBeatmapSetsRequest(Filter.Search.Text, + getSetsRequest = new GetBeatmapSetsRequest(lastQuery, ((FilterControl)Filter).Ruleset.Value, Filter.DisplayStyleControl.Dropdown.Current.Value, Filter.Tabs.Current.Value); //todo: sort direction From add08e65ffd7e61084f690f8ecbc74917105bc18 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 7 Jun 2017 11:30:52 -0300 Subject: [PATCH 09/28] Result counts displaying --- osu.Game/Database/BeatmapMetadata.cs | 2 ++ osu.Game/Overlays/DirectOverlay.cs | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/osu.Game/Database/BeatmapMetadata.cs b/osu.Game/Database/BeatmapMetadata.cs index a038b9cd19..ccf1a99c2c 100644 --- a/osu.Game/Database/BeatmapMetadata.cs +++ b/osu.Game/Database/BeatmapMetadata.cs @@ -23,6 +23,8 @@ namespace osu.Game.Database public string Author { get; set; } public string Source { get; set; } + + [JsonProperty(@"tags")] public string Tags { get; set; } public int PreviewTime { get; set; } public string AudioFile { get; set; } diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index c2c7c0e306..5619d567f7 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -165,6 +165,7 @@ namespace osu.Game.Overlays if (!IsLoaded) return; BeatmapSets = null; + ResultAmounts = null; getSetsRequest?.Cancel(); if (api == null || Filter.Search.Text == string.Empty) return; @@ -174,10 +175,29 @@ namespace osu.Game.Overlays Filter.DisplayStyleControl.Dropdown.Current.Value, Filter.Tabs.Current.Value); //todo: sort direction - getSetsRequest.Success += r => BeatmapSets = r?.Select(response => response.ToSetInfo(rulesets)); + getSetsRequest.Success += r => + { + BeatmapSets = r?.Select(response => response.ToSetInfo(rulesets)); + + var artists = new List(); + var songs = new List(); + var tags = new List(); + foreach (var s in BeatmapSets) + { + artists.Add(s.Metadata.Artist); + songs.Add(s.Metadata.Title); + tags.AddRange(s.Metadata.Tags.Split(' ')); + } + + ResultAmounts = new ResultCounts(distinctCount(artists), + distinctCount(songs), + distinctCount(tags)); + }; api.Queue(getSetsRequest); } + private int distinctCount(List list) => list.Distinct().ToArray().Length; + public class ResultCounts { public readonly int Artists; From ddc4d45ae88b239485218160435a2c377d0fb5d8 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 7 Jun 2017 11:39:04 -0300 Subject: [PATCH 10/28] Unused usings --- osu.Game/Database/BeatmapOnlineInfo.cs | 1 - osu.Game/Database/BeatmapSetOnlineInfo.cs | 1 - osu.Game/Overlays/Direct/DirectGridPanel.cs | 1 - osu.Game/Overlays/Direct/DirectListPanel.cs | 1 - osu.Game/Overlays/Direct/DirectPanel.cs | 1 - osu.Game/Overlays/Direct/FilterControl.cs | 1 - 6 files changed, 6 deletions(-) diff --git a/osu.Game/Database/BeatmapOnlineInfo.cs b/osu.Game/Database/BeatmapOnlineInfo.cs index 7740545d6e..f4e70388f5 100644 --- a/osu.Game/Database/BeatmapOnlineInfo.cs +++ b/osu.Game/Database/BeatmapOnlineInfo.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using Newtonsoft.Json; -using System.Collections.Generic; namespace osu.Game.Database { diff --git a/osu.Game/Database/BeatmapSetOnlineInfo.cs b/osu.Game/Database/BeatmapSetOnlineInfo.cs index 87859bf761..28461c0447 100644 --- a/osu.Game/Database/BeatmapSetOnlineInfo.cs +++ b/osu.Game/Database/BeatmapSetOnlineInfo.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using Newtonsoft.Json; -using System.Collections.Generic; namespace osu.Game.Database { diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 1301d961f3..4a1fad41d9 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Linq; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index aae906a644..fc44004df6 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -14,7 +14,6 @@ using osu.Game.Database; using osu.Framework.Allocation; using osu.Framework.Localisation; using osu.Framework.Graphics.Textures; -using System.Linq; using osu.Framework.Input; namespace osu.Game.Overlays.Direct diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index f7ff88c24a..1c007dd534 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; -using System.Linq; using OpenTK; using osu.Framework.Allocation; using osu.Framework.Graphics; diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index b6682a2768..ea5936b85a 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -10,7 +10,6 @@ using osu.Framework.Graphics.Containers; using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Overlays.SearchableList; -using osu.Game.Rulesets; namespace osu.Game.Overlays.Direct { From d54100613442034d67cb5fea5770c0d5ed07e4c9 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 7 Jun 2017 12:15:11 -0300 Subject: [PATCH 11/28] Use 2x size covers in list view --- osu.Game/Overlays/Direct/DirectGridPanel.cs | 2 +- osu.Game/Overlays/Direct/DirectListPanel.cs | 2 +- osu.Game/Overlays/Direct/DirectPanel.cs | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 4a1fad41d9..5a1bb609b2 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -58,7 +58,7 @@ namespace osu.Game.Overlays.Direct RelativeSizeAxes = Axes.Both, Colour = Color4.Black, }, - GetBackground(textures), + GetBackground(textures, false), new Box { RelativeSizeAxes = Axes.Both, diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index fc44004df6..c4b941a362 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -56,7 +56,7 @@ namespace osu.Game.Overlays.Direct RelativeSizeAxes = Axes.Both, Colour = Color4.Black, }, - GetBackground(textures), + GetBackground(textures, true), new Box { RelativeSizeAxes = Axes.Both, diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index 1c007dd534..45ca51b4b0 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -34,9 +34,9 @@ namespace osu.Game.Overlays.Direct return icons; } - protected Drawable GetBackground(TextureStore textures) + protected Drawable GetBackground(TextureStore textures, bool doubleSize) { - return new AsyncLoadWrapper(new BeatmapSetBackgroundSprite(SetInfo) + return new AsyncLoadWrapper(new BeatmapSetBackgroundSprite(SetInfo, doubleSize) { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -90,17 +90,19 @@ namespace osu.Game.Overlays.Direct private class BeatmapSetBackgroundSprite : Sprite { private readonly BeatmapSetInfo set; + private readonly bool doubleSize; - public BeatmapSetBackgroundSprite(BeatmapSetInfo set) + public BeatmapSetBackgroundSprite(BeatmapSetInfo set, bool doubleSize) { this.set = set; + this.doubleSize = doubleSize; } [BackgroundDependencyLoader] private void load(TextureStore textures) { if (set.OnlineInfo?.Covers?.Card != null) - Texture = textures.Get(set.OnlineInfo.Covers.Card); + Texture = textures.Get(doubleSize ? set.OnlineInfo.Covers.Card2x : set.OnlineInfo.Covers.Card); } } } From 1162df96be1c3a8043ea6803da1f2d8628a2f38f Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 8 Jun 2017 05:08:12 -0300 Subject: [PATCH 12/28] Use DelayedLoadWrapper in DirectPanel backgrounds --- osu.Game/Overlays/Direct/DirectPanel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index 45ca51b4b0..958fb7ac51 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -36,13 +36,13 @@ namespace osu.Game.Overlays.Direct protected Drawable GetBackground(TextureStore textures, bool doubleSize) { - return new AsyncLoadWrapper(new BeatmapSetBackgroundSprite(SetInfo, doubleSize) + return new DelayedLoadWrapper(new BeatmapSetBackgroundSprite(SetInfo, doubleSize) { Anchor = Anchor.Centre, Origin = Anchor.Centre, FillMode = FillMode.Fill, OnLoadComplete = d => d.FadeInFromZero(400, EasingTypes.Out), - }) { RelativeSizeAxes = Axes.Both }; + }) { RelativeSizeAxes = Axes.Both, TimeBeforeLoad = 300 }; } public class Statistic : FillFlowContainer From 70e12e5d9bee55bcc9e0382ff5a3440378fd88f0 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 8 Jun 2017 06:21:45 -0300 Subject: [PATCH 13/28] Make the header tabs work --- osu.Game/Overlays/Direct/FilterControl.cs | 1 + osu.Game/Overlays/Direct/Header.cs | 6 +++--- osu.Game/Overlays/DirectOverlay.cs | 22 ++++++++++++++++++---- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index ea5936b85a..3667359d94 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -103,5 +103,6 @@ namespace osu.Game.Overlays.Direct Difficulty, Ranked, Rating, + Plays, } } diff --git a/osu.Game/Overlays/Direct/Header.cs b/osu.Game/Overlays/Direct/Header.cs index 000ef473cc..4310a9329f 100644 --- a/osu.Game/Overlays/Direct/Header.cs +++ b/osu.Game/Overlays/Direct/Header.cs @@ -30,10 +30,10 @@ namespace osu.Game.Overlays.Direct { Search, [Description("Newest Maps")] - NewestMaps, + NewestMaps = (int)DirectSortCriteria.Ranked, [Description("Top Rated")] - TopRated, + TopRated = (int)DirectSortCriteria.Rating, [Description("Most Played")] - MostPlayed + MostPlayed = (int)DirectSortCriteria.Plays, } } diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 5619d567f7..b6c8e30764 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -114,7 +114,15 @@ namespace osu.Game.Overlays }, }; - Header.Tabs.Current.ValueChanged += tab => { if (tab != DirectTab.Search) Filter.Search.Text = string.Empty; }; + Header.Tabs.Current.ValueChanged += tab => + { + if (tab != DirectTab.Search) + { + Filter.Search.Text = lastQuery = string.Empty; + Filter.Tabs.Current.Value = (DirectSortCriteria)Header.Tabs.Current.Value; + updateSets(); + } + }; Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) Header.Tabs.Current.Value = DirectTab.Search; }; Filter.Search.OnCommit = (sender, text) => { @@ -122,7 +130,13 @@ namespace osu.Game.Overlays updateSets(); }; ((FilterControl)Filter).Ruleset.ValueChanged += ruleset => updateSets(); - Filter.Tabs.Current.ValueChanged += sortCriteria => updateSets(); + Filter.Tabs.Current.ValueChanged += sortCriteria => + { + if (Header.Tabs.Current.Value != DirectTab.Search && sortCriteria != (DirectSortCriteria)Header.Tabs.Current.Value) + Header.Tabs.Current.Value = DirectTab.Search; + + updateSets(); + }; Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels; Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += rankStatus => updateSets(); @@ -159,7 +173,7 @@ namespace osu.Game.Overlays } private GetBeatmapSetsRequest getSetsRequest; - private string lastQuery; + private string lastQuery = string.Empty; private void updateSets() { if (!IsLoaded) return; @@ -168,7 +182,7 @@ namespace osu.Game.Overlays ResultAmounts = null; getSetsRequest?.Cancel(); - if (api == null || Filter.Search.Text == string.Empty) return; + if (api == null || Filter.Search.Text == string.Empty && Header.Tabs.Current.Value == DirectTab.Search) return; getSetsRequest = new GetBeatmapSetsRequest(lastQuery, ((FilterControl)Filter).Ruleset.Value, From bb103d7878d011f0f43c4adf4c39af863c67db8e Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 8 Jun 2017 06:31:37 -0300 Subject: [PATCH 14/28] Fix being able to commit with an empty query and clearing the results --- osu.Game/Overlays/DirectOverlay.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index b6c8e30764..5e9cc4076d 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -176,18 +176,18 @@ namespace osu.Game.Overlays private string lastQuery = string.Empty; private void updateSets() { - if (!IsLoaded) return; + if (!IsLoaded || Header.Tabs.Current.Value == DirectTab.Search && Filter.Search.Text == string.Empty) return; BeatmapSets = null; ResultAmounts = null; getSetsRequest?.Cancel(); - if (api == null || Filter.Search.Text == string.Empty && Header.Tabs.Current.Value == DirectTab.Search) return; + if (api == null) return; getSetsRequest = new GetBeatmapSetsRequest(lastQuery, ((FilterControl)Filter).Ruleset.Value, Filter.DisplayStyleControl.Dropdown.Current.Value, - Filter.Tabs.Current.Value); //todo: sort direction + Filter.Tabs.Current.Value); //todo: sort direction (?) getSetsRequest.Success += r => { From 30fe7315ee60fd0483abc824fabe412b7d34b858 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 8 Jun 2017 06:47:21 -0300 Subject: [PATCH 15/28] Small cleanup --- osu.Game/Overlays/DirectOverlay.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 5e9cc4076d..4f5bbca219 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -114,6 +114,11 @@ namespace osu.Game.Overlays }, }; + Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) Header.Tabs.Current.Value = DirectTab.Search; }; + ((FilterControl)Filter).Ruleset.ValueChanged += ruleset => updateSets(); + Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels; + Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += rankStatus => updateSets(); + Header.Tabs.Current.ValueChanged += tab => { if (tab != DirectTab.Search) @@ -123,13 +128,13 @@ namespace osu.Game.Overlays updateSets(); } }; - Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) Header.Tabs.Current.Value = DirectTab.Search; }; + Filter.Search.OnCommit = (sender, text) => { lastQuery = Filter.Search.Text; updateSets(); }; - ((FilterControl)Filter).Ruleset.ValueChanged += ruleset => updateSets(); + Filter.Tabs.Current.ValueChanged += sortCriteria => { if (Header.Tabs.Current.Value != DirectTab.Search && sortCriteria != (DirectSortCriteria)Header.Tabs.Current.Value) @@ -137,8 +142,6 @@ namespace osu.Game.Overlays updateSets(); }; - Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels; - Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += rankStatus => updateSets(); updateResultCounts(); } @@ -176,7 +179,7 @@ namespace osu.Game.Overlays private string lastQuery = string.Empty; private void updateSets() { - if (!IsLoaded || Header.Tabs.Current.Value == DirectTab.Search && Filter.Search.Text == string.Empty) return; + if (!IsLoaded || Header.Tabs.Current.Value == DirectTab.Search && (Filter.Search.Text == string.Empty || lastQuery == string.Empty)) return; BeatmapSets = null; ResultAmounts = null; From 69b290519fa81ebd1b37b76d2b67d5ba31a0b718 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 11 Jul 2017 00:28:25 -0300 Subject: [PATCH 16/28] Better BeatmapSetOnlineInfo comments. --- osu.Game/Database/BeatmapSetOnlineInfo.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Database/BeatmapSetOnlineInfo.cs b/osu.Game/Database/BeatmapSetOnlineInfo.cs index 28461c0447..aad565eff9 100644 --- a/osu.Game/Database/BeatmapSetOnlineInfo.cs +++ b/osu.Game/Database/BeatmapSetOnlineInfo.cs @@ -11,25 +11,25 @@ namespace osu.Game.Database public class BeatmapSetOnlineInfo { /// - /// The different sizes of cover art for this beatmap. + /// The different sizes of cover art for this beatmap set. /// [JsonProperty(@"covers")] public BeatmapSetOnlineCovers Covers { get; set; } /// - /// A small sample clip of this beatmap's song. + /// A small sample clip of this beatmap set's song. /// [JsonProperty(@"previewUrl")] public string Preview { get; set; } /// - /// The amount of plays this set has. + /// The amount of plays this beatmap set has. /// [JsonProperty(@"play_count")] public int PlayCount { get; set; } /// - /// The amount of people who have favourited this map. + /// The amount of people who have favourited this beatmap set. /// [JsonProperty(@"favourite_count")] public int FavouriteCount { get; set; } From fbe414d780b6db6c0dfbf4f8320d2ff1c2803e9c Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 11 Jul 2017 01:03:38 -0300 Subject: [PATCH 17/28] Cleanup. --- .../Tests/TestCaseDirect.cs | 24 +++++++++++++++---- .../Tests/TestCaseRoomInspector.cs | 8 +++---- .../API/Requests/GetBeatmapSetsRequest.cs | 2 +- osu.Game/Overlays/DirectOverlay.cs | 2 +- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs index 6cbcb7ef94..acd243d9af 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs @@ -50,7 +50,11 @@ namespace osu.Desktop.VisualTests.Tests }, OnlineInfo = new BeatmapSetOnlineInfo { - Covers = new BeatmapSetOnlineCovers { Card = @"https://assets.ppy.sh//beatmaps/578332/covers/cover.jpg?1494591390" }, + Covers = new BeatmapSetOnlineCovers + { + Card = @"https://assets.ppy.sh/beatmaps/578332/covers/card.jpg?1494591390", + Card2x = @"https://assets.ppy.sh/beatmaps/578332/covers/cover.jpg?1494591390", + }, Preview = @"https://b.ppy.sh/preview/578332.mp3", PlayCount = 97, FavouriteCount = 72, @@ -76,7 +80,11 @@ namespace osu.Desktop.VisualTests.Tests }, OnlineInfo = new BeatmapSetOnlineInfo { - Covers = new BeatmapSetOnlineCovers { Card = @"https://assets.ppy.sh//beatmaps/599627/covers/cover.jpg?1494539318" }, + Covers = new BeatmapSetOnlineCovers + { + Card = @"https://assets.ppy.sh/beatmaps/599627/covers/card.jpg?1494539318", + Card2x = @"https://assets.ppy.sh/beatmaps/599627/covers/cover.jpg?1494539318", + }, Preview = @"https//b.ppy.sh/preview/599627.mp3", PlayCount = 3082, FavouriteCount = 14, @@ -102,7 +110,11 @@ namespace osu.Desktop.VisualTests.Tests }, OnlineInfo = new BeatmapSetOnlineInfo { - Covers = new BeatmapSetOnlineCovers { Card = @"https://assets.ppy.sh//beatmaps/513268/covers/cover.jpg?1494502863" }, + Covers = new BeatmapSetOnlineCovers + { + Card = @"https://assets.ppy.sh/beatmaps/513268/covers/card.jpg?1494502863", + Card2x = @"https://assets.ppy.sh/beatmaps/513268/covers/cover.jpg?1494502863", + }, Preview = @"https//b.ppy.sh/preview/513268.mp3", PlayCount = 2762, FavouriteCount = 15, @@ -143,7 +155,11 @@ namespace osu.Desktop.VisualTests.Tests }, OnlineInfo = new BeatmapSetOnlineInfo { - Covers = new BeatmapSetOnlineCovers { Card = @"https://assets.ppy.sh//beatmaps/586841/covers/cover.jpg?1494052741" }, + Covers = new BeatmapSetOnlineCovers + { + Card = @"https://assets.ppy.sh/beatmaps/586841/covers/card.jpg?1494052741", + Card2x = @"https://assets.ppy.sh/beatmaps/586841/covers/cover.jpg?1494052741", + }, Preview = @"https//b.ppy.sh/preview/586841.mp3", PlayCount = 62317, FavouriteCount = 161, diff --git a/osu.Desktop.VisualTests/Tests/TestCaseRoomInspector.cs b/osu.Desktop.VisualTests/Tests/TestCaseRoomInspector.cs index df5dbe2add..6f01234d02 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseRoomInspector.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseRoomInspector.cs @@ -45,7 +45,7 @@ namespace osu.Desktop.VisualTests.Tests { Covers = new BeatmapSetOnlineCovers { - Cover2x = @"https://assets.ppy.sh//beatmaps/560573/covers/cover.jpg?1492722343", + Cover2x = @"https://assets.ppy.sh/beatmaps/560573/covers/cover.jpg?1492722343", }, }, }, @@ -102,8 +102,8 @@ namespace osu.Desktop.VisualTests.Tests Ruleset = rulesets.GetRuleset(0), Metadata = new BeatmapMetadata { - Title = @"xi", - Artist = @"FREEDOM DIVE", + Title = @"FREEDOM DIVE", + Artist = @"xi", Author = @"Nakagawa-Kanon", }, BeatmapSet = new BeatmapSetInfo @@ -112,7 +112,7 @@ namespace osu.Desktop.VisualTests.Tests { Covers = new BeatmapSetOnlineCovers { - Cover2x = @"https://assets.ppy.sh//beatmaps/39804/covers/cover.jpg?1456506845", + Cover2x = @"https://assets.ppy.sh/beatmaps/39804/covers/cover.jpg?1456506845", }, }, }, diff --git a/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs index f3f670138a..f6f9bf69fd 100644 --- a/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs +++ b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs @@ -48,7 +48,7 @@ namespace osu.Game.Online.API.Requests [JsonProperty(@"beatmaps")] private IEnumerable beatmaps { get; set; } - public BeatmapSetInfo ToSetInfo(RulesetDatabase rulesets) + public BeatmapSetInfo ToBeatmapSet(RulesetDatabase rulesets) { return new BeatmapSetInfo { diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 68a41c06a8..252c542328 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -194,7 +194,7 @@ namespace osu.Game.Overlays getSetsRequest.Success += r => { - BeatmapSets = r?.Select(response => response.ToSetInfo(rulesets)); + BeatmapSets = r?.Select(response => response.ToBeatmapSet(rulesets)); var artists = new List(); var songs = new List(); From c449491c0476c36c9d4d92fa7fac61a659369866 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 11 Jul 2017 01:18:16 -0300 Subject: [PATCH 18/28] Fix RoomInspector covers. --- osu.Game/Screens/Multiplayer/RoomInspector.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Multiplayer/RoomInspector.cs b/osu.Game/Screens/Multiplayer/RoomInspector.cs index 2e17d5eb30..2a3b2cca61 100644 --- a/osu.Game/Screens/Multiplayer/RoomInspector.cs +++ b/osu.Game/Screens/Multiplayer/RoomInspector.cs @@ -539,8 +539,8 @@ namespace osu.Game.Screens.Multiplayer [BackgroundDependencyLoader] private void load(TextureStore textures) { - if (set.OnlineInfo?.Covers?.Card2x != null) - Texture = textures.Get(set.OnlineInfo.Covers.Card2x); + if (set.OnlineInfo?.Covers?.Cover2x != null) + Texture = textures.Get(set.OnlineInfo.Covers.Cover2x); } } } From fc7b4ceff132935ddc5f9dd68e6645c29b51758c Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 11 Jul 2017 01:30:59 -0300 Subject: [PATCH 19/28] Fix osu!direct visual test initially not having a mode selected. --- osu.Game/Overlays/Direct/FilterControl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index 58c519473f..bb6055dc4f 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -37,7 +37,7 @@ namespace osu.Game.Overlays.Direct { DisplayStyleControl.Dropdown.AccentColour = colours.BlueDark; - Ruleset.BindTo(game?.Ruleset ?? new Bindable()); + Ruleset.BindTo(game?.Ruleset ?? new Bindable() { Value = rulesets.GetRuleset(0) }); foreach (var r in rulesets.AllRulesets) { modeButtons.Add(new RulesetToggleButton(Ruleset, r)); From b448603d6c33f9aa68d9dba92cac3c2227b0080b Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 11 Jul 2017 01:42:51 -0300 Subject: [PATCH 20/28] CI fixes. --- osu.Desktop.VisualTests/Tests/TestCaseDirect.cs | 8 ++++---- osu.Desktop.VisualTests/Tests/TestCaseRoomInspector.cs | 4 ++-- osu.Game/Database/BeatmapSetOnlineInfo.cs | 6 +++--- osu.Game/Overlays/Direct/DirectPanel.cs | 2 +- osu.Game/Overlays/Direct/Header.cs | 6 +++--- osu.Game/Overlays/DirectOverlay.cs | 1 + osu.Game/Screens/Multiplayer/RoomInspector.cs | 4 ++-- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs index acd243d9af..fb1dbf01ee 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs @@ -53,7 +53,7 @@ namespace osu.Desktop.VisualTests.Tests Covers = new BeatmapSetOnlineCovers { Card = @"https://assets.ppy.sh/beatmaps/578332/covers/card.jpg?1494591390", - Card2x = @"https://assets.ppy.sh/beatmaps/578332/covers/cover.jpg?1494591390", + Card2X = @"https://assets.ppy.sh/beatmaps/578332/covers/cover.jpg?1494591390", }, Preview = @"https://b.ppy.sh/preview/578332.mp3", PlayCount = 97, @@ -83,7 +83,7 @@ namespace osu.Desktop.VisualTests.Tests Covers = new BeatmapSetOnlineCovers { Card = @"https://assets.ppy.sh/beatmaps/599627/covers/card.jpg?1494539318", - Card2x = @"https://assets.ppy.sh/beatmaps/599627/covers/cover.jpg?1494539318", + Card2X = @"https://assets.ppy.sh/beatmaps/599627/covers/cover.jpg?1494539318", }, Preview = @"https//b.ppy.sh/preview/599627.mp3", PlayCount = 3082, @@ -113,7 +113,7 @@ namespace osu.Desktop.VisualTests.Tests Covers = new BeatmapSetOnlineCovers { Card = @"https://assets.ppy.sh/beatmaps/513268/covers/card.jpg?1494502863", - Card2x = @"https://assets.ppy.sh/beatmaps/513268/covers/cover.jpg?1494502863", + Card2X = @"https://assets.ppy.sh/beatmaps/513268/covers/cover.jpg?1494502863", }, Preview = @"https//b.ppy.sh/preview/513268.mp3", PlayCount = 2762, @@ -158,7 +158,7 @@ namespace osu.Desktop.VisualTests.Tests Covers = new BeatmapSetOnlineCovers { Card = @"https://assets.ppy.sh/beatmaps/586841/covers/card.jpg?1494052741", - Card2x = @"https://assets.ppy.sh/beatmaps/586841/covers/cover.jpg?1494052741", + Card2X = @"https://assets.ppy.sh/beatmaps/586841/covers/cover.jpg?1494052741", }, Preview = @"https//b.ppy.sh/preview/586841.mp3", PlayCount = 62317, diff --git a/osu.Desktop.VisualTests/Tests/TestCaseRoomInspector.cs b/osu.Desktop.VisualTests/Tests/TestCaseRoomInspector.cs index 6f01234d02..0b5fa2384b 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseRoomInspector.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseRoomInspector.cs @@ -45,7 +45,7 @@ namespace osu.Desktop.VisualTests.Tests { Covers = new BeatmapSetOnlineCovers { - Cover2x = @"https://assets.ppy.sh/beatmaps/560573/covers/cover.jpg?1492722343", + Cover2X = @"https://assets.ppy.sh/beatmaps/560573/covers/cover.jpg?1492722343", }, }, }, @@ -112,7 +112,7 @@ namespace osu.Desktop.VisualTests.Tests { Covers = new BeatmapSetOnlineCovers { - Cover2x = @"https://assets.ppy.sh/beatmaps/39804/covers/cover.jpg?1456506845", + Cover2X = @"https://assets.ppy.sh/beatmaps/39804/covers/cover.jpg?1456506845", }, }, }, diff --git a/osu.Game/Database/BeatmapSetOnlineInfo.cs b/osu.Game/Database/BeatmapSetOnlineInfo.cs index aad565eff9..d581137a97 100644 --- a/osu.Game/Database/BeatmapSetOnlineInfo.cs +++ b/osu.Game/Database/BeatmapSetOnlineInfo.cs @@ -40,16 +40,16 @@ namespace osu.Game.Database public string Cover { get; set; } [JsonProperty(@"cover@2x")] - public string Cover2x { get; set; } + public string Cover2X { get; set; } public string Card { get; set; } [JsonProperty(@"card@2x")] - public string Card2x { get; set; } + public string Card2X { get; set; } public string List { get; set; } [JsonProperty(@"list@2x")] - public string List2x { get; set; } + public string List2X { get; set; } } } diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index f2373cb97e..1c2ecd767c 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -103,7 +103,7 @@ namespace osu.Game.Overlays.Direct private void load(TextureStore textures) { if (set.OnlineInfo?.Covers?.Card != null) - Texture = textures.Get(doubleSize ? set.OnlineInfo.Covers.Card2x : set.OnlineInfo.Covers.Card); + Texture = textures.Get(doubleSize ? set.OnlineInfo.Covers.Card2X : set.OnlineInfo.Covers.Card); } } } diff --git a/osu.Game/Overlays/Direct/Header.cs b/osu.Game/Overlays/Direct/Header.cs index 4310a9329f..2c50fb453f 100644 --- a/osu.Game/Overlays/Direct/Header.cs +++ b/osu.Game/Overlays/Direct/Header.cs @@ -30,10 +30,10 @@ namespace osu.Game.Overlays.Direct { Search, [Description("Newest Maps")] - NewestMaps = (int)DirectSortCriteria.Ranked, + NewestMaps = DirectSortCriteria.Ranked, [Description("Top Rated")] - TopRated = (int)DirectSortCriteria.Rating, + TopRated = DirectSortCriteria.Rating, [Description("Most Played")] - MostPlayed = (int)DirectSortCriteria.Plays, + MostPlayed = DirectSortCriteria.Plays, } } diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 252c542328..f186d954d1 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -195,6 +195,7 @@ namespace osu.Game.Overlays getSetsRequest.Success += r => { BeatmapSets = r?.Select(response => response.ToBeatmapSet(rulesets)); + if (BeatmapSets == null) return; var artists = new List(); var songs = new List(); diff --git a/osu.Game/Screens/Multiplayer/RoomInspector.cs b/osu.Game/Screens/Multiplayer/RoomInspector.cs index 2a3b2cca61..d488b1f5a1 100644 --- a/osu.Game/Screens/Multiplayer/RoomInspector.cs +++ b/osu.Game/Screens/Multiplayer/RoomInspector.cs @@ -539,8 +539,8 @@ namespace osu.Game.Screens.Multiplayer [BackgroundDependencyLoader] private void load(TextureStore textures) { - if (set.OnlineInfo?.Covers?.Cover2x != null) - Texture = textures.Get(set.OnlineInfo.Covers.Cover2x); + if (set.OnlineInfo?.Covers?.Cover2X != null) + Texture = textures.Get(set.OnlineInfo.Covers.Cover2X); } } } From a9ff0b5317f19ec3e7257f1a21c7b613b06f3730 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 11 Jul 2017 01:59:52 -0300 Subject: [PATCH 21/28] Make SlimMenu more opaque. --- osu.Game/Overlays/SearchableList/SlimEnumDropdown.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/SearchableList/SlimEnumDropdown.cs b/osu.Game/Overlays/SearchableList/SlimEnumDropdown.cs index 6c0887b5df..e2eec0214f 100644 --- a/osu.Game/Overlays/SearchableList/SlimEnumDropdown.cs +++ b/osu.Game/Overlays/SearchableList/SlimEnumDropdown.cs @@ -34,7 +34,7 @@ namespace osu.Game.Overlays.SearchableList { public SlimMenu() { - Background.Colour = Color4.Black.Opacity(0.25f); + Background.Colour = Color4.Black.Opacity(0.7f); } } } From 2c1f3de47a2551a3f4a92d8860dc883a56c16af0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Jul 2017 10:27:39 +0900 Subject: [PATCH 22/28] Rename 2X resources to be defaults --- osu.Desktop.VisualTests/Tests/TestCaseDirect.cs | 8 ++++---- .../Tests/TestCaseRoomInspector.cs | 4 ++-- osu.Game/Database/BeatmapSetOnlineInfo.cs | 12 ++++++------ osu.Game/Screens/Multiplayer/RoomInspector.cs | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs index fb1dbf01ee..2a20bca836 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs @@ -53,7 +53,7 @@ namespace osu.Desktop.VisualTests.Tests Covers = new BeatmapSetOnlineCovers { Card = @"https://assets.ppy.sh/beatmaps/578332/covers/card.jpg?1494591390", - Card2X = @"https://assets.ppy.sh/beatmaps/578332/covers/cover.jpg?1494591390", + Cover = @"https://assets.ppy.sh/beatmaps/578332/covers/cover.jpg?1494591390", }, Preview = @"https://b.ppy.sh/preview/578332.mp3", PlayCount = 97, @@ -83,7 +83,7 @@ namespace osu.Desktop.VisualTests.Tests Covers = new BeatmapSetOnlineCovers { Card = @"https://assets.ppy.sh/beatmaps/599627/covers/card.jpg?1494539318", - Card2X = @"https://assets.ppy.sh/beatmaps/599627/covers/cover.jpg?1494539318", + Cover = @"https://assets.ppy.sh/beatmaps/599627/covers/cover.jpg?1494539318", }, Preview = @"https//b.ppy.sh/preview/599627.mp3", PlayCount = 3082, @@ -113,7 +113,7 @@ namespace osu.Desktop.VisualTests.Tests Covers = new BeatmapSetOnlineCovers { Card = @"https://assets.ppy.sh/beatmaps/513268/covers/card.jpg?1494502863", - Card2X = @"https://assets.ppy.sh/beatmaps/513268/covers/cover.jpg?1494502863", + Cover = @"https://assets.ppy.sh/beatmaps/513268/covers/cover.jpg?1494502863", }, Preview = @"https//b.ppy.sh/preview/513268.mp3", PlayCount = 2762, @@ -158,7 +158,7 @@ namespace osu.Desktop.VisualTests.Tests Covers = new BeatmapSetOnlineCovers { Card = @"https://assets.ppy.sh/beatmaps/586841/covers/card.jpg?1494052741", - Card2X = @"https://assets.ppy.sh/beatmaps/586841/covers/cover.jpg?1494052741", + Cover = @"https://assets.ppy.sh/beatmaps/586841/covers/cover.jpg?1494052741", }, Preview = @"https//b.ppy.sh/preview/586841.mp3", PlayCount = 62317, diff --git a/osu.Desktop.VisualTests/Tests/TestCaseRoomInspector.cs b/osu.Desktop.VisualTests/Tests/TestCaseRoomInspector.cs index 0b5fa2384b..4d650afed5 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseRoomInspector.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseRoomInspector.cs @@ -45,7 +45,7 @@ namespace osu.Desktop.VisualTests.Tests { Covers = new BeatmapSetOnlineCovers { - Cover2X = @"https://assets.ppy.sh/beatmaps/560573/covers/cover.jpg?1492722343", + Cover = @"https://assets.ppy.sh/beatmaps/560573/covers/cover.jpg?1492722343", }, }, }, @@ -112,7 +112,7 @@ namespace osu.Desktop.VisualTests.Tests { Covers = new BeatmapSetOnlineCovers { - Cover2X = @"https://assets.ppy.sh/beatmaps/39804/covers/cover.jpg?1456506845", + Cover = @"https://assets.ppy.sh/beatmaps/39804/covers/cover.jpg?1456506845", }, }, }, diff --git a/osu.Game/Database/BeatmapSetOnlineInfo.cs b/osu.Game/Database/BeatmapSetOnlineInfo.cs index d581137a97..61d408c94a 100644 --- a/osu.Game/Database/BeatmapSetOnlineInfo.cs +++ b/osu.Game/Database/BeatmapSetOnlineInfo.cs @@ -37,19 +37,19 @@ namespace osu.Game.Database public class BeatmapSetOnlineCovers { - public string Cover { get; set; } + public string CoverLowRes { get; set; } [JsonProperty(@"cover@2x")] - public string Cover2X { get; set; } + public string Cover { get; set; } - public string Card { get; set; } + public string CardLowRes { get; set; } [JsonProperty(@"card@2x")] - public string Card2X { get; set; } + public string Card { get; set; } - public string List { get; set; } + public string ListLowRes { get; set; } [JsonProperty(@"list@2x")] - public string List2X { get; set; } + public string List { get; set; } } } diff --git a/osu.Game/Screens/Multiplayer/RoomInspector.cs b/osu.Game/Screens/Multiplayer/RoomInspector.cs index d488b1f5a1..73783bab12 100644 --- a/osu.Game/Screens/Multiplayer/RoomInspector.cs +++ b/osu.Game/Screens/Multiplayer/RoomInspector.cs @@ -539,8 +539,8 @@ namespace osu.Game.Screens.Multiplayer [BackgroundDependencyLoader] private void load(TextureStore textures) { - if (set.OnlineInfo?.Covers?.Cover2X != null) - Texture = textures.Get(set.OnlineInfo.Covers.Cover2X); + if (set.OnlineInfo?.Covers?.Cover != null) + Texture = textures.Get(set.OnlineInfo.Covers.Cover); } } } From 3f2f42d13cea6802305a010c1cbb0045dff109e9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Jul 2017 10:30:09 +0900 Subject: [PATCH 23/28] Always load high resolution for now Also rename GetBackground to CreateBackground, since it's returning a new instance. --- osu.Game/Overlays/Direct/DirectGridPanel.cs | 2 +- osu.Game/Overlays/Direct/DirectListPanel.cs | 5 ++-- osu.Game/Overlays/Direct/DirectPanel.cs | 33 +++++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 243c5f1a4d..c1777038c0 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -58,7 +58,7 @@ namespace osu.Game.Overlays.Direct RelativeSizeAxes = Axes.Both, Colour = Color4.Black, }, - GetBackground(textures, false), + CreateBackground(), new Box { RelativeSizeAxes = Axes.Both, diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index c2299e8255..f693998563 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -12,7 +12,6 @@ using osu.Game.Graphics.Sprites; using osu.Game.Database; using osu.Framework.Allocation; using osu.Framework.Localisation; -using osu.Framework.Graphics.Textures; using osu.Framework.Input; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics.Containers; @@ -48,7 +47,7 @@ namespace osu.Game.Overlays.Direct } [BackgroundDependencyLoader] - private void load(LocalisationEngine localisation, TextureStore textures) + private void load(LocalisationEngine localisation) { Children = new[] { @@ -57,7 +56,7 @@ namespace osu.Game.Overlays.Direct RelativeSizeAxes = Axes.Both, Colour = Color4.Black, }, - GetBackground(textures, true), + CreateBackground(), new Box { RelativeSizeAxes = Axes.Both, diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index 1c2ecd767c..02b6e32192 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -34,23 +34,25 @@ namespace osu.Game.Overlays.Direct return icons; } - protected Drawable GetBackground(TextureStore textures, bool doubleSize) + protected Drawable CreateBackground() => new DelayedLoadWrapper(new BeatmapSetBackgroundSprite(SetInfo) { - return new DelayedLoadWrapper(new BeatmapSetBackgroundSprite(SetInfo, doubleSize) - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - FillMode = FillMode.Fill, - OnLoadComplete = d => d.FadeInFromZero(400, EasingTypes.Out), - }) { RelativeSizeAxes = Axes.Both, TimeBeforeLoad = 300 }; - } + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + FillMode = FillMode.Fill, + OnLoadComplete = d => d.FadeInFromZero(400, EasingTypes.Out), + }) + { + RelativeSizeAxes = Axes.Both, + TimeBeforeLoad = 300 + }; public class Statistic : FillFlowContainer { private readonly SpriteText text; private int value; + public int Value { get { return value; } @@ -91,19 +93,18 @@ namespace osu.Game.Overlays.Direct private class BeatmapSetBackgroundSprite : Sprite { private readonly BeatmapSetInfo set; - private readonly bool doubleSize; - - public BeatmapSetBackgroundSprite(BeatmapSetInfo set, bool doubleSize) + public BeatmapSetBackgroundSprite(BeatmapSetInfo set) { this.set = set; - this.doubleSize = doubleSize; } [BackgroundDependencyLoader] private void load(TextureStore textures) { - if (set.OnlineInfo?.Covers?.Card != null) - Texture = textures.Get(doubleSize ? set.OnlineInfo.Covers.Card2X : set.OnlineInfo.Covers.Card); + string resource = set.OnlineInfo.Covers.Card; + + if (resource != null) + Texture = textures.Get(resource); } } } From 190ea3bfabb472daef2de7318a665a2b706f72eb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Jul 2017 11:06:28 +0900 Subject: [PATCH 24/28] Remove unnused variable --- osu.Game/Overlays/Direct/DirectGridPanel.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index c1777038c0..3c464af05d 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -7,7 +7,6 @@ using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Textures; using osu.Framework.Localisation; using osu.Game.Database; using osu.Game.Graphics; @@ -49,7 +48,7 @@ namespace osu.Game.Overlays.Direct } [BackgroundDependencyLoader] - private void load(OsuColour colours, LocalisationEngine localisation, TextureStore textures) + private void load(OsuColour colours, LocalisationEngine localisation) { Children = new[] { From e30f0a2e69bcb63e67abc80d11ea490e5339e7a8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Jul 2017 12:20:07 +0900 Subject: [PATCH 25/28] Avoid potentially calling updateSearch more than once in a single update --- osu.Game/Overlays/DirectOverlay.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index f186d954d1..82aef021cd 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -7,6 +7,7 @@ using OpenTK; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Threading; using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; @@ -115,9 +116,9 @@ namespace osu.Game.Overlays }; Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) Header.Tabs.Current.Value = DirectTab.Search; }; - ((FilterControl)Filter).Ruleset.ValueChanged += ruleset => updateSets(); + ((FilterControl)Filter).Ruleset.ValueChanged += ruleset => Scheduler.AddOnce(updateSearch); Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels; - Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += rankStatus => updateSets(); + Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += rankStatus => Scheduler.AddOnce(updateSearch); Header.Tabs.Current.ValueChanged += tab => { @@ -125,7 +126,7 @@ namespace osu.Game.Overlays { Filter.Search.Text = lastQuery = string.Empty; Filter.Tabs.Current.Value = (DirectSortCriteria)Header.Tabs.Current.Value; - updateSets(); + Scheduler.AddOnce(updateSearch); } }; @@ -140,7 +141,7 @@ namespace osu.Game.Overlays if (Header.Tabs.Current.Value != DirectTab.Search && sortCriteria != (DirectSortCriteria)Header.Tabs.Current.Value) Header.Tabs.Current.Value = DirectTab.Search; - updateSets(); + Scheduler.AddOnce(updateSearch); }; updateResultCounts(); @@ -177,7 +178,7 @@ namespace osu.Game.Overlays private GetBeatmapSetsRequest getSetsRequest; private string lastQuery = string.Empty; - private void updateSets() + private void updateSearch() { if (!IsLoaded || Header.Tabs.Current.Value == DirectTab.Search && (Filter.Search.Text == string.Empty || lastQuery == string.Empty)) return; From 4e1a998f9d0e5f4da2c8d91a9f029d83ee765af5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Jul 2017 12:20:32 +0900 Subject: [PATCH 26/28] Don't return so early on empty search (never clears results) --- osu.Game/Overlays/DirectOverlay.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 82aef021cd..83f22c6ad8 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -180,15 +180,18 @@ namespace osu.Game.Overlays private string lastQuery = string.Empty; private void updateSearch() { - if (!IsLoaded || Header.Tabs.Current.Value == DirectTab.Search && (Filter.Search.Text == string.Empty || lastQuery == string.Empty)) return; + if (!IsLoaded) return; BeatmapSets = null; ResultAmounts = null; + getSetsRequest?.Cancel(); if (api == null) return; - getSetsRequest = new GetBeatmapSetsRequest(lastQuery, + if (Header.Tabs.Current.Value == DirectTab.Search && (Filter.Search.Text == string.Empty || currentQuery == string.Empty)) return; + + getSetsRequest = new GetBeatmapSetsRequest(currentQuery, ((FilterControl)Filter).Ruleset.Value, Filter.DisplayStyleControl.Dropdown.Current.Value, Filter.Tabs.Current.Value); //todo: sort direction (?) From 8045e0566f331e5573e174cb2d943bd29aa51797 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Jul 2017 12:22:51 +0900 Subject: [PATCH 27/28] Use a bindable for the current query. Aso debounce and don't require hitting enter. --- osu.Game/Overlays/DirectOverlay.cs | 35 ++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 83f22c6ad8..df5955e7e6 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using OpenTK; using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Threading; @@ -124,18 +125,29 @@ namespace osu.Game.Overlays { if (tab != DirectTab.Search) { - Filter.Search.Text = lastQuery = string.Empty; + currentQuery.Value = string.Empty; Filter.Tabs.Current.Value = (DirectSortCriteria)Header.Tabs.Current.Value; Scheduler.AddOnce(updateSearch); } }; - Filter.Search.OnCommit = (sender, text) => + currentQuery.ValueChanged += v => { - lastQuery = Filter.Search.Text; - updateSets(); + queryChangedDebounce?.Cancel(); + + if (string.IsNullOrEmpty(v)) + Scheduler.AddOnce(updateSearch); + else + { + BeatmapSets = null; + ResultAmounts = null; + + queryChangedDebounce = Scheduler.AddDelayed(updateSearch, 500); + } }; + currentQuery.BindTo(Filter.Search.Current); + Filter.Tabs.Current.ValueChanged += sortCriteria => { if (Header.Tabs.Current.Value != DirectTab.Search && sortCriteria != (DirectSortCriteria)Header.Tabs.Current.Value) @@ -157,7 +169,7 @@ namespace osu.Game.Overlays private void updateResultCounts() { - resultCountsContainer.FadeTo(ResultAmounts == null ? 0f : 1f, 200, EasingTypes.Out); + resultCountsContainer.FadeTo(ResultAmounts == null ? 0f : 1f, 200, EasingTypes.OutQuint); if (ResultAmounts == null) return; resultCountsText.Text = pluralize("Artist", ResultAmounts.Artists) + ", " + @@ -177,9 +189,15 @@ namespace osu.Game.Overlays } private GetBeatmapSetsRequest getSetsRequest; - private string lastQuery = string.Empty; + + private readonly Bindable currentQuery = new Bindable(); + + private ScheduledDelegate queryChangedDebounce; + private void updateSearch() { + queryChangedDebounce?.Cancel(); + if (!IsLoaded) return; BeatmapSets = null; @@ -211,10 +229,9 @@ namespace osu.Game.Overlays tags.AddRange(s.Metadata.Tags.Split(' ')); } - ResultAmounts = new ResultCounts(distinctCount(artists), - distinctCount(songs), - distinctCount(tags)); + ResultAmounts = new ResultCounts(distinctCount(artists), distinctCount(songs), distinctCount(tags)); }; + api.Queue(getSetsRequest); } From f142bd0dc066fdbbcc7a2e0da5176fb61405677f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Jul 2017 12:52:51 +0900 Subject: [PATCH 28/28] Improve formatting of panel creation code --- osu.Game/Overlays/DirectOverlay.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index df5955e7e6..5fa90ab1d6 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -185,7 +185,17 @@ namespace osu.Game.Overlays private void recreatePanels(PanelDisplayStyle displayStyle) { if (BeatmapSets == null) return; - panels.ChildrenEnumerable = BeatmapSets.Select(b => displayStyle == PanelDisplayStyle.Grid ? (DirectPanel)new DirectGridPanel(b) { Width = 400 } : new DirectListPanel(b)); + + panels.ChildrenEnumerable = BeatmapSets.Select(b => + { + switch (displayStyle) + { + case PanelDisplayStyle.Grid: + return new DirectGridPanel(b) { Width = 400 }; + default: + return new DirectListPanel(b); + } + }); } private GetBeatmapSetsRequest getSetsRequest;