1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866
|
# Configurable Widgets
## Introduction
VCMI has capabilities to change some UI elements in your mods beyond only replacing one image with another. Not all UI elements are possible to modify currently, but development team is expanding them.
Elements possible to modify are located in `config/widgets`.
## Tutorial
Let's take `extendedLobby` mod from `vcmi-extras` as an example for VCMI-1.4. [Example sources](https://github.com/vcmi-mods/vcmi-extras/tree/vcmi-1.4/Mods/extendedLobby).
**You can take all assets from this tutorial from sources.**
This submod offers extended options while player creates new game.
For random map tab it defines UI to select RMG template, select map size bigger than XL, configure teams and roads.
For options tab it introduces UI for chess timers.
In this tutorial we will recreate options tab to support chess timers UI.
### Creating mod structure
To start making mod, create following folders structure;
```text
extendedLobby/
|- content/
| |- sprites/
| |- config/
| | |- widgets/
|- mod.json
```
File `mod.json` is generic and could look like this:
```json
{
"name" : "Configurable UI tutorial mod",
"description" : "See tutorial here https://github.com/vcmi/vcmi/wiki/Configurable-UI-widgets",
"version" : "0.1",
"modType" : "Interface",
"compatibility":
{
"min" : "1.4.0"
},
}
```
After that you can copy `extendedLobby/` folder to `mods/` folder and your mod will immediately appear in launcher but it does nothing for now.
### Making layout for timer
Let's copy `config/widgets/optionsTab.json` file from VCMI folder to `content/config/widgets/` folder from our mod.
It defines UI for options tab as it designed in original game, we will keep everything related to player settings and will modify only timer area.
**It's important, that when you are modifying `optionsTab.json`, game restart is not needed! When you updated file, it's enough to go back to main menu and then open lobby and options again. However, when you add new assets (images), you have to restart game to make possible find them.**
It looks like on image below and has 3 elements: label with "Player Turn Duration", label with timer duration ("Unlimited" on picture) and slider to control timer.
<img width="350" alt="Снимок экрана 2023-08-30 в 14 53 49" src="https://github.com/vcmi/vcmi/assets/9308612/a34be309-29fc-412a-9d54-e40a634b56f9">
So we need to modify turn duration label and add combo box with timer types
<img width="345" alt="Снимок экрана 2023-08-30 в 14 53 02" src="https://github.com/vcmi/vcmi/assets/9308612/717b21e6-4ac9-4e27-b90b-b68b0ce65db2">
Open `optionsTab.json` and scroll it until you see comment `timer`. Three elements after this comment are related to timer.
Let's find first element, which is label
```json
{
"items"
[
...
// timer
{
"type": "label",
"font": "small",
"alignment": "center",
"color": "yellow",
"text": "core.genrltxt.521",
"position": {"x": 222, "y": 544}
},
...
],
...
}
```
And modify it a bit
```json
{
"name": "labelTimer", //add name, only for convenience
"type": "label",
"font": "small",
"alignment": "center",
"color": "yellow",
"text": "vcmi.optionsTab.widgets.labelTimer", //replace text
"position": {"x": 104, "y": 542} //move to the left
},
```
But we also need proper background image for this label. Add image widget BEFORE labelTimer widget:
```json
{
"type": "picture",
"image": "RmgTTBk",
"position": {"x": 54, "y": 532}
},
{
"name": "labelTimer", //add name, only for convenience
...
},
```
In order to make it work, add file `RmgTTBk.bmp` to `content/sprites/`
Elements named `labelTurnDurationValue` and `sliderTurnDuration` we will keep without change - they are needed to configure classic timer.
### Adding combo box
Now, let's add combo box.
Copy image `DrDoCoBk.bmp` to `content/sprites/`. Button objects use animated images to show different button states.
For normal, pressed, blocked and highlighted. Our combo box inherits this behavior, so let's convert image to animation.
In order to do it, we need to create file `DrDoCoBk.json` in same folder `content/sprites/` with following content:
```json
{
"sequences" :
[
{
"group" : 0,
"frames" :
[
"DrDoCoBk.bmp"
]
}
]
}
```
Thus we created file with animation, containing single frame which can be used for combo box.
Let's add one more element after `//timer` comment:
```json
...
//timer
{
"name": "timerModeSwitch", //this is important to name it timerModeSwitch, because VCMI binds behavior to element called this way
"type": "comboBox",
"image": "DrDoCoBk",
"position": {"x": 158, "y": 532},
"imageOrder": [0, 0, 0, 0],
"dropDown": {}, //here will be defined elements to be shown in drop down list
},
```
`imageOrder` helps VCMI to understand, which frame from animation to use in normal, pressed, blocked and highlighted states. In our case they will be same and we use 0 frame from `DrDoCoBk` animation.
We also want to have label on the top of this combo box showing which element is selected. You need to add `items` array, where additional elements can be specified, label in our case:
```json
...
//timer
{
"name": "timerModeSwitch",
"type": "comboBox",
"image": "DrDoCoBk",
"position": {"x": 158, "y": 532},
"imageOrder": [0, 0, 0, 0],
"dropDown": {}, //here will be defined elements to be shown in drop down list
"items":
[
{
"name": "timer",
"type": "label",
"font": "small",
"alignment": "left",
"color": "yellow",
"text": "vcmi.optionsTab.widgets.timerModeSwitch.classic" //default value for timer label
}
]
},
```
With that we already have desired layout with all elements shown by default, but we also need to add elements with timer modes into drop-down list:
<img width="236" alt="Снимок экрана 2023-08-30 в 15 34 47" src="https://github.com/vcmi/vcmi/assets/9308612/f515f54e-94e1-4650-88e4-721e00c22e0d">
First of all, add images to `content/sprites/` folder: `List2Bk.bmp` for drop-down background and `List10Sl.bmp` for element highlighting.
Now specify items inside `dropDown` field
```json
"dropDown":
{
"items":
[
{
"name": "background",
"type": "picture",
"image": "List2Bk",
"position": {"x": 0, "y": -52} //negative value because our drop-down shall open in the top direction
},
{
"name": "slider", //let's add slider if we have more elements in future
"type": "slider",
"position": {"x": 212, "y": -52},
"size": 52,
"style": "blue",
"itemsVisible": 2, //we show only two elements
"itemsTotal": 0,
"selected": 0,
"orientation": "vertical",
"callback": "sliderMove" //callback predefined for drop-down menu to control which elements to show
},
//now list elements
{ //classic timer
"type": "item", //this is special type for drop-down elements
"position": {"x": 0, "y": -52},
"items": //each element may have several elements
[
{
"type": "label",
"name": "labelName",
"font": "small",
"alignment": "left",
"color": "white",
"position": {"x": 4, "y": 0},
"text": "vcmi.optionsTab.widgets.timerModeSwitch.classic"
},
{
"type": "picture",
"name": "hoverImage", //"hoverImage" is a key word, helping VCMI to understand which element to show when cursor hovers element
"visible": false, //invisible by default
"image": "List10Sl"
}
]
},
{ //chess timer
"type": "item",
"position": {"x": 0, "y": -27},
"items":
[
{
"type": "label",
"name": "labelName",
"font": "small",
"alignment": "left",
"color": "white",
"position": {"x": 4, "y": 0},
"text": "vcmi.optionsTab.widgets.timerModeSwitch.chess"
},
{
"type": "picture",
"name": "hoverImage",
"visible": false,
"image": "List10Sl"
}
]
},
]
},
```
Now we can press drop-down menu and even select elements.
### Switching timer modes
After view part is done, let's make behavioural part.
Let's hide elements, related to classic timer when chess timer is selected and show them back if classic selected.
To do that, find `"variables"` part inside `optionsTab.json` and add there `"timers"` array, containing 2 elements:
```json
"variables":
{
"timers":
[
{ //variables used if first element is chosen
"text": "vcmi.optionsTab.widgets.timerModeSwitch.classic",
"showWidgets": ["labelTurnDurationValue", "sliderTurnDuration"],
"hideWidgets": [],
},
{ //variables used if second element is chosen
"text": "vcmi.optionsTab.widgets.timerModeSwitch.chess",
"showWidgets": [],
"hideWidgets": ["labelTurnDurationValue", "sliderTurnDuration"],
},
],
"timerPresets" :
[
...
]
}
```
Now we show and hide elements, but visually you still can some "artifacts":
<img width="341" alt="Снимок экрана 2023-08-30 в 15 51 22" src="https://github.com/vcmi/vcmi/assets/9308612/8a4eecdf-2c44-4f38-a7a0-aff6b9254fe6">
It's because options tab background image we use has those elements drawn. Let's hide them with overlay image `timchebk.bmp`.
It should be drawn before all other timer elements:
```json
...
// timer
{
"name": "timerBackground",
"type": "picture",
"image": "timchebk",
"position": {"x": 0, "y": 530}
},
{
"name": "timerModeSwitch",
...
},
...
```
This background must be visible for chess timer and hidden for classic timer. Just put its name `"timerBackground"` into `"hideWidgets"` and `"showWidgets"` for corresponding elements.
It works and can switch elements, the only missing part is chess timer configuration.
### Chess timer configuration
We should add text input fields, to specify different timers. We will use background for them `timerField.bmp`, copy it to `content/sprites/` folder of your mod.
There are 4 different timers: base, turn, battle and creature. Read about them here: <https://github.com/vcmi/vcmi/issues/1364>
We can add editors for them into items list, their format will be following:
```json
{
"name": "chessFieldBase",
"type": "textInput",
"background": "timerField",
"alignment": "center",
"text": "00:00", //default text
"rect": {"x": 54, "y": 557, "w": 84, "h": 25},
"offset": {"x": 0, "y": 0},
"callback": "parseAndSetTimer_base", //callback to specify base timer value from string
"help": "vcmi.optionsTab.widgets.chessFieldBase.help"
},
```
Add three remaining elements for different timers by yourself. You can play with all settings, except callback. There are 4 predefined callbacks to setup timers:
- `parseAndSetTimer_base`
- `parseAndSetTimer_turn`
- `parseAndSetTimer_battle`
- `parseAndSetTimer_creature`
And what we want to do is to hide/show those fields when classic/chess times is selected. Just add names of those elements into corresponding variables `"showWidgets"`, `"hideWidgets".
We are done! You can find more information about configurable UI elements in documentation section.
## Documentation
### Types
All fields have format `"key": value`
There are different basic types, which can be used as value.
#### Primitive types
Read JSON documentation for primitive types description: <https://www.json.org/json-en.html>
#### Text
Load predefined text which can be localised, examples:
`"vcmi.otherOptions.availableCreaturesAsDwellingLabel"`
`"core.genrltxt.738"`
#### Position
Point with two coordinates, example:
`{ "x": 43, "y": -28 }`
#### Rect
Rectangle ares, example:
`{ "x": 28, "y": 220, "w": 108, "h": 50 }`
#### Text alignment
Defines text alignment, can be one of values:
`"center"`, `"left"`, `"right"`
#### Color
Predefined colors:
`"yellow"`, `"white"`, `"gold"`, `"green"`, `"orange"`, `"bright-yellow"`
To have custom color make an array of four elements in RGBA notation:
`[255, 128, 0, 255]`
#### Font
Predefined fonts:
`"big"`, `"medium"`, `"small"`, `"tiny"`, `"calisto"`
#### Hint text
Hint text is a pair of strings, one is usually shown in status bar when cursor hovers element, another hint while right button pressed.
Each of elements is a [Text](#text)
```json
{
"hover": "Text",
"help": "Text
}
```
If one string specified, it will be applied for both hover and help.
`"text"`
#### Shortcut
String value defines shortcut. Some examples of shortcuts:
`"globalAccept", "globalCancel", "globalReturn","globalFullscreen", "globalOptions", "globalBackspace", "globalMoveFocus"`
Full list is TBD
#### [VCMI-1.4] Player color
One of predefined values:
`"red"`, `"blue"`, `"tan"`, `"green"`, `"orange"`, `"purple"`, `"teal"`, `"pink"`
### Configurable objects
Configurable object has following structure:
```json
{
"items": [],
"variables": {}, //optional
"customTypes": {}, //optional
"library": {} //optional
}
```
`items` - array of widgets to be created. Widgets are created in sequentially in same order as they described.
`variables` - variables, which can be used by object. Meaningful variable names are predefined for each object
`customTypes` - description of custom widgets, which can be used for this object, see [Custom widgets](#custom-widgets)
`library` - same as above, but custom widgets are described in separate json, this parameter should contain path to library json is specified
### Basic widgets
#### Label
`"type": "label"`
`"name": "string"` optional, object name
`"font"`: [font](#font)
`"alignment"`: [alignment](#text-alignment),
`"color"`: [color](#color),
`"text"`: [text](#text),
`"position"`: [position](#position),
`"maxWidth"`: int` optional, trim longer text
#### [VCMI-1.4] Multi-line label
`"type": "multiLineLabel"`
`"name": "string"` optional, object name
`"font"`: [font](#font)
`"alignment"`: [alignment](#text-alignment),
`"color"`: [color](#color),
`"text"`: [text](#text),
`"position"`: [position](#position)
`"rect"`: [rect](#rect) //text area
`"adoptHeight": bool` //if true, text area height will be adopted automatically based on content
#### Label group
`"type": "labelGroup"`
`"name": "string"` optional, object name
`"font"`: [font](#font)
`"alignment"`: [alignment](#text-alignment),
`"color"`: [color](#color),
`"items": []` array of elements
**Label group item**
`"position"`: [position](#position)
`"text"`: [text](#text),
#### TextBox
`"type": "textBox"`
`"name": "string"` optional, object name
`"font"`: [font](#font)
`"alignment"`: [alignment](#text-alignment),
`"color"`: [color](#color),
`"text"`: [text](#text),
`"rect"`: [rect](#rect)
#### Picture
`"type": "picture"`
`"name": "string"` optional, object name
`"position"`: [position](#position)
`"image": string`, specify filename
`"visible": bool`, optional
`"playerColored", bool`, optional, if true will be colorised to current player
#### Image
Use to show single frame from animation
`"type": "image"`
`"name": "string"` optional, object name
`"position"`: [position](#position)
`"image": string`, specify filename, animation only (def, json)
`"group": integer` optional, specify animation group
`"frame": integer` optional, specify animation frame
#### Texture
Filling area with texture
`"type": "texture"`
`"name": "string"` optional, object name
`"image": string`, specify filename
`"rect"`: [rect](#rect)
#### TransparentFilledRectangle
`"type": "transparentFilledRectangle"`
`"name": "string"` optional, object name
`"color"`: [color](#color) fill color of rectangle (supports transparency)
`"colorLine"`: [color](#color) optional, 1px border color
`"rect"`: [rect](#rect)
#### Animation
`"type": "animation"`
`"name": "string"` optional, object name
`"position"`: [position](#position)
`"image": string`, specify filename, animation only (def, json)
`"repeat": bool`, play only once or repeat animation
`"group": integer` optional, specify animation group
`"alpha": integer` optional, specify alpha opacity
`"callback": string` optional, callback to be called after animation complete
`"frames": []` optional, array of frame ranges to show
**Frame range**
`"start": integer`, first frame
`"end": integer`, last frame
#### [VCMI-1.4] Text input
`"type": "textInput"`
`"name": "string"` optional, object name
`"rect"`: [rect](#rect)
`"backgroundOffset": [position](#position)
`"background": string`, specify filename
`"font"`: [font](#font)
`"alignment"`: [alignment](#text-alignment),
`"color"`: [color](#color),
`"text": string` optional, default text. Translations are not supported
`"position"`: [position](#position)
`"help"`: [hint](#hint-text)
`"callback": string` optional, callback to be called on text changed. Input text is passed to callback function as an argument.
#### Button
`"type": "button"`
`"name": "string"` optional, object name
`"position"`: [position](#position)
`"image": string`, specify filename, animation only (def, json)
`"help"`: [hint](#hint-text)
`"imageOrder": []` array of 4 integers, each is responsible for frame to be shown in different states: normal, pressed, blocked and highlighted
`"borderColor"`: [color](#color), optional
`"hotkey"`: [shortcut](#shortcut), optional
`"callback": string` optional, callback to be called on press. No arguments are passed to callback function.
`"items": []` array of widgets to be shown as overlay (caption [label](#label), for example)
#### Toggle button
`"type": "toggleButton"`
`"name": "string"` optional, object name
`"position"`: [position](#position)
`"image": string`, specify filename, animation only (def, json)
`"help"`: [hint](#hint-text)
`"imageOrder": []` array of 4 integers, each is responsible for frame to be shown in different states: normal, pressed, blocked and highlighted
`"callback": string` optional, callback to be called on selection. Toggle identifier is passed to callback function as an argument.
`"selected": bool`, optional, is selected by default
`"items": []` array of widgets to be shown as overlay (caption [label](#label), for example)
#### Toggle group
Group of [toggle buttons](#toggle-button), when one is selected, other will be de-selected
`"type": "toggleGroup"`
`"name": "string"` optional, object name
`"position"`: [position](#position)
`"callback": string` optional, callback to be called when one of toggles is selected
`"items": []` array of [toggle buttons](#toggle-button)
#### Slider
`"type": "slider"`
`"name": "string"` optional, object name
`"position"`: [position](#position)
`"size": integer` size in pixels
`"style": string`, can be `"brown"` or `"blue"`
`"itemsVisible": integer`, how many items are visible
`"itemsTotal": integer`, how many items in total
`"selected": integer`, current state for slider
`"orientation" string`, can be `"horizontal"` or `"vertical"`
`"callback": string` callback to be called on state change. Slider position is passed to callback function as an argument.
`"scrollBounds":` [rect](#rect), optional
`"panningStep": integer`, optional
#### Combo box
`"type": "comboBox"`
`"name": "string"` optional, object name
`"position"`: [position](#position)
`"image": string`, specify filename, animation only (def, json)
`"help"`: [hint](#hint-text)
`"imageOrder": []` array of 4 integers, each is responsible for frame to be shown in different states: normal, pressed, blocked and highlighted
`"borderColor"`: [color](#color), optional
`"hotkey"`: [shortcut](#shortcut), optional
`"items": []` array of widgets to be shown as overlay, for example, [label](#label)
`"dropDown" : {}` description of [drop down](#drop-down) menu widget
#### Drop down
Used only as special object for [combo box](#combo-box)
`"items": []` array of widgets to be built. Usually contains background [picture](#picture), [slider](#slider) and item elements.
**Item elements**
`"type": "item"`
`"name": "string"` optional, object name
`"position"`: [position](#position)
`"items": []` array of overlay widgets with certain types and names:
- `"name": "hoverImage"`, `"type":` [picture](#picture) - image to be shown when cursor hovers elements
- `"name": "labelName"`, `"type":` [label](#label) - element caption
**Callbacks**
- `sliderMove` connect to slider callback to correctly navigate over elements
#### Layout
`"type": "layout"`
`"name": "string"` optional, object name
### High-level widgets
### Custom widgets
## For developers
While designing a new element, you can make it configurable to reuse all functionality described above. It will provide flexibility to further changes as well as modding capabilities.
Class should inherit `InterfaceObjectConfigurable`.
```cpp
#include "gui/InterfaceObjectConfigurable.h" //assuming we are in client folder
class MyYesNoDialog: public InterfaceObjectConfigurable
{
}
```
`InterfaceObjectConfigurable` doesn't have default constructor, but has possibility to specify arguments to be passed to `CIntObject`.
To make new object work, it's sufficient to define constructor, which receives const reference to `JsonNode`.
```cpp
MyYesNoDialog::MyYesNoDialog(const JsonNode & config):
InterfaceObjectConfigurable(), //you can pass arguments same as for CIntObject
{
//register custom builders
REGISTER_BUILDER("MyItem", &MyYesNoDialog::buildMyItem);
//add callbacks which can be used by widgets
addCallback("okPressed", std::bind(&MyYesNoDialog::onOk, this, std::placeholders::_1));
addCallback("cancelPressed", std::bind(&MyYesNoDialog::onCancel, this, std::placeholders::_1));
build(config); //after this point all widgets are built and accessible
//access widgets by name
if(auto w = widget<CButton>("cancel"))
{
//now you can do something with button
}
}
```
### Callbacks
### Custom widgets
You can build custom widgets, related to your UI element specifically. Like in example above, there is Item widget, which can be also used on JSON config.
```cpp
REGISTER_BUILDER("myItem", &MyYesNoDialog::buildMyItem);
```
You have to define function, which takes JsonNode as an argument and return pointer to built widget
```cpp
std::shared_ptr<MyYesNoDialog::Item> MyYesNoDialog::buildMyItem(const JsonNode & config)
{
auto position = readPosition(config["position"]);
return std::make_shared<MyYesNoDialog::Item>(*this, position); //define Item object as you want
}
```
After that, if your JSON file has items with type "MyItem", the new Item element will be constructed.
```json
{
"items":
[
{
"type": "myItem",
"position": {"x": 100, "y": 50}
}
]
}
```
### Variables
After calling `build(config)` variables defined in config JSON file become available. You can interpret them and use in callbacks or in element code
```cpp
build(config);
if(variables["colorfulText"].Bool())
{
if(auto w = widget<CLabel>("text"))
{
w->setColor(getMyPlayerColor()); //for reference only, getMyPlayerColor is not defined
}
}
```
|