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
ScrollingLayoutElement
DescriptionBox layout that supports smooth scrollingParent
BoxLayoutElementFunctions
- addElement
- copyAttributes
- invalidateLayout
- loadFromXML
- new
- onGuiSetupFinished
- onSliderValueChanged
- onVerticalCursorInput
- raiseSliderUpdateEvent
- removeActionEvents
- removeElement
- scrollTo
addElement
DescriptionUpdate content size when an element is addedDefinition
addElement()Code
177 | function ScrollingLayoutElement:addElement(element) |
178 | ScrollingLayoutElement:superClass().addElement(self, element) |
179 | |
180 | if self.autoValidateLayout then |
181 | self:invalidateLayout() |
182 | end |
183 | end |
copyAttributes
DescriptionDefinitioncopyAttributes()Code
43 | function ScrollingLayoutElement:copyAttributes(src) |
44 | ScrollingLayoutElement:superClass().copyAttributes(self, src) |
45 | |
46 | self.topClipperElementName = src.topClipperElementName |
47 | self.bottomClipperElementName = src.bottomClipperElementName |
48 | end |
invalidateLayout
DescriptionRebuild the layout. Adjusts start Y with our visible YDefinition
invalidateLayout()Code
69 | function ScrollingLayoutElement:invalidateLayout(ignoreVisibility) |
70 | local cells = self:getLayoutCells(ignoreVisibility) |
71 | |
72 | local lateralFlowSizes, totalLateralSize, flowSize = self:getLayoutSizes(cells) |
73 | local offsetStartX, offsetStartY, xDir, yDir = self:getAlignmentOffset(flowSize, totalLateralSize) |
74 | |
75 | offsetStartY = offsetStartY + self.firstVisibleY |
76 | |
77 | self:applyCellPositions(cells, offsetStartX, offsetStartY, xDir, yDir, lateralFlowSizes) |
78 | |
79 | if self.handleFocus and self.focusDirection ~= BoxLayoutElement.FLOW_NONE then |
80 | self:focusLinkCells(cells) |
81 | end |
82 | |
83 | self:updateContentSize() |
84 | self:updateScrollClippers() |
85 | |
86 | for _, e in pairs(self.elements) do |
87 | self:addFocusListener(e) |
88 | end |
89 | |
90 | return flowSize |
91 | end |
loadFromXML
DescriptionDefinitionloadFromXML()Code
34 | function ScrollingLayoutElement:loadFromXML(xmlFile, key) |
35 | ScrollingLayoutElement:superClass().loadFromXML(self, xmlFile, key) |
36 | |
37 | self.topClipperElementName = getXMLString(xmlFile, key.."#topClipperElementName") |
38 | self.bottomClipperElementName = getXMLString(xmlFile, key.."#bottomClipperElementName") |
39 | end |
new
DescriptionDefinitionnew()Code
15 | function ScrollingLayoutElement.new(target, custom_mt) |
16 | local self = BoxLayoutElement.new(target, custom_mt or ScrollingLayoutElement_mt) |
17 | |
18 | self.alignmentX = BoxLayoutElement.ALIGN_LEFT |
19 | self.alignmentY = BoxLayoutElement.ALIGN_TOP |
20 | self.clipping = true |
21 | self.wrapAround = true -- needed for focus handling when scrolling |
22 | |
23 | self.sliderElement = nil -- sliders register themselves with lists in this field if they point at them via configuration |
24 | |
25 | self.firstVisibleY = 0 |
26 | self.targetFirstVisibleY = 0 |
27 | self.contentSize = 1 -- height only for now |
28 | |
29 | return self |
30 | end |
onGuiSetupFinished
DescriptionDefinitiononGuiSetupFinished()Code
52 | function ScrollingLayoutElement:onGuiSetupFinished() |
53 | ScrollingLayoutElement:superClass().onGuiSetupFinished(self) |
54 | |
55 | if self.topClipperElementName ~= nil then |
56 | self.topClipperElement = self.parent:getDescendantByName(self.topClipperElementName) |
57 | end |
58 | if self.bottomClipperElementName ~= nil then |
59 | self.bottomClipperElement = self.parent:getDescendantByName(self.bottomClipperElementName) |
60 | end |
61 | |
62 | for _, e in pairs(self.elements) do |
63 | self:addFocusListener(e) |
64 | end |
65 | end |
onSliderValueChanged
DescriptionDefinitiononSliderValueChanged()Code
107 | function ScrollingLayoutElement:onSliderValueChanged(slider, newValue) |
108 | local newStartY = 0 |
109 | if slider.minValue ~= slider.maxValue then |
110 | newStartY = ((self.contentSize - self.absSize[2]) / (slider.maxValue - slider.minValue)) * (newValue - slider.minValue) |
111 | end |
112 | |
113 | self:scrollTo(newStartY, false) |
114 | end |
onVerticalCursorInput
DescriptionEvent function for vertical cursor input bound to InputAction.MENU_AXIS_UP_DOWN_SECONDARY.Definition
onVerticalCursorInput()Code
288 | function ScrollingLayoutElement:onVerticalCursorInput(_, inputValue) |
289 | if not self.useMouse then |
290 | self.sliderElement:setValue(self.sliderElement.currentValue + self.sliderElement.stepSize * inputValue) |
291 | end |
292 | self.useMouse = false |
293 | end |
raiseSliderUpdateEvent
DescriptionDefinitionraiseSliderUpdateEvent()Code
169 | function ScrollingLayoutElement:raiseSliderUpdateEvent() |
170 | if self.sliderElement ~= nil then |
171 | self.sliderElement:onBindUpdate(self) |
172 | end |
173 | end |
removeActionEvents
DescriptionRemove non-GUI input action events.Definition
removeActionEvents()Code
282 | function ScrollingLayoutElement:removeActionEvents() |
283 | g_inputBinding:removeActionEventsByTarget(self) |
284 | end |
removeElement
DescriptionUpdate content size when an element is removedDefinition
removeElement()Code
200 | function ScrollingLayoutElement:removeElement(element) |
201 | ScrollingLayoutElement:superClass().removeElement(self, element) |
202 | |
203 | if element.scrollingFocusEnter_orig == nil then |
204 | element.onFocusEnter = element.scrollingFocusEnter_orig |
205 | end |
206 | |
207 | if self.autoValidateLayout then |
208 | self:invalidateLayout() |
209 | end |
210 | end |
scrollTo
DescriptionScroll to an Y position within the contentDefinition
scrollTo()Code
118 | function ScrollingLayoutElement:scrollTo(startY, updateSlider, noUpdateTarget) |
119 | self.firstVisibleY = startY |
120 | |
121 | if not noUpdateTarget then |
122 | self.targetFirstVisibleY = startY |
123 | self.isMovingToTarget = false |
124 | end |
125 | |
126 | self:invalidateLayout() |
127 | |
128 | -- update scrolling |
129 | if updateSlider == nil or updateSlider then |
130 | if self.sliderElement ~= nil then |
131 | local newValue = startY / ((self.contentSize - self.absSize[2]) / self.sliderElement.maxValue) |
132 | self.sliderElement:setValue(newValue, true) |
133 | end |
134 | end |
135 | |
136 | self:raiseCallback("onScrollCallback") |
137 | end |