mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 20:07:29 +08:00
772bef91fa
# Conflicts: # osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
70 lines
2.3 KiB
C#
70 lines
2.3 KiB
C#
// 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;
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Framework.Graphics.Effects;
|
|
using osu.Framework.Graphics.Shapes;
|
|
using osu.Framework.Graphics.Sprites;
|
|
using osu.Game.Graphics.Containers;
|
|
using osu.Game.Rulesets;
|
|
using osuTK;
|
|
using osuTK.Graphics;
|
|
|
|
namespace osu.Game.Beatmaps.Drawables
|
|
{
|
|
public class DifficultyIcon : DifficultyColouredContainer
|
|
{
|
|
private readonly RulesetInfo ruleset;
|
|
|
|
public DifficultyIcon(BeatmapInfo beatmap, RulesetInfo ruleset = null)
|
|
: base(beatmap)
|
|
{
|
|
if (beatmap == null)
|
|
throw new ArgumentNullException(nameof(beatmap));
|
|
|
|
this.ruleset = ruleset ?? beatmap.Ruleset;
|
|
|
|
Size = new Vector2(20);
|
|
}
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load()
|
|
{
|
|
Children = new Drawable[]
|
|
{
|
|
new CircularContainer
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
Scale = new Vector2(0.84f),
|
|
Anchor = Anchor.Centre,
|
|
Origin = Anchor.Centre,
|
|
Masking = true,
|
|
EdgeEffect = new EdgeEffectParameters
|
|
{
|
|
Colour = Color4.Black.Opacity(0.08f),
|
|
Type = EdgeEffectType.Shadow,
|
|
Radius = 5,
|
|
},
|
|
Child = new Box
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
Colour = AccentColour,
|
|
},
|
|
},
|
|
new ConstrainedIconContainer
|
|
{
|
|
Anchor = Anchor.Centre,
|
|
Origin = Anchor.Centre,
|
|
RelativeSizeAxes = Axes.Both,
|
|
// the null coalesce here is only present to make unit tests work (ruleset dlls aren't copied correctly for testing at the moment)
|
|
Icon = ruleset?.CreateInstance().CreateIcon() ?? new SpriteIcon { Icon = FontAwesome.Regular.QuestionCircle }
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}
|