diff --git a/osu.Game/Beatmaps/Drawables/DifficultyColouredContainer.cs b/osu.Game/Beatmaps/Drawables/DifficultyColouredContainer.cs new file mode 100644 index 0000000000..7c0aa49d2a --- /dev/null +++ b/osu.Game/Beatmaps/Drawables/DifficultyColouredContainer.cs @@ -0,0 +1,69 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Graphics.Containers; +using osu.Game.Database; +using osu.Game.Graphics; +using OpenTK.Graphics; + +namespace osu.Game.Beatmaps.Drawables +{ + internal class DifficultyColouredContainer : Container, IHasAccentColour + { + 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) + { + this.palette = palette; + AccentColour = getColour(beatmap); + } + + private 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; + } + } + } +} diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs index 8a9183819c..6b8b267894 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs @@ -3,31 +3,28 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Game.Database; using osu.Game.Graphics; using OpenTK; using OpenTK.Graphics; +using System; namespace osu.Game.Beatmaps.Drawables { - internal class DifficultyIcon : Container - { - private readonly BeatmapInfo beatmap; - private OsuColour palette; - public DifficultyIcon(BeatmapInfo beatmap) + internal class DifficultyIcon : DifficultyColouredContainer + { + private BeatmapInfo beatmap; + + public DifficultyIcon(BeatmapInfo beatmap) : base(beatmap) { this.beatmap = beatmap; - const float size = 20; - Size = new Vector2(size); + Size = new Vector2(20); } [BackgroundDependencyLoader] - private void load(OsuColour palette) + private void load(OsuColour colours) { - this.palette = palette; - Children = new[] { new TextAwesome @@ -35,7 +32,7 @@ namespace osu.Game.Beatmaps.Drawables Anchor = Anchor.Centre, Origin = Anchor.Centre, TextSize = Size.X, - Colour = getColour(beatmap), + Colour = AccentColour, Icon = FontAwesome.fa_circle }, new TextAwesome @@ -48,43 +45,5 @@ namespace osu.Game.Beatmaps.Drawables } }; } - - private 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/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index a87d5f58a1..60e6221907 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using OpenTK; using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; @@ -148,11 +149,16 @@ namespace osu.Game.Screens.Select }, }, }, - // Text for beatmap info + new DifficultyColourBar(beatmap.BeatmapInfo) + { + RelativeSizeAxes = Axes.Y, + Width = 20, + }, new FillFlowContainer { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, + Name = "Top-aligned metadata", + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, Direction = FillDirection.Vertical, Margin = new MarginPadding { Top = 10, Left = 25, Right = 10, Bottom = 20 }, AutoSizeAxes = Axes.Both, @@ -161,16 +167,32 @@ namespace osu.Game.Screens.Select new OsuSpriteText { Font = @"Exo2.0-MediumItalic", - Text = metadata.Artist + " -- " + metadata.Title, + Text = beatmapInfo.Version, + TextSize = 24, + }, + } + }, + new FillFlowContainer + { + Name = "Bottom-aligned metadata", + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Direction = FillDirection.Vertical, + Margin = new MarginPadding { Top = 15, Left = 25, Right = 10, Bottom = 20 }, + AutoSizeAxes = Axes.Both, + Children = new Drawable[] + { + new OsuSpriteText + { + Font = @"Exo2.0-MediumItalic", + Text = !string.IsNullOrEmpty(metadata.Source) ? metadata.Source + " — " + metadata.Title : metadata.Title, TextSize = 28, - Shadow = true, }, new OsuSpriteText { Font = @"Exo2.0-MediumItalic", - Text = beatmapInfo.Version, + Text = metadata.Artist, TextSize = 17, - Shadow = true, }, new FillFlowContainer { @@ -184,20 +206,18 @@ namespace osu.Game.Screens.Select Font = @"Exo2.0-Medium", Text = "mapped by ", TextSize = 15, - Shadow = true, - }, + }, new OsuSpriteText { Font = @"Exo2.0-Bold", Text = metadata.Author, TextSize = 15, - Shadow = true, - }, + }, } }, new FillFlowContainer { - Margin = new MarginPadding { Top = 20 }, + Margin = new MarginPadding { Top = 20, Left = 10 }, Spacing = new Vector2(40, 0), AutoSizeAxes = Axes.Both, Children = labels @@ -256,5 +276,37 @@ namespace osu.Game.Screens.Select }; } } + + private class DifficultyColourBar : DifficultyColouredContainer + { + public DifficultyColourBar(BeatmapInfo beatmap) : base(beatmap) + { + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + const float full_opacity_ratio = 0.7f; + + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = AccentColour, + Width = full_opacity_ratio, + }, + new Box + { + RelativeSizeAxes = Axes.Both, + RelativePositionAxes = Axes.Both, + Colour = AccentColour, + Alpha = 0.5f, + X = full_opacity_ratio, + Width = 1 - full_opacity_ratio, + } + }; + } + } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index c9a3b08713..25df354aea 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -187,6 +187,7 @@ +