What options are available when using text?

General Tso

Panzer General
Joined
Oct 12, 2007
Messages
1,547
Location
U. S. of A.
I'm trying to be a good little programmer and use text keys but I'm not sure if it's possible. I have multiple lines of text in one text key. I would like to able to control whether individual lines of text are centered or left justified. It would also be nice if I could control the font size for each line.
 
I have tried everything I can think of to make the formatting work the way I want to but it's been to no avail. I guess I'll use Lua and create separate lines of text that can be controlled the way I want. I can always switch the individual lines to text keys later.

Since I plan on using ConvertTextKey when creating the lines in Lua I'm still interested in finding out if there are any built in options other than the ones listed above. If anybody has any insight that would be great. I can always add it to the first post so that people have one place to find out about texts options.
 
To change font size and centering, AFAIK the only way is to change the XML template associated with your Lua file. If you want to have different font sizes and centering choices [for given lines of text], you need to add a new field to the XML.
 
You can do it through Lua as long as you have the control object for what ever you are formatting. The control object contains functions for many of the XML fields. For example to change the font it would be something like - control:SetFontByName("TwCenMT20").
 
Yeah. I'm creating them from scratch. Sorry about the confusion.
 
Adding fields to the XML for each line is the way to go if you only have a few known number of lines. For a more generic solution,

In the XML add an empty, downward growing stack where you want the text to appear. Also add an instance that contains a single label

In the Lua, create an instance manager for the stack with the label instance. Write a helper method that a) clears the stack, b) splits the inbound text message into separate strings at the [NEWLINE] marker, c) for each line string add an instance to the stack and set the defaults for the label, eg Font 16, left aligned, d) parse out any pseudo-codes, eg [FONT20], [CENTRE] at the start and set the label to have those values, e) add the remaining text to the label
 
Thanks. That's what I ended up doing. For now I just placed the text in a Lua table one line at a time along with formatting data as needed.
 
Top Bottom