feat(gui): lange tekstrækker ombrydes over flere linjer i stedet for at blive afkortet; markdetaljen viser hele statusteksten (v1.29.4.0)

This commit is contained in:
2026-09-26 16:29:21 +02:00
parent 813ee6d0b9
commit 1b0a2c152b
7 changed files with 47 additions and 4 deletions
+19
View File
@@ -147,3 +147,22 @@ function ADFlowView.joinCounted(names, separator, empty)
end end
return table.concat(parts, separator) return table.concat(parts, separator)
end end
-- Lang tekst -> linjer på højst maxChars (ombrydes ved mellemrum; indrykning gentages på hver linje,
-- så en indrykket forklaring forbliver indrykket). Ét ord længere end linjen deles ikke.
function ADFlowView.wrapText(text, maxChars)
text = tostring(text or "")
if #text <= maxChars then return {text} end
local indent = string.match(text, "^%s*") or ""
local lines, line = {}, indent
for word in string.gmatch(string.sub(text, #indent + 1), "%S+") do
if line ~= indent and #line + 1 + #word > maxChars then
table.insert(lines, line)
line = indent .. word
else
line = line == indent and (indent .. word) or (line .. " " .. word)
end
end
if line ~= indent then table.insert(lines, line) end
return lines
end
@@ -192,6 +192,8 @@ function SmartPickupFrame:fillFieldDetail(adEnv, info)
local yesNo = {i18n:getText("ui_no"), i18n:getText("ui_yes")} local yesNo = {i18n:getText("ui_no"), i18n:getText("ui_yes")}
local crop = ADFieldView.cropText(info, function(key) return i18n:getText(key) end) local crop = ADFieldView.cropText(info, function(key) return i18n:getText(key) end)
self:addTextRow(string.format(i18n:getText("spu_field_section"), info.id, crop)) self:addTextRow(string.format(i18n:getText("spu_field_section"), info.id, crop))
-- hele statusteksten (tabellens celle afkorter den)
self:addTextRow(" " .. string.format(i18n:getText("spu_field_statusFull"), self:fieldStatusText(field, info)))
local targetTexts, targetValues = self:sowFruitChoices("spu_field_target_none") local targetTexts, targetValues = self:sowFruitChoices("spu_field_target_none")
self:addChoiceRow("fieldTarget", i18n:getText("spu_field_target"), targetTexts, targetValues, plan.targetFruit or "") self:addChoiceRow("fieldTarget", i18n:getText("spu_field_target"), targetTexts, targetValues, plan.targetFruit or "")
local hasTarget = plan.targetFruit ~= nil and plan.targetFruit ~= "" local hasTarget = plan.targetFruit ~= nil and plan.targetFruit ~= ""
+11 -3
View File
@@ -340,10 +340,18 @@ function SmartPickupFrame:addRow(prefab, data)
end end
-- Tekstrække uden valgmuligheder: sektionstitler, Wait-pulje-linjer og statuslinjen. -- Tekstrække uden valgmuligheder: sektionstitler, Wait-pulje-linjer og statuslinjen.
-- Tegn pr. tekstrække før teksten ombrydes (rækken afkorter med "..." ved ca. 70 tegn).
SmartPickupFrame.TEXT_ROW_CHARS = 66
-- Lange tekster fordeles på flere rækker i stedet for at blive afkortet. Returnerer første rækkes titel.
function SmartPickupFrame:addTextRow(text) function SmartPickupFrame:addTextRow(text)
local title = self:addRow(self.textPrefab, {kind = "text"}):getDescendantByName("title") local first = nil
title:setText(text) for _, line in ipairs(ADFlowView.wrapText(text, SmartPickupFrame.TEXT_ROW_CHARS)) do
return title local title = self:addRow(self.textPrefab, {kind = "text"}):getDescendantByName("title")
title:setText(line)
first = first or title
end
return first
end end
-- AutoDrive farver hver række i onCreate; her sker det efter hver genopbygning, -- AutoDrive farver hver række i onCreate; her sker det efter hver genopbygning,
+1
View File
@@ -73,6 +73,7 @@
<text name="spu_col_plan" text="Plan"/> <text name="spu_col_plan" text="Plan"/>
<text name="spu_col_mode" text="Kørsel"/> <text name="spu_col_mode" text="Kørsel"/>
<text name="spu_field_section" text="— Mark F%d: %s —"/> <text name="spu_field_section" text="— Mark F%d: %s —"/>
<text name="spu_field_statusFull" text="Status: %s"/>
<text name="spu_field_plan" text="Plan"/> <text name="spu_field_plan" text="Plan"/>
<text name="spu_field_mode" text="Kørsel"/> <text name="spu_field_mode" text="Kørsel"/>
<text name="spu_field_rake" text="Riv skårene sammen før opsamling (gør smalle læssevogne brugbare)"/> <text name="spu_field_rake" text="Riv skårene sammen før opsamling (gør smalle læssevogne brugbare)"/>
+1
View File
@@ -73,6 +73,7 @@
<text name="spu_col_plan" text="Plan"/> <text name="spu_col_plan" text="Plan"/>
<text name="spu_col_mode" text="Mode"/> <text name="spu_col_mode" text="Mode"/>
<text name="spu_field_section" text="— Field F%d: %s —"/> <text name="spu_field_section" text="— Field F%d: %s —"/>
<text name="spu_field_statusFull" text="Status: %s"/>
<text name="spu_field_plan" text="Plan"/> <text name="spu_field_plan" text="Plan"/>
<text name="spu_field_mode" text="Mode"/> <text name="spu_field_mode" text="Mode"/>
<text name="spu_field_rake" text="Rake the swaths before collecting (lets narrow loading wagons collect)"/> <text name="spu_field_rake" text="Rake the swaths before collecting (lets narrow loading wagons collect)"/>
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?> <?xml version="1.0" encoding="utf-8" standalone="no"?>
<modDesc descVersion="107"> <modDesc descVersion="107">
<author>masterdraco</author> <author>masterdraco</author>
<version>1.29.3.0</version> <version>1.29.4.0</version>
<title> <title>
<en>AD Smart Pickup</en> <en>AD Smart Pickup</en>
</title> </title>
+12
View File
@@ -75,5 +75,17 @@ check("FV4 sammenlæg", V.joinCounted({"Chicken Coop", "Chicken Coop", "Cow Barn
check("FV4 ingen dubletter", V.joinCounted({"A", "B"}, " + ", "-"), "A + B") check("FV4 ingen dubletter", V.joinCounted({"A", "B"}, " + ", "-"), "A + B")
check("FV4 tom -> tekst", V.joinCounted({}, " + ", "(ingen)"), "(ingen)") check("FV4 tom -> tekst", V.joinCounted({}, " + ", "(ingen)"), "(ingen)")
-- FV-wrap: lange tekstrækker ombrydes ved mellemrum; indrykning gentages; kort tekst uændret
local wrapped = V.wrapText(" Prepared and sown with Sugar Beet as soon as it is sowing time for it", 30)
check("FVwrap flere linjer", #wrapped > 1, true)
check("FVwrap første linje indrykket", string.sub(wrapped[1], 1, 4), " ")
check("FVwrap anden linje indrykket", string.sub(wrapped[2], 1, 4), " ")
local maxLen = 0
for _, line in ipairs(wrapped) do if #line > maxLen then maxLen = #line end end
check("FVwrap ingen linje over grænsen", maxLen <= 30, true)
check("FVwrap intet ord tabt", table.concat(wrapped, " "):gsub("%s+", " "):gsub("^ ", ""), "Prepared and sown with Sugar Beet as soon as it is sowing time for it")
check("FVwrap kort tekst", V.wrapText("Kort", 30)[1], "Kort")
check("FVwrap langt ord deles ikke", V.wrapText("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 10)[1], "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL")) print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL"))
os.exit(failures == 0 and 0 or 1) os.exit(failures == 0 and 0 or 1)