-
Notifications
You must be signed in to change notification settings - Fork 0
Creating A Custom Bracket
To create your own bracket that will be picked up by the update log, you'll need to inherit from the TaggedSegment class.
These 2 values will determine what the parser is matching against when checking the auto-generated regex.
For example:
<tag> would be the opening tag and </tag> would be the closing tag.
Final Result:
public override (string open, string close) Tags => ("<tag>", "</tag>");If you are using a self closing tag, put it into the open tag return value and leave the close tag return value null or empty.
For example:
<tag/> which would be the only tag searched for.
Final Result:
public override (string open, string close) Tags => ("<tag/>", string.Empty);This method determines the height that will be taken up by this bracket when given the innerText. In most cases it might be 0 (like with anchor and font which do not output anything and only change elements with the current GUIStyle) in which case you do not need to override this method. In other cases like with <img> you do need to reserve a defined amount of height. This will ensure the scrollable view is large enough to contain the description.
Handle what is drawn or shown for the text within these brackets on the dialog window. You are given the current Listing_Rich instance as well as the text between these custom brackets.
eg.
public override void SegmentAction(Listing_Rich lister, string innerText)
{
var font = Text.Font;
Text.Font = GameFont.Small;
innerText = "<b>" + innerText + "</b>";
Rect labelRect = lister.Label(innerText);
Widgets.DrawLineHorizontal(0, labelRect.y + Text.CalcHeight(innerText, 9999), labelRect.width);
Text.Font = font;
}This is what is written for the <title> tag which is included with this Modding tool.
And that's it. Once you create this class you can use the brackets within your description. The only thing you need to note is that elements created this way cannot be inlined, meaning you cannot apply this to text in the middle of a paragraph (like bold, italics, link, and underline). This will create a new section resulting in the bracket and text within it being pushed to a new line.