LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

DialogElement

Description
Base element for modal dialogs. Dialogs are a specialization of ScreenElement, but work mostly the same in terms of loading and configuration. Much like screens, dialogs are controlled and configured by correspondingly named [dialogName]Dialog.lua and [dialogName]Dialog.xml files.
Parent
ScreenElement
Functions

close

Description
Definition
close()
Code
67function DialogElement:close()
68 g_gui:closeDialogByName(self.name)
69end

new

Description
Definition
new()
Code
55function DialogElement.new(target, custom_mt)
56 local self = ScreenElement.new(target, custom_mt or DialogElement_mt)
57
58 self.isCloseAllowed = true
59
60 self:registerControls(DialogElement.CONTROLS)
61
62 return self
63end

onClickBack

Description
Definition
onClickBack()
Code
73function DialogElement:onClickBack(forceBack, usedMenuButton)
74 if (self.isCloseAllowed or forceBack) and not usedMenuButton then
75 self:close()
76 return false -- event used
77 else
78 return true -- event unused
79 end
80end

setDialogType

Description
Definition
setDialogType()
Code
84function DialogElement:setDialogType(dialogType)
85 dialogType = Utils.getNoNil(dialogType, DialogElement.TYPE_WARNING)
86 self.dialogType = dialogType
87
88 -- apply element visibility based on dialog type
89 for dt, id in pairs(TYPE_ICON_ID_MAPPING) do
90 local typeElement = self[id]
91 if typeElement then
92 typeElement:setVisible(dt == dialogType)
93 end
94 end
95
96 if self.dialogCircle ~= nil then
97 self.dialogCircle:setVisible(dialogType ~= DialogElement.TYPE_LOADING)
98 end
99end

setIsCloseAllowed

Description
Definition
setIsCloseAllowed()
Code
103function DialogElement:setIsCloseAllowed(isAllowed)
104 self.isCloseAllowed = isAllowed
105end