LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

ScreenElement

Description
Base 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
FrameElement
Functions

canReceiveFocus

Description
Definition
canReceiveFocus()
Code
254function 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
267end

getIsOpen

Description
Definition
getIsOpen()
Code
248function ScreenElement:getIsOpen()
249 return self.isOpen
250end

initializeScreen

Description
Definition
initializeScreen()
Code
65function 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
72end

inputEvent

Description
Definition
inputEvent()
Code
196function 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
220end

invalidateScreen

Description
Definition
invalidateScreen()
Code
171function ScreenElement:invalidateScreen()
172end

new

Description
Definition
new()
Code
24function 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
40end

onClose

Description
Definition
onClose()
Code
76function 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
90end

onOpen

Description
Definition
onOpen()
Code
44function 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
61end

setNextScreenClickSoundMuted

Description
Mute the next click sound. Used to override click sounds for the activate/cancel actions
Definition
setNextScreenClickSoundMuted()
Code
271function ScreenElement:setNextScreenClickSoundMuted(value)
272 if value == nil then
273 value = true
274 end
275 self.nextClickSoundMuted = value
276end

setReturnScreen

Description
Definition
setReturnScreen()
Code
235function ScreenElement:setReturnScreen(screenName, screen)
236 self.returnScreenName = screenName
237 self.returnScreen = screen
238end

setReturnScreenClass

Description
Set the class of the return screen which should be opened when the "back" action is triggered on this screen.
Definition
setReturnScreenClass()
Code
242function ScreenElement:setReturnScreenClass(returnScreenClass)
243 self.returnScreenClass = returnScreenClass
244end