Structured Text: Difference between revisions
Killzone Kid (talk | contribs) |
Killzone Kid (talk | contribs) (format, still WIP) |
||
Line 30: | Line 30: | ||
=== Hyperlink === | === Hyperlink === | ||
Hyperlinks could be created the following markup: ''(Since ["Arma 3","Arma3",125,126163,"Development"])'' | Hyperlinks could be created the following markup: ''(Since ["Arma 3","Arma3",125,126163,"Development"])'' | ||
* <tt><nowiki><a | * <tt><nowiki><a href="http://arma3.com">Arma 3</a></nowiki></tt> | ||
== Attributes == | == Attributes == | ||
The following inline text attributes are supported: | The following inline text attributes are supported: | ||
* <tt>size</tt> | * <tt>size</tt> | ||
* <tt>color</tt> | |||
* <tt>font</tt> | |||
* <tt>align</tt> | * <tt>align</tt> | ||
* <tt>valign</tt> | * <tt>valign</tt> | ||
* <tt> | * <tt>underline</tt> | ||
* <tt>image</tt> | * <tt>image</tt> | ||
* <tt>shadow</tt> | * <tt>shadow</tt> | ||
* <tt>shadowOffset</tt> | * <tt>shadowOffset</tt> | ||
* <tt>shadowColor</tt> | * <tt>shadowColor</tt> | ||
* <tt>href</tt> | * <tt>href</tt> | ||
* <tt>colorLink</tt> | * <tt>colorLink</tt> | ||
=== Size === | === Size === | ||
The multiplier for the value of control config property <tt>size</tt>. 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: | The structured text <tt>size</tt> attribute is a multiplier for the value of control config property <tt>size</tt>. 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>class MyStructuredText: RscStructuredText | <syntaxhighlight lang=cpp>class MyStructuredText: RscStructuredText | ||
Line 76: | Line 61: | ||
<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. | 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. | ||
=== Color === | |||
The <tt>color</tt> attribute is similar to HTML hex color and could either have format [http://en.wikipedia.org/wiki/RGB #RRGGBB] or [http://en.wikipedia.org/wiki/ARGB #AARRGGBB]. | |||
<t color="#FF0000">Red text</t> | |||
<t color="#99FFFFFF">Semi-transparent white text</t> | |||
=== Font === | === Font === | ||
The value for the <tt>font</tt> attribute could be found in <tt>CfgFontFamilies</tt> config. Some of the Arma 3 fonts: | |||
<t font= | * <tt>EtelkaMonospacePro</tt> | ||
* <tt>EtelkaMonospaceProBold</tt> | |||
* <tt>EtelkaNarrowMediumPro</tt> | |||
* <tt>LCD14</tt> | |||
* <tt>LucidaConsoleB</tt> | |||
* <tt>PuristaBold</tt> | |||
* <tt>PuristaLight</tt> | |||
* <tt>PuristaMedium</tt> | |||
* <tt>PuristaSemibold</tt> | |||
* <tt>RobotoCondensed</tt> | |||
* <tt>RobotoCondensedBold</tt> | |||
* <tt>RobotoCondensedLight</tt> | |||
* <tt>TahomaB</tt> | |||
<t font="PuristaBold">Bold Text</t> | |||
<t font="LCD14">Wicked looking text</t> | |||
=== Horizontal Alignment === | |||
The <tt>align</tt> attribute controls horizontal text alignment and could be one of the following: | |||
* <tt>left</tt> | |||
* <tt>center</tt> | |||
* <tt>right</tt> | |||
<t align="right">Text displayed to the right</t> | |||
=== | === Vertical Alignment === | ||
The <tt>valign</tt> attribute controls vertical text alignment and could be one of the following: | |||
<t align= | * <tt>top</tt> | ||
* <tt>middle</tt> | |||
* <tt>bottom</tt> | |||
<t align="bottom">Text displayed at the bottom</t> | |||
=== Underline === | === Underline === | ||
<t underline= | The <tt>underline</tt> attribute underlines each individual word in text. The normal spaces are not underlined. | ||
<t underline="1">Underlined Text</t> | |||
<code>[[format]] ["<t underline='true'>%1</t>", "Underlined Text" [[splitString]] " " [[joinString]] [[toString]] [160]]</code> | {{Informative | If you would like to have have a continuous underline between words, use non-breaking spaces. This could be achieved in several ways: | ||
* Insertion from keyboard: [https://en.wikipedia.org/wiki/Non-breaking_space#Keyboard_entry_methods Alt+255] | |||
* Scripted method: | |||
<code>[[hint]] [[parseText]] [[format]] ["<t underline<nowiki>=</nowiki>'true'>%1</t>", "Underlined Text" [[splitString]] " " [[joinString]] [[toString]] [160]]</code> | |||
* Using HTML code: | |||
<code>[[hint]] [[parseText]] "<t underline<nowiki>=</nowiki>'1'>Underlined&#160;Text</t>";</code>}} | |||
=== Shadow === | === Shadow === | ||
Line 95: | Line 114: | ||
<t shadow='1' shadowColor='#ff0000'>Text with red Shadow</t> | <t shadow='1' shadowColor='#ff0000'>Text with red Shadow</t> | ||
<t shadow='2'>Text with outline</t> | <t shadow='2'>Text with outline</t> | ||
=== Syntax === | === Syntax === | ||
Line 105: | Line 120: | ||
While the following is correct: | While the following is correct: | ||
<t size='2.0'>Large text</t> | <t size='2.0'>Large text</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> | |||
== Code Examples: == | == Code Examples: == | ||
<tt>align</tt> <tt>valign</tt> 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> | |||
Create clickable image: | |||
<code>_ctrl = [[findDisplay]] 46 [[createDisplay]] "RscDisplayEmpty" [[ctrlCreate]] ["RscStructuredText", -1]; | |||
_ctrl [[ctrlSetPosition]] [0,0,1,1]; | |||
_ctrl [[ctrlCommit]] 0; | |||
_ctrl [[ctrlSetStructuredText]] [[parseText]] "<nowiki><a color='#00FF00' size='5' href='http://arma3.com'><img image='\A3\weapons_f\ammoBoxes\data\ui\map_AmmoBox_F_CA.paa' /></a></nowiki>";</code> | |||
<code>_separator1 = [[parseText]] <nowiki>"<br />------------------------<br /></nowiki>"; | <code>_separator1 = [[parseText]] <nowiki>"<br />------------------------<br /></nowiki>"; |
Revision as of 21:23, 11 January 2019
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
Markups
Text
Texts could be created with the following markup:
- <t>Hello World!</t>
Or could also be inserted via the composeText and text commands
Non-break Space
A non-break space, commonly known as shows as ? in structured text control. Use alternative which is: 
<t>FIVE     SPACES</t>
Line break
Line breaks could be created with either of the following markups:
- <br/>
- <br></br>
Or could also be inserted via the composeText 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>
Or could also be inserted via the composeText and image commands.
Hyperlink
Hyperlinks could be created the following markup: (Since ["Arma 3","Arma3",125,126163,"Development"])
- <a href="http://arma3.com">Arma 3</a>
Attributes
The following inline text attributes are supported:
- size
- color
- font
- align
- valign
- underline
- image
- shadow
- shadowOffset
- shadowColor
- href
- colorLink
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 align="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
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>
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>
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>
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>";
_separator1 = parseText "<br />------------------------<br />";
_image = "\ca\ui\textures\aus_flag.paa";
_txt = composeText [image _image, "Heading Text", _separator1, "Content"];
hint _txt;