Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- AnimalScreen
- AnimationElement
- BitmapElement
- BoxLayoutElement
- BreadcrumbsElement
- ButtonElement
- ButtonOverlay
- ChatWindow
- CheckedOptionElement
- ClearElement
- ColorPickButtonElement
- ConstructionScreen
- ContextActionDisplay
- ControlBarDisplay
- DialogElement
- DynamicFadedBitmapElement
- FillLevelsDisplay
- FlowLayoutElement
- FocusManager
- FrameElement
- FrameReferenceElement
- GameInfoDisplay
- GameInfoDisplayMobile
- GamePausedDisplay
- Gui
- GuiDataSource
- GuiElement
- GuiMixin
- GuiOverlay
- GuiProfile
- GuiSoundPlayer
- GuiTopDownCamera
- GuiTopDownCursor
- GuiUtils
- HUDDisplayElement
- HUDElement
- HUDFrameElement
- HUDPopupMessage
- HUDSliderElement
- HUDTextDisplay
- IndexChangeSubjectMixin
- IndexStateElement
- InfoDisplay
- InfoHUDBox
- InGameIcon
- IngameMap
- IngameMapElement
- InputGlyphElement
- InputGlyphElementUI
- InputHelpDisplay
- KeyValueInfoHUDBox
- ListElement
- ListItemElement
- MapOverlayGenerator
- MixerWagonHUDExtension
- MultiTextOptionElement
- MultiValueTween
- Overlay
- PagingElement
- PictureElement
- PlatformIconElement
- PlayerControlPadDisplay
- PlaySampleMixin
- RenderElement
- RoundStatusBar
- ScreenElement
- ScrollingLayoutElement
- SettingsModel
- SideNotification
- SideNotificationMobile
- SliderElement
- SpeakerDisplay
- SpeedMeterDisplay
- SpeedSliderDisplay
- StatusBar
- SteeringSliderDisplay
- TabbedMenu
- TabbedMenuFrameElement
- TabbedMenuWithDetails
- TableElement
- TableHeaderElement
- TerrainLayerElement
- TextBackdropElement
- TextElement
- TextInputElement
- ThreePartBitmapElement
- TimerElement
- ToggleButtonElement
- TopNotification
- Tween
- TweenSequence
- VariableWorkWidthHUDExten...
- VehicleHUDExtension
- VehicleSchemaDisplay
- VideoElement
- WardrobeScreen
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- Parameters
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- StateMachine
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
GuiDataSource
DescriptionData source for UI elements. Holds dynamic data and allows configuration of accessors.Functions
addChangeListener
DescriptionAdd a listener with a member function which is called when this data source changes.Definition
addChangeListener()Code
37 | function GuiDataSource:addChangeListener(target, callback) |
38 | self.changeListeners[target] = callback or NO_CALLBACK |
39 | end |
getCount
DescriptionGet the number of data items.Definition
getCount()Code
58 | function GuiDataSource:getCount() |
59 | return #self.data |
60 | end |
getItem
DescriptionGet a data item at a given index.Definition
getItem()Code
64 | function GuiDataSource:getItem(index) |
65 | return self.data[index] |
66 | end |
iterateRange
DescriptionIterate a data range within the given indices. This is an iterator factory compatible with the default Lua for loop. E.g. "for _, item in source:iterateRange(1, 10) do" will loop over data items 1 to 10.Definition
iterateRange()Code
84 | function GuiDataSource:iterateRange(startIndex, endIndex) |
85 | local iterator = function(data, iter) |
86 | local item = data[iter] |
87 | if iter <= endIndex and item ~= nil then |
88 | return iter + 1, item |
89 | else |
90 | return nil, nil |
91 | end |
92 | end |
93 | |
94 | return iterator, self.data, startIndex |
95 | end |
new
DescriptionCreate a new GuiDataSource instance.Definition
new()Code
19 | function GuiDataSource.new(subclass_mt) |
20 | local self = setmetatable({}, subclass_mt or GuiDataSource_mt) |
21 | |
22 | self.data = NO_DATA |
23 | self.changeListeners = {} -- {<listener table> = <listener function>} |
24 | |
25 | return self |
26 | end |
notifyChange
DescriptionNotify this data source that its data has been changed externally. This will call the change callback if it has been set.Definition
notifyChange()Code
50 | function GuiDataSource:notifyChange() |
51 | for target, callback in pairs(self.changeListeners) do |
52 | callback(target) |
53 | end |
54 | end |
removeChangeListener
DescriptionRemove a previously added change listener from the notification table.Definition
removeChangeListener()Code
43 | function GuiDataSource:removeChangeListener(target) |
44 | self.changeListeners[target] = nil |
45 | end |
setData
DescriptionSet the data source data array.Definition
setData()Code
30 | function GuiDataSource:setData(data) |
31 | self.data = data or NO_DATA |
32 | self:notifyChange() |
33 | end |
setItem
DescriptionSet a data item at a given index. If the index is out bounds of the data, this will have no effect.Definition
setItem()Code
71 | function GuiDataSource:setItem(index, value, needsNotification) |
72 | if index > 0 and index <= #self.data then |
73 | self.data[index] = value |
74 | if needsNotification then |
75 | self:notifyChange() |
76 | end |
77 | end |
78 | end |