Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- AnimalScreen
- AnimationElement
- BitmapElement
- BoxLayoutElement
- BreadcrumbsElement
- ButtonElement
- ButtonOverlay
- ChatWindow
- CheckedOptionElement
- ClearElement
- ColorPickButtonElement
- ConstructionScreen
- ContextActionDisplay
- ControlBarDisplay
- DialogElement
- DynamicFadedBitmapElement
- FillLevelsDisplay
- FlowLayoutElement
- FocusManager
- FrameElement
- FrameReferenceElement
- GameInfoDisplay
- GameInfoDisplayMobile
- GamePausedDisplay
- Gui
- GuiDataSource
- GuiElement
- GuiMixin
- GuiOverlay
- GuiProfile
- GuiSoundPlayer
- GuiTopDownCamera
- GuiTopDownCursor
- GuiUtils
- HUDDisplayElement
- HUDElement
- HUDFrameElement
- HUDPopupMessage
- HUDSliderElement
- HUDTextDisplay
- IndexChangeSubjectMixin
- IndexStateElement
- InfoDisplay
- InfoHUDBox
- InGameIcon
- IngameMap
- IngameMapElement
- InputGlyphElement
- InputGlyphElementUI
- InputHelpDisplay
- KeyValueInfoHUDBox
- ListElement
- ListItemElement
- MapOverlayGenerator
- MixerWagonHUDExtension
- MultiTextOptionElement
- MultiValueTween
- Overlay
- PagingElement
- PictureElement
- PlatformIconElement
- PlayerControlPadDisplay
- PlaySampleMixin
- RenderElement
- RoundStatusBar
- ScreenElement
- ScrollingLayoutElement
- SettingsModel
- SideNotification
- SideNotificationMobile
- SliderElement
- SpeakerDisplay
- SpeedMeterDisplay
- SpeedSliderDisplay
- StatusBar
- SteeringSliderDisplay
- TabbedMenu
- TabbedMenuFrameElement
- TabbedMenuWithDetails
- TableElement
- TableHeaderElement
- TerrainLayerElement
- TextBackdropElement
- TextElement
- TextInputElement
- ThreePartBitmapElement
- TimerElement
- ToggleButtonElement
- TopNotification
- Tween
- TweenSequence
- VariableWorkWidthHUDExten...
- VehicleHUDExtension
- VehicleSchemaDisplay
- VideoElement
- WardrobeScreen
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- Parameters
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- StateMachine
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
HUDFrameElement
DescriptionFrameElement HUD background frame element. Displays a transparent frame with a thick bottom bar for use as a background in HUD elements.Parent
HUDElementFunctions
- createComponents
- new
- setBottomBarColor
- setBottomBarHeight
- setDimension
- setFrameColor
- setLeftLineVisible
- setRightLineVisible
createComponents
DescriptionCreate display components.Definition
createComponents()Code
45 | function HUDFrameElement:createComponents(hudAtlasPath, baseX, baseY, width, height) |
46 | -- get pixel sizes so that frame lines are always at least a screen pixel thick |
47 | local refPixelX, refPixelY = 1 / g_referenceScreenWidth, 1 / g_referenceScreenHeight |
48 | local screenPixelX, screenPixelY = 1 / g_screenWidth, 1 / g_screenHeight |
49 | local onePixelX, onePixelY = math.max(refPixelX, screenPixelX), math.max(refPixelY, screenPixelY) |
50 | |
51 | -- top line |
52 | local posX, posY = baseX, baseY + self:getHeight() |
53 | local frameWidth, frameHeight = getNormalizedScreenValues(self.frameThickness, self.frameThickness) |
54 | local pixelsX, pixelsY = math.ceil(frameWidth / onePixelX), math.ceil(frameHeight / onePixelY) |
55 | self.frameWidth, self.frameHeight = pixelsX * onePixelX, pixelsY * onePixelY |
56 | |
57 | local lineOverlay = Overlay.new(hudAtlasPath, posX, posY - self.frameHeight, width, self.frameHeight) |
58 | lineOverlay:setUVs(GuiUtils.getUVs(HUDElement.UV.FILL)) |
59 | lineOverlay:setColor(unpack(HUDFrameElement.COLOR.FRAME)) |
60 | |
61 | local lineElement = HUDElement.new(lineOverlay) |
62 | self.topLine = lineElement |
63 | self:addChild(lineElement) |
64 | |
65 | -- side lines |
66 | posX, posY = baseX, baseY + self.frameHeight |
67 | lineOverlay = Overlay.new(hudAtlasPath, posX, posY, self.frameWidth, height - self.frameHeight * 2) |
68 | lineOverlay:setUVs(GuiUtils.getUVs(HUDElement.UV.FILL)) |
69 | lineOverlay:setColor(unpack(HUDFrameElement.COLOR.FRAME)) |
70 | |
71 | lineElement = HUDElement.new(lineOverlay) |
72 | self.leftLine = lineElement |
73 | self:addChild(lineElement) |
74 | |
75 | posX, posY = baseX + width - self.frameWidth, baseY + self.frameHeight |
76 | lineOverlay = Overlay.new(hudAtlasPath, posX, posY, self.frameWidth, height - self.frameHeight * 2) |
77 | lineOverlay:setUVs(GuiUtils.getUVs(HUDElement.UV.FILL)) |
78 | lineOverlay:setColor(unpack(HUDFrameElement.COLOR.FRAME)) |
79 | |
80 | lineElement = HUDElement.new(lineOverlay) |
81 | self.rightLine = lineElement |
82 | self:addChild(lineElement) |
83 | |
84 | -- bottom bar |
85 | local barSize = self.barThickness |
86 | local barColor = HUDFrameElement.COLOR.BAR |
87 | if not self.showBar then |
88 | barSize = self.frameThickness |
89 | barColor = HUDFrameElement.COLOR.FRAME |
90 | end |
91 | |
92 | local _, barHeight = getNormalizedScreenValues(0, barSize) |
93 | pixelsY = math.ceil(barHeight / onePixelY) |
94 | local barOverlay = Overlay.new(hudAtlasPath, baseX, baseY, width, pixelsY * onePixelY) |
95 | barOverlay:setUVs(GuiUtils.getUVs(HUDElement.UV.FILL)) |
96 | barOverlay:setColor(unpack(barColor)) |
97 | |
98 | local barElement = HUDElement.new(barOverlay) |
99 | self.bottomBar = barElement |
100 | self:addChild(barElement) |
101 | end |
new
DescriptionCreate a new instance of FrameElement.Definition
new(string hudAtlasPath, float posX, float posY, float width, float height, table parent)Arguments
string | hudAtlasPath | Path to the HUD atlas texture |
float | posX | Initial X position in screen space |
float | posY | Initial Y position in screen space |
float | width | Frame width in screen space |
float | height | Frame height in screen space |
table | parent | [optional] Parent HUDElement which will receive this frame as its child element |
23 | function HUDFrameElement.new(hudAtlasPath, posX, posY, width, height, parent, showBar, frameThickness, barThickness) |
24 | local backgroundOverlay = Overlay.new(hudAtlasPath, posX, posY, width, height) |
25 | backgroundOverlay:setUVs(GuiUtils.getUVs(HUDElement.UV.FILL)) |
26 | backgroundOverlay:setColor(0, 0, 0, 0) -- default invisible |
27 | local self = HUDElement.new(backgroundOverlay, parent, HUDFrameElement_mt) |
28 | |
29 | self.topLine = nil |
30 | self.leftLine = nil |
31 | self.rightLine = nil |
32 | self.bottomBar = nil |
33 | self.frameWidth, self.frameHeight = 0, 0 |
34 | self.showBar = Utils.getNoNil(showBar, true) |
35 | self.frameThickness = frameThickness or HUDFrameElement.THICKNESS.FRAME |
36 | self.barThickness = barThickness or HUDFrameElement.THICKNESS.BAR |
37 | |
38 | self:createComponents(hudAtlasPath, posX, posY, width, height) |
39 | |
40 | return self |
41 | end |
setBottomBarColor
DescriptionSet frame bottom bar height.Definition
setBottomBarColor()Code
132 | function HUDFrameElement:setBottomBarColor(r, g, b, a) |
133 | self.bottomBar:setColor(r, g, b, a) |
134 | end |
setBottomBarHeight
DescriptionSet frame bottom bar height.Definition
setBottomBarHeight()Code
126 | function HUDFrameElement:setBottomBarHeight(height) |
127 | self.bottomBar:setDimension(nil, height) |
128 | end |
setDimension
DescriptionSet frame element dimensions. Override from HUDElement to preserve border positioning and sizes.Definition
setDimension()Code
106 | function HUDFrameElement:setDimension(width, height) |
107 | HUDFrameElement:superClass().setDimension(self, width, height) |
108 | |
109 | local lineHeight = nil |
110 | if height ~= nil then |
111 | lineHeight = height - self.frameHeight * 2 |
112 | end |
113 | |
114 | self.topLine:setDimension(width, nil) |
115 | self.leftLine:setDimension(nil, lineHeight) |
116 | self.rightLine:setDimension(nil, lineHeight) |
117 | self.bottomBar:setDimension(width, nil) |
118 | |
119 | local x, y = self:getPosition() |
120 | self.topLine:setPosition(nil, y + self:getHeight() - self.frameHeight) |
121 | self.rightLine:setPosition(x + self:getWidth() - self.frameWidth, nil) |
122 | end |
setFrameColor
DescriptionSets color of the frameDefinition
setFrameColor()Code
150 | function HUDFrameElement:setFrameColor(r, g, b, a) |
151 | self.topLine:setColor(r, g, b, a) |
152 | self.leftLine:setColor(r, g, b, a) |
153 | self.rightLine:setColor(r, g, b, a) |
154 | self.bottomBar:setColor(r, g, b, a) |
155 | end |
setLeftLineVisible
DescriptionSet visibility of left lineDefinition
setLeftLineVisible()Code
138 | function HUDFrameElement:setLeftLineVisible(visible) |
139 | self.leftLine:setVisible(visible) |
140 | end |
setRightLineVisible
DescriptionSet visibility of right lineDefinition
setRightLineVisible()Code
144 | function HUDFrameElement:setRightLineVisible(visible) |
145 | self.rightLine:setVisible(visible) |
146 | end |