feat: ESC-fane 'Smart Pickup' (runs: mål, varer, Wait-pulje, ture, traktorer, Start/Stop)

This commit is contained in:
2026-09-22 22:52:48 +02:00
parent bd446f8add
commit 254274f926
7 changed files with 670 additions and 0 deletions
+75
View File
@@ -10,6 +10,11 @@
ADSmartPickup = {}
ADSmartPickup.dir = g_currentModDirectory
if ADSmartPickup.dir ~= nil and source ~= nil then
source(ADSmartPickup.dir .. "gui/SmartPickupFrame.lua")
end
-- Markøren er dér hvor trækkerens næse stopper; læssetriggeren ligger et
-- vogntog bagved. Siloer tættere end dette regnes som "markørens silo".
ADSmartPickup.MAX_MARKER_TO_TRIGGER_DISTANCE = 40
@@ -671,6 +676,76 @@ local function restoreStoppedVehicles()
end
end
-- Indsætter fanen i ESC-menuen foran Statistik/Priser (mønster fra FS25_FarmOperationsDashboard).
local function insertInGameMenuPage(frame, pageName, iconFile, uvs, position, predicate)
local inGameMenu = g_gui ~= nil and g_gui.screenControllers ~= nil and g_gui.screenControllers[InGameMenu] or nil
if inGameMenu == nil or inGameMenu.pagingElement == nil then
return false
end
local insertAt = position
for i = 1, #inGameMenu.pagingElement.elements do
local child = inGameMenu.pagingElement.elements[i]
if child == inGameMenu.pageStatistics or child == inGameMenu.pagePrices then
insertAt = i
break
end
end
if inGameMenu.controlIDs ~= nil then
inGameMenu.controlIDs[pageName] = nil
end
inGameMenu[pageName] = frame
inGameMenu.pagingElement:addElement(frame)
if inGameMenu.exposeControlsAsFields ~= nil then
inGameMenu:exposeControlsAsFields(pageName)
end
for _, list in ipairs({inGameMenu.pagingElement.elements, inGameMenu.pageFrames}) do
for i = 1, #list do
if list[i] == frame then
table.remove(list, i)
table.insert(list, insertAt, frame)
break
end
end
end
for i = 1, #inGameMenu.pagingElement.pages do
if inGameMenu.pagingElement.pages[i].element == frame then
local page = table.remove(inGameMenu.pagingElement.pages, i)
table.insert(inGameMenu.pagingElement.pages, insertAt, page)
break
end
end
inGameMenu.pagingElement:updateAbsolutePosition()
inGameMenu.pagingElement:updatePageMapping()
inGameMenu:registerPage(frame, position, predicate)
inGameMenu:addPageTab(frame, iconFile, GuiUtils.getUVs(uvs))
inGameMenu:rebuildTabList()
return true
end
local function loadGui()
if g_gui == nil or SmartPickupFrame == nil or ADSmartPickup.dir == nil then
return
end
g_gui:loadProfiles(ADSmartPickup.dir .. "gui/guiProfiles.xml")
local frame = SmartPickupFrame.new(g_i18n, getAutoDriveEnv)
g_gui:loadGui(ADSmartPickup.dir .. "gui/SmartPickupFrame.xml", "smartPickupFrame", frame, true)
local iconFile = Utils.getFilename("icon.dds", ADSmartPickup.dir)
if not insertInGameMenuPage(frame, "smartPickupFrame", iconFile, {0, 0, 512, 512}, 2, function() return g_currentMission ~= nil end) then
Logging.warning(ADSmartPickup.LOG_PREFIX .. "kunne ikke indsætte fanen i ESC-menuen")
return
end
frame:initialize()
ADSmartPickup.guiFrame = frame
Logging.info(ADSmartPickup.LOG_PREFIX .. "ESC-fane 'Smart Pickup' registreret")
end
function ADSmartPickup:loadMap()
local ok, err = pcall(loadGui)
if not ok then
Logging.warning(ADSmartPickup.LOG_PREFIX .. "GUI kunne ikke indlæses (resten af moden virker): %s", tostring(err))
end
end
function ADSmartPickup:update(dt)
if not isHooked then
local adEnv = getAutoDriveEnv()