mirror of
https://github.com/ppy/osu
synced 2024-12-18 04:46:09 +00:00
Remove manual romanisation handling in PlaylistItem
This commit is contained in:
parent
ed00cd9fc5
commit
d218e7d935
@ -25,9 +25,6 @@ namespace osu.Game.Overlays.Music
|
|||||||
private TextFlowContainer text;
|
private TextFlowContainer text;
|
||||||
private ITextPart titlePart;
|
private ITextPart titlePart;
|
||||||
|
|
||||||
private ILocalisedBindableString title;
|
|
||||||
private ILocalisedBindableString artist;
|
|
||||||
|
|
||||||
private Color4 selectedColour;
|
private Color4 selectedColour;
|
||||||
private Color4 artistColour;
|
private Color4 artistColour;
|
||||||
|
|
||||||
@ -45,17 +42,12 @@ namespace osu.Game.Overlays.Music
|
|||||||
selectedColour = colours.Yellow;
|
selectedColour = colours.Yellow;
|
||||||
artistColour = colours.Gray9;
|
artistColour = colours.Gray9;
|
||||||
HandleColour = colours.Gray5;
|
HandleColour = colours.Gray5;
|
||||||
|
|
||||||
title = localisation.GetLocalisedBindableString(new RomanisableString(Model.Metadata.TitleUnicode, Model.Metadata.Title));
|
|
||||||
artist = localisation.GetLocalisedBindableString(new RomanisableString(Model.Metadata.ArtistUnicode, Model.Metadata.Artist));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
artist.BindValueChanged(_ => recreateText(), true);
|
|
||||||
|
|
||||||
SelectedSet.BindValueChanged(set =>
|
SelectedSet.BindValueChanged(set =>
|
||||||
{
|
{
|
||||||
if (set.OldValue?.Equals(Model) != true && set.NewValue?.Equals(Model) != true)
|
if (set.OldValue?.Equals(Model) != true && set.NewValue?.Equals(Model) != true)
|
||||||
@ -71,26 +63,31 @@ namespace osu.Game.Overlays.Music
|
|||||||
s.FadeColour(SelectedSet.Value?.Equals(Model) == true ? selectedColour : Color4.White, instant ? 0 : FADE_DURATION);
|
s.FadeColour(SelectedSet.Value?.Equals(Model) == true ? selectedColour : Color4.White, instant ? 0 : FADE_DURATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Drawable CreateContent() => text = new OsuTextFlowContainer
|
protected override Drawable CreateContent()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
text = new OsuTextFlowContainer
|
||||||
AutoSizeAxes = Axes.Y,
|
{
|
||||||
};
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
};
|
||||||
|
|
||||||
private void recreateText()
|
var title = new RomanisableString(Model.Metadata.TitleUnicode, Model.Metadata.Title);
|
||||||
{
|
var artist = new RomanisableString(Model.Metadata.ArtistUnicode, Model.Metadata.Artist);
|
||||||
text.Clear();
|
|
||||||
|
|
||||||
// space after the title to put a space between the title and artist
|
titlePart = text.AddText(title, sprite => sprite.Font = OsuFont.GetFont(weight: FontWeight.Regular));
|
||||||
titlePart = text.AddText(title.Value + @" ", sprite => sprite.Font = OsuFont.GetFont(weight: FontWeight.Regular));
|
|
||||||
updateSelectionState(true);
|
updateSelectionState(true);
|
||||||
|
titlePart.DrawablePartsRecreated += _ => updateSelectionState(true);
|
||||||
|
|
||||||
text.AddText(artist.Value, sprite =>
|
text.AddText(@" "); // to separate the title from the artist.
|
||||||
|
|
||||||
|
text.AddText(artist, sprite =>
|
||||||
{
|
{
|
||||||
sprite.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold);
|
sprite.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold);
|
||||||
sprite.Colour = artistColour;
|
sprite.Colour = artistColour;
|
||||||
sprite.Padding = new MarginPadding { Top = 1 };
|
sprite.Padding = new MarginPadding { Top = 1 };
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
|
Loading…
Reference in New Issue
Block a user