LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

PictureElement

Description
Displays an image with content sizing constraints
Parent
BitmapElement
XML Configuration Parameters
GuiElement#offsetstring [optional] Position offset of the displayed image relative to this element's origin in reference resolution, defaults to [0, 0]. Format: "[x]px [y]px".
GuiElement#focuseOffsetstring [optional] Position offset of the displayed image when it's focused, pressed, highlighted or selected. Works like #offset.

Functions

copyAttributes

Description
Definition
copyAttributes()
Code
65function PictureElement:copyAttributes(src)
66 PictureElement:superClass().copyAttributes(self, src)
67
68 self.contentMode = src.contentMode
69 self.aspectRatio = src.aspectRatio
70 self.imageSize = src.imageSize
71end

draw

Description
Definition
draw()
Code
127function PictureElement:draw(clipX1, clipY1, clipX2, clipY2)
128 local x, y, width, height = self:getAdjustedPosition()
129
130 GuiOverlay.renderOverlay(self.overlay, self.absPosition[1] + x, self.absPosition[2] + y, width, height, self:getOverlayState(), clipX1, clipY1, clipX2, clipY2)
131
132 if self.debugEnabled or g_uiDebugEnabled then
133 local xPixel = 1 / g_screenWidth
134 local yPixel = 1 / g_screenHeight
135
136 drawFilledRect(self.absPosition[1] - xPixel + x, self.absPosition[2] - yPixel + y, width + 2 * xPixel, yPixel, 1, 1, 0, 1)
137 drawFilledRect(self.absPosition[1] - xPixel + x, self.absPosition[2] + height + y, width + 2 * xPixel, yPixel, 1, 1, 0, 1)
138 drawFilledRect(self.absPosition[1] - xPixel + x, self.absPosition[2] + y, xPixel, height, 1, 1, 0, 1)
139 drawFilledRect(self.absPosition[1] + width + x, self.absPosition[2] + y, xPixel, height, 1, 1, 0, 1)
140 end
141
142 -- Skip over superclass
143 PictureElement:superClass():superClass().draw(self, clipX1, clipY1, clipX2, clipY2)
144end

loadFromXML

Description
Definition
loadFromXML()
Code
40function PictureElement:loadFromXML(xmlFile, key)
41 PictureElement:superClass().loadFromXML(self, xmlFile, key)
42
43 self.imageSize = GuiUtils.getNormalizedValues(getXMLString(xmlFile, key.."#imageSize"), self.outputSize, self.imageSize)
44 self.aspectRatio = self.imageSize[1] / self.imageSize[2]
45end

loadProfile

Description
Definition
loadProfile()
Code
49function PictureElement:loadProfile(profile, applyProfile)
50 PictureElement:superClass().loadProfile(self, profile, applyProfile)
51
52 self.imageSize = GuiUtils.getNormalizedValues(profile:getValue("imageSize"), self.outputSize, self.imageSize)
53 self.aspectRatio = self.imageSize[1] / self.imageSize[2]
54
55 local mode = profile:getValue("pictureContentMode")
56 if mode == "scaleToFill" then
57 self.contentMode = PictureElement.CONTENT_MODE.SCALE_TO_FILL
58 elseif mode == "scaleAspectFit" then
59 self.contentMode = PictureElement.CONTENT_MODE.SCALE_ASPECT_FIT
60 end
61end

new

Description
Definition
new()
Code
27function PictureElement.new(target, custom_mt)
28 local self = BitmapElement.new(target, custom_mt or PictureElement_mt)
29
30 self.contentMode = PictureElement.CONTENT_MODE.SCALE_ASPECT_FIT
31
32 self.imageSize = {1, 1}
33 self.aspectRatio = 1
34
35 return self
36end