From 0df2b478f18297e2aa377b1b523c2f6d3ceced0b Mon Sep 17 00:00:00 2001 From: David Schwietering Date: Fri, 15 Mar 2024 23:25:42 +0100 Subject: [PATCH 1/4] WIP diff code improvements --- config/MasterTranslations.xml | 44 +++--- .../gamePadHud/BaleLoaderGamePadHudPage.xml | 2 +- .../gamePadHud/BunkerSiloGamePadHudPage.xml | 2 +- config/gamePadHud/FieldworkGamePadHudPage.xml | 4 +- .../gamePadHud/SiloLoaderGamePadHudPage.xml | 2 +- .../BaleFinderJobParameterSetup.xml | 4 +- .../BunkerSiloJobParameterSetup.xml | 2 +- .../CombineUnloaderJobParameterSetup.xml | 2 +- ...tup.xml => FieldWorkJobParameterSetup.xml} | 4 +- scripts/ai/AIDriveStrategyCourse.lua | 4 +- scripts/ai/jobs/CpAIJob.lua | 50 ++----- scripts/ai/jobs/CpAIJobBunkerSilo.lua | 4 +- scripts/ai/jobs/CpAIJobFieldWork.lua | 4 +- scripts/ai/jobs/CpJobParameters.lua | 129 +++++++++--------- scripts/gui/CpGamePadHudScreen.lua | 8 +- scripts/gui/hud/CpBaseHud.lua | 4 +- scripts/specializations/CpAIBaleFinder.lua | 2 +- .../specializations/CpAIBunkerSiloWorker.lua | 4 +- .../specializations/CpAICombineUnloader.lua | 2 +- scripts/specializations/CpAIFieldWorker.lua | 6 +- .../specializations/CpAISiloLoaderWorker.lua | 4 +- scripts/specializations/CpGamePadHud.lua | 6 +- translations/translation_br.xml | 44 +++--- translations/translation_cs.xml | 44 +++--- translations/translation_ct.xml | 44 +++--- translations/translation_cz.xml | 44 +++--- translations/translation_da.xml | 44 +++--- translations/translation_de.xml | 44 +++--- translations/translation_ea.xml | 44 +++--- translations/translation_en.xml | 44 +++--- translations/translation_es.xml | 44 +++--- translations/translation_fc.xml | 44 +++--- translations/translation_fi.xml | 44 +++--- translations/translation_fr.xml | 44 +++--- translations/translation_hu.xml | 44 +++--- translations/translation_it.xml | 44 +++--- translations/translation_jp.xml | 44 +++--- translations/translation_kr.xml | 44 +++--- translations/translation_nl.xml | 44 +++--- translations/translation_no.xml | 44 +++--- translations/translation_pl.xml | 44 +++--- translations/translation_pt.xml | 44 +++--- translations/translation_ro.xml | 44 +++--- translations/translation_ru.xml | 44 +++--- translations/translation_sv.xml | 44 +++--- translations/translation_tr.xml | 44 +++--- 46 files changed, 656 insertions(+), 693 deletions(-) rename config/jobParameters/{JobParameterSetup.xml => FieldWorkJobParameterSetup.xml} (93%) diff --git a/config/MasterTranslations.xml b/config/MasterTranslations.xml index a0cfcfa23..63d02d11a 100644 --- a/config/MasterTranslations.xml +++ b/config/MasterTranslations.xml @@ -89,91 +89,91 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/config/gamePadHud/BaleLoaderGamePadHudPage.xml b/config/gamePadHud/BaleLoaderGamePadHudPage.xml index 54525f233..7f7d58edf 100644 --- a/config/gamePadHud/BaleLoaderGamePadHudPage.xml +++ b/config/gamePadHud/BaleLoaderGamePadHudPage.xml @@ -6,7 +6,7 @@ - + diff --git a/config/gamePadHud/BunkerSiloGamePadHudPage.xml b/config/gamePadHud/BunkerSiloGamePadHudPage.xml index aba940a96..fbadb44de 100644 --- a/config/gamePadHud/BunkerSiloGamePadHudPage.xml +++ b/config/gamePadHud/BunkerSiloGamePadHudPage.xml @@ -5,7 +5,7 @@ --> - + diff --git a/config/gamePadHud/FieldworkGamePadHudPage.xml b/config/gamePadHud/FieldworkGamePadHudPage.xml index 3d68617df..b5d253869 100644 --- a/config/gamePadHud/FieldworkGamePadHudPage.xml +++ b/config/gamePadHud/FieldworkGamePadHudPage.xml @@ -5,9 +5,9 @@ --> - + - + diff --git a/config/gamePadHud/SiloLoaderGamePadHudPage.xml b/config/gamePadHud/SiloLoaderGamePadHudPage.xml index 34fc6f86f..09b66ee30 100644 --- a/config/gamePadHud/SiloLoaderGamePadHudPage.xml +++ b/config/gamePadHud/SiloLoaderGamePadHudPage.xml @@ -5,7 +5,7 @@ --> - + diff --git a/config/jobParameters/BaleFinderJobParameterSetup.xml b/config/jobParameters/BaleFinderJobParameterSetup.xml index fb225ccd8..bc7e863bf 100644 --- a/config/jobParameters/BaleFinderJobParameterSetup.xml +++ b/config/jobParameters/BaleFinderJobParameterSetup.xml @@ -9,11 +9,11 @@ - + - + 1 2 diff --git a/config/jobParameters/BunkerSiloJobParameterSetup.xml b/config/jobParameters/BunkerSiloJobParameterSetup.xml index 41c6cf694..9828a0bc8 100644 --- a/config/jobParameters/BunkerSiloJobParameterSetup.xml +++ b/config/jobParameters/BunkerSiloJobParameterSetup.xml @@ -9,7 +9,7 @@ - + diff --git a/config/jobParameters/CombineUnloaderJobParameterSetup.xml b/config/jobParameters/CombineUnloaderJobParameterSetup.xml index 92b203fe4..bbc44d6c1 100644 --- a/config/jobParameters/CombineUnloaderJobParameterSetup.xml +++ b/config/jobParameters/CombineUnloaderJobParameterSetup.xml @@ -9,7 +9,7 @@ - + diff --git a/config/jobParameters/JobParameterSetup.xml b/config/jobParameters/FieldWorkJobParameterSetup.xml similarity index 93% rename from config/jobParameters/JobParameterSetup.xml rename to config/jobParameters/FieldWorkJobParameterSetup.xml index ef081c84c..c805e5252 100644 --- a/config/jobParameters/JobParameterSetup.xml +++ b/config/jobParameters/FieldWorkJobParameterSetup.xml @@ -5,11 +5,11 @@ For documentation look up the CpSettingUtil.lua. --> - + - + diff --git a/scripts/ai/AIDriveStrategyCourse.lua b/scripts/ai/AIDriveStrategyCourse.lua index ee2ff0fbf..4b29ced51 100644 --- a/scripts/ai/AIDriveStrategyCourse.lua +++ b/scripts/ai/AIDriveStrategyCourse.lua @@ -187,11 +187,11 @@ function AIDriveStrategyCourse:getGeneratedCourse(jobParameters) end function AIDriveStrategyCourse:getStartingPointWaypointIx(course, startAt) - if startAt == CpJobParameters.START_AT_NEAREST_POINT then + if startAt == CpFieldWorkJobParameters.START_AT_NEAREST_POINT then local _, _, ixClosestRightDirection, _ = course:getNearestWaypoints(self.vehicle:getAIDirectionNode()) self:debug('Starting course at the closest waypoint in the right direction %d', ixClosestRightDirection) return ixClosestRightDirection - elseif startAt == CpJobParameters.START_AT_LAST_POINT then + elseif startAt == CpFieldWorkJobParameters.START_AT_LAST_POINT then local lastWpIx = self.vehicle:getCpLastRememberedWaypointIx() if lastWpIx then self:debug('Starting course at the last waypoint %d', lastWpIx) diff --git a/scripts/ai/jobs/CpAIJob.lua b/scripts/ai/jobs/CpAIJob.lua index 78d0200e4..d11895901 100644 --- a/scripts/ai/jobs/CpAIJob.lua +++ b/scripts/ai/jobs/CpAIJob.lua @@ -23,12 +23,7 @@ CpAIJob = { local AIJobCp_mt = Class(CpAIJob, AIJob) function CpAIJob.new(isServer, customMt) - local mt = customMt or AIJobCp_mt - mt.__tostring = function(_self) - CpUtil.info("Job: %s", g_currentMission.aiJobTypeManager:getJobTypeByIndex(_self.jobTypeIndex).name) - return string.format("%d Job parameters", tostring(_self.cpJobParameters)) - end - local self = AIJob.new(isServer, mt) + local self = AIJob.new(isServer, customMt or AIJobCp_mt) self.isDirectStart = false self.debugChannel = CpDebug.DBG_FIELDWORK @@ -469,41 +464,14 @@ AIJobTypeManager.getJobTypeIndex = Utils.overwrittenFunction(AIJobTypeManager.ge --- Registers additional jobs. function CpAIJob.registerJob(AIJobTypeManager) - AIJobTypeManager:registerJobType(CpAIJobBaleFinder.name, CpAIJobBaleFinder.jobName, CpAIJobBaleFinder) - AIJobTypeManager:registerJobType(CpAIJobFieldWork.name, CpAIJobFieldWork.jobName, CpAIJobFieldWork) - AIJobTypeManager:registerJobType(CpAIJobCombineUnloader.name, CpAIJobCombineUnloader.jobName, CpAIJobCombineUnloader) - AIJobTypeManager:registerJobType(CpAIJobSiloLoader.name, CpAIJobSiloLoader.jobName, CpAIJobSiloLoader) - AIJobTypeManager:registerJobType(CpAIJobBunkerSilo.name, CpAIJobBunkerSilo.jobName, CpAIJobBunkerSilo) -end - - ---- for reload, messing with the internals of the job type manager so it uses the reloaded job -if g_currentMission then - local myJobTypeIndex = g_currentMission.aiJobTypeManager:getJobTypeIndexByName(AIJob.name) - if myJobTypeIndex then - local myJobType = g_currentMission.aiJobTypeManager:getJobTypeByIndex(myJobTypeIndex) - myJobType.classObject = AIJob - end - local myJobTypeIndex = g_currentMission.aiJobTypeManager:getJobTypeIndexByName(CpAIJobFieldWork.name) - if myJobTypeIndex then - local myJobType = g_currentMission.aiJobTypeManager:getJobTypeByIndex(myJobTypeIndex) - myJobType.classObject = CpAIJobFieldWork - end - local myJobTypeIndex = g_currentMission.aiJobTypeManager:getJobTypeIndexByName(CpAIJobBaleFinder.name) - if myJobTypeIndex then - local myJobType = g_currentMission.aiJobTypeManager:getJobTypeByIndex(myJobTypeIndex) - myJobType.classObject = CpAIJobBaleFinder - end - local myJobTypeIndex = g_currentMission.aiJobTypeManager:getJobTypeIndexByName(CpAIJobBunkerSilo.name) - if myJobTypeIndex then - local myJobType = g_currentMission.aiJobTypeManager:getJobTypeByIndex(myJobTypeIndex) - myJobType.classObject = CpAIJobBunkerSilo - end - local myJobTypeIndex = g_currentMission.aiJobTypeManager:getJobTypeIndexByName(CpAIJobSiloLoader.name) - if myJobTypeIndex then - local myJobType = g_currentMission.aiJobTypeManager:getJobTypeByIndex(myJobTypeIndex) - myJobType.classObject = CpAIJobSiloLoader - end + local function register(class) + AIJobTypeManager:registerJobType(class.name, class.jobName, class) + end + register(CpAIJobBaleFinder) + register(CpAIJobFieldWork) + register(CpAIJobCombineUnloader) + register(CpAIJobSiloLoader) + register(CpAIJobBunkerSilo) end AIJobTypeManager.loadMapData = Utils.appendedFunction(AIJobTypeManager.loadMapData,CpAIJob.registerJob) diff --git a/scripts/ai/jobs/CpAIJobBunkerSilo.lua b/scripts/ai/jobs/CpAIJobBunkerSilo.lua index 43e3d5ef2..9594dfef5 100644 --- a/scripts/ai/jobs/CpAIJobBunkerSilo.lua +++ b/scripts/ai/jobs/CpAIJobBunkerSilo.lua @@ -3,8 +3,8 @@ CpAIJobBunkerSilo = { name = "BUNKER_SILO_CP", jobName = "CP_job_bunkerSilo", - fieldPositionParameterText = "CP_jobParameters_bunkerSiloPosition_title", - targetPositionParameterText = "CP_jobParameters_parkPosition_title", + fieldPositionParameterText = "CP_fieldWorkJobParameters_bunkerSiloPosition_title", + targetPositionParameterText = "CP_fieldWorkJobParameters_parkPosition_title", } local CpAIJobBunkerSilo_mt = Class(CpAIJobBunkerSilo, CpAIJob) diff --git a/scripts/ai/jobs/CpAIJobFieldWork.lua b/scripts/ai/jobs/CpAIJobFieldWork.lua index ab39c76fe..3c884ae67 100644 --- a/scripts/ai/jobs/CpAIJobFieldWork.lua +++ b/scripts/ai/jobs/CpAIJobFieldWork.lua @@ -4,7 +4,7 @@ CpAIJobFieldWork = { name = "FIELDWORK_CP", jobName = "CP_job_fieldWork", GenerateButton = "FIELDWORK_BUTTON", - fieldPositionParameterText = "CP_jobParameters_fieldPosition_title" + fieldPositionParameterText = "CP_fieldWorkJobParameters_fieldPosition_title" } local AIJobFieldWorkCp_mt = Class(CpAIJobFieldWork, CpAIJob) @@ -45,7 +45,7 @@ end function CpAIJobFieldWork:setupJobParameters() CpAIJob.setupJobParameters(self) - self:setupCpJobParameters(CpJobParameters(self)) + self:setupCpJobParameters(CpFieldWorkJobParameters(self)) end ---@param vehicle table diff --git a/scripts/ai/jobs/CpJobParameters.lua b/scripts/ai/jobs/CpJobParameters.lua index 39f871a82..8221f9495 100644 --- a/scripts/ai/jobs/CpJobParameters.lua +++ b/scripts/ai/jobs/CpJobParameters.lua @@ -24,13 +24,13 @@ CpJobParameters = CpObject() CpJobParameters.xmlKey = ".cpJobParameters" CpJobParameters.baseFilePath = "config/jobParameters/" -function CpJobParameters:init(job) - if not CpJobParameters.settings then +function CpJobParameters:init(job, class, configPath) + if not class.settings then -- initialize the class members first so the class can be used to access constants, etc. - local filePath = Utils.getFilename(self.baseFilePath .. "JobParameterSetup.xml", g_Courseplay.BASE_DIRECTORY) - CpSettingsUtil.loadSettingsFromSetup(CpJobParameters, filePath) + local filePath = Utils.getFilename(self.baseFilePath .. configPath, g_Courseplay.BASE_DIRECTORY) + CpSettingsUtil.loadSettingsFromSetup(class, filePath) end - CpSettingsUtil.cloneSettingsTable(self, CpJobParameters.settings, nil, self) + CpSettingsUtil.cloneSettingsTable(self, class.settings, nil, self) self.job = job end @@ -38,10 +38,6 @@ function CpJobParameters.registerXmlSchema(schema, baseKey) CpSettingsUtil.registerXmlSchema(schema, baseKey .. CpJobParameters.xmlKey.."(?)") end -function CpJobParameters.getSettings(vehicle) - return vehicle.spec_cpAIFieldWorker.cpJob:getCpJobParameters() -end - function CpJobParameters:validateSettings() for i, setting in ipairs(self.settings) do setting:refresh() @@ -87,32 +83,6 @@ function CpJobParameters:getAiTargetMapHotspotParameters() return parameters end -function CpJobParameters:getMultiTools() - local vehicle = self.job:getVehicle() - if vehicle then - local course = vehicle:getFieldWorkCourse() - if course then - return course:getMultiTools() or 1 - else - return 1 - end - end - --- This needs to be 5, as the server otherwise has problems. - return 5 -end - -function CpJobParameters:noMultiToolsCourseSelected() - return self:getMultiTools() <= 1 -end - -function CpJobParameters:evenNumberOfMultiTools() - return self:getMultiTools() %2 == 0 -end - -function CpJobParameters:lessThanThreeMultiTools() - return self:getMultiTools() < 4 -end - function CpJobParameters:isAIMenuJob() return not self.job:getIsHudJob() end @@ -153,14 +123,59 @@ end ---@param callbackStr string event to be raised ---@param setting AIParameterSettingList setting that raised the callback. function CpJobParameters:raiseCallback(callbackStr, setting, ...) + if self[callbackStr] then + self[callbackStr](self, setting, ...) + return + end local vehicle = self.job:getVehicle() if vehicle then SpecializationUtil.raiseEvent(vehicle, callbackStr, setting, ...) end end -function CpJobParameters:__tostring() - return tostring(self.settings) +function CpJobParameters:debug(...) + self.job:debug(...) +end + +---@class CpFieldWorkJobParameters : CpJobParameters +CpFieldWorkJobParameters = CpObject(CpJobParameters) +function CpFieldWorkJobParameters:init(job) + CpJobParameters.init(self, job, + CpFieldWorkJobParameters, "FieldWorkJobParameterSetup.xml") +end + +function CpFieldWorkJobParameters.getSettings(vehicle) + return vehicle.spec_cpAIFieldWorker.cpJob:getCpJobParameters() +end + +function CpFieldWorkJobParameters:isUnloadRefillTargetDisabled() + return self:isGiantsForStreetActive() --- TODO: Added check for refill/unload possibilities ... +end + +function CpFieldWorkJobParameters:getMultiTools() + local vehicle = self.job:getVehicle() + if vehicle then + local course = vehicle:getFieldWorkCourse() + if course then + return course:getMultiTools() or 1 + else + return 1 + end + end + --- This needs to be 5, as the server otherwise has problems. + return 5 +end + +function CpFieldWorkJobParameters:noMultiToolsCourseSelected() + return self:getMultiTools() <= 1 +end + +function CpFieldWorkJobParameters:evenNumberOfMultiTools() + return self:getMultiTools() %2 == 0 +end + +function CpFieldWorkJobParameters:lessThanThreeMultiTools() + return self:getMultiTools() < 4 end --- Are the setting values roughly equal. @@ -180,26 +195,21 @@ end ---@class CpBaleFinderJobParameters : CpJobParameters CpBaleFinderJobParameters = CpObject(CpJobParameters) - function CpBaleFinderJobParameters:init(job) - if not CpBaleFinderJobParameters.settings then - -- initialize the class members first so the class can be used to access constants, etc. - local filePath = Utils.getFilename(self.baseFilePath .. "BaleFinderJobParameterSetup.xml", g_Courseplay.BASE_DIRECTORY) - CpSettingsUtil.loadSettingsFromSetup(CpBaleFinderJobParameters, filePath) - end - CpSettingsUtil.cloneSettingsTable(self, CpBaleFinderJobParameters.settings, nil, self) - self.job = job + CpJobParameters.init(self, job, + CpBaleFinderJobParameters, "BaleFinderJobParameterSetup.xml") end function CpBaleFinderJobParameters.getSettings(vehicle) return vehicle.spec_cpAIBaleFinder.cpJob:getCpJobParameters() end -function CpBaleFinderJobParameters:isBaleWrapSettingVisible() +function CpBaleFinderJobParameters:hasBaleLoader() local vehicle = self.job:getVehicle() if vehicle then return AIUtil.hasChildVehicleWithSpecialization(vehicle, BaleLoader) end + return true end --- AI parameters for the bale finder job. @@ -209,13 +219,8 @@ end CpCombineUnloaderJobParameters = CpObject(CpJobParameters) function CpCombineUnloaderJobParameters:init(job) - self.job = job - if not CpCombineUnloaderJobParameters.settings then - local filePath = Utils.getFilename(self.baseFilePath .. "CombineUnloaderJobParameterSetup.xml", g_Courseplay.BASE_DIRECTORY) - -- initialize the class members first so the class can be used to access constants, etc. - CpSettingsUtil.loadSettingsFromSetup(CpCombineUnloaderJobParameters, filePath) - end - CpSettingsUtil.cloneSettingsTable(self, CpCombineUnloaderJobParameters.settings, nil, self) + CpJobParameters.init(self, job, + CpCombineUnloaderJobParameters, "CombineUnloaderJobParameterSetup.xml") end function CpCombineUnloaderJobParameters:isGiantsUnloadDisabled() @@ -303,13 +308,8 @@ end CpBunkerSiloJobParameters = CpObject(CpJobParameters) function CpBunkerSiloJobParameters:init(job) - if not CpBunkerSiloJobParameters.settings then - local filePath = Utils.getFilename(self.baseFilePath .."BunkerSiloJobParameterSetup.xml", g_Courseplay.BASE_DIRECTORY) - -- initialize the class members first so the class can be used to access constants, etc. - CpSettingsUtil.loadSettingsFromSetup(CpBunkerSiloJobParameters, filePath) - end - CpSettingsUtil.cloneSettingsTable(self, CpBunkerSiloJobParameters.settings, nil, self) - self.job = job + CpJobParameters.init(self, job, + CpBunkerSiloJobParameters, "BunkerSiloJobParameterSetup.xml") end function CpBunkerSiloJobParameters.getSettings(vehicle) @@ -337,13 +337,8 @@ end CpSiloLoaderJobParameters = CpObject(CpJobParameters) function CpSiloLoaderJobParameters:init(job) - if not CpSiloLoaderJobParameters.settings then - local filePath = Utils.getFilename(self.baseFilePath .."SiloLoaderJobParameterSetup.xml", g_Courseplay.BASE_DIRECTORY) - -- initialize the class members first so the class can be used to access constants, etc. - CpSettingsUtil.loadSettingsFromSetup(CpSiloLoaderJobParameters, filePath) - end - CpSettingsUtil.cloneSettingsTable(self, CpSiloLoaderJobParameters.settings, nil, self) - self.job = job + CpJobParameters.init(self, job, + CpSiloLoaderJobParameters, "SiloLoaderJobParameterSetup.xml") end function CpSiloLoaderJobParameters.getSettings(vehicle) diff --git a/scripts/gui/CpGamePadHudScreen.lua b/scripts/gui/CpGamePadHudScreen.lua index b1b9429b9..1e6268de3 100644 --- a/scripts/gui/CpGamePadHudScreen.lua +++ b/scripts/gui/CpGamePadHudScreen.lua @@ -194,10 +194,10 @@ end function CpGamePadHudFieldWorkScreen:update(dt, ...) CpGamePadHudFieldWorkScreen:superClass().update(self, dt, ...) - if self.vehicle:getCanStartCpBunkerSiloWorker() and self.vehicle:getCpStartingPointSetting():getValue() == CpJobParameters.START_AT_BUNKER_SILO + if self.vehicle:getCanStartCpBunkerSiloWorker() and self.vehicle:getCpStartingPointSetting():getValue() == CpFieldWorkJobParameters.START_AT_BUNKER_SILO and not AIUtil.hasChildVehicleWithSpecialization(self.vehicle, Leveler) then self.vehicle:reopenCpGamePadHud() - elseif self.vehicle:getCanStartCpSiloLoaderWorker() and self.vehicle:getCpStartingPointSetting():getValue() == CpJobParameters.START_AT_SILO_LOADING + elseif self.vehicle:getCanStartCpSiloLoaderWorker() and self.vehicle:getCpStartingPointSetting():getValue() == CpFieldWorkJobParameters.START_AT_SILO_LOADING and not AIUtil.hasChildVehicleWithSpecialization(self.vehicle, ConveyorBelt) then self.vehicle:reopenCpGamePadHud() end @@ -247,7 +247,7 @@ end function CpGamePadHudBunkerSiloScreen:update(dt, ...) CpGamePadHudBunkerSiloScreen:superClass().update(self, dt, ...) - if not self.vehicle:getCanStartCpBunkerSiloWorker() or self.vehicle:getCpStartingPointSetting():getValue() ~= CpJobParameters.START_AT_BUNKER_SILO then + if not self.vehicle:getCanStartCpBunkerSiloWorker() or self.vehicle:getCpStartingPointSetting():getValue() ~= CpFieldWorkJobParameters.START_AT_BUNKER_SILO then self.vehicle:reopenCpGamePadHud() end end @@ -268,7 +268,7 @@ end function CpGamePadHudSiloLoaderScreen:update(dt, ...) CpGamePadHudSiloLoaderScreen:superClass().update(self, dt, ...) - if not self.vehicle:getCanStartCpSiloLoaderWorker() or self.vehicle:getCpStartingPointSetting():getValue() ~= CpJobParameters.START_AT_SILO_LOADING then + if not self.vehicle:getCanStartCpSiloLoaderWorker() or self.vehicle:getCpStartingPointSetting():getValue() ~= CpFieldWorkJobParameters.START_AT_SILO_LOADING then self.vehicle:reopenCpGamePadHud() end end diff --git a/scripts/gui/hud/CpBaseHud.lua b/scripts/gui/hud/CpBaseHud.lua index dc8f2e077..bfd22eaab 100644 --- a/scripts/gui/hud/CpBaseHud.lua +++ b/scripts/gui/hud/CpBaseHud.lua @@ -423,10 +423,10 @@ function CpBaseHud:getActiveHudPage(vehicle) return self.combineUnloaderLayout elseif vehicle:getCanStartCpBaleFinder() and not vehicle:hasCpCourse() then return self.baleFinderLayout - elseif vehicle:getCanStartCpSiloLoaderWorker() and (vehicle:getCpStartingPointSetting():getValue() == CpJobParameters.START_AT_SILO_LOADING + elseif vehicle:getCanStartCpSiloLoaderWorker() and (vehicle:getCpStartingPointSetting():getValue() == CpFieldWorkJobParameters.START_AT_SILO_LOADING or AIUtil.hasChildVehicleWithSpecialization(vehicle, ConveyorBelt)) then return self.siloLoaderWorkerLayout - elseif vehicle:getCanStartCpBunkerSiloWorker() and (vehicle:getCpStartingPointSetting():getValue() == CpJobParameters.START_AT_BUNKER_SILO or + elseif vehicle:getCanStartCpBunkerSiloWorker() and (vehicle:getCpStartingPointSetting():getValue() == CpFieldWorkJobParameters.START_AT_BUNKER_SILO or (AIUtil.hasChildVehicleWithSpecialization(vehicle, Leveler) and not AIUtil.hasChildVehicleWithSpecialization(vehicle, Shovel))) then return self.bunkerSiloWorkerLayout diff --git a/scripts/specializations/CpAIBaleFinder.lua b/scripts/specializations/CpAIBaleFinder.lua index 905a8d2a5..d640f0e65 100644 --- a/scripts/specializations/CpAIBaleFinder.lua +++ b/scripts/specializations/CpAIBaleFinder.lua @@ -4,7 +4,7 @@ local modName = CpAIBaleFinder and CpAIBaleFinder.MOD_NAME -- for reload ---@class CpAIBaleFinder CpAIBaleFinder = {} -CpAIBaleFinder.startText = g_i18n:getText("CP_jobParameters_startAt_bales") +CpAIBaleFinder.startText = g_i18n:getText("CP_fieldWorkJobParameters_startAt_bales") CpAIBaleFinder.MOD_NAME = g_currentModName or modName CpAIBaleFinder.NAME = ".cpAIBaleFinder" diff --git a/scripts/specializations/CpAIBunkerSiloWorker.lua b/scripts/specializations/CpAIBunkerSiloWorker.lua index f288847aa..fbea78db9 100644 --- a/scripts/specializations/CpAIBunkerSiloWorker.lua +++ b/scripts/specializations/CpAIBunkerSiloWorker.lua @@ -4,7 +4,7 @@ local modName = CpAIBunkerSiloWorker and CpAIBunkerSiloWorker.MOD_NAME -- for re ---@class CpAIBunkerSiloWorker CpAIBunkerSiloWorker = {} -CpAIBunkerSiloWorker.startText = g_i18n:getText("CP_jobParameters_startAt_bunkerSilo") +CpAIBunkerSiloWorker.startText = g_i18n:getText("CP_fieldWorkJobParameters_startAt_bunkerSilo") CpAIBunkerSiloWorker.MOD_NAME = g_currentModName or modName CpAIBunkerSiloWorker.NAME = ".cpAIBunkerSiloWorker" @@ -109,7 +109,7 @@ function CpAIBunkerSiloWorker:getCpStartableJob(superFunc, isStartedByHud) local spec = self.spec_cpAIBunkerSiloWorker local job = self:getCanStartCpBunkerSiloWorker() and spec.cpJob if isStartedByHud and not AIUtil.hasChildVehicleWithSpecialization(self, Leveler) then - job = self:getCpStartingPointSetting():getValue() == CpJobParameters.START_AT_BUNKER_SILO and job + job = self:getCpStartingPointSetting():getValue() == CpFieldWorkJobParameters.START_AT_BUNKER_SILO and job end return superFunc(self, isStartedByHud) or job end diff --git a/scripts/specializations/CpAICombineUnloader.lua b/scripts/specializations/CpAICombineUnloader.lua index 8527cd397..3f13de130 100644 --- a/scripts/specializations/CpAICombineUnloader.lua +++ b/scripts/specializations/CpAICombineUnloader.lua @@ -4,7 +4,7 @@ local modName = CpAICombineUnloader and CpAICombineUnloader.MOD_NAME -- for relo ---@class CpAICombineUnloader CpAICombineUnloader = {} -CpAICombineUnloader.startText = g_i18n:getText("CP_jobParameters_startAt_unload") +CpAICombineUnloader.startText = g_i18n:getText("CP_fieldWorkJobParameters_startAt_unload") CpAICombineUnloader.MOD_NAME = g_currentModName or modName CpAICombineUnloader.NAME = ".cpAICombineUnloader" diff --git a/scripts/specializations/CpAIFieldWorker.lua b/scripts/specializations/CpAIFieldWorker.lua index 3d9984752..6afc9033e 100644 --- a/scripts/specializations/CpAIFieldWorker.lua +++ b/scripts/specializations/CpAIFieldWorker.lua @@ -81,13 +81,13 @@ function CpAIFieldWorker:onLoad(savegame) local spec = self.spec_cpAIFieldWorker --- This job is for starting the driving with a key bind or the hud. spec.cpJob = g_currentMission.aiJobTypeManager:createJob(AIJobType.FIELDWORK_CP) - spec.cpJob:getCpJobParameters().startAt:setValue(CpJobParameters.START_AT_NEAREST_POINT) + spec.cpJob:getCpJobParameters().startAt:setValue(CpFieldWorkJobParameters.START_AT_NEAREST_POINT) spec.cpJob:setVehicle(self, true) --- Theses jobs are used for external mod, for example AutoDrive. spec.cpJobStartAtFirstWp = g_currentMission.aiJobTypeManager:createJob(AIJobType.FIELDWORK_CP) - spec.cpJobStartAtFirstWp:getCpJobParameters().startAt:setValue(CpJobParameters.START_AT_FIRST_POINT) + spec.cpJobStartAtFirstWp:getCpJobParameters().startAt:setValue(CpFieldWorkJobParameters.START_AT_FIRST_POINT) spec.cpJobStartAtLastWp = g_currentMission.aiJobTypeManager:createJob(AIJobType.FIELDWORK_CP) - spec.cpJobStartAtLastWp:getCpJobParameters().startAt:setValue(CpJobParameters.START_AT_LAST_POINT) + spec.cpJobStartAtLastWp:getCpJobParameters().startAt:setValue(CpFieldWorkJobParameters.START_AT_LAST_POINT) end function CpAIFieldWorker:onLoadFinished(savegame) diff --git a/scripts/specializations/CpAISiloLoaderWorker.lua b/scripts/specializations/CpAISiloLoaderWorker.lua index a6334e86c..43a7bec24 100644 --- a/scripts/specializations/CpAISiloLoaderWorker.lua +++ b/scripts/specializations/CpAISiloLoaderWorker.lua @@ -6,7 +6,7 @@ local modName = CpAISiloLoaderWorker and CpAISiloLoaderWorker.MOD_NAME -- for re ---@class CpAISiloLoaderWorker CpAISiloLoaderWorker = {} -CpAISiloLoaderWorker.startText = g_i18n:getText("CP_jobParameters_startAt_siloLoader") +CpAISiloLoaderWorker.startText = g_i18n:getText("CP_fieldWorkJobParameters_startAt_siloLoader") CpAISiloLoaderWorker.MOD_NAME = g_currentModName or modName CpAISiloLoaderWorker.NAME = ".cpAISiloLoaderWorker" @@ -106,7 +106,7 @@ function CpAISiloLoaderWorker:getCpStartableJob(superFunc, isStartedByHud) local spec = self.spec_cpAISiloLoaderWorker local job = self:getCanStartCpSiloLoaderWorker() and spec.cpJob if isStartedByHud and not AIUtil.hasChildVehicleWithSpecialization(self, ConveyorBelt) then - job = self:getCpStartingPointSetting():getValue() == CpJobParameters.START_AT_SILO_LOADING and job + job = self:getCpStartingPointSetting():getValue() == CpFieldWorkJobParameters.START_AT_SILO_LOADING and job end return superFunc(self, isStartedByHud) or job end diff --git a/scripts/specializations/CpGamePadHud.lua b/scripts/specializations/CpGamePadHud.lua index c9fdc8994..e58cabfdb 100644 --- a/scripts/specializations/CpGamePadHud.lua +++ b/scripts/specializations/CpGamePadHud.lua @@ -13,7 +13,7 @@ CpGamePadHud.GUI_NAME = "CpGamePadHudDialog" CpGamePadHud.SETTING_TYPES = { vehicleSettings = CpVehicleSettings, courseGeneratorSettings = CpCourseGeneratorSettings, - jobParameters = CpJobParameters, + fieldWorkJobParameters = CpFieldWorkJobParameters, baleFinderJobParameters = CpBaleFinderJobParameters, combineUnloaderJobParameters = CpCombineUnloaderJobParameters, bunkerSiloJobParameters = CpBunkerSiloJobParameters, @@ -194,10 +194,10 @@ function CpGamePadHud:actionEventOpenCloseDisplay() page = CpGamePadHud.UNLOADER_PAGE elseif self:getCanStartCpBaleFinder() then page = CpGamePadHud.BALE_LOADER_PAGE - elseif self:getCanStartCpSiloLoaderWorker() and (self:getCpStartingPointSetting():getValue() == CpJobParameters.START_AT_SILO_LOADING or + elseif self:getCanStartCpSiloLoaderWorker() and (self:getCpStartingPointSetting():getValue() == CpFieldWorkJobParameters.START_AT_SILO_LOADING or AIUtil.hasChildVehicleWithSpecialization(self, ConveyorBelt)) then page = CpGamePadHud.SILO_LOADER_PAGE - elseif self:getCanStartCpBunkerSiloWorker() and (self:getCpStartingPointSetting():getValue() == CpJobParameters.START_AT_BUNKER_SILO + elseif self:getCanStartCpBunkerSiloWorker() and (self:getCpStartingPointSetting():getValue() == CpFieldWorkJobParameters.START_AT_BUNKER_SILO or (AIUtil.hasChildVehicleWithSpecialization(self, Leveler) and not AIUtil.hasChildVehicleWithSpecialization(self, Shovel))) then page = CpGamePadHud.BUNKER_SILO_PAGE diff --git a/translations/translation_br.xml b/translations/translation_br.xml index 75c8c42e1..2e1169ff7 100644 --- a/translations/translation_br.xml +++ b/translations/translation_br.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_cs.xml b/translations/translation_cs.xml index fc92fd183..87ffa1ce8 100644 --- a/translations/translation_cs.xml +++ b/translations/translation_cs.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_ct.xml b/translations/translation_ct.xml index adaa0e9b1..366c8bc0b 100644 --- a/translations/translation_ct.xml +++ b/translations/translation_ct.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_cz.xml b/translations/translation_cz.xml index 670cd929c..13354b040 100644 --- a/translations/translation_cz.xml +++ b/translations/translation_cz.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_da.xml b/translations/translation_da.xml index 350f12887..9c539bf04 100644 --- a/translations/translation_da.xml +++ b/translations/translation_da.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_de.xml b/translations/translation_de.xml index da033aed6..d216563e0 100644 --- a/translations/translation_de.xml +++ b/translations/translation_de.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_ea.xml b/translations/translation_ea.xml index e1128cda8..a0b9d037c 100644 --- a/translations/translation_ea.xml +++ b/translations/translation_ea.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_en.xml b/translations/translation_en.xml index 51269f33b..5340f28e7 100644 --- a/translations/translation_en.xml +++ b/translations/translation_en.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_es.xml b/translations/translation_es.xml index 77fcd818e..cf02b1d2a 100644 --- a/translations/translation_es.xml +++ b/translations/translation_es.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_fc.xml b/translations/translation_fc.xml index b4b905726..b6fc0f5f7 100644 --- a/translations/translation_fc.xml +++ b/translations/translation_fc.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_fi.xml b/translations/translation_fi.xml index 714080897..3797d7d4c 100644 --- a/translations/translation_fi.xml +++ b/translations/translation_fi.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_fr.xml b/translations/translation_fr.xml index b94ab0433..6b5624763 100644 --- a/translations/translation_fr.xml +++ b/translations/translation_fr.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_hu.xml b/translations/translation_hu.xml index f7124a9e9..edc298f6e 100644 --- a/translations/translation_hu.xml +++ b/translations/translation_hu.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_it.xml b/translations/translation_it.xml index a918a6ae2..17861400b 100644 --- a/translations/translation_it.xml +++ b/translations/translation_it.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_jp.xml b/translations/translation_jp.xml index 81e017965..ae5153637 100644 --- a/translations/translation_jp.xml +++ b/translations/translation_jp.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_kr.xml b/translations/translation_kr.xml index 8e82f01c8..63ad5cd92 100644 --- a/translations/translation_kr.xml +++ b/translations/translation_kr.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_nl.xml b/translations/translation_nl.xml index b9d133128..7f15ccb4c 100644 --- a/translations/translation_nl.xml +++ b/translations/translation_nl.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_no.xml b/translations/translation_no.xml index eade5ed2b..3bd9725b4 100644 --- a/translations/translation_no.xml +++ b/translations/translation_no.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_pl.xml b/translations/translation_pl.xml index 6d9064e30..944625839 100644 --- a/translations/translation_pl.xml +++ b/translations/translation_pl.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_pt.xml b/translations/translation_pt.xml index 445079938..e52fd69d8 100644 --- a/translations/translation_pt.xml +++ b/translations/translation_pt.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_ro.xml b/translations/translation_ro.xml index d09065514..c144fe925 100644 --- a/translations/translation_ro.xml +++ b/translations/translation_ro.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_ru.xml b/translations/translation_ru.xml index 853c8eb76..0cedef01b 100644 --- a/translations/translation_ru.xml +++ b/translations/translation_ru.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_sv.xml b/translations/translation_sv.xml index 0971d1f81..0d515c1b8 100644 --- a/translations/translation_sv.xml +++ b/translations/translation_sv.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/translations/translation_tr.xml b/translations/translation_tr.xml index fa2992e89..883936bbd 100644 --- a/translations/translation_tr.xml +++ b/translations/translation_tr.xml @@ -30,28 +30,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + From fb606ec38c7cc959c938b0565c98227b905eeee1 Mon Sep 17 00:00:00 2001 From: David Schwietering Date: Fri, 15 Mar 2024 23:45:36 +0100 Subject: [PATCH 2/4] Another code improvement --- scripts/ai/jobs/CpAIJobBaleFinder.lua | 2 +- scripts/ai/jobs/CpAIJobBunkerSilo.lua | 2 +- scripts/ai/jobs/CpAIJobCombineUnloader.lua | 2 +- scripts/ai/jobs/CpAIJobFieldWork.lua | 2 +- scripts/ai/jobs/CpAIJobSiloLoader.lua | 2 +- scripts/gui/CpAIFrameExtended.lua | 7 ++----- 6 files changed, 7 insertions(+), 10 deletions(-) diff --git a/scripts/ai/jobs/CpAIJobBaleFinder.lua b/scripts/ai/jobs/CpAIJobBaleFinder.lua index cc7245bd8..a6544bd97 100644 --- a/scripts/ai/jobs/CpAIJobBaleFinder.lua +++ b/scripts/ai/jobs/CpAIJobBaleFinder.lua @@ -107,7 +107,7 @@ function CpAIJobBaleFinder:validateFieldPosition(isValid, errorMessage) return isValid, errorMessage end -function CpAIJobBaleFinder:drawSelectedField(map) +function CpAIJobBaleFinder:draw(map) self.selectedFieldPlot:draw(map) end diff --git a/scripts/ai/jobs/CpAIJobBunkerSilo.lua b/scripts/ai/jobs/CpAIJobBunkerSilo.lua index 9594dfef5..fc3ca4fbe 100644 --- a/scripts/ai/jobs/CpAIJobBunkerSilo.lua +++ b/scripts/ai/jobs/CpAIJobBunkerSilo.lua @@ -109,7 +109,7 @@ function CpAIJobBunkerSilo:validate(farmId) return true, '' end -function CpAIJobBunkerSilo:drawSilos(map) +function CpAIJobBunkerSilo:draw(map) g_bunkerSiloManager:drawSilos(map, self.bunkerSilo) end diff --git a/scripts/ai/jobs/CpAIJobCombineUnloader.lua b/scripts/ai/jobs/CpAIJobCombineUnloader.lua index b58e2cc66..3c01a9aa0 100644 --- a/scripts/ai/jobs/CpAIJobCombineUnloader.lua +++ b/scripts/ai/jobs/CpAIJobCombineUnloader.lua @@ -228,7 +228,7 @@ function CpAIJobCombineUnloader:validate(farmId) return isValid, errorMessage end -function CpAIJobCombineUnloader:drawSelectedField(map) +function CpAIJobCombineUnloader:draw(map) self.selectedFieldPlot:draw(map) self.heapPlot:draw(map) end diff --git a/scripts/ai/jobs/CpAIJobFieldWork.lua b/scripts/ai/jobs/CpAIJobFieldWork.lua index 3c884ae67..251a398cb 100644 --- a/scripts/ai/jobs/CpAIJobFieldWork.lua +++ b/scripts/ai/jobs/CpAIJobFieldWork.lua @@ -149,7 +149,7 @@ function CpAIJobFieldWork:validate(farmId) return true, '' end -function CpAIJobFieldWork:drawSelectedField(map) +function CpAIJobFieldWork:draw(map) if self.selectedFieldPlot then self.selectedFieldPlot:draw(map) end diff --git a/scripts/ai/jobs/CpAIJobSiloLoader.lua b/scripts/ai/jobs/CpAIJobSiloLoader.lua index a7bff9c60..da3f11227 100644 --- a/scripts/ai/jobs/CpAIJobSiloLoader.lua +++ b/scripts/ai/jobs/CpAIJobSiloLoader.lua @@ -321,7 +321,7 @@ function CpAIJobSiloLoader:getUnloadTriggerAt(unloadPosition) return found, trigger, station end -function CpAIJobSiloLoader:drawSilos(map) +function CpAIJobSiloLoader:draw(map) self.heapPlot:draw(map) g_bunkerSiloManager:drawSilos(map, self.bunkerSilo) if self.cpJobParameters.unloadAt:getValue() == CpSiloLoaderJobParameters.UNLOAD_TRIGGER then diff --git a/scripts/gui/CpAIFrameExtended.lua b/scripts/gui/CpAIFrameExtended.lua index 6d41d1ce2..337c6cddc 100644 --- a/scripts/gui/CpAIFrameExtended.lua +++ b/scripts/gui/CpAIFrameExtended.lua @@ -467,11 +467,8 @@ function CpInGameMenuAIFrameExtended:draw() local job = pageAI.currentJob if pageAI.mode == InGameMenuAIFrame.MODE_CREATE or pageAI.mode == CpInGameMenuAIFrameExtended.MODE_COURSE_GENERATOR then - if job and job.drawSelectedField then - job:drawSelectedField(self) - end - if job and job.drawSilos then - job:drawSilos(self) + if job and job.draw then + job:draw(self) end end From 4e229f8c82ba6381ada0a95ed919555119aeb88c Mon Sep 17 00:00:00 2001 From: David Schwietering Date: Fri, 15 Mar 2024 23:54:30 +0100 Subject: [PATCH 3/4] Another adjustment --- scripts/ai/jobs/CpAIJob.lua | 4 ++++ scripts/ai/jobs/CpAIJobBaleFinder.lua | 7 ++++-- scripts/ai/jobs/CpAIJobBunkerSilo.lua | 7 ++++-- scripts/ai/jobs/CpAIJobCombineUnloader.lua | 9 +++++--- scripts/ai/jobs/CpAIJobFieldWork.lua | 9 +++++--- scripts/ai/jobs/CpAIJobSiloLoader.lua | 27 ++++++++++++---------- scripts/gui/CpAIFrameExtended.lua | 5 ++-- 7 files changed, 44 insertions(+), 24 deletions(-) diff --git a/scripts/ai/jobs/CpAIJob.lua b/scripts/ai/jobs/CpAIJob.lua index d11895901..f28ab375e 100644 --- a/scripts/ai/jobs/CpAIJob.lua +++ b/scripts/ai/jobs/CpAIJob.lua @@ -269,6 +269,10 @@ function CpAIJob.getIsStartErrorText(state) return g_i18n:getText("ai_startStateSuccess") end +function CpAIJob:draw(map, isOverviewMap) + +end + function CpAIJob:writeStream(streamId, connection) streamWriteBool(streamId, self.isDirectStart) diff --git a/scripts/ai/jobs/CpAIJobBaleFinder.lua b/scripts/ai/jobs/CpAIJobBaleFinder.lua index a6544bd97..34dd06be2 100644 --- a/scripts/ai/jobs/CpAIJobBaleFinder.lua +++ b/scripts/ai/jobs/CpAIJobBaleFinder.lua @@ -107,8 +107,11 @@ function CpAIJobBaleFinder:validateFieldPosition(isValid, errorMessage) return isValid, errorMessage end -function CpAIJobBaleFinder:draw(map) - self.selectedFieldPlot:draw(map) +function CpAIJobBaleFinder:draw(map, isOverviewMap) + CpAIJob.draw(self, map, isOverviewMap) + if not isOverviewMap then + self.selectedFieldPlot:draw(map) + end end --- Gets the additional task description shown. diff --git a/scripts/ai/jobs/CpAIJobBunkerSilo.lua b/scripts/ai/jobs/CpAIJobBunkerSilo.lua index fc3ca4fbe..f3c2ded27 100644 --- a/scripts/ai/jobs/CpAIJobBunkerSilo.lua +++ b/scripts/ai/jobs/CpAIJobBunkerSilo.lua @@ -109,8 +109,11 @@ function CpAIJobBunkerSilo:validate(farmId) return true, '' end -function CpAIJobBunkerSilo:draw(map) - g_bunkerSiloManager:drawSilos(map, self.bunkerSilo) +function CpAIJobBunkerSilo:draw(map, isOverviewMap) + CpAIJob.draw(self, map, isOverviewMap) + if not isOverviewMap then + g_bunkerSiloManager:drawSilos(map, self.bunkerSilo) + end end function CpAIJobBunkerSilo:readStream(streamId, connection) diff --git a/scripts/ai/jobs/CpAIJobCombineUnloader.lua b/scripts/ai/jobs/CpAIJobCombineUnloader.lua index 3c01a9aa0..381b42137 100644 --- a/scripts/ai/jobs/CpAIJobCombineUnloader.lua +++ b/scripts/ai/jobs/CpAIJobCombineUnloader.lua @@ -228,9 +228,12 @@ function CpAIJobCombineUnloader:validate(farmId) return isValid, errorMessage end -function CpAIJobCombineUnloader:draw(map) - self.selectedFieldPlot:draw(map) - self.heapPlot:draw(map) +function CpAIJobCombineUnloader:draw(map, isOverviewMap) + CpAIJob.draw(self, map, isOverviewMap) + if not isOverviewMap then + self.selectedFieldPlot:draw(map) + self.heapPlot:draw(map) + end end ------------------------------------ diff --git a/scripts/ai/jobs/CpAIJobFieldWork.lua b/scripts/ai/jobs/CpAIJobFieldWork.lua index 251a398cb..f30fa72d3 100644 --- a/scripts/ai/jobs/CpAIJobFieldWork.lua +++ b/scripts/ai/jobs/CpAIJobFieldWork.lua @@ -149,9 +149,12 @@ function CpAIJobFieldWork:validate(farmId) return true, '' end -function CpAIJobFieldWork:draw(map) - if self.selectedFieldPlot then - self.selectedFieldPlot:draw(map) +function CpAIJobFieldWork:draw(map, isOverviewMap) + CpAIJob.draw(self, map, isOverviewMap) + if not isOverviewMap then + if self.selectedFieldPlot then + self.selectedFieldPlot:draw(map) + end end end diff --git a/scripts/ai/jobs/CpAIJobSiloLoader.lua b/scripts/ai/jobs/CpAIJobSiloLoader.lua index da3f11227..8ae7dd319 100644 --- a/scripts/ai/jobs/CpAIJobSiloLoader.lua +++ b/scripts/ai/jobs/CpAIJobSiloLoader.lua @@ -321,19 +321,22 @@ function CpAIJobSiloLoader:getUnloadTriggerAt(unloadPosition) return found, trigger, station end -function CpAIJobSiloLoader:draw(map) - self.heapPlot:draw(map) - g_bunkerSiloManager:drawSilos(map, self.bunkerSilo) - if self.cpJobParameters.unloadAt:getValue() == CpSiloLoaderJobParameters.UNLOAD_TRIGGER then - local fillTypes = self:getConvertedFillTypes() - local silo = self.heap or self.bunkerSilo - if silo then - table.insert(fillTypes, silo:getFillType()) +function CpAIJobSiloLoader:draw(map, isOverviewMap) + CpAIJob.draw(self, map, isOverviewMap) + if not isOverviewMap then + self.heapPlot:draw(map) + g_bunkerSiloManager:drawSilos(map, self.bunkerSilo) + if self.cpJobParameters.unloadAt:getValue() == CpSiloLoaderJobParameters.UNLOAD_TRIGGER then + local fillTypes = self:getConvertedFillTypes() + local silo = self.heap or self.bunkerSilo + if silo then + table.insert(fillTypes, silo:getFillType()) + end + g_triggerManager:drawDischargeableTriggers(map, self.unloadTrigger, fillTypes) + else + --- Drawing trailer area + self.trailerAreaPlot:draw(map) end - g_triggerManager:drawDischargeableTriggers(map, self.unloadTrigger, fillTypes) - else - --- Drawing trailer area - self.trailerAreaPlot:draw(map) end end diff --git a/scripts/gui/CpAIFrameExtended.lua b/scripts/gui/CpAIFrameExtended.lua index 337c6cddc..b6696f41e 100644 --- a/scripts/gui/CpAIFrameExtended.lua +++ b/scripts/gui/CpAIFrameExtended.lua @@ -466,9 +466,10 @@ function CpInGameMenuAIFrameExtended:draw() local pageAI = g_currentMission.inGameMenu.pageAI local job = pageAI.currentJob if pageAI.mode == InGameMenuAIFrame.MODE_CREATE or - pageAI.mode == CpInGameMenuAIFrameExtended.MODE_COURSE_GENERATOR then + pageAI.mode == InGameMenuAIFrame.MODE_OVERVIEW or + pageAI.mode == CpInGameMenuAIFrameExtended.MODE_COURSE_GENERATOR then if job and job.draw then - job:draw(self) + job:draw(self, pageAI.mode == InGameMenuAIFrame.MODE_OVERVIEW) end end From 257035e1fa40dc8723e77f79f3e20df9860212cc Mon Sep 17 00:00:00 2001 From: David Schwietering Date: Tue, 19 Mar 2024 20:24:38 +0100 Subject: [PATCH 4/4] WIP --- scripts/ai/jobs/CpJobParameters.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scripts/ai/jobs/CpJobParameters.lua b/scripts/ai/jobs/CpJobParameters.lua index 8221f9495..96e39be3b 100644 --- a/scripts/ai/jobs/CpJobParameters.lua +++ b/scripts/ai/jobs/CpJobParameters.lua @@ -148,10 +148,6 @@ function CpFieldWorkJobParameters.getSettings(vehicle) return vehicle.spec_cpAIFieldWorker.cpJob:getCpJobParameters() end -function CpFieldWorkJobParameters:isUnloadRefillTargetDisabled() - return self:isGiantsForStreetActive() --- TODO: Added check for refill/unload possibilities ... -end - function CpFieldWorkJobParameters:getMultiTools() local vehicle = self.job:getVehicle() if vehicle then