feat: traktorer i et andet run vises låst med run-navn i stedet for at kunne vælges (v1.9.7.0)
This commit is contained in:
@@ -318,9 +318,18 @@ function SmartPickupFrame:fillVehicleRows(adEnv, run)
|
||||
for _, vehicle in ipairs(ADRunsController.getFarmVehicles(adEnv)) do
|
||||
local id = ADRunsController.getVehicleId(vehicle)
|
||||
local row = self:addRow(self.vehiclePrefab, {kind = "vehicle", vehicle = vehicle, row = nil})
|
||||
self.rowData[row:getDescendantByName("option")].row = row
|
||||
row:getDescendantByName("option"):setState(inRun[id] and SmartPickupFrame.STATE_ON or SmartPickupFrame.STATE_OFF, false)
|
||||
row:getDescendantByName("title"):setText(self:describeVehicle(adEnv, run, vehicle, inRun[id]))
|
||||
local option, title = row:getDescendantByName("option"), row:getDescendantByName("title")
|
||||
self.rowData[option].row = row
|
||||
option:setState(inRun[id] and SmartPickupFrame.STATE_ON or SmartPickupFrame.STATE_OFF, false)
|
||||
-- Traktorer i et ANDET run kan ikke vælges her (én traktor = ét run); rækken viser hvor den er.
|
||||
local otherRun = ADRunsController.getRunForVehicle(vehicle)
|
||||
if otherRun ~= nil and otherRun.id ~= run.id then
|
||||
option:setDisabled(true)
|
||||
self.rowData[option].locked = true
|
||||
title:setText(string.format("%s — %s", ADRunsController.getVehicleLabel(adEnv, vehicle), string.format(self.i18n:getText("spu_inRun"), tostring(otherRun.name))))
|
||||
else
|
||||
title:setText(self:describeVehicle(adEnv, run, vehicle, inRun[id]))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -560,7 +569,7 @@ end
|
||||
function SmartPickupFrame:onClickVehicle(state, element)
|
||||
self:safe(function(frame)
|
||||
local run, data = frame:getRun(), frame.rowData[element]
|
||||
if run == nil or data == nil then return end
|
||||
if run == nil or data == nil or data.locked then return end
|
||||
if state == SmartPickupFrame.STATE_ON then
|
||||
local previousRunId = ADRunsController.assignVehicle(run.id, data.vehicle)
|
||||
if previousRunId ~= nil then
|
||||
|
||||
Reference in New Issue
Block a user