Arma: GUI Configuration: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Some wiki formatting)
 
(310 intermediate revisions by 30 users not shown)
Line 1: Line 1:
== Introduction ==
{{TOC|side}}
Dialogs are one way to provide custom graphical user interface in your missions and allow interaction with the player as well as they are able to run [[Code|code]]. They are defined as classes in the [[Description.ext|missionConfigFile]] ([[Description.ext|description.ext]]), [[campaignConfigFile]] ([[Campaign Description.ext]]) or [[configFile]] ([[config.cpp]]).
<gallery mode="nolines" class="center" widths=150px>
A3_GUI_Example_1.jpg|Custom Briefing Editor
A3_GUI_Example_2.jpg|Teamswitch GUI
A3_GUI_Example_3.jpg|Dynamic Groups GUI
</gallery>


Dialogs are one way to provide custom graphical user interface in your missions and allow interaction with the player aswell as they are able to run [[Code|code]]. They are defined as classes in the [[Description.ext|description.ext]] file.


'''Notice:''' If you change your description.ext file while the mission is still open in the editor, you will have to reload or resave the mission before the changes will take effect.  This behaviour is due to the fact the mission editor only reads the description.ext file during save/load.
=== Terminology ===


'''Warning:''' If there are syntactic errors in your description.ext file (e.g. incorrect spelling of keywords), then the game will simply return to desktop while processing the file, stating the nature and location of the error that caused it.
; GUI
: Graphical User Interface - Allows user interaction with the software through graphical controls like buttons, lists and so on.


Most of these definitions work with numeric constants, which are presented in [[#Constants|the following section]]. For readability purposes you should consider favoring them instead of the actual integers.
; UI
: User Interface - Allows the user to interact with the software through a console application.


* Positions and dimensions (x, y, w, h) aswell as font sizes are '''relative''' to the screen (and '''not''' pixel values), normally ranging from 0.0 to 1.0; 0.0 means 0% of the screen width (e.g. the left side of the screen in the context of x or y, or 0% length in the context of width and height). This makes font sizes usually a very small number (~0.02). This percentage is only based on the standard 4:3 screen area.  A dialog will look the same for all users, regardless of their monitor's aspect ratio, as long as their aspect ratio is set correctly for their monitor in the display options panel. This is only likely to be a problem, should you be intentionally trying to fill the whole screen with a dialog and the user has a non-4:3 monitor.  In all other situations, this behaviour is likely to be to your benefit, as you don't have to worry about users with different setups.  Keep this in mind.  You can set your positions and dimension outside of 0-1 if you wish. For the most part though, it's not reccomended as parts of your dialog will be drawn outside the standard 4:3 screen area.  This means the majority of users could not access the items outside this area.  One practical application for that though, is that it lets you make a solid background that blocks out the screen for all users regardless of their monitor's screen aspect ratio.  This can be done by setting a panel's position and dimensions to "X = -1; Y = -1; W = 3; h = 3".
; IGUI
* Colors are usually defined in the following convention: <tt>{ Red, Green, Blue, Alpha }</tt>, each ranging from 0.0 to 1.0 aswell. To Easilly convert from the more standard 0-255 range, simply divide the 255 based number by 255.
: Integrated Graphical User Interface - A term usually encountered when talking about vanilla menus in {{arma3}}.
* Sounds are usually defined in the following convention: <tt>{ "file.ogg", volume, pitch }</tt>, Volume ranges from 0.0 to 1.0.  Pitch is a floating point number ranging from 0.0 to 4.0.  2.0 doubles the pitch (makes it higer), 0.5 halfs the pitch (makes it deeper) and 1.0 is normal.  


<!-- I have no idea. Someone please correct the sound convention. -->


You can find a complete list of scripting related GUI functions in [[:Category:Command Group: GUI Control]].
== User Interface Types ==


== Constants ==
=== Dialog ===


These are constants generally used to maintain a certain degree of readability. They represent integer values for use with ''type'' and ''style'' properties of controls. You can also define other constants, e.g. the font name.
* Can be created upon an existing display. Parent display will be hidden.


<code><nowiki>// Control types
** Player movement is blocked by dialog
#define CT_STATIC          0
** '''Commands:''' [[createDialog]], [[closeDialog]], [[allControls]], [[dialog]]
#define CT_BUTTON          1
#define CT_EDIT            2
#define CT_SLIDER          3
#define CT_COMBO            4
#define CT_LISTBOX          5
#define CT_TOOLBOX          6
#define CT_CHECKBOXES      7
#define CT_PROGRESS        8
#define CT_HTML            9
#define CT_STATIC_SKEW      10
#define CT_ACTIVETEXT      11
#define CT_TREE            12
#define CT_STRUCTURED_TEXT  13
#define CT_CONTEXT_MENU    14
#define CT_CONTROLS_GROUP  15
#define CT_XKEYDESC        40
#define CT_XBUTTON          41
#define CT_XLISTBOX        42
#define CT_XSLIDER          43
#define CT_XCOMBO          44
#define CT_ANIMATED_TEXTURE 45
#define CT_OBJECT          80
#define CT_OBJECT_ZOOM      81
#define CT_OBJECT_CONTAINER 82
#define CT_OBJECT_CONT_ANIM 83
#define CT_LINEBREAK        98
#define CT_USER            99
#define CT_MAP              100
#define CT_MAP_MAIN        101


=== Display ===


// Static styles
* Can be created upon an existing display. Parent display will be hidden.
#define ST_POS            0x0F
* Player movement is not blocked by display, if it has not been blocked by its parent display already.
#define ST_HPOS          0x03
** '''Commands:''' [[createDisplay]], [[closeDisplay]], [[allControls]], [[allDisplays]]
#define ST_VPOS          0x0C
#define ST_LEFT          0x00
#define ST_RIGHT          0x01
#define ST_CENTER        0x02
#define ST_DOWN          0x04
#define ST_UP            0x08
#define ST_VCENTER        0x0c


#define ST_TYPE          0xF0
{{Feature|informative|Generally speaking, dialogs and displays are identical. They are only differentiated by the way they are created ([[createDisplay]], [[createDialog]]).}}
#define ST_SINGLE        0
#define ST_MULTI          16
#define ST_TITLE_BAR      32
#define ST_PICTURE        48
#define ST_FRAME          64
#define ST_BACKGROUND    80
#define ST_GROUP_BOX      96
#define ST_GROUP_BOX2    112
#define ST_HUD_BACKGROUND 128
#define ST_TILE_PICTURE  144
#define ST_WITH_RECT      160
#define ST_LINE          176


#define ST_SHADOW        0x100
=== HUD ===
#define ST_NO_RECT        0x200
#define ST_KEEP_ASPECT_RATIO  0x800


#define ST_TITLE          ST_TITLE_BAR + ST_CENTER
* Is created in a new, or already existing layer. The user can not interact with it. Usually used to show information, like stamina, ammunition and so on.
** '''Commands:''' [[allCutLayers]], [[titleRsc]], [[cutText]], [[cutObj]], [[cutFadeOut]], [[setTitleEffect]], [[allActiveTitleEffects]]


// Slider styles
{{Feature|informative|Some of the commands have different effects. Please check the command's biki page for detailed information.}}
#define SL_DIR            0x400
#define SL_VERT          0
#define SL_HORZ          0x400


#define SL_TEXTURES      0x10


// Listbox styles
== Display and Dialog ==
#define LB_TEXTURES      0x10
#define LB_MULTI          0x20


#define FontM            "Zeppelin32"</nowiki></code>
Displays and dialogs are defined in the config file. They are usually used to simplify user interactions, through controls like buttons, list boxes and so on.


'''Notice:''' All examples within this article use these constants. If you do not include them, or name them differently, these examples won't work as-is.
=== Properties ===


== Attributes ==
{| class="wikitable sortable" Style = "Width: 100%"
 
A list of all available attributes (properties) without explaination, originally posted by ColonelSandersLite, can be found [http://www.flashpoint1985.com/cgi-bin/ikonboard311/ikonboard.cgi?act=ST;f=71;t=64450;st=15 here]
 
== Dialogs ==
 
Dialogs are parent containers for the actual controls it contains. Their definition contains several properties on the controls it contains, how the dialog can be addressed, and whether or not the player is able to continue regular movement while the dialog is shown.
 
They can be defined in the [[Description.ext|description.ext]] file or externalized to seperate hpp-files, which are included in the description.ext file using the [[PreProcessor_Commands#.23include|#include]] preprocessor directive. The latter method is generally a good idea to split a large description.ext file into several small chunks in order to keep track of what's where.
 
Most often, controls of a dialog are defined within the definition of the dialog itself, though it's a good practice to generalize common controls in a base definition in the global scope. See [[#Best Practice|best practice]] for details. For simplicity we won't apply this practice in the following code examples.
 
 
{| border="1" align="center" cellpadding="3" cellspacing="0" |
! colspan="3" bgcolor="#bbbbff" | Properties
|-
|-
! bgcolor="#ddddff" | Name
! Name !! Type!! Remark
! bgcolor="#ddddff" | Type
! bgcolor="#ddddff" | Remark
|-
|-
| '''idd'''
| '''idd'''
| integer
| Integer
| the unique ID number of this dialog. can be -1 if you don't require access to the dialog itself from within a script.
| The unique ID number of this dialog. Used with [[findDisplay]] to find the display. Can be -1 if no access is required from within a script.
|-
| '''access'''
| Integer
|
* 0 - ReadAndWrite - this is the default case where properties can still be added or overridden.
* 1 - ReadAndCreate - this only allows creating new properties.
* 2 - ReadOnly - this does not allow to do anything in deriving classes.
* 3 - ReadOnlyVerified - this does not allow to do anything either in deriving classes, and a CRC check will be performed.
|-
|-
| '''movingEnable'''
| '''movingEnable'''
| boolean
| [[Boolean]]
| sets whether or not the player is hindered from aiming or moving while the dialog is open.
| Specifies whether the dialog can be moved or not (if enabled one of the dialogs controls should have the ''moving'' property set to 1 so it becomes the "handle" the dialog can be moved with). Doesn't seem to matter in {{arma3}}
|-
| '''enableSimulation'''
| [[Boolean]]
| Specifies whether the game continues while the dialog is shown or not.
|-
| '''onLoad'''
| [[String]]
| Expression executed when the dialog is opened. See [[User_Interface_Event_Handlers#onLoad|User Interface Event Handlers]]
|-
| '''onUnload'''
| [[String]]
| Expression executed when the dialog is closed. See [[User_Interface_Event_Handlers#onUnload|User Interface Event Handlers]]
|-
|-
| '''controlsBackground'''
| '''controlsBackground'''
| array
| [[Array]] or class
| contains class names of all background controls associated to this dialog.
| Contains class names of all background controls associated to this dialog.<br>
The sequence in which the controls are listed will decide their z-index (i.e. the last ones will on top of the first ones).
|-
|-
| '''controls'''
| '''controls'''
| array
| [[Array]] or class
| contains class names of all foreground controls associated to this dialog.
| Contains class names of all foreground controls associated to this dialog.
|-
|-
| '''objects'''
| '''objects'''
| array
| [[Array]] or class
|
| List of all [[DialogControls-Objects]] type controls
|-
|}
|}


=== Example Config ===


Setting the ''idd'' property to a non-negative (i.e. "useful") number is only required if you want to access the dialog itself via the [[findDisplay]] function. Accessing the dialog itself via the ''idd'' property though does not mean that you can implicitely access the controls within the dialog. For that you will have to rely on the control's ''idc'' properties. Hence, in most basic cases you won't need it and -1 should be sufficient.
<spoiler text="Show Example Config">
<syntaxhighlight lang="cpp">
class DefaultDialog
{
idd = -1;
access = 0;
movingEnable = true;
onLoad = "hint str _this";
onUnload  = "hint str _this";
enableSimulation = false;
class ControlsBackground
{
//Background controls
};
class Controls
{
//Controls
};
class Objects
{
//Objects
};
};
</syntaxhighlight>
</spoiler>


It's also noteworthy for more advanced developers that there is a numeric property named '''''access''''' with the following possible values (and their named constants):
=== Opening a display or dialog ===
* '''0''' - ''ReadAndWrite'' - this is the default case where properties can still be added or overridden.
* '''1''' - ''ReadAndCreate'' - this only allows creating new properties.
* '''2''' - ''ReadOnly'' - this does not allow to do anything in deriving classes.
* '''3''' - ''ReadOnlyVerified'' - this does not allow to do anything either in deriving classes, and a CRC check will be performed.
This does not have any impact other than limiting what deriving classes are allowed to (re-)specify. Generally this is not required for dialogs or dialog controls and can be safely ignored.


Here's an example of a dialog that will only display ''Hello world'' in the top right corner of the screen. If you get confused by the ''MyHelloText'' class, just ignore it for the moment until you have read details on the definition of controls  in the following chapter, [[#Controls|Controls]].
There are two ways of creating a display or dialog. One can either use [[createDialog]] or [[createDisplay]] command.


* '''Example:'''
=== Closing a display or dialog ===
<code><nowiki>class MyHelloWorldDialog {
idd = -1;  // set to -1, because we don't require a unique ID
movingEnable = false;  // no movement while the dialog is shown
controlsBackground[] = { };  // no background controls needed
objects[] = { };  // no objects needed
controls[] = { MyHelloText };  // our Hello World text as seen below:
class MyHelloText {
idc = -1;  // set to -1, unneeded
type = CT_STATIC;  // constant
style = ST_LEFT;  // constant
text = "Hello world";
font = FontM;
sizeEx = 0.023;


colorBackground[] = { 1, 1, 1, 0.3 };
There are several ways to close a dialog:
colorText[] = { 0, 0, 0, 1 };
* Pressing {{Controls|Esc}}
* Clicking a button with IDC 0, 1 or 2
* [[closeDialog]]
* [[closeDisplay]]


x = 0.8;
==== Exit Codes ====
y = 0.1;
Exit codes are a way to determine in what way a display was closed. The [[User_Interface_Event_Handlers#onUnload|onUnload UIEH]] has the exit code as one of its parameters. This way you can handle different user decisions, eg. save a value if the user confirms it or discard changes when the user pressed a cancel button. Macros for the different exit codes can be found in {{hl|\a3\ui_f\hpp\defineResincl.inc}}:
w = 0.2;
<syntaxhighlight lang="cpp">
h = 0.05;
// Predefined controls
};
#define IDC_OK 1
};</nowiki></code>
#define IDC_CANCEL 2
#define IDC_AUTOCANCEL 3
#define IDC_ABORT 4
#define IDC_RESTART 5
#define IDC_USER_BUTTON 6
#define IDC_EXIT_TO_MAIN 7
</syntaxhighlight>
{| class="wikitable"
|-
! Exit Code !! Macro !! Comment
|-
| 1 || IDC_OK || Dialog was closed with a positive outcome
|-
| 2 || IDC_CANCEL || Dialog was closed with a negative outcome
|-
| 3 || IDC_AUTOCANCEL || ?
|-
| 4 || IDC_ABORT || When used on the mission display (Display #46) it simulates "Save and Exit" button from escape menu
|-
| 5 || IDC_RESTART || ?
|-
| 6 || IDC_USER_BUTTON || ?
|-
| 7 || IDC_EXIT_TO_MAIN || ?
|}


Once you have defined (or prototyped) dialogs you want to use, be sure to reload the mission in the editor if it is already running.
== HUDs ==


=== Creating dialogs ===
HUDs are defined in the class RscTitles, unlike displays or dialogs which are root classes in the config file. Additionally, their properties are different.


Dialogs can then be created and shown using the [[createDialog]] function. If you do so by script and await a responsive action from the user, you might also want to wait until the user has closed the dialog by using a wait statement (e.g. [[waitUntil]]) in conjunction with the [[dialog]] function, if you intend to handle the dialog result within the same script.
=== Properties ===


* '''Example:'''
{| class="wikitable sortable" Style="Width: 100%"
<code><nowiki>_ok = createDialog "MyHelloWorldDialog";
|-
waitUntil { !dialog };
! Name !! Type !! Remark
hint "Dialog closed.";</nowiki></code>
|-
| '''idd'''
| Integer
| The unique ID number of this HUD. Used with [[findDisplay]] to find the display. Can be -1 if no access is required from within a script.
|-
| '''fadeIn'''
| Integer
|  Duration of fade in effect when opening in seconds.
|-
| '''fadeOut'''
| Integer
| Duration of fade out effect when closing in seconds.
|-
| '''duration'''
| Integer
| Duration the HUD is displayed after opening in seconds. Use a very large number to have it always open.
|-
| '''onLoad'''
| [[String]]
| Expression executed when the dialog is opened. See [[User_Interface_Event_Handlers#onLoad|User Interface Event Handlers]]
|-
| '''onUnload'''
| [[String]]
| Expression executed when the dialog is closed. See [[User_Interface_Event_Handlers#onUnload|User Interface Event Handlers]]
|-
| '''controls'''
| [[Array]]
| Contains class names of all foreground controls associated to this dialog.
|}


=== Closing dialogs ===
=== Example Config ===


Im most use cases a dialog "closes itself", ie. by invoking the [[closeDialog]] function in an ''action'' field. However dialogs don't necessarily have to close themselves, but can also be closed from the "outside" (ie. by scripts or triggers). Once closed, the [[dialog]] function returns <tt>false</tt> and wait statements with a <tt>!dialog</tt> condition will end.
<spoiler text="Show Example Config">
<syntaxhighlight lang="cpp">
#include "\a3\ui_f\hpp\definecommongrids.inc"
 
class RscTitles
{
class RscInfoText
{
idd = 3100;
fadein = 0;
fadeout = 0;
duration = 1e+011;
onLoad = "uinamespace setVariable ['BIS_InfoText',_this select 0]";
onUnLoad = "uinamespace setVariable ['BIS_InfoText', nil]";
class Controls
{
class InfoText
{
idc = 3101;
style = "0x01 + 0x10 + 0x200 + 0x100";
font = "RobotoCondensedBold";
x = "(profileNamespace getVariable [""IGUI_GRID_MISSION_X"", (safezoneX + safezoneW - 21 * (GUI_GRID_WAbs / 40))])";
y = "(profileNamespace getVariable [""IGUI_GRID_MISSION_Y"", (safezoneY + safezoneH - 10.5 * (GUI_GRID_HAbs / 25))])";
w = "20 * (GUI_GRID_WAbs / 40)";
h = "5 * ((GUI_GRID_WAbs / 1.2) / 25)";
colorText[] = {1,1,1,1};
colorBackground[] = {0,0,0,0};
text = "";
lineSpacing = 1;
sizeEx = 0.045;
fixedWidth = 1;
deletable = 0;
fade = 0;
access = 0;
type = 0;
shadow = 1;
colorShadow[] = {0,0,0,0.5};
tooltipColorText[] = {1,1,1,1};
tooltipColorBox[] = {1,1,1,1};
tooltipColorShade[] = {0,0,0,0.65};
};
};
};
};
</syntaxhighlight>
</spoiler>


* '''Example''' - close by action
<code><nowiki>class CloseButton : RscButton {
/* ... */
type = CT_BUTTON;
text = "Close";
action = "closeDialog 0";
}</nowiki></code>
* '''Example''' - close by external request
<code><nowiki>closeDialog 0</nowiki></code>


== Controls ==
== Controls ==


Controls are the actual content of dialogs and can be anything, ranging from simple solid rectangles to a complex 3d object within a dialog. Like dialogs, controls can have a unique ID saved in the ''idc'' property to access them from within scripts using [[:Category:Command_Group:_GUI_Control|GUI functions]].
Controls are used to allow the player to interact with the GUI. Controls range from simple rectangles to 3D objects.
Like dialogs, displays and HUDs, controls can have a unique ID to access them from within scripts. The classname of controls have to be unique.


The type of the control is usually set in the ''type'' property. Different types allow or require a different set of properties. However most controls share a set of properties in addition to the properties described in the following sections:
What properties a control needs is defined by its ''type'' property. However most controls share a set of properties described in the following sections.
For control specific properties visit the corresponding pages.


{| border="1" align="center" cellpadding="3" cellspacing="0" |
=== Common Properties ===
! colspan="3" bgcolor="#bbbbff" | Common properties
 
{| class="wikitable" width="100%"
|-
|-
! bgcolor="#ddddff" | Name
! Name
! bgcolor="#ddddff" | Type
! Type
! bgcolor="#ddddff" | Remark
! Remark
|-
|-
| '''idc'''
| '''idc'''
| integer
| Integer
| the unique ID number of this control. can be -1 if you don't require access to the control itself from within a script
| The unique ID number of this control. Can be -1 if you don't require access to the control itself from within a script.<br>
Special (button) IDCs (according to \a3\ui_f\hpp\defineResincl.inc):
* 1: OK (closes display when clicked upon, raises exit code 1 in the [[User_Interface_Event_Handlers#onUnload|onUnload UIEH]])
* 2: Cancel (closes display when clicked upon, raises exit code 2 in the [[User_Interface_Event_Handlers#onUnload|onUnload UIEH]])
* 3: Auto cancel
* 4: Abort
* 5: Restart
* 6: User button
* 7: Exit to main
While the purposes of idcs 3 to 7 remain unknown, it is advisable to give all of your controls larger numbers, eg. 100.
|-
|-
| '''moving'''
| '''moving'''
| boolean
| [[Boolean]]
| whether the dialog will be moved if this control is dragged (should be set in a background control)
| Whether the dialog will be moved if this control is dragged (may require "movingEnable" to be 1 in the dialog. In {{arma3}} works regardless). Another way of allowing moving of the dialog is to have control of style ST_TITLE_BAR
|-
|-
| '''type'''
| '''type'''
| integer (constant)
| Integer
| control type [[#Constants|constant]]
| See [[#Control Types|Control Types]]
|-
|-
| '''style'''
| '''style'''
| integer (constant)
| Integer
| style [[#Constants|constant]]
| See [[#Control Styles|Control Styles]]. <syntaxhighlight lang="cpp" inline>style = "0x400+0x02+0x10";</syntaxhighlight>
|-
|-
| '''x'''
| '''x/y/w/h'''
| float
| [[Number]]
| the offset from the left side of the window (0..1; 0.0 = left side; 1.0 = right side)
| The position and size of the control in fractions of screen size.
|-
|-
| '''y'''
| '''sizeEx'''
| float
| [[Number]]
| the offset from the top side of the window (0..1; 0.0 = left side; 1.0 = right side)
| The font size of text in fractions of screen size. Behaves similar to '''h''' property. For some controls it is named '''size'''.
|-
|-
| '''w'''
| '''font'''
| float
| [[String]]
| the width of the control (0..1)
| The font to use. See the list of [[Fonts#Available_Fonts|available fonts]] for possible values.
|-
|-
| '''h'''
| '''colorText'''
| float
| [[Array]]
| the height of the control (0..1)
| Text color
|-
|-
| '''sizeEx'''
| '''colorBackground'''
| float
| [[Array]]
| the font size of text (0..1)
| Background color
|-
| '''text'''
| [[String]]
| The text '''or picture''' to display.
|-
| '''shadow'''
| Integer
| Can be applied to most controls (0 = no shadow, 1 = drop shadow with soft edges, 2 = stroke).
|-
| '''tooltip'''
| [[String]]
| Text to display in a tooltip when control is moused over. A tooltip can be added to any control type except CT_STATIC and CT_STRUCTURED_TEXT. Note: As of {{GVI| arma3|1.48}}, most controls now support tooltips. A linebreak can be created by adding '''\n'''.
|-
| '''tooltipColorShade'''
| [[Array]]
| Tooltip background color
|-
| '''tooltipColorText'''
| [[Array]]
| Tooltip text color
|-
| '''tooltipColorBox'''
| [[Array]]
| Tooltip border color
|-
| '''autocomplete'''
| [[String]]
| (where applicable) Option for entry fields (e.g. RscEdit) to activate autocompletion. For known script commands and functions use autocomplete = "scripting".
|-
|-
| '''font'''
| '''url'''
| string
| [[String]]
| the font to use. See the list of [[Fonts#Available_Fonts|available fonts]] for possible values
| (where applicable) URL which will be opened when clicking on the control. Used on e.g. a button control. Does not utilize the Steam Overlay browser if enabled by default, opens the link in the default browser set by the OS.
|-
|-
| '''overlayMode'''
| [[Number]]
| {{GVI|arma3|2.10}} (where applicable) 0 - opens URL in default browser; 1 - opens URL in Steam overlay id enabled, otherwise in default browser; 2 - opens URL in Steam overlay, shows error message box (with button to use default browser) if Steam overlay is disabled.
|}
|}


To save space and effort, it is generally a good idea to make use of class polymorphism, i.e. deriving from very basic classes that already have some specific properties set. See the [[#Best_Practice|Best Practice]] chapter for details.
A property to enable or disable a control does not exist (because of implementation issues). However, there is a simple workaround based on the [[User_Interface_Event_Handlers#onLoad|onLoad]] UI Event Handler that can be used to disable a control in the config:
<syntaxhighlight lang="cpp">onLoad = "(_this # 0) ctrlEnable false;";</syntaxhighlight>


=== Static ===
=== Attributes Class ===


Static controls represent exactly that: static data. Primarily they are used for texts, dialog backgrounds and pictures. The constant ''type'' property for these controls usually is <tt>CT_STATIC</tt>.
{| class="wikitable" width="70%"
 
{| border="1" align="center" cellpadding="3" cellspacing="0" |
! colspan="3" bgcolor="#bbbbff" | Properties
|-
|-
! bgcolor="#ddddff" | Name
! Name
! bgcolor="#ddddff" | Type
! Type
! bgcolor="#ddddff" | Remark
! Remark
|-
|-
| '''colorText'''
| '''font'''
| color array
| [[String]]
| text color
| [[FXY_File_Format#Available_Fonts|Available Fonts]]
|-
|-
| '''colorBackground'''
| '''color'''
| color array
| HTML color
| background color
| {{Link|https://html-color-codes.info/|HTML Color Codes}}
|-
|-
| '''text'''
| '''align'''
| string
| [[String]]
| the text to display initially
| "center", "left", "right"
|-
| '''lineSpacing'''
| float
| line spacing. Required, if the style was set to <tt>ST_MULTI</tt>.
|-
|-
| '''shadow'''
| Integer
| 0 = no shadow, 1 = drop shadow with soft edges, 2 = stroke
|}
|}


==== Text ====
=== AttributesImage Class ===
[[Image:Dialog controls text.jpg|thumb||''Hello world'' text with semi-transparent background]]
Most often this type of control will be used to add text to dialogs. If you want the text to change dynamically while playing the mission, you should set the ''idc'' property to a positive number, which allows usage of the [[ctrlSetText]] function. Text alignment can be controlled using the ''style'' property and the <tt>ST_*</tt> constants.


By default, this will only display a '''single line''' (and cut the overflow); use <tt>ST_MULTI</tt> if you intend to use multiple lines. This also requires setting the property ''lineSpacing'', which indicates the relative space between lines; usually, you can set this to 1 for normal line spacing.
{| class="wikitable" width="70%"
|-
! Name
! Type
! Remark
|-
| '''font'''
| [[String]]
| [[FXY_File_Format#Available_Fonts|Available Fonts]] (Optional)
|-
| '''color'''
| HTML color
| {{Link|https://html-color-codes.info/|HTML Color Codes}}
|-
| '''align'''
| [[String]]
| "center", "left", "Right" (optional)
|-
|}<br clear="all">


* '''Example:'''
=== Example Config ===
<code><nowiki>class MyHelloPlayerExample {
idc = -1;
type = CT_STATIC;  // defined constant
style = ST_CENTER;  // defined constant
colorText[] = { 0, 0, 0, 1 };
colorBackground[] = { 1, 1, 1, 0.75 };
font = FontM;  // defined constant
sizeEx = 0.023;
x = 0.3; y = 0.1;
w = 0.4;  h = 0.03;
text = "Hello player!";
};</nowiki></code>


==== Solid rectangles ====
<spoiler text="Show Example Config">
[[Image:Dialog controls background.jpg|thumb||Semi-transparent background]]
<syntaxhighlight lang="cpp">
One can also use this control type to add solid background to dialogs by simply leaving the ''text'' property empty. This way, it will look like a regular rectangle.
#include "\a3\ui_f\hpp\definecommongrids.inc"


* '''Example:'''
class RscButton
<code><nowiki>class MyRedBackgroundExample {
{
/* ... same as the text example, except for */
deletable = 0;
colorBackground[] = { 1, 0.1, 0.1, 0.8 };
fade = 0;
access = 0;
type = 1;
text = "";
text = "";
};</nowiki></code>
colorText[] = {1,1,1,1};
colorDisabled[] = {1,1,1,0.25};
colorBackground[] = {0,0,0,0.5};
colorBackgroundDisabled[] = {0,0,0,0.5};
colorBackgroundActive[] = {0,0,0,1};
colorFocused[] = {0,0,0,1};
colorShadow[] = {0,0,0,0};
colorBorder[] = {0,0,0,1};
soundEnter[] = {"\A3\ui_f\data\sound\RscButton\soundEnter",0.09,1};
soundPush[] = {"\A3\ui_f\data\sound\RscButton\soundPush",0.09,1};
soundClick[] = {"\A3\ui_f\data\sound\RscButton\soundClick",0.09,1};
soundEscape[] = {"\A3\ui_f\data\sound\RscButton\soundEscape",0.09,1};
idc = -1;
style = 2;
x = 0;
y = 0;
w = 0.095589;
h = 0.039216;
shadow = 2;
font = "RobotoCondensed";
sizeEx = "GUI_GRID_HAbs / 25";
url = "";
offsetX = 0;
offsetY = 0;
offsetPressedX = 0;
offsetPressedY = 0;
borderSize = 0;
};
</syntaxhighlight>
</spoiler>


==== Pictures ====
Using specific style constants you can enhance your dialogs with pictures too. These pictures should reside in your mission folder as [[PAA File Format|paa]]-files. Then set your ''style'' property to <tt>ST_PICTURE</tt> (to display it once) or <tt>ST_TILE_PICTURE</tt> (to tile it) and use the ''text'' property to locate the paa image you want to use, relative to your mission folder.


[[Image:Dialog controls picture.jpg|thumb|100px|Dialog control showing a picture]]
== Control Types ==
* '''Example:'''
<code><nowiki>class MyPictureExample {
/* ... same as the text example, except for */
style = ST_PICTURE;
text = "mypicture.paa";
};</nowiki></code>


=== Button ===
The type property of controls defines what type of control they are. For example an edit box has the type 2.
 
There is an ingame dialog with examples of how the control types look and act like:
Buttons are one way to add interactivity to your dialogs. Their corresponding ''type'' property is <tt>CT_BUTTON</tt>.
<sqf>createDialog "RscTestControlTypes";</sqf>
 
{{Navbox/CT}}
Buttons can have different states (see screenshot) and will render slightly different to give the user a visual feedback on the button's state:
<!---
* '''Enabled''': the button has not been [[ctrlEnable|disabled]], it currently doesn't have any mouse or keyboard related focus
{| class="wikitable sortable" Style ="Width: 100%"
* '''Disabled''': the button has been explicitely disabled. It will not be clickable.
! Define !! Decimal !! Hexadecimal !! Remark
* '''Enabled''' + '''Focused''': As enabled; additionally it will have a small border of the color defined in the ''colorFocused'' property. This occurs when the button currently has focus (ie. is the default button or has been selected via the ''Tab'' key).
|-
* '''Enabled''' + '''Active''': As enabled; additionally it will have a different background as specified in the ''colorBackgroundActive'' background. This occurs when the mouse is currently hovering over an unfocused button.
| [[CT_STATIC]] || 0 || 0x00 ||
* '''Enabled''' + '''Active''' + '''Focused''': The combined result of the above two states. The mouse is currently hovering over the button in question and it has input focus.
|-
 
| [[CT_BUTTON]] || 1 || 0x01 ||
Button can also have code attached to it in the ''action'' property. This code will be run when the button is clicked. Most often, you will have at least one button that closes the dialog via [[closeDialog]]. In this case you can provide ''0'' as the right-side parameter to close the currently open dialog.
 
{| border="1" align="center" cellpadding="3" cellspacing="0" |
! colspan="3" bgcolor="#bbbbff" | Properties
|-
|-
! bgcolor="#ddddff" | Name
| [[CT_EDIT]] || 2 || 0x02 ||
! bgcolor="#ddddff" | Type
! bgcolor="#ddddff" | Remark
|-
|-
| '''action'''
| [[CT_SLIDER]] || 3 || 0x03 ||
| string
| a statement that is executed when the button is not disabled and clicked
|-
|-
| '''text'''
| [[CT_COMBO]] || 4 || 0x04 ||
| string
| the text to display initially
|-
|-
| '''default'''
| [[CT_LISTBOX]] || 5 || 0x05 ||
| boolean
| Whether or not this button is the dialog's initially selected button
|-
|-
| '''colorText'''
| [[CT_TOOLBOX]] || 6 || 0x06 ||
| color array
| text color
|-
|-
| '''colorDisabled'''
| [[CT_CHECKBOXES]] || 7 || 0x07 ||
| color array
| text color, if the control has been disabled via [[ctrlEnable]]
|-
|-
| '''colorFocused'''
| [[CT_PROGRESS]] || 8 || 0x08 ||  
| color array
| color when control has received focus via tabbing or scripted methods
|-
|-
| '''colorShadow'''
| [[CT_HTML]] || 9 || 0x09 ||
| color array
| the color of the shadow
|-
|-
| '''colorBorder'''
| [[CT_STATIC_SKEW]] || 10 || 0x0A ||
| color array
| the color of the border, if any
|-
|-
| '''borderSize'''
| [[CT_ACTIVETEXT]] || 11|| 0x0B||
| float
| the width of the border
|-
|-
| '''colorBackgroundActive'''
| [[CT_TREE]] || 12 || 0x0C ||
| color array
| color when control has received focus via mouse-over
|-
|-
| '''colorBackgroundDisabled'''
| [[CT_STRUCTURED_TEXT]] || 13 || 0x0D ||
| color array
| background color, if the control has disabled via [[ctrlEnable]]
|-
|-
| '''offsetX'''
| [[CT_CONTEXT_MENU]] || 14 || 0x0E ||
| float
| the relative X offset between the button and its shadow
|-
|-
| '''offsetY'''
| [[CT_CONTROLS_GROUP]] || 15 || 0x0F ||
| float
| the relative Y offset between the button and its shadow
|-
|-
| '''offsetPressedX'''
| [[CT_SHORTCUTBUTTON]] || 16 || 0x10 ||
| float
| the relative X offset between the button and its shadow, when it's pressed
|-
|-
| '''offsetPressedY'''
| [[CT_HITZONES]] || 17 || 0x11 ||
| float
| the relative Y offset between the button and its shadow, when it's pressed
|-
|-
| '''soundEnter'''
| [[CT_VEHICLETOGGLES]] || 18 || 0x12 ||  
| sound array
| the sound to play, when the cursor enters the button's bounds
|-
|-
| '''soundPush'''
| [[CT_CONTROLS_TABLE]] || 19 || 0x13 ||
| sound array
| the sound to play, when the button has been pushed
|-
|-
| '''soundClick'''
| [[CT_XKEYDESC]] || 40 || 0x28 ||
| sound array
| the sound to play, when the button is being released
|-
|-
| '''soundEscape'''
| [[CT_XBUTTON]] || 41 || 0x29 ||
| sound array
| the sound to play, when the button has been pushed and the mouse button is released when not over the control
|-
|-
|}
| [[CT_XLISTBOX]] || 42 || 0x2A ||
 
 
The following example uses almost the same code as the buttons shown in the example screenshot.
[[Image:Dialog controls button.jpg|thumb|110px|The same button four times in different states]]
 
* '''Example:'''
<code><nowiki>class MyButton {
idc = -1;
type = CT_BUTTON;
style = ST_LEFT;
default = false;
font = FontM;
sizeEx = 0.03;
colorText[] = { 0, 0, 0, 1 };
colorFocused[] = { 1, 0, 0, 1 };  // border color for focused state
colorDisabled[] = { 0, 0, 1, 0.7 };  // text color for disabled state
colorBackground[] = { 1, 1, 1, 0.8 };
colorBackgroundDisabled[] = { 1, 1, 1, 0.5 };  // background color for disabled state
colorBackgroundActive[] = { 1, 1, 1, 1 };  // background color for active state
offsetX = 0.003;
offsetY = 0.003;
offsetPressedX = 0.002;
offsetPressedY = 0.002;
colorShadow[] = { 0, 0, 0, 0.5 };
colorBorder[] = { 0, 0, 0, 1 };
borderSize = 0;
soundEnter[] = { "", 0, 1 };  // no sound
soundPush[] = { "buttonpushed.ogg", 0.1, 1 };
soundClick[] = { "", 0, 1 };  // no sound
soundEscape[] = { "", 0, 1 };  // no sound
x = 0.4; y = 0.475;
w = 0.2; h = 0.05;
text = "Close";
action = "closeDialog 0; hint ""Dialog closed. You are good to go now!""";
};</nowiki></code>
 
=== Active text ===
 
The Active Text control behaves very similar to buttons. It shows up as regular text with the additional functionality that you can click and select it. The dialog's currently selected Active Text control will be underlined to indicate it's status. By default, the first Active Text control is selected. When the mouse cursor hovers over an instance of this control, it will show up in the color defined in the ''colorActive'' property.
 
'''Notice:''' This control doesn't render the usually common ''colorBackground'' property and ''colorText'' is replaced with ''color''.
 
{| border="1" align="center" cellpadding="3" cellspacing="0" |
! colspan="3" bgcolor="#bbbbff" | Properties
|-
|-
! bgcolor="#ddddff" | Name
| [[CT_XSLIDER]] || 43 || 0x2B ||
! bgcolor="#ddddff" | Type
! bgcolor="#ddddff" | Remark
|-
|-
| '''action'''
| [[CT_XCOMBO]] || 44 || 0x2C ||
| string
| a statement that is executed when the control has been clicked
|-
|-
| '''blinkingPeriod'''
| [[CT_ANIMATED_TEXTURE]] || 45 || 0x2D ||
| float (Seconds)
| Makes the text start transparent, go to full opacity and back to full transparent in the amount of time specified.
|-
|-
| '''color'''
| [[CT_MENU]] || 46 || 0x2E || {{arma3}} (EDEN)
| color array
| '''replaces ''colorText''''', standard text and underline color
|-
|-
| '''colorActive'''
| [[CT_MENU_STRIP]] || 47 || 0x2F || {{arma3}} (EDEN)
| color array
| text and underline color whenever the mouse hovers over the control
|-
|-
| <strike>'''colorBackground'''</strike>
| [[CT_CHECKBOX]] || 77 || 0x4D || {{arma3}}
| <strike>color array</strike>
| '''not applicable'''
|-
|-
| '''default'''
| [[CT_OBJECT]] || 80 || 0x50 ||
| boolean
| Whether or not this control is the dialog's initially selected active text
|-
|-
| '''soundEnter'''
| [[CT_OBJECT_ZOOM]] || 81 || 0x51 ||
| sound array
| the sound to play, when the cursor enters the button's bounds
|-
|-
| '''soundPush'''
| [[CT_OBJECT_CONTAINER]] || 82 || 0x52 ||
| sound array
| the sound to play, when the button has been pushed
|-
|-
| '''soundClick'''
| [[CT_OBJECT_CONT_ANIM]] || 83 || 0x53 ||
| sound array
| the sound to play, when the button is being released
|-
|-
| '''soundEscape'''
| [[CT_LINEBREAK]] || 98 || 0x62 ||
| sound array
| the sound to play, when the button has been pushed and the mouse button is released when not over the control.
|-
|-
| '''text'''
| [[CT_USER]] || 99 || 0x63 ||
| string
| the text to display initially
|-
|-
|}
| [[CT_MAP]] || 100 || 0x64 ||
 
The following example uses almost the same code as the controls shown in the example screenshot.
[[Image:Dialog controls activetext.jpg|thumb|110px|Simple dialog with three Active Text controls]]
* '''Example:'''
<code><nowiki>class MyActiveText {
idc = -1;
type = CT_ACTIVETEXT;
style = ST_LEFT;
x = 0.75; y = 0.5;
w = 0.2; h = 0.035;
font = FontM;
sizeEx = 0.024;
color[] = { 1, 1, 1, 1 };
colorActive[] = { 1, 0.2, 0.2, 1 };
soundEnter[] = { "", 0, 1 };  // no sound
soundPush[] = { "", 0, 1 };
soundClick[] = { "", 0, 1 };
soundEscape[] = { "", 0, 1 };
action = "hint ""Good choice!""";
text = "Text";
default = true;
};</nowiki></code>
 
=== Structured text ===
=== Text box ===
=== Slider ===
 
{| border="1" align="center" cellpadding="3" cellspacing="0" |
! colspan="3" bgcolor="#bbbbff" | Properties
|-
|-
! bgcolor="#ddddff" | Name
| [[CT_MAP_MAIN]] || 101 || 0x65 ||
! bgcolor="#ddddff" | Type
! bgcolor="#ddddff" | Remark
|-
|-
| '''idc'''
| [[CT_LISTNBOX]] || 102 || 0x66 ||
| integer
| the unique ID number of this dialog. Can be -1 if you don't require access to the dialog itself from within a script.
|-
|-
| '''color'''
| [[CT_ITEMSLOT]] || 103 || 0x67 ||
| color array
| color of the slider lines.
|-
|-
| '''coloractive'''
| [[CT_LISTNBOX_CHECKABLE]] || 104 || 0x68 ||
| color array
| color of the arrows.
|-
|-
| [[CT_VEHICLE_DIRECTION]] || 105 || 0x69 ||
|}
|}
--->


Sliders corresponding '''type''' property is ''CT_SLIDER''.
=== Control Type Definitions ===
All definitions can be retrieved with <sqf inline>"Default" call BIS_fnc_exportGUIBaseClasses;</sqf>.<br>
<spoiler text="Show Control Type Definitions">
<syntaxhighlight lang="cpp">
#define CT_STATIC   0
#define CT_BUTTON   1
#define CT_EDIT   2
#define CT_SLIDER   3
#define CT_COMBO   4
#define CT_LISTBOX   5
#define CT_TOOLBOX   6
#define CT_CHECKBOXES   7
#define CT_PROGRESS   8
#define CT_HTML   9
#define CT_STATIC_SKEW 10
#define CT_ACTIVETEXT 11
#define CT_TREE 12
#define CT_STRUCTURED_TEXT 13
#define CT_CONTEXT_MENU 14
#define CT_CONTROLS_GROUP 15
#define CT_SHORTCUTBUTTON 16
#define CT_HITZONES 17
#define CT_VEHICLETOGGLES 18
#define CT_CONTROLS_TABLE 19
#define CT_XKEYDESC 40
#define CT_XBUTTON 41
#define CT_XLISTBOX 42
#define CT_XSLIDER 43
#define CT_XCOMBO 44
#define CT_ANIMATED_TEXTURE 45
#define CT_MENU 46
#define CT_MENU_STRIP 47
#define CT_CHECKBOX 77
#define CT_OBJECT 80
#define CT_OBJECT_ZOOM 81
#define CT_OBJECT_CONTAINER 82
#define CT_OBJECT_CONT_ANIM 83
#define CT_LINEBREAK 98
#define CT_USER 99
#define CT_MAP 100
#define CT_MAP_MAIN 101
#define CT_LISTNBOX 102
#define CT_ITEMSLOT 103
#define CT_LISTNBOX_CHECKABLE 104
#define CT_VEHICLE_DIRECTION 105
</syntaxhighlight>
</spoiler>


'''Notice:'''
== Control Styles ==


You can change the orientation of the slider with the '''style''' constants ''SL_HORZ'' and ''SL_VERT''.
To further customize controls there are several different styles for each control type available.<br>
[[Image:ControlSlider.JPG|thumb|200px|A Slider Contorl]]
* '''Example:'''
<code><nowiki>class MySlider {
    idc = -1;
    type = CT_SLIDER;
    style = SL_HORZ;
    x = 0.4;
    y = 0.2;
    w = 0.3;
    h = 0.025;
    color[] = { 1, 1, 1, 1 };
    coloractive[] = { 1, 0, 0, 0.5 };
    // This is an ctrlEventHandler to show you some response if you move the sliderpointer.
    onSliderPosChanged = "hint format[""%1"",_this];";
  }
};</nowiki></code>


=== Combobox ===
To get an idea of how the styles look like you can create the following dialog:
<sqf>createDialog "RscTestControlStyles";</sqf>


{| border="1" align="center" cellpadding="3" cellspacing="0" |
{{Feature | important | Note that drawing of vertical text is not supported and any attempt to use {{hl|ST_UP}}, {{hl|ST_DOWN}}, {{hl|ST_VCENTER}} is likely to result in the following ''.rpt'' spam:<br>{{hl|Obsolete, sizeH and sizeW calculation missing}}<br>In addition, {{hl|ST_UP}}, {{hl|ST_DOWN}}, {{hl|ST_VCENTER}} are stand alone styles and should not be mixed with any other styles}}
! colspan="3" bgcolor="#bbbbff" | Properties
 
{| class="wikitable" Style="Width: 100%"
! Define !! Decimal !! Hexadecimal !! Remark
|-
| ST_LEFT || 0 || 0x00 || Default, text left aligned
|-
| ST_RIGHT || 1 || 0x01 || Modifier, adding this to another style will force text to be aligned to the right
|-
| ST_CENTER || 2 || 0x02 || Modifier, adding this to another style will force text to be centered
|-
| ST_DOWN || 4 || 0x04 || Vertical text alignment (See the note above)
|-
| ST_UP || 8 || 0x08 || Vertical text alignment (See the note above)
|-
| ST_VCENTER || 12 || 0x0C || Vertical text alignment, same as ST_DOWN + ST_UP (See the note above)
|-
| ST_SINGLE || 0 || 0x00 || Plain single line box without a border
|-
| ST_MULTI || 16 || 0x10 || Plain multiple line box with a slight border. To remove border add 512 (+ ST_NO_RECT) to the style (style 528, 529 and 530 are therefore border-less). Additional parameter ''lineSpacing'' is required for this style. ''lineSpacing'' = 1; is normal line spacing. Any '''\n''' character in the text string will be interpreted as new line.
|-
|-
! bgcolor="#ddddff" | Name
| ST_TITLE_BAR || 32 || 0x20 || Plain single line box with semi-transparent background and somewhat embossed border. When this style is used, the dialog containing control becomes draggable by this control
! bgcolor="#ddddff" | Type
! bgcolor="#ddddff" | Remark
|-
|-
| '''idc'''
| ST_PICTURE || 48 || 0x30 || Border-less picture box. Text string is treated as a path to a texture. Alignment has no effect. The texture is stretched to fit the box by default. To force original aspect ratio add 2048 (+ ST_KEEP_ASPECT_RATIO) to the style. Background is ignored, ''colorText'' controls texture colour and opacity
| integer
| the unique ID number of this dialog. Can be -1 if you don't require access to the dialog itself from within a script.
|-
|-
| '''type'''
| ST_FRAME || 64 || 0x40 || Legend like frame without background with text showing over the frame edge. Alignment has no effect. ''colorText'' defines both text and frame colour
| integer (constant)
| control type (ComboBox=4) [[#Constants|constant]]
|-
|-
| '''style'''
| ST_BACKGROUND || 80 || 0x50 || Single line box with always black opaque background and thick raised beveled border
| integer (constant)
| style [[#Constants|constant]]
|-
|-
| '''font'''
| ST_GROUP_BOX || 96 || 0x60 || Single line box with delicate semi-transparent background and slight border. Only text colour can be controlled
| float
| the font to use. See the list of [[Fonts#Available_Fonts|available fonts]] for possible values
|-
|-
| '''sizeEx'''
| ST_GROUP_BOX2 || 112 || 0x70 || Plain single line box, same as ST_SINGLE, only with a slight border similar to ST_MULTI box border
| color array
| the font size of text (0..1)
|-
|-
| '''rowHeight'''
| ST_HUD_BACKGROUND || 128 || 0x80 || Sets special texture for corners. It was used for rounded corners in {{Name|ofp|short}}, {{Name|arma1|short}} and {{arma2}}. In {{arma3}}, square corners are used everywhere, so the texture is adapted to the unified style, but the technology is not removed. In {{arma3}} it looks the same as normal ST_SINGLE. Corner textures are defined in <sqf inline>configFile >> "CfgInGameUI" >> "imageCornerElement"</sqf> (can be set only globally for the whole game, not per control)
| float
| the height of a single row in the elapsed box.
|-
|-
| '''wholeHeight'''
| ST_TILE_PICTURE || 144 || 0x90 || The picture is tiled according to ''tileH'' and ''tileW'' values. To force tiled picture to keep aspect ratio of original image, add 2048 (+ ST_KEEP_ASPECT_RATIO) to the style.
| float
| the height of the elapsed box.
|-
|-
| '''color'''
| ST_WITH_RECT || 160 || 0xA0 || Single line box frame, similar to ST_FRAME box. The text however is displayed inside the frame. Frame and text colour are set with ''colorText''
| color array
| color of the control surrounding lines.
|-
|-
| '''colorText'''
| ST_LINE || 176 || 0xB0 || Diagonal line going from left top corner to bottom right corner. To control line direction, width ''w'' and height ''h'' parameters of the box could be negative. Line and text colour are set with ''colorText''
| color array
| color of the text.
|-
|-
| '''colorBackground'''
| ST_UPPERCASE || 192 || 0xC0 || Forces control text to upper case
| color array
| background color.
|-
|-
| '''colorSelect'''
| ST_LOWERCASE || 208 || 0xD0 || Forces control text to lower case
| color array
| color of selected text.
|-
|-
| '''colorSelectBackground'''
| ST_ADDITIONAL_INFO || 3840 || 0x0F00 || ST_SHADOW + ST_NO_RECT + SL_HORZ + ST_KEEP_ASPECT_RATIO
| color array
| background color of selected lines.
|-
|-
| '''soundSelect'''
| ST_SHADOW || 256 || 0x0100 ||
| sound array
| Maybe the sound if an item is selected. ''don't work at this time''
|-
|-
| '''soundExpand'''
| ST_NO_RECT || 512 || 0x0200 || This style works for [[CT_STATIC]] in conjunction with ST_MULTI
| sound array
| Maybe the sound if the box expand. ''don't work at this time''
|-
|-
| '''soundCollapse'''
| ST_KEEP_ASPECT_RATIO || 2048 || 0x0800 || When used with image or texture, stops it from stretching to fit the control
| sound array
| Maybe the sound if the box collapse. ''don't work at this time''
|-
|-
| ST_TITLE || 34 || 0x22 || ST_TITLE_BAR + ST_CENTER
|}
|}


ComboBox corresponding '''type''' property is ''CT_COMBO''.
=== Control Specific Styles ===
==== [[CT_LISTBOX]] Specific Styles ====
{| class="wikitable" width="70%"
! Define !! Decimal !! Hexadecimal !! Remark
|-
| LB_TEXTURES || 16 || 0x10 ||
|-
| LB_MULTI || 32 || 0x20 || Makes [[CT_LISTBOX]] multi-selectable
|}


==== [[CT_PROGRESS]] Specific Styles ====
{| class="wikitable" width="70%"
! Define !! Decimal !! Hexadecimal
|-
| ST_VERTICAL || 1 || 0x01
|-
| ST_HORIZONTAL || 0 || 0x00
|}


==== [[CT_SLIDER]] Specific Styles ====
{| class="wikitable" width="70%"
|-
! Define !! Decimal !! Hexadecimal
|-
| SL_VERT || 0 || 0x00
|-
| SL_HORZ || 1024 || 0x0400
|-
| SL_TEXTURES || 16 || 0x10
|}


'''Notice:'''
==== [[CT_TREE]] Specific Styles ====
{| class="wikitable" width="70%"
! Define !! Decimal !! Hexadecimal !! Remark
|-
| TR_SHOWROOT || 1 || 0x01 || When this style is applied, all entries even with path [] can be collapsed. Use unkown.
|-
| TR_AUTOCOLLAPSE || 2 || 0x02 || Use unknown
|}


This seems to be a kind of listbox, so use the '''lb*''' commands to like '''[[lbAdd]]''' or '''[[lbSetSelected]]''' to work with this control.
=== Control Style Definitions ===
All definitions can be retrieved with <sqf inline>"Default" call BIS_fnc_exportGUIBaseClasses;</sqf>.<br>
<spoiler text="Show Control Style Definitions">
<syntaxhighlight lang="cpp">
#define ST_LEFT 0x00
#define ST_RIGHT 0x01
#define ST_CENTER 0x02
#define ST_DOWN 0x04
#define ST_UP 0x08
#define ST_VCENTER 0x0C
#define ST_SINGLE 0x00
#define ST_MULTI 0x10
#define ST_TITLE_BAR 0x20
#define ST_PICTURE 0x30
#define ST_FRAME 0x40
#define ST_BACKGROUND 0x50
#define ST_GROUP_BOX 0x60
#define ST_GROUP_BOX2 0x70
#define ST_HUD_BACKGROUND 0x80
#define ST_TILE_PICTURE 0x90
#define ST_WITH_RECT 0xA0
#define ST_LINE 0xB0
#define ST_UPPERCASE 0xC0
#define ST_LOWERCASE 0xD0
#define ST_ADDITIONAL_INFO 0x0F00
#define ST_SHADOW 0x0100
#define ST_NO_RECT 0x0200
#define ST_KEEP_ASPECT_RATIO 0x0800
#define ST_TITLE ST_TITLE_BAR + ST_CENTER
#define SL_VERT 0
#define SL_HORZ 0x400
#define SL_TEXTURES 0x10
#define ST_VERTICAL 0x01
#define ST_HORIZONTAL 0
#define LB_TEXTURES 0x10
#define LB_MULTI 0x20
#define TR_SHOWROOT 1
#define TR_AUTOCOLLAPSE 2
</syntaxhighlight>
</spoiler>


== Positioning ==


[[Image:ControlCombo.JPG|thumb|200px|A ComboBox Control from example code]]
A detailed description of how you can achieve proper GUI placement can be found on the [[Arma 3: GUI Coordinates]] page.
* '''Example:'''
<code><nowiki>class MyRscCombo {
  idc = -1;
  type = CT_COMBO;
  style = ST_LEFT;


  x = 0.1;
== Inheritance ==
  y = 0.1;
  w = 0.2;
  h = 0.3;
   
  font = "TahomaB";
  sizeEx = 0.025;
 
  rowHeight = 0.025;
  wholeHeight = 4 * 0.025 // 3 lines to display + 1 line of the unelapsed control
 
  color[] = {1,1,1,1};
  colorText[] = {0,0,0,1};
  colorBackground[] = {1,1,1,1};
  colorSelect[] = {1,0,0,1};
  colorSelectBackground[] = {0,1,0,1};


  soundSelect[] = {"", 0.0, 1};
Using inheritance can reduce your dialog class definitions significantly by standardising common attributes in base classes and just changing unique attributes in derived classes. There is no need to re-declare all attributes for every class definition.
  soundExpand[] = {"", 0.0, 1};
  soundCollapse[] = {"", 0.0, 1};
};</nowiki></code>


=== Listbox ===
{{Feature|informative|Using inheritance can make your GUI config hard to read for others.}}
Notes for future:


For list boxes, the usage of 'ST_' style constants (ST_MULTI & ST_TITLE_BAR) behave differently than expected for other controls, so use the corresponding 'LB_' (LB_TEXTURES & LB_MULTI) list box style variants instead.
View the [[Class Inheritance|dedicated inheritance page]] for more information.


type = CT_LISTBOX;
== Preprocessor instructions ==
style = LB_TEXTURES; // solid scrollbar


type = CT_LISTBOX;
Note that you can also add your own [[PreProcessor_Commands|preprocessor instructions]] for commonly used data, eg. for colors, to save yourself the hassle of writing it in several different places and then adapt each of them if you want to change them afterwards (especially if class inheritance is not applicable). It can also make your code more readable sometimes.
style = LB_MULTI; // multiple item selection


=== Toolbox ===
=== Example Config ===
=== Checkbox ===
<spoiler text="Show Example Config">
=== Progress bar ===
<syntaxhighlight lang="cpp">
#define COLOR_HALF_BLACK { 0, 0, 0, 0.5 }


Progress bars are handled by the engine internally. While it is technically possible to attach a progress bar to a dialog, there are no means to influence it (e.g. setting it's value). The progress bar will always stay at 0%.
class MyDialog
{
idd = -1;
movingEnable = 1;
objects[] = {};
controlsBackground[] = { MyDialogBackground };


=== Context menu ===
class MyDialogBackground : RscText
=== HTML ===
{
=== Tree ===
colorBackground[] = COLOR_HALF_BLACK;
Raedor has said, "Unfortunately one can only use RscTree hardcoded." This strongly implies that RscTree is only available to BIS and not to the public. The original post can be [http://www.mapfact.net/forum_arma/viewtopic.php?p=7504&sid=09dda9bd058705f71d489a657fd7f155 found here].
x = 0.7; y = 0.1;
w = 0.25; h = 0.15;
};
};
</syntaxhighlight>
</spoiler>


=== Static skew ===
=== Useful includes ===
=== Controls group ===
=== Animated texture ===
=== Map ===
# '''Example:'''
<code><nowiki>
#define FontM  "Zeppelin33Italic"
#define FontN  "Zeppelin32"
#define CT_STATIC 0
#define CT_BUTTON 1
#define ST_LEFT 0x01
#define CT_ACTIVETEXT  11
#define MM_act0 850
#define MM_act1 851
#define MM_act2 852
#define MM_act3 853
#define MM_act4 854
#define MM_act5 855
#define MM_act6 856
#define MM_act7 857


class RscButton
{{arma3}} offers a wide range of useful files which can be included to get access to some  helpful macros.
{
{| class="wikitable"
type = CT_BUTTON;
|-
idc = 0;
! Include Code !! Description / Content
style = ST_LEFT;
|-
colorText[] = { 0, 0, 0, 1 };
| <syntaxhighlight lang="cpp">#include "\a3\3DEN\UI\macros.inc"</syntaxhighlight> || Defines for [[:Category:Eden Editor|Eden Editor]] like colors, text sizes custom pixel grid macros.
colorFocused[] = {};
|-
colorDisabled[] = { 0, 0, 1, 0.7 };
| <syntaxhighlight lang="cpp">#include "\a3\3DEN\UI\macroexecs.inc"</syntaxhighlight> || Defines for [[:Category:Eden Editor|Eden Editor]] to calculate text sizes etc.
colorBackground[] = { 1, 1, 1, 0.9 };
|-
colorBackgroundDisabled[] = { 1, 1, 1, 0.2 };
| <syntaxhighlight lang="cpp">#include "\a3\ui_f\hpp\definedikcodes.inc"</syntaxhighlight> || Useful when working with custom shortcuts. Contains defines for key codes.
colorBackgroundActive[] = { 0, 0.7, 0.8, 1 };
|-
colorShadow[] = { 0, 0, 0, 0.5 };
| <syntaxhighlight lang="cpp">#include "\a3\ui_f\hpp\definecommoncolors.inc"</syntaxhighlight> || Colors used in {{arma3}}, like background color set by the user.
colorBorder[] = { 0, 0, 0, 1 };
|-
borderSize = 0.01;
| <syntaxhighlight lang="cpp">#include "\a3\ui_f\hpp\definecommongrids.inc"</syntaxhighlight> || UI grids such as GUI_GRID and all its variants.
offsetX = 0.003;
|-
offsetY = 0.003;
| <syntaxhighlight lang="cpp">#include "\a3\ui_f\hpp\defineresincl.inc"</syntaxhighlight> || IDCs and IDDs of many {{arma3}} UIs.
offsetPressedX = 0.002;
|}
offsetPressedY = 0.002;
 
soundEnter[] = { "", 0, 1 };
== User Interface Event Handlers ==
soundPush[] = { "", 0.1, 1 };
soundClick[] = { "null.ogg", 0, 1 };
soundEscape[] = { "", 0, 1 };
font = FontN;
sizeEx = 0.03;
};
class RscMapControl{
access = 0;
type = 101;
idc = -1;
style = 48;
colorBackground[] = {1.00, 1.00, 1.00, 1.00};
colorText[] = {0.00, 0.00, 0.00, 1.00};
font = "TahomaB";
sizeEx = 0.040000;
showCountourInterval=2;
colorSea[] = {0.56, 0.80, 0.98, 0.50};
colorForest[] = {0.60, 0.80, 0.20, 0.50};
colorRocks[] = {0.50, 0.50, 0.50, 0.50};
colorCountlines[] = {0.65, 0.45, 0.27, 0.50};
colorMainCountlines[] = {0.65, 0.45, 0.27, 1.00};
colorCountlinesWater[] = {0.00, 0.53, 1.00, 0.50};
colorMainCountlinesWater[] = {0.00, 0.53, 1.00, 1.00};
colorForestBorder[] = {0.40, 0.80, 0.00, 1.00};
colorRocksBorder[] = {0.50, 0.50, 0.50, 1.00};
colorPowerLines[] = {0.00, 0.00, 0.00, 1.00};
colorNames[] = {0.00, 0.00, 0.00, 1.00};
colorInactive[] = {1.00, 1.00, 1.00, 0.50};
colorLevels[] = {0.00, 0.00, 0.00, 1.00};
fontLabel = "TahomaB";
sizeExLabel = 0.02;
fontGrid = "TahomaB";
sizeExGrid = 0.02;
fontUnits = "TahomaB";
sizeExUnits = 0.02;
fontNames = "TahomaB";
sizeExNames = 0.02;
fontInfo = "TahomaB";
sizeExInfo = 0.02;
fontLevel = "TahomaB";
sizeExLevel = 0.02;
stickX = {0.20, {"Gamma", 1.00, 1.50} };
stickY = {0.20, {"Gamma", 1.00, 1.50} };
ptsPerSquareSea = 6;
ptsPerSquareTxt = 8;
ptsPerSquareCLn = 8;
ptsPerSquareExp = 8;
ptsPerSquareCost = 8;
ptsPerSquareFor = "4.0f";
ptsPerSquareForEdge = "10.0f";
ptsPerSquareRoad = 2;
ptsPerSquareObj = 10;
text = "\ca\ui\data\map_background2_co.paa";


class ActiveMarker {
User Interface Event Handlers are a key component of any {{arma3}} GUI. See [[User Interface Event Handlers]].
color[] = {0.30, 0.10, 0.90, 1.00};
size = 50;
};
class Bunker {
icon = "\ca\ui\data\map_bunker_ca.paa";
color[] = {0.00, 0.35, 0.70, 1.00};
size = 14;
importance = "1.5 * 14 * 0.05";
coefMin = 0.25;
coefMax = 4.00;
};
class Bush {
icon = "\ca\ui\data\map_bush_ca.paa";
color[] = {0.55, 0.64, 0.43, 1.00};
size = 14;
importance = "0.2 * 14 * 0.05";
coefMin = 0.25;
coefMax = 4.00;
};
class BusStop {
icon = "\ca\ui\data\map_busstop_ca.paa";
color[] = {0.00, 0.00, 1.00, 1.00};
size = 10;
importance = "1 * 10 * 0.05";
coefMin = 0.25;
coefMax = 4.00;
};
class Command {
icon = "#(argb,8,8,3)color(1,1,1,1)";
color[] = {0.00, 0.00, 0.00, 1.00};
size = 18;
importance = 1.00;
coefMin = 1.00;
coefMax = 1.00;
};
class Cross {
icon = "\ca\ui\data\map_cross_ca.paa";
color[] = {0.00, 0.35, 0.70, 1.00};
size = 16;
importance = "0.7 * 16 * 0.05";
coefMin = 0.25;
coefMax = 4.00;
};
class Fortress {
icon = "\ca\ui\data\map_bunker_ca.paa";
color[] = {0.00, 0.35, 0.70, 1.00};
size = 16;
importance = "2 * 16 * 0.05";
coefMin = 0.25;
coefMax = 4.00;
};
class Fuelstation {
icon = "\ca\ui\data\map_fuelstation_ca.paa";
color[] = {1.00, 0.35, 0.35, 1.00};
size = 16;
importance = "2 * 16 * 0.05";
coefMin = 0.75;
coefMax = 4.00;
};
class Fountain {
icon = "\ca\ui\data\map_fountain_ca.paa";
color[] = {0.00, 0.35, 0.70, 1.00};
size = 12;
importance = "1 * 12 * 0.05";
coefMin = 0.25;
coefMax = 4.00;
};
class Hospital {
icon = "\ca\ui\data\map_hospital_ca.paa";
color[] = {0.78, 0.00, 0.05, 1.00};
size = 16;
importance = "2 * 16 * 0.05";
coefMin = 0.50;
coefMax = 4;
};
class Chapel {
icon = "\ca\ui\data\map_chapel_ca.paa";
color[] = {0.00, 0.35, 0.70, 1.00};
size = 16;
importance = "1 * 16 * 0.05";
coefMin = 0.90;
coefMax = 4.00;
};
class Church {
icon = "\ca\ui\data\map_church_ca.paa";
color[] = {0.00, 0.35, 0.70, 1.00};
size = 16;
importance = "2 * 16 * 0.05";
coefMin = 0.90;
coefMax = 4.00;
};
class Lighthouse {
icon = "\ca\ui\data\map_lighthouse_ca.paa";
color[] = {0.78, 0.00, 0.05, 1.00};
size = 20;
importance = "3 * 16 * 0.05";
coefMin = 0.90;
coefMax = 4.00;
};
class Quay {
icon = "\ca\ui\data\map_quay_ca.paa";
color[] = {0.00, 0.35, 0.70, 1.00};
size = 16;
importance = "2 * 16 * 0.05";
coefMin = 0.50;
coefMax = 4.00;
};
class Rock {
icon = "\ca\ui\data\map_rock_ca.paa";
color[] = {0.35, 0.35, 0.35, 1.00};
size = 12;
importance = "0.5 * 12 * 0.05";
coefMin = 0.25;
coefMax = 4.00;
};
class Ruin {
icon = "\ca\ui\data\map_ruin_ca.paa";
color[] = {0.78, 0.00, 0.05, 1.00};
size = 16;
importance = "1.2 * 16 * 0.05";
coefMin = 1.00;
coefMax = 4.00;
};
class Stack {
icon = "\ca\ui\data\map_stack_ca.paa";
color[] = {0.00, 0.35, 0.70, 1.00};
size = 20;
importance = "2 * 16 * 0.05";
coefMin = 0.90;
coefMax = 4.00;
};
class Tree {
icon = "\ca\ui\data\map_tree_ca.paa";
color[] = {0.55, 0.64, 0.43, 1.00};
size = 12;
importance = "0.9 * 16 * 0.05";
coefMin = 0.25;
coefMax = 4.00;
};
class SmallTree {
icon = "\ca\ui\data\map_smalltree_ca.paa";
color[] = {0.55, 0.64, 0.43, 1.00};
size = 12;
importance = "0.6 * 12 * 0.05";
coefMin = 0.25;
coefMax = 4.00;
};
class Tourism {
icon = "\ca\ui\data\map_tourism_ca.paa";
color[] = {0.78, 0.00, 0.05, 1.00};
size = 16;
importance = "1 * 16 * 0.05";
coefMin = 0.70;
coefMax = 4.00;
};
class Transmitter {
icon = "\ca\ui\data\map_transmitter_ca.paa";
color[] = {0.00, 0.35, 0.70, 1.00};
size = 20;
importance = "2 * 16 * 0.05";
coefMin = 0.90;
coefMax = 4.00;
};
class ViewTower {
icon = "\ca\ui\data\map_viewtower_ca.paa";
color[] = {0.00, 0.35, 0.70, 1.00};
size = 16;
importance = "2.5 * 16 * 0.05";
coefMin = 0.50;
coefMax = 4.00;
};
class Watertower {
icon = "\ca\ui\data\map_watertower_ca.paa";
color[] = {0.00, 0.35, 0.70, 1.00};
size = 32;
importance = "1.2 * 16 * 0.05";
coefMin = 0.90;
coefMax = 4.00;
};
class Waypoint {
icon = "\ca\ui\data\map_waypoint_ca.paa";
color[] = {0.00, 0.00, 0.00, 1.00};
size = 24;
importance = 1.00;
coefMin = 1.00;
coefMax = 1.00;
};
class WaypointCompleted {
icon = "\ca\ui\data\map_waypoint_completed_ca.paa";
color[] = {0.00, 0.00, 0.00, 1.00};
size = 24;
importance = 1.00;
coefMin = 1.00;
coefMax = 1.00;
};
};


class ctrlParaDiag
{
idd = 856;
moving = false;
movingEnable = false;
movingEnabled = false;
controlsBackground[ ]={ };
objects[ ]={ };
controls[ ]={ Map,Sostsiti0,Sostsiti1,Sostsiti2,Sostsiti3,Sostsiti4,Sostsiti5,
Sostsiti6,Sostsiti7 };


class Map: RscMapControl
== Scripting ==
{
idc = 858;
colorBackground[] = {1,1,1,1};
colorSea[] = {0.56,0.8,0.98,0.5};
x = 0.1;
y = 0.1;
w = 0.8;
h = 0.8;
font = FontM;
default = true;
};
class Sostsiti0 : RscButton
{
idc = MM_act0;
x = 0.105;
y = 0.95;
w = 0.19;
h = 0.04;
text = "In Siti";
action = "";
};
class Sostsiti1 : RscButton
{
idc = MM_act1;
x = 0.305;
y = 0.95;
w = 0.19;
h = 0.04;
text = "In Vzvod";
action = "";
};
class Sostsiti2 : RscButton
{
idc = MM_act2;
x = 0.505;
y = 0.95;
w = 0.19;
h = 0.04;
text = "Osmotr";
action = "";
};
class Sostsiti3 : RscButton
{
idc = MM_act3;
x = 0.705;
y = 0.95;
w = 0.19;
h = 0.04;
text = "Exit";
action = "closeDialog 0";
};
class Sostsiti4 : RscButton
{
idc = MM_act4;
x = 0.105;
y = 0.0;
w = 0.19;
h = 0.04;
text = "Strig";
action = "";
};
class Sostsiti5 : RscButton
{
idc = MM_act5;
x = 0.305;
y = 0.0;
w = 0.19;
h = 0.04;
text = "Bomber";
action = "";
};
class Sostsiti6 : RscButton
{
idc = MM_act6;
x = 0.505;
y = 0.0;
w = 0.19;
h = 0.04;
text = "Gaubica";
action = "";
};
class Sostsiti7 : RscButton
{
idc = MM_act7;
x = 0.705;
y = 0.0;
w = 0.19;
h = 0.04;
text = "Razvedka";
action = "";
};
};</nowiki></code>


== UI Eventhandlers ==
There are several functions and commands to edit your dialog after its creation. These functions and commands can be found here:
* [[:Category:Function_Group:_GUI|GUI Functions]]
* [[:Category:Command Group: GUI Control|GUI Commands]]


A reference list of [[User Interface Event Handlers|User_Interface_Event_Handlers]].


== Best practice ==
== Native {{arma3}} GUIs ==


=== Inheritance ===
{{arma3}} comes with a wide varity of various displays and dialogs. They can be found in:
<!-- added by Dr_Eyeball. Example not tested. 11 May 2007. Modify it as you see fit, but don't forget this important topic. -->
* [[configFile]] usually with names like '''Rsc'''SomeDisplayName or '''Display'''SomeDisplayName
<!-- Nasty person and Java developer that I am, I dared to move all opening braces at the end of the previous line to make it look more compact. Furthermore I removed some placeholders, because they didn't seem to be needed that much. I hope you don't mind. Also, I love to meddle... :) ~~~~ -->
Using inheritance can reduce your dialog class definitions significantly by standardising common attributes in base classes and just changing unique attributes in derived classes. There is no need to redeclare all attributes for each class definition.


* '''Example:'''
Additonally, {{arma3}} offers some customizeable GUIs which can be accessed by scripts.
<code><nowiki>class RscText {
* [[BIS_fnc_3DENShowMessage]]
  type = CT_STATIC;
* [[BIS_fnc_guiMessage]]
  idc = -1;
* [[BIS_fnc_GUIhint]]
  style = ST_LEFT;
* [[hint]], [[hintSilent]], [[hintC]]
  colorBackground[] = {0, 0, 0, 1};
  colorText[] = {1, 1, 1, 1};
  font = FontM;
  sizeEx = 0.04;
  h = 0.04;
  text = "";
};


class My_BlueText : RscText {
  colorText[] = {0, 0, 1, 1};
  x = 0.1;
  w = 0.4;
};


class My_Dialog {
== GUI References ==
  //...


  controls[] = {
It is sometimes a good idea so see how others created their GUIs. Here is a list of a few resources:
    My_Text_1,
* {{Link|https://github.com/7erra/-Terra-s-Editing-Extensions/tree/master/TER_editing/gui|Terra's Editing Extensions}}
    My_Text_2
* {{Link|https://github.com/ConnorAU/A3ExtendedFunctionViewer|A3ExtendedFunctionViewer}}
  };
* {{Link|https://github.com/ConnorAU/A3UserInputMenus|A3UserInputMenus}}
* {{Link|https://github.com/ConnorAU/A3ColorPicker|A3ColorPicker}}
* {{Link|https://github.com/R3voA3/3den-Enhanced/tree/master/3denEnhanced/GUI|3den Enhanced}}


  class My_Text_1 : My_BlueText {
== Tips for creating GUIs ==
    text = "Line 1";
<!-- What is this? -->
    y = 0.2; 
* Functionality
  };
* Layout
* Style
* Behaviour
* Customizability


  class My_Text_2 : My_BlueText {
{{Wiki|stub}}
    text = "Line 2";
    y = 0.25; 
  };
};</nowiki></code>


=== Preprocessor instructions ===


Note that you can also add your own preprocessor instructions for commonly used data, eg. for colors, to save yourself the hassle of writing it in several different places and then adapt each of them if you want to change them afterwards (especially if class inheritance isn't applicable). Also it can make your code look more readable sometimes.
== Tutorials ==


* '''Example:'''
* [[GUI Tutorial]]
<code><nowiki>#define COLOR_LIGHTBROWN { 0.776, 0.749, 0.658, 1 }
{{Wiki|stub}}
#define COLOR_HALF_BLACK { 0, 0, 0, 0.5 }
#define COLOR_TRANSPARENT { 0, 0, 0, 0 }


// ...


class MyDialog {
== See Also ==
idd = -1;
movingEnable = 1;
objects[] = {};
controlsBackground[] = { MyDialogBackground };
controls[] = { MyDialogText };


class MyDialogBackground : RscText {
* [[Arma 3: IDD List]]
colorBackground[] = COLOR_HALF_BLACK;
* [[Arma 3: User Interface Editor]]
x = 0.7;  y = 0.1;
* [[Arma 3: GUI Coordinates]]
w = 0.25; h = 0.15;
* [[:Category:Function Group:_GUI|GUI Functions]]
};
* [[:Category:Command Group: GUI Control|GUI Commands]]
* [[User Interface Event Handlers]]
* [[Class Inheritance]]
* [[PreProcessor Commands]]


class MyDialogText : RscText {
style = ST_MULTI;
colorBackground[] = COLOR_TRANSPARENT;
colorText[] = COLOR_LIGHTBROWN;
text = "No power in the 'Verse can stop me.";
lineSpacing = 1;
x = 0.71; y = 0.11;
w = 0.23; h = 0.13;
};
};</nowiki></code>


[[Category: Scripting_Topics]]
[[Category:GUI Topics|GUI Configuration]]

Latest revision as of 10:31, 19 April 2024

Dialogs are one way to provide custom graphical user interface in your missions and allow interaction with the player as well as they are able to run code. They are defined as classes in the missionConfigFile (description.ext), campaignConfigFile (Campaign Description.ext) or configFile (config.cpp).


Terminology

GUI
Graphical User Interface - Allows user interaction with the software through graphical controls like buttons, lists and so on.
UI
User Interface - Allows the user to interact with the software through a console application.
IGUI
Integrated Graphical User Interface - A term usually encountered when talking about vanilla menus in Arma 3.


User Interface Types

Dialog

  • Can be created upon an existing display. Parent display will be hidden.

Display

  • Can be created upon an existing display. Parent display will be hidden.
  • Player movement is not blocked by display, if it has not been blocked by its parent display already.
Generally speaking, dialogs and displays are identical. They are only differentiated by the way they are created (createDisplay, createDialog).

HUD

Some of the commands have different effects. Please check the command's biki page for detailed information.


Display and Dialog

Displays and dialogs are defined in the config file. They are usually used to simplify user interactions, through controls like buttons, list boxes and so on.

Properties

Name Type Remark
idd Integer The unique ID number of this dialog. Used with findDisplay to find the display. Can be -1 if no access is required from within a script.
access Integer
  • 0 - ReadAndWrite - this is the default case where properties can still be added or overridden.
  • 1 - ReadAndCreate - this only allows creating new properties.
  • 2 - ReadOnly - this does not allow to do anything in deriving classes.
  • 3 - ReadOnlyVerified - this does not allow to do anything either in deriving classes, and a CRC check will be performed.
movingEnable Boolean Specifies whether the dialog can be moved or not (if enabled one of the dialogs controls should have the moving property set to 1 so it becomes the "handle" the dialog can be moved with). Doesn't seem to matter in Arma 3
enableSimulation Boolean Specifies whether the game continues while the dialog is shown or not.
onLoad String Expression executed when the dialog is opened. See User Interface Event Handlers
onUnload String Expression executed when the dialog is closed. See User Interface Event Handlers
controlsBackground Array or class Contains class names of all background controls associated to this dialog.

The sequence in which the controls are listed will decide their z-index (i.e. the last ones will on top of the first ones).

controls Array or class Contains class names of all foreground controls associated to this dialog.
objects Array or class List of all DialogControls-Objects type controls

Example Config

class DefaultDialog
{
	idd = -1;
	access = 0;
	movingEnable = true;
	onLoad = "hint str _this";
	onUnload  = "hint str _this";
	enableSimulation = false;
	class ControlsBackground
	{
		//Background controls
	};
	class Controls
	{
		//Controls
	};
	class Objects
	{
		//Objects
	};
};

Opening a display or dialog

There are two ways of creating a display or dialog. One can either use createDialog or createDisplay command.

Closing a display or dialog

There are several ways to close a dialog:

Exit Codes

Exit codes are a way to determine in what way a display was closed. The onUnload UIEH has the exit code as one of its parameters. This way you can handle different user decisions, eg. save a value if the user confirms it or discard changes when the user pressed a cancel button. Macros for the different exit codes can be found in \a3\ui_f\hpp\defineResincl.inc:

// Predefined controls
#define IDC_OK				1
#define IDC_CANCEL			2
#define IDC_AUTOCANCEL		3
#define IDC_ABORT			4
#define IDC_RESTART			5
#define IDC_USER_BUTTON		6
#define IDC_EXIT_TO_MAIN	7
Exit Code Macro Comment
1 IDC_OK Dialog was closed with a positive outcome
2 IDC_CANCEL Dialog was closed with a negative outcome
3 IDC_AUTOCANCEL ?
4 IDC_ABORT When used on the mission display (Display #46) it simulates "Save and Exit" button from escape menu
5 IDC_RESTART ?
6 IDC_USER_BUTTON ?
7 IDC_EXIT_TO_MAIN ?

HUDs

HUDs are defined in the class RscTitles, unlike displays or dialogs which are root classes in the config file. Additionally, their properties are different.

Properties

Name Type Remark
idd Integer The unique ID number of this HUD. Used with findDisplay to find the display. Can be -1 if no access is required from within a script.
fadeIn Integer Duration of fade in effect when opening in seconds.
fadeOut Integer Duration of fade out effect when closing in seconds.
duration Integer Duration the HUD is displayed after opening in seconds. Use a very large number to have it always open.
onLoad String Expression executed when the dialog is opened. See User Interface Event Handlers
onUnload String Expression executed when the dialog is closed. See User Interface Event Handlers
controls Array Contains class names of all foreground controls associated to this dialog.

Example Config

#include "\a3\ui_f\hpp\definecommongrids.inc"

class RscTitles
{
	class RscInfoText
	{
		idd = 3100;
		fadein = 0;
		fadeout = 0;
		duration = 1e+011;
		onLoad = "uinamespace setVariable ['BIS_InfoText',_this select 0]";
		onUnLoad = "uinamespace setVariable ['BIS_InfoText', nil]";
		class Controls
		{
			class InfoText
			{
				idc = 3101;
				style = "0x01 + 0x10 + 0x200 + 0x100";
				font = "RobotoCondensedBold";
				x = "(profileNamespace getVariable [""IGUI_GRID_MISSION_X"", (safezoneX + safezoneW - 21 * (GUI_GRID_WAbs / 40))])";
				y = "(profileNamespace getVariable [""IGUI_GRID_MISSION_Y"", (safezoneY + safezoneH - 10.5 * (GUI_GRID_HAbs / 25))])";
				w = "20 * (GUI_GRID_WAbs / 40)";
				h = "5 * ((GUI_GRID_WAbs / 1.2) / 25)";
				colorText[] = {1,1,1,1};
				colorBackground[] = {0,0,0,0};
				text = "";
				lineSpacing = 1;
				sizeEx = 0.045;
				fixedWidth = 1;
				deletable = 0;
				fade = 0;
				access = 0;
				type = 0;
				shadow = 1;
				colorShadow[] = {0,0,0,0.5};
				tooltipColorText[] = {1,1,1,1};
				tooltipColorBox[] = {1,1,1,1};
				tooltipColorShade[] = {0,0,0,0.65};
			};
		};
	};
};
↑ Back to spoiler's top


Controls

Controls are used to allow the player to interact with the GUI. Controls range from simple rectangles to 3D objects. Like dialogs, displays and HUDs, controls can have a unique ID to access them from within scripts. The classname of controls have to be unique.

What properties a control needs is defined by its type property. However most controls share a set of properties described in the following sections. For control specific properties visit the corresponding pages.

Common Properties

Name Type Remark
idc Integer The unique ID number of this control. Can be -1 if you don't require access to the control itself from within a script.

Special (button) IDCs (according to \a3\ui_f\hpp\defineResincl.inc):

  • 1: OK (closes display when clicked upon, raises exit code 1 in the onUnload UIEH)
  • 2: Cancel (closes display when clicked upon, raises exit code 2 in the onUnload UIEH)
  • 3: Auto cancel
  • 4: Abort
  • 5: Restart
  • 6: User button
  • 7: Exit to main

While the purposes of idcs 3 to 7 remain unknown, it is advisable to give all of your controls larger numbers, eg. 100.

moving Boolean Whether the dialog will be moved if this control is dragged (may require "movingEnable" to be 1 in the dialog. In Arma 3 works regardless). Another way of allowing moving of the dialog is to have control of style ST_TITLE_BAR
type Integer See Control Types
style Integer See Control Styles. style = "0x400+0x02+0x10";
x/y/w/h Number The position and size of the control in fractions of screen size.
sizeEx Number The font size of text in fractions of screen size. Behaves similar to h property. For some controls it is named size.
font String The font to use. See the list of available fonts for possible values.
colorText Array Text color
colorBackground Array Background color
text String The text or picture to display.
shadow Integer Can be applied to most controls (0 = no shadow, 1 = drop shadow with soft edges, 2 = stroke).
tooltip String Text to display in a tooltip when control is moused over. A tooltip can be added to any control type except CT_STATIC and CT_STRUCTURED_TEXT. Note: As of Arma 3 logo black.png1.48, most controls now support tooltips. A linebreak can be created by adding \n.
tooltipColorShade Array Tooltip background color
tooltipColorText Array Tooltip text color
tooltipColorBox Array Tooltip border color
autocomplete String (where applicable) Option for entry fields (e.g. RscEdit) to activate autocompletion. For known script commands and functions use autocomplete = "scripting".
url String (where applicable) URL which will be opened when clicking on the control. Used on e.g. a button control. Does not utilize the Steam Overlay browser if enabled by default, opens the link in the default browser set by the OS.
overlayMode Number Arma 3 logo black.png2.10 (where applicable) 0 - opens URL in default browser; 1 - opens URL in Steam overlay id enabled, otherwise in default browser; 2 - opens URL in Steam overlay, shows error message box (with button to use default browser) if Steam overlay is disabled.

A property to enable or disable a control does not exist (because of implementation issues). However, there is a simple workaround based on the onLoad UI Event Handler that can be used to disable a control in the config:

onLoad = "(_this # 0) ctrlEnable false;";

Attributes Class

Name Type Remark
font String Available Fonts
color HTML color HTML Color Codes
align String "center", "left", "right"
shadow Integer 0 = no shadow, 1 = drop shadow with soft edges, 2 = stroke

AttributesImage Class

Name Type Remark
font String Available Fonts (Optional)
color HTML color HTML Color Codes
align String "center", "left", "Right" (optional)


Example Config

#include "\a3\ui_f\hpp\definecommongrids.inc"

class RscButton
{
	deletable = 0;
	fade = 0;
	access = 0;
	type = 1;
	text = "";
	colorText[] = {1,1,1,1};
	colorDisabled[] = {1,1,1,0.25};
	colorBackground[] = {0,0,0,0.5};
	colorBackgroundDisabled[] = {0,0,0,0.5};
	colorBackgroundActive[] = {0,0,0,1};
	colorFocused[] = {0,0,0,1};
	colorShadow[] = {0,0,0,0};
	colorBorder[] = {0,0,0,1};
	soundEnter[] = {"\A3\ui_f\data\sound\RscButton\soundEnter",0.09,1};
	soundPush[] = {"\A3\ui_f\data\sound\RscButton\soundPush",0.09,1};
	soundClick[] = {"\A3\ui_f\data\sound\RscButton\soundClick",0.09,1};
	soundEscape[] = {"\A3\ui_f\data\sound\RscButton\soundEscape",0.09,1};
	idc = -1;
	style = 2;
	x = 0;
	y = 0;
	w = 0.095589;
	h = 0.039216;
	shadow = 2;
	font = "RobotoCondensed";
	sizeEx = "GUI_GRID_HAbs / 25";
	url = "";
	offsetX = 0;
	offsetY = 0;
	offsetPressedX = 0;
	offsetPressedY = 0;
	borderSize = 0;
};
↑ Back to spoiler's top


Control Types

The type property of controls defines what type of control they are. For example an edit box has the type 2. There is an ingame dialog with examples of how the control types look and act like:

createDialog "RscTestControlTypes";


Control Type Definitions

All definitions can be retrieved with "Default" call BIS_fnc_exportGUIBaseClasses;.

#define CT_STATIC				  0
#define CT_BUTTON				  1
#define CT_EDIT					  2
#define CT_SLIDER				  3
#define CT_COMBO				  4
#define CT_LISTBOX				  5
#define CT_TOOLBOX				  6
#define CT_CHECKBOXES			  7
#define CT_PROGRESS				  8
#define CT_HTML					  9
#define CT_STATIC_SKEW			 10
#define CT_ACTIVETEXT			 11
#define CT_TREE					 12
#define CT_STRUCTURED_TEXT		 13
#define CT_CONTEXT_MENU			 14
#define CT_CONTROLS_GROUP		 15
#define CT_SHORTCUTBUTTON		 16
#define CT_HITZONES				 17
#define CT_VEHICLETOGGLES		 18
#define CT_CONTROLS_TABLE		 19
#define CT_XKEYDESC				 40
#define CT_XBUTTON				 41
#define CT_XLISTBOX				 42
#define CT_XSLIDER				 43
#define CT_XCOMBO				 44
#define CT_ANIMATED_TEXTURE		 45
#define CT_MENU					 46
#define CT_MENU_STRIP			 47
#define CT_CHECKBOX				 77
#define CT_OBJECT				 80
#define CT_OBJECT_ZOOM			 81
#define CT_OBJECT_CONTAINER		 82
#define CT_OBJECT_CONT_ANIM		 83
#define CT_LINEBREAK			 98
#define CT_USER					 99
#define CT_MAP					100
#define CT_MAP_MAIN				101
#define CT_LISTNBOX				102
#define CT_ITEMSLOT				103
#define CT_LISTNBOX_CHECKABLE	104
#define CT_VEHICLE_DIRECTION	105
↑ Back to spoiler's top

Control Styles

To further customize controls there are several different styles for each control type available.

To get an idea of how the styles look like you can create the following dialog:

createDialog "RscTestControlStyles";

Note that drawing of vertical text is not supported and any attempt to use ST_UP, ST_DOWN, ST_VCENTER is likely to result in the following .rpt spam:
Obsolete, sizeH and sizeW calculation missing
In addition, ST_UP, ST_DOWN, ST_VCENTER are stand alone styles and should not be mixed with any other styles
Define Decimal Hexadecimal Remark
ST_LEFT 0 0x00 Default, text left aligned
ST_RIGHT 1 0x01 Modifier, adding this to another style will force text to be aligned to the right
ST_CENTER 2 0x02 Modifier, adding this to another style will force text to be centered
ST_DOWN 4 0x04 Vertical text alignment (See the note above)
ST_UP 8 0x08 Vertical text alignment (See the note above)
ST_VCENTER 12 0x0C Vertical text alignment, same as ST_DOWN + ST_UP (See the note above)
ST_SINGLE 0 0x00 Plain single line box without a border
ST_MULTI 16 0x10 Plain multiple line box with a slight border. To remove border add 512 (+ ST_NO_RECT) to the style (style 528, 529 and 530 are therefore border-less). Additional parameter lineSpacing is required for this style. lineSpacing = 1; is normal line spacing. Any \n character in the text string will be interpreted as new line.
ST_TITLE_BAR 32 0x20 Plain single line box with semi-transparent background and somewhat embossed border. When this style is used, the dialog containing control becomes draggable by this control
ST_PICTURE 48 0x30 Border-less picture box. Text string is treated as a path to a texture. Alignment has no effect. The texture is stretched to fit the box by default. To force original aspect ratio add 2048 (+ ST_KEEP_ASPECT_RATIO) to the style. Background is ignored, colorText controls texture colour and opacity
ST_FRAME 64 0x40 Legend like frame without background with text showing over the frame edge. Alignment has no effect. colorText defines both text and frame colour
ST_BACKGROUND 80 0x50 Single line box with always black opaque background and thick raised beveled border
ST_GROUP_BOX 96 0x60 Single line box with delicate semi-transparent background and slight border. Only text colour can be controlled
ST_GROUP_BOX2 112 0x70 Plain single line box, same as ST_SINGLE, only with a slight border similar to ST_MULTI box border
ST_HUD_BACKGROUND 128 0x80 Sets special texture for corners. It was used for rounded corners in OFP, ArmA and Arma 2. In Arma 3, square corners are used everywhere, so the texture is adapted to the unified style, but the technology is not removed. In Arma 3 it looks the same as normal ST_SINGLE. Corner textures are defined in configFile >> "CfgInGameUI" >> "imageCornerElement" (can be set only globally for the whole game, not per control)
ST_TILE_PICTURE 144 0x90 The picture is tiled according to tileH and tileW values. To force tiled picture to keep aspect ratio of original image, add 2048 (+ ST_KEEP_ASPECT_RATIO) to the style.
ST_WITH_RECT 160 0xA0 Single line box frame, similar to ST_FRAME box. The text however is displayed inside the frame. Frame and text colour are set with colorText
ST_LINE 176 0xB0 Diagonal line going from left top corner to bottom right corner. To control line direction, width w and height h parameters of the box could be negative. Line and text colour are set with colorText
ST_UPPERCASE 192 0xC0 Forces control text to upper case
ST_LOWERCASE 208 0xD0 Forces control text to lower case
ST_ADDITIONAL_INFO 3840 0x0F00 ST_SHADOW + ST_NO_RECT + SL_HORZ + ST_KEEP_ASPECT_RATIO
ST_SHADOW 256 0x0100
ST_NO_RECT 512 0x0200 This style works for CT_STATIC in conjunction with ST_MULTI
ST_KEEP_ASPECT_RATIO 2048 0x0800 When used with image or texture, stops it from stretching to fit the control
ST_TITLE 34 0x22 ST_TITLE_BAR + ST_CENTER

Control Specific Styles

CT_LISTBOX Specific Styles

Define Decimal Hexadecimal Remark
LB_TEXTURES 16 0x10
LB_MULTI 32 0x20 Makes CT_LISTBOX multi-selectable

CT_PROGRESS Specific Styles

Define Decimal Hexadecimal
ST_VERTICAL 1 0x01
ST_HORIZONTAL 0 0x00

CT_SLIDER Specific Styles

Define Decimal Hexadecimal
SL_VERT 0 0x00
SL_HORZ 1024 0x0400
SL_TEXTURES 16 0x10

CT_TREE Specific Styles

Define Decimal Hexadecimal Remark
TR_SHOWROOT 1 0x01 When this style is applied, all entries even with path [] can be collapsed. Use unkown.
TR_AUTOCOLLAPSE 2 0x02 Use unknown

Control Style Definitions

All definitions can be retrieved with "Default" call BIS_fnc_exportGUIBaseClasses;.

#define ST_LEFT					0x00
#define ST_RIGHT				0x01
#define ST_CENTER				0x02
#define ST_DOWN					0x04
#define ST_UP					0x08
#define ST_VCENTER				0x0C
#define ST_SINGLE				0x00
#define ST_MULTI				0x10
#define ST_TITLE_BAR			0x20
#define ST_PICTURE				0x30
#define ST_FRAME				0x40
#define ST_BACKGROUND			0x50
#define ST_GROUP_BOX			0x60
#define ST_GROUP_BOX2			0x70
#define ST_HUD_BACKGROUND		0x80
#define ST_TILE_PICTURE			0x90
#define ST_WITH_RECT			0xA0
#define ST_LINE					0xB0
#define ST_UPPERCASE			0xC0
#define ST_LOWERCASE			0xD0
#define ST_ADDITIONAL_INFO		0x0F00
#define ST_SHADOW				0x0100
#define ST_NO_RECT				0x0200
#define ST_KEEP_ASPECT_RATIO	0x0800
#define ST_TITLE				ST_TITLE_BAR + ST_CENTER
#define SL_VERT					0
#define SL_HORZ					0x400
#define SL_TEXTURES				0x10
#define ST_VERTICAL				0x01
#define ST_HORIZONTAL			0
#define LB_TEXTURES				0x10
#define LB_MULTI				0x20
#define TR_SHOWROOT				1
#define TR_AUTOCOLLAPSE			2
↑ Back to spoiler's top

Positioning

A detailed description of how you can achieve proper GUI placement can be found on the Arma 3: GUI Coordinates page.

Inheritance

Using inheritance can reduce your dialog class definitions significantly by standardising common attributes in base classes and just changing unique attributes in derived classes. There is no need to re-declare all attributes for every class definition.

Using inheritance can make your GUI config hard to read for others.

View the dedicated inheritance page for more information.

Preprocessor instructions

Note that you can also add your own preprocessor instructions for commonly used data, eg. for colors, to save yourself the hassle of writing it in several different places and then adapt each of them if you want to change them afterwards (especially if class inheritance is not applicable). It can also make your code more readable sometimes.

Example Config

#define COLOR_HALF_BLACK { 0, 0, 0, 0.5 }

class MyDialog
{
	idd = -1;
	movingEnable = 1;
	objects[] = {};
	controlsBackground[] = { MyDialogBackground };

	class MyDialogBackground : RscText
	{
		colorBackground[] = COLOR_HALF_BLACK;
		x = 0.7;  y = 0.1;
		w = 0.25; h = 0.15;
	};
};

Useful includes

Arma 3 offers a wide range of useful files which can be included to get access to some helpful macros.

Include Code Description / Content
#include "\a3\3DEN\UI\macros.inc"
Defines for Eden Editor like colors, text sizes custom pixel grid macros.
#include "\a3\3DEN\UI\macroexecs.inc"
Defines for Eden Editor to calculate text sizes etc.
#include "\a3\ui_f\hpp\definedikcodes.inc"
Useful when working with custom shortcuts. Contains defines for key codes.
#include "\a3\ui_f\hpp\definecommoncolors.inc"
Colors used in Arma 3, like background color set by the user.
#include "\a3\ui_f\hpp\definecommongrids.inc"
UI grids such as GUI_GRID and all its variants.
#include "\a3\ui_f\hpp\defineresincl.inc"
IDCs and IDDs of many Arma 3 UIs.

User Interface Event Handlers

User Interface Event Handlers are a key component of any Arma 3 GUI. See User Interface Event Handlers.


Scripting

There are several functions and commands to edit your dialog after its creation. These functions and commands can be found here:


Native Arma 3 GUIs

Arma 3 comes with a wide varity of various displays and dialogs. They can be found in:

  • configFile usually with names like RscSomeDisplayName or DisplaySomeDisplayName

Additonally, Arma 3 offers some customizeable GUIs which can be accessed by scripts.


GUI References

It is sometimes a good idea so see how others created their GUIs. Here is a list of a few resources:

Tips for creating GUIs

  • Functionality
  • Layout
  • Style
  • Behaviour
  • Customizability


Tutorials


See Also