2022-06-23 17:53:21 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2022-06-23 17:37:53 +08:00
|
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-23 17:53:21 +08:00
|
|
|
|
public bool ShowTooltip
|
|
|
|
|
{
|
|
|
|
|
get => difficultyIcon.ShowTooltip;
|
|
|
|
|
set => difficultyIcon.ShowTooltip = value;
|
|
|
|
|
}
|
2022-06-23 17:37:53 +08:00
|
|
|
|
|
|
|
|
|
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>
|
2022-06-24 12:58:02 +08:00
|
|
|
|
public CalculatingDifficultyIcon(IBeatmapInfo beatmapInfo)
|
2022-06-23 17:37:53 +08:00
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
2022-06-23 17:53:21 +08:00
|
|
|
|
difficultyIcon = new DifficultyIcon(beatmapInfo),
|
2022-06-24 13:06:31 +08:00
|
|
|
|
new DelayedLoadUnloadWrapper(() => new DifficultyRetriever(beatmapInfo) { StarDifficulty = { BindTarget = difficultyIcon.Current } }, 0)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
}
|
2022-06-23 17:37:53 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|