2017-02-07 12:59:30 +08:00
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2017-02-07 12:52:19 +08:00
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Game.Database;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Modes;
|
|
|
|
using OpenTK;
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
2016-11-23 10:59:50 +08:00
|
|
|
namespace osu.Game.Beatmaps.Drawables
|
2016-10-27 10:55:55 +08:00
|
|
|
{
|
2017-03-07 09:59:19 +08:00
|
|
|
internal class DifficultyIcon : Container
|
2017-02-07 12:52:19 +08:00
|
|
|
{
|
|
|
|
private readonly BeatmapInfo beatmap;
|
|
|
|
private OsuColour palette;
|
|
|
|
|
|
|
|
public DifficultyIcon(BeatmapInfo beatmap)
|
|
|
|
{
|
|
|
|
this.beatmap = beatmap;
|
|
|
|
const float size = 20;
|
|
|
|
Size = new Vector2(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2017-01-30 14:26:28 +08:00
|
|
|
private void load(OsuColour palette)
|
|
|
|
{
|
|
|
|
this.palette = palette;
|
|
|
|
|
|
|
|
Children = new[]
|
2017-02-07 12:52:19 +08:00
|
|
|
{
|
|
|
|
new TextAwesome
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
2017-03-06 16:06:48 +08:00
|
|
|
Origin = Anchor.Centre,
|
2017-02-07 12:52:19 +08:00
|
|
|
TextSize = Size.X,
|
|
|
|
Colour = getColour(beatmap),
|
|
|
|
Icon = FontAwesome.fa_circle
|
|
|
|
},
|
|
|
|
new TextAwesome
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
2017-03-06 16:06:48 +08:00
|
|
|
Origin = Anchor.Centre,
|
2017-02-07 12:52:19 +08:00
|
|
|
TextSize = Size.X,
|
|
|
|
Colour = Color4.White,
|
|
|
|
Icon = Ruleset.GetRuleset(beatmap.Mode).Icon
|
|
|
|
}
|
2017-01-30 14:26:28 +08:00
|
|
|
};
|
2017-02-07 12:52:19 +08:00
|
|
|
}
|
|
|
|
|
2017-03-07 09:59:19 +08:00
|
|
|
private enum DifficultyRating
|
2017-01-30 14:26:28 +08:00
|
|
|
{
|
|
|
|
Easy,
|
|
|
|
Normal,
|
|
|
|
Hard,
|
|
|
|
Insane,
|
|
|
|
Expert
|
2017-02-07 12:52:19 +08:00
|
|
|
}
|
|
|
|
|
2017-01-30 14:26:28 +08:00
|
|
|
private DifficultyRating getDifficultyRating(BeatmapInfo beatmap)
|
|
|
|
{
|
|
|
|
var rating = beatmap.StarDifficulty;
|
|
|
|
|
2017-02-07 12:52:19 +08:00
|
|
|
if (rating < 1.5) return DifficultyRating.Easy;
|
|
|
|
if (rating < 2.25) return DifficultyRating.Normal;
|
|
|
|
if (rating < 3.75) return DifficultyRating.Hard;
|
|
|
|
if (rating < 5.25) return DifficultyRating.Insane;
|
|
|
|
return DifficultyRating.Expert;
|
|
|
|
}
|
|
|
|
|
|
|
|
private Color4 getColour(BeatmapInfo beatmap)
|
2017-01-30 14:26:28 +08:00
|
|
|
{
|
2017-02-07 12:52:19 +08:00
|
|
|
switch (getDifficultyRating(beatmap))
|
|
|
|
{
|
|
|
|
case DifficultyRating.Easy:
|
2017-01-30 14:26:28 +08:00
|
|
|
return palette.Green;
|
2017-02-07 12:52:19 +08:00
|
|
|
default:
|
|
|
|
case DifficultyRating.Normal:
|
|
|
|
return palette.Yellow;
|
|
|
|
case DifficultyRating.Hard:
|
|
|
|
return palette.Pink;
|
|
|
|
case DifficultyRating.Insane:
|
|
|
|
return palette.Purple;
|
|
|
|
case DifficultyRating.Expert:
|
|
|
|
return palette.Gray0;
|
2017-01-30 14:26:28 +08:00
|
|
|
}
|
2017-02-07 12:52:19 +08:00
|
|
|
}
|
2016-10-27 10:55:55 +08:00
|
|
|
}
|
|
|
|
}
|