diff --git a/FS25_ADSmartPickup/adFlowGuide.lua b/FS25_ADSmartPickup/adFlowGuide.lua index 47656ca..f9bf77e 100644 --- a/FS25_ADSmartPickup/adFlowGuide.lua +++ b/FS25_ADSmartPickup/adFlowGuide.lua @@ -143,6 +143,13 @@ local function setPolicy(products, name, policy) end function ADFlowGuide.choose(guide, id, value) + if id == "showBlocked" then + -- visning, ikke en del af flowet: fold listen over traktorer der ikke kan bruges ud/ind + local copy = {} + for key, field in pairs(guide) do copy[key] = field end + copy.showBlocked = not guide.showBlocked + return copy + end local draft = ADGuide.deepCopy(guide.draft) if SET_VALUES[id] then draft[id] = value @@ -328,10 +335,13 @@ local function rowsTractors(guide) if #rows == 0 then table.insert(rows, text("spu_guide_flow_noTractors")) end if other > 0 then table.insert(rows, text("spu_guide_flow_otherFlows", {other})) end if blocked > 0 then - table.insert(rows, text("spu_guide_flow_blocked", {blocked})) - -- navn + grund (fx "X ingen vogn"), så man kan se hvorfor en traktor ikke kan vælges - table.sort(blockedTexts) - for _, line in ipairs(blockedTexts) do table.insert(rows, {type = "text", label = T(" " .. line)}) end + -- foldet sammen som standard; linjen med antallet folder navn + grund ud/ind + local key = guide.showBlocked and "spu_guide_flow_blockedHide" or "spu_guide_flow_blockedShow" + table.insert(rows, {type = "link", id = "showBlocked", value = true, label = L(key, {blocked})}) + if guide.showBlocked then + table.sort(blockedTexts) + for _, line in ipairs(blockedTexts) do table.insert(rows, {type = "text", label = T(" " .. line)}) end + end end return rows end diff --git a/FS25_ADSmartPickup/l10n/l10n_da.xml b/FS25_ADSmartPickup/l10n/l10n_da.xml index 4b3000e..c2c708b 100644 --- a/FS25_ADSmartPickup/l10n/l10n_da.xml +++ b/FS25_ADSmartPickup/l10n/l10n_da.xml @@ -451,6 +451,8 @@ + + diff --git a/FS25_ADSmartPickup/l10n/l10n_en.xml b/FS25_ADSmartPickup/l10n/l10n_en.xml index f0edaa9..44b8af1 100644 --- a/FS25_ADSmartPickup/l10n/l10n_en.xml +++ b/FS25_ADSmartPickup/l10n/l10n_en.xml @@ -451,6 +451,8 @@ + + diff --git a/FS25_ADSmartPickup/modDesc.xml b/FS25_ADSmartPickup/modDesc.xml index c39fb04..58d67a8 100644 --- a/FS25_ADSmartPickup/modDesc.xml +++ b/FS25_ADSmartPickup/modDesc.xml @@ -1,7 +1,7 @@ masterdraco - 1.36.5.0 + 1.36.6.0 <en>AD Smart Pickup</en> diff --git a/tests/test_adFlowGuide.lua b/tests/test_adFlowGuide.lua index 921ccd9..592b6a9 100644 --- a/tests/test_adFlowGuide.lua +++ b/tests/test_adFlowGuide.lua @@ -161,11 +161,25 @@ check("FL9 traktorer: kun egne + ledige", countType(tractorRows, "check"), 2) check("FL9 egne først", (function() for _, r in ipairs(tractorRows) do if r.type == "check" then return r.item end end end)(), "t4") check("FL9 skjult andre flows", findRow(tractorRows, "vehicleIds", "t2"), nil) check("FL9 skjult blokeret", findRow(tractorRows, "vehicleIds", "t3"), nil) -check("FL9 linjer", textKeys(tractorRows), "spu_guide_flow_otherFlows,spu_guide_flow_blocked") --- in-game 27/9: en parkeret Lintrac dukkede ikke op og ingen kunne se hvorfor — blokerede står med navn + grund -local blockedLine = nil -for _, r in ipairs(tractorRows) do if r.type == "text" and r.label.text ~= nil and r.label.text:find("Traktor 3", 1, true) then blockedLine = r end end -check("FL9 blokeret traktor vises med sin tekst", blockedLine ~= nil, true) +check("FL9 linjer", textKeys(tractorRows), "spu_guide_flow_otherFlows") +-- blokerede traktorer: foldet sammen som standard (in-game 27/9: 37 linjer der ikke kunne bruges fyldte trinnet); +-- linjen med antallet er et link der folder navn + grund ud og ind +local function blockedLine(rows) + for _, r in ipairs(rows) do if r.type == "text" and r.label.text ~= nil and r.label.text:find("Traktor 3", 1, true) then return r end end + return nil +end +local function blockedLink(rows) + for _, r in ipairs(rows) do if r.type == "link" and r.id == "showBlocked" then return r end end + return nil +end +check("FL9 blokerede foldet sammen som standard", blockedLine(tractorRows), nil) +check("FL9 link med antal", blockedLink(tractorRows) ~= nil and blockedLink(tractorRows).label.key, "spu_guide_flow_blockedShow") +local expanded = FG.choose(assigned, "showBlocked", true) +local expandedRows = FG.rows(at(expanded, "tractors")) +check("FL9 foldet ud viser navn + grund", blockedLine(expandedRows) ~= nil, true) +check("FL9 foldet ud: link skjuler igen", blockedLink(expandedRows).label.key, "spu_guide_flow_blockedHide") +check("FL9 fold ud ændrer ikke kladden", expanded.draft.vehicleIds[1], "t4") +check("FL9 fold sammen igen", blockedLine(FG.rows(at(FG.choose(expanded, "showBlocked", true), "tractors"))), nil) local inThisRun = FG.open(newRun("supply"), ctx({vehicles = {{id = "t2", text = "T2", otherRunId = 1, otherRunName = "Mælk ud"}}})) check("FL9 traktor i dette flow er ikke 'andet flow'", countType(FG.rows(at(inThisRun, "tractors")), "check"), 1)