Arma: GUI Configuration: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
Line 358: Line 358:
| '''colorFocused'''
| '''colorFocused'''
| color array
| color array
|
| color when control has received focus via tabbing or scripted methods
|-
|-
| '''colorShadow'''
| '''colorShadow'''
Line 374: Line 374:
| '''colorBackgroundActive'''
| '''colorBackgroundActive'''
| color array
| color array
|  
| color when control has received focus via mouse-over
|-
|-
| '''colorBackgroundDisabled'''
| '''colorBackgroundDisabled'''

Revision as of 20:23, 1 October 2008

Introduction

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. They are defined as classes in the 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.

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.

Most of these definitions work with numeric constants, which are presented in the following section. For readability purposes you should consider favoring them instead of the actual integers.

  • 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".
  • Colors are usually defined in the following convention: { Red, Green, Blue, Alpha }, 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.
  • Sounds are usually defined in the following convention: { "file.ogg", volume, pitch }, 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.


You can find a complete list of scripting related GUI functions in Category:Command Group: GUI Control.

Constants

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.

// Control types #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_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 // Static styles #define ST_POS 0x0F #define ST_HPOS 0x03 #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 #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 FontM "Zeppelin32"

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.

Attributes

A list of all available attributes (properties) without explaination, originally posted by ColonelSandersLite, can be found 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 file or externalized to seperate hpp-files, which are included in the description.ext file using the #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 for details. For simplicity we won't apply this practice in the following code examples.


Properties
Name Type Remark
idd 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.
movingEnable boolean sets whether or not the player is hindered from aiming or moving while the dialog is open.
controlsBackground array contains class names of all background controls associated to this dialog.
controls array contains class names of all foreground controls associated to this dialog.
objects array


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.

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):

  • 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.

  • Example:

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 }; colorText[] = { 0, 0, 0, 1 }; x = 0.8; y = 0.1; w = 0.2; h = 0.05; }; };

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.

Creating dialogs

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.

  • Example:

_ok = createDialog "MyHelloWorldDialog"; waitUntil { !dialog }; hint "Dialog closed.";

Closing dialogs

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 false and wait statements with a !dialog condition will end.

  • Example - close by action

class CloseButton : RscButton { /* ... */ type = CT_BUTTON; text = "Close"; action = "closeDialog 0"; }

  • Example - close by external request

closeDialog 0

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 GUI functions.

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:

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
moving boolean whether the dialog will be moved if this control is dragged (should be set in a background control)
type integer (constant) control type constant
style integer (constant) style constant
x float the offset from the left side of the window (0..1; 0.0 = left side; 1.0 = right side)
y float the offset from the top side of the window (0..1; 0.0 = left side; 1.0 = right side)
w float the width of the control (0..1)
h float the height of the control (0..1)
sizeEx float the font size of text (0..1)
font string the font to use. See the list of available fonts for possible values

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 chapter for details.

Static

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 CT_STATIC.

Properties
Name Type Remark
colorText color array text color
colorBackground color array background color
text string the text to display initially
lineSpacing float line spacing. Required, if the style was set to ST_MULTI.

Text

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 ST_* constants.

By default, this will only display a single line (and cut the overflow); use ST_MULTI 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.

  • Example:

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!"; };

Solid rectangles

Semi-transparent background

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.

  • Example:

class MyRedBackgroundExample { /* ... same as the text example, except for */ colorBackground[] = { 1, 0.1, 0.1, 0.8 }; text = ""; };

Pictures

Using specific style constants you can enhance your dialogs with pictures too. These pictures should reside in your mission folder as paa-files. Then set your style property to ST_PICTURE (to display it once) or ST_TILE_PICTURE (to tile it) and use the text property to locate the paa image you want to use, relative to your mission folder.

Dialog control showing a picture
  • Example:

class MyPictureExample { /* ... same as the text example, except for */ style = ST_PICTURE; text = "mypicture.paa"; };

Button

Buttons are one way to add interactivity to your dialogs. Their corresponding type property is CT_BUTTON.

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 disabled, it currently doesn't have any mouse or keyboard related focus
  • Disabled: the button has been explicitely disabled. It will not be clickable.
  • 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.
  • 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.

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.

Properties
Name Type Remark
action string a statement that is executed when the button is not disabled and clicked
text string the text to display initially
default boolean Whether or not this button is the dialog's initially selected button
colorText color array text color
colorDisabled color array text color, if the control has been disabled via ctrlEnable
colorFocused color array color when control has received focus via tabbing or scripted methods
colorShadow color array the color of the shadow
colorBorder color array the color of the border, if any
borderSize float the width of the border
colorBackgroundActive color array color when control has received focus via mouse-over
colorBackgroundDisabled color array background color, if the control has disabled via ctrlEnable
offsetX float the relative X offset between the button and its shadow
offsetY float the relative Y offset between the button and its shadow
offsetPressedX float the relative X offset between the button and its shadow, when it's pressed
offsetPressedY float the relative Y offset between the button and its shadow, when it's pressed
soundEnter sound array the sound to play, when the cursor enters the button's bounds
soundPush sound array the sound to play, when the button has been pushed
soundClick sound array the sound to play, when the button is being released
soundEscape sound array the sound to play, when the button has been pushed and the mouse button is released when not over the control


The following example uses almost the same code as the buttons shown in the example screenshot.

The same button four times in different states
  • Example:

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!"""; };

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.

Properties
Name Type Remark
action string a statement that is executed when the control has been clicked
blinkingPeriod float (Seconds) Makes the text start transparent, go to full opacity and back to full transparent in the amount of time specified.
color color array replaces colorText, standard text and underline color
colorActive color array text and underline color whenever the mouse hovers over the control
colorBackground color array not applicable
default boolean Whether or not this control is the dialog's initially selected active text
soundEnter sound array the sound to play, when the cursor enters the button's bounds
soundPush sound array the sound to play, when the button has been pushed
soundClick sound array the sound to play, when the button is being released
soundEscape sound array the sound to play, when the button has been pushed and the mouse button is released when not over the control.
text string the text to display initially

The following example uses almost the same code as the controls shown in the example screenshot.

Simple dialog with three Active Text controls
  • Example:

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; };

Structured text

Text box

Slider

Combobox

Listbox

Notes for future:

Using ST_TYPE with scrollable controls will set the scrollbar to solid texture instead of a box outline.

type = CT_LISTBOX;
style = ST_TYPE;

Toolbox

Checkbox

Progress bar

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%.

Context menu

HTML

Tree

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 found here.

Static skew

Controls group

Animated texture

Map

  1. Example:

#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 { type = CT_BUTTON; idc = 0; style = ST_LEFT; colorText[] = { 0, 0, 0, 1 }; colorFocused[] = {}; colorDisabled[] = { 0, 0, 1, 0.7 }; colorBackground[] = { 1, 1, 1, 0.9 }; colorBackgroundDisabled[] = { 1, 1, 1, 0.2 }; colorBackgroundActive[] = { 0, 0.7, 0.8, 1 }; colorShadow[] = { 0, 0, 0, 0.5 }; colorBorder[] = { 0, 0, 0, 1 }; borderSize = 0.01; offsetX = 0.003; offsetY = 0.003; offsetPressedX = 0.002; offsetPressedY = 0.002; soundEnter[] = { "", 0, 1 }; 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 { 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 { 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 = ""; }; };

UI Eventhandlers

A reference list of User_Interface_Event_Handlers.

Best practice

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 redeclare all attributes for each class definition.

  • Example:

class RscText { type = CT_STATIC; idc = -1; style = ST_LEFT; 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 { //... controls[] = { My_Text_1, My_Text_2 }; class My_Text_1 : My_BlueText { text = "Line 1"; y = 0.2; }; class My_Text_2 : My_BlueText { text = "Line 2"; y = 0.25; }; };

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.

  • Example:

#define COLOR_LIGHTBROWN { 0.776, 0.749, 0.658, 1 } #define COLOR_HALF_BLACK { 0, 0, 0, 0.5 } #define COLOR_TRANSPARENT { 0, 0, 0, 0 } // ... class MyDialog { idd = -1; movingEnable = 1; objects[] = {}; controlsBackground[] = { MyDialogBackground }; controls[] = { MyDialogText }; class MyDialogBackground : RscText { colorBackground[] = COLOR_HALF_BLACK; x = 0.7; y = 0.1; w = 0.25; h = 0.15; }; 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; }; };