2022-06-07 07:32:15 +00: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 osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Game.Beatmaps;
|
2022-06-07 07:45:20 +00:00
|
|
|
using osu.Game.Configuration;
|
2022-06-07 07:32:15 +00:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Containers;
|
2022-06-07 08:13:04 +00:00
|
|
|
using osu.Game.Localisation;
|
2022-06-07 07:32:15 +00:00
|
|
|
using osu.Game.Online.Chat;
|
|
|
|
using osu.Game.Overlays;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Select
|
|
|
|
{
|
2022-06-07 08:13:04 +00:00
|
|
|
public partial class NoResultsPlaceholder : VisibilityContainer
|
2022-06-07 07:32:15 +00:00
|
|
|
{
|
2022-06-07 07:45:20 +00:00
|
|
|
private FilterCriteria? filter;
|
|
|
|
|
|
|
|
private LinkFlowContainer textFlow = null!;
|
2022-06-07 07:32:15 +00:00
|
|
|
|
2022-06-07 07:45:20 +00:00
|
|
|
[Resolved]
|
|
|
|
private BeatmapManager beatmaps { get; set; } = null!;
|
2022-06-07 07:32:15 +00:00
|
|
|
|
|
|
|
[Resolved]
|
2022-06-07 07:45:20 +00:00
|
|
|
private FirstRunSetupOverlay? firstRunSetupOverlay { get; set; }
|
2022-06-07 07:32:15 +00:00
|
|
|
|
2022-06-07 07:45:20 +00:00
|
|
|
[Resolved]
|
|
|
|
private OsuConfigManager config { get; set; } = null!;
|
2022-06-07 07:32:15 +00:00
|
|
|
|
|
|
|
public FilterCriteria Filter
|
|
|
|
{
|
|
|
|
set
|
|
|
|
{
|
2022-06-07 08:13:04 +00:00
|
|
|
if (filter == value)
|
|
|
|
return;
|
|
|
|
|
2022-06-07 07:32:15 +00:00
|
|
|
filter = value;
|
|
|
|
Scheduler.AddOnce(updateText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
Masking = true;
|
|
|
|
CornerRadius = 10;
|
|
|
|
|
2022-07-01 06:17:53 +00:00
|
|
|
Width = 400;
|
2022-06-07 07:32:15 +00:00
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
Colour = colours.Gray2,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
|
|
|
new SpriteIcon
|
|
|
|
{
|
2022-06-07 08:13:04 +00:00
|
|
|
Icon = FontAwesome.Regular.SadTear,
|
2022-06-07 07:32:15 +00:00
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Margin = new MarginPadding(10),
|
|
|
|
Size = new Vector2(50),
|
|
|
|
},
|
|
|
|
textFlow = new LinkFlowContainer
|
|
|
|
{
|
2022-06-07 08:13:04 +00:00
|
|
|
Y = 60,
|
2022-06-07 07:32:15 +00:00
|
|
|
Padding = new MarginPadding(10),
|
|
|
|
TextAnchor = Anchor.TopCentre,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-06-07 08:13:04 +00:00
|
|
|
protected override void PopIn()
|
2022-06-07 07:32:15 +00:00
|
|
|
{
|
|
|
|
this.FadeIn(600, Easing.OutQuint);
|
|
|
|
|
|
|
|
Scheduler.AddOnce(updateText);
|
|
|
|
}
|
|
|
|
|
2022-06-07 08:13:04 +00:00
|
|
|
protected override void PopOut()
|
2022-06-07 07:32:15 +00:00
|
|
|
{
|
|
|
|
this.FadeOut(200, Easing.OutQuint);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateText()
|
|
|
|
{
|
2022-06-07 08:13:04 +00:00
|
|
|
// TODO: Refresh this text when new beatmaps are imported. Right now it won't get up-to-date suggestions.
|
|
|
|
|
|
|
|
// Bounce should play every time the filter criteria is updated.
|
|
|
|
this.ScaleTo(0.9f)
|
|
|
|
.ScaleTo(1f, 1000, Easing.OutElastic);
|
|
|
|
|
2022-06-07 07:32:15 +00:00
|
|
|
textFlow.Clear();
|
|
|
|
|
|
|
|
if (beatmaps.QueryBeatmapSet(s => !s.Protected && !s.DeletePending) == null)
|
|
|
|
{
|
|
|
|
textFlow.AddParagraph("No beatmaps found!");
|
|
|
|
textFlow.AddParagraph(string.Empty);
|
|
|
|
|
2022-07-15 08:50:10 +00:00
|
|
|
textFlow.AddParagraph("- Consider running the \"");
|
2022-06-07 08:13:04 +00:00
|
|
|
textFlow.AddLink(FirstRunSetupOverlayStrings.FirstRunSetupTitle, () => firstRunSetupOverlay?.Show());
|
|
|
|
textFlow.AddText("\" to download or import some beatmaps!");
|
2022-06-07 07:32:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
textFlow.AddParagraph("No beatmaps match your filter criteria!");
|
|
|
|
textFlow.AddParagraph(string.Empty);
|
|
|
|
|
2022-07-01 06:17:53 +00:00
|
|
|
if (filter?.UserStarDifficulty.HasFilter == true)
|
2022-06-07 07:45:20 +00:00
|
|
|
{
|
2022-07-01 06:17:53 +00:00
|
|
|
textFlow.AddParagraph("- Try ");
|
|
|
|
textFlow.AddLink("removing", () =>
|
2022-06-07 07:45:20 +00:00
|
|
|
{
|
2022-07-01 06:17:53 +00:00
|
|
|
config.SetValue(OsuSetting.DisplayStarsMinimum, 0.0);
|
|
|
|
config.SetValue(OsuSetting.DisplayStarsMaximum, 10.1);
|
|
|
|
});
|
|
|
|
|
2022-09-08 06:51:15 +00:00
|
|
|
string lowerStar = $"{filter.UserStarDifficulty.Min ?? 0:N1}";
|
2022-07-01 06:17:53 +00:00
|
|
|
string upperStar = filter.UserStarDifficulty.Max == null ? "∞" : $"{filter.UserStarDifficulty.Max:N1}";
|
|
|
|
|
2022-09-04 22:09:20 +00:00
|
|
|
textFlow.AddText($" the {lowerStar} - {upperStar} star difficulty filter.");
|
2022-07-01 06:17:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Add realm queries to hint at which ruleset results are available in (and allow clicking to switch).
|
|
|
|
// TODO: Make this message more certain by ensuring the osu! beatmaps exist before suggesting.
|
2022-07-07 05:46:51 +00:00
|
|
|
if (filter?.Ruleset?.OnlineID != 0 && filter?.AllowConvertedBeatmaps == false)
|
2022-07-01 06:17:53 +00:00
|
|
|
{
|
|
|
|
textFlow.AddParagraph("- Try");
|
|
|
|
textFlow.AddLink(" enabling ", () => config.SetValue(OsuSetting.ShowConvertedBeatmaps, true));
|
|
|
|
textFlow.AddText("automatic conversion!");
|
2022-06-07 07:45:20 +00:00
|
|
|
}
|
2022-06-07 07:32:15 +00:00
|
|
|
}
|
2022-06-07 08:13:04 +00:00
|
|
|
|
2022-07-15 08:50:10 +00:00
|
|
|
if (!string.IsNullOrEmpty(filter?.SearchText))
|
|
|
|
{
|
|
|
|
textFlow.AddParagraph("- Try ");
|
|
|
|
textFlow.AddLink("searching online", LinkAction.SearchBeatmapSet, filter.SearchText);
|
|
|
|
textFlow.AddText($" for \"{filter.SearchText}\".");
|
|
|
|
}
|
2022-06-07 08:13:04 +00:00
|
|
|
// TODO: add clickable link to reset criteria.
|
2022-06-07 07:32:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|