11AutoDrive = {}
2- AutoDrive .version = " 2.0.0.3 "
2+ AutoDrive .version = " 2.0.0.4 "
33
44AutoDrive .directory = g_currentModDirectory
55
@@ -25,10 +25,10 @@ AutoDrive.mapHotspotsBuffer = {}
2525AutoDrive .drawHeight = 0.3
2626AutoDrive .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
3333AutoDrive .MODE_DRIVETO = 1
3434AutoDrive .MODE_PICKUPANDDELIVER = 2
@@ -86,42 +86,6 @@ AutoDrive.FLAG_SUBPRIO = 1
8686AutoDrive .FLAG_TRAFFIC_SYSTEM = 2
8787AutoDrive .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-
12589AutoDrive .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
307271function 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
314288end
@@ -389,6 +363,70 @@ function AutoDrive.drawRouteOnMap()
389363 end
390364end
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+
392430function 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)
642680end
643681
644682function AutoDrive :FarmStats_getStatisticData (superFunc )
0 commit comments