2017-04-24 11:11:36 +00: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-11-07 22:16:19 +00:00
|
|
|
using System;
|
2017-04-24 11:11:36 +00:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps.Drawables
|
|
|
|
{
|
2017-05-19 15:52:23 +00:00
|
|
|
public class DifficultyColouredContainer : Container, IHasAccentColour
|
2017-04-24 11:11:36 +00:00
|
|
|
{
|
|
|
|
public Color4 AccentColour { get; set; }
|
|
|
|
|
|
|
|
private readonly BeatmapInfo beatmap;
|
|
|
|
private OsuColour palette;
|
|
|
|
|
|
|
|
public DifficultyColouredContainer(BeatmapInfo beatmap)
|
|
|
|
{
|
|
|
|
this.beatmap = beatmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour palette)
|
|
|
|
{
|
2017-11-07 22:16:19 +00:00
|
|
|
if (palette == null)
|
|
|
|
throw new ArgumentNullException(nameof(palette));
|
|
|
|
|
2017-04-24 11:11:36 +00:00
|
|
|
this.palette = palette;
|
|
|
|
AccentColour = getColour(beatmap);
|
|
|
|
}
|
|
|
|
|
|
|
|
private enum DifficultyRating
|
|
|
|
{
|
|
|
|
Easy,
|
|
|
|
Normal,
|
|
|
|
Hard,
|
|
|
|
Insane,
|
2017-09-05 11:57:30 +00:00
|
|
|
Expert,
|
|
|
|
ExpertPlus
|
2017-04-24 11:11:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private DifficultyRating getDifficultyRating(BeatmapInfo beatmap)
|
|
|
|
{
|
2017-11-07 22:17:45 +00:00
|
|
|
if (beatmap == null)
|
|
|
|
throw new ArgumentNullException(nameof(beatmap));
|
|
|
|
|
2017-04-24 11:11:36 +00:00
|
|
|
var rating = beatmap.StarDifficulty;
|
|
|
|
|
|
|
|
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;
|
2017-09-05 11:57:30 +00:00
|
|
|
if (rating < 6.75) return DifficultyRating.Expert;
|
|
|
|
return DifficultyRating.ExpertPlus;
|
2017-04-24 11:11:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private Color4 getColour(BeatmapInfo beatmap)
|
|
|
|
{
|
|
|
|
switch (getDifficultyRating(beatmap))
|
|
|
|
{
|
|
|
|
case DifficultyRating.Easy:
|
|
|
|
return palette.Green;
|
|
|
|
default:
|
|
|
|
case DifficultyRating.Normal:
|
2017-09-05 11:57:30 +00:00
|
|
|
return palette.Blue;
|
2017-04-24 11:11:36 +00:00
|
|
|
case DifficultyRating.Hard:
|
2017-09-05 11:57:30 +00:00
|
|
|
return palette.Yellow;
|
2017-04-24 11:11:36 +00:00
|
|
|
case DifficultyRating.Insane:
|
2017-09-05 11:57:30 +00:00
|
|
|
return palette.Pink;
|
2017-04-24 11:11:36 +00:00
|
|
|
case DifficultyRating.Expert:
|
2017-09-05 11:57:30 +00:00
|
|
|
return palette.Purple;
|
|
|
|
case DifficultyRating.ExpertPlus:
|
2017-04-24 11:11:36 +00:00
|
|
|
return palette.Gray0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|