diff --git a/FS25_ADSmartPickup/gui/SmartPickupFlowTab.lua b/FS25_ADSmartPickup/gui/SmartPickupFlowTab.lua index ea1a6c3..6edb978 100644 --- a/FS25_ADSmartPickup/gui/SmartPickupFlowTab.lua +++ b/FS25_ADSmartPickup/gui/SmartPickupFlowTab.lua @@ -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 diff --git a/FS25_ADSmartPickup/gui/SmartPickupFrame.lua b/FS25_ADSmartPickup/gui/SmartPickupFrame.lua index 655c357..4c44778 100644 --- a/FS25_ADSmartPickup/gui/SmartPickupFrame.lua +++ b/FS25_ADSmartPickup/gui/SmartPickupFrame.lua @@ -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 diff --git a/FS25_ADSmartPickup/gui/SmartPickupFrame.xml b/FS25_ADSmartPickup/gui/SmartPickupFrame.xml index 2f9988c..197f596 100644 --- a/FS25_ADSmartPickup/gui/SmartPickupFrame.xml +++ b/FS25_ADSmartPickup/gui/SmartPickupFrame.xml @@ -72,6 +72,15 @@ + + + + + + + + + diff --git a/FS25_ADSmartPickup/l10n/l10n_da.xml b/FS25_ADSmartPickup/l10n/l10n_da.xml index 5738c0c..d753aac 100644 --- a/FS25_ADSmartPickup/l10n/l10n_da.xml +++ b/FS25_ADSmartPickup/l10n/l10n_da.xml @@ -135,6 +135,12 @@ + + + + + + diff --git a/FS25_ADSmartPickup/l10n/l10n_en.xml b/FS25_ADSmartPickup/l10n/l10n_en.xml index 1f407e2..1cbba5a 100644 --- a/FS25_ADSmartPickup/l10n/l10n_en.xml +++ b/FS25_ADSmartPickup/l10n/l10n_en.xml @@ -135,6 +135,12 @@ + + + + + + diff --git a/FS25_ADSmartPickup/modDesc.xml b/FS25_ADSmartPickup/modDesc.xml index 8f3e9e0..f08165d 100644 --- a/FS25_ADSmartPickup/modDesc.xml +++ b/FS25_ADSmartPickup/modDesc.xml @@ -1,7 +1,7 @@ masterdraco - 1.19.0.0 + 1.19.1.0 <en>AD Smart Pickup</en> diff --git a/docs/BRUGERMANUAL.md b/docs/BRUGERMANUAL.md index afae118..7c4c7c5 100644 --- a/docs/BRUGERMANUAL.md +++ b/docs/BRUGERMANUAL.md @@ -1,6 +1,6 @@ # AD Smart Pickup — brugermanual -Version 1.19.0 · Farming Simulator 25 · tillæg til AutoDrive +Version 1.19.1 · Farming Simulator 25 · tillæg til AutoDrive *English version: [USER_MANUAL.md](USER_MANUAL.md)* @@ -120,19 +120,24 @@ som er 25 m som standard. Står siloerne tættere, kan nabosiloen få læsset. S ## 4. Menuen Smart Pickup -Tryk **ESC** og vælg fanen **Smart Pickup**. Fanen har fem underfaner: +Tryk **ESC** og vælg fanen **Smart Pickup**. Fanen har seks underfaner: | Fane | Indhold | |---|---| -| **Flows** | Tavlen med alle flows, redigering af det valgte flow og Wait-puljerne | +| **Overblik** | Tabel over alle flows og Wait-puljerne | +| **Flows** | Redigering af det valgte flow | | **Fabrikker** | Beholdning og statistik for gårdens fabrikker | | **Siloer** | Beholdning og statistik for gårdens siloer | | **Stalde** | Beholdning og statistik for gårdens stalde | | **Palleskure** | Beholdning og statistik for gårdens objektlagre | -### Flow-tavlen +### Overblik -Øverst står én linje pr. flow. Det valgte flow er markeret med `>`. +Fanen **Overblik** viser alle flows som en tabel med kolonnerne **Flow**, **Varer**, **Fra**, **Til**, +**Kører** og **Status**. Det valgte flow er markeret med `>`. Kører viser traktorer i gang ud af flowets +traktorer. Status viser en advarsel, grunden til at traktorerne holder, eller flowets regel. + +Tidligere stod tavlen som én lang linje pr. flow: ``` > Mælkesalg: Mælk · Cow Barn 1 + Cow Barn 2 → Salg · pris >= 90 %, lager > 80 % · Virtus · Kører (1/1) diff --git a/docs/USER_MANUAL.md b/docs/USER_MANUAL.md index 96f9716..c31a5c6 100644 --- a/docs/USER_MANUAL.md +++ b/docs/USER_MANUAL.md @@ -1,6 +1,6 @@ # AD Smart Pickup — user manual -Version 1.19.0 · Farming Simulator 25 · add-on for AutoDrive +Version 1.19.1 · Farming Simulator 25 · add-on for AutoDrive *Dansk version: [BRUGERMANUAL.md](BRUGERMANUAL.md)* @@ -122,19 +122,24 @@ storage target with a neighbouring trigger. ## 4. The Smart Pickup menu -Press **ESC** and open the **Smart Pickup** tab. It has five sub-tabs: +Press **ESC** and open the **Smart Pickup** tab. It has six sub-tabs: | Tab | Contents | |---|---| -| **Flows** | The board with all flows, editing of the selected flow and the Wait pools | +| **Overview** | A table of all flows and the Wait pools | +| **Flows** | Editing of the selected flow | | **Factories** | Inventory and statistics for the farm's factories | | **Silos** | Inventory and statistics for the farm's silos | | **Barns** | Inventory and statistics for the farm's barns | | **Pallet sheds** | Inventory and statistics for the farm's object storages | -### The flow board +### Overview -At the top there is one line per flow. The selected flow is marked with `>`. +The **Overview** tab shows all flows as a table with the columns **Flow**, **Goods**, **From**, **To**, +**Running** and **Status**. The selected flow is marked with `>`. Running shows tractors at work out of +the flow's tractors. Status shows a warning, the reason tractors are waiting, or the flow's rule. + +Earlier the board was one long line per flow: ``` > Milk sale: Milk · Cow Barn 1 + Cow Barn 2 → Sell · price >= 90 %, storage > 80 % · Virtus · Running (1/1)