Skip to content

Commit

Permalink
Merge pull request #1090 from Stephan-S/dev-iwan
Browse files Browse the repository at this point in the history
AutoDrive 2.0.1.6
  • Loading branch information
Iwan1803 authored Feb 27, 2024
2 parents 1eb6f65 + fe7706c commit f8ecba3
Show file tree
Hide file tree
Showing 86 changed files with 2,079 additions and 1,326 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# FS22_AutoDrive
FS22 version of the AutoDrive mod

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

Expand All @@ -18,13 +18,12 @@ And to all who do donate: Thank you very much :-)
#### Stephan (Founder):
https://www.paypal.me/StephanSchlosser

#### Axel (Modder)

#### Iwan1803 (Community Manager, Supporter & Tester):
https://www.tipeeestream.com/iwan1803/tip
https://iwan1803.de/urls/tip

#### Willi (Supporter & Tester)
#### Axel & Tommo (Modder)

#### Willi (Supporter & Tester)

## Course Editor
The course editor is now maintained by @KillBait and can be found here:
Expand Down
8 changes: 8 additions & 0 deletions gui/settingsPage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@
<GuiElement type="bitmap" profile="multiTextOptionSettingsBg" />
<GuiElement type="bitmap" profile="baseReference" position="730px 0px" size="50px 50px"/>
</GuiElement>
<GuiElement type="multiTextOption" profile="multiTextOptionSettings" onCreate="onCreateAutoDriveSetting" onClick="onOptionChange" name="BSMRange" toolTipElementId="ingameMenuHelpBoxText">
<GuiElement type="button" profile="multiTextOptionSettingsLeft" />
<GuiElement type="button" profile="multiTextOptionSettingsRight" />
<GuiElement type="text" profile="multiTextOptionSettingsText" />
<GuiElement type="text" profile="multiTextOptionSettingsTitle" position="27px 0px" />
<GuiElement type="bitmap" profile="multiTextOptionSettingsBg" />
<GuiElement type="bitmap" profile="baseReference" position="730px 0px" size="50px 50px"/>
</GuiElement>
</GuiElement>
</GuiElement>

Expand Down
8 changes: 8 additions & 0 deletions gui/vehicleSettingsPage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@
<GuiElement type="bitmap" profile="multiTextOptionSettingsBg" />
<GuiElement type="bitmap" profile="baseReference" position="730px 0px" size="50px 50px"/>
</GuiElement>
<GuiElement type="multiTextOption" profile="multiTextOptionSettings" onCreate="onCreateAutoDriveSetting" onClick="onOptionChange" name="maxTriggerDistanceVehicle" toolTipElementId="ingameMenuHelpBoxText">
<GuiElement type="button" profile="multiTextOptionSettingsLeft" />
<GuiElement type="button" profile="multiTextOptionSettingsRight" />
<GuiElement type="text" profile="multiTextOptionSettingsText" />
<GuiElement type="text" profile="multiTextOptionSettingsTitle" position="27px 0px" />
<GuiElement type="bitmap" profile="multiTextOptionSettingsBg" />
<GuiElement type="bitmap" profile="baseReference" position="730px 0px" size="50px 50px"/>
</GuiElement>
</GuiElement>
</GuiElement>
<GuiElement type="bitmap" profile="ingameMenuHelpRowBg" position="210px -64px" id="ingameMenuHelpBox" visible="false">
Expand Down
4 changes: 2 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="75">
<modDesc descVersion="79">
<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.4</version>
<version>2.0.1.6</version>
<multiplayer supported="true" />
<iconFilename>icon.dds</iconFilename>
<extraSourceFiles>
Expand Down
2 changes: 2 additions & 0 deletions register.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ source(Utils.getFilename("scripts/TelemetryExport.lua", g_currentModDirectory))

source(Utils.getFilename("scripts/Hud/GenericHudElement.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/Hud/HudButton.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/Hud/HudCounterButton.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/Hud/HudSettingsButton.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/Hud/HudIcon.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/Hud/HudSpeedmeter.lua", g_currentModDirectory))
Expand Down Expand Up @@ -79,6 +80,7 @@ source(Utils.getFilename("scripts/Manager/UserDataManager.lua", g_currentModDire
source(Utils.getFilename("scripts/Manager/MultipleTargetsManager.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/Manager/ThirdPartyModsManager.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/Manager/Scheduler.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/Manager/BunkerSiloManager.lua", g_currentModDirectory))

source(Utils.getFilename("scripts/Tasks/AbstractTask.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/Tasks/DriveToDestinationTask.lua", g_currentModDirectory))
Expand Down
18 changes: 15 additions & 3 deletions scripts/AutoDrive.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AutoDrive = {}
AutoDrive.version = "2.0.1.4"
AutoDrive.version = "2.0.1.6"

AutoDrive.directory = g_currentModDirectory

Expand Down Expand Up @@ -92,6 +92,11 @@ AutoDrive.FLAG_TRAFFIC_SYSTEM_CONNECTION = 4
-- add this to measured size of vehicles
AutoDrive.DIMENSION_ADDITION = 0.2

-- AD invoked by which type of user
AutoDrive.USER_PLAYER = 1
AutoDrive.USER_GIANTS = 2
AutoDrive.USER_CP = 3

AutoDrive.colors = {
ad_color_singleConnection = {0, 1, 0, 1},
ad_color_dualConnection = {0, 0, 1, 1},
Expand All @@ -107,8 +112,13 @@ AutoDrive.colors = {
ad_color_currentConnection = {1, 1, 1, 1},
ad_color_closestLine = {1, 0, 0, 1},
ad_color_editorHeightLine = {1, 1, 1, 1},
ad_color_previewSingleConnection = {0.3, 0.9, 0, 1},
ad_color_previewDualConnection = {0, 0, 0.9, 1},
ad_color_previewSubPrioSingleConnection = {0.9, 0.4, 0.1, 1},
ad_color_previewSubPrioDualConnection = {0.3, 0.15, 0, 1},
ad_color_previewOk = {0.3, 0.9, 0, 1},
ad_color_previewNotOk = {1, 0.1, 0, 1}
ad_color_previewNotOk = {1, 0.1, 0, 1},
ad_color_textInputBackground = {0.0227, 0.5346, 0.8519, 1} -- Giants original
}

AutoDrive.currentColors = {} -- this will hold the current colors, derived from default colors above, overwritten by local settings
Expand Down Expand Up @@ -146,7 +156,7 @@ end

function AutoDrive:restartMySavegame()
if g_server then
restartApplication(" -autoStartSavegameId 1", true)
restartApplication(true, " -autoStartSavegameId 1")
end
end

Expand Down Expand Up @@ -252,6 +262,7 @@ function AutoDrive:loadMap(name)

ADMultipleTargetsManager:load()
-- AutoDrive.initTelemetry()
ADBunkerSiloManager:load()

InGameMenuAIFrame.onFrameOpen = Utils.appendedFunction(InGameMenuAIFrame.onFrameOpen, AutoDrive.onAIFrameOpen)
InGameMenuAIFrame.onFrameClose = Utils.appendedFunction(InGameMenuAIFrame.onFrameClose, AutoDrive.onAIFrameClose)
Expand Down Expand Up @@ -651,6 +662,7 @@ function AutoDrive:update(dt)
if g_server ~= nil then
ADHarvestManager:update(dt)
ADScheduler:update(dt)
ADBunkerSiloManager:update(dt)
end

ADMessagesManager:update(dt)
Expand Down
15 changes: 9 additions & 6 deletions scripts/Events/Graph/CreateSplineConnectionEvent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ function CreateSplineConnectionEvent.emptyNew()
return self
end

function CreateSplineConnectionEvent.new(start, waypoints, target)
function CreateSplineConnectionEvent.new(start, waypoints, target, dualConnection)
local self = CreateSplineConnectionEvent.emptyNew()
self.start = start
self.waypoints = waypoints
self.target = target
self.dualConnection = dualConnection
return self
end

function CreateSplineConnectionEvent:writeStream(streamId, connection)
function CreateSplineConnectionEvent:writeStream(streamId, connection)
local paramsXZ = g_currentMission.vehicleXZPosCompressionParams
local paramsY = g_currentMission.vehicleYPosCompressionParams

Expand All @@ -30,6 +31,7 @@ function CreateSplineConnectionEvent:writeStream(streamId, connection)
end

streamWriteInt32(streamId, self.target)
streamWriteBool(streamId, self.dualConnection)
end

function CreateSplineConnectionEvent:readStream(streamId, connection)
Expand All @@ -47,21 +49,22 @@ function CreateSplineConnectionEvent:readStream(streamId, connection)
end

self.target = streamReadInt32(streamId)
self.dualConnection = streamReadBool(streamId)
self:run(connection)
end

function CreateSplineConnectionEvent:run(connection)
if g_server ~= nil and connection:getIsServer() == false then
-- If the event is coming from a client, server have only to broadcast
CreateSplineConnectionEvent.sendEvent(self.start, self.waypoints, self.target)
CreateSplineConnectionEvent.sendEvent(self.start, self.waypoints, self.target, self.dualConnection)
else
-- If the event is coming from the server, both clients and server have to create the way point
ADGraphManager:createSplineConnection(self.start, self.waypoints, self.target, false)
ADGraphManager:createSplineConnection(self.start, self.waypoints, self.target, self.dualConnection, false)
end
end

function CreateSplineConnectionEvent.sendEvent(start, waypoints, target)
local event = CreateSplineConnectionEvent.new(start, waypoints, target)
function CreateSplineConnectionEvent.sendEvent(start, waypoints, target, dualConnection)
local event = CreateSplineConnectionEvent.new(start, waypoints, target, dualConnection)
if g_server ~= nil then
-- Server have to broadcast to all clients and himself
g_server:broadcastEvent(event, true)
Expand Down
13 changes: 8 additions & 5 deletions scripts/Events/Graph/ToggleConnectionEvent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,41 @@ function AutoDriveToggleConnectionEvent.emptyNew()
return self
end

function AutoDriveToggleConnectionEvent.new(startNode, endNode, reverseDirection)
function AutoDriveToggleConnectionEvent.new(startNode, endNode, reverseDirection, dualConnection)
local self = AutoDriveToggleConnectionEvent.emptyNew()
self.startNode = startNode
self.endNode = endNode
self.reverseDirection = reverseDirection
self.dualConnection = dualConnection
return self
end

function AutoDriveToggleConnectionEvent:writeStream(streamId, connection)
streamWriteUIntN(streamId, self.startNode.id, 20)
streamWriteUIntN(streamId, self.endNode.id, 20)
streamWriteBool(streamId, self.reverseDirection)
streamWriteBool(streamId, self.dualConnection)
end

function AutoDriveToggleConnectionEvent:readStream(streamId, connection)
self.startNode = ADGraphManager:getWayPointById(streamReadUIntN(streamId, 20))
self.endNode = ADGraphManager:getWayPointById(streamReadUIntN(streamId, 20))
self.reverseDirection = streamReadBool(streamId)
self.dualConnection = streamReadBool(streamId)
self:run(connection)
end

function AutoDriveToggleConnectionEvent:run(connection)
if g_server ~= nil and connection:getIsServer() == false then
-- If the event is coming from a client, server have only to broadcast
AutoDriveToggleConnectionEvent.sendEvent(self.startNode, self.endNode, self.reverseDirection)
AutoDriveToggleConnectionEvent.sendEvent(self.startNode, self.endNode, self.reverseDirection, self.dualConnection)
else
ADGraphManager:toggleConnectionBetween(self.startNode, self.endNode, self.reverseDirection, false)
ADGraphManager:toggleConnectionBetween(self.startNode, self.endNode, self.reverseDirection, self.dualConnection, false)
end
end

function AutoDriveToggleConnectionEvent.sendEvent(startNode, endNode, reverseDirection)
local event = AutoDriveToggleConnectionEvent.new(startNode, endNode, reverseDirection)
function AutoDriveToggleConnectionEvent.sendEvent(startNode, endNode, reverseDirection, dualConnection)
local event = AutoDriveToggleConnectionEvent.new(startNode, endNode, reverseDirection, dualConnection)
if g_server ~= nil then
-- Server have to broadcast to all clients and himself
g_server:broadcastEvent(event, true)
Expand Down
19 changes: 18 additions & 1 deletion scripts/Events/HudInputEvent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ AutoDriveHudInputEventEvent.TYPE_SECOND_MARKER = 2
AutoDriveHudInputEventEvent.TYPE_FILLTYPE = 3
AutoDriveHudInputEventEvent.TYPE_TOGGLE_FILLTYPE_SELECTION = 4
AutoDriveHudInputEventEvent.TYPE_TOGGLE_ALL_FILLTYPE_SELECTIONS = 5
AutoDriveHudInputEventEvent.CHANGE_LOOP_COUNTER = 6




AutoDriveHudInputEventEvent_mt = Class(AutoDriveHudInputEventEvent, Event)

Expand Down Expand Up @@ -40,7 +44,7 @@ function AutoDriveHudInputEventEvent:run(connection)
if self.eventType == self.TYPE_FIRST_MARKER then
local currentFirstMarker = self.vehicle.ad.stateModule:getFirstMarkerId()
if currentFirstMarker > 0 and currentFirstMarker ~= self.value then
if not (self.vehicle.spec_combine or AutoDrive.getIsBufferCombine(self.vehicle) or self.vehicle.ad.isCombine ~= nil) then
if not self.vehicle.ad.hasCombine then
-- not stop / change CP for harvesters
AutoDrive:StopCP(self.vehicle)
end
Expand All @@ -63,6 +67,11 @@ function AutoDriveHudInputEventEvent:run(connection)
if self.eventType == self.TYPE_TOGGLE_ALL_FILLTYPE_SELECTIONS then
self.vehicle.ad.stateModule:toggleAllFillTypeSelections(self.value)
end

if self.eventType == self.CHANGE_LOOP_COUNTER then
local increment, fast, wheel = ADHudCounterButton.int_to_flags(self.value)
self.vehicle.ad.stateModule:changeLoopCounter(increment, fast, wheel)
end
end
end

Expand Down Expand Up @@ -100,3 +109,11 @@ function AutoDriveHudInputEventEvent:sendToggleAllFillTypeSelectionsEvent(vehicl
g_client:getServerConnection():sendEvent(AutoDriveHudInputEventEvent.new(vehicle, self.TYPE_TOGGLE_ALL_FILLTYPE_SELECTIONS, fillTypeId))
end
end

function AutoDriveHudInputEventEvent:sendChangeLoopCounterEvent(vehicle, increment, fast, wheel)
if g_client ~= nil then
-- Client have to send to server
local value = ADHudCounterButton.flags_to_int(increment, fast, wheel)
g_client:getServerConnection():sendEvent(AutoDriveHudInputEventEvent.new(vehicle, self.CHANGE_LOOP_COUNTER, value))
end
end
5 changes: 5 additions & 0 deletions scripts/Gui/EnterDestinationFilterGUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ function ADEnterDestinationFilterGui:onOpen()
ADEnterDestinationFilterGui:superClass().onOpen(self)
self.textInputElement.blockTime = 0
self.textInputElement:onFocusActivate()
if self.textInputElement.overlay and self.textInputElement.overlay.colorFocused then
if AutoDrive.currentColors and AutoDrive.currentColors.ad_color_textInputBackground then
self.textInputElement.overlay.colorFocused = AutoDrive.currentColors.ad_color_textInputBackground
end
end
if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle.ad ~= nil then
self.textInputElement:setText(g_currentMission.controlledVehicle.ad.destinationFilterText)
end
Expand Down
5 changes: 5 additions & 0 deletions scripts/Gui/EnterDriverNameGUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ function ADEnterDriverNameGui:onOpen()
ADEnterDriverNameGui:superClass().onOpen(self)
self.textInputElement.blockTime = 0
self.textInputElement:onFocusActivate()
if self.textInputElement.overlay and self.textInputElement.overlay.colorFocused then
if AutoDrive.currentColors and AutoDrive.currentColors.ad_color_textInputBackground then
self.textInputElement.overlay.colorFocused = AutoDrive.currentColors.ad_color_textInputBackground
end
end
if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle.ad ~= nil then
self.textInputElement:setText(g_currentMission.controlledVehicle.ad.stateModule:getName())
end
Expand Down
5 changes: 5 additions & 0 deletions scripts/Gui/EnterGroupNameGUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ function ADEnterGroupNameGui:onOpen()
ADEnterGroupNameGui:superClass().onOpen(self)
self.textInputElement.blockTime = 0
self.textInputElement:onFocusActivate()
if self.textInputElement.overlay and self.textInputElement.overlay.colorFocused then
if AutoDrive.currentColors and AutoDrive.currentColors.ad_color_textInputBackground then
self.textInputElement.overlay.colorFocused = AutoDrive.currentColors.ad_color_textInputBackground
end
end
self.textInputElement:setText("")
end

Expand Down
5 changes: 5 additions & 0 deletions scripts/Gui/EnterTargetNameGUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ function ADEnterTargetNameGui:onOpen()
ADEnterTargetNameGui:superClass().onOpen(self)
self.textInputElement.blockTime = 0
self.textInputElement:onFocusActivate()
if self.textInputElement.overlay and self.textInputElement.overlay.colorFocused then
if AutoDrive.currentColors and AutoDrive.currentColors.ad_color_textInputBackground then
self.textInputElement.overlay.colorFocused = AutoDrive.currentColors.ad_color_textInputBackground
end
end
self.editName = nil
self.editId = nil
self.edit = false
Expand Down
5 changes: 5 additions & 0 deletions scripts/Gui/RoutesManagerGUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ function ADRoutesManagerGui:onCreate()
end

function ADRoutesManagerGui:onOpen()
if self.textInputElement.overlay and self.textInputElement.overlay.colorFocused then
if AutoDrive.currentColors and AutoDrive.currentColors.ad_color_textInputBackground then
self.textInputElement.overlay.colorFocused = AutoDrive.currentColors.ad_color_textInputBackground
end
end
self:refreshItems()
ADRoutesManagerGui:superClass().onOpen(self)
end
Expand Down
2 changes: 1 addition & 1 deletion scripts/Gui/Settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function ADSettings:setupPages()
end

local combineEnabled = function()
if vehicleEnabled() and g_currentMission.controlledVehicle.ad.isCombine then
if vehicleEnabled() and (g_currentMission.controlledVehicle.ad and g_currentMission.controlledVehicle.ad.hasCombine) then
return true
end
return false
Expand Down
Loading

0 comments on commit f8ecba3

Please sign in to comment.