Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- 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
ScreenElement
DescriptionBase screen element. All full-screen GUI views inherit from this. ScreenElement inherits from FrameElement and has no additional configuration, but contains UI logic shared across all full screen views.Parent
FrameElementFunctions
- canReceiveFocus
- getIsOpen
- initializeScreen
- inputEvent
- invalidateScreen
- new
- onClose
- onOpen
- setNextScreenClickSoundMuted
- setReturnScreen
- setReturnScreenClass
canReceiveFocus
DescriptionDefinitioncanReceiveFocus()Code
254 | function ScreenElement:canReceiveFocus() |
255 | if not self.visible then |
256 | return false |
257 | end |
258 | |
259 | -- element can only receive focus if all sub elements are ready to receive focus |
260 | for i = 1, #self.elements do |
261 | if not self.elements[i]:canReceiveFocus() then |
262 | return false |
263 | end |
264 | end |
265 | |
266 | return true |
267 | end |
getIsOpen
DescriptionDefinitiongetIsOpen()Code
248 | function ScreenElement:getIsOpen() |
249 | return self.isOpen |
250 | end |
initializeScreen
DescriptionDefinitioninitializeScreen()Code
65 | function ScreenElement:initializeScreen() |
66 | self.isInitialized = true |
67 | |
68 | if self.pageSelector ~= nil and self.pageSelector.disableButtonSounds ~= nil then |
69 | -- disable click sounds for page selector buttons, we use the paging sound in separate screen logic |
70 | self.pageSelector:disableButtonSounds() |
71 | end |
72 | end |
inputEvent
DescriptionDefinitioninputEvent()Code
196 | function ScreenElement:inputEvent(action, value, eventUsed) |
197 | eventUsed = ScreenElement:superClass().inputEvent(self, action, value, eventUsed) |
198 | |
199 | if self.inputDisableTime <= 0 then |
200 | -- handle special case for screen paging controls: |
201 | if self.pageSelector ~= nil and (action == InputAction.MENU_PAGE_PREV or action == InputAction.MENU_PAGE_NEXT) then |
202 | if action == InputAction.MENU_PAGE_PREV then |
203 | self:onPagePrevious() |
204 | elseif action == InputAction.MENU_PAGE_NEXT then |
205 | self:onPageNext() |
206 | end |
207 | -- always consume event to avoid triggering any other focused elements |
208 | eventUsed = true |
209 | end |
210 | |
211 | if not eventUsed then |
212 | -- Directly access screen element subclass events by button presses. The abstract implementation of these |
213 | -- methods in this class return true, so that we can evaluate if there is no concrete implementation. In |
214 | -- that case, the event must not be consumed. |
215 | eventUsed = ScreenElement.callButtonsWithAction(self.elements, action) |
216 | end |
217 | end |
218 | |
219 | return eventUsed |
220 | end |
invalidateScreen
DescriptionDefinitioninvalidateScreen()Code
171 | function ScreenElement:invalidateScreen() |
172 | end |
new
DescriptionDefinitionnew()Code
24 | function ScreenElement.new(target, custom_mt) |
25 | local self = FrameElement.new(target, custom_mt or ScreenElement_mt) |
26 | |
27 | self.isBackAllowed = true |
28 | self.handleCursorVisibility = true |
29 | self.returnScreenName = nil |
30 | self.returnScreen = nil |
31 | self.returnScreenClass = nil |
32 | self.isOpen = false |
33 | self.lastMouseCursorState = false |
34 | self.isInitialized = false |
35 | self.nextClickSoundMuted = false |
36 | |
37 | self:registerControls(ScreenElement.CONTROLS) |
38 | |
39 | return self |
40 | end |
onClose
DescriptionDefinitiononClose()Code
76 | function ScreenElement:onClose() |
77 | -- Break inheritance here to avoid callback loops |
78 | local rootElement = self:getRootElement() |
79 | -- we need to run onClose() only on children of the screen root element because the root usually has the main |
80 | -- callbacks on itself |
81 | for _, child in ipairs(rootElement.elements) do |
82 | child:onClose() |
83 | end |
84 | |
85 | if self.handleCursorVisibility then |
86 | g_inputBinding:setShowMouseCursor(self.lastMouseCursorState) |
87 | end |
88 | |
89 | self.isOpen = false |
90 | end |
onOpen
DescriptionDefinitiononOpen()Code
44 | function ScreenElement:onOpen() |
45 | -- Break inheritance here to avoid callback loops |
46 | local rootElement = self:getRootElement() |
47 | -- we need to run onOpen() only on children of the screen root element because the root usually has the main |
48 | -- callbacks on itself |
49 | for _, child in ipairs(rootElement.elements) do |
50 | child:onOpen() |
51 | end |
52 | |
53 | if not self.isInitialized then |
54 | self:initializeScreen() |
55 | end |
56 | |
57 | self.lastMouseCursorState = g_inputBinding:getShowMouseCursor() |
58 | g_inputBinding:setShowMouseCursor(true) |
59 | |
60 | self.isOpen = true |
61 | end |
setNextScreenClickSoundMuted
DescriptionMute the next click sound. Used to override click sounds for the activate/cancel actionsDefinition
setNextScreenClickSoundMuted()Code
271 | function ScreenElement:setNextScreenClickSoundMuted(value) |
272 | if value == nil then |
273 | value = true |
274 | end |
275 | self.nextClickSoundMuted = value |
276 | end |
setReturnScreen
DescriptionDefinitionsetReturnScreen()Code
235 | function ScreenElement:setReturnScreen(screenName, screen) |
236 | self.returnScreenName = screenName |
237 | self.returnScreen = screen |
238 | end |
setReturnScreenClass
DescriptionSet the class of the return screen which should be opened when the "back" action is triggered on this screen.Definition
setReturnScreenClass()Code
242 | function ScreenElement:setReturnScreenClass(returnScreenClass) |
243 | self.returnScreenClass = returnScreenClass |
244 | end |