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 @@
+