Skip to content

Commit

Permalink
Merge branch 'beta-testing'
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan-S committed Apr 1, 2020
2 parents d8db3e1 + b0a7b78 commit ed3e5c8
Show file tree
Hide file tree
Showing 35 changed files with 448 additions and 115 deletions.
33 changes: 33 additions & 0 deletions FS19_AutoDrive/drawing/marker_2.i3d
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="iso-8859-1"?>

<i3D name="marker" version="1.6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://i3d.giants.ch/schema/i3d-1.6.xsd">
<Asset>
<Export program="GIANTS Editor 64bit" version="8.2.0"/>
</Asset>

<Files>
<File fileId="2" filename="$data/shaders/fxCircleShader.xml"/>
<File fileId="1" filename="marker_diffuse_2.dds"/>
</Files>


<Materials>
<Material name="marker_mat" materialId="4" alphaBlending="true" customShaderId="2" customShaderVariation="PULSATING">
<Emissivemap fileId="1"/>
<CustomParameter name="scaleParameters" value="0.65 1 2.5 1"/>
</Material>
</Materials>


<Shapes externalShapesFile="marker_2.i3d.shapes">
</Shapes>


<Dynamics>
</Dynamics>

<Scene>
<Shape shapeId="1" name="marker" clipDistance="100" nodeId="7" materialIds="4"/>
</Scene>

</i3D>
Binary file added FS19_AutoDrive/drawing/marker_2.i3d.shapes
Binary file not shown.
Binary file added FS19_AutoDrive/drawing/marker_diffuse_2.dds
Binary file not shown.
24 changes: 24 additions & 0 deletions FS19_AutoDrive/gui/settingsPage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,30 @@
<GuiElement type="bitmap" profile="multiTextOptionSettingsBg" />
<GuiElement type="bitmap" profile="baseReference" screenAlign="topLeft" position="5px 4px" size="17px 17px" />
</GuiElement>
<GuiElement type="multiTextOption" profile="multiTextOptionSettings" onCreate="onCreateAutoDriveSetting" onClick="onOptionChange" name="addSettingsToHUD" toolTipElementId="ingameMenuHelpBoxText">
<GuiElement type="button" profile="multiTextOptionSettingsLeft" />
<GuiElement type="button" profile="multiTextOptionSettingsRight" />
<GuiElement type="text" profile="multiTextOptionSettingsText" />
<GuiElement type="text" profile="multiTextOptionSettingsTitle" position="27px 6px" />
<GuiElement type="bitmap" profile="multiTextOptionSettingsBg" />
<GuiElement type="bitmap" profile="baseReference" screenAlign="topLeft" position="5px 4px" size="17px 17px" />
</GuiElement>
<GuiElement type="multiTextOption" profile="multiTextOptionSettings" onCreate="onCreateAutoDriveSetting" onClick="onOptionChange" name="iconSetToUse" toolTipElementId="ingameMenuHelpBoxText">
<GuiElement type="button" profile="multiTextOptionSettingsLeft" />
<GuiElement type="button" profile="multiTextOptionSettingsRight" />
<GuiElement type="text" profile="multiTextOptionSettingsText" />
<GuiElement type="text" profile="multiTextOptionSettingsTitle" position="27px 6px" />
<GuiElement type="bitmap" profile="multiTextOptionSettingsBg" />
<GuiElement type="bitmap" profile="baseReference" screenAlign="topLeft" position="5px 4px" size="17px 17px" />
</GuiElement>
<GuiElement type="multiTextOption" profile="multiTextOptionSettings" onCreate="onCreateAutoDriveSetting" onClick="onOptionChange" name="secondEditorModeAllowed" toolTipElementId="ingameMenuHelpBoxText">
<GuiElement type="button" profile="multiTextOptionSettingsLeft" />
<GuiElement type="button" profile="multiTextOptionSettingsRight" />
<GuiElement type="text" profile="multiTextOptionSettingsText" />
<GuiElement type="text" profile="multiTextOptionSettingsTitle" position="27px 6px" />
<GuiElement type="bitmap" profile="multiTextOptionSettingsBg" />
<GuiElement type="bitmap" profile="baseReference" screenAlign="topLeft" position="5px 4px" size="17px 17px" />
</GuiElement>
</GuiElement>
</GuiElement>

Expand Down
2 changes: 1 addition & 1 deletion FS19_AutoDrive/modDesc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Changelog 1.1.0.0:
]]>
</ru>
</description>
<version>1.1.0.3</version>
<version>1.1.0.4</version>
<multiplayer supported="true" />
<iconFilename>icon.dds</iconFilename>
<extraSourceFiles>
Expand Down
26 changes: 14 additions & 12 deletions FS19_AutoDrive/scripts/AutoDrive.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AutoDrive = {}
AutoDrive.version = "1.1.0.3-4"
AutoDrive.version = "1.1.0.4"

AutoDrive.directory = g_currentModDirectory

Expand Down Expand Up @@ -194,17 +194,19 @@ function AutoDrive:keyEvent(unicode, sym, modifier, isDown)
AutoDrive.leftCTRLmodifierKeyPressed = bitAND(modifier, Input.MOD_LCTRL) > 0
AutoDrive.leftALTmodifierKeyPressed = bitAND(modifier, Input.MOD_LALT) > 0

local vehicle = g_currentMission.controlledVehicle
if vehicle ~= nil and vehicle.ad ~= nil and vehicle.ad.stateModule ~= nil then
if vehicle.ad.stateModule:getEditorMode() == ADStateModule.EDITOR_ON then
if AutoDrive.leftCTRLmodifierKeyPressed then
vehicle.ad.stateModule:setEditorMode(ADStateModule.EDITOR_EXTENDED)
AutoDrive.toggledEditorMode = true
end
elseif vehicle.ad.stateModule:getEditorMode() == ADStateModule.EDITOR_EXTENDED and AutoDrive.toggledEditorMode then
if not AutoDrive.leftCTRLmodifierKeyPressed then
vehicle.ad.stateModule:setEditorMode(ADStateModule.EDITOR_ON)
AutoDrive.toggledEditorMode = false
if not AutoDrive.getSetting("secondEditorModeAllowed") then
local vehicle = g_currentMission.controlledVehicle
if vehicle ~= nil and vehicle.ad ~= nil and vehicle.ad.stateModule ~= nil then
if vehicle.ad.stateModule:getEditorMode() == ADStateModule.EDITOR_ON then
if AutoDrive.leftCTRLmodifierKeyPressed then
vehicle.ad.stateModule:setEditorMode(ADStateModule.EDITOR_EXTENDED)
AutoDrive.toggledEditorMode = true
end
elseif vehicle.ad.stateModule:getEditorMode() == ADStateModule.EDITOR_EXTENDED and AutoDrive.toggledEditorMode then
if not AutoDrive.leftCTRLmodifierKeyPressed then
vehicle.ad.stateModule:setEditorMode(ADStateModule.EDITOR_ON)
AutoDrive.toggledEditorMode = false
end
end
end
end
Expand Down
110 changes: 79 additions & 31 deletions FS19_AutoDrive/scripts/Hud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,20 @@ function AutoDriveHud:createHudAt(hudX, hudY)
--------------------------------------------------

---------- SECOND ROW BUTTONS ---------------------
if AutoDrive.experimentalFeatures.wideHUD then
self:AddSettingsButton("enableTrafficDetection", "gui_ad_enableTrafficDetection", 1, true)
self:AddSettingsButton("distributeToFolder", "gui_ad_distributeToFolder", 1, true)
self:AddSettingsButton("exitField", "gui_ad_exitField", 1, true)
self:AddSettingsButton("restrictToField", "gui_ad_restrictToField", 1, true)
self:AddSettingsButton("avoidFruit", "gui_ad_avoidFruit", 1, true)
if AutoDrive.experimentalFeatures.wideHUD then
if AutoDrive.getSetting("addSettingsToHUD") then
self:AddSettingsButton("enableTrafficDetection", "gui_ad_enableTrafficDetection", 1, true)
self:AddSettingsButton("distributeToFolder", "gui_ad_distributeToFolder", 1, true)
self:AddSettingsButton("exitField", "gui_ad_exitField", 1, true)
self:AddSettingsButton("restrictToField", "gui_ad_restrictToField", 1, true)
self:AddSettingsButton("avoidFruit", "gui_ad_avoidFruit", 1, true)
else
self:AddEditModeButtons()
if g_courseplay ~= nil then
self.buttonCounter = self.buttonCounter - 1
self:AddButton("input_startCp", nil, "hud_startCp", 1, true)
end
end

speedX = self.posX + (self.cols - 1 + self.buttonCollOffset) * self.borderX + (self.cols - 2 + self.buttonCollOffset) * self.buttonWidth
speedY = self.posY + (2) * self.borderY + (1) * self.buttonHeight
Expand All @@ -209,19 +217,26 @@ function AutoDriveHud:createHudAt(hudX, hudY)
self:AddButton("input_openGUI", nil, "input_ADOpenGUI", 1, true)
else
self:AddEditModeButtons()
self.buttonCounter = self.buttonCounter - 5
if AutoDrive.getSetting("addSettingsToHUD") then
self.buttonCounter = self.buttonCounter - 5

if g_courseplay ~= nil then
self:AddButton("input_startCp", nil, "hud_startCp", 1, true)
else
self:AddSettingsButton("enableTrafficDetection", "gui_ad_enableTrafficDetection", 1, true)
end

if g_courseplay ~= nil then
self:AddButton("input_startCp", nil, "hud_startCp", 1, true)
self:AddSettingsButton("distributeToFolder", "gui_ad_distributeToFolder", 1, true)
self:AddSettingsButton("exitField", "gui_ad_exitField", 1, true)
self:AddSettingsButton("restrictToField", "gui_ad_restrictToField", 1, true)
self:AddSettingsButton("avoidFruit", "gui_ad_avoidFruit", 1, true)
else
self:AddSettingsButton("enableTrafficDetection", "gui_ad_enableTrafficDetection", 1, true)
if g_courseplay ~= nil then
self.buttonCounter = self.buttonCounter - 1
self:AddButton("input_startCp", nil, "hud_startCp", 1, true)
end
end

self:AddSettingsButton("distributeToFolder", "gui_ad_distributeToFolder", 1, true)
self:AddSettingsButton("exitField", "gui_ad_exitField", 1, true)
self:AddSettingsButton("restrictToField", "gui_ad_restrictToField", 1, true)
self:AddSettingsButton("avoidFruit", "gui_ad_avoidFruit", 1, true)

speedX = self.posX + (self.cols - 1 + self.buttonCollOffset) * self.borderX + (self.cols - 2 + self.buttonCollOffset) * self.buttonWidth
speedY = self.posY + (2) * self.borderY + (1) * self.buttonHeight
table.insert(self.hudElements, ADHudSpeedmeter:new(speedX, speedY, self.buttonWidth, self.buttonHeight, true))
Expand All @@ -232,7 +247,7 @@ function AutoDriveHud:createHudAt(hudX, hudY)
--------------------------------------------------

---------- THIRD ROW BUTTONS ---------------------
if AutoDrive.experimentalFeatures.wideHUD then
if AutoDrive.experimentalFeatures.wideHUD and AutoDrive.getSetting("addSettingsToHUD") then
self:AddEditModeButtons()

if g_courseplay ~= nil then
Expand All @@ -250,7 +265,7 @@ function AutoDriveHud:AddEditModeButtons()
self:AddButton("input_createMapMarker", nil, "input_ADDebugCreateMapMarker", 1, false)
self:AddButton("input_removeWaypoint", "input_removeMapMarker", "input_ADDebugDeleteWayPoint", 1, false)
self:AddButton("input_editMapMarker", nil, "input_ADDebugCreateMapMarker", 1, false)
if AutoDrive.experimentalFeatures.wideHUD then
if AutoDrive.experimentalFeatures.wideHUD and AutoDrive.getSetting("addSettingsToHUD") then
self:AddButton("input_removeMapMarker", nil, "input_ADDebugDeleteWayPoint", 1, false)
end
end
Expand Down Expand Up @@ -408,7 +423,7 @@ function AutoDriveHud:mouseEvent(vehicle, posX, posY, isDown, isUp, button)
end
end

if not AutoDrive.leftALTmodifierKeyPressed then
if not AutoDrive.leftALTmodifierKeyPressed and (not AutoDrive.leftCTRLmodifierKeyPressed or not AutoDrive.getSetting("secondEditorModeAllowed")) then
if (button == 2 or button == 3) and isUp then
if vehicle.ad.nodeToMoveId ~= nil then
ADGraphManager:changeWayPointPosition(vehicle.ad.nodeToMoveId)
Expand All @@ -421,19 +436,52 @@ function AutoDriveHud:mouseEvent(vehicle, posX, posY, isDown, isUp, button)
end
end

--If no node is hovered / moved - check for creation of new node
if vehicle.ad.nodeToMoveId == nil and vehicle.ad.hoveredNodeId == nil then
if button == 1 and isDown then
--For rough depth assertion, we use the closest nodes location as this is roughly in the screen's center
local closest = vehicle:getClosestWayPoint()
closest = ADGraphManager:getWayPointById(closest)
if closest ~= nil then
local _, _, depth = project(closest.x, closest.y, closest.z)

local x, y, z = unProject(g_lastMousePosX, g_lastMousePosY, depth)
-- And just to correct for slope changes, we now set the height to the terrain height
y = getTerrainHeightAtWorldPos(g_currentMission.terrainRootNode, x, 1, z)
ADGraphManager:createWayPoint(x, y, z)
if AutoDrive.leftCTRLmodifierKeyPressed then
--If no node is hovered / moved - check for creation of new node
if vehicle.ad.nodeToMoveId == nil and vehicle.ad.hoveredNodeId == nil then
if button == 1 and isDown then
--For rough depth assertion, we use the closest nodes location as this is roughly in the screen's center
local closest = vehicle:getClosestWayPoint()
closest = ADGraphManager:getWayPointById(closest)
if closest ~= nil then
local _, _, depth = project(closest.x, closest.y, closest.z)

local x, y, z = unProject(g_lastMousePosX, g_lastMousePosY, depth)
-- And just to correct for slope changes, we now set the height to the terrain height
y = getTerrainHeightAtWorldPos(g_currentMission.terrainRootNode, x, 1, z)

local screenX, screenY, depthNew = project(x, y, z)
local _, _, depth = project(closest.x, closest.y, closest.z)

local maxLoops = 1000
local minDistance = MathUtil.vector2Length(g_lastMousePosX - screenX, g_lastMousePosY - screenY)
local minX, minY, minZ = x, y, z
while minDistance > 0.002 and maxLoops > 0 do
maxLoops = maxLoops - 1
if screenY > g_lastMousePosY then
depth = depth - 0.0001
else
depth = depth + 0.0001
end

x, y, z = unProject(g_lastMousePosX, g_lastMousePosY, depth)
y = getTerrainHeightAtWorldPos(g_currentMission.terrainRootNode, x, 1, z)

screenX, screenY, depthNew = project(x, y, z)

local distance = MathUtil.vector2Length(g_lastMousePosX - screenX, g_lastMousePosY - screenY)
if distance < minDistance then
minX = x
minY = y
minZ = z
minDistance = distance
end
end

ADGraphManager:createWayPoint(minX, minY, minZ)
screenX, screenY, depthNew = project(minX, minY, minZ)
--print("Looped: mouse: " .. g_lastMousePosX .. "/" .. g_lastMousePosY .. " node: " .. screenX .. "/" .. screenY .. " minDistance: " .. minDistance .. " loopsLeft: " .. maxLoops)
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion FS19_AutoDrive/scripts/Hud/HudButton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function ADHudButton:getNewState(vehicle)
else
newState = 1
end
self.isVisible = not vehicle.ad.stateModule:isEditorModeEnabled() or AutoDrive.experimentalFeatures.wideHUD
self.isVisible = (not vehicle.ad.stateModule:isEditorModeEnabled()) or (AutoDrive.experimentalFeatures.wideHUD and AutoDrive.getSetting("addSettingsToHUD"))
end

return newState
Expand Down
15 changes: 11 additions & 4 deletions FS19_AutoDrive/scripts/Hud/HudIcon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,17 @@ function ADHudIcon:onDrawHeader(vehicle, uiScale)
textToShow = textToShow .. " - " .. taskInfo
end

if vehicle.ad.stateModule:isInExtendedEditorMode() then
textToShow = textToShow .. " - " .. g_i18n:getText("AD_lalt_for_deletion")
elseif vehicle.ad.stateModule:getEditorMode() == ADStateModule.EDITOR_ON then
textToShow = textToShow .. " - " .. g_i18n:getText("AD_lctrl_for_extendedEditor")
if AutoDrive.getSetting("secondEditorModeAllowed") then
if vehicle.ad.stateModule:isInExtendedEditorMode() then
textToShow = textToShow .. " - " .. g_i18n:getText("AD_lctrl_for_creation")
textToShow = textToShow .. " / " .. g_i18n:getText("AD_lalt_for_deletion")
end
else
if vehicle.ad.stateModule:isInExtendedEditorMode() then
textToShow = textToShow .. " - " .. g_i18n:getText("AD_lalt_for_deletion")
elseif vehicle.ad.stateModule:getEditorMode() == ADStateModule.EDITOR_ON then
textToShow = textToShow .. " - " .. g_i18n:getText("AD_lctrl_for_extendedEditor")
end
end

if vehicle.ad.stateModule:isEditorModeEnabled() and AutoDrive.getDebugChannelIsSet(AutoDrive.DC_PATHINFO) then
Expand Down
31 changes: 28 additions & 3 deletions FS19_AutoDrive/scripts/Manager/DrawingManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ ADDrawingManager.sphere.tasks = {}
ADDrawingManager.sphere.lastDrawZero = true

ADDrawingManager.markers = {}
ADDrawingManager.markers.fileName = "marker.i3d"
ADDrawingManager.markers.fileNames = {}
ADDrawingManager.markers.fileNames[1] = "marker.i3d"
ADDrawingManager.markers.fileNames[2] = "marker_2.i3d"
ADDrawingManager.markers.buffer = Buffer:new()
ADDrawingManager.markers.objects = FlaggedTable:new()
ADDrawingManager.markers.tasks = {}
ADDrawingManager.markers.lastDrawZero = true
ADDrawingManager.markers.lastDrawFileUsed = 1
ADDrawingManager.markers.usesSelection = true

ADDrawingManager.cross = {}
ADDrawingManager.cross.fileName = "cross.i3d"
Expand All @@ -57,7 +61,9 @@ function ADDrawingManager:load()
g_i3DManager:fillSharedI3DFileCache(self.arrows.fileName, self.i3DBaseDir)
g_i3DManager:fillSharedI3DFileCache(self.sSphere.fileName, self.i3DBaseDir)
g_i3DManager:fillSharedI3DFileCache(self.sphere.fileName, self.i3DBaseDir)
g_i3DManager:fillSharedI3DFileCache(self.markers.fileName, self.i3DBaseDir)
for _, filename in ipairs(self.markers.fileNames) do
g_i3DManager:fillSharedI3DFileCache(filename, self.i3DBaseDir)
end
end

function ADDrawingManager.initObject(id)
Expand Down Expand Up @@ -161,6 +167,25 @@ end
function ADDrawingManager:drawObjects(obj, dFunc, iFunc)
local taskCount = #obj.tasks

local fileToUse
if obj.usesSelection then
if obj.lastDrawFileUsed ~= AutoDrive.getSetting("iconSetToUse") then
-- cleaning up not needed objects and send them back to the buffer
obj.objects:ResetFlags()
local unusedObjects = obj.objects:RemoveUnflagged()
for _, id in pairs(unusedObjects) do
-- make invisible unused items
setVisibility(id, false)
obj.buffer:Insert(id)
end
obj.buffer = Buffer:new()
end
fileToUse = obj.fileNames[AutoDrive.getSetting("iconSetToUse")]
obj.lastDrawFileUsed = AutoDrive.getSetting("iconSetToUse")
else
fileToUse = obj.fileName
end

local stats = {}
stats["Tasks"] = {Total = taskCount, Performed = 0}
stats["Objects"] = obj.objects:Count()
Expand Down Expand Up @@ -198,7 +223,7 @@ function ADDrawingManager:drawObjects(obj, dFunc, iFunc)
local baseDir = self.i3DBaseDir
for i = 1, remainingTaskCount - bufferCount do
-- loading new i3ds
local id = g_i3DManager:loadSharedI3DFile(obj.fileName, baseDir)
local id = g_i3DManager:loadSharedI3DFile(fileToUse, baseDir)
obj.buffer:Insert(iFunc(id))
end
end
Expand Down
Loading

0 comments on commit ed3e5c8

Please sign in to comment.