-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This wiki explains how to use the addon in probably the best way possible to get maximum of it's usage.
The primary tool of this addon is Textbuilder class, which allows us to build formatted text in specified bounds, font, scale, color and so on.
TextBuilder(SpriteFont font, string text, Vector2 pos, Vector2 size, Color color = default, bool applyformat = true, Textarea label = null)
- font — set textbuilder's font
- text — text to display
- pos — initial position of the text
- size — bounds to contain the text inside (basically used to newline)
- color — default text color
- applyformat — whether or not to ignore text formatting rules (command definitions will be left as is)
- label — attach a textarea to this textbuilder
SpriteFont Font | Set this Textbuilder's font |
string Text | Set this Textbuilder's text |
Vector2 ScrollPosition | Get/set scrolling position of the Textbuilder |
Vector2 Position | Get/set total offset of the Textbuilder |
float FontSize | Get/set text scale of the Textbuilder's text |
Text formatter uses following styling syntax:
{%command1%(%c1params%):%c1_directives%;%command2%(%c2params%):%c2_directives%; . . .;%commandN%(%cNparams%):%cN_directives%;}So the command definition should not: contain any spaces inside.
And the command definition should: contain parentheses "()" for each rule (except for propstopper) after rule's name (even if it doesn't have any parameters on input) and semicolon at the end.
Example command:
{normal();}mytext
There are several predefined style rules to use for text formatting:
Name | Description | Params | Example |
---|---|---|---|
{blue} | Set blue color of the text (sample rule) | () | {blue();}bluetext |
{#} | Set RGB values of the text color | (red,green,blue) | {#(0,255,255);}cyan |
{@p} | Stops rule propagation | — | {#(0,255,255):p;}cyan text{@p;} not touched |
Directives are special subcommands used as a pointer to execute some internal operation. Currently, there are two of them: h and p.
h (hover) used to mark the rule to apply when mouse cursor hover over the word.
p (propagate) used to spread the rule to further words until propstopper appears.
It's possible to expand formatting rules for further words inside the text via "p" directive:
{#(0,255,255):p;}mytext is now cyan{@p;} but not this
So you don't need to put the rule for each word by just defining it once for selected region of the text.
The "{@p;}" command is used to stop rule propagation, so the further text won't be touched by current propagation rule.
If you want apply a rule when cursor hover over the word, you can use "h" directive:
{#(0,255,255):h;}hoverable
You can apply your rules by writing them in one sequence and even combine their directives:
Press Gal{#(85,185,255):p;#(25,125,255):h,p;}axy Map but{@p;}ton
There we have one command of two rules. One coloring-propagation and one coloring-hover-propagation. First one will set default blue color for each word and last will set the color-on-hover rule.
(Under construction)