diff --git a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs index 220aa1f56d..ed402858a6 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs @@ -131,7 +131,7 @@ namespace osu.Game.Beatmaps.Drawables }, } }, - new StarCounter { Count = beatmap.BaseDifficulty?.OverallDifficulty ?? 5, StarSize = 8 } + new StarCounter { Count = beatmap.StarDifficulty, StarSize = 8 } } } } diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs index 460af12d65..0d1a3b7320 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs @@ -1,7 +1,10 @@ //Copyright (c) 2007-2016 ppy Pty Ltd . //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; +using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Game.Database; using osu.Game.Graphics; @@ -13,20 +16,76 @@ namespace osu.Game.Beatmaps.Drawables { class DifficultyIcon : Container { + private readonly BeatmapInfo beatmap; + private OsuColour palette; + public DifficultyIcon(BeatmapInfo beatmap) { + this.beatmap = beatmap; const float size = 20; Size = new Vector2(size); - Children = new[] + } + + [BackgroundDependencyLoader] + private void load(OsuColour palette) + { + this.palette = palette; + + Children = new[] { new TextAwesome { Anchor = Anchor.Centre, - TextSize = size, - Colour = new Color4(159, 198, 0, 255), + TextSize = Size.X, + Colour = getColour(beatmap), + Icon = FontAwesome.fa_circle + }, + new TextAwesome + { + Anchor = Anchor.Centre, + TextSize = Size.X, + Colour = Color4.White, Icon = Ruleset.GetRuleset(beatmap.Mode).Icon } - }; + }; + } + + enum DifficultyRating + { + Easy, + Normal, + Hard, + Insane, + Expert + } + + private DifficultyRating getDifficultyRating(BeatmapInfo beatmap) + { + 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; + return DifficultyRating.Expert; + } + + private Color4 getColour(BeatmapInfo beatmap) + { + switch (getDifficultyRating(beatmap)) + { + case DifficultyRating.Easy: + return palette.Green; + 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; + } } } } \ No newline at end of file diff --git a/osu.Game/Database/BeatmapInfo.cs b/osu.Game/Database/BeatmapInfo.cs index ef5f00b634..002a883ec5 100644 --- a/osu.Game/Database/BeatmapInfo.cs +++ b/osu.Game/Database/BeatmapInfo.cs @@ -73,6 +73,8 @@ namespace osu.Game.Database // Metadata public string Version { get; set; } + public float StarDifficulty => BaseDifficulty?.OverallDifficulty ?? 5; //todo: implement properly + public bool Equals(BeatmapInfo other) { return ID == other?.ID; diff --git a/osu.Game/Graphics/OsuColour.cs b/osu.Game/Graphics/OsuColour.cs index 1ab5ec8f7c..2d434fb9b4 100644 --- a/osu.Game/Graphics/OsuColour.cs +++ b/osu.Game/Graphics/OsuColour.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using OpenTK.Graphics; using osu.Framework.Graphics.Colour; @@ -17,11 +18,23 @@ namespace osu.Game.Graphics private static Color4 FromHex(string hex) { - return new Color4( - Convert.ToByte(hex.Substring(0, 2), 16), - Convert.ToByte(hex.Substring(2, 2), 16), - Convert.ToByte(hex.Substring(4, 2), 16), - 255); + switch (hex.Length) + { + default: + throw new Exception(@"Invalid hex string length!"); + case 3: + return new Color4( + (byte)(Convert.ToByte(hex.Substring(0, 1), 16) * 17), + (byte)(Convert.ToByte(hex.Substring(1, 1), 16) * 17), + (byte)(Convert.ToByte(hex.Substring(2, 1), 16) * 17), + 255); + case 6: + return new Color4( + Convert.ToByte(hex.Substring(0, 2), 16), + Convert.ToByte(hex.Substring(2, 2), 16), + Convert.ToByte(hex.Substring(4, 2), 16), + 255); + } } // See https://github.com/ppy/osu-web/blob/master/resources/assets/less/colors.less @@ -56,6 +69,23 @@ namespace osu.Game.Graphics public Color4 GreenDark = FromHex(@"668800"); public Color4 GreenDarker = FromHex(@"445500"); + public Color4 Gray0 = FromHex(@"000"); + public Color4 Gray1 = FromHex(@"111"); + public Color4 Gray2 = FromHex(@"222"); + public Color4 Gray3 = FromHex(@"333"); + public Color4 Gray4 = FromHex(@"444"); + public Color4 Gray5 = FromHex(@"555"); + public Color4 Gray6 = FromHex(@"666"); + public Color4 Gray7 = FromHex(@"777"); + public Color4 Gray8 = FromHex(@"888"); + public Color4 Gray9 = FromHex(@"999"); + public Color4 GrayA = FromHex(@"aaa"); + public Color4 GrayB = FromHex(@"bbb"); + public Color4 GrayC = FromHex(@"ccc"); + public Color4 GrayD = FromHex(@"ddd"); + public Color4 GrayE = FromHex(@"eee"); + public Color4 GrayF = FromHex(@"fff"); + public Color4 Red = FromHex(@"fc4549"); } } diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 23aed2d1a3..69336dc013 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -310,7 +310,7 @@ namespace osu.Game.Screens.Select if (b.Metadata == null) b.Metadata = beatmapSet.Metadata; }); - beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.BaseDifficulty.OverallDifficulty).ToList(); + beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.StarDifficulty).ToList(); var beatmap = new WorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault(), beatmapSet, database);