LUADOC - Farming Simulator 19

Script v1.7.1.0

Engine v1.7.1.0

Foundation Reference

IngameMap

Description
In-game map display element. This class is used to display the game map both in the HUD as well as in the in-game menu.
Parent
HUDElement
Functions

addMapHotspot

Description
Definition
addMapHotspot()
Code
460function IngameMap:addMapHotspot(mapHotspot)
461 table.insert(self.hotspots, mapHotspot)
462
463 table.sort(self.hotspots, function(v1, v2) return v1.category > v2.category end)
464 self.hotspots_sorted = nil
465
466 return mapHotspot
467end

colorForFarm

Description
Definition
colorForFarm()
Code
882function IngameMap:colorForFarm(farmId)
883 local farm = g_farmManager:getFarmById(farmId)
884 if farm ~= nil then
885 local color = Farm.COLORS[farm.color]
886 if color ~= nil then
887 return color[1], color[2], color[3], color[4]
888 end
889 end
890
891 return 1, 1, 1, 1
892end

createBackground

Description
Create the empty background overlay.
Definition
createBackground()
Code
1091function IngameMap.createBackground()
1092 local width, height = getNormalizedScreenValues(unpack(IngameMap.SIZE.SELF))
1093 local posX, posY = IngameMap.getBackgroundPosition()
1094 return Overlay:new(nil, posX, posY, width, height)
1095end

createComponents

Description
Create required display components.
Definition
createComponents(string hudAtlasPath)
Arguments
stringhudAtlasPathPath to the HUD texture atlas
Code
1100function IngameMap:createComponents(hudAtlasPath)
1101 local baseX, baseY = self:getPosition()
1102 local width, height = self:getWidth(), self:getHeight()
1103
1104 self:createFrame(hudAtlasPath, baseX, baseY, width, height)
1105 self:createToggleMapSizeGlyph(hudAtlasPath, baseX, baseY, width, height)
1106
1107 self:createPlayerMapArrow()
1108 self:createOtherMapArrowOverlay()
1109end

createFrame

Description
Create the map frame.
Definition
createFrame()
Code
1113function IngameMap:createFrame(hudAtlasPath, baseX, baseY, width, height)
1114 local frame = HUDFrameElement:new(hudAtlasPath, baseX, baseY, width, height)
1115 self.mapFrameElement = frame
1116 self:addChild(frame)
1117end

createOtherMapArrowOverlay

Description
Create an arrow overlay used for other player's and their vehicles in multiplayer.
Definition
createOtherMapArrowOverlay()
Code
1152function IngameMap:createOtherMapArrowOverlay()
1153 local width, height = getNormalizedScreenValues(unpack(IngameMap.SIZE.OTHER_ARROW))
1154 local mapArrowRedOverlay = Overlay:new(IngameMap.MAP_HOTSPOT_ATLAS_PATH, 0, 0, width, height)
1155 mapArrowRedOverlay:setUVs(getNormalizedUVs(MapHotspot.UV.NAVIGATION_POINTER))
1156 mapArrowRedOverlay:setColor(unpack(IngameMap.COLOR.OTHER_ARROW))
1157
1158 self.mapArrowRedOverlay = mapArrowRedOverlay
1159end

createPlayerMapArrow

Description
Create the map arrow for the player's position.
Definition
createPlayerMapArrow()
Code
1138function IngameMap:createPlayerMapArrow()
1139 local width, height = getNormalizedScreenValues(unpack(IngameMap.SIZE.PLAYER_ARROW))
1140 local playerMapArrowOverlay = Overlay:new(IngameMap.MAP_HOTSPOT_ATLAS_PATH, 0, 0, width, height)
1141 playerMapArrowOverlay:setUVs(getNormalizedUVs(MapHotspot.UV.NAVIGATION_POINTER))
1142 playerMapArrowOverlay:setColor(unpack(IngameMap.COLOR.PLAYER_ARROW))
1143 playerMapArrowOverlay:setAlignment(Overlay.ALIGN_VERTICAL_BOTTOM, Overlay.ALIGN_HORIZONTAL_LEFT)
1144 self.playerMapArrowOverlay = playerMapArrowOverlay
1145
1146 local element = HUDElement:new(playerMapArrowOverlay)
1147 self.playerMapArrowElement = element
1148end

createToggleMapSizeGlyph

Description
Create the input glyph for map size toggling.
Definition
createToggleMapSizeGlyph()
Code
1121function IngameMap:createToggleMapSizeGlyph(hudAtlasPath, baseX, baseY, baseWidth, baseHeight)
1122 local width, height = getNormalizedScreenValues(unpack(IngameMap.SIZE.INPUT_ICON))
1123 local offX, offY = getNormalizedScreenValues(unpack(IngameMap.POSITION.INPUT_ICON))
1124
1125 local element = InputGlyphElement:new(self.inputDisplayManager, width, height)
1126 local posX, posY = baseX + baseWidth - width - offX, baseY + baseHeight + offY
1127
1128 element:setPosition(posX, posY)
1129 element:setKeyboardGlyphColor(IngameMap.COLOR.INPUT_ICON)
1130 element:setAction(InputAction.TOGGLE_MAP_SIZE)
1131
1132 self.toggleMapSizeGlyph = element
1133 self:addChild(element)
1134end

delete

Description
Delete this element and all of its components.
Definition
delete()
Code
128function IngameMap:delete()
129 IngameMap:superClass().delete(self)
130
131 g_inputBinding:removeActionEventsByTarget(self)
132
133 self.mapElement:delete()
134 self.playerMapArrowElement:delete()
135 self.mapArrowRedOverlay:delete()
136
137 self:setSelectedHotspot(nil)
138
139 -- delete all hotspots
140 for _, hotspot in pairs(self.hotspots) do
141 hotspot:delete()
142 end
143end

determinePlayerPosition

Description
Definition
determinePlayerPosition()
Code
416function IngameMap:determinePlayerPosition(player)
417 return player:getPositionData()
418end

determineVehiclePosition

Description
Definition
determineVehiclePosition()
Code
422function IngameMap:determineVehiclePosition(steerable)
423 local posX, posY, posZ = getTranslation(steerable.rootNode)
424
425 -- set arrow rotation
426 local dx, _, dz = localDirectionToWorld(steerable.rootNode, 0, 0, 1)
427 local yRot
428 if steerable.spec_drivable ~= nil and steerable.spec_drivable.reverserDirection == -1 then
429 yRot = MathUtil.getYRotationFromDirection(dx, dz)
430 else
431 yRot = MathUtil.getYRotationFromDirection(dx, dz) + math.pi
432 end
433 return posX, posY, posZ, yRot
434end

drawEnterableArrows

Description
Draw arrows for enterable vehicles controlled by players.
Definition
drawEnterableArrows()
Code
928function IngameMap:drawEnterableArrows(showNames, leftBorderReached, rightBorderReached, topBorderReached, bottomBorderReached)
929 for _, enterable in pairs(g_currentMission.enterables) do
930 -- isControlled -> being steered, isEntered -> locally controlled and entered (don't show)
931 if enterable.spec_enterable ~= nil and enterable.spec_enterable.isControlled and not enterable.spec_enterable.isEntered then
932 local posX, _, posZ, rotY = self:determineVehiclePosition(enterable)
933 posX = (math.floor(posX) + self.worldCenterOffsetX) / self.worldSizeX
934 posZ = (math.floor(posZ) + self.worldCenterOffsetZ) / self.worldSizeZ
935
936 local positionVisible = self:setMapObjectOverlayPosition(self.mapArrowRedOverlay, posX, posZ,
937 self.mapArrowRedOverlay.width, self.mapArrowRedOverlay.height, true, showNames,
938 leftBorderReached, rightBorderReached, topBorderReached, bottomBorderReached)
939
940 if positionVisible then
941 self:setMapObjectOverlayRotation(self.mapArrowRedOverlay, rotY)
942 local r,g,b,a = self:colorForFarm(enterable:getActiveFarm())
943 self.mapArrowRedOverlay:setColor(r, g, b, a)
944 self.mapArrowRedOverlay:render()
945 if showNames then
946 setTextAlignment(RenderText.ALIGN_LEFT)
947 setTextBold(false)
948 setTextColor(1, 1, 1, 1)
949 local textWidth = getTextWidth(self.playerFontSize, enterable:getControllerName())
950 local posX = MathUtil.clamp(self.mapArrowRedOverlay.x + self.mapArrowRedOverlay.width * 0.5 + self.playerNameOffsetX - textWidth * 0.5, self.mapPosX, self.mapPosX + self.mapWidth - textWidth)
951 renderText(posX, self.mapArrowRedOverlay.y + self.playerNameOffsetY, self.playerFontSize, enterable:getControllerName())
952 end
953 end
954 end
955 end
956end

drawHotspot

Description
Draw a single hotspot on the map.
Definition
drawHotspot()
Code
978function IngameMap:drawHotspot(hotspot, leftBorderReached, rightBorderReached, topBorderReached, bottomBorderReached, showNames, noScaling)
979 if hotspot ~= nil then
980 -- update hotspot's position if it's dynamic
981 if hotspot.objectId ~= nil and hotspot.objectId ~= 0 then
982 local objectX, _, objectZ = getWorldTranslation(hotspot.objectId)
983 hotspot.xMapPos = objectX
984 hotspot.zMapPos = objectZ
985 end
986
987 local objectX = (hotspot.xMapPos+self.worldCenterOffsetX) / self.worldSizeX
988 local objectZ = (hotspot.zMapPos+self.worldCenterOffsetZ) / self.worldSizeZ
989
990 hotspot.zoom = self.iconZoom
991 hotspot.visible = self:setMapObjectOverlayPosition(hotspot, objectX, objectZ, hotspot.width * hotspot.zoom, hotspot.height * hotspot.zoom, hotspot.enabled, hotspot.persistent, leftBorderReached, rightBorderReached, topBorderReached, bottomBorderReached)
992 local scale = self.uiScale
993 if noScaling then
994 scale = 1
995 end
996
997 hotspot:render(self.mapPosX, self.mapPosX + self.mapWidth, self.mapPosY, self.mapPosY + self.mapHeight, scale, showNames)
998 end
999end

drawLatencyToServer

Description
Draw current latency to server as text.
Definition
drawLatencyToServer()
Code
1015function IngameMap:drawLatencyToServer()
1016 if g_client ~= nil and g_client.currentLatency ~= nil and g_currentMission.missionDynamicInfo.isMultiplayer and g_currentMission.missionDynamicInfo.isClient then
1017 if g_client.currentLatency <= 50 then
1018 setTextColor(unpack(IngameMap.COLOR.LATENCY_GOOD))
1019 elseif g_client.currentLatency < 100 then
1020 setTextColor(unpack(IngameMap.COLOR.LATENCY_MEDIUM))
1021 else
1022 setTextColor(unpack(IngameMap.COLOR.LATENCY_BAD))
1023 end
1024
1025 setTextBold(false)
1026 setTextAlignment(RenderText.ALIGN_RIGHT)
1027 renderText(self.mapPosX + self.mapWidth - self.coordOffsetX, self.mapPosY + self.mapHeight - self.coordOffsetY - self.fontSize, self.fontSize, string.format("%dms", math.max(g_client.currentLatency, 10)))
1028 end
1029end

drawOtherPlayerArrows

Description
Draw arrows for other players' positions.
Definition
drawOtherPlayerArrows()
Code
896function IngameMap:drawOtherPlayerArrows(showNames, leftBorderReached, rightBorderReached, topBorderReached, bottomBorderReached)
897 for _, player in pairs(g_currentMission.players) do
898 if player.isControlled and not player.isEntered and player ~= g_currentMission.player then
899 local posX, _, posZ, rotY = self:determinePlayerPosition(player)
900 rotY = rotY - math.pi -- offset returned display rotation value
901 posX = (math.floor(posX) + self.worldCenterOffsetX) / self.worldSizeX
902 posZ = (math.floor(posZ) + self.worldCenterOffsetZ) / self.worldSizeZ
903
904 local positionVisible = self:setMapObjectOverlayPosition(self.mapArrowRedOverlay, posX, posZ,
905 self.mapArrowRedOverlay.width, self.mapArrowRedOverlay.height, true, showNames,
906 leftBorderReached, rightBorderReached, topBorderReached, bottomBorderReached)
907
908 if positionVisible then
909 self:setMapObjectOverlayRotation(self.mapArrowRedOverlay, rotY)
910 local r, g, b, a = self:colorForFarm(player.farmId)
911 self.mapArrowRedOverlay:setColor(r, g, b, a)
912 self.mapArrowRedOverlay:render()
913 if showNames then
914 setTextAlignment(RenderText.ALIGN_LEFT)
915 setTextBold(false)
916 setTextColor(1, 1, 1, 1)
917 local textWidth = getTextWidth(self.playerFontSize, player.visualInformation.playerName)
918 local posX = MathUtil.clamp(self.mapArrowRedOverlay.x + self.mapArrowRedOverlay.width * 0.5 + self.playerNameOffsetX - textWidth * 0.5, self.mapPosX, self.mapPosX + self.mapWidth - textWidth)
919 renderText(posX, self.mapArrowRedOverlay.y + self.playerNameOffsetY, self.playerFontSize, player.visualInformation.playerName)
920 end
921 end
922 end
923 end
924end

drawPlayersCoordinates

Description
Draw the player's current coordinates as text.
Definition
drawPlayersCoordinates()
Code
1003function IngameMap:drawPlayersCoordinates()
1004 local renderString = string.format("[%.1f°, %d, %d]", math.deg(-self.playerRotation % (2*math.pi)), self.normalizedPlayerPosX * self.worldSizeX, self.normalizedPlayerPosZ * self.worldSizeZ)
1005
1006 -- show the player's current coordinates
1007 setTextAlignment(RenderText.ALIGN_RIGHT)
1008 setTextBold(false)
1009 setTextColor(unpack(IngameMap.COLOR.COORDINATES_TEXT))
1010 renderText(self.mapPosX + self.mapWidth - self.coordOffsetX, self.mapPosY + self.coordOffsetY, self.fontSize, renderString)
1011end

getBackgroundPosition

Description
Get the base position of the entire element.
Definition
getBackgroundPosition()
Code
1085function IngameMap.getBackgroundPosition()
1086 return g_safeFrameOffsetX, g_safeFrameOffsetY
1087end

getIsFullSize

Description
Definition
getIsFullSize()
Code
283function IngameMap:getIsFullSize()
284 return self.state == IngameMap.STATE_MAP or (self.isFullscreen and self.mapVisWidthMin <= 1)
285end

loadMap

Description
Definition
loadMap()
Code
374function IngameMap:loadMap(filename, worldSizeX, worldSizeZ)
375 self.mapElement:delete() -- will also delete the wrapped Overlay
376
377 self:setWorldSize(worldSizeX, worldSizeZ)
378
379 local baseX, baseY = self:getPosition()
380 local mapOverlay = Overlay:new(filename, baseX + self.mapOffsetX, baseY + self.mapOffsetY, self.mapSizeX, self.mapSizeY)
381
382 self.mapOverlay = mapOverlay
383 self.mapAlpha = 1
384
385 local mapElement = HUDElement:new(mapOverlay)
386 self.mapElement = mapElement
387 self:setScale(self.uiScale) -- re-scale map overlay and borders
388end

new

Description
Create a new instance of IngameMap.
Definition
new(string hudAtlasPath, table inputDisplayManager)
Arguments
stringhudAtlasPathPath to the HUD atlas texture
tableinputDisplayManagerInputDisplayManager reference
Code
34function IngameMap:new(hudAtlasPath, inputDisplayManager)
35 local backgroundOverlay = IngameMap.createBackground()
36 local self = IngameMap:superClass().new(IngameMap_mt, backgroundOverlay, nil)
37
38 self.uiScale = 1.0
39
40 self.inputDisplayManager = inputDisplayManager
41
42 self.mapOverlay = Overlay:new(nil, 0, 0, 1, 1) -- null-object, obsoletes defensive checks
43 self.mapElement = HUDElement:new(self.mapOverlay) -- null-object
44 self.mapFrameElement = nil
45 self.toggleMapSizeGlyph = nil -- toggle map size input glyph
46 self.playerMapArrowElement = nil -- arrow indicator for player position on map
47
48 self.mapLabelText = utf8ToUpper(g_i18n:getText(IngameMap.L10N_SYMBOL_MAP_LABEL))
49 self.selectHotspotText = g_i18n:getText(IngameMap.L10N_SYMBOL_SELECT_MAP)
50
51 self.mapLabelOffsetX, self.mapLabelOffsetY = 0, 0
52 self.mapLabelTextSize = 0
53 self.mapOffsetX, self.mapOffsetY = 0, 0
54 self.mapSizeX, self.mapSizeY = 0, 0
55 self.mapToFrameDiffX, self.mapToFrameDiffY = 0, 0
56 self.toggleSizeGlyphOffsetX, self.toggleSizeGlyphOffsetY = 0, 0
57
58 self:createComponents(hudAtlasPath)
59
60 self.filter = {}
61 self.filter[MapHotspot.CATEGORY_DEFAULT] = true
62 self.filter[MapHotspot.CATEGORY_FIELD_DEFINITION] = true
63 self.filter[MapHotspot.CATEGORY_TRIGGER] = true
64 self.filter[MapHotspot.CATEGORY_COLLECTABLE] = true
65 self.filter[MapHotspot.CATEGORY_AI] = true
66 self.filter[MapHotspot.CATEGORY_TOUR] = true
67 self.filter[MapHotspot.CATEGORY_MISSION] = true
68 self.filter[MapHotspot.CATEGORY_VEHICLE_STEERABLE] = true
69 self.filter[MapHotspot.CATEGORY_VEHICLE_COMBINE] = true
70 self.filter[MapHotspot.CATEGORY_VEHICLE_TRAILER] = true
71 self.filter[MapHotspot.CATEGORY_VEHICLE_TOOL] = true
72
73 self:setWorldSize(2048, 2048)
74
75 local uiScale = g_gameSettings:getValue("uiScale")
76
77 self.mapPosX = g_safeFrameOffsetX
78 self.mapPosY = g_safeFrameOffsetY
79 self.minMapWidth, self.minMapHeight = getNormalizedScreenValues(unpack(IngameMap.SIZE.MAP))
80
81 -- map arrow representing the player
82 self.mapArrowWidth, self.mapArrowHeight = getNormalizedScreenValues(unpack(IngameMap.SIZE.PLAYER_ARROW))
83
84 self:setSize(self.minMapWidth, self.minMapHeight)
85
86 self.maxMapHeight = 0.7 - 2 * self.mapPosY
87 self.maxMapWidth = (self.maxMapHeight * g_screenHeight) / g_screenWidth
88
89 self.resizeTime = 0.1 * 1000
90 self.resizeDir = 0
91 self.state = IngameMap.STATE_MINIMAP
92
93 self.minMapVisWidth = 0.3
94 self.maxMapVisWidth = 1
95
96 self.iconZoom = 1.4
97 self.maxIconZoom = IngameMap.maxIconZoom
98
99 self.mapVisWidthMin = self.minMapVisWidth -- this is the largest zoom factor (width) for the map
100 self.mapVisWidth = 0.1 -- this is the current zoom factor (width) changes in relation to vehicle speed
101 self.mapVisHeight = self.mapVisWidth / self.mapAspectRatio -- zoom factor for height (with aspect ratio from map)
102
103 self.mapUVs = {0, 0, 0, 0, 0, 0, 0, 0}
104
105 -- the player's position on the map
106 self.normalizedPlayerPosX = 0
107 self.normalizedPlayerPosZ = 0
108 self.playerRotation = 0
109
110 -- the map's current center position (same as player position, unless map borders reached)
111 self.centerXPos = 0
112 self.centerZPos = 0
113
114 self.hotspots = {}
115
116 self.selectedHotspot = nil
117
118 self.isVisible = true
119 self.allowToggle = true
120
121 self.topDownCamera = nil -- set by screen views which use a top down view, used for map position update
122
123 return self
124end

removeMapHotspot

Description
Definition
removeMapHotspot()
Code
471function IngameMap:removeMapHotspot(mapHotspot)
472 if mapHotspot ~= nil then
473 for i = 1, table.getn(self.hotspots) do
474 if self.hotspots[i] == mapHotspot then
475 table.remove(self.hotspots, i)
476 break
477 end
478 end
479
480 if self.selectedHotspot == mapHotspot then
481 self:setSelectedHotspot(nil)
482 end
483
484 if g_currentMission ~= nil then
485 if g_currentMission.currentMapTargetHotspot == mapHotspot then
486 g_currentMission:setMapTargetHotspot(nil)
487 end
488 end
489
490 mapHotspot.enabled = false
491
492 self.hotspots_sorted = nil
493 end
494end

renderHotspots

Description
Draw all known hotspots on the map.
Definition
renderHotspots()
Code
960function IngameMap:renderHotspots(leftBorderReached, rightBorderReached, topBorderReached, bottomBorderReached, renderLast, showNames, minimalHotspotSize, noScaling)
961 -- reposition all hotspots
962 if renderLast then
963 new2DLayer()
964 end
965
966 if self.hotspots_sorted ~= nil then -- this data structure is built in update() when necessary and reset to nil on changes
967 for _, hotspot in pairs(self.hotspots_sorted[renderLast]) do
968 hotspot.visible = false
969 if hotspot ~= self.selectedHotspot and (minimalHotspotSize == nil or hotspot.category == MapHotspot.CATEGORY_FIELD_DEFINITION or minimalHotspotSize <= hotspot.width) then
970 self:drawHotspot(hotspot, leftBorderReached, rightBorderReached, topBorderReached, bottomBorderReached, showNames, noScaling)
971 end
972 end
973 end
974end

resetSettings

Description
Definition
resetSettings()
Code
254function IngameMap:resetSettings()
255 if self.overlay == nil then
256 return -- instance has been deleted, ignore reset
257 end
258
259 if self.state == IngameMap.STATE_MAP then
260 self.mapWidth = self.maxMapWidth
261 self.mapHeight = self.maxMapHeight
262 self.mapVisWidthMin = self.maxMapVisWidth
263 self.iconZoom = self.maxIconZoom
264 self.mapAlpha = 0.7
265 else
266 self.mapWidth = self.minMapWidth
267 self.mapHeight = self.minMapHeight
268 self.mapVisWidthMin = self.minMapVisWidth
269 self.iconZoom = self.maxIconZoom
270 self.mapAlpha = 1
271 end
272
273 self:setScale(self.uiScale) -- resets scaled values
274
275 local baseX, baseY = IngameMap.getBackgroundPosition()
276 self:setPosition(baseX + self.mapOffsetX, baseY + self.mapOffsetY)
277 self:setSize(self.mapWidth, self.mapHeight)
278 self:setSelectedHotspot(nil)
279end

setAllowToggle

Description
Definition
setAllowToggle()
Code
334function IngameMap:setAllowToggle(isAllowed)
335 self.allowToggle = isAllowed
336 self.toggleMapSizeGlyph:setVisible(isAllowed)
337end

setFilter

Description
Definition
setFilter()
Code
446function IngameMap:setFilter(category, isActive)
447 if category ~= nil then
448 if isActive then
449 g_gameSettings:setValue("ingameMapFilter", Utils.clearBit(g_gameSettings:getValue("ingameMapFilter"), category))
450 else
451 g_gameSettings:setValue("ingameMapFilter", Utils.setBit(g_gameSettings:getValue("ingameMapFilter"), category))
452 end
453 self.filter[category] = isActive
454 self.hotspots_sorted = nil
455 end
456end

setFullscreen

Description
Set full-screen mode (for map overview) without affecting the mini-map state.
Definition
setFullscreen()
Code
147function IngameMap:setFullscreen(isFullscreen)
148 self.isFullscreen = isFullscreen
149
150 if isFullscreen then
151 self.mapVisWidthMin = 1
152 self.centerXPos = 0
153 self.centerZPos = 0
154 end
155end

setMapObjectOverlayRotation

Description
Definition
setMapObjectOverlayRotation()
Code
410function IngameMap:setMapObjectOverlayRotation(overlay, rotation)
411 overlay:setRotation(rotation, overlay.width*0.5, overlay.height*0.5)
412end

setScale

Description
Set this element's scale.
Definition
setScale(float uiScale)
Arguments
floatuiScaleCurrent UI scale applied to both width and height of elements
Code
1038function IngameMap:setScale(uiScale)
1039 IngameMap:superClass().setScale(self, uiScale, uiScale)
1040 self.uiScale = uiScale
1041 self:storeScaledValues(uiScale)
1042
1043 self.mapElement:setScale(uiScale, uiScale)
1044 local uniZoomScale = uiScale * self.iconZoom
1045 self.playerMapArrowElement:setScale(uniZoomScale, uniZoomScale)
1046 self.mapArrowRedOverlay:setScale(uniZoomScale, uniZoomScale)
1047
1048 -- update some positioning info by resetting position and size
1049 local x, y = self:getPosition()
1050 self:setPosition(x + self.mapOffsetX, y + self.mapOffsetY)
1051 self:setSize(self.mapWidth, self.mapHeight)
1052end

setSelectedHotspot

Description
Definition
setSelectedHotspot()
Code
195function IngameMap:setSelectedHotspot(hotspot)
196 if self.selectedHotspot ~= nil then
197 self.selectedHotspot:setSelected(false)
198 end
199 self.selectedHotspot = hotspot
200 if self.selectedHotspot ~= nil then
201 self.selectedHotspot:setSelected(true)
202 end
203end

setWorldSize

Description
Definition
setWorldSize()
Code
401function IngameMap:setWorldSize(worldSizeX, worldSizeZ)
402 self.worldSizeX = worldSizeX
403 self.worldSizeZ = worldSizeZ
404 self.worldCenterOffsetX = self.worldSizeX * 0.5
405 self.worldCenterOffsetZ = self.worldSizeZ * 0.5
406end

setZoomScale

Description
Definition
setZoomScale()
Code
353function IngameMap:setZoomScale(uniZoomScale)
354 self.playerMapArrowElement:setScale(uniZoomScale, uniZoomScale)
355 self.mapArrowRedOverlay:setScale(uniZoomScale, uniZoomScale)
356end

storeScaledValues

Description
Store scaled positioning, size and offset values.
Definition
storeScaledValues()
Code
1056function IngameMap:storeScaledValues(uiScale)
1057 self.minMapWidth, self.minMapHeight = self:scalePixelToScreenVector(IngameMap.SIZE.MAP)
1058
1059 self.mapLabelOffsetX, self.mapLabelOffsetY = self:scalePixelToScreenVector(IngameMap.POSITION.MAP_LABEL)
1060 self.mapLabelTextSize = self:scalePixelToScreenHeight(HUDElement.TEXT_SIZE.DEFAULT_TITLE)
1061
1062 self.mapOffsetX, self.mapOffsetY = self:scalePixelToScreenVector(IngameMap.POSITION.MAP)
1063 self.mapSizeX, self.mapSizeY = self:scalePixelToScreenVector(IngameMap.SIZE.MAP)
1064
1065 self.toggleSizeGlyphOffsetX, self.toggleSizeGlyphOffsetY = self:scalePixelToScreenVector(IngameMap.POSITION.INPUT_ICON)
1066 self.selectHotspotTextSize = self:scalePixelToScreenHeight(IngameMap.TEXT_SIZE.GLYPH_TEXT)
1067
1068 self.fontSize = self:scalePixelToScreenHeight(HUDElement.TEXT_SIZE.DEFAULT_TEXT)
1069 self.coordOffsetX, self.coordOffsetY = self:scalePixelToScreenVector(IngameMap.POSITION.INFO_TEXT)
1070
1071 self.playerFontSize = self:scalePixelToScreenHeight(IngameMap.TEXT_SIZE.PLAYER_NAME)
1072 self.playerNameOffsetX, self.playerNameOffsetY = self:scalePixelToScreenVector(IngameMap.POSITION.PLAYER_NAME)
1073
1074 self.mapToFrameDiffX, self.mapToFrameDiffY =
1075 self:scalePixelToScreenWidth(IngameMap.SIZE.SELF[1] - IngameMap.SIZE.MAP[1]),
1076 self:scalePixelToScreenHeight(IngameMap.SIZE.SELF[2] - IngameMap.SIZE.MAP[2])
1077end

toggleSize

Description
Definition
toggleSize()
Code
159function IngameMap:toggleSize(state, force)
160 local newState = self.state + 1
161 if newState > IngameMap.STATE_OFF then
162 newState = IngameMap.STATE_MINIMAP
163 end
164
165 if state ~= nil then
166 if force or self.state ~= IngameMap.STATE_OFF then
167 newState = state
168 if state == IngameMap.STATE_MINIMAP and self.state == IngameMap.STATE_MAP then
169 self.resizeDir = -1
170 end
171 end
172 end
173
174 self.state = newState
175 if newState == IngameMap.STATE_MAP then
176 self.resizeDir = 1
177 else
178 self:resetSettings()
179 end
180
181 -- only show toggle map input binding display in global input hints if the map is currently invisible:
182 g_inputBinding:setActionEventTextVisibility(self.toggleMapSizeEventId, self.state == IngameMap.STATE_OFF)
183
184 g_gameSettings:setValue("ingameMapState", newState)
185end

updateFilters

Description
Definition
updateFilters()
Code
438function IngameMap:updateFilters()
439 for category, _ in pairs(self.filter) do
440 self:setFilter(category, not Utils.isBitSet(g_gameSettings:getValue("ingameMapFilter"), category))
441 end
442end

zoom

Description
Definition
zoom()
Code
341function IngameMap:zoom(zoomDiff)
342 self.mapVisWidthMin = MathUtil.clamp(self.mapVisWidthMin + zoomDiff, self.minMapVisWidth, self.maxMapVisWidth)
343
344 self:setSize(self.mapWidth, self.mapHeight)
345
346 self.iconZoom = 1.2 + (1 - (self.mapVisWidthMin - self.minMapVisWidth) / (self.maxMapVisWidth - self.minMapVisWidth))
347
348 self:setZoomScale(self.uiScale * self.iconZoom)
349end