Structured Text: Difference between revisions
Killzone Kid (talk | contribs) (→Size: clarified) |
Killzone Kid (talk | contribs) (tidying up) |
||
Line 1: | Line 1: | ||
== Description == | == Description == | ||
Rich text is able to include images and formatting. | Rich text, which is able to include images and formatting. It can be created using XML like syntax, as seen in [[parseText]]. Introduced with Armed Assault, does not refer to Cold War Crisis or Resistance. | ||
It can be created using XML like syntax, as seen in [[parseText]]. | |||
Introduced with Armed Assault, does not refer to Cold War Crisis or Resistance. | |||
'''Related commands:''' [[parseText]], [[composeText]], [[ctrlSetStructuredText]], [[hintC_structuredText]] | '''Related commands:''' [[parseText]], [[composeText]], [[ctrlSetStructuredText]], [[hintC_structuredText]] | ||
== Attributes == | == Attributes == | ||
Line 34: | Line 20: | ||
* <tt>colorLink</tt> | * <tt>colorLink</tt> | ||
== | == Formats == | ||
=== Line break === | === Line break === | ||
Line 61: | Line 47: | ||
};</syntaxhighlight> | };</syntaxhighlight> | ||
Then the structured text: | |||
<code>_control [[ctrlSetStructuredText]] [[parseText]] "<t size='2'>Hello!</t>";</code> | <code>_control [[ctrlSetStructuredText]] [[parseText]] "<t size='2'>Hello!</t>";</code> | ||
Will result in a total text size of 0.04*2 = 0.08. Unfortunately, there is no script command to set or get the value of config <tt>size</tt> property dynamically. | |||
=== Font === | === Font === | ||
Line 96: | Line 82: | ||
[[Category: Data Types]] | [[Category: Data Types]] | ||
=== | === Space === | ||
A non-break space, commonly known as '''&nbsp;''' shows as '''?''' in structured text control. Use alternative which is:'''&#160;''' | |||
<t size='2.0'>FIVE&#160;&#160;&#160;&#160;&#160;SPACES</t> | |||
=== Syntax === | |||
All operator types values should be encapsulated with <nowiki>''</nowiki>, for example, the following will log an .rpt error "Unknown attribute .0" and only 2 would be taken into account: | All operator types values should be encapsulated with <nowiki>''</nowiki>, for example, the following will log an .rpt error "Unknown attribute .0" and only 2 would be taken into account: | ||
<t size=2.0>Large text</t> | <t size=2.0>Large text</t> | ||
While the following is correct: | While the following is correct: | ||
<t size='2.0'>Large text</t> | <t size='2.0'>Large text</t> | ||
== Code Examples: == | |||
<code>_separator1 = [[parseText]] <nowiki>"<br />------------------------<br /></nowiki>"; | |||
_image = "\ca\ui\textures\aus_flag.paa"; | |||
_txt = [[composeText]] <nowiki>[</nowiki>[[image]] _image, "Heading Text", _separator1, "Content"]; | |||
[[hint]] _txt;</code> |
Revision as of 16:04, 3 September 2018
Description
Rich text, which is able to include images and formatting. It can be created using XML like syntax, as seen in parseText. Introduced with Armed Assault, does not refer to Cold War Crisis or Resistance.
Related commands: parseText, composeText, ctrlSetStructuredText, hintC_structuredText
Attributes
The following inline text attributes are supported:
- size
- align
- valign
- color
- font
- image
- shadow
- shadowOffset
- shadowColor
- underline
- href
- colorLink
Formats
Line break
Line breaks can also be inserted via the composeText and lineBreak commands
<br />
Image
Images can also be inserted via the composeText and image commands
<img image='red.paa' />
Color
<t color='#ff0000'>Red text</t> <t color='#99ffffff'>Transparent white text</t> <t colorLink='#0000ff'><a href='http://www.arma3.com/'>Blue link</a></t>
Size
The multiplier for the value of control config property size. Default is 1, meaning that the height of letters will be equal to the value set in config. Setting this to 2 will make letters 2 times the size, etc. If the control is defined as follows:
class MyStructuredText: RscStructuredText
{
...
text = "Hello!";
size = 0.04;
...
};
Then the structured text:
_control ctrlSetStructuredText parseText "<t size='2'>Hello!</t>";
Will result in a total text size of 0.04*2 = 0.08. Unfortunately, there is no script command to set or get the value of config size property dynamically.
Font
Font are defined in CfgFontFamilies
<t font='Zeppelin33'>Bold Text</t>
Align
Parameter can be 'left', 'center', 'right'
<t align='center'>Centered Text</t>
Underline
<t underline='true'>Underlined Text</t>
NOTE: Using regular spaces might split the underline between words. To have a continuous underline, you must use non-breaking spaces, via Alt+255 or the following code:
format ["<t underline='true'>%1</t>", "Underlined Text" splitString " " joinString toString [160]]
Shadow
Parameter can be '0' (no shadow), '1' (classic shadow, can be colored), '2' outline (always black)
<t shadow='1'>Text with shadow</t> <t shadow='1' shadowColor='#ff0000'>Text with red Shadow</t> <t shadow='2'>Text with outline</t>
Hyperlink
Since ["Arma 3","Arma3",125,126163,"Development"]
<a href='http://google.com'>Google</a> <a color='#0000FF' href='http://arma3.com'>Arma 3</a> <a underline='true' color='#0000FF' href='http://killzonekid.com'>KK's blog</a>
Create clickable image:
_ctrl = findDisplay 46 createDisplay "RscDisplayEmpty" ctrlCreate ["RscStructuredText", -1];
_ctrl ctrlSetPosition [0,0,1,1];
_ctrl ctrlCommit 0;
_ctrl ctrlSetStructuredText parseText "<a color='#00FF00' size='5' href='http://arma3.com'><img image='\A3\weapons_f\ammoBoxes\data\ui\map_AmmoBox_F_CA.paa' /></a>";
Space
A non-break space, commonly known as shows as ? in structured text control. Use alternative which is: 
<t size='2.0'>FIVE     SPACES</t>
Syntax
All operator types values should be encapsulated with '', for example, the following will log an .rpt error "Unknown attribute .0" and only 2 would be taken into account:
<t size=2.0>Large text</t>
While the following is correct:
<t size='2.0'>Large text</t>
Code Examples:
_separator1 = parseText "<br />------------------------<br />";
_image = "\ca\ui\textures\aus_flag.paa";
_txt = composeText [image _image, "Heading Text", _separator1, "Content"];
hint _txt;