A Gui element forhandling number in the Gui for FS 19. The element can count a number up and down with arrow keys.
Simple place the NumberUpDownElement.lua anywhere in the your project. And make sure the file is loaded either in the modDesc.xml:
<extraSourceFiles>
<sourceFile filename="NumberUpDownElement.lua"/>
</extraSourceFiles>
or in loader file:
source(Utils.getFilename("NumberUpDownElement.lua", directory))
The element is used the same way as multiTextOption with min 3 child elements.
- Button for counting down
- Button for counting up
- Text element for displaying value.
- [option] Text element for title
- [option] bitmap for background example:
<GuiElement type="numberUpDown" profile="multiTextOptionSettings" id="elementId">
<GuiElement type="button" profile="multiTextOptionLeft"/>
<GuiElement type="button" profile="multiTextOptionRight"/>
<GuiElement type="text" profile="multiTextOptionText"/>
<GuiElement type="text" profile="multiTextOptionSettingsTitle" text="Title"/>
<GuiElement type="bitmap" profile="multiTextOptionBg"/>
</GuiElement>
following xml attributes is possible to use:
| Attribute | Describtion |
|---|---|
| increment | The value which the number is changed with for every click. |
| min | The minimum value the number can be counted down to. |
| max | The maximum value the number can be counted up to. |
Following function is available
| Function | Describtion |
|---|---|
| NumberUpDownElement:getValue() | Get the current value |
| NumberUpDownElement:setValue(value) | Set a new current value |
| NumberUpDownElement:getIncrement() | Get current increment value |
| NumberUpDownElement:setIncrement(increment) | Set a new increment value |
| NumberUpDownElement:getMin() | Get current minimum value |
| NumberUpDownElement:setMin(minValue) | Set a new minimum value |
| NumberUpDownElement:getMax() | Get current maximum value |
| NumberUpDownElement:setMax(maxValue) | Set a new maximum value |