feat(ui): ny fane Overblik — flows som tabel (flow/varer/fra/til/kører/status) grupperet Ind/Ud + Wait-puljer; Flows-fanen kun redigering (v1.19.1.0)

This commit is contained in:
2026-09-24 19:37:41 +02:00
parent 99c509ea10
commit a2444661a0
8 changed files with 83 additions and 57 deletions
+21 -34
View File
@@ -11,8 +11,9 @@ local function joinOr(list, empty)
return table.concat(list, " + ")
end
-- "Mælk · Kostald 1 + Kostald 2 → salg · pris ≥ 90 %, lager > 80 % · Virtus · kører (1/1) — SUGAR 78 % af top"
function SmartPickupFrame:describeFlow(adEnv, run, isSelected)
-- Én række i Oversigt: {flow, varer, fra, til, traktorer "kører/i alt", status}.
-- Status = advarsel (!!), ellers begrundelse, ellers flowets regel.
function SmartPickupFrame:flowCells(adEnv, run)
local row = ADRunsController.getFlowRow(adEnv, run)
local i18n = self.i18n
local products
@@ -53,51 +54,37 @@ function SmartPickupFrame:describeFlow(adEnv, run, isSelected)
else
rule = row.loops ~= nil and row.loops > 0 and string.format(i18n:getText("spu_flow_ruleInLoops"), row.loops) or i18n:getText("spu_flow_ruleIn")
end
local vehicles = joinOr(row.vehicleNames, i18n:getText("spu_flow_noVehicle"))
local status = row.running > 0 and string.format(i18n:getText("spu_status_running"), row.running, row.total) or string.format(i18n:getText("spu_status_stopped"), row.total)
local status = rule
if row.warning ~= nil then
status = status .. " — !! " .. row.warning
status = "!! " .. row.warning
elseif row.reason ~= nil then
status = status .. " — " .. row.reason
status = row.reason
end
local prefix = isSelected and "> " or " "
return string.format("%s%s: %s · %s → %s · %s · %s · %s", prefix, run.name, products, from, to, rule, vehicles, status)
local name = (run.id == self.selectedRunId and "> " or "") .. tostring(run.name)
return {name, products, from, to, string.format("%d/%d", row.running, row.total), status}
end
-- Tavlen klones bagest og flyttes derefter forrest i layoutet (foran de faste rækker).
function SmartPickupFrame:fillBoardRows(adEnv)
self.boardRows = {}
local rows = {}
local header = self:addTextRow(self.i18n:getText("spu_section_flows"))
table.insert(rows, header.parent)
-- grupperet: Ind til bygning, så Ud fra bygning — hver efter navn
-- Fanen Oversigt: alle flows som tabel, grupperet Ind/Ud efter navn.
function SmartPickupFrame:fillOverviewRows(adEnv)
self.overviewRows = {}
local i18n = self.i18n
self:addCellRow(self.flowPrefab, {i18n:getText("spu_col_flow"), i18n:getText("spu_col_goods"), i18n:getText("spu_col_from"), i18n:getText("spu_col_to"), i18n:getText("spu_col_tractors"), i18n:getText("spu_col_status")})
for _, group in ipairs(ADFlowView.boardGroups(ADRunsController.store.runs)) do
table.insert(rows, self:addTextRow(self.i18n:getText(group.kind == "outbound" and "spu_board_outbound" or "spu_board_supply")).parent)
self:addTextRow(i18n:getText(group.kind == "outbound" and "spu_board_outbound" or "spu_board_supply"))
for _, run in ipairs(group.runs) do
local title = self:addTextRow(self:describeFlow(adEnv, run, run.id == self.selectedRunId))
table.insert(rows, title.parent)
table.insert(self.boardRows, {run = run, title = title})
table.insert(self.overviewRows, {runId = run.id, cells = self:addCellRow(self.flowPrefab, self:flowCells(adEnv, run))})
end
end
if #ADRunsController.store.runs == 0 then
table.insert(rows, self:addTextRow(self.i18n:getText("spu_noRuns")).parent)
end
local elements = self.boxLayout.elements
for index = #rows, 1, -1 do
for position = #elements, 1, -1 do
if elements[position] == rows[index] then
table.remove(elements, position)
break
end
end
table.insert(elements, 1, rows[index])
self:addTextRow(i18n:getText("spu_noRuns"))
end
end
function SmartPickupFrame:refreshBoard(adEnv)
for _, entry in ipairs(self.boardRows or {}) do
if ADRuns.getRun(ADRunsController.store, entry.run.id) ~= nil then
entry.title:setText(self:describeFlow(adEnv, ADRuns.getRun(ADRunsController.store, entry.run.id), entry.run.id == self.selectedRunId))
function SmartPickupFrame:refreshOverview(adEnv)
for _, entry in ipairs(self.overviewRows or {}) do
local run = ADRuns.getRun(ADRunsController.store, entry.runId)
if run ~= nil then
SmartPickupFrame.setCells(entry.cells, self:flowCells(adEnv, run))
end
end
end
+20 -12
View File
@@ -10,10 +10,10 @@ SmartPickupFrame.REFRESH_INTERVAL_MS = 1000
SmartPickupFrame.STATUS_OVERRIDE_TICKS = 6
SmartPickupFrame.LOG_PREFIX = "ADSmartPickup: "
SmartPickupFrame.STATE_OFF, SmartPickupFrame.STATE_ON = 1, 2
SmartPickupFrame.TAB_FLOWS = 1
SmartPickupFrame.TAB_OVERVIEW, SmartPickupFrame.TAB_FLOWS = 1, 2
-- Lagerfaner: én pr. bygningstype (indeks -> kind i ADSources.getFarmInventory)
SmartPickupFrame.TAB_NAMES = {"spu_tab_flows", "spu_tab_factories", "spu_tab_silos", "spu_tab_barns", "spu_tab_sheds"}
SmartPickupFrame.TAB_KINDS = {[2] = "factory", [3] = "silo", [4] = "husbandry", [5] = "objectStorage"}
SmartPickupFrame.TAB_NAMES = {"spu_tab_overview", "spu_tab_flows", "spu_tab_factories", "spu_tab_silos", "spu_tab_barns", "spu_tab_sheds"}
SmartPickupFrame.TAB_KINDS = {[3] = "factory", [4] = "silo", [5] = "husbandry", [6] = "objectStorage"}
function SmartPickupFrame.getTabKind(tab)
return SmartPickupFrame.TAB_KINDS[tab]
@@ -38,7 +38,7 @@ function SmartPickupFrame.new(i18n, getAdEnv)
self.pendingRebuild = false
self.frameOpen = false
self.focusLost = false
self.currentTab = SmartPickupFrame.TAB_FLOWS
self.currentTab = SmartPickupFrame.TAB_OVERVIEW
self.subCategoryTabs = {}
self.backButtonInfo = {inputAction = InputAction.MENU_BACK}
self.startButtonInfo = {inputAction = InputAction.MENU_ACTIVATE, text = i18n:getText("spu_button_start"), callback = function() self:onClickStartStop() end}
@@ -62,7 +62,7 @@ end
-- Prefabs skal ud af layoutet før de klones, ellers vises de selv som rækker.
function SmartPickupFrame:initialize()
for _, name in ipairs({"ingredientPrefab", "vehiclePrefab", "textPrefab", "productPrefab", "statPrefab", "gridPrefab"}) do
for _, name in ipairs({"ingredientPrefab", "vehiclePrefab", "textPrefab", "productPrefab", "statPrefab", "gridPrefab", "flowPrefab"}) do
local prefab = self[name]
if prefab ~= nil then
prefab:unlinkElement()
@@ -370,6 +370,19 @@ function SmartPickupFrame:rebuild()
self:refreshLive()
return
end
if self.currentTab == SmartPickupFrame.TAB_OVERVIEW then
if adEnv ~= nil then
self:fillOverviewRows(adEnv)
end
self.statusRow = self:addTextRow("")
self:addTextRow(self.i18n:getText("spu_waitPools"))
self:fillPoolRows(adEnv)
self:colorRows()
self.boxLayout:invalidateLayout()
self:refreshLive()
self:restoreFocusIfLost()
return
end
self:fillRunOption(adEnv)
local hasRun = run ~= nil and adEnv ~= nil
for _, element in ipairs({self.waitPoolOption, self.loopsOption, self.returnBelowOption, self.sellAtOption, self.storeAboveOption}) do
@@ -377,9 +390,6 @@ function SmartPickupFrame:rebuild()
element:setDisabled(not hasRun)
end
end
if adEnv ~= nil then
self:fillBoardRows(adEnv)
end
if hasRun then
self:fillWaitPoolOption(adEnv, run)
self:rebuildFlowDetail(adEnv, run)
@@ -388,8 +398,6 @@ function SmartPickupFrame:rebuild()
self:addTextRow(self.i18n:getText("spu_section_status"))
end
self.statusRow = self:addTextRow("")
self:addTextRow(self.i18n:getText("spu_waitPools"))
self:fillPoolRows(adEnv)
self:colorRows()
self.boxLayout:invalidateLayout()
self:refreshLive()
@@ -639,8 +647,8 @@ function SmartPickupFrame:refreshLive()
self:setStatusText(self.i18n:getText("spu_status_noAd"))
return
end
if self.currentTab == SmartPickupFrame.TAB_FLOWS then
self:refreshBoard(adEnv)
if self.currentTab == SmartPickupFrame.TAB_OVERVIEW then
self:refreshOverview(adEnv)
end
self:refreshStorageRows(adEnv)
local isRunning = false
@@ -72,6 +72,15 @@
<Bitmap profile="fs25_multiTextOptionContainer" id="textPrefab">
<Text profile="spuInfoText" name="title"/>
</Bitmap>
<!-- Oversigt: én række pr. flow (flow · varer · fra · til · traktorer · status). Rækken er ~815 px bred. -->
<Bitmap profile="fs25_multiTextOptionContainer" id="flowPrefab">
<Text profile="spuCellBold" name="c1" position="20px 0px" size="150px 40px"/>
<Text profile="spuCell" name="c2" position="170px 0px" size="110px 40px"/>
<Text profile="spuCell" name="c3" position="280px 0px" size="170px 40px"/>
<Text profile="spuCell" name="c4" position="450px 0px" size="170px 40px"/>
<Text profile="spuCell" name="c5" position="620px 0px" size="50px 40px"/>
<Text profile="spuCell" name="c6" position="670px 0px" size="140px 40px"/>
</Bitmap>
<!-- Lagre: statistik-tabel (vare · i bygningen · værdi nu · ved toppris · gården · rækker til · forbrug/prod.) -->
<Bitmap profile="fs25_multiTextOptionContainer" id="statPrefab">
<Text profile="spuCellBold" name="c1" position="20px 0px" size="140px 40px"/>
+6
View File
@@ -135,6 +135,12 @@
<text name="spu_stat_use" text="forbrug %s/døgn"/>
<text name="spu_stat_prod" text="prod. %s/døgn"/>
<text name="spu_stat_total" text="Bygningen i alt"/>
<text name="spu_col_flow" text="Flow"/>
<text name="spu_col_goods" text="Varer"/>
<text name="spu_col_from" text="Fra"/>
<text name="spu_col_to" text="Til"/>
<text name="spu_col_tractors" text="Kører"/>
<text name="spu_col_status" text="Status"/>
<text name="spu_board_supply" text="· Ind til bygning ·"/>
<text name="spu_board_outbound" text="· Ud fra bygning ·"/>
<text name="spu_showAllVehicles" text="Vis alle traktorer (%d skjult)"/>
+6
View File
@@ -135,6 +135,12 @@
<text name="spu_stat_use" text="use %s/day"/>
<text name="spu_stat_prod" text="prod. %s/day"/>
<text name="spu_stat_total" text="Building total"/>
<text name="spu_col_flow" text="Flow"/>
<text name="spu_col_goods" text="Goods"/>
<text name="spu_col_from" text="From"/>
<text name="spu_col_to" text="To"/>
<text name="spu_col_tractors" text="Running"/>
<text name="spu_col_status" text="Status"/>
<text name="spu_board_supply" text="· Into building ·"/>
<text name="spu_board_outbound" text="· Out of building ·"/>
<text name="spu_showAllVehicles" text="Show all tractors (%d hidden)"/>
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<modDesc descVersion="107">
<author>masterdraco</author>
<version>1.19.0.0</version>
<version>1.19.1.0</version>
<title>
<en>AD Smart Pickup</en>
</title>