Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- Player
- Shop
- Sounds
- Specializations
- Triggers
- Utils
- Vehicles
- Weather
Engine v1.7.1.0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- Overlays
- Particle System
- Physics
- JointConstructor:setActors
- JointConstructor:setJointTransforms
- addDifferential
- addForce
- addImpulse
- addTorque
- addTorqueImpulse
- addVehicleLink
- computeWheelShapeTireForces
- createCCT
- createWheelShape
- getAngularDamping
- getAngularVelocity
- getCCTCollisionFlags
- getCenterOfMass
- getCollisionMask
- getDensity
- getLinearDamping
- getLinearVelocity
- getMass
- getMotorRotationSpeed
- getRigidBodyType
- getVelocityAtLocalPos
- getVelocityAtWorldPos
- getVolume
- getWheelShapeAxleSpeed
- getWheelShapeContactForce
- getWheelShapeContactNormal
- getWheelShapeContactObject
- getWheelShapeContactPoint
- getWheelShapePosition
- getWheelShapeSlip
- moveCCT
- overlapBox
- overlapSphere
- raycastAll
- raycastClosest
- removeCCT
- setAngularDamping
- setAngularVelocity
- setCenterOfMass
- setCollisionMask
- setFrictionVelocity
- setJointDrive
- setLinearDamping
- setLinearVelocity
- setMass
- setRigidBodyType
- setSolverIterationCount
- setWheelShapeForcePoint
- setWheelShapeProps
- setWheelShapeTireFriction
- simulatePhysics
- simulatePhysicsTimeScale
- updateDifferential
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- XML
- general
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
252 | function ScreenElement:canReceiveFocus() |
253 | if not self.visible then |
254 | return false |
255 | end |
256 | -- element can only receive focus if all sub elements are ready to receive focus |
257 | for _, v in ipairs(self.elements) do |
258 | if (not v:canReceiveFocus()) then |
259 | return false |
260 | end |
261 | end |
262 | return true |
263 | end |
getIsOpen
DescriptionDefinitiongetIsOpen()Code
246 | function ScreenElement:getIsOpen() |
247 | return self.isOpen |
248 | 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
171 | function ScreenElement:inputEvent(action, value, eventUsed) |
172 | eventUsed = ScreenElement:superClass().inputEvent(self, action, value, eventUsed) |
173 | if self.inputDisableTime <= 0 then |
174 | -- handle special case for screen paging controls: |
175 | if self.pageSelector ~= nil and (action == InputAction.MENU_PAGE_PREV or action == InputAction.MENU_PAGE_NEXT) then |
176 | if action == InputAction.MENU_PAGE_PREV then |
177 | self:onPagePrevious() |
178 | elseif action == InputAction.MENU_PAGE_NEXT then |
179 | self:onPageNext() |
180 | end |
181 | -- always consume event to avoid triggering any other focused elements |
182 | eventUsed = true |
183 | end |
184 | |
185 | if not eventUsed then |
186 | local sampleToPlay = nil |
187 | |
188 | -- Directly access screen element subclass events by button presses. The abstract implementation of these |
189 | -- methods in this class return true, so that we can evaluate if there is no concrete implementation. In |
190 | -- that case, the event must not be consumed. |
191 | |
192 | if action == InputAction.MENU then |
193 | eventUsed = not self:onClickMenu() |
194 | sampleToPlay = GuiSoundPlayer.SOUND_SAMPLES.BACK -- in the menu, toggling menu means exiting, hence BACK |
195 | elseif action == InputAction.TOGGLE_STORE then |
196 | eventUsed = not self:onClickShop() |
197 | sampleToPlay = GuiSoundPlayer.SOUND_SAMPLES.BACK |
198 | elseif action == InputAction.MENU_ACTIVATE then |
199 | eventUsed = not self:onClickActivate() |
200 | sampleToPlay = GuiSoundPlayer.SOUND_SAMPLES.CLICK |
201 | elseif action == InputAction.MENU_CANCEL then |
202 | eventUsed = not self:onClickCancel() |
203 | sampleToPlay = GuiSoundPlayer.SOUND_SAMPLES.CLICK |
204 | elseif action == InputAction.MENU_ACCEPT then |
205 | eventUsed = not self:onClickOk() |
206 | sampleToPlay = GuiSoundPlayer.SOUND_SAMPLES.CLICK |
207 | elseif action == InputAction.MENU_BACK then |
208 | eventUsed = not self:onClickBack(false, false) |
209 | sampleToPlay = GuiSoundPlayer.SOUND_SAMPLES.BACK |
210 | elseif action == InputAction.MENU_EXTRA_1 then |
211 | eventUsed = not self:onClickMenuExtra1() |
212 | sampleToPlay = GuiSoundPlayer.SOUND_SAMPLES.CLICK |
213 | elseif action == InputAction.MENU_EXTRA_2 then |
214 | eventUsed = not self:onClickMenuExtra2() |
215 | sampleToPlay = GuiSoundPlayer.SOUND_SAMPLES.CLICK |
216 | end |
217 | |
218 | if eventUsed and sampleToPlay ~= nil then |
219 | if not self.nextClickSoundMuted then |
220 | self:playSample(sampleToPlay) |
221 | end |
222 | end |
223 | |
224 | self.nextClickSoundMuted = false |
225 | end |
226 | end |
227 | |
228 | return eventUsed |
229 | end |
invalidateScreen
DescriptionDefinitioninvalidateScreen()Code
166 | function ScreenElement:invalidateScreen() |
167 | 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
267 | function ScreenElement:setNextScreenClickSoundMuted(value) |
268 | if value == nil then |
269 | value = true |
270 | end |
271 | self.nextClickSoundMuted = value |
272 | end |
setReturnScreen
DescriptionDefinitionsetReturnScreen()Code
233 | function ScreenElement:setReturnScreen(screenName, screen) |
234 | self.returnScreenName = screenName |
235 | self.returnScreen = screen |
236 | 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
240 | function ScreenElement:setReturnScreenClass(returnScreenClass) |
241 | self.returnScreenClass = returnScreenClass |
242 | end |