fix: Smart Pickup-fane — ingen callbacks under opbygning, fokus-oprydning, pcall på alle klik, navn/ikon/status
This commit is contained in:
@@ -677,7 +677,7 @@ local function restoreStoppedVehicles()
|
||||
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 function insertInGameMenuPage(frame, pageName, iconFile, iconUVs, 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
|
||||
@@ -717,7 +717,7 @@ local function insertInGameMenuPage(frame, pageName, iconFile, uvs, position, pr
|
||||
inGameMenu.pagingElement:updateAbsolutePosition()
|
||||
inGameMenu.pagingElement:updatePageMapping()
|
||||
inGameMenu:registerPage(frame, position, predicate)
|
||||
inGameMenu:addPageTab(frame, iconFile, GuiUtils.getUVs(uvs))
|
||||
inGameMenu:addPageTab(frame, iconFile, iconUVs)
|
||||
inGameMenu:rebuildTabList()
|
||||
return true
|
||||
end
|
||||
@@ -730,7 +730,10 @@ local function loadGui()
|
||||
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
|
||||
-- icon.dds er 512×512. Uden referencestørrelsen normaliserer getUVs mod 1024×1024,
|
||||
-- og fanen ville kun vise ikonets øverste venstre fjerdedel.
|
||||
local iconUVs = GuiUtils.getUVs({0, 0, 512, 512}, {512, 512})
|
||||
if not insertInGameMenuPage(frame, "smartPickupFrame", iconFile, iconUVs, 2, function() return g_currentMission ~= nil end) then
|
||||
Logging.warning(ADSmartPickup.LOG_PREFIX .. "kunne ikke indsætte fanen i ESC-menuen")
|
||||
return
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user