Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workaround: 1.5 patch #447

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions scripts/gui/pages/CpCourseGeneratorFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function CpCourseGeneratorFrame.new(target, custom_mt)
self.subCategoryTabs = {}
self.contextActions = {}
self.contextActionMapping = {}
self.playerFarmActiveJobs = {}
self.activeInfoTexts = {}
self.hasFullScreenMap = true
self.dataTables = {}
Expand Down Expand Up @@ -239,8 +240,7 @@ function CpCourseGeneratorFrame:update(dt)
for i = 1, self.activeWorkerList:getItemCount() do
local element = self.activeWorkerList:getElementAtSectionIndex(1, i)
if element ~= nil then
local job = g_currentMission.aiSystem:getJobByIndex(i)

local job = g_currentMission.aiSystem:getJobById(self.playerFarmActiveJobs[i])
if job ~= nil then
element:getAttribute("text"):setText(job:getDescription())
end
Expand Down Expand Up @@ -311,7 +311,10 @@ function CpCourseGeneratorFrame:onFrameOpen()
end
end, self)

g_messageCenter:subscribe(MessageType.AI_JOB_STARTED, function(self)
g_messageCenter:subscribe(MessageType.AI_JOB_STARTED, function(self, job, farmId)
if g_localPlayer ~= nil and farmId == g_localPlayer.farmId then
table.insert(self.playerFarmActiveJobs, job.jobId)
end
self.activeWorkerList:reloadData()
end, self)

Expand All @@ -328,8 +331,11 @@ function CpCourseGeneratorFrame:onFrameOpen()
end
end, self)
g_messageCenter:subscribe(MessageType.AI_JOB_REMOVED, function(self, jobId)
table.removeElement(self.playerFarmActiveJobs, jobId)
self.activeWorkerList:reloadData()
-- InGameMenuMapUtil.hideContextBox(self.contextBox)
InGameMenuMapUtil.hideContextBox(self.contextBox)
InGameMenuMapUtil.hideContextBox(self.contextBoxPlayer)
InGameMenuMapUtil.hideContextBox(self.contextBoxFarmland)
end, self)
g_messageCenter:subscribe(MessageType.CP_INFO_TEXT_CHANGED, function (menu)
self.infoTextList:reloadData()
Expand Down Expand Up @@ -374,6 +380,12 @@ function CpCourseGeneratorFrame:onFrameOpen()
else
self.buttonDeselectAllText:setText(g_i18n:getText(InGameMenuMapFrame.L10N_SYMBOL.DESELECT_ALL))
end
local farmId = g_localPlayer == nil and 1 or g_localPlayer.farmId
for _, job in ipairs(g_currentMission.aiSystem:getActiveJobs()) do
if job.startedFarmId == farmId then
table.insert(self.playerFarmActiveJobs, job.jobId)
end
end
self.activeWorkerList:reloadData()
self.filterList:reloadData()
if g_Courseplay.globalSettings.infoTextHudActive:getValue() > 0 then
Expand Down Expand Up @@ -1187,7 +1199,7 @@ function CpCourseGeneratorFrame:onClickList(list, section, index, listElement)
self.ingameMapBase:restoreDefaultFilter()
self:saveHotspotFilter()
elseif list == self.activeWorkerList then
local job = g_currentMission.aiSystem:getJobByIndex(index)
local job = g_currentMission.aiSystem:getJobById(self.playerFarmActiveJobs[index])
if job ~= nil and not job.vehicleParameter then
local vehicle = job.vehicleParameter:getVehicle()
if vehicle ~= nil then
Expand All @@ -1207,7 +1219,18 @@ function CpCourseGeneratorFrame:onClickList(list, section, index, listElement)
end

function CpCourseGeneratorFrame:onListSelectionChanged(list, section, index)

if list == self.activeWorkerList then
-- local job = g_currentMission.aiSystem:getJobById(self.playerFarmActiveJobs[index])
-- if job ~= nil and job.vehicleParameter then
-- local vehicle = job.vehicleParameter:getVehicle()
-- if vehicle ~= nil then
-- local hotspot = vehicle:getMapHotspot()
-- self.mode = InGameMenuMapFrame.AI_MODE_WORKER_LIST
-- self:setMapSelectionItem(hotspot)
-- self.ingameMap:panToHotspot(hotspot)
-- end
-- end
end
end

function CpCourseGeneratorFrame:mouseEvent(posX, posY, isDown, isUp, button, eventUsed)
Expand Down
Loading