diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index 16978903a7..bde043d0d4 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -11,6 +11,9 @@ using osu.Game.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; using osu.Framework.Localisation; +using osu.Framework.Graphics.Sprites; +using System.Collections.Generic; +using System.Linq; namespace osu.Game.Overlays.Music { @@ -19,9 +22,13 @@ namespace osu.Game.Overlays.Music private const float fade_duration = 100; private Color4 hoverColour; + private Color4 artistColour; private TextAwesome handle; - private OsuSpriteText title; + private Paragraph text; + private IEnumerable titleSprites; + private UnicodeBindableString titleBind; + private UnicodeBindableString artistBind; public readonly BeatmapSetInfo BeatmapSetInfo; @@ -37,7 +44,8 @@ namespace osu.Game.Overlays.Music selected = value; Flush(true); - title.FadeColour(Selected ? hoverColour : Color4.White, fade_duration); + foreach (SpriteText s in titleSprites) + s.FadeColour(Selected ? hoverColour : Color4.White, fade_duration); } } @@ -53,8 +61,10 @@ namespace osu.Game.Overlays.Music [BackgroundDependencyLoader] private void load(OsuColour colours, LocalisationEngine localisation) { - BeatmapMetadata metadata = BeatmapSetInfo.Metadata; - + hoverColour = colours.Yellow; + artistColour = colours.Gray9; + + var metadata = BeatmapSetInfo.Metadata; FilterTerms = metadata.SearchableTerms; Children = new Drawable[] @@ -70,33 +80,46 @@ namespace osu.Game.Overlays.Music Margin = new MarginPadding { Left = 5 }, Padding = new MarginPadding { Top = 2 }, }, - new FillFlowContainer + text = new Paragraph { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Padding = new MarginPadding { Left = 20 }, - Spacing = new Vector2(5f, 0f), - Children = new [] - { - title = new OsuSpriteText - { - TextSize = 16, - Font = @"Exo2.0-Regular", - Current = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title), - }, - new OsuSpriteText - { - TextSize = 14, - Font = @"Exo2.0-Bold", - Colour = colours.Gray9, - Padding = new MarginPadding { Top = 1 }, - Current = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist), - } - } + ContentIndent = 10f, }, }; - hoverColour = colours.Yellow; + titleBind = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title); + artistBind = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist); + + titleBind.ValueChanged += newText => recreateText(); + titleBind.TriggerChange(); + } + + private void recreateText() + { + text.Clear(); + + var metadata = BeatmapSetInfo.Metadata; + var t = new List(); + + //space after the title to put a space between the title and artist + text.AddText(titleBind.Value + @" ", sprite => + { + sprite.TextSize = 16; + sprite.Font = @"Exo2.0-Regular"; + t.Add(sprite); + }); + + titleSprites = t; + + text.AddText(artistBind.Value, sprite => + { + sprite.TextSize = 14; + sprite.Font = @"Exo2.0-Bold"; + sprite.Colour = artistColour; + sprite.Padding = new MarginPadding { Top = 1 }; + }); } protected override bool OnHover(Framework.Input.InputState state)