Skip to content

Commit

Permalink
Ported from LS22 to LS25
Browse files Browse the repository at this point in the history
  • Loading branch information
Peppie84 committed Nov 24, 2024
1 parent 2e07efd commit fc137ba
Show file tree
Hide file tree
Showing 25 changed files with 410 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# top-most EditorConfig file
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4
charset = utf-8

[*.{xml,xsd}]
max_line_length = off
indent_size = 2

[*.md]
trim_trailing_whitespace = false
insert_final_newline = false
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Compiled Lua sources
luac.out

# luarocks build files
*.src.rock

# archiv files
*.zip
*.tar.gz

# repo specific
.testrunner/

# Giants debugger
*.gdpu
*.gdp
*.gspu
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]
- Ported from LS22 to LS25
- Initial release
16 changes: 16 additions & 0 deletions FS25_ExtendedGameInfoDisplay.gsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<giantsStudioProject version="1" connectionPort="61407" listeningPort="61408" builtInTableWriteProtection="true">
<projectName>FS25_ExtendedGameInfoDisplay</projectName>
<projectSources>
<source path="C:/Users/Peppie/Documents/FarmingSimulator25 - Entwicklung/mods/FS25_ExtendedGameInfoDisplay/FS25_ExtendedGameInfoDisplay/" />
</projectSources>
<excludePaths></excludePaths>
<gameUserProfileAppDirectory>%gameuserprofile%/FarmingSimulator2025/</gameUserProfileAppDirectory>
<gameSourceDirectory>D:/Steam/steamapps/common/Farming Simulator 25/</gameSourceDirectory>
<scriptBinding>D:/Steam/steamapps/common/Farming Simulator 25/sdk/debugger/scriptBinding.xml</scriptBinding>
<launchWorkingDirectory>D:/Steam/steamapps/common/Farming Simulator 25/</launchWorkingDirectory>
<launchExecutable>D:/Steam/steamapps/common/Farming Simulator 25/x64/FarmingSimulator2025Game.exe</launchExecutable>
<launchProfiles>
<launchProfile name="default" parameters="" />
</launchProfiles>
</giantsStudioProject>
Binary file not shown.
27 changes: 27 additions & 0 deletions FS25_ExtendedGameInfoDisplay/modDesc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<modDesc descVersion="92">
<author>Peppie84</author>
<version>1.0.0.0</version>
<title>
<en>Extended Game Infodisplay</en>
<de>Erweiterte Spiel-Infodarstellung</de>
</title>
<description>
<en><![CDATA[
Expands the current GameInfoDisplay in the upper right corner by displaying the current year under the date and activates a hidden temperature feature with an indicator of whether the temperature is falling, staying constant or rising, the display of the current temperature. I also added the min/max temperature of the day.
For more information, help and reporting issues please visit <a href='https://github.com/Peppie84/FS25_ExtendedGameInfoDisplay'>GitHub</a>.
]]></en>
<de><![CDATA[
Erweitert die aktuelle GameInfoDisplay oben rechts um die Anzeige des aktuellen Jahres unter dem Datum und aktiviert ein verstecktes Temperaturfeature mit einem Indikator ob die Temepratur fällt, gleich bleibt oder steigt, die Anzeige der aktuellen Temperatur und der min/max Temperatur des Tages.
Weitere Informationen, Hilfe und Probleme melden findest Du unter <a href='https://github.com/Peppie84/FS25_ExtendedGameInfoDisplay'>GitHub</a>.
]]></de>
</description>
<iconFilename>icon_ExGameInfoDisp.dds</iconFilename>
<multiplayer supported="true" />
<extraSourceFiles>
<sourceFile filename="src/extendedgameinfodisplay.lua" />
</extraSourceFiles>
<l10n filenamePrefix="translations/l10n" />
</modDesc>
147 changes: 147 additions & 0 deletions FS25_ExtendedGameInfoDisplay/src/extendedgameinfodisplay.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
---
-- ExtendedGameInfoDisplay
--
-- Main class to extend the default gameInfoDisplay with year info
-- and temperatur + trend and current/min/max temperatur.
--
-- Copyright (c) Peppie84, 2024
-- https://github.com/Peppie84/FS25_ExtendedGameInfoDisplay
--

ExtendedGameInfoDisplay = {
STRECH_GAME_INFO_DISPLAY = 95,
TEMPERATUR_ICON_SIZE = 40,
L10N_SYMBOLS = {
YEAR_TEXT = "yearinfo_current_year"
},
CURRENT_MOD = g_currentModName or 'unknown',
DIRECTORY_MOD = g_currentModDirectory or '',
WEATHER_HOURS_FORECAST = 3600000*6,
HOURS_A_DAY = 3600000*24
}

---Overwritten HUD.createDisplayComponents()
---@param overwrittenFunc function
---@param uiScale number
function ExtendedGameInfoDisplay:hud__createDisplayComponents(overwrittenFunc, uiScale)
overwrittenFunc(self, uiScale)
-- Set some offsets to move the hud to the left
self.gameInfoDisplay.calendarTextOffsetY = self.gameInfoDisplay.calendarTextOffsetY + self.gameInfoDisplay:scalePixelToScreenHeight(7)
self.gameInfoDisplay.infoBgLeft.offsetX = -self.gameInfoDisplay:scalePixelToScreenWidth(ExtendedGameInfoDisplay.STRECH_GAME_INFO_DISPLAY)
self.gameInfoDisplay.weatherIcon.offsetX = -self.gameInfoDisplay:scalePixelToScreenWidth(ExtendedGameInfoDisplay.STRECH_GAME_INFO_DISPLAY)
self.gameInfoDisplay.weatherNextIcon.offsetX = -self.gameInfoDisplay:scalePixelToScreenWidth(ExtendedGameInfoDisplay.STRECH_GAME_INFO_DISPLAY)

local posX, posY = self.gameInfoDisplay:getPosition()
local temperaturPositionY = posY - self.gameInfoDisplay:scalePixelToScreenHeight(ExtendedGameInfoDisplay.TEMPERATUR_ICON_SIZE + 12)
local temperaturIconWidth = self.gameInfoDisplay:scalePixelToScreenWidth(ExtendedGameInfoDisplay.TEMPERATUR_ICON_SIZE)
local temperaturIconHeight = self.gameInfoDisplay:scalePixelToScreenHeight(ExtendedGameInfoDisplay.TEMPERATUR_ICON_SIZE)

self.gameInfoDisplay.temperatur = g_overlayManager:createOverlay("ui_elements.thermometer", 0, temperaturPositionY, temperaturIconWidth, temperaturIconHeight)
self.gameInfoDisplay.temperatur:setColor(unpack(HUD.COLOR.ACTIVE))
self.gameInfoDisplay.temperaturUp = g_overlayManager:createOverlay("ui_elements.thermometerUp", 0, temperaturPositionY, temperaturIconWidth, temperaturIconHeight)
self.gameInfoDisplay.temperaturUp:setColor(unpack(HUD.COLOR.ACTIVE))
self.gameInfoDisplay.temperaturDown = g_overlayManager:createOverlay("ui_elements.thermometerDown", 0, temperaturPositionY, temperaturIconWidth, temperaturIconHeight)
self.gameInfoDisplay.temperaturDown:setColor(unpack(HUD.COLOR.ACTIVE))
end

---Overwrite GameInfoDisplay.draw()
---@param overwrittenFunc function
function ExtendedGameInfoDisplay:gameinfodisplay__draw(overwrittenFunc)
overwrittenFunc(self)

local weatherType = g_currentMission.environment.weather:getCurrentWeatherType()
local forcastDayTime = math.floor(g_currentMission.environment.dayTime + ExtendedGameInfoDisplay.WEATHER_HOURS_FORECAST )
local forcastDay = g_currentMission.environment.currentDay
if forcastDayTime > ExtendedGameInfoDisplay.HOURS_A_DAY then
forcastDayTime = forcastDayTime - ExtendedGameInfoDisplay.HOURS_A_DAY
forcastDay = forcastDay + 1
end

local nextWeatherType = g_currentMission.environment.weather:getNextWeatherType(forcastDay, forcastDayTime )

-- Strech the background and render new!
self.infoBgScale.width = self:scalePixelToScreenWidth(ExtendedGameInfoDisplay.STRECH_GAME_INFO_DISPLAY)
self.infoBgScale.offsetX = -self:scalePixelToScreenWidth(ExtendedGameInfoDisplay.STRECH_GAME_INFO_DISPLAY)
self.infoBgScale:render()

-- ReRender to bring it back to top
self.weatherIcon:render()
self.weatherNextIcon:render()
self.weatherNextIcon:setVisible(weatherType ~= nextWeatherType)

ExtendedGameInfoDisplay:setTemperaturPosition(self)
ExtendedGameInfoDisplay:setTemperaturTrendAndDraw(self)
ExtendedGameInfoDisplay:drawYearText(self)
ExtendedGameInfoDisplay:drawTemperaturText(self)
end

function ExtendedGameInfoDisplay:setTemperaturPosition(gameInfoDisplay)
local referencePositionX = gameInfoDisplay.calendarIcon.x - gameInfoDisplay:scalePixelToScreenHeight(65)
gameInfoDisplay.temperatur.x = referencePositionX
gameInfoDisplay.temperaturUp.x = referencePositionX
gameInfoDisplay.temperaturDown.x = referencePositionX
end

function ExtendedGameInfoDisplay:setTemperaturTrendAndDraw(gameInfoDisplay)
local temperaturTrend = g_currentMission.environment.weather:getCurrentTemperatureTrend()

gameInfoDisplay.temperatur:setVisible(temperaturTrend == 0)
gameInfoDisplay.temperaturUp:setVisible(temperaturTrend > 0)
gameInfoDisplay.temperaturDown:setVisible(temperaturTrend < 0)

gameInfoDisplay.temperatur:draw()
gameInfoDisplay.temperaturUp:draw()
gameInfoDisplay.temperaturDown:draw()

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

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

function ExtendedGameInfoDisplay:drawTemperaturText(gameInfoDisplay)
local minTemperaturInC, maxTemperaturInC = g_currentMission.environment.weather:getCurrentMinMaxTemperatures()
local currentTemperaturInC = g_currentMission.environment.weather:getCurrentTemperature()

local minTemperaturExpanded = g_i18n:getTemperature(minTemperaturInC)
local maxTemperaturExpanded = g_i18n:getTemperature(maxTemperaturInC)
local currentTemperaturExpanded = g_i18n:getTemperature(currentTemperaturInC)

local scaledTextSizeForCurrentTemperatur = gameInfoDisplay:scalePixelToScreenHeight(19)
local scaledTextSizeForTemperatur = gameInfoDisplay:scalePixelToScreenHeight(14)

local temperaturTextX = gameInfoDisplay.temperatur.x + gameInfoDisplay.temperatur.width + gameInfoDisplay:scalePixelToScreenWidth(40)
local temperaturTextY = gameInfoDisplay.temperatur.y + gameInfoDisplay.temperatur.height + gameInfoDisplay:scalePixelToScreenHeight(2)

setTextBold(false)
setTextAlignment(RenderText.ALIGN_RIGHT)

renderText(temperaturTextX, temperaturTextY - gameInfoDisplay:scalePixelToScreenHeight(22), scaledTextSizeForCurrentTemperatur, string.format('%d°', currentTemperaturExpanded))
renderText(temperaturTextX, temperaturTextY - gameInfoDisplay:scalePixelToScreenHeight(38), scaledTextSizeForTemperatur, string.format('%d°/%d°', maxTemperaturExpanded, minTemperaturExpanded))
end

function ExtendedGameInfoDisplay:drawYearText(gameInfoDisplay)
local monthTextSize = gameInfoDisplay:scalePixelToScreenHeight(10)
local scaledTextSizeForYear = gameInfoDisplay:scalePixelToScreenHeight(12)

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

local l10nTextYear = g_i18n:getText(ExtendedGameInfoDisplay.L10N_SYMBOLS.YEAR_TEXT, ExtendedGameInfoDisplay.CURRENT_MOD)

setTextBold(false)
setTextAlignment(RenderText.ALIGN_LEFT)

renderText(posX, posY, scaledTextSizeForYear, string.format('%s %s', l10nTextYear, g_currentMission.environment.currentYear))
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

init()
8 changes: 8 additions & 0 deletions FS25_ExtendedGameInfoDisplay/translations/l10n_cz.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<l10n>
<translationContributors>SniperKittenCz</translationContributors>
<elements>
<e k="mod_title" v="Rozšířený herní info displej"/>
<e k="yearinfo_current_year" v="Rok"/>
</elements>
</l10n>
8 changes: 8 additions & 0 deletions FS25_ExtendedGameInfoDisplay/translations/l10n_de.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<l10n>
<translationContributors>Peppie84</translationContributors>
<elements>
<e k="mod_title" v="Erweiterte Spiel-Infodarstellung"/>
<e k="yearinfo_current_year" v="Jahr"/>
</elements>
</l10n>
8 changes: 8 additions & 0 deletions FS25_ExtendedGameInfoDisplay/translations/l10n_en.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<l10n>
<translationContributors>Peppie84</translationContributors>
<elements>
<e k="mod_title" v="Extended Game Infodisplay"/>
<e k="yearinfo_current_year" v="Year"/>
</elements>
</l10n>
8 changes: 8 additions & 0 deletions FS25_ExtendedGameInfoDisplay/translations/l10n_es.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<l10n>
<translationContributors>Ferchu425</translationContributors>
<elements>
<e k="mod_title" v="Extended Game Infodisplay"/>
<e k="yearinfo_current_year" v="Año"/>
</elements>
</l10n>
8 changes: 8 additions & 0 deletions FS25_ExtendedGameInfoDisplay/translations/l10n_fr.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<l10n>
<translationContributors>Rudolfet</translationContributors>
<elements>
<e k="mod_title" v="Affichage &eacute;tendu des informations sur le jeu"/>
<e k="yearinfo_current_year" v="Ann&eacute;e"/>
</elements>
</l10n>
8 changes: 8 additions & 0 deletions FS25_ExtendedGameInfoDisplay/translations/l10n_hu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<l10n>
<translationContributors>Petrovics Zsombor</translationContributors>
<elements>
<e k="mod_title" v="Kibővített Információs Sáv"/>
<e k="yearinfo_current_year" v="Év"/>
</elements>
</l10n>
8 changes: 8 additions & 0 deletions FS25_ExtendedGameInfoDisplay/translations/l10n_it.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<l10n>
<translationContributors>Rudolfet</translationContributors>
<elements>
<e k="mod_title" v="Visualizzazione estesa delle informazioni sul gioco"/>
<e k="yearinfo_current_year" v="Anno"/>
</elements>
</l10n>
8 changes: 8 additions & 0 deletions FS25_ExtendedGameInfoDisplay/translations/l10n_pl.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<l10n>
<translationContributors>dexus</translationContributors>
<elements>
<e k="mod_title" v="Extended Game Infodisplay"/>
<e k="yearinfo_current_year" v="Rok"/>
</elements>
</l10n>
8 changes: 8 additions & 0 deletions FS25_ExtendedGameInfoDisplay/translations/l10n_ru.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<l10n>
<translationContributors>nagor</translationContributors>
<elements>
<e k="mod_title" v="Extended Game Infodisplay"/>
<e k="yearinfo_current_year" v="Год"/>
</elements>
</l10n>
File renamed without changes.
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,39 @@
# FS25_ExtendedGameInfoDisplay
<a name="readme-top"></a>

<div align="center">

[![FarmingSimulator-25](https://img.shields.io/badge/FarmingSimulator-25-73A302?style=flat-square)](https://www.farming-simulator.com/mods.php?title=fs2025)
[![Last commit](https://img.shields.io/github/last-commit/Peppie84/FS25_ExtendedGameInfoDisplay?style=flat-square&color=important)](https://github.com/Peppie84/FS25_ExtendedGameInfoDisplay/commits/development)
[![Modhub Version](https://img.shields.io/badge/Modhub-v1.0.0.0-green?style=flat-square)](waiting-for-modhub)
[![GitHub issues](https://img.shields.io/github/issues/Peppie84/FS25_ExtendedGameInfoDisplay?style=flat-square)](https://github.com/Peppie84/FS25_ExtendedGameInfoDisplay/issues)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue?style=flat-square)](https://www.gnu.org/licenses/gpl-3.0)
[![Top language](https://img.shields.io/github/languages/top/Peppie84/FS25_ExtendedGameInfoDisplay?style=flat-square&color=blueviolet)](https://github.com/search?q=repo%3APeppie84%FS25_ExtendedGameInfoDisplay++language%3ALua&type=code)


<br />

<a href="waiting-for-modhub">
<img src="documents/icon_ExGameInfoDisp.png" style="width: 250px;">
</a>

<h3 align="center"><u>FS25_ExtendedGameInfoDisplay</u></h3>

<p align="center">
Expands the current GameInfoDisplay in the upper right corner by displaying the current year under the date and activates a hidden temperature feature with an indicator of whether the temperature is falling, staying constant or rising, the display of the current temperature. I also added the min/max temperature of the day.
</p>

</div>

<div align='center'>
<img src="documents/screen2-v1.0.0.0.png" style="width: 50%;">
</div>

## Credits
* Woeller ([Youtube](https://www.youtube.com/@woeller))
* Sqeep

# Copyright
Copyright (c) 2024 [Dennis Schmitt](https://github.com/peppie84).
All rights reserved.

<p align="right">(<a href="#readme-top">back to top</a>)</p>
Binary file added documents/Screens.afdesign
Binary file not shown.
Binary file added documents/icon_ExGameInfoDisp.afdesign
Binary file not shown.
Binary file added documents/icon_ExGameInfoDisp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documents/screen1-v1.0.0.0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documents/screen2-v1.0.0.0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documents/screen3-v1.0.0.0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit fc137ba

Please sign in to comment.