Skip to content

Commit

Permalink
Merge pull request #934 from Stephan-S/dev-iwan
Browse files Browse the repository at this point in the history
Release 2.0.1.2
  • Loading branch information
Iwan1803 authored Jul 21, 2023
2 parents f82dc79 + 0baaa6c commit e9084e7
Show file tree
Hide file tree
Showing 45 changed files with 742 additions and 246 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# FS22_AutoDrive
FS22 version of the AutoDrive mod

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

## Discord Server:
For help & support, feel free to join us on Discord:
Expand Down
5 changes: 3 additions & 2 deletions modDesc.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<modDesc descVersion="72">
<modDesc descVersion="75">
<author>AutoDrive Team</author>
<title>
<en>AutoDrive</en>
Expand Down Expand Up @@ -32,7 +32,7 @@ Différents modes d'utilisation ont été ajoutés depuis les premières version
<![CDATA[Этот мод может быть использован для создания сети маршрутов для транспортных средств для автономного вождения. После настройки вы можете указать трактору, стоящему где-угодно рядом с сетью, проехать в любую точку, например, в магазин, поле №1 или в точку продажи.]]>
</ru>
</description>
<version>2.0.1.0</version>
<version>2.0.1.2</version>
<multiplayer supported="true" />
<iconFilename>icon.dds</iconFilename>
<extraSourceFiles>
Expand Down Expand Up @@ -92,6 +92,7 @@ Différents modes d'utilisation ont été ajoutés depuis les premières version
<action name="ADToggleHudExtension" category="VEHICLE" ignoreComboMask="false" />
<action name="ADToggleAutomaticUnloadTarget" category="VEHICLE" ignoreComboMask="false" />
<action name="ADToggleAutomaticPickupTarget" category="VEHICLE" ignoreComboMask="false" />
<action name="ADToggleLoadByFillLevel" category="VEHICLE" ignoreComboMask="false" />
<action name="ADRepairVehicle" category="VEHICLE" ignoreComboMask="false" />
</actions>

Expand Down
38 changes: 19 additions & 19 deletions scripts/AutoDrive.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AutoDrive = {}
AutoDrive.version = "2.0.1.0"
AutoDrive.version = "2.0.1.2"

AutoDrive.directory = g_currentModDirectory

Expand All @@ -11,7 +11,7 @@ AutoDrive.experimentalFeatures = {}
AutoDrive.experimentalFeatures.redLinePosition = false
-- AutoDrive.experimentalFeatures.telemetryOutput = false
AutoDrive.experimentalFeatures.enableRoutesManagerOnDediServer = false
AutoDrive.experimentalFeatures.detectGrasField = true
AutoDrive.experimentalFeatures.detectSwath = true
AutoDrive.experimentalFeatures.colorAssignmentMode = false
AutoDrive.experimentalFeatures.UTurn = true
AutoDrive.experimentalFeatures.FoldImplements = true
Expand Down Expand Up @@ -289,7 +289,7 @@ function AutoDrive:refreshContextInputAIFrame()
end

function AutoDrive:drawBaseMission()
if AutoDrive.aiFrameOpen then
if AutoDrive.aiFrameOpen then
AutoDrive:drawRouteOnMap()
AutoDrive.drawNetworkOnMap()
if AutoDrive.aiFrameVehicle ~= nil then
Expand Down Expand Up @@ -355,20 +355,20 @@ function AutoDrive.drawRouteOnMap()
if lastWp ~= nil and index >= currentWp then
local startX, startY, _, _ = AutoDrive.getScreenPosFromWorldPos(lastWp.x, lastWp.z)
local endX, endY, _, _ = AutoDrive.getScreenPosFromWorldPos(wp.x, wp.z)

if startX and startY and endX and endY then
dx2D = endX - startX;
dy2D = ( endY - startY ) / g_screenAspectRatio;
width = MathUtil.vector2Length(dx2D, dy2D);

dx = wp.x - lastWp.x;
dz = wp.z - lastWp.z;
rotation = MathUtil.getYRotationFromDirection(dx, dz) - math.pi * 0.5;

local lineThickness = 2 / g_screenHeight
setOverlayColor( AutoDrive.courseOverlayId, 0.3, 0.5, 0.56, 1)
setOverlayRotation( AutoDrive.courseOverlayId, rotation, 0, 0)

renderOverlay( AutoDrive.courseOverlayId, startX, startY, width, lineThickness )
end
setOverlayRotation( AutoDrive.courseOverlayId, 0, 0, 0 ) -- reset overlay rotation
Expand Down Expand Up @@ -407,34 +407,34 @@ function AutoDrive.drawNetworkOnMap()
local outNode = network[outNodeId]
local startX, startY, _, _ = AutoDrive.getScreenPosFromWorldPos(node.x, node.z)
local endX, endY, _, _ = AutoDrive.getScreenPosFromWorldPos(outNode.x, outNode.z)

if startX and startY and endX and endY then
dx2D = endX - startX;
dy2D = ( endY - startY ) / g_screenAspectRatio;
width = MathUtil.vector2Length(dx2D, dy2D);

dx = outNode.x - node.x;
dz = outNode.z - node.z;
rotation = MathUtil.getYRotationFromDirection(dx, dz) - math.pi * 0.5;

local lineThickness = 2 / g_screenHeight
local r, g, b, a = unpack(AutoDrive.currentColors.ad_color_singleConnection)

if isSubPrio(outNode) then
r, g, b, a = unpack(AutoDrive.currentColors.ad_color_subPrioSingleConnection)
end

if ADGraphManager:isDualRoad(node, outNode) then
r, g, b, a = unpack(AutoDrive.currentColors.ad_color_dualConnection)
if isSubPrio(outNode) then
r, g, b, a = unpack(AutoDrive.currentColors.ad_color_subPrioDualConnection)
end
elseif ADGraphManager:isReverseRoad(start, target) then
end
elseif ADGraphManager:isReverseRoad(start, target) then
r, g, b, a = unpack(AutoDrive.currentColors.ad_color_reverseConnection)
end
setOverlayColor( AutoDrive.courseOverlayId, r, g, b, a)
setOverlayRotation( AutoDrive.courseOverlayId, rotation, 0, 0)

renderOverlay( AutoDrive.courseOverlayId, startX, startY, width, lineThickness )
end
setOverlayRotation( AutoDrive.courseOverlayId, 0, 0, 0 ) -- reset overlay rotation
Expand All @@ -448,7 +448,7 @@ function AutoDrive.getScreenPosFromWorldPos(worldX, worldZ)
local objectX = (worldX + AutoDrive.aiFrame.ingameMapBase.worldCenterOffsetX) / AutoDrive.aiFrame.ingameMapBase.worldSizeX * 0.5 + 0.25
local objectZ = (worldZ + AutoDrive.aiFrame.ingameMapBase.worldCenterOffsetZ) / AutoDrive.aiFrame.ingameMapBase.worldSizeZ * 0.5 + 0.25
local x, y, _, _ = AutoDrive.aiFrame.ingameMapBase.layout:getMapObjectPosition(objectX, objectZ, 0, 0, 0, true)

return x, y
end

Expand Down Expand Up @@ -557,7 +557,7 @@ end
function AutoDrive:mouseEvent(posX, posY, isDown, isUp, button)
local vehicle = AutoDrive.getADFocusVehicle()
local mouseActiveForAutoDrive = (g_gui.currentGui == nil or AutoDrive.aiFrameOpen) and (g_inputBinding:getShowMouseCursor() == true)

if not mouseActiveForAutoDrive then
AutoDrive.lastButtonDown = nil
return
Expand Down Expand Up @@ -591,7 +591,7 @@ function AutoDrive:mouseEvent(posX, posY, isDown, isUp, button)
end
end

function AutoDrive:update(dt)
function AutoDrive:update(dt)
if AutoDrive.scanDialogState == AutoDrive.SCAN_DIALOG_NONE and ADGraphManager:getWayPointsCount() == 0 then
if g_server ~= nil and g_dedicatedServer == nil then
-- open dialog
Expand Down Expand Up @@ -657,7 +657,7 @@ function AutoDrive:update(dt)
ADTriggerManager:update(dt)
ADRoutesManager:update(dt)

-- AutoDrive.handleTelemetry(dt)
-- AutoDrive.handleTelemetry(dt)
end

function AutoDrive:draw()
Expand Down
24 changes: 24 additions & 0 deletions scripts/Events/HudInputEvent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ AutoDriveHudInputEventEvent = {}
AutoDriveHudInputEventEvent.TYPE_FIRST_MARKER = 1
AutoDriveHudInputEventEvent.TYPE_SECOND_MARKER = 2
AutoDriveHudInputEventEvent.TYPE_FILLTYPE = 3
AutoDriveHudInputEventEvent.TYPE_TOGGLE_FILLTYPE_SELECTION = 4
AutoDriveHudInputEventEvent.TYPE_TOGGLE_ALL_FILLTYPE_SELECTIONS = 5

AutoDriveHudInputEventEvent_mt = Class(AutoDriveHudInputEventEvent, Event)

Expand Down Expand Up @@ -53,6 +55,14 @@ function AutoDriveHudInputEventEvent:run(connection)
if self.eventType == self.TYPE_FILLTYPE then
self.vehicle.ad.stateModule:setFillType(self.value)
end

if self.eventType == self.TYPE_TOGGLE_FILLTYPE_SELECTION then
self.vehicle.ad.stateModule:toggleFillTypeSelection(self.value)
end

if self.eventType == self.TYPE_TOGGLE_ALL_FILLTYPE_SELECTIONS then
self.vehicle.ad.stateModule:toggleAllFillTypeSelections(self.value)
end
end
end

Expand All @@ -76,3 +86,17 @@ function AutoDriveHudInputEventEvent:sendFillTypeEvent(vehicle, fillTypeId)
g_client:getServerConnection():sendEvent(AutoDriveHudInputEventEvent.new(vehicle, self.TYPE_FILLTYPE, fillTypeId))
end
end

function AutoDriveHudInputEventEvent:sendToggleFillTypeSelectionEvent(vehicle, fillTypeId)
if g_client ~= nil then
-- Client have to send to server
g_client:getServerConnection():sendEvent(AutoDriveHudInputEventEvent.new(vehicle, self.TYPE_TOGGLE_FILLTYPE_SELECTION, fillTypeId))
end
end

function AutoDriveHudInputEventEvent:sendToggleAllFillTypeSelectionsEvent(vehicle, fillTypeId)
if g_client ~= nil then
-- Client have to send to server
g_client:getServerConnection():sendEvent(AutoDriveHudInputEventEvent.new(vehicle, self.TYPE_TOGGLE_ALL_FILLTYPE_SELECTIONS, fillTypeId))
end
end
Loading

0 comments on commit e9084e7

Please sign in to comment.