Fix `PlaylistItem` attempting to read from `OsuColour` dependency too early

This commit is contained in:
Bartłomiej Dach 2021-11-02 23:19:45 +01:00
parent e4e8390a8a
commit 494d582830
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497
1 changed files with 13 additions and 15 deletions

View File

@ -25,8 +25,8 @@ public class PlaylistItem : OsuRearrangeableListItem<BeatmapSetInfo>, IFilterabl
private TextFlowContainer text; private TextFlowContainer text;
private ITextPart titlePart; private ITextPart titlePart;
private Color4 selectedColour; [Resolved]
private Color4 artistColour; private OsuColour colours { get; set; }
public PlaylistItem(BeatmapSetInfo item) public PlaylistItem(BeatmapSetInfo item)
: base(item) : base(item)
@ -37,10 +37,8 @@ public PlaylistItem(BeatmapSetInfo item)
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours, LocalisationManager localisation) private void load()
{ {
selectedColour = colours.Yellow;
artistColour = colours.Gray9;
HandleColour = colours.Gray5; HandleColour = colours.Gray5;
} }
@ -60,17 +58,19 @@ protected override void LoadComplete()
private void updateSelectionState(bool instant) private void updateSelectionState(bool instant)
{ {
foreach (Drawable s in titlePart.Drawables) foreach (Drawable s in titlePart.Drawables)
s.FadeColour(SelectedSet.Value?.Equals(Model) == true ? selectedColour : Color4.White, instant ? 0 : FADE_DURATION); s.FadeColour(SelectedSet.Value?.Equals(Model) == true ? colours.Yellow : Color4.White, instant ? 0 : FADE_DURATION);
} }
protected override Drawable CreateContent() protected override Drawable CreateContent() => text = new OsuTextFlowContainer
{
text = new OsuTextFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
}; };
protected override void LoadAsyncComplete()
{
base.LoadAsyncComplete();
var title = new RomanisableString(Model.Metadata.TitleUnicode, Model.Metadata.Title); var title = new RomanisableString(Model.Metadata.TitleUnicode, Model.Metadata.Title);
var artist = new RomanisableString(Model.Metadata.ArtistUnicode, Model.Metadata.Artist); var artist = new RomanisableString(Model.Metadata.ArtistUnicode, Model.Metadata.Artist);
@ -83,11 +83,9 @@ protected override Drawable CreateContent()
text.AddText(artist, sprite => 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 = colours.Gray9;
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)