mirror of https://github.com/ppy/osu
Load text only after it comes on screen (and tidy up selection handling logic)
This commit is contained in:
parent
ace2bd2208
commit
2a786f9ec0
|
@ -50,12 +50,9 @@ protected override void LoadComplete()
|
||||||
var artist = new RomanisableString(metadata.ArtistUnicode, metadata.Artist);
|
var artist = new RomanisableString(metadata.ArtistUnicode, metadata.Artist);
|
||||||
|
|
||||||
titlePart = text.AddText(title, sprite => sprite.Font = OsuFont.GetFont(weight: FontWeight.Regular));
|
titlePart = text.AddText(title, sprite => sprite.Font = OsuFont.GetFont(weight: FontWeight.Regular));
|
||||||
|
|
||||||
updateSelectionState(true);
|
|
||||||
titlePart.DrawablePartsRecreated += _ => updateSelectionState(true);
|
titlePart.DrawablePartsRecreated += _ => updateSelectionState(true);
|
||||||
|
|
||||||
text.AddText(@" "); // to separate the title from the artist.
|
text.AddText(@" "); // to separate the title from the artist.
|
||||||
|
|
||||||
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);
|
||||||
|
@ -65,24 +62,31 @@ protected override void LoadComplete()
|
||||||
|
|
||||||
SelectedSet.BindValueChanged(set =>
|
SelectedSet.BindValueChanged(set =>
|
||||||
{
|
{
|
||||||
if (set.OldValue?.Equals(Model) != true && set.NewValue?.Equals(Model) != true)
|
bool newSelected = set.NewValue?.Equals(Model) == true;
|
||||||
|
|
||||||
|
if (newSelected == selected)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
selected = newSelected;
|
||||||
updateSelectionState(false);
|
updateSelectionState(false);
|
||||||
}, true);
|
});
|
||||||
|
|
||||||
|
updateSelectionState(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool selected;
|
||||||
|
|
||||||
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 ? colours.Yellow : Color4.White, instant ? 0 : FADE_DURATION);
|
s.FadeColour(selected ? colours.Yellow : Color4.White, instant ? 0 : FADE_DURATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Drawable CreateContent() => text = new OsuTextFlowContainer
|
protected override Drawable CreateContent() => new DelayedLoadWrapper(text = new OsuTextFlowContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
};
|
});
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue