Difference between revisions of "GUIVariable"

From The Battle for Wesnoth Wiki
(Generate new version)
 
m (Simple types)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Autogenerated}}
+
== Variables ==
 
 
= Variables =
 
 
 
 
In various parts of the GUI there are several variables types in use. This
 
In various parts of the GUI there are several variables types in use. This
 
page describes them.
 
page describes them.
  
 
== Simple types ==
 
== Simple types ==
 
 
The simple types are types which have one value or a short list of options.
 
The simple types are types which have one value or a short list of options.
  
{| border="1"
+
{| class="wikitable"
!Variable
+
!Variable !!Description
!description
 
 
|-
 
|-
| <span id="unsigned">unsigned</span>
+
|style="vertical-align:top"| <span id="unsigned">unsigned</span>
 
| Unsigned number (positive whole numbers and zero).
 
| Unsigned number (positive whole numbers and zero).
 
|-
 
|-
| <span id="f_unsigned">f_unsigned</span>
+
|style="vertical-align:top"| <span id="f_unsigned">f_unsigned</span>
 
| Unsigned number or formula returning an unsigned number.
 
| Unsigned number or formula returning an unsigned number.
 
|-
 
|-
| <span id="int">int</span>
+
|style="vertical-align:top"| <span id="int">int</span>
 
| Signed number (whole numbers).
 
| Signed number (whole numbers).
 
|-
 
|-
| <span id="f_int">f_int</span>
+
|style="vertical-align:top"| <span id="f_int">f_int</span>
 
| Signed number or formula returning an signed number.
 
| Signed number or formula returning an signed number.
 
|-
 
|-
| <span id="bool">bool</span>
+
|style="vertical-align:top"| <span id="bool">bool</span>
 
| A boolean value accepts the normal values as the rest of the game.
 
| A boolean value accepts the normal values as the rest of the game.
 
|-
 
|-
| <span id="f_bool">f_bool</span>
+
|style="vertical-align:top"| <span id="f_bool">f_bool</span>
 
| Boolean value or a formula returning a boolean value.
 
| Boolean value or a formula returning a boolean value.
 
|-
 
|-
| <span id="string">string</span>
+
|style="vertical-align:top"| <span id="string">string</span>
 
| A text.
 
| A text.
 
|-
 
|-
| <span id="tstring">tstring</span>
+
|style="vertical-align:top"| <span id="tstring">tstring</span>
 
| A translatable string.
 
| A translatable string.
 
|-
 
|-
| <span id="f_tstring">f_tstring</span>
+
|style="vertical-align:top"| <span id="f_tstring">f_tstring</span>
 
| Formula returning a translatable string.
 
| Formula returning a translatable string.
 
|-
 
|-
| <span id="function">function</span>
+
|style="vertical-align:top"| <span id="function">function</span>
 
| A string containing a set of function definition for the formula language.
 
| A string containing a set of function definition for the formula language.
 
|-
 
|-
| <span id="color">color</span>
+
|style="vertical-align:top"| <span id="color">color</span>
| A string which contains the color, this a group of 4 numbers between 0 and 255 separated by a comma. The numbers are red component, green component, blue component and alpha. A color of 0 is not available. An alpha of 255 is fully transparent. Omitted values are set to 0.
+
| A string which contains the color, this a group of 4 numbers between 0 and 255 separated by commas. The numbers are red component, green component, blue component and alpha. An alpha of 0 is fully transparent, while an alpha of 255 is fully opaque.
 +
|-
 +
|style="vertical-align:top"| <span id="f_color">f_color</span>
 +
|  A color, or a formula returning a color value.
 
|-
 
|-
| <span id="font_style">font_style</span>
+
|style="vertical-align:top"| <span id="font_style">font_style</span>
 
| A string which contains the style of the font:  
 
| A string which contains the style of the font:  
 
* normal    normal font  
 
* normal    normal font  
Line 55: Line 53:
 
Since SDL has problems combining these styles only one can be picked. Once SDL will allow multiple options, this type will be transformed to a comma separated list. If empty we default to the normal style. Since the render engine is replaced by Pango markup this field will change later on. Note widgets that allow marked up text can use markup to change the font style.
 
Since SDL has problems combining these styles only one can be picked. Once SDL will allow multiple options, this type will be transformed to a comma separated list. If empty we default to the normal style. Since the render engine is replaced by Pango markup this field will change later on. Note widgets that allow marked up text can use markup to change the font style.
 
|-
 
|-
| <span id="v_align">v_align</span>
+
|style="vertical-align:top"| <span id="v_align">v_align</span>
 
| Vertical alignment; how an item is aligned vertically in the available space. Possible values:  
 
| Vertical alignment; how an item is aligned vertically in the available space. Possible values:  
 
* top    aligned at the top  
 
* top    aligned at the top  
Line 62: Line 60:
 
When nothing is set or an another value as in the list the item is centered.
 
When nothing is set or an another value as in the list the item is centered.
 
|-
 
|-
| <span id="h_align">h_align</span>
+
|style="vertical-align:top"| <span id="h_align">h_align</span>
| Horizontal alignment; how an item is aligned horizontal in the available space. Possible values:  
+
| Horizontal alignment; how an item is aligned horizontally in the available space. Possible values:  
 
* left  aligned at the left side  
 
* left  aligned at the left side  
 
* right  aligned at the right side  
 
* right  aligned at the right side  
 
* center centered
 
* center centered
 
|-
 
|-
| <span id="f_h_align">f_h_align</span>
+
|style="vertical-align:top"| <span id="f_h_align">f_h_align</span>
 
| A horizontal alignment or a formula returning a horizontal alignment.
 
| A horizontal alignment or a formula returning a horizontal alignment.
 
|-
 
|-
| <span id="border">border</span>
+
|style="vertical-align:top"| <span id="border">border</span>
 
| Comma separated list of borders to use. Possible values:  
 
| Comma separated list of borders to use. Possible values:  
 
* left  border at the left side  
 
* left  border at the left side  
Line 79: Line 77:
 
* all    alias for "left, right, top, bottom"
 
* all    alias for "left, right, top, bottom"
 
|-
 
|-
| <span id="scrollbar_mode">scrollbar_mode</span>
+
|style="vertical-align:top"| <span id="scrollbar_mode">scrollbar_mode</span>
 
| How to show the scrollbar of a widget. Possible values:  
 
| How to show the scrollbar of a widget. Possible values:  
 
* always      The scrollbar is always shown, regardless whether it's required or not.  
 
* always      The scrollbar is always shown, regardless whether it's required or not.  
Line 87: Line 85:
 
Use auto when the list can be changed dynamically eg the game list in the lobby. For optimization you can also use auto when you really expect a scrollbar, but don't want it to be shown when not needed eg the language list will need a scrollbar on most screens.
 
Use auto when the list can be changed dynamically eg the game list in the lobby. For optimization you can also use auto when you really expect a scrollbar, but don't want it to be shown when not needed eg the language list will need a scrollbar on most screens.
 
|-
 
|-
| <span id="resize_mode">resize_mode</span>
+
|style="vertical-align:top"| <span id="resize_mode">resize_mode</span>
 
| Determines how an image is resized. Possible values:  
 
| Determines how an image is resized. Possible values:  
 
* scale        The image is scaled.  
 
* scale        The image is scaled.  
Line 93: Line 91:
 
* tile        The image is placed several times until the entire surface is filled. The last images are truncated.
 
* tile        The image is placed several times until the entire surface is filled. The last images are truncated.
 
|-
 
|-
| <span id="grow_direction">grow_direction</span>
+
|style="vertical-align:top"| <span id="grow_direction">grow_direction</span>
 
| Determines how an image is resized. Possible values:  
 
| Determines how an image is resized. Possible values:  
 
* scale        The image is scaled.  
 
* scale        The image is scaled.  
Line 99: Line 97:
 
* tile        The image is placed several times until the entire surface is filled. The last images are truncated.
 
* tile        The image is placed several times until the entire surface is filled. The last images are truncated.
 
|}
 
|}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
== Section types ==
 
== Section types ==
 
 
For more complex parts, there are sections. Sections contain of several
 
For more complex parts, there are sections. Sections contain of several
 
lines of WML and can have sub sections. For example a grid has sub sections
 
lines of WML and can have sub sections. For example a grid has sub sections
Line 141: Line 113:
 
| A grid contains several widgets. (TODO add link to generic grid page.)
 
| A grid contains several widgets. (TODO add link to generic grid page.)
 
|}
 
|}
 +
 
[[Category: WML Reference]]
 
[[Category: WML Reference]]
 
[[Category: GUI WML Reference]]
 
[[Category: GUI WML Reference]]

Latest revision as of 03:14, 5 November 2024

Variables

In various parts of the GUI there are several variables types in use. This page describes them.

Simple types

The simple types are types which have one value or a short list of options.

Variable Description
unsigned Unsigned number (positive whole numbers and zero).
f_unsigned Unsigned number or formula returning an unsigned number.
int Signed number (whole numbers).
f_int Signed number or formula returning an signed number.
bool A boolean value accepts the normal values as the rest of the game.
f_bool Boolean value or a formula returning a boolean value.
string A text.
tstring A translatable string.
f_tstring Formula returning a translatable string.
function A string containing a set of function definition for the formula language.
color A string which contains the color, this a group of 4 numbers between 0 and 255 separated by commas. The numbers are red component, green component, blue component and alpha. An alpha of 0 is fully transparent, while an alpha of 255 is fully opaque.
f_color A color, or a formula returning a color value.
font_style A string which contains the style of the font:
  • normal normal font
  • bold bold font
  • italic italic font
  • underline underlined font

Since SDL has problems combining these styles only one can be picked. Once SDL will allow multiple options, this type will be transformed to a comma separated list. If empty we default to the normal style. Since the render engine is replaced by Pango markup this field will change later on. Note widgets that allow marked up text can use markup to change the font style.

v_align Vertical alignment; how an item is aligned vertically in the available space. Possible values:
  • top aligned at the top
  • bottom aligned at the bottom
  • center centered

When nothing is set or an another value as in the list the item is centered.

h_align Horizontal alignment; how an item is aligned horizontally in the available space. Possible values:
  • left aligned at the left side
  • right aligned at the right side
  • center centered
f_h_align A horizontal alignment or a formula returning a horizontal alignment.
border Comma separated list of borders to use. Possible values:
  • left border at the left side
  • right border at the right side
  • top border at the top
  • bottom border at the bottom
  • all alias for "left, right, top, bottom"
scrollbar_mode How to show the scrollbar of a widget. Possible values:
  • always The scrollbar is always shown, regardless whether it's required or not.
  • never The scrollbar is never shown, even not when needed. (Note when setting this mode dialogs might not properly fit anymore).
  • auto Shows the scrollbar when needed. The widget will reserve space for the scrollbar, but only show when needed.
  • initial_auto Like auto, but when the scrollbar is not needed the space is not reserved.

Use auto when the list can be changed dynamically eg the game list in the lobby. For optimization you can also use auto when you really expect a scrollbar, but don't want it to be shown when not needed eg the language list will need a scrollbar on most screens.

resize_mode Determines how an image is resized. Possible values:
  • scale The image is scaled.
  • stretch The first row or column of pixels is copied over the entire image. (Can only be used to scale resize in one direction, else falls back to scale.)
  • tile The image is placed several times until the entire surface is filled. The last images are truncated.
grow_direction Determines how an image is resized. Possible values:
  • scale The image is scaled.
  • stretch The first row or column of pixels is copied over the entire image. (Can only be used to scale resize in one direction, else falls back to scale.)
  • tile The image is placed several times until the entire surface is filled. The last images are truncated.

Section types

For more complex parts, there are sections. Sections contain of several lines of WML and can have sub sections. For example a grid has sub sections which contain various widgets. Here's the list of sections.

Variable description
section A generic section. The documentation about the section should describe the section in further detail.
grid A grid contains several widgets. (TODO add link to generic grid page.)
This page was last edited on 5 November 2024, at 03:14.