Skip to content

Commit

Permalink
Merge pull request #177 from Stephan-S/dev_RC (Release 3.0.0.4)
Browse files Browse the repository at this point in the history
Release 3.0.0.4
  • Loading branch information
Iwan1803 authored Jan 31, 2025
2 parents e0563c4 + 877728b commit be7f560
Show file tree
Hide file tree
Showing 12 changed files with 265 additions and 167 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# FS25_AutoDrive
FS25 version of the AutoDrive mod

### Latest Release: 3.0.0.2
### Latest Release: 3.0.0.4
![GitHub all releases](https://img.shields.io/github/downloads/Stephan-S/FS25_AutoDrive/total?label=Downloads&style=plastic)
Direct Download: https://github.com/Stephan-S/FS25_AutoDrive/releases/latest/download/FS25_AutoDrive.zip

Expand Down
2 changes: 1 addition & 1 deletion modDesc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Changelog: Необходимые корректировки для FS25, нас
]]>
</ru>
</description>
<version>3.0.0.2</version>
<version>3.0.0.4</version>
<multiplayer supported="true" />
<iconFilename>icon_AutoDrive.dds</iconFilename>
<extraSourceFiles>
Expand Down
6 changes: 4 additions & 2 deletions scripts/AutoDrive.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AutoDrive = {}
AutoDrive.version = "3.0.0.2"
AutoDrive.version = "3.0.0.4"

AutoDrive.directory = g_currentModDirectory

Expand Down Expand Up @@ -218,7 +218,8 @@ function AutoDrive:loadMap(name)
AutoDrive.Hud:loadHud()

-- Save Configuration when saving savegame
FSBaseMission.saveSavegame = Utils.appendedFunction(FSBaseMission.saveSavegame, AutoDrive.saveSavegame)
-- Fix for 1.5 - FSBaseMission.saveSavegame = Utils.appendedFunction(FSBaseMission.saveSavegame, AutoDrive.saveSavegame)
ItemSystem.save = Utils.prependedFunction(ItemSystem.save, AutoDrive.saveSavegame)

LoadTrigger.onFillTypeSelection = Utils.appendedFunction(LoadTrigger.onFillTypeSelection, AutoDrive.onFillTypeSelection)

Expand Down Expand Up @@ -531,6 +532,7 @@ function AutoDrive:init()
loadSample(AutoDrive.selectedWayPointSample, fileName, false)
end
AutoDrivePlaceableData:setActive(true)
AutoDrive:setValidSupportedFillTypesForAllVehicles()
AutoDrive:autostartHelpers()
end

Expand Down
71 changes: 67 additions & 4 deletions scripts/Hud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ end

function AutoDriveHud:mouseEvent(vehicle, posX, posY, isDown, isUp, button)
local mouseActiveForAutoDrive = (g_gui.currentGui == nil or AutoDrive.aiFrameOpen) and (g_inputBinding:getShowMouseCursor() == true)

if mouseActiveForAutoDrive then
local mouseEventHandled = false
local silent = false
Expand Down Expand Up @@ -461,10 +461,56 @@ function AutoDriveHud:mouseEvent(vehicle, posX, posY, isDown, isUp, button)
AutoDrive.resetMouseSelections(vehicle)
end

vehicle.ad.hoveredNodeId = nil
vehicle.ad.hoveredNodeId = nil
vehicle.ad.sectionWayPoints = {}
local adjustedPaths = false
if (not mouseEventHandled) and AutoDrive.isInExtendedEditorMode() and g_gui.currentGui == nil then
vehicle.ad.selectionRange = vehicle.ad.selectionRange or 1 -- start with 1m range
local adjustedPaths = false
if (not mouseEventHandled) and AutoDrive.isInExtendedEditorMode() and g_gui.currentGui == nil then
if
not AutoDrive.leftLSHIFTmodifierKeyPressed
and not AutoDrive.leftCTRLmodifierKeyPressed
and AutoDrive.leftALTmodifierKeyPressed
and not AutoDrive.rightSHIFTmodifierKeyPressed
and vehicle.ad.newcreated == nil
and vehicle.ad.selectedNodeId ~= nil
then
-- selected node and LALT pressed
AutoDriveHud.debugMsg(vehicle, "AutoDriveHud:mouseEvent selection start")
AutoDrive.mouseWheelActive = true
if button == 4 and isUp and vehicle.ad.selectionRange > 1 then
AutoDriveHud.debugMsg(vehicle, "AutoDriveHud:mouseEvent decrement")
-- decrement range
vehicle.ad.selectionActive = true
vehicle.ad.selectionRange = vehicle.ad.selectionRange - 0.5
vehicle.ad.selectionWayPoints = self:getSelectionWayPoints(vehicle)
elseif button == 5 and isUp and vehicle.ad.selectionRange < AutoDrive.drawDistance / 2 then
AutoDriveHud.debugMsg(vehicle, "AutoDriveHud:mouseEvent increment")
-- increment range
vehicle.ad.selectionActive = true
vehicle.ad.selectionRange = vehicle.ad.selectionRange + 0.5
vehicle.ad.selectionWayPoints = self:getSelectionWayPoints(vehicle)
elseif vehicle.ad.selectionActive then
-- activated again
vehicle.ad.selectionWayPoints = self:getSelectionWayPoints(vehicle)
end
if button == 1 and isUp and vehicle.ad.selectionActive then
-- delete selected wayPoints
AutoDriveHud.debugMsg(vehicle, "AutoDriveHud:mouseEvent delete selection")
ADGraphManager:deleteWayPointsInSelection(vehicle)
vehicle:resetWayPointsDistance()
vehicle.ad.selectedNodeId = nil
end
else
-- clear selection wayPoints
if vehicle.ad.selectionWayPoints and #vehicle.ad.selectionWayPoints > 0 then
for _, wayPointId in pairs(vehicle.ad.selectionWayPoints) do
local wayPoint = ADGraphManager:getWayPointById(wayPointId)
wayPoint.isSelected = false
end
vehicle.ad.selectionWayPoints = {}
end
end

if
not AutoDrive.leftLSHIFTmodifierKeyPressed
and not AutoDrive.leftCTRLmodifierKeyPressed
Expand Down Expand Up @@ -879,6 +925,23 @@ function AutoDriveHud:deleteMapHotspot(vehicle)
end
end

function AutoDriveHud:getSelectionWayPoints(vehicle)
local selectionWayPoints = {}
if vehicle.ad.selectionActive and vehicle.ad.selectedNodeId then
local selectedWayPoint = ADGraphManager:getWayPointById(vehicle.ad.selectedNodeId)
for _, elem in pairs(AutoDrive.getWayPointsDistance(vehicle)) do
local distance = MathUtil.vector2Length(elem.wayPoint.x - selectedWayPoint.x , elem.wayPoint.z - selectedWayPoint.z)
if distance <= vehicle.ad.selectionRange then
elem.wayPoint.isSelected = true
table.insert(selectionWayPoints, elem.wayPoint.id)
else
elem.wayPoint.isSelected = false
end
end
end
return selectionWayPoints
end

function AutoDrive:ingameMapElementMouseEvent(superFunc, posX, posY, isDown, isUp, button, eventUsed)
eventUsed = superFunc(self, posX, posY, isDown, isUp, button, eventUsed)

Expand Down
19 changes: 19 additions & 0 deletions scripts/Manager/GraphManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1704,6 +1704,25 @@ function ADGraphManager:deleteWayPointsInSection(vehicle)
end
end

function ADGraphManager:deleteWayPointsInSelection(vehicle)
if vehicle.ad.selectionWayPoints and #vehicle.ad.selectionWayPoints > 0 then
-- delete the wayPoints
local pointsToDelete = {}
for i = 1, #vehicle.ad.selectionWayPoints do
table.insert(pointsToDelete, vehicle.ad.selectionWayPoints[i])
end
-- sort the wayPoints to delete in descant order to ensure correct linkage deletion
local sort_func = function(a, b)
return a > b
end
table.sort(pointsToDelete, sort_func)
for i = 1, #pointsToDelete do
ADGraphManager:removeWayPoint(pointsToDelete[i])
end
vehicle.ad.selectionWayPoints = {}
end
end

function ADGraphManager:deleteColorSelectionWayPoints()
-- delete the color selection wayPoints in descant order to ensure correct linkage deletion
local actualID = self:getWayPointsCount()
Expand Down
1 change: 1 addition & 0 deletions scripts/Manager/RoutesManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function ADRoutesManager:load()
createFolder(self.managerFolder)
self.routesFolder = self.managerFolder .. "routes/"
createFolder(self.routesFolder)
Logging.info("[AD] RoutesManager folder: '" .. self.routesFolder .. "'")

self.cfnFile = self.managerFolder .. "reload.cfn"

Expand Down
13 changes: 9 additions & 4 deletions scripts/Specialization.lua
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ function AutoDrive:onDrawEditorMode()
if AutoDrive.isInExtendedEditorMode() then
arrowPosition = DrawingManager.arrows.position.middle
if AutoDrive.enableSphere == true then
if AutoDrive.mouseIsAtPos(point, 0.01) then
if AutoDrive.mouseIsAtPos(point, 0.01) or point.isSelected then
DrawingManager:addSphereTask(x, y, z, 3, unpack(AutoDrive.currentColors.ad_color_hoveredNode))
else
if point.id == self.ad.selectedNodeId then
Expand Down Expand Up @@ -1052,6 +1052,14 @@ function AutoDrive:onDrawEditorMode()
end
end
end

if AutoDrive.isInExtendedEditorMode() and AutoDrive.enableSphere == true then
if self.ad.selectionWayPoints and #self.ad.selectionWayPoints > 0 then
-- draw range circle for selection wayPoints
local selectedWayPoint = ADGraphManager:getWayPointById(self.ad.selectedNodeId)
DebugUtil.drawDebugCircle(selectedWayPoint.x, selectedWayPoint.y, selectedWayPoint.z, self.ad.selectionRange, 30, AutoDrive.currentColors.ad_color_hoveredNode, true)
end
end
end

function AutoDrive:startAutoDrive()
Expand Down Expand Up @@ -1670,9 +1678,6 @@ function AutoDrive:updateAutoDriveLights(switchOff)
if AutoDrive.getSetting("useHazardLightReverse", self) and self.setTurnLightState then
self:setTurnLightState(Lights.TURNLIGHT_OFF)
end
if self.updateAutomaticLights ~= nil then
self:updateAutomaticLights(false, false)
end
elseif self.ad ~= nil and self.ad.stateModule:isActive() then
local isInRangeToLoadUnloadTarget = false
local isInBunkerSilo = false
Expand Down
10 changes: 9 additions & 1 deletion scripts/Utils/TrailerUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ function AutoDrive.getValidSupportedFillTypes(vehicle, excludedVehicles)
end

function AutoDrive.setValidSupportedFillType(vehicle, excludedImplementIndex)
if vehicle == nil then
if vehicle == nil or vehicle.ad == nil or vehicle.ad.stateModule == nil or AutoDrive.isFirstRun == nil then
return
end

Expand Down Expand Up @@ -1099,4 +1099,12 @@ function AutoDrive.setValidSupportedFillType(vehicle, excludedImplementIndex)
end

return ret
end

function AutoDrive:setValidSupportedFillTypesForAllVehicles()
-- This is called once via AutoDrive:init. We initially suppress filltype updates to deal with
-- the random order of onPostAttachImplement calls. This function repeats those suppressed calls.
for _, vehicle in pairs(self:getAllVehicles()) do
self:setValidSupportedFillType(vehicle)
end
end
6 changes: 3 additions & 3 deletions translations/translation_de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@
<text name="gui_ad_pathfinder_custom" text="AutoDrive Spezial" />
<text name="gui_ad_enableRoutesManagerOnDediServer" text="Routenmanager im Server" />
<text name="gui_ad_enableRoutesManagerOnDediServer_tooltip" text="Aktiviert die Nutzung des Routenmanagers auf einem dedizierten Server." />
<text name="gui_ad_autostartHelpers" text="Autostart helpers" />
<text name="gui_ad_autostartHelpers_tooltip" text="Automatically restart active helpers after loading a savegame" />
<text name="gui_ad_autostartHelpers" text="Autostart AD-Helfer" />
<text name="gui_ad_autostartHelpers_tooltip" text="Automatischer Neustart aktiver AD-Helfer nach dem Laden eines Spielstands" />
<text name="gui_ad_detectSwath" text="Schwaderkennung" />
<text name="gui_ad_detectSwath_tooltip" text="Legt fest, ob das Fahrzeug Grasschwaden als Frucht erkennt." />
<text name="gui_ad_colorAssignmentMode" text="Personalisierte Farben" />
Expand Down Expand Up @@ -376,4 +376,4 @@
<text name="gui_ad_editorTip_10" text="LSTRG: Streckentyp wechseln" />
<text name="gui_ad_editorTip_11" text="LSHIFT = Nebenstrecke wechseln" />
</texts>
</l10n>
</l10n>
Loading

0 comments on commit be7f560

Please sign in to comment.