From 08d983800c66bcb7a123655ae308dac5239be782 Mon Sep 17 00:00:00 2001 From: masterdraco Date: Sat, 26 Sep 2026 12:03:56 +0200 Subject: [PATCH] =?UTF-8?q?fix(gui):=20bygningsr=C3=A6kker=20i=20fast=20r?= =?UTF-8?q?=C3=A6kkef=C3=B8lge=20(navn,=20s=C3=A5=20mark=C3=B8r)=20?= =?UTF-8?q?=E2=80=94=20et=20tryk=20flyttede=20valgte=20drops=20op=20i=20to?= =?UTF-8?q?ppen;=20fjernet=20bygning=20vises=20som=20'Fjernet=20bygning'?= =?UTF-8?q?=20i=20stedet=20for=20r=C3=A5=20id=20(v1.28.4.0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FS25_ADSmartPickup/adFlowView.lua | 21 +++++++++++++------ FS25_ADSmartPickup/gui/SmartPickupFlowTab.lua | 6 +++--- FS25_ADSmartPickup/l10n/l10n_da.xml | 2 +- FS25_ADSmartPickup/l10n/l10n_en.xml | 2 +- FS25_ADSmartPickup/modDesc.xml | 2 +- tests/test_adFlowView.lua | 14 +++++++++++-- 6 files changed, 33 insertions(+), 14 deletions(-) diff --git a/FS25_ADSmartPickup/adFlowView.lua b/FS25_ADSmartPickup/adFlowView.lua index 78afd9c..e2e8a82 100644 --- a/FS25_ADSmartPickup/adFlowView.lua +++ b/FS25_ADSmartPickup/adFlowView.lua @@ -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 diff --git a/FS25_ADSmartPickup/gui/SmartPickupFlowTab.lua b/FS25_ADSmartPickup/gui/SmartPickupFlowTab.lua index 4d3ad52..cf20b0d 100644 --- a/FS25_ADSmartPickup/gui/SmartPickupFlowTab.lua +++ b/FS25_ADSmartPickup/gui/SmartPickupFlowTab.lua @@ -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 diff --git a/FS25_ADSmartPickup/l10n/l10n_da.xml b/FS25_ADSmartPickup/l10n/l10n_da.xml index e7f44e5..1067ef8 100644 --- a/FS25_ADSmartPickup/l10n/l10n_da.xml +++ b/FS25_ADSmartPickup/l10n/l10n_da.xml @@ -260,7 +260,7 @@ - + diff --git a/FS25_ADSmartPickup/l10n/l10n_en.xml b/FS25_ADSmartPickup/l10n/l10n_en.xml index 71b0a6e..e916ab2 100644 --- a/FS25_ADSmartPickup/l10n/l10n_en.xml +++ b/FS25_ADSmartPickup/l10n/l10n_en.xml @@ -260,7 +260,7 @@ - + diff --git a/FS25_ADSmartPickup/modDesc.xml b/FS25_ADSmartPickup/modDesc.xml index 3233bfc..26f884a 100644 --- a/FS25_ADSmartPickup/modDesc.xml +++ b/FS25_ADSmartPickup/modDesc.xml @@ -1,7 +1,7 @@ masterdraco - 1.28.3.0 + 1.28.4.0 <en>AD Smart Pickup</en> diff --git a/tests/test_adFlowView.lua b/tests/test_adFlowView.lua index e0b1a02..c64d380 100644 --- a/tests/test_adFlowView.lua +++ b/tests/test_adFlowView.lua @@ -57,8 +57,18 @@ local buildings = { {id = "a", name = "Anlæg", hasMarker = 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") -check("FV3 vis alle: uden markør til sidst", ids(V.buildingRows(buildings, chosen, true)), "y,s10,a,s2,x") +-- fast rækkefølge (et tryk må ikke flytte rækken — in-game 26/9 hoppede valgte drops op i toppen) +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 check("FV4 sammenlæg", V.joinCounted({"Chicken Coop", "Chicken Coop", "Cow Barn", "Chicken Coop"}, " + ", "-"), "Chicken Coop x3 + Cow Barn")