Structured Text: Difference between revisions
Lou Montana (talk | contribs) m (Text replacement - "\{\{ArgTitle *\| *([^\|]+) *\| *([1-6]) *\|" to "{{ArgTitle|$2|$1|") |
Lou Montana (talk | contribs) m (Text replacement - "<tt>([a-zA-Z0-9\. _"\\']+)<\/tt>" to "{{hl|$1}}") |
||
Line 15: | Line 15: | ||
=== Syntax === | === Syntax === | ||
All attribute values should be encapsulated in double | All attribute values should be encapsulated in double {{hl|"..."}} or single {{hl|'...'}} quotes. Both of the following are correct: | ||
<syntaxhighlight lang="html"> | <syntaxhighlight lang="html"> | ||
<t size="2.0">Large text</t> | <t size="2.0">Large text</t> | ||
Line 21: | Line 21: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{Feature|warning|The following will log an ''.rpt'' error | {{Feature|warning|The following will log an ''.rpt'' error {{hl|Unknown attribute .0}} and only number 2 would be taken into account: | ||
<syntaxhighlight lang="html"> | <syntaxhighlight lang="html"> | ||
<t size=2.0>Large text</t> | <t size=2.0>Large text</t> | ||
Line 80: | Line 80: | ||
The following inline attributes are supported: | The following inline attributes are supported: | ||
{{Columns|4| | {{Columns|4| | ||
* | * {{hl|size}} | ||
* | * {{hl|color}} | ||
* | * {{hl|font}} | ||
* | * {{hl|align}} | ||
* | * {{hl|valign}} | ||
* | * {{hl|underline}} | ||
* | * {{hl|shadow}} | ||
* | * {{hl|shadowColor}} | ||
* | * {{hl|shadowOffset}} | ||
* | * {{hl|colorLink}} | ||
* | * {{hl|href}} | ||
* | * {{hl|image}} | ||
}} | }} | ||
=== Size === | === Size === | ||
The structured text | The structured text {{hl|size}} attribute is a multiplier for the value of control config property {{hl|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, 0.5 will make them half the size, etc. If the control is defined as follows: | ||
<syntaxhighlight lang="cpp"> | <syntaxhighlight lang="cpp"> | ||
Line 110: | Line 110: | ||
Then the structured text: | Then the structured text: | ||
_control [[ctrlSetStructuredText]] [[parseText]] "<t size='2'>Hello!</t>"; | _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 | 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 {{hl|size}} property dynamically. | ||
=== Color === | === Color === | ||
The | The {{hl|color}} attribute is similar to HTML hex color and could either have format {{Wikipedia|RGB|#RRGGBB}} or {{Wikipedia|ARGB|#AARRGGBB}}. | ||
<syntaxhighlight lang="html"> | <syntaxhighlight lang="html"> | ||
<t color='#ff0000'>Red text</t> | <t color='#ff0000'>Red text</t> | ||
Line 122: | Line 122: | ||
=== Font === | === Font === | ||
The value for the | The value for the {{hl|font}} attribute could be found in {{hl|CfgFontFamilies}} config. Some of the {{arma3}} fonts: | ||
{{Columns|4| | {{Columns|4| | ||
* | * {{hl|EtelkaMonospacePro}} | ||
* | * {{hl|EtelkaMonospaceProBold}} | ||
* | * {{hl|EtelkaNarrowMediumPro}} | ||
* | * {{hl|LCD14}} | ||
* | * {{hl|LucidaConsoleB}} | ||
* | * {{hl|PuristaBold}} | ||
* | * {{hl|PuristaLight}} | ||
* | * {{hl|PuristaMedium}} | ||
* | * {{hl|PuristaSemibold}} | ||
* | * {{hl|RobotoCondensed}} | ||
* | * {{hl|RobotoCondensedBold}} | ||
* | * {{hl|RobotoCondensedLight}} | ||
* | * {{hl|TahomaB}} | ||
}} | }} | ||
<syntaxhighlight lang="html"> | <syntaxhighlight lang="html"> | ||
Line 145: | Line 145: | ||
=== Horizontal Alignment === | === Horizontal Alignment === | ||
The | The {{hl|align}} attribute controls horizontal text alignment and could be one of the following: | ||
* | * {{hl|left}} | ||
* | * {{hl|center}} | ||
* | * {{hl|right}} | ||
<syntaxhighlight lang="html"> | <syntaxhighlight lang="html"> | ||
<t align='right'>Text displayed to the right</t> | <t align='right'>Text displayed to the right</t> | ||
Line 155: | Line 155: | ||
=== Vertical Alignment === | === Vertical Alignment === | ||
The | The {{hl|valign}} attribute controls vertical text alignment and could be one of the following: | ||
* | * {{hl|top}} | ||
* | * {{hl|middle}} | ||
* | * {{hl|bottom}} | ||
<syntaxhighlight lang="html"> | <syntaxhighlight lang="html"> | ||
<t valign='bottom'>Text displayed at the bottom</t> | <t valign='bottom'>Text displayed at the bottom</t> | ||
Line 165: | Line 165: | ||
=== Underline === | === Underline === | ||
The | The {{hl|underline}} attribute underlines each individual word in text. The normal spaces are not underlined. | ||
<syntaxhighlight lang="html"> | <syntaxhighlight lang="html"> | ||
<t underline='1'>Underlined Text</t> | <t underline='1'>Underlined Text</t> | ||
Line 178: | Line 178: | ||
=== Shadow === | === Shadow === | ||
The | The {{hl|shadow}} attribute controls the appearance of shadow/outline around text and could be one of the following: | ||
* | * {{hl|0}} - normal text | ||
* | * {{hl|1}} - classic shadow (text ghosting below and to the right) | ||
* | * {{hl|2}} - outline (slight, always black, outline around characters) | ||
<syntaxhighlight lang="html"> | <syntaxhighlight lang="html"> | ||
<t shadow='0'>Text with no shadow</t> | <t shadow='0'>Text with no shadow</t> | ||
Line 190: | Line 190: | ||
=== Shadow Color === | === Shadow Color === | ||
The | The {{hl|shadowColor}} attribute controls the color of the shadow (not the outline, which is always black for some reason) | ||
<syntaxhighlight lang="html"> | <syntaxhighlight lang="html"> | ||
<t shadow='1' shadowColor='#ff0000'>Text with red shadow</t> | <t shadow='1' shadowColor='#ff0000'>Text with red shadow</t> | ||
Line 197: | Line 197: | ||
=== Shadow Offset === | === Shadow Offset === | ||
The | The {{hl|shadowOffset}} attribute controls how far is the shadow offset from the text source (has no effect on the outline) | ||
<syntaxhighlight lang="html"> | <syntaxhighlight lang="html"> | ||
<t shadow='1' shadowColor='#ff0000' shadowOffset='0.5'>Text with red shadow, which is offset by half character size</t> | <t shadow='1' shadowColor='#ff0000' shadowOffset='0.5'>Text with red shadow, which is offset by half character size</t> | ||
Line 213: | Line 213: | ||
=== Hyperlink Reference === | === Hyperlink Reference === | ||
The | The {{hl|href}} attribute is essential part of the <tt><nowiki><a></nowiki></tt> tag and should contain URL of the destination (See [[#Hyperlink | Hyperlink]]). | ||
=== Image Reference === | === Image Reference === | ||
The | The {{hl|image}} attribute is essential part of the <tt><nowiki><img></nowiki></tt> tag and should contain filepath to the image (See [[Structured_Text#Image | Image]]). | ||
== SQF Code Examples == | == SQF Code Examples == | ||
{{hl|align}} {{hl|valign}} demo: | |||
<code>[[hint]] [[parseText]] "<t size='3'><t size='1' valign='top' align='right'>Top Right</t> <t size='1' valign='middle' align='center'>Middle Center</t> <t size='1' valign='bottom' align='left'>Bottom Left</t></t>";</code> | <code>[[hint]] [[parseText]] "<t size='3'><t size='1' valign='top' align='right'>Top Right</t> <t size='1' valign='middle' align='center'>Middle Center</t> <t size='1' valign='bottom' align='left'>Bottom Left</t></t>";</code> | ||
{{Feature | Informative | Sometimes an extra space is required when outputting to [[hint]]. In the above example spaces between <tt><nowiki><t></nowiki></tt>s inside another <tt><nowiki><t></nowiki></tt> wrapper ensure that the hint will be 3 lines tall}} | {{Feature | Informative | Sometimes an extra space is required when outputting to [[hint]]. In the above example spaces between <tt><nowiki><t></nowiki></tt>s inside another <tt><nowiki><t></nowiki></tt> wrapper ensure that the hint will be 3 lines tall}} |
Revision as of 23:55, 15 November 2021
Structured Text is a Data Type that has been introduced with Armed Assault. It is a rich text, which is able to include images and formatting. It can be created using XML-like syntax, as seen below. However, using XML-like syntax alone is not going to turn a normal string into structured text, it should be converted to TEXT first.
Commands
- See Command Group: Structured Text for all related commands.
Markups
Syntax
All attribute values should be encapsulated in double "..." or single '...' quotes. Both of the following are correct:
<t size="2.0">Large text</t>
<t size='2.0'>Large text</t>
Text
Texts could be created with the following markup:
<t>Hello World!</t>
Or could also be inserted via the composeText / formatText and text commands.
Non-breaking space
A non-breaking space, commonly known as shows as ? in structured text control. Use   as an alternative.
<t>FIVE     SPACES</t>
Line break
Line breaks could be created with either of the following markups:
<br/>
<br />
<br></br>
Or could also be inserted via the composeText / formatText and lineBreak commands.
Image
Images could be created with either of the following markups:
<img image='\a3\Data_f\Flags\flag_Altis_co.paa'/>
<img image='\a3\Data_f\Flags\flag_Altis_co.paa' />
<img image='\a3\Data_f\Flags\flag_Altis_co.paa'></img>
Or could also be inserted via the composeText / formatText and image commands.
Hyperlink
Clickable links, similar to HTML hyperlinks, could be created with the following markup:
<a href='http://arma3.com'>Arma 3</a>
By default the links are not underlined or have a different color to stand out. These attributes should be added separately.
Note: & should be escaped by &.
<a href='https://arma3.com/?foo&bar'>Example URL A</a> <!-- will not work -->
<a href='https://arma3.com/?foo&bar'>Example URL B</a> <!-- will work -->
Attributes
The following inline attributes are supported:
- size
- color
- font
- align
- valign
- underline
- shadow
- shadowColor
- shadowOffset
- colorLink
- href
- image
Size
The structured text size attribute is a 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, 0.5 will make them half 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.
Color
The color attribute is similar to HTML hex color and could either have format #RRGGBB or #AARRGGBB.
<t color='#ff0000'>Red text</t>
<t color='#99ffffff'>Semi-transparent white text</t>
Font
The value for the font attribute could be found in CfgFontFamilies config. Some of the Arma 3 fonts:
- EtelkaMonospacePro
- EtelkaMonospaceProBold
- EtelkaNarrowMediumPro
- LCD14
- LucidaConsoleB
- PuristaBold
- PuristaLight
- PuristaMedium
- PuristaSemibold
- RobotoCondensed
- RobotoCondensedBold
- RobotoCondensedLight
- TahomaB
<t font='PuristaBold'>Bold Text</t>
<t font='LCD14'>Wicked looking text</t>
Horizontal Alignment
The align attribute controls horizontal text alignment and could be one of the following:
- left
- center
- right
<t align='right'>Text displayed to the right</t>
Vertical Alignment
The valign attribute controls vertical text alignment and could be one of the following:
- top
- middle
- bottom
<t valign='bottom'>Text displayed at the bottom</t>
Underline
The underline attribute underlines each individual word in text. The normal spaces are not underlined.
<t underline='1'>Underlined Text</t>
Shadow
The shadow attribute controls the appearance of shadow/outline around text and could be one of the following:
- 0 - normal text
- 1 - classic shadow (text ghosting below and to the right)
- 2 - outline (slight, always black, outline around characters)
<t shadow='0'>Text with no shadow</t>
<t shadow='1'>Text with default black shadow</t>
<t shadow='2'>Text with default black outline</t>
Shadow Color
The shadowColor attribute controls the color of the shadow (not the outline, which is always black for some reason)
<t shadow='1' shadowColor='#ff0000'>Text with red shadow</t>
Shadow Offset
The shadowOffset attribute controls how far is the shadow offset from the text source (has no effect on the outline)
<t shadow='1' shadowColor='#ff0000' shadowOffset='0.5'>Text with red shadow, which is offset by half character size</t>
Link Color
Will change the color of the text if the text is a link, otherwise the text color is unaffected.
<t colorLink='#0000ff'><a href='http://www.arma3.com/'>Blue text</a></t>
<a colorLink='#0000ff' href='http://www.arma3.com/'>Blue text too</a>
<t colorLink='#0000ff'>Normal text color</t>
Hyperlink Reference
The href attribute is essential part of the <a> tag and should contain URL of the destination (See Hyperlink).
Image Reference
The image attribute is essential part of the <img> tag and should contain filepath to the image (See Image).
SQF Code Examples
align valign demo:
hint parseText "<t size='3'><t size='1' valign='top' align='right'>Top Right</t> <t size='1' valign='middle' align='center'>Middle Center</t> <t size='1' valign='bottom' align='left'>Bottom Left</t></t>";
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>";
The use of composeText:
_separator = parseText "<br />------------------------<br />";
_image = "\a3\Data_f\Flags\flag_Altis_co.paa";
_txt1 = text "left";
_txt1 setAttributes ["align", "left"];
_txt2 = text "right";
_txt2 setAttributes ["align", "right"];
_structuredText = composeText [image _image, lineBreak, lineBreak, text "Heading Text", _separator, _txt1, _txt2];
hint _structuredText;