1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 23:27:24 +08:00
osu-lazer/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs

67 lines
2.2 KiB
C#
Raw Normal View History

2018-04-13 17:19:50 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Allocation;
2018-07-13 16:15:06 +08:00
using osu.Framework.Extensions.Color4Extensions;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics;
2018-07-13 16:15:06 +08:00
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
2018-04-13 17:19:50 +08:00
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using OpenTK;
2018-07-13 16:15:06 +08:00
using OpenTK.Graphics;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Beatmaps.Drawables
{
public class DifficultyIcon : DifficultyColouredContainer
{
private readonly BeatmapInfo beatmap;
2018-07-13 16:15:06 +08:00
public DifficultyIcon(BeatmapInfo beatmap)
: base(beatmap)
2018-04-13 17:19:50 +08:00
{
if (beatmap == null)
throw new ArgumentNullException(nameof(beatmap));
this.beatmap = beatmap;
Size = new Vector2(20);
}
[BackgroundDependencyLoader]
private void load()
{
Children = new Drawable[]
{
2018-07-13 16:15:06 +08:00
new CircularContainer
2018-04-13 17:19:50 +08:00
{
2018-07-13 16:15:06 +08:00
RelativeSizeAxes = Axes.Both,
Scale = new Vector2(0.84f),
2018-04-13 17:19:50 +08:00
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2018-07-13 16:15:06 +08:00
Masking = true,
EdgeEffect = new EdgeEffectParameters
{
Colour = Color4.Black.Opacity(0.08f),
Type = EdgeEffectType.Shadow,
Radius = 5,
},
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = AccentColour,
},
2018-04-13 17:19:50 +08:00
},
new ConstrainedIconContainer
{
2018-07-13 16:15:06 +08:00
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2018-04-13 17:19:50 +08:00
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 = beatmap.Ruleset?.CreateInstance().CreateIcon() ?? new SpriteIcon { Icon = FontAwesome.fa_question_circle_o }
}
};
}
}
}