diff --git a/FS25_ADSmartPickup/adFlowView.lua b/FS25_ADSmartPickup/adFlowView.lua index 54f4dcc..78afd9c 100644 --- a/FS25_ADSmartPickup/adFlowView.lua +++ b/FS25_ADSmartPickup/adFlowView.lua @@ -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 diff --git a/FS25_ADSmartPickup/gui/SmartPickupFlowTab.lua b/FS25_ADSmartPickup/gui/SmartPickupFlowTab.lua index 68cd2fd..b8f07d6 100644 --- a/FS25_ADSmartPickup/gui/SmartPickupFlowTab.lua +++ b/FS25_ADSmartPickup/gui/SmartPickupFlowTab.lua @@ -37,7 +37,7 @@ function SmartPickupFrame:flowCells(adEnv, run) end local from, to if row.kind == "outbound" then - from = joinOr(mark(row.fromNames), i18n:getText("spu_flow_noSource")) + from = ADFlowView.joinCounted(mark(row.fromNames), " + ", i18n:getText("spu_flow_noSource")) local seen, policies = {}, {} for _, policy in ipairs(row.policies) do if not seen[policy] then seen[policy] = true; table.insert(policies, i18n:getText("spu_policy_" .. policy)) end @@ -45,7 +45,7 @@ function SmartPickupFrame:flowCells(adEnv, run) to = joinOr(policies, i18n:getText("spu_flow_noProducts")) else from = i18n:getText("spu_from_allSilos") - to = joinOr(mark(row.toNames), i18n:getText("spu_flow_noTarget")) + to = ADFlowView.joinCounted(mark(row.toNames), " + ", i18n:getText("spu_flow_noTarget")) end local rule if row.kind == "outbound" then diff --git a/FS25_ADSmartPickup/gui/SmartPickupFrame.xml b/FS25_ADSmartPickup/gui/SmartPickupFrame.xml index 197f596..0a13383 100644 --- a/FS25_ADSmartPickup/gui/SmartPickupFrame.xml +++ b/FS25_ADSmartPickup/gui/SmartPickupFrame.xml @@ -74,28 +74,28 @@ - - - - - - + + + + + + - - - - - - - + + + + + + + - - - + + + diff --git a/FS25_ADSmartPickup/modDesc.xml b/FS25_ADSmartPickup/modDesc.xml index 42d1542..4300286 100644 --- a/FS25_ADSmartPickup/modDesc.xml +++ b/FS25_ADSmartPickup/modDesc.xml @@ -1,7 +1,7 @@ masterdraco - 1.19.2.0 + 1.19.3.0 <en>AD Smart Pickup</en> diff --git a/docs/BRUGERMANUAL.md b/docs/BRUGERMANUAL.md index 7f54b0b..d438ed0 100644 --- a/docs/BRUGERMANUAL.md +++ b/docs/BRUGERMANUAL.md @@ -1,6 +1,6 @@ # AD Smart Pickup — brugermanual -Version 1.19.2 · Farming Simulator 25 · tillæg til AutoDrive +Version 1.19.3 · Farming Simulator 25 · tillæg til AutoDrive *English version: [USER_MANUAL.md](USER_MANUAL.md)* diff --git a/docs/USER_MANUAL.md b/docs/USER_MANUAL.md index e53a3be..c0eea3c 100644 --- a/docs/USER_MANUAL.md +++ b/docs/USER_MANUAL.md @@ -1,6 +1,6 @@ # AD Smart Pickup — user manual -Version 1.19.2 · Farming Simulator 25 · add-on for AutoDrive +Version 1.19.3 · Farming Simulator 25 · add-on for AutoDrive *Dansk version: [BRUGERMANUAL.md](BRUGERMANUAL.md)* diff --git a/tests/test_adFlowView.lua b/tests/test_adFlowView.lua index 3fefd5f..e0b1a02 100644 --- a/tests/test_adFlowView.lua +++ b/tests/test_adFlowView.lua @@ -60,5 +60,10 @@ 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") check("FV3 vis alle: uden markør til sidst", ids(V.buildingRows(buildings, chosen, true)), "y,s10,a,s2,x") +-- 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 ingen dubletter", V.joinCounted({"A", "B"}, " + ", "-"), "A + B") +check("FV4 tom -> tekst", V.joinCounted({}, " + ", "(ingen)"), "(ingen)") + print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL")) os.exit(failures == 0 and 0 or 1)