LUADOC - Farming Simulator 19

Script v1.7.1.0

Engine v1.7.1.0

Foundation Reference

GamePausedDisplay

Description
HUD game pause display element. Displays a customizable message when the game is paused.
Parent
HUDDisplayElement
Functions

createBackground

Description
Get this element's base background position.
Definition
createBackground()
Code
96function GamePausedDisplay.createBackground(hudAtlasPath)
97 local _, height = getNormalizedScreenValues(unpack(GamePausedDisplay.SIZE.SELF))
98 local overlay = Overlay:new(hudAtlasPath, 0, (1 - height) * 0.5, 1, height) -- span horizontally, middle vertical
99 overlay:setUVs(getNormalizedUVs(GamePausedDisplay.UV.BACKGROUND))
100 overlay:setColor(unpack(GamePausedDisplay.COLOR.BACKGROUND))
101 return overlay
102end

createComponents

Description
Create required display components.
Definition
createComponents()
Code
106function GamePausedDisplay:createComponents(hudAtlasPath)
107 local baseX, baseY = self:getPosition()
108 local width, height = self:getWidth(), self:getHeight()
109 local frameElement = HUDFrameElement:new(hudAtlasPath, baseX, baseY, width, height)
110 self:addChild(frameElement)
111
112 local syncOverlay = Overlay:new(GamePausedDisplay.SYNC_SPLASH_PATH, 0, 0, 1, g_screenWidth / g_screenHeight)
113 self.syncBackgroundElement = HUDElement:new(syncOverlay)
114 self:addChild(self.syncBackgroundElement)
115end

draw

Description
Definition
draw()
Code
57function GamePausedDisplay:draw()
58 if self:getVisible() then
59 GamePausedDisplay:superClass().draw(self)
60
61 local textHeight = getTextHeight(self.textSize, self.pauseText)
62 local baseX, baseY = self:getPosition()
63 local posX = baseX + self:getWidth() * 0.5 + self.textOffsetX
64 local posY = baseY + (self:getHeight() - textHeight) * 0.5 + self.textOffsetY
65
66 setTextBold(true)
67 setTextAlignment(RenderText.ALIGN_CENTER)
68 setTextColor(unpack(GamePausedDisplay.COLOR.TEXT))
69 renderText(posX, posY, self.textSize, self.pauseText)
70 end
71end

new

Description
Create a new GamePausedDisplay.
Definition
new(string hudAtlasPath)
Arguments
stringhudAtlasPathPath to the HUD atlas texture.
Return Values
tableGamePausedDisplayinstance
Code
19function GamePausedDisplay.new(hudAtlasPath)
20 local backgroundOverlay = GamePausedDisplay.createBackground(hudAtlasPath)
21 local self = GamePausedDisplay:superClass().new(GamePausedDisplay_mt, backgroundOverlay, nil)
22
23 self.pauseText = ""
24 self.isMenuVisible = false
25
26 self.syncBackgroundElement = nil
27
28 self.textSize = 0
29 self.textOffsetX, self.textOffsetY = 0, 0
30
31 self:storeOriginalPosition()
32 self:storeScaledValues()
33 self:createComponents(hudAtlasPath)
34
35 return self
36end

onMenuVisibilityChange

Description
Handle menu visibility state change.
Definition
onMenuVisibilityChange()
Code
46function GamePausedDisplay:onMenuVisibilityChange(isMenuVisible, isOverlayMenu)
47 local showFullscreen = isMenuVisible and not isOverlayMenu
48 self.syncBackgroundElement:setVisible(showFullscreen)
49end

setPauseText

Description
Set a custom text to display.
Definition
setPauseText()
Code
40function GamePausedDisplay:setPauseText(text)
41 self.pauseText = text
42end

setScale

Description
Set uniform UI scale.
Definition
setScale()
Code
79function GamePausedDisplay:setScale(uiScale)
80 GamePausedDisplay:superClass().setScale(self, 1) -- ignore UI scale, this element must only scale with resolution
81end

storeScaledValues

Description
Store scaled positioning, size and offset values.
Definition
storeScaledValues()
Code
85function GamePausedDisplay:storeScaledValues()
86 self.textSize = self:scalePixelToScreenHeight(GamePausedDisplay.TEXT_SIZE.PAUSE_TEXT)
87 self.textOffsetX, self.textOffsetY = self:scalePixelToScreenVector(GamePausedDisplay.POSITION.PAUSE_TEXT)
88end