Fix CreditsLogic to word-wrap the text.

This allows the text to be word-wrapped automatically, rather than the current approach of manually wrapping the source text.
This commit is contained in:
RoosterDragon
2024-09-19 21:15:16 +01:00
committed by abcdefg30
parent 073ce4a718
commit 833e6bd652
4 changed files with 29 additions and 42 deletions

View File

@@ -82,10 +82,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
isShowingModTab = modCredits;
scrollPanel.RemoveChildren();
var font = Game.Renderer.Fonts[template.Font];
foreach (var line in modCredits ? modLines : engineLines)
{
var label = template.Clone() as LabelWidget;
var label = (LabelWidget)template.Clone();
label.GetText = () => line;
var wrappedLine = line;
if (label.WordWrap)
wrappedLine = WidgetUtils.WrapText(line, label.Bounds.Width, font);
label.Bounds.Height = Math.Max(label.Bounds.Height, font.Measure(wrappedLine).Y);
scrollPanel.AddChild(label);
}
}