feat(gui): markens lagervalg viser markørnavn og afstand, marksilo/gæringssilo først, kun de 8 nærmeste (34 ens Farma-rækker) (v1.29.5.0)
This commit is contained in:
@@ -185,6 +185,9 @@ function SmartPickupFrame:fillFieldRows(adEnv)
|
||||
self:fillFleetRows(adEnv)
|
||||
end
|
||||
|
||||
-- lagervalget viser de nærmeste siloer (plus valgte, marksiloer og gæringssiloer)
|
||||
SmartPickupFrame.FIELD_STORE_ROWS = 8
|
||||
|
||||
function SmartPickupFrame:fillFieldDetail(adEnv, info)
|
||||
local i18n = self.i18n
|
||||
local field = ADFieldJobs.getField(info.id)
|
||||
@@ -284,18 +287,38 @@ function SmartPickupFrame:fillFieldStoreRows(adEnv, info, field)
|
||||
if info.kind == "mowable" and product == "silage" then
|
||||
for _, building in ipairs(ADFieldJobs.getFermenters(adEnv, farmId, fillType, info.x, info.z)) do fermenterIds[building.id] = true end
|
||||
end
|
||||
local count = 0
|
||||
-- kandidater med markørnavn og afstand til marken (34 ens "Farma 500 + Obi 1000" kan ellers ikke skelnes)
|
||||
local entries = {}
|
||||
for _, building in ipairs(ADBuildings.list(adEnv, farmId)) do
|
||||
local isSilo = building.kind == "silo" and ADRunsController.canStoreAt(adEnv, building, {{fillType = fillType, isPallet = false}})
|
||||
if chosen[building.id] or isSilo or fermenterIds[building.id] then
|
||||
count = count + 1
|
||||
local row = self:addRow(self.ingredientPrefab, {kind = "fieldStore", buildingId = building.id})
|
||||
local suffix = fieldSilos[building.id] ~= nil and (" (" .. i18n:getText("spu_field_fieldSilo") .. ")") or ""
|
||||
if fermenterIds[building.id] then suffix = suffix .. " (" .. i18n:getText("spu_field_fermenter") .. ")" end
|
||||
row:getDescendantByName("title"):setText(" " .. tostring(building.name) .. suffix)
|
||||
row:getDescendantByName("option"):setState(chosen[building.id] and SmartPickupFrame.STATE_ON or SmartPickupFrame.STATE_OFF, false)
|
||||
local distance = nil
|
||||
local node = building.placeable ~= nil and building.placeable.rootNode or nil
|
||||
if node ~= nil and info.x ~= nil then
|
||||
local bx, _, bz = getWorldTranslation(node)
|
||||
distance = math.sqrt((bx - info.x) ^ 2 + (bz - info.z) ^ 2)
|
||||
end
|
||||
table.insert(entries, {id = building.id, building = building, distance = distance, chosen = chosen[building.id] == true,
|
||||
fieldSilo = fieldSilos[building.id] ~= nil, fermenter = fermenterIds[building.id] == true})
|
||||
end
|
||||
end
|
||||
local storeRows, hiddenStores = ADFieldView.storeRows(entries, SmartPickupFrame.FIELD_STORE_ROWS)
|
||||
local count = #storeRows
|
||||
for _, entry in ipairs(storeRows) do
|
||||
local building = entry.building
|
||||
local row = self:addRow(self.ingredientPrefab, {kind = "fieldStore", buildingId = building.id})
|
||||
local markers = ADBuildings.getMarkers ~= nil and ADBuildings.getMarkers(building, "unload") or {}
|
||||
-- det der skelner rækkerne først (rækken afkorter bagfra): markør, afstand, art — så bygningens navn
|
||||
local label = (markers[1] ~= nil and tostring(markers[1].name) or tostring(building.name)) .. ", " .. ADFieldView.distanceText(entry.distance)
|
||||
if entry.fieldSilo then label = label .. " (" .. i18n:getText("spu_field_fieldSilo") .. ")" end
|
||||
if entry.fermenter then label = label .. " (" .. i18n:getText("spu_field_fermenter") .. ")" end
|
||||
if markers[1] ~= nil then label = label .. " — " .. tostring(building.name) end
|
||||
row:getDescendantByName("title"):setText(" " .. label)
|
||||
row:getDescendantByName("option"):setState(entry.chosen and SmartPickupFrame.STATE_ON or SmartPickupFrame.STATE_OFF, false)
|
||||
end
|
||||
if hiddenStores > 0 then
|
||||
self:addTextRow(" " .. string.format(i18n:getText("spu_field_storeHidden"), hiddenStores))
|
||||
end
|
||||
if count == 0 then
|
||||
self:addTextRow(" " .. i18n:getText("spu_field_noStore"))
|
||||
elseif #field.plan.storeBuildingIds == 0 then
|
||||
|
||||
Reference in New Issue
Block a user