Skip to content

OrganiseLines

A static method in MainManager that automatically inserts line breaks to fit inside a constrained width (typically the textbox or other GUI elements). This is mostly used in SetText, but it is also used when calling the dialog via backtracking.

This method works on all languages except Japanese where it will immediately return text.

English works slightly differently as the line width calculations are broken (see OrganiseLines Known Issues for more details).

Signature

private static string OrganizeLines(string text, float maxoffset, float size, int fontid)

Parameters

text: string

The text to have the line breaks inserted.

maxoffset: float

The maximum width of a line. This is usually the linebreak's parameter sent to SetText, but it can be overridden by setbreak (doing so is not recommended).

size: float

The horizontal scale of the text. This is usually sent by SetText and corresponds to the current size.

fontid: int

The fonttype that will be used to render. Typically comes from SetText using the current one.

Returns

On Japanese, text is returned with no changes. On other languages, the same string is returned, but with LF inserted at places to indicate a line change (the LF are line commands without parameters in case singlebreak is present in the input string).

Remarks

There are a couple of caveats to this method because of its design. The main one is it is not able to "look ahead" of the input string so for example, it cannot know if there will be redirection or text replacement performed during processing. While there are some specific cases where this method actually processes commands (such as sstring and menu), they are far from exhaustive.

Additionally, there are some known issues that are important to mention which you can learn more at OrganiseLines Known Issues.

For details of the automatic line breaking procedure, see Organisation procedure.