Skip to content

Commit

Permalink
fix moving HUD elements dmg/fuel via XML config
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhooL committed Dec 7, 2024
1 parent d38c17b commit c623372
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
5 changes: 3 additions & 2 deletions FS25_EnhancedVehicle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
-- Author: Majo76
-- email: ls (at) majo76 (dot) de
-- @Date: 02.12.2024
-- @Version: 1.1.2.2
-- @Version: 1.1.3.0

--[[
CHANGELOG
2024-xx-xx - V1.x.x.x
2024-12-07 - V1.1.3.0
* HUD elements dmg and fuel can now be moved correctly by changing offsetX/Y in XML config
+ added translation: da, cz, es, hu
2024-12-02 - V1.1.2.2
Expand Down
22 changes: 16 additions & 6 deletions ui/FS25_EnhancedVehicle_HUD.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
--
-- Author: Majo76
-- email: ls (at) majo76 (dot) de
-- @Date: 01.12.2024
-- @Version: 1.1.2.1
-- @Date: 07.12.2024
-- @Version: 1.1.3.0

local myName = "FS25_EnhancedVehicle_HUD"

Expand Down Expand Up @@ -868,7 +868,7 @@ function FS25_EnhancedVehicle_HUD:drawHUD()
end

local deltaY = 0
if g_currentMission.hud.sideNotifications ~= nil then
if g_currentMission.hud.sideNotifications ~= nil and FS25_EnhancedVehicle.hud.dmg.offsetX == 0 and FS25_EnhancedVehicle.hud.dmg.offsetY == 0 and FS25_EnhancedVehicle.hud.fuel.offsetX == 0 and FS25_EnhancedVehicle.hud.fuel.offsetY == 0 then
-- move our elements down if game displays side notifications
if #g_currentMission.hud.sideNotifications.notificationQueue > 0 then
deltaY = deltaY + (g_currentMission.hud.sideNotifications.bgScale.height + g_currentMission.hud.sideNotifications.notificationOffsetY) * #g_currentMission.hud.sideNotifications.notificationQueue
Expand Down Expand Up @@ -925,9 +925,14 @@ function FS25_EnhancedVehicle_HUD:drawHUD()
-- calculate position of text
local x = self.dmgText.posX
local y = self.dmgText.posY - deltaY

-- move further down for more elements
deltaY = deltaY + _h + self.dmgText.textMarginHeight * 2 + self.marginElement
if FS25_EnhancedVehicle.hud.dmg.offsetX ~= 0 or FS25_EnhancedVehicle.hud.dmg.offsetY ~= 0 then
local offX, offY = self.speedMeter:scalePixelToScreenVector({ FS25_EnhancedVehicle.hud.dmg.offsetX, FS25_EnhancedVehicle.hud.dmg.offsetY })
x = x + offX
y = y + offY
else
-- move further down for more elements
deltaY = deltaY + _h + self.dmgText.textMarginHeight * 2 + self.marginElement
end

self.dmgBox.topleft:setPosition( x - _w - self.dmgText.textMarginWidth * 2, y - self.dmgText.boxMarginHeight)
self.dmgBox.topright:setPosition( x - self.dmgText.boxMarginWidth, y - self.dmgText.boxMarginHeight)
Expand Down Expand Up @@ -1030,6 +1035,11 @@ function FS25_EnhancedVehicle_HUD:drawHUD()
-- calculate position of text
local x = self.fuelText.posX
local y = self.fuelText.posY - deltaY
if FS25_EnhancedVehicle.hud.fuel.offsetX ~= 0 or FS25_EnhancedVehicle.hud.fuel.offsetY ~= 0 then
local offX, offY = self.speedMeter:scalePixelToScreenVector({ FS25_EnhancedVehicle.hud.fuel.offsetX, FS25_EnhancedVehicle.hud.fuel.offsetY })
x = x + offX
y = y + offY
end

self.fuelBox.topleft:setPosition( x - _w - self.fuelText.textMarginWidth * 2, y - self.fuelText.boxMarginHeight)
self.fuelBox.topright:setPosition( x - self.fuelText.boxMarginWidth, y - self.fuelText.boxMarginHeight)
Expand Down

0 comments on commit c623372

Please sign in to comment.