Back to TPG

TPG.UI.Wrap

C🏷️ Palette

Part of TPG namespace

TPG.UI.Wrap(text, font, maxW, maxLines)
View on GitHub|gamemode/config/sh_palette.lua:427-455
📋 Has LDoc👁️ 0 viewsUpdated 1 month ago

Description

Break text into lines that each fit a width, splitting between words. TPG.UI.Truncate is the right answer for a NAME: one line, an ellipsis, the full text a tooltip away. It is the wrong answer for a SENTENCE. The loadout menu's slot descriptions explain what a cooldown actually costs you, and a single line cut them at "until it runs out you spawn with the fre...", the setup with the answer missing, and nowhere else to read it. A word wider than the whole box gets a clipped line of its own (via Truncate) rather than being dropped or looping forever; a weapon pack is free to ship one. maxLines caps the block, because this text sits above a grid and a long description must not be able to push the grid off the panel. Everything past the cap is folded back onto the last line kept, so the ellipsis lands where the text really stops rather than at the end of a line that happened to fit. the tail is folded onto the last line and truncated with an ellipsis. (returns { "" }).

Parameters

NameTypeDescription
textstring
fontstringA font name already created by `TPG.UI.BuildFonts`.
maxWnumberMaximum width per line, in pixels.
maxLines?numberIf given, caps the number of lines returned;

Returns

TypeDescription
{string,...}At least one line, even for an empty/nil `text`

Examples

No examples available.

Used In

No usages found in the codebase.