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
TableHeaderElement
DescriptionTable header element to use within tables. Children which serve as sorting icons are to be marked in the screen XML configuration by setting the name attribute to "iconAscending" or "iconDescending" depending on which sorting state they are intended to represent. Headers must be defined outside of tables, because anything within a table is considered a table item.Parent
ButtonElementXML Configuration Parameters
GuiElement#targetTableId | string Configured ID of the decorated table |
GuiElement#columnName | string Name of the table column which will be sorted when this header is activated |
GuiElement#allowSortingAsc | bool [optional, default=false] If set to true, allows sorting the associated table column in ascending order. |
GuiElement#allowSortingDesc | bool [optional, default=false] If set to true, allows sorting the associated table column in descending order. |
Functions
addElement
DescriptionAdd a child element to this GUI element. This element searches for marked children to use as sorting icons.Definition
addElement(element Element)Arguments
element | Element | to add. |
100 | function TableHeaderElement:addElement(element) |
101 | TableHeaderElement:superClass().addElement(self, element) |
102 | |
103 | -- find header icons by configuration attribute |
104 | if element.name == TableHeaderElement.NAME_ASC_ICON then |
105 | self.sortingIcons[TableHeaderElement.SORTING_ASC] = element |
106 | end |
107 | if element.name == TableHeaderElement.NAME_DESC_ICON then |
108 | self.sortingIcons[TableHeaderElement.SORTING_DESC] = element |
109 | end |
110 | end |
copyAttributes
DescriptionDefinitioncopyAttributes()Code
88 | function TableHeaderElement:copyAttributes(src) |
89 | TableHeaderElement:superClass().copyAttributes(self, src) |
90 | |
91 | self.targetTableId = src.targetTableId |
92 | self.columnName = src.columnName |
93 | self.allowedSortingStates = {unpack(src.allowedSortingStates)} |
94 | end |
disableSorting
DescriptionDisable sorting on this header by setting its sorting state to OFF.Definition
disableSorting()Code
132 | function TableHeaderElement:disableSorting() |
133 | self.sortingOrder = TableHeaderElement.SORTING_OFF |
134 | self:updateSortingDisplay() |
135 | end |
loadFromXML
DescriptionDefinitionloadFromXML()Code
64 | function TableHeaderElement:loadFromXML(xmlFile, key) |
65 | TableHeaderElement:superClass().loadFromXML(self, xmlFile, key) |
66 | |
67 | self.targetTableId = Utils.getNoNil(getXMLString(xmlFile, key.."#targetTableId"), self.targetTableId) |
68 | self.columnName = Utils.getNoNil(getXMLString(xmlFile, key.."#columnName"), self.columnName) |
69 | |
70 | local allowAscendingSort = Utils.getNoNil(getXMLBool(xmlFile, key.."#allowSortingAsc"), self.allowedSortingStates[TableHeaderElement.SORTING_ASC]) |
71 | local allowDescendingSort = Utils.getNoNil(getXMLBool(xmlFile, key.."#allowSortingDesc"), self.allowedSortingStates[TableHeaderElement.SORTING_DESC]) |
72 | self.allowedSortingStates[TableHeaderElement.SORTING_ASC] = allowAscendingSort |
73 | self.allowedSortingStates[TableHeaderElement.SORTING_DESC] = allowDescendingSort |
74 | end |
loadProfile
DescriptionDefinitionloadProfile()Code
78 | function TableHeaderElement:loadProfile(profile, applyProfile) |
79 | TableHeaderElement:superClass().loadProfile(self, profile, applyProfile) |
80 | |
81 | self.columnName = profile:getValue("columnName", self.columnName) |
82 | self.allowedSortingStates[TableHeaderElement.SORTING_ASC] = profile:getBool("allowSortingAsc", self.allowedSortingStates[TableHeaderElement.SORTING_ASC]) |
83 | self.allowedSortingStates[TableHeaderElement.SORTING_DESC] = profile:getBool("allowSortingDesc", self.allowedSortingStates[TableHeaderElement.SORTING_DESC]) |
84 | end |
new
DescriptionDefinitionnew()Code
40 | function TableHeaderElement.new(target, custom_mt) |
41 | local self = ButtonElement.new(target, custom_mt or TableHeaderElement_mt) |
42 | |
43 | self.allowedSortingStates = { |
44 | [TableHeaderElement.SORTING_OFF] = true, -- no reason to ever change this, only here for processing |
45 | [TableHeaderElement.SORTING_ASC] = false, |
46 | [TableHeaderElement.SORTING_DESC] = false, |
47 | } |
48 | self.sortingOrder = TableHeaderElement.SORTING_OFF -- state index in allowed sorting states |
49 | |
50 | self.sortingIcons = { |
51 | [TableHeaderElement.SORTING_OFF] = nil, -- off state icon element |
52 | [TableHeaderElement.SORTING_ASC] = nil, -- ascending sort state icon element |
53 | [TableHeaderElement.SORTING_DESC] = nil -- descending sort state icon element |
54 | } |
55 | |
56 | self.targetTableId = "" -- ID of decorated table |
57 | self.columnName = "" -- name of table column to sort |
58 | |
59 | return self |
60 | end |
toggleSorting
DescriptionToggle this header's sorting display state, if allowed.Definition
toggleSorting()Return Values
The | new | sorting order |
115 | function TableHeaderElement:toggleSorting() |
116 | -- cycle to the next allowed sorting state (will stop at off setting at the latest): |
117 | local prevOrderIndex = self.sortingOrder |
118 | |
119 | repeat |
120 | self.sortingOrder = ((self.sortingOrder) % #self.allowedSortingStates) + 1 |
121 | until self.allowedSortingStates[self.sortingOrder] |
122 | |
123 | if not (prevOrderIndex == self.sortingOrder) then |
124 | self:updateSortingDisplay() |
125 | end |
126 | |
127 | return self.sortingOrder |
128 | end |
updateSortingDisplay
DescriptionUpdate the header's display with its new state.Definition
updateSortingDisplay()Code
139 | function TableHeaderElement:updateSortingDisplay() |
140 | -- enable current state, disable others |
141 | for sortOrderIndex, icon in pairs(self.sortingIcons) do |
142 | if sortOrderIndex == self.sortingOrder then |
143 | icon:setVisible(true) |
144 | else |
145 | icon:setVisible(false) |
146 | end |
147 | end |
148 | end |