mirror of
https://github.com/ppy/osu.git
synced 2025-02-16 11:42:56 +08:00
Proper playlist item text wrapping
This commit is contained in:
parent
67f1167172
commit
241895c85b
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
@ -300,7 +301,7 @@ namespace osu.Game.Overlays
|
|||||||
private Color4 current_colour;
|
private Color4 current_colour;
|
||||||
|
|
||||||
private TextAwesome icon;
|
private TextAwesome icon;
|
||||||
private OsuSpriteText title, artist;
|
private readonly IEnumerable<OsuSpriteText> title, artist;
|
||||||
|
|
||||||
public readonly int Index;
|
public readonly int Index;
|
||||||
public readonly BeatmapSetInfo RepresentedSet;
|
public readonly BeatmapSetInfo RepresentedSet;
|
||||||
@ -315,8 +316,9 @@ namespace osu.Game.Overlays
|
|||||||
if (value == current) return;
|
if (value == current) return;
|
||||||
current = value;
|
current = value;
|
||||||
|
|
||||||
//todo: fading off screen doesn't work
|
//todo: fading when masked away is broken
|
||||||
title.FadeColour(Current ? current_colour : Color4.White, fade_duration);
|
foreach (OsuSpriteText t in title)
|
||||||
|
t.FadeColour(Current ? current_colour : Color4.White, fade_duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,6 +331,14 @@ namespace osu.Game.Overlays
|
|||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
Padding = new MarginPadding { Top = 3, Bottom = 3 };
|
Padding = new MarginPadding { Top = 3, Bottom = 3 };
|
||||||
|
|
||||||
|
FillFlowContainer<OsuSpriteText> textContainer = new FillFlowContainer<OsuSpriteText>
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Padding = new MarginPadding { Left = 20 },
|
||||||
|
Spacing = new Vector2(5f, 0f),
|
||||||
|
};
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
icon = new TextAwesome
|
icon = new TextAwesome
|
||||||
@ -341,37 +351,38 @@ namespace osu.Game.Overlays
|
|||||||
Margin = new MarginPadding { Left = 5 },
|
Margin = new MarginPadding { Left = 5 },
|
||||||
Padding = new MarginPadding { Top = 2 },
|
Padding = new MarginPadding { Top = 2 },
|
||||||
},
|
},
|
||||||
new FillFlowContainer
|
textContainer,
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Padding = new MarginPadding { Left = 20 },
|
|
||||||
Spacing = new Vector2(10f, 0f),
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
title = new OsuSpriteText
|
|
||||||
{
|
|
||||||
TextSize = 16,
|
|
||||||
Font = @"Exo2.0-Regular",
|
|
||||||
Text = RepresentedSet.Metadata.Title,
|
|
||||||
},
|
|
||||||
artist = new OsuSpriteText
|
|
||||||
{
|
|
||||||
TextSize = 14,
|
|
||||||
Font = @"Exo2.0-Bold",
|
|
||||||
Text = RepresentedSet.Metadata.Artist,
|
|
||||||
Padding = new MarginPadding { Top = 1 },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
textContainer.Add(title = splitText(RepresentedSet.Metadata.Title, 16, @"Exo2.0-Regular", new MarginPadding(0)));
|
||||||
|
textContainer.Add(artist = splitText(RepresentedSet.Metadata.Artist, 14, @"Exo2.0-Bold", new MarginPadding { Top = 1 }));
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerable<OsuSpriteText> splitText(string text, int textSize, string font, MarginPadding padding)
|
||||||
|
{
|
||||||
|
List<OsuSpriteText> sprites = new List<OsuSpriteText>();
|
||||||
|
|
||||||
|
foreach (string w in text.Split(' '))
|
||||||
|
{
|
||||||
|
sprites.Add(new OsuSpriteText
|
||||||
|
{
|
||||||
|
TextSize = textSize,
|
||||||
|
Font = font,
|
||||||
|
Text = w,
|
||||||
|
Padding = padding,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return sprites;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
|
foreach (OsuSpriteText t in artist)
|
||||||
|
t.Colour = colours.Gray9;
|
||||||
|
|
||||||
icon.Colour = colours.Gray5;
|
icon.Colour = colours.Gray5;
|
||||||
artist.Colour = colours.Gray9;
|
|
||||||
current_colour = colours.Yellow;
|
current_colour = colours.Yellow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user