Skip to content

Commit

Permalink
Will start fill the text after BDL loaded, so there's no need to add …
Browse files Browse the repository at this point in the history
…schedule in the child class.
  • Loading branch information
andy840119 committed Sep 4, 2022
1 parent 1f20dd3 commit 9c1917a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,13 @@ protected override void CreateDisplayContent(OsuTextFlowContainer textFlowContai
}
else
{
Schedule(() =>
{
// display the lyric order.
textFlowContainer.AddText($"#{model.Order}", x => x.Colour = colours.Yellow);
textFlowContainer.AddText(" ");

// main text
textFlowContainer.AddText(model.Text);
textFlowContainer.AddText(" ");
});
// display the lyric order.
textFlowContainer.AddText($"#{model.Order}", x => x.Colour = colours.Yellow);
textFlowContainer.AddText(" ");

// main text
textFlowContainer.AddText(model.Text);
textFlowContainer.AddText(" ");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,24 +147,21 @@ protected override bool OnClick(ClickEvent e)

protected override void CreateDisplayContent(OsuTextFlowContainer textFlowContainer, Lyric? model)
{
// should have disable style if lyric is not selectable.
textFlowContainer.Alpha = selectable(model) ? 1 : 0.5f;

base.CreateDisplayContent(textFlowContainer, model);

if (model == null)
return;

Schedule(() =>
{
// should have disable style if lyric is not selectable.
textFlowContainer.Alpha = selectable(model) ? 1 : 0.5f;

// add reference text at the end of the text.
int referenceLyricsAmount = EditorBeatmapUtils.GetAllReferenceLyrics(editorBeatmap, model).Count();
// add reference text at the end of the text.
int referenceLyricsAmount = EditorBeatmapUtils.GetAllReferenceLyrics(editorBeatmap, model).Count();

if (referenceLyricsAmount > 0)
{
textFlowContainer.AddText($"({referenceLyricsAmount} reference)", x => x.Colour = colours.Red);
}
});
if (referenceLyricsAmount > 0)
{
textFlowContainer.AddText($"({referenceLyricsAmount} reference)", x => x.Colour = colours.Red);
}
}

private bool selectable(Lyric? lyric)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,14 @@ protected override void LoadComplete()
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
}.With(x => CreateDisplayContent(x, Model));
}.With(x =>
{
Schedule(() =>
{
// should create the text after BDL loaded.
CreateDisplayContent(x, Model);
});
});

protected override bool OnClick(ClickEvent e)
{
Expand Down
23 changes: 10 additions & 13 deletions osu.Game.Rulesets.Karaoke/Graphics/UserInterfaceV2/FontSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,21 +271,18 @@ public DrawableFontFamilyListItem(string item)
protected override void CreateDisplayContent(OsuTextFlowContainer textFlowContainer, string model)
{
textFlowContainer.TextAnchor = Anchor.BottomLeft;
Schedule(() =>
{
textFlowContainer.AddText(model);
textFlowContainer.AddText(model);

var matchedFormat = fontManager.Fonts
.Where(x => x.Family == Model).Select(x => x.FontFormat)
.Distinct()
.ToArray();
var matchedFormat = fontManager.Fonts
.Where(x => x.Family == Model).Select(x => x.FontFormat)
.Distinct()
.ToArray();

foreach (var format in matchedFormat)
{
textFlowContainer.AddText(" ");
textFlowContainer.AddArbitraryDrawable(new FontFormatBadge(format));
}
});
foreach (var format in matchedFormat)
{
textFlowContainer.AddText(" ");
textFlowContainer.AddArbitraryDrawable(new FontFormatBadge(format));
}
}
}
}
Expand Down

0 comments on commit 9c1917a

Please sign in to comment.