LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

InputGlyphElementUI

Parent
GuiElement
Functions

copyAttributes

Description
Definition
copyAttributes()
Code
57function InputGlyphElementUI:copyAttributes(src)
58 InputGlyphElementUI:superClass().copyAttributes(self, src)
59
60 self.color = table.copy(src.color)
61
62 if src.glyphElement ~= nil then
63 local actionNames = src.glyphElement.actionNames
64 local actionText = src.glyphElement.actionText
65 local actionTextSize = src.glyphElement.actionTextSize
66
67 self:rebuildGlyph()
68 self:setActions(actionNames, actionText, actionTextSize)
69 end
70end

delete

Description
Definition
delete()
Code
26function InputGlyphElementUI:delete()
27 if self.glyphElement ~= nil then
28 self.glyphElement:delete()
29 self.glyphElement = nil
30 end
31
32 InputGlyphElementUI:superClass().delete(self)
33end

draw

Description
Draw the glyph
Definition
draw()
Code
95function InputGlyphElementUI:draw(clipX1, clipY1, clipX2, clipY2)
96 InputGlyphElementUI:superClass().draw(self, clipX1, clipY1, clipX2, clipY2)
97
98 if self.glyphElement ~= nil then
99 self.glyphElement:draw(clipX1, clipY1, clipX2, clipY2)
100 end
101end

loadFromXML

Description
Definition
loadFromXML()
Code
37function InputGlyphElementUI:loadFromXML(xmlFile, key)
38 InputGlyphElementUI:superClass().loadFromXML(self, xmlFile, key)
39
40 self.color = GuiUtils.getColorArray(getXMLString(xmlFile, key.."#glyphColor"), self.color)
41
42 self:rebuildGlyph()
43end

loadProfile

Description
Definition
loadProfile()
Code
47function InputGlyphElementUI:loadProfile(profile, applyProfile)
48 InputGlyphElementUI:superClass().loadProfile(self, profile, applyProfile)
49
50 self.color = GuiUtils.getColorArray(profile:getValue("glyphColor"), self.color)
51
52 self:rebuildGlyph()
53end

new

Description
Definition
new()
Code
16function InputGlyphElementUI.new(target, custom_mt)
17 local self = GuiElement.new(target, custom_mt or InputGlyphElementUI_mt)
18
19 self.color = {1, 1, 1, 1}
20
21 return self
22end

setActions

Description
Set glyph actions
Definition
setActions()
Code
105function InputGlyphElementUI:setActions(actions, ...)
106 if self.glyphElement ~= nil then
107 self.glyphElement:setActions(actions, ...)
108
109 -- The size could have changed
110 if not self.didSetAbsolutePosition then
111 self:updateAbsolutePosition()
112 end
113
114 -- A bit of a nasty thing: base size is based on original width and height of the element,
115 -- but we change the width based on the content. We still need the original width in case position changes.
116 if self.absSize[1] > 0 then
117 self.originalWidth = self.originalWidth or self.absSize[1]
118 end
119
120 self.absSize[1] = self.glyphElement:getGlyphWidth()
121 self.size[1] = self.absSize[1] / g_aspectScaleX
122
123 if self.parent ~= nil and self.parent.invalidateLayout ~= nil then
124 self.parent:invalidateLayout()
125 end
126 end
127end