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
VariableWorkWidthHUDExtension
DescriptionCustom HUD drawing extension for VariableWorkWidth Displays the active partial sectionsParent
VehicleHUDExtensionFunctions
canDraw
DescriptionDetermine if the HUD extension should be drawn.Definition
canDraw()Code
70 | function VariableWorkWidthHUDExtension:canDraw() |
71 | return self.vehicle:getIsActiveForInput(true) and self.variableWorkWidth.drawInputHelp |
72 | end |
draw
DescriptionDraw mixing ratio information for a mixing wagon when it is active.Definition
draw(float leftPosX, float rightPosX, float posY)Arguments
float | leftPosX | Left input help panel column start position |
float | rightPosX | Right input help panel column start position |
float | posY | Current input help panel drawing vertical offset |
float | Modified | input help panel drawing vertical offset |
94 | function VariableWorkWidthHUDExtension:draw(leftPosX, rightPosX, posY) |
95 | setTextColor(unpack(self.uiTextColor)) |
96 | setTextBold(true) |
97 | setTextAlignment(RenderText.ALIGN_LEFT) |
98 | renderText(leftPosX, posY + self.displayHeight - self.uiTextSize * 1.7, self.uiTextSize, g_i18n:getText("info_partialWorkingWidth")) |
99 | setTextBold(false) |
100 | |
101 | setTextAlignment(RenderText.ALIGN_RIGHT) |
102 | local usage = self.vehicle:getVariableWorkWidthUsage() |
103 | if usage ~= nil then |
104 | usage = MathUtil.round(usage) |
105 | renderText(rightPosX, posY + self.displayHeight - self.uiTextSize * 1.7, self.uiTextSize, string.format(g_i18n:getText("info_workWidthAndUsage"), usage, self.vehicle:getWorkAreaWidth(self.variableWorkWidth.widthReferenceWorkArea))) |
106 | else |
107 | renderText(rightPosX, posY + self.displayHeight - self.uiTextSize * 1.7, self.uiTextSize, string.format(g_i18n:getText("info_workWidth"), self.vehicle:getWorkAreaWidth(self.variableWorkWidth.widthReferenceWorkArea))) |
108 | end |
109 | |
110 | local numSections = #self.sectionOverlays |
111 | local _, yOffset = getNormalizedScreenValues(0, 25 * self.uiScale) |
112 | local fullWidth = (rightPosX - leftPosX) |
113 | local sectionWidth = fullWidth / numSections |
114 | local sideOffset = sectionWidth * 0.1 |
115 | for i=1, numSections do |
116 | local overlay = self.sectionOverlays[i].overlay |
117 | |
118 | local color = VariableWorkWidthHUDExtension.COLOR.SECTION_ACTIVE |
119 | if not self.sectionOverlays[i].section.isActive then |
120 | color = VariableWorkWidthHUDExtension.COLOR.SECTION_INACTIVE |
121 | end |
122 | local posX = leftPosX + sectionWidth * (i - 1) * (1 + (sectionWidth * 0.2) / fullWidth) |
123 | local width = sectionWidth * 0.8 |
124 | overlay:setPosition(posX, posY + yOffset) |
125 | overlay:setDimension(width) |
126 | overlay:setColor(unpack(color)) |
127 | overlay:render() |
128 | |
129 | local separator = self.sectionOverlays[i].separator |
130 | if separator ~= nil then |
131 | separator:setPosition(posX + width + sideOffset - separator.width * 0.5, posY + yOffset) |
132 | separator:render() |
133 | end |
134 | end |
135 | |
136 | return posY |
137 | end |
getDisplayHeight
DescriptionGet this HUD extension's display height.Definition
getDisplayHeight()Return Values
float | Display | height in screen space |
77 | function VariableWorkWidthHUDExtension:getDisplayHeight() |
78 | return self:canDraw() and self.displayHeight or 0 |
79 | end |
getHelpEntryCountReduction
DescriptionReturns how many help entry slots should be removed for display of the hud extensionDefinition
getHelpEntryCountReduction()Return Values
integer | numSLots | numSLots |
84 | function VariableWorkWidthHUDExtension:getHelpEntryCountReduction() |
85 | return self:canDraw() and 1 or 0 |
86 | end |
new
DescriptionCreate a new instance of VariableWorkWidthHUDExtension.Definition
new(table vehicle, float uiScale, table uiTextColor, float uiTextSize)Arguments
table | vehicle | Vehicle which has the specialization required by a sub-class |
float | uiScale | Current UI scale |
table | uiTextColor | HUD text drawing color as an RGBA array |
float | uiTextSize | HUD text size |
24 | function VariableWorkWidthHUDExtension.new(vehicle, uiScale, uiTextColor, uiTextSize) |
25 | local self = VehicleHUDExtension.new(VariableWorkWidthHUDExtension_mt, vehicle, uiScale, uiTextColor, uiTextSize) |
26 | |
27 | self.variableWorkWidth = vehicle.spec_variableWorkWidth |
28 | |
29 | local _, sectionHeight = getNormalizedScreenValues(0, 15 * uiScale) |
30 | self.sectionOverlays = {} |
31 | local numSections = #self.variableWorkWidth.sections |
32 | for i=1, numSections do |
33 | local section = self.variableWorkWidth.sections[i] |
34 | |
35 | local sectionOverlay = {} |
36 | |
37 | local overlay = Overlay.new(g_baseHUDFilename, 0, 0, 0, sectionHeight) |
38 | overlay:setAlignment(Overlay.ALIGN_VERTICAL_MIDDLE, Overlay.ALIGN_HORIZONTAL_LEFT) |
39 | overlay:setUVs(GuiUtils.getUVs(HUDElement.UV.FILL)) |
40 | overlay:setColor(unpack(uiTextColor)) |
41 | self:addComponentForCleanup(overlay) |
42 | |
43 | sectionOverlay.overlay = overlay |
44 | sectionOverlay.section = section |
45 | |
46 | if (i < numSections and self.variableWorkWidth.sections[i+1].isCenter) or section.isCenter or (not self.variableWorkWidth.hasCenter and i == numSections / 2)then |
47 | local separatorWidth, separatorHeight = getNormalizedScreenValues(1, 35 * uiScale) |
48 | separatorWidth = math.max(separatorWidth, 1 / g_screenWidth) |
49 | local separator = Overlay.new(g_baseHUDFilename, 0, 0, separatorWidth, separatorHeight) |
50 | separator:setAlignment(Overlay.ALIGN_VERTICAL_MIDDLE, Overlay.ALIGN_HORIZONTAL_LEFT) |
51 | separator:setUVs(GuiUtils.getUVs(HUDElement.UV.FILL)) |
52 | separator:setColor(unpack(VariableWorkWidthHUDExtension.COLOR.SEPARATOR)) |
53 | self:addComponentForCleanup(separator) |
54 | |
55 | sectionOverlay.separator = separator |
56 | end |
57 | |
58 | table.insert(self.sectionOverlays, sectionOverlay) |
59 | end |
60 | |
61 | local _, helpHeight = getNormalizedScreenValues(0, 75 * uiScale) |
62 | |
63 | self.displayHeight = helpHeight |
64 | |
65 | return self |
66 | end |