From ab32e962ca90a4a73ce88e7ec9f90f0dd4de7ff8 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sun, 28 May 2017 00:37:55 -0300 Subject: [PATCH 01/40] 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/40] 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/40] 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/40] 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/40] 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/40] 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/40] 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/40] 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/40] 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/40] 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/40] 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/40] 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/40] 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/40] 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/40] 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 b105d6d7415956e68ab3c2679e445c2899393ed5 Mon Sep 17 00:00:00 2001 From: Vlad K Date: Tue, 27 Jun 2017 02:10:00 +0300 Subject: [PATCH 16/40] Insert icon into osu exe --- osu.Desktop/OsuGameDesktop.cs | 3 ++- osu.Desktop/osu.Desktop.csproj | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index 299f64d998..536fe40c6a 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -12,6 +12,7 @@ using System.Drawing; using System.IO; using System.Threading.Tasks; using osu.Game.Screens.Menu; +using System.Resources; namespace osu.Desktop { @@ -45,7 +46,7 @@ namespace osu.Desktop { desktopWindow.CursorState |= CursorState.Hidden; - desktopWindow.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); + desktopWindow.Icon = new Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream(this.GetType(), "lazer.ico")); desktopWindow.Title = Name; desktopWindow.DragEnter += dragEnter; diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index 5ac888b515..e69603602c 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -232,7 +232,7 @@ - +