fix(ui): tabelceller skæres af ved egen bredde (textMaxWidth); ens bygningsnavne slås sammen ('Chicken Coop x5') i Oversigt (v1.19.3.0)
This commit is contained in:
@@ -117,3 +117,24 @@ function ADFlowView.buildingRows(buildings, chosen, showAll)
|
||||
end
|
||||
return rows
|
||||
end
|
||||
|
||||
-- "Chicken Coop x3 + Cow Barn": ens navne slås sammen med antal, i rækkefølge efter første forekomst.
|
||||
function ADFlowView.joinCounted(names, separator, empty)
|
||||
local order, counts = {}, {}
|
||||
for _, name in ipairs(names or {}) do
|
||||
local key = tostring(name)
|
||||
if counts[key] == nil then
|
||||
counts[key] = 0
|
||||
table.insert(order, key)
|
||||
end
|
||||
counts[key] = counts[key] + 1
|
||||
end
|
||||
if #order == 0 then
|
||||
return empty
|
||||
end
|
||||
local parts = {}
|
||||
for _, key in ipairs(order) do
|
||||
table.insert(parts, counts[key] > 1 and string.format("%s x%d", key, counts[key]) or key)
|
||||
end
|
||||
return table.concat(parts, separator)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user