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:
@@ -101,18 +101,27 @@ end
|
|||||||
-- Bygninger: buildings = {{id, name, hasMarker}}, chosen = {[id] = true}. Valgte først; bygninger uden
|
-- 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).
|
-- 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)
|
function ADFlowView.buildingRows(buildings, chosen, showAll)
|
||||||
local picked, withMarker, withoutMarker = {}, {}, {}
|
local shown, withoutMarker = {}, {}
|
||||||
for _, building in ipairs(buildings or {}) do
|
for _, building in ipairs(buildings or {}) do
|
||||||
if chosen ~= nil and chosen[building.id] then
|
if (chosen ~= nil and chosen[building.id]) or building.hasMarker then
|
||||||
table.insert(picked, building)
|
table.insert(shown, building)
|
||||||
elseif building.hasMarker then
|
|
||||||
table.insert(withMarker, building)
|
|
||||||
elseif showAll then
|
elseif showAll then
|
||||||
table.insert(withoutMarker, building)
|
table.insert(withoutMarker, building)
|
||||||
end
|
end
|
||||||
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 = {}
|
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
|
for _, building in ipairs(list) do table.insert(rows, building) end
|
||||||
end
|
end
|
||||||
return rows
|
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"
|
local rowKind = role == "load" and "sourceBuilding" or role == "store" and "storeBuilding" or "targetBuilding"
|
||||||
for _, id in ipairs(ids or {}) do chosen[id] = true end
|
for _, id in ipairs(ids or {}) do chosen[id] = true end
|
||||||
local count = 0
|
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 = {}
|
local candidates = {}
|
||||||
-- "Lager til": kun bygninger der kan tage flowets lagervarer (æg-paller -> palleskure der tager æg)
|
-- "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
|
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)))
|
or (role == "store" and isStoreKind and (chosen[building.id] or ADRunsController.canStoreAt(adEnv, building, storeGoods)))
|
||||||
if fits then
|
if fits then
|
||||||
local markers = ADBuildings.getMarkers ~= nil and ADBuildings.getMarkers(building, role == "store" and "unload" or role) or {}
|
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
|
||||||
end
|
end
|
||||||
local shown = ADFlowView.buildingRows(candidates, chosen, self.showAllBuildings == true)
|
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
|
for _, id in ipairs(ids or {}) do
|
||||||
if ADBuildings.find(adEnv, g_currentMission:getFarmId(), id) == nil then
|
if ADBuildings.find(adEnv, g_currentMission:getFarmId(), id) == nil then
|
||||||
local row = self:addRow(self.ingredientPrefab, {kind = rowKind, buildingId = id})
|
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)
|
row:getDescendantByName("option"):setState(SmartPickupFrame.STATE_ON, false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -260,7 +260,7 @@
|
|||||||
<text name="spu_markerAt" text="%s %d m"/>
|
<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_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_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_reason_noMarker" text="'%s' mangler en AD-markør ved triggeren"/>
|
||||||
<text name="spu_storage_select" text="Vis bygning"/>
|
<text name="spu_storage_select" text="Vis bygning"/>
|
||||||
<text name="spu_stat_now" text="nu %s"/>
|
<text name="spu_stat_now" text="nu %s"/>
|
||||||
|
|||||||
@@ -260,7 +260,7 @@
|
|||||||
<text name="spu_markerAt" text="%s %d m"/>
|
<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_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_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_reason_noMarker" text="'%s' has no AD marker at its trigger"/>
|
||||||
<text name="spu_storage_select" text="Show building"/>
|
<text name="spu_storage_select" text="Show building"/>
|
||||||
<text name="spu_stat_now" text="now %s"/>
|
<text name="spu_stat_now" text="now %s"/>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
<modDesc descVersion="107">
|
<modDesc descVersion="107">
|
||||||
<author>masterdraco</author>
|
<author>masterdraco</author>
|
||||||
<version>1.28.3.0</version>
|
<version>1.28.4.0</version>
|
||||||
<title>
|
<title>
|
||||||
<en>AD Smart Pickup</en>
|
<en>AD Smart Pickup</en>
|
||||||
</title>
|
</title>
|
||||||
|
|||||||
@@ -57,8 +57,18 @@ local buildings = {
|
|||||||
{id = "a", name = "Anlæg", hasMarker = true},
|
{id = "a", name = "Anlæg", hasMarker = true},
|
||||||
}
|
}
|
||||||
local chosen = {s10 = true, y = true}
|
local chosen = {s10 = true, y = true}
|
||||||
check("FV3 standard: valgte først, så med markør", ids(V.buildingRows(buildings, chosen, false)), "y,s10,a,s2")
|
-- fast rækkefølge (et tryk må ikke flytte rækken — in-game 26/9 hoppede valgte drops op i toppen)
|
||||||
check("FV3 vis alle: uden markør til sidst", ids(V.buildingRows(buildings, chosen, true)), "y,s10,a,s2,x")
|
check("FV3 standard: fast rækkefølge efter navn, valgte bliver hvor de er", ids(V.buildingRows(buildings, chosen, false)), "y,a,s2,s10")
|
||||||
|
check("FV3 vis alle: uden markør til sidst", ids(V.buildingRows(buildings, chosen, true)), "y,a,s2,s10,x")
|
||||||
|
-- ens bygningsnavne (5 x "BGA (1) : DOB 115") sorteres efter markørnavnet
|
||||||
|
local drops = {
|
||||||
|
{id = "d5", name = "DOB", label = "Biogas Drop 5", hasMarker = true},
|
||||||
|
{id = "d3", name = "DOB", label = "Biogas Drop 3", hasMarker = true},
|
||||||
|
{id = "d1", name = "DOB", label = "Biogas Drop 1", hasMarker = true},
|
||||||
|
{id = "d4", name = "DOB", label = "Biogas Drop 4", hasMarker = true},
|
||||||
|
{id = "d2", name = "DOB", label = "Biogas Drop 2", hasMarker = true},
|
||||||
|
}
|
||||||
|
check("FV3 ens navne efter markør", ids(V.buildingRows(drops, {d2 = true}, false)), "d1,d2,d3,d4,d5")
|
||||||
|
|
||||||
-- FV4: ens navne slås sammen med antal ("Chicken Coop x5"), rækkefølge efter første forekomst
|
-- FV4: ens navne slås sammen med antal ("Chicken Coop x5"), rækkefølge efter første forekomst
|
||||||
check("FV4 sammenlæg", V.joinCounted({"Chicken Coop", "Chicken Coop", "Cow Barn", "Chicken Coop"}, " + ", "-"), "Chicken Coop x3 + Cow Barn")
|
check("FV4 sammenlæg", V.joinCounted({"Chicken Coop", "Chicken Coop", "Cow Barn", "Chicken Coop"}, " + ", "-"), "Chicken Coop x3 + Cow Barn")
|
||||||
|
|||||||
Reference in New Issue
Block a user