mirror of
https://github.com/ppy/osu
synced 2024-12-15 03:16:17 +00:00
Remove custom word splitting logic, add localisation support.
This commit is contained in:
parent
2cfb83436d
commit
0f4ef16910
@ -12,16 +12,18 @@ using osu.Game.Graphics;
|
|||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Music
|
namespace osu.Game.Overlays.Music
|
||||||
{
|
{
|
||||||
internal class PlaylistItem : Container
|
internal class PlaylistItem : Container
|
||||||
{
|
{
|
||||||
private const float fade_duration = 100;
|
private const float fade_duration = 100;
|
||||||
private Color4 currentColour;
|
|
||||||
|
|
||||||
private readonly TextAwesome icon;
|
private Color4 hoverColour;
|
||||||
private readonly IEnumerable<OsuSpriteText> title, artist;
|
|
||||||
|
private TextAwesome handle;
|
||||||
|
private OsuSpriteText title;
|
||||||
|
|
||||||
public readonly BeatmapSetInfo BeatmapSetInfo;
|
public readonly BeatmapSetInfo BeatmapSetInfo;
|
||||||
|
|
||||||
@ -37,8 +39,7 @@ namespace osu.Game.Overlays.Music
|
|||||||
selected = value;
|
selected = value;
|
||||||
|
|
||||||
Flush(true);
|
Flush(true);
|
||||||
foreach (OsuSpriteText t in title)
|
title.FadeColour(Selected ? hoverColour : Color4.White, fade_duration);
|
||||||
t.FadeColour(Selected ? currentColour : Color4.White, fade_duration);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,72 +50,65 @@ namespace osu.Game.Overlays.Music
|
|||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
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>
|
[BackgroundDependencyLoader]
|
||||||
{
|
private void load(OsuColour colours, LocalisationEngine localisation)
|
||||||
RelativeSizeAxes = Axes.X,
|
{
|
||||||
AutoSizeAxes = Axes.Y,
|
BeatmapMetadata metadata = BeatmapSetInfo.Metadata;
|
||||||
Padding = new MarginPadding { Left = 20 },
|
|
||||||
Spacing = new Vector2(5f, 0f),
|
|
||||||
};
|
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
icon = new TextAwesome
|
handle = new TextAwesome
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopLeft,
|
Anchor = Anchor.TopLeft,
|
||||||
Origin = Anchor.TopLeft,
|
Origin = Anchor.TopLeft,
|
||||||
TextSize = 12,
|
TextSize = 12,
|
||||||
|
Colour = colours.Gray5,
|
||||||
Icon = FontAwesome.fa_bars,
|
Icon = FontAwesome.fa_bars,
|
||||||
Alpha = 0f,
|
Alpha = 0f,
|
||||||
Margin = new MarginPadding { Left = 5 },
|
Margin = new MarginPadding { Left = 5 },
|
||||||
Padding = new MarginPadding { Top = 2 },
|
Padding = new MarginPadding { Top = 2 },
|
||||||
},
|
},
|
||||||
textContainer,
|
new FillFlowContainer<OsuSpriteText>
|
||||||
|
{
|
||||||
|
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),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
textContainer.Add(title = splitText(BeatmapSetInfo.Metadata.Title, 16, @"Exo2.0-Regular", new MarginPadding(0)));
|
hoverColour = colours.Yellow;
|
||||||
textContainer.Add(artist = splitText(BeatmapSetInfo.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]
|
|
||||||
private void load(OsuColour colours)
|
|
||||||
{
|
|
||||||
foreach (OsuSpriteText t in artist)
|
|
||||||
t.Colour = colours.Gray9;
|
|
||||||
|
|
||||||
icon.Colour = colours.Gray5;
|
|
||||||
currentColour = colours.Yellow;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnHover(Framework.Input.InputState state)
|
protected override bool OnHover(Framework.Input.InputState state)
|
||||||
{
|
{
|
||||||
icon.FadeIn(fade_duration);
|
handle.FadeIn(fade_duration);
|
||||||
|
|
||||||
return base.OnHover(state);
|
return base.OnHover(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnHoverLost(Framework.Input.InputState state)
|
protected override void OnHoverLost(Framework.Input.InputState state)
|
||||||
{
|
{
|
||||||
icon.FadeOut(fade_duration);
|
handle.FadeOut(fade_duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnClick(Framework.Input.InputState state)
|
protected override bool OnClick(Framework.Input.InputState state)
|
||||||
|
Loading…
Reference in New Issue
Block a user