2018-01-05 19:21:19 +08:00
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-02-07 12:59:30 +08:00
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2017-02-07 12:52:19 +08:00
|
|
|
|
2017-11-08 06:13:09 +08:00
|
|
|
using System;
|
2017-02-07 12:52:19 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Game.Graphics;
|
2017-08-03 13:36:21 +08:00
|
|
|
using osu.Game.Graphics.Containers;
|
2017-02-07 12:52:19 +08:00
|
|
|
using OpenTK;
|
|
|
|
|
2016-11-23 10:59:50 +08:00
|
|
|
namespace osu.Game.Beatmaps.Drawables
|
2016-10-27 10:55:55 +08:00
|
|
|
{
|
2017-05-19 23:52:23 +08:00
|
|
|
public class DifficultyIcon : DifficultyColouredContainer
|
2017-02-07 12:52:19 +08:00
|
|
|
{
|
2017-04-24 19:31:25 +08:00
|
|
|
private readonly BeatmapInfo beatmap;
|
2017-02-07 12:52:19 +08:00
|
|
|
|
2017-04-24 19:11:36 +08:00
|
|
|
public DifficultyIcon(BeatmapInfo beatmap) : base(beatmap)
|
2017-02-07 12:52:19 +08:00
|
|
|
{
|
2017-11-08 06:13:09 +08:00
|
|
|
if (beatmap == null)
|
|
|
|
throw new ArgumentNullException(nameof(beatmap));
|
|
|
|
|
2017-02-07 12:52:19 +08:00
|
|
|
this.beatmap = beatmap;
|
2017-04-24 19:11:36 +08:00
|
|
|
Size = new Vector2(20);
|
2017-02-07 12:52:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2017-04-24 19:31:25 +08:00
|
|
|
private void load()
|
2017-01-30 14:26:28 +08:00
|
|
|
{
|
2017-08-03 13:36:21 +08:00
|
|
|
Children = new Drawable[]
|
2017-02-07 12:52:19 +08:00
|
|
|
{
|
2017-08-03 13:36:21 +08:00
|
|
|
new SpriteIcon
|
2017-02-07 12:52:19 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
2017-03-06 16:06:48 +08:00
|
|
|
Origin = Anchor.Centre,
|
2017-08-03 13:36:21 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-04-24 19:11:36 +08:00
|
|
|
Colour = AccentColour,
|
2017-02-07 12:52:19 +08:00
|
|
|
Icon = FontAwesome.fa_circle
|
|
|
|
},
|
2017-08-03 13:36:21 +08:00
|
|
|
new ConstrainedIconContainer
|
2017-02-07 12:52:19 +08:00
|
|
|
{
|
2017-08-03 13:36:21 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-10-23 15:56:29 +08:00
|
|
|
// 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 }
|
2017-02-07 12:52:19 +08:00
|
|
|
}
|
2017-01-30 14:26:28 +08:00
|
|
|
};
|
2017-02-07 12:52:19 +08:00
|
|
|
}
|
2016-10-27 10:55:55 +08:00
|
|
|
}
|
2017-04-24 19:11:36 +08:00
|
|
|
}
|