diff --git a/FS25_ADSmartPickup/adFieldGuide.lua b/FS25_ADSmartPickup/adFieldGuide.lua index e3bdfa2..9a88741 100644 --- a/FS25_ADSmartPickup/adFieldGuide.lua +++ b/FS25_ADSmartPickup/adFieldGuide.lua @@ -97,6 +97,12 @@ local function isPrepAuto(plan) return (plan.soil or "auto") == "auto" and plan.mulch ~= true and plan.lime ~= false and plan.roll ~= true end +-- Pleje "Automatisk" = al pleje slået til (gødning, ukrudt, kalk). Kalk tæller kun her når den ikke hører +-- under klargøring — ellers afgør klargøringens valg den. +local function isCareAuto(plan) + return plan.fertilize ~= false and plan.weed ~= false and plan.lime ~= false +end + local function storeModeOf(ids, fieldSilos) if #ids == 0 then return "auto" end local silo = {} @@ -114,7 +120,7 @@ local function draftFrom(field, context) local mode = storeModeOf(plan.storeBuildingIds, context.fieldSilos) return { fieldId = field.id, plan = plan, originalTarget = plan.targetFruit or "", - prepAuto = isPrepAuto(plan), useDedicated = #plan.rigIds > 0, + prepAuto = isPrepAuto(plan), careAuto = isCareAuto(plan), useDedicated = #plan.rigIds > 0, storeMode = mode, storeIds = mode == "manual" and ADGuide.deepCopy(plan.storeBuildingIds) or {}, } end @@ -149,7 +155,7 @@ function ADFieldGuide.choose(guide, id, value) draft.plan[id] = value elseif id == "product" then draft.plan.product = value and "hay" or "silage" - elseif id == "prepAuto" or id == "useDedicated" then + elseif id == "prepAuto" or id == "careAuto" or id == "useDedicated" then draft[id] = value == true elseif id == "rigIds" then draft.plan.rigIds = ADGuide.toggleItem(draft.plan.rigIds, value.item, value.on) @@ -242,8 +248,14 @@ local function rowsPrep(guide) end local function rowsCare(guide) - local plan = guide.draft.plan - local rows = {toggle("fertilize", L("spu_field_fertilize"), plan.fertilize ~= false)} + local draft, plan = guide.draft, guide.draft.plan + local rows = {choice("careAuto", L("spu_guide_care"), { + {label = L("spu_guide_auto"), value = true}, {label = L("spu_guide_manual"), value = false}}, draft.careAuto)} + if draft.careAuto then + table.insert(rows, {type = "text", label = L("spu_guide_care_autoText")}) + return rows + end + table.insert(rows, toggle("fertilize", L("spu_field_fertilize"), plan.fertilize ~= false)) if weedVisible(guide) then table.insert(rows, toggle("weed", L("spu_field_weed"), plan.weed ~= false)) end if not prepVisible(guide) then table.insert(rows, toggle("lime", L("spu_field_lime"), plan.lime ~= false)) end return rows @@ -388,6 +400,7 @@ local SUMMARY = { return parts end, care = function(guide) + if guide.draft.careAuto then return {L("spu_guide_sum_auto")} end local plan, parts = guide.draft.plan, {} if plan.fertilize ~= false then table.insert(parts, L("spu_guide_sum_fert")) end if weedVisible(guide) and plan.weed ~= false then table.insert(parts, L("spu_guide_sum_weed")) end @@ -438,6 +451,10 @@ function ADFieldGuide.result(guide, start) if draft.prepAuto and ADFieldGuide.isVisible("prep", guide) then plan.soil, plan.mulch, plan.lime, plan.roll = "auto", false, true, false end + if draft.careAuto and ADFieldGuide.isVisible("care", guide) then + plan.fertilize, plan.weed = true, true + if not prepVisible(guide) then plan.lime = true end + end if ADFieldGuide.isVisible("store", guide) then if draft.storeMode == "fieldSilo" then local ids = {} diff --git a/FS25_ADSmartPickup/l10n/l10n_da.xml b/FS25_ADSmartPickup/l10n/l10n_da.xml index 676de04..16d486e 100644 --- a/FS25_ADSmartPickup/l10n/l10n_da.xml +++ b/FS25_ADSmartPickup/l10n/l10n_da.xml @@ -437,6 +437,8 @@ + + diff --git a/FS25_ADSmartPickup/l10n/l10n_en.xml b/FS25_ADSmartPickup/l10n/l10n_en.xml index 6ada825..6abee4e 100644 --- a/FS25_ADSmartPickup/l10n/l10n_en.xml +++ b/FS25_ADSmartPickup/l10n/l10n_en.xml @@ -437,6 +437,8 @@ + + diff --git a/FS25_ADSmartPickup/modDesc.xml b/FS25_ADSmartPickup/modDesc.xml index f17f3db..0b6d8f6 100644 --- a/FS25_ADSmartPickup/modDesc.xml +++ b/FS25_ADSmartPickup/modDesc.xml @@ -1,7 +1,7 @@ masterdraco - 1.59.7.0 + 1.59.8.0 <en>AD Smart Pickup</en> diff --git a/tests/test_adFieldGuide.lua b/tests/test_adFieldGuide.lua index 4d40752..100a7d4 100644 --- a/tests/test_adFieldGuide.lua +++ b/tests/test_adFieldGuide.lua @@ -122,10 +122,19 @@ check("FG6 vælg selv: kalk", findRow(prepManual, "lime") ~= nil, true) check("FG6 vælg selv: mulch", findRow(prepManual, "mulch") ~= nil, true) check("FG6 vælg selv: ingen tromle uden såning", findRow(prepManual, "roll"), nil) -local careGrass = FG.rows(G.jump(FG.open(field(1), ctx(GRASS)), "care", "close")) +-- pleje: Automatisk/Manuelt som klargøring (brugerønske 29/9); knapperne vises under Manuelt +local careAutoRows = FG.rows(G.jump(g, "care", "close")) +check("FG7 pleje: valg auto/manuel", findRow(careAutoRows, "careAuto").type, "choice") +check("FG7 pleje auto: ingen knapper", findRow(careAutoRows, "fertilize"), nil) +check("FG7 standard: pleje auto", g.draft.careAuto, true) +check("FG7 uden gødning -> manuel", FG.open(field(2, {fertilize = false}), ctx(WHEAT)).draft.careAuto, false) +local autoCare = FG.result(FG.choose(FG.open(field(2, {fertilize = false, weed = false}), ctx(WHEAT)), "careAuto", true), true).plan +check("FG7 auto slår gødning til", autoCare.fertilize, true) +check("FG7 auto slår ukrudt til", autoCare.weed, true) +local careGrass = FG.rows(G.jump(FG.choose(FG.open(field(1), ctx(GRASS)), "careAuto", false), "care", "close")) check("FG7 græs: ingen ukrudt", findRow(careGrass, "weed"), nil) check("FG7 græs: kalk i pleje", findRow(careGrass, "lime") ~= nil, true) -local careWheat = FG.rows(G.jump(g, "care", "close")) +local careWheat = FG.rows(G.jump(FG.choose(g, "careAuto", false), "care", "close")) check("FG7 hvede: ukrudt", findRow(careWheat, "weed") ~= nil, true) check("FG7 hvede: kalk ikke i pleje", findRow(careWheat, "lime"), nil) @@ -215,7 +224,8 @@ check("FG16 linjer for synlige trin", #sum, 6) check("FG16 afgrøde behold", partKeys(lineFor(sum, "crop")), "spu_guide_crop_keep") check("FG16 halm", partKeys(lineFor(sum, "cropChoice")), "spu_guide_sum_straw_chop") check("FG16 klargøring auto", partKeys(lineFor(sum, "prep")), "spu_guide_sum_auto") -check("FG16 pleje", partKeys(lineFor(sum, "care")), "spu_guide_sum_fert,spu_guide_sum_weed") +check("FG16 pleje auto", partKeys(lineFor(sum, "care")), "spu_guide_sum_auto") +check("FG16 pleje manuel", partKeys(lineFor(FG.summary(FG.choose(g, "careAuto", false)), "care")), "spu_guide_sum_fert,spu_guide_sum_weed") check("FG16 maskiner", partKeys(lineFor(sum, "machines")), "spu_guide_sum_freeRigs,spu_guide_sum_rigs,spu_guide_sum_unloaders") check("FG16 lager auto", partKeys(lineFor(sum, "store")), "spu_guide_sum_auto") check("FG16 ingen mark/summary-linje", lineFor(sum, "summary"), nil) @@ -231,7 +241,7 @@ check("FG17 lager valgt silo", partKeys(lineFor(FG.summary(manual), "store")), " check("FG17 lager marksilo", partKeys(lineFor(FG.summary(useSilo), "store")), "spu_guide_sum_fieldSilo") local sumHay = FG.summary(FG.choose(FG.choose(FG.open(field(1), ctx(GRASS)), "product", true), "rake", true)) check("FG17 hø + river", partKeys(lineFor(sumHay, "cropChoice")), "spu_field_plan_hay,spu_guide_sum_rake") -local sumNoCare = FG.summary(FG.choose(FG.choose(g, "fertilize", false), "weed", false)) +local sumNoCare = FG.summary(FG.choose(FG.choose(FG.choose(g, "careAuto", false), "fertilize", false), "weed", false)) check("FG17 ingen pleje", partKeys(lineFor(sumNoCare, "care")), "spu_guide_sum_noCare") local sumSow = FG.summary(FG.choose(g, "sow", true)) check("FG17 så igen", partKeys(lineFor(sumSow, "crop")), "spu_guide_crop_keep,spu_guide_sum_sowAgain")