2020-02-18 22:25:12 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osuTK;
|
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
|
using osu.Game.Beatmaps.Drawables;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2020-02-18 22:40:12 +08:00
|
|
|
|
using osuTK.Graphics;
|
2020-03-06 07:12:30 +08:00
|
|
|
|
using osu.Game.Rulesets;
|
2020-02-18 22:25:12 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.BeatmapListing
|
|
|
|
|
{
|
2020-04-21 14:13:19 +08:00
|
|
|
|
public class BeatmapListingSearchControl : CompositeDrawable
|
2020-02-18 22:25:12 +08:00
|
|
|
|
{
|
2020-03-06 07:12:30 +08:00
|
|
|
|
public Bindable<string> Query => textBox.Current;
|
|
|
|
|
|
|
|
|
|
public Bindable<RulesetInfo> Ruleset => modeFilter.Current;
|
|
|
|
|
|
2020-04-21 14:37:50 +08:00
|
|
|
|
public Bindable<SearchCategory> Category => categoryFilter.Current;
|
2020-03-06 07:12:30 +08:00
|
|
|
|
|
2020-04-21 14:37:50 +08:00
|
|
|
|
public Bindable<SearchGenre> Genre => genreFilter.Current;
|
2020-03-06 07:12:30 +08:00
|
|
|
|
|
2020-04-21 14:37:50 +08:00
|
|
|
|
public Bindable<SearchLanguage> Language => languageFilter.Current;
|
2020-02-20 22:56:49 +08:00
|
|
|
|
|
2020-02-18 22:25:12 +08:00
|
|
|
|
public BeatmapSetInfo BeatmapSet
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
2020-02-18 22:40:12 +08:00
|
|
|
|
if (value == null || string.IsNullOrEmpty(value.OnlineInfo.Covers.Cover))
|
2020-02-18 22:25:12 +08:00
|
|
|
|
{
|
|
|
|
|
beatmapCover.FadeOut(600, Easing.OutQuint);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
beatmapCover.BeatmapSet = value;
|
|
|
|
|
beatmapCover.FadeTo(0.1f, 200, Easing.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 22:40:12 +08:00
|
|
|
|
private readonly BeatmapSearchTextBox textBox;
|
2020-02-18 22:25:12 +08:00
|
|
|
|
private readonly BeatmapSearchRulesetFilterRow modeFilter;
|
2020-04-21 14:37:50 +08:00
|
|
|
|
private readonly BeatmapSearchFilterRow<SearchCategory> categoryFilter;
|
|
|
|
|
private readonly BeatmapSearchFilterRow<SearchGenre> genreFilter;
|
|
|
|
|
private readonly BeatmapSearchFilterRow<SearchLanguage> languageFilter;
|
2020-02-18 22:25:12 +08:00
|
|
|
|
|
|
|
|
|
private readonly Box background;
|
|
|
|
|
private readonly UpdateableBeatmapSetCover beatmapCover;
|
|
|
|
|
|
2020-04-21 14:13:19 +08:00
|
|
|
|
public BeatmapListingSearchControl()
|
2020-02-18 22:25:12 +08:00
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AddRangeInternal(new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
background = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Masking = true,
|
|
|
|
|
Child = beatmapCover = new UpdateableBeatmapSetCover
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Padding = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Vertical = 20,
|
|
|
|
|
Horizontal = 40,
|
|
|
|
|
},
|
|
|
|
|
Child = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Spacing = new Vector2(0, 20),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2020-02-18 22:40:12 +08:00
|
|
|
|
textBox = new BeatmapSearchTextBox
|
2020-02-18 22:25:12 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
},
|
|
|
|
|
new ReverseChildIDFillFlowContainer<Drawable>
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Padding = new MarginPadding { Horizontal = 10 },
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
modeFilter = new BeatmapSearchRulesetFilterRow(),
|
2020-04-21 14:37:50 +08:00
|
|
|
|
categoryFilter = new BeatmapSearchFilterRow<SearchCategory>(@"Categories"),
|
|
|
|
|
genreFilter = new BeatmapSearchFilterRow<SearchGenre>(@"Genre"),
|
|
|
|
|
languageFilter = new BeatmapSearchFilterRow<SearchLanguage>(@"Language"),
|
2020-02-18 22:25:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2020-02-20 09:19:50 +08:00
|
|
|
|
|
2020-04-21 14:37:50 +08:00
|
|
|
|
categoryFilter.Current.Value = SearchCategory.Leaderboard;
|
2020-02-18 22:25:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
|
|
|
|
{
|
|
|
|
|
background.Colour = colourProvider.Dark6;
|
|
|
|
|
}
|
2020-02-18 22:40:12 +08:00
|
|
|
|
|
2020-04-21 14:47:43 +08:00
|
|
|
|
public void TakeFocus() => textBox.TakeFocus();
|
|
|
|
|
|
2020-02-18 22:40:12 +08:00
|
|
|
|
private class BeatmapSearchTextBox : SearchTextBox
|
|
|
|
|
{
|
|
|
|
|
protected override Color4 SelectionColour => Color4.Gray;
|
|
|
|
|
|
|
|
|
|
public BeatmapSearchTextBox()
|
|
|
|
|
{
|
|
|
|
|
PlaceholderText = @"type in keywords...";
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-02-18 22:25:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|