fix(gui): bygningsrækker i fast rækkefølge (navn, så markør) — et tryk flyttede valgte drops op i toppen; fjernet bygning vises som 'Fjernet bygning' i stedet for rå id (v1.28.4.0)

This commit is contained in:
2026-09-26 12:03:56 +02:00
parent 41e50ccec8
commit 08d983800c
6 changed files with 33 additions and 14 deletions
+15 -6
View File
@@ -101,18 +101,27 @@ end
-- Bygninger: buildings = {{id, name, hasMarker}}, chosen = {[id] = true}. Valgte først; bygninger uden
-- markør kun hvis valgte eller showAll (de kan alligevel ikke bruges før en markør er sat).
function ADFlowView.buildingRows(buildings, chosen, showAll)
local picked, withMarker, withoutMarker = {}, {}, {}
local shown, withoutMarker = {}, {}
for _, building in ipairs(buildings or {}) do
if chosen ~= nil and chosen[building.id] then
table.insert(picked, building)
elseif building.hasMarker then
table.insert(withMarker, building)
if (chosen ~= nil and chosen[building.id]) or building.hasMarker then
table.insert(shown, building)
elseif showAll then
table.insert(withoutMarker, building)
end
end
-- fast rækkefølge: bygningsnavn, så markørnavn (label) — et tryk må ikke flytte rækken under markøren
local function byNameThenLabel(list)
local copy = {}
for _, item in ipairs(list) do table.insert(copy, item) end
table.sort(copy, function(a, b)
if a.name ~= b.name then return ADFlowView.naturalLess(a.name, b.name) end
if (a.label or "") ~= (b.label or "") then return ADFlowView.naturalLess(a.label or "", b.label or "") end
return tostring(a.id) < tostring(b.id)
end)
return copy
end
local rows = {}
for _, list in ipairs({sortedBy(picked, "name"), sortedBy(withMarker, "name"), sortedBy(withoutMarker, "name")}) do
for _, list in ipairs({byNameThenLabel(shown), byNameThenLabel(withoutMarker)}) do
for _, building in ipairs(list) do table.insert(rows, building) end
end
return rows
@@ -148,7 +148,7 @@ function SmartPickupFrame:fillBuildingRows(adEnv, run, role)
local rowKind = role == "load" and "sourceBuilding" or role == "store" and "storeBuilding" or "targetBuilding"
for _, id in ipairs(ids or {}) do chosen[id] = true end
local count = 0
-- kandidater -> valgte først, så med markør; uden markør kun med "Vis alle bygninger"
-- kandidater i fast rækkefølge (navn, markør); uden markør kun med "Vis alle bygninger"
local candidates = {}
-- "Lager til": kun bygninger der kan tage flowets lagervarer (æg-paller -> palleskure der tager æg)
local storeGoods = role == "store" and ADRunsController.getStoreGoods(adEnv, run) or nil
@@ -158,7 +158,7 @@ function SmartPickupFrame:fillBuildingRows(adEnv, run, role)
or (role == "store" and isStoreKind and (chosen[building.id] or ADRunsController.canStoreAt(adEnv, building, storeGoods)))
if fits then
local markers = ADBuildings.getMarkers ~= nil and ADBuildings.getMarkers(building, role == "store" and "unload" or role) or {}
table.insert(candidates, {id = building.id, name = building.name, hasMarker = markers[1] ~= nil, building = building})
table.insert(candidates, {id = building.id, name = building.name, label = markers[1] ~= nil and tostring(markers[1].name) or nil, hasMarker = markers[1] ~= nil, building = building})
end
end
local shown = ADFlowView.buildingRows(candidates, chosen, self.showAllBuildings == true)
@@ -177,7 +177,7 @@ function SmartPickupFrame:fillBuildingRows(adEnv, run, role)
for _, id in ipairs(ids or {}) do
if ADBuildings.find(adEnv, g_currentMission:getFarmId(), id) == nil then
local row = self:addRow(self.ingredientPrefab, {kind = rowKind, buildingId = id})
row:getDescendantByName("title"):setText(string.format(" %s — %s", tostring(id), self.i18n:getText("spu_buildingGone")))
row:getDescendantByName("title"):setText(" " .. self.i18n:getText("spu_buildingGone"))
row:getDescendantByName("option"):setState(SmartPickupFrame.STATE_ON, false)
end
end
+1 -1
View File
@@ -260,7 +260,7 @@
<text name="spu_markerAt" text="%s %d m"/>
<text name="spu_noMarker" text="INGEN MARKØR inden for 40 m — sæt en AD-markør ved triggeren"/>
<text name="spu_noBuildings" text="Ingen bygninger fundet"/>
<text name="spu_buildingGone" text="bygningen findes ikke længere"/>
<text name="spu_buildingGone" text="Fjernet bygning (findes ikke mere) — sæt NEJ"/>
<text name="spu_reason_noMarker" text="'%s' mangler en AD-markør ved triggeren"/>
<text name="spu_storage_select" text="Vis bygning"/>
<text name="spu_stat_now" text="nu %s"/>
+1 -1
View File
@@ -260,7 +260,7 @@
<text name="spu_markerAt" text="%s %d m"/>
<text name="spu_noMarker" text="NO MARKER within 40 m — place an AD marker at the trigger"/>
<text name="spu_noBuildings" text="No buildings found"/>
<text name="spu_buildingGone" text="building no longer exists"/>
<text name="spu_buildingGone" text="Removed building (no longer exists) — set NO"/>
<text name="spu_reason_noMarker" text="'%s' has no AD marker at its trigger"/>
<text name="spu_storage_select" text="Show building"/>
<text name="spu_stat_now" text="now %s"/>
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<modDesc descVersion="107">
<author>masterdraco</author>
<version>1.28.3.0</version>
<version>1.28.4.0</version>
<title>
<en>AD Smart Pickup</en>
</title>