Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #7319 from Courseplay/InfoTexts
Browse files Browse the repository at this point in the history
Diff changes
  • Loading branch information
schwiti6190 authored Jul 2, 2021
2 parents 1bdf5dc + 006fcea commit 3c2d99f
Show file tree
Hide file tree
Showing 15 changed files with 590 additions and 455 deletions.
15 changes: 8 additions & 7 deletions AIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -416,14 +416,15 @@ end
-- This has to be called in each update cycle to show messages
function AIDriver:updateInfoText()
for msg, _ in pairs(self.activeMsgReferences) do
CpManager:setGlobalInfoText(self.vehicle, msg)
g_globalInfoTextHandler:setInfoText(self.vehicle, msg)
end
end

--- Displays an one time ingame warning.
---@param msgReference string this can be a global info text or just a translation text.
function AIDriver:displayWarning(msgReference)
local msg = CpManager.globalInfoText.msgReference[msgReference] or msgReference
local infoTexts = g_globalInfoTextHandler:getInfoTexts()
local msg = infoTexts[msgReference] and infoTexts[msgReference].text or msgReference
local text = string.format("%s: %s",nameNum(self.vehicle),courseplay:loc(msg))
g_currentMission:addIngameNotification(FSBaseMission.INGAME_NOTIFICATION_CRITICAL, text)
end
Expand Down Expand Up @@ -1725,7 +1726,7 @@ end
--- without restarting the game.
function AIDriver:onDraw()
if CpManager.isDeveloper and self.course and
(self.vehicle.cp.drawCourseMode == courseplay.COURSE_2D_DISPLAY_DBGONLY or self.vehicle.cp.drawCourseMode == courseplay.COURSE_2D_DISPLAY_BOTH) then
self.settings.courseDrawMode:isCourseVisible() then
self.course:draw()
end
if CpManager.isDeveloper and self.pathfinder then
Expand Down Expand Up @@ -2189,13 +2190,13 @@ end
function AIDriver:isFuelLevelOk()
local currentFuelPercentage = self:getFuelLevelPercentage()
if currentFuelPercentage < 5 then
CpManager:setGlobalInfoText(self.vehicle, 'FUEL_MUST');
self:setInfoText('FUEL_MUST')
return false
elseif currentFuelPercentage < 20 then
CpManager:setGlobalInfoText(self.vehicle, 'FUEL_SHOULD');
self:setInfoText('FUEL_SHOULD')
elseif currentFuelPercentage < 99.99 then
-- CpManager:setGlobalInfoText(vehicle, 'FUEL_IS');
end;
-- self:setInfoText('FUEL_IS')
end
return true
end

Expand Down
2 changes: 1 addition & 1 deletion BalerAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function BalerAIDriver:handleBaler()
self:setSpeed(0)
--baler needs refilling of some sort (net,...)
if self.balerSpec.unloadingState == Baler.UNLOADING_CLOSED then
CpManager:setGlobalInfoText(self.vehicle, 'NEEDS_REFILLING');
self:setInfoText('NEEDS_REFILLING')
end
end
end
Expand Down
353 changes: 5 additions & 348 deletions CpManager.lua

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions Events/InfoTextEvent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ end
function InfoTextEvent:run(connection) -- wir fuehren das empfangene event aus
courseplay.debugVehicle(courseplay.DBG_MULTIPLAYER,vehicle,"run infoText event")
if self.vehicle then
CpManager:setGlobalInfoText(self.vehicle, self.refIdx, self.forceRemove)
if self.forceRemove then
g_globalInfoTextHandler:resetInfoText(self.vehicle,self.refIdx)
else
g_globalInfoTextHandler:setInfoText(self.vehicle,self.refIdx)
end
end

end

function InfoTextEvent.sendEvent(vehicle,refIdx,forceRemove)
Expand Down
6 changes: 6 additions & 0 deletions FieldworkAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ function FieldworkAIDriver:stop(msgReference)
AIDriver.stop(self, msgReference)
end


function FieldworkAIDriver:setWorkFinished(msgReference)
self:stopWork()
AIDriver.setWorkFinished(self, msgReference)
end

function FieldworkAIDriver:writeUpdateStream(streamId, connection, dirtyMask)
if self.vehicle.cp.settings.convoyActive:is(true) then
streamWriteInt32(streamId,self.convoyCurrentDistance)
Expand Down
Loading

0 comments on commit 3c2d99f

Please sign in to comment.