Move all logic to TopLocalRank and remove CarouselBeatmapRank

This commit is contained in:
Santeri Nogelainen
2020-04-04 22:28:36 +03:00
parent 6bde102207
commit 1e8badb14a
3 changed files with 32 additions and 94 deletions

View File

@ -1,68 +0,0 @@
// 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.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Online.Leaderboards;
using osu.Game.Rulesets;
using osu.Game.Scoring;
namespace osu.Game.Screens.Select.Carousel
{
public class CarouselBeatmapRank : Container
{
private const int rank_size = 20;
private readonly BeatmapInfo beatmap;
private TopLocalRank rank;
public CarouselBeatmapRank(BeatmapInfo beatmap)
{
this.beatmap = beatmap;
Height = rank_size;
}
[BackgroundDependencyLoader]
private void load(ScoreManager scores, IBindable<RulesetInfo> ruleset)
{
scores.ItemAdded += scoreChanged;
scores.ItemRemoved += scoreChanged;
ruleset.ValueChanged += _ => rulesetChanged();
rank = new TopLocalRank(beatmap)
{
ScoreLoaded = scaleDisplay
};
InternalChild = new DelayedLoadWrapper(rank)
{
RelativeSizeAxes = Axes.Both
};
}
private void rulesetChanged()
{
rank.FetchAndLoadTopScore();
}
private void scoreChanged(ScoreInfo score)
{
if (score.BeatmapInfoID == beatmap.ID)
{
rank.FetchAndLoadTopScore();
}
}
private void scaleDisplay(ScoreInfo score)
{
if (score != null)
Width = rank_size * 2;
else
Width = 0;
}
}
}

View File

@ -19,6 +19,7 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Leaderboards;
using osu.Game.Overlays;
using osuTK;
using osuTK.Graphics;
@ -129,9 +130,10 @@ namespace osu.Game.Screens.Select.Carousel
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
new CarouselBeatmapRank(beatmap)
new TopLocalRank(beatmap)
{
Scale = new Vector2(0.8f)
Scale = new Vector2(0.8f),
Size = new Vector2(40, 20)
},
starCounter = new StarCounter
{