Skip to content

Commit

Permalink
#10 Fixed rounding problem for current temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
Peppie84 committed Jan 23, 2025
1 parent bb7c973 commit cde6428
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Added `l10n_uk.xml` by Gonimy-Vetrom
- Fixed temperature misalignment for widesceen resolutions for [#3](https://github.com/Peppie84/FS25_ExtendedGameInfoDisplay/issues/3)
- Added `l10n_tr.xml` by [RuyaSavascisi](https://github.com/RuyaSavascisi)
- Fixed rounding problem for current temperature for [#10](https://github.com/Peppie84/FS25_ExtendedGameInfoDisplay/issues/10)

## [v1.0.0.0] - 2025-01-09
- Ported from LS22 to LS25
Expand Down
17 changes: 8 additions & 9 deletions FS25_ExtendedGameInfoDisplay/src/extendedgameinfodisplay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function ExtendedGameInfoDisplay:gameinfodisplay__draw(overwrittenFunc)
end

function ExtendedGameInfoDisplay:setTemperaturePosition(gameInfoDisplay)
local referencePositionX = gameInfoDisplay.calendarIcon.x - gameInfoDisplay:scalePixelToScreenWidth(120)
local referencePositionX = gameInfoDisplay.calendarIcon.x - gameInfoDisplay:scalePixelToScreenWidth(115)
gameInfoDisplay.temperature.x = referencePositionX
gameInfoDisplay.temperatureUp.x = referencePositionX
gameInfoDisplay.temperatureDown.x = referencePositionX
Expand All @@ -93,20 +93,20 @@ function ExtendedGameInfoDisplay:setTemperatureTrendAndDraw(gameInfoDisplay)
gameInfoDisplay.temperatureUp:draw()
gameInfoDisplay.temperatureDown:draw()

local seperatorPosX = gameInfoDisplay.temperature.x - gameInfoDisplay:scalePixelToScreenWidth(5)
local seperatorPosX = gameInfoDisplay.temperature.x - gameInfoDisplay:scalePixelToScreenWidth(10)
local seperatorPosYStart = gameInfoDisplay.temperature.y + gameInfoDisplay:scalePixelToScreenHeight(ExtendedGameInfoDisplay.TEMPERATURE_ICON_SIZE-1)
local seperatorPosYEnd = gameInfoDisplay.temperature.y + gameInfoDisplay:scalePixelToScreenHeight(4)

drawLine2D(seperatorPosX, seperatorPosYStart, seperatorPosX, seperatorPosYEnd, gameInfoDisplay.separatorWidth, 1,1,1,0.2)
drawLine2D(seperatorPosX, seperatorPosYStart, seperatorPosX, seperatorPosYEnd, gameInfoDisplay.separatorWidth, 1,1,1, 0.2)
end

function ExtendedGameInfoDisplay:drawTemperatureText(gameInfoDisplay)
local minTemperatureInC, maxTemperatureInC = g_currentMission.environment.weather:getCurrentMinMaxTemperatures()
local currentTemperatureInC = g_currentMission.environment.weather:getCurrentTemperature()
local currentTemperatureInC = g_currentMission.environment.weather.forecast:getCurrentWeather()

local minTemperatureExpanded = g_i18n:getTemperature(minTemperatureInC)
local maxTemperatureExpanded = g_i18n:getTemperature(maxTemperatureInC)
local currentTemperatureExpanded = g_i18n:getTemperature(currentTemperatureInC)
local minTemperatureExpanded = MathUtil.round(g_i18n:getTemperature(minTemperatureInC), 0)
local maxTemperatureExpanded = MathUtil.round(g_i18n:getTemperature(maxTemperatureInC), 0)
local currentTemperatureExpanded = MathUtil.round(g_i18n:getTemperature(currentTemperatureInC.temperature), 0)

local scaledTextSizeForCurrentTemperature = gameInfoDisplay:scalePixelToScreenHeight(19)
local scaledTextSizeForTemperature = gameInfoDisplay:scalePixelToScreenHeight(14)
Expand All @@ -125,7 +125,7 @@ function ExtendedGameInfoDisplay:drawYearText(gameInfoDisplay)
local monthTextSize = gameInfoDisplay:scalePixelToScreenHeight(10)
local scaledTextSizeForYear = gameInfoDisplay:scalePixelToScreenHeight(12)

local gameInfoDisplayPosX, gameInfoDisplayPosY = gameInfoDisplay:getPosition()
local _, gameInfoDisplayPosY = gameInfoDisplay:getPosition()
local posX = gameInfoDisplay.calendarIcon.x + gameInfoDisplay.calendarIcon.width + gameInfoDisplay:scalePixelToScreenWidth(2)
local posY = gameInfoDisplayPosY - gameInfoDisplay.calendarTextOffsetY - monthTextSize

Expand All @@ -139,7 +139,6 @@ end

--- Initialize the mod
local function init()
--HUD.new = Utils.prependedFunction(HUD.new, newHud)
HUD.createDisplayComponents = Utils.overwrittenFunction(HUD.createDisplayComponents, ExtendedGameInfoDisplay.hud__createDisplayComponents)
GameInfoDisplay.draw = Utils.overwrittenFunction(GameInfoDisplay.draw, ExtendedGameInfoDisplay.gameinfodisplay__draw)
end
Expand Down

0 comments on commit cde6428

Please sign in to comment.