Skip to content

Commit 3f464d9

Browse files
authored
Merge pull request #298 from Stephan-S/dev
Release 2.0.0.4
2 parents 8428ce7 + b4911f9 commit 3f464d9

33 files changed

Lines changed: 677 additions & 350 deletions

modDesc.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Différents modes d'utilisation ont été ajoutés depuis les premières version
3232
<![CDATA[Этот мод может быть использован для создания сети маршрутов для транспортных средств для автономного вождения. После настройки вы можете указать трактору, стоящему где-угодно рядом с сетью, проехать в любую точку, например, в магазин, поле №1 или в точку продажи.]]>
3333
</ru>
3434
</description>
35-
<version>2.0.0.3</version>
35+
<version>2.0.0.4</version>
3636
<multiplayer supported="true" />
3737
<iconFilename>icon.dds</iconFilename>
3838
<extraSourceFiles>
@@ -109,7 +109,6 @@ Différents modes d'utilisation ont été ajoutés depuis les premières version
109109
<binding device="0_XINPUT_GAMEPAD" input="BUTTON_5 BUTTON_6 BUTTON_19" axisComponent="+" neutralInput="0" index="1" />
110110
</actionBinding>
111111
<actionBinding action="ADEnDisable">
112-
<binding device="KB_MOUSE_DEFAULT" input="KEY_lctrl KEY_lalt KEY_up" axisComponent="+" inputComponent="+" index="1" />
113112
<binding device="0_XINPUT_GAMEPAD" input="BUTTON_5 BUTTON_6 BUTTON_17" axisComponent="+" neutralInput="0" index="1" />
114113
</actionBinding>
115114
<actionBinding action="ADSelectTarget">

register.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ source(Utils.getFilename("scripts/Tasks/Turns/ForwardOffsetTurn.lua", g_currentM
145145
AutoDriveRegister = {}
146146
AutoDriveRegister.version = g_modManager:getModByName(g_currentModName).version
147147

148+
if AutoDrive.currentModName == nil then
149+
AutoDrive.currentModName = g_currentModName
150+
end
151+
148152
if AutoDrive.ADSpecName == nil then
149153
AutoDrive.ADSpecName = g_currentModName .. ".AutoDrive"
150154
end

scripts/AutoDrive.lua

Lines changed: 82 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AutoDrive = {}
2-
AutoDrive.version = "2.0.0.3"
2+
AutoDrive.version = "2.0.0.4"
33

44
AutoDrive.directory = g_currentModDirectory
55

@@ -25,10 +25,10 @@ AutoDrive.mapHotspotsBuffer = {}
2525
AutoDrive.drawHeight = 0.3
2626
AutoDrive.drawDistance = getViewDistanceCoeff() * 50
2727

28-
AutoDrive.STAT_NAMES = {"driversTraveledDistance", "driversHired"}
29-
for _, statName in pairs(AutoDrive.STAT_NAMES) do
30-
table.insert(FarmStats.STAT_NAMES, statName)
31-
end
28+
-- AutoDrive.STAT_NAMES = {"driversTraveledDistance", "driversHired"}
29+
-- for _, statName in pairs(AutoDrive.STAT_NAMES) do
30+
-- table.insert(FarmStats.STAT_NAMES, statName)
31+
-- end
3232

3333
AutoDrive.MODE_DRIVETO = 1
3434
AutoDrive.MODE_PICKUPANDDELIVER = 2
@@ -86,42 +86,6 @@ AutoDrive.FLAG_SUBPRIO = 1
8686
AutoDrive.FLAG_TRAFFIC_SYSTEM = 2
8787
AutoDrive.FLAG_TRAFFIC_SYSTEM_CONNECTION = 4
8888

89-
AutoDrive.actions = {
90-
{"ADToggleMouse", true, 1},
91-
{"ADToggleHud", true, 1},
92-
{"ADEnDisable", true, 1},
93-
{"ADSelectTarget", false, 0},
94-
{"ADSelectPreviousTarget", false, 0},
95-
{"ADSelectTargetUnload", false, 0},
96-
{"ADSelectPreviousTargetUnload", false, 0},
97-
{"ADActivateDebug", false, 0},
98-
{"ADDebugSelectNeighbor", false, 0},
99-
{"ADDebugChangeNeighbor", false, 0},
100-
{"ADDebugCreateConnection", false, 0},
101-
{"ADDebugCreateMapMarker", false, 0},
102-
{"ADDebugDeleteWayPoint", false, 0},
103-
{"ADDebugDeleteDestination", false, 3},
104-
{"ADSilomode", false, 0},
105-
{"ADOpenGUI", true, 2},
106-
{"ADCallDriver", false, 3},
107-
{"ADSelectNextFillType", false, 0},
108-
{"ADSelectPreviousFillType", false, 0},
109-
{"ADRecord", false, 0},
110-
{"AD_routes_manager", false, 0},
111-
{"ADGoToVehicle", false, 3},
112-
{"ADNameDriver", false, 0},
113-
{"ADRenameMapMarker", false, 0},
114-
{"ADSwapTargets", false, 0},
115-
{"AD_open_notification_history", false, 0},
116-
-- {"AD_open_colorSettings", false, 0},
117-
{"AD_continue", false, 3},
118-
{"ADParkVehicle", false, 0},
119-
{"AD_devAction", false, 0},
120-
{"ADRefuelVehicle", false, 0},
121-
{"ADToggleHudExtension", true, 1},
122-
{"ADRepairVehicle", false, 0}
123-
}
124-
12589
AutoDrive.colors = {
12690
ad_color_singleConnection = {0, 1, 0, 1},
12791
ad_color_dualConnection = {0, 0, 1, 1},
@@ -250,7 +214,7 @@ function AutoDrive:loadMap(name)
250214

251215
IngameMapElement.mouseEvent = Utils.overwrittenFunction(IngameMapElement.mouseEvent, AutoDrive.ingameMapElementMouseEvent)
252216

253-
FarmStats.getStatisticData = Utils.overwrittenFunction(FarmStats.getStatisticData, AutoDrive.FarmStats_getStatisticData)
217+
-- FarmStats.getStatisticData = Utils.overwrittenFunction(FarmStats.getStatisticData, AutoDrive.FarmStats_getStatisticData)
254218

255219
FSBaseMission.removeVehicle = Utils.prependedFunction(FSBaseMission.removeVehicle, AutoDrive.preRemoveVehicle)
256220

@@ -307,8 +271,18 @@ end
307271
function AutoDrive:drawBaseMission()
308272
if AutoDrive.aiFrameOpen then
309273
AutoDrive:drawRouteOnMap()
274+
AutoDrive.drawNetworkOnMap()
310275
if AutoDrive.aiFrameVehicle ~= nil then
311-
AutoDrive.Hud:drawHud(AutoDrive.aiFrameVehicle)
276+
if AutoDrive.aiFrameVehicle.ad and AutoDrive.aiFrameVehicle.ad.stateModule then
277+
if AutoDrive.aiFrameVehicle.ad.showingHud ~= AutoDrive.Hud.showHud then
278+
AutoDrive.Hud:toggleHud(AutoDrive.aiFrameVehicle)
279+
end
280+
if AutoDrive.Hud ~= nil then
281+
if AutoDrive.Hud.showHud == true then
282+
AutoDrive.Hud:drawHud(AutoDrive.aiFrameVehicle)
283+
end
284+
end
285+
end
312286
end
313287
end
314288
end
@@ -389,6 +363,70 @@ function AutoDrive.drawRouteOnMap()
389363
end
390364
end
391365

366+
function AutoDrive.drawNetworkOnMap()
367+
if AutoDrive.aiFrame == nil then
368+
return
369+
end
370+
371+
if not AutoDrive.isEditorModeEnabled() then
372+
return
373+
end
374+
375+
if AutoDrive.courseOverlayId == nil then
376+
AutoDrive.courseOverlayId = createImageOverlay('data/shared/default_normal.dds')
377+
end
378+
379+
local dx, dz, dx2D, dy2D, width, rotation, r, g, b
380+
381+
local isSubPrio = function(pointToTest)
382+
return bitAND(pointToTest.flags, AutoDrive.FLAG_SUBPRIO) > 0
383+
end
384+
385+
local network = ADGraphManager:getWayPoints()
386+
if network ~= nil then
387+
for index, node in pairs(network) do
388+
if node.out ~= nil then
389+
for _, outNodeId in pairs(node.out) do
390+
local outNode = network[outNodeId]
391+
local startX, startY, _, _ = AutoDrive.getScreenPosFromWorldPos(node.x, node.z)
392+
local endX, endY, _, _ = AutoDrive.getScreenPosFromWorldPos(outNode.x, outNode.z)
393+
394+
if startX and startY and endX and endY then
395+
dx2D = endX - startX;
396+
dy2D = ( endY - startY ) / g_screenAspectRatio;
397+
width = MathUtil.vector2Length(dx2D, dy2D);
398+
399+
dx = outNode.x - node.x;
400+
dz = outNode.z - node.z;
401+
rotation = MathUtil.getYRotationFromDirection(dx, dz) - math.pi * 0.5;
402+
403+
local lineThickness = 2 / g_screenHeight
404+
local r, g, b, a = unpack(AutoDrive.currentColors.ad_color_singleConnection)
405+
406+
if isSubPrio(outNode) then
407+
r, g, b, a = unpack(AutoDrive.currentColors.ad_color_subPrioSingleConnection)
408+
end
409+
410+
if ADGraphManager:isDualRoad(node, outNode) then
411+
r, g, b, a = unpack(AutoDrive.currentColors.ad_color_dualConnection)
412+
if isSubPrio(outNode) then
413+
r, g, b, a = unpack(AutoDrive.currentColors.ad_color_subPrioDualConnection)
414+
end
415+
elseif ADGraphManager:isReverseRoad(start, target) then
416+
r, g, b, a = unpack(AutoDrive.currentColors.ad_color_reverseConnection)
417+
end
418+
setOverlayColor( AutoDrive.courseOverlayId, r, g, b, a)
419+
setOverlayRotation( AutoDrive.courseOverlayId, rotation, 0, 0)
420+
421+
renderOverlay( AutoDrive.courseOverlayId, startX, startY, width, lineThickness )
422+
end
423+
setOverlayRotation( AutoDrive.courseOverlayId, 0, 0, 0 ) -- reset overlay rotation
424+
end
425+
end
426+
end
427+
end
428+
end
429+
392430
function AutoDrive.getScreenPosFromWorldPos(worldX, worldZ)
393431
local objectX = (worldX + AutoDrive.aiFrame.ingameMapBase.worldCenterOffsetX) / AutoDrive.aiFrame.ingameMapBase.worldSizeX * 0.5 + 0.25
394432
local objectZ = (worldZ + AutoDrive.aiFrame.ingameMapBase.worldCenterOffsetZ) / AutoDrive.aiFrame.ingameMapBase.worldSizeZ * 0.5 + 0.25
@@ -638,7 +676,7 @@ function AutoDrive:FarmStats_loadFromXMLFile(xmlFileName, key)
638676
key = key .. ".statistics"
639677
-- self.statistics["driversTraveledDistance"].total = Utils.getNoNil(getXMLFloat(xmlFile, key .. ".driversTraveledDistance"), 0)
640678

641-
self.statistics["driversTraveledDistance"].total = xmlFile:getFloat(key .. ".driversTraveledDistance", 0)
679+
-- self.statistics["driversTraveledDistance"].total = xmlFile:getFloat(key .. ".driversTraveledDistance", 0)
642680
end
643681

644682
function AutoDrive:FarmStats_getStatisticData(superFunc)

scripts/Events/HudInputEvent.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function AutoDriveHudInputEventEvent:run(connection)
3838
if self.eventType == self.TYPE_FIRST_MARKER then
3939
local currentFirstMarker = self.vehicle.ad.stateModule:getFirstMarkerId()
4040
if currentFirstMarker > 0 and currentFirstMarker ~= self.value then
41-
self.vehicle.ad.stateModule:removeCPCallback()
41+
AutoDrive:StopCP(self.vehicle)
4242
end
4343
self.vehicle.ad.stateModule:setFirstMarker(self.value)
4444
end

scripts/Events/MessageEvent.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function AutoDriveMessageEvent:run(connection)
6464
end
6565

6666
if not self.isNotification then
67-
ADMessagesManager:addMessage(self.messageType, self.text, self.duration)
67+
ADMessagesManager:addMessage(self.vehicle, self.messageType, self.text, self.duration)
6868
else
6969
ADMessagesManager:addNotification(self.vehicle, self.messageType, self.text, self.duration)
7070
end

0 commit comments

Comments
 (0)