mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 06:03:08 +08:00
Nuke calculating everything
The whole component is pointless so I'm just going to nuke for now I guess. Kind of makes the whole refactor effort pointless but oh well? To expand on this, the implementation was actually incorrect as pointed out at https://github.com/ppy/osu/pull/18819#pullrequestreview-1017886035.
This commit is contained in:
parent
12ea8369ee
commit
28837693e5
@ -1,50 +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.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawables
|
||||
{
|
||||
/// <summary>
|
||||
/// A difficulty icon which automatically calculates difficulty in the background.
|
||||
/// </summary>
|
||||
public class CalculatingDifficultyIcon : CompositeDrawable
|
||||
{
|
||||
/// <summary>
|
||||
/// Size of this difficulty icon.
|
||||
/// </summary>
|
||||
public new Vector2 Size
|
||||
{
|
||||
get => difficultyIcon.Size;
|
||||
set => difficultyIcon.Size = value;
|
||||
}
|
||||
|
||||
public bool ShowTooltip
|
||||
{
|
||||
get => difficultyIcon.ShowTooltip;
|
||||
set => difficultyIcon.ShowTooltip = value;
|
||||
}
|
||||
|
||||
private readonly DifficultyIcon difficultyIcon;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="CalculatingDifficultyIcon"/> that follows the currently-selected ruleset and mods.
|
||||
/// </summary>
|
||||
/// <param name="beatmapInfo">The beatmap to show the difficulty of.</param>
|
||||
public CalculatingDifficultyIcon(IBeatmapInfo beatmapInfo)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
difficultyIcon = new DifficultyIcon(beatmapInfo),
|
||||
new DelayedLoadUnloadWrapper(() => new DifficultyRetriever(beatmapInfo) { StarDifficulty = { BindTarget = difficultyIcon.Current } }, 0)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,83 +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 System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawables
|
||||
{
|
||||
/// <summary>
|
||||
/// A component solely responsible for calculating difficulty in the background.
|
||||
/// Intended for use with <see cref="DelayedLoadWrapper"/> to only run processing when usage is on-screen.
|
||||
/// </summary>
|
||||
public class DifficultyRetriever : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The bindable star difficulty.
|
||||
/// </summary>
|
||||
public IBindable<StarDifficulty> StarDifficulty => starDifficulty;
|
||||
|
||||
private readonly Bindable<StarDifficulty> starDifficulty = new Bindable<StarDifficulty>();
|
||||
|
||||
private readonly IBeatmapInfo beatmapInfo;
|
||||
|
||||
private readonly IRulesetInfo? ruleset;
|
||||
private readonly IReadOnlyList<Mod>? mods;
|
||||
|
||||
private readonly CancellationTokenSource difficultyCancellation = new CancellationTokenSource();
|
||||
|
||||
[Resolved]
|
||||
private BeatmapDifficultyCache difficultyCache { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Construct a difficulty retriever that tracks the current ruleset / mod selection.
|
||||
/// </summary>
|
||||
/// <param name="beatmapInfo">The beatmap to use for calculation.</param>
|
||||
public DifficultyRetriever(IBeatmapInfo beatmapInfo)
|
||||
{
|
||||
this.beatmapInfo = beatmapInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Construct a difficulty retriever that is calculated only once for the specified ruleset / mod combination.
|
||||
/// This will not track global ruleset and mod changes.
|
||||
/// </summary>
|
||||
/// <param name="beatmapInfo">The beatmap to use for calculation.</param>
|
||||
/// <param name="ruleset">The ruleset to use for calculation.</param>
|
||||
/// <param name="mods">The mods to use for calculation.</param>
|
||||
public DifficultyRetriever(IBeatmapInfo beatmapInfo, IRulesetInfo ruleset, IReadOnlyList<Mod> mods)
|
||||
{
|
||||
this.beatmapInfo = beatmapInfo;
|
||||
this.ruleset = ruleset;
|
||||
this.mods = mods;
|
||||
}
|
||||
|
||||
private IBindable<StarDifficulty?> localStarDifficulty = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
localStarDifficulty = ruleset != null
|
||||
? difficultyCache.GetBindableDifficulty(beatmapInfo, ruleset, mods, difficultyCancellation.Token)
|
||||
: difficultyCache.GetBindableDifficulty(beatmapInfo, difficultyCancellation.Token);
|
||||
|
||||
localStarDifficulty.BindValueChanged(d =>
|
||||
{
|
||||
if (d.NewValue is StarDifficulty diff)
|
||||
starDifficulty.Value = diff;
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
difficultyCancellation.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
@ -53,7 +53,9 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
private Action<BeatmapInfo> hideRequested;
|
||||
|
||||
private Triangles triangles;
|
||||
|
||||
private StarCounter starCounter;
|
||||
private DifficultyIcon difficultyIcon;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private BeatmapSetOverlay beatmapOverlay { get; set; }
|
||||
@ -113,7 +115,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
Origin = Anchor.CentreLeft,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new CalculatingDifficultyIcon(beatmapInfo)
|
||||
difficultyIcon = new DifficultyIcon(beatmapInfo)
|
||||
{
|
||||
ShowTooltip = false,
|
||||
Scale = new Vector2(1.8f),
|
||||
@ -217,6 +219,8 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
starDifficultyBindable.BindValueChanged(d =>
|
||||
{
|
||||
starCounter.Current = (float)(d.NewValue?.Stars ?? 0);
|
||||
if (d.NewValue != null)
|
||||
difficultyIcon.Current.Value = d.NewValue.Value;
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user