2019-10-04 22:35:41 +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.
|
|
|
|
|
|
2021-10-29 16:58:46 +08:00
|
|
|
|
using System.Linq;
|
2019-10-04 22:35:41 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-10-16 04:33:50 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2019-10-04 22:35:41 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2021-11-15 13:38:14 +08:00
|
|
|
|
using osu.Game.Extensions;
|
2019-10-04 22:35:41 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2021-10-29 16:58:46 +08:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2019-10-04 22:35:41 +08:00
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.BeatmapSet
|
|
|
|
|
{
|
2020-02-03 19:16:26 +08:00
|
|
|
|
public class BeatmapRulesetTabItem : OverlayRulesetTabItem
|
2019-10-04 22:35:41 +08:00
|
|
|
|
{
|
2021-10-29 16:58:46 +08:00
|
|
|
|
public readonly Bindable<APIBeatmapSet> BeatmapSet = new Bindable<APIBeatmapSet>();
|
2019-10-16 04:33:50 +08:00
|
|
|
|
|
2020-02-03 19:16:26 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private OverlayColourProvider colourProvider { get; set; }
|
|
|
|
|
|
|
|
|
|
private OsuSpriteText count;
|
|
|
|
|
private Container countContainer;
|
|
|
|
|
|
2019-10-04 22:35:41 +08:00
|
|
|
|
public BeatmapRulesetTabItem(RulesetInfo value)
|
|
|
|
|
: base(value)
|
|
|
|
|
{
|
2020-02-03 19:16:26 +08:00
|
|
|
|
}
|
2019-10-04 22:35:41 +08:00
|
|
|
|
|
2020-02-03 19:16:26 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2020-02-03 20:25:07 +08:00
|
|
|
|
Add(countContainer = new Container
|
2019-10-04 22:35:41 +08:00
|
|
|
|
{
|
2020-02-03 19:16:26 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Masking = true,
|
|
|
|
|
CornerRadius = 4f,
|
|
|
|
|
Children = new Drawable[]
|
2019-10-04 22:35:41 +08:00
|
|
|
|
{
|
2020-02-03 19:16:26 +08:00
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = colourProvider.Background6
|
|
|
|
|
},
|
|
|
|
|
count = new OsuSpriteText
|
2019-10-04 22:35:41 +08:00
|
|
|
|
{
|
2020-02-03 19:16:26 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Margin = new MarginPadding { Horizontal = 5f },
|
|
|
|
|
Font = OsuFont.Default.With(weight: FontWeight.SemiBold),
|
|
|
|
|
Colour = colourProvider.Foreground1,
|
2019-10-04 22:35:41 +08:00
|
|
|
|
}
|
2020-02-03 19:16:26 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
2019-10-04 22:35:41 +08:00
|
|
|
|
|
2019-10-16 04:33:50 +08:00
|
|
|
|
BeatmapSet.BindValueChanged(setInfo =>
|
|
|
|
|
{
|
2021-11-15 13:38:14 +08:00
|
|
|
|
int beatmapsCount = setInfo.NewValue?.Beatmaps.Count(b => b.Ruleset.MatchesOnlineID(Value)) ?? 0;
|
2019-10-16 04:33:50 +08:00
|
|
|
|
|
2019-10-31 15:23:10 +08:00
|
|
|
|
count.Text = beatmapsCount.ToString();
|
2020-02-03 19:16:26 +08:00
|
|
|
|
countContainer.FadeTo(beatmapsCount > 0 ? 1 : 0);
|
2019-10-31 15:23:10 +08:00
|
|
|
|
|
2019-10-16 04:33:50 +08:00
|
|
|
|
Enabled.Value = beatmapsCount > 0;
|
|
|
|
|
}, true);
|
2019-10-04 22:35:41 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|