Skip to content

Commit

Permalink
Merge pull request #1580 from Courseplay/InfoTexts
Browse files Browse the repository at this point in the history
Added Infotexts for off track error and proximity sensor stop.
  • Loading branch information
Tensuko authored May 22, 2022
2 parents 7ee6de4 + 2349d3c commit 417d7bb
Show file tree
Hide file tree
Showing 22 changed files with 97 additions and 40 deletions.
4 changes: 3 additions & 1 deletion config/InfoTexts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
-->

<InfoTexts prefix="CP_infoTexts_">
<InfoText name="ERROR_STOPPED" text="errorStopped" class="AIMessageCpError"/>

<InfoText name="IS_STUCK" text="isStuck"/>
<InfoText name="TRAFFIC" text="isInTraffic"/>
<InfoText name="BLOCKED_BY_OBJECT" text="blockedByObject"/>

<InfoText name="OUT_OF_MONEY" text="outOfMoney" class="AIMessageErrorOutOfMoney"/>
<InfoText name="FUEL_IS_EMPTY" text="needsFuel" hasFinished="true" event="onCpFuelEmpty" class="AIMessageErrorOutOfFuel"/>
Expand Down
18 changes: 17 additions & 1 deletion scripts/ai/AIMessages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,24 @@ function AIMessageErrorIsFull:getMessage()
return g_i18n:getText("CP_ai_messageErrorIsFull")
end

AIMessageCpError = {
name = "CP_ERROR"
}
local AIMessageCpError_mt = Class(AIMessageCpError, AIMessage)

function AIMessageCpError.new(customMt)
local self = AIMessage.new(customMt or AIMessageCpError_mt)

return self
end

function AIMessageCpError:getMessage()
return g_i18n:getText("CP_ai_messageError")
end

function AIMessageErrorIsFull.register()
g_currentMission.aiMessageManager:registerMessage(AIMessageErrorIsFull.name, AIMessageErrorIsFull)
g_currentMission.aiMessageManager:registerMessage(AIMessageCpError.name, AIMessageCpError)
end

--- Another ugly hack, as the giants code to get the message index in mp isn't working ..
Expand All @@ -25,4 +41,4 @@ local function getMessageIndex(aiMessageManager, superFunc, messageObject, ...)
end
return ix
end
AIMessageManager.getMessageIndex = Utils.overwrittenFunction(AIMessageManager.getMessageIndex, getMessageIndex)
AIMessageManager.getMessageIndex = Utils.overwrittenFunction(AIMessageManager.getMessageIndex, getMessageIndex)
3 changes: 2 additions & 1 deletion scripts/ai/InfoTextsManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ CpInfoTextElement.aiMessageNameToClass = {
AIMessageErrorOutOfFuel = AIMessageErrorOutOfFuel,
AIMessageErrorVehicleBroken = AIMessageErrorVehicleBroken,
AIMessageErrorOutOfMoney = AIMessageErrorOutOfMoney,
AIMessageErrorBlockedByObject = AIMessageErrorBlockedByObject
AIMessageErrorBlockedByObject = AIMessageErrorBlockedByObject,
AIMessageCpError = AIMessageCpError
}

--- Info text
Expand Down
5 changes: 5 additions & 0 deletions scripts/ai/ProximityController.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ end
---@return boolean direction is forwards if true or nil
---@return number maximum speed adjusted to slow down (or 0 to stop) when obstacles are ahead, otherwise maxSpeed
function ProximityController:getDriveData(maxSpeed)

--- Resets the traffic info text.
self.vehicle:resetCpActiveInfoText(InfoTextManager.BLOCKED_BY_OBJECT)

local d, vehicle, range, deg, dAvg = math.huge, nil, 10, 0
local pack = self.ppc:isReversing() and self.backwardLookingProximitySensorPack or self.forwardLookingProximitySensorPack
if pack then
Expand All @@ -74,6 +78,7 @@ function ProximityController:getDriveData(maxSpeed)
self:setState(self.states.STOP,
string.format('Obstacle ahead, d = %.1f, deg = %.1f, too close, stop.', d, deg))
maxSpeed = 0
self.vehicle:setCpInfoTextActive(InfoTextManager.BLOCKED_BY_OBJECT)
elseif normalizedD < 1 and self:isSlowdownEnabled(vehicle) then
-- something in range, reduce speed proportionally when enabled
local deltaV = maxSpeed - self.minLimitedSpeed
Expand Down
2 changes: 1 addition & 1 deletion scripts/ai/PurePursuitController.lua
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ function PurePursuitController:findGoalPoint()
end
if (q1 > self.cutOutDistanceLimit) and (q2 > self.cutOutDistanceLimit) then
CpUtil.infoVehicle(self.vehicle, 'vehicle off track, shutting off Courseplay now.')
self.vehicle:stopCurrentAIJob(AIMessageErrorUnknown.new())
self.vehicle:stopCurrentAIJob(AIMessageCpError.new())
return
end
break
Expand Down
6 changes: 4 additions & 2 deletions translations/translation_br.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

<!-- AI messages -->
<text name="CP_ai_messageErrorIsFull" text="motorista AI %s parou de trabalhar inesperadamente - o tanque está cheio!" />
<text name="CP_ai_messageError" text="AI worker %s has stopped work unexpectedly - left the course!" />
<!-- VehicleSettings -->
<text name="CP_vehicle_setting_title" text="Configuração do veículo para (%s)"/>

Expand Down Expand Up @@ -321,7 +322,7 @@

<!-- Info texts -->
<text name="CP_infoTexts_isStuck" text="O ajudante está preso"/>
<text name="CP_infoTexts_isInTraffic" text="Está no trânsito"/>
<text name="CP_infoTexts_blockedByObject" text="Blocked by an object"/>
<text name="CP_infoTexts_shouldRefuel" text="Precisa reabastecer"/>
<text name="CP_infoTexts_needsFuel" text="Precisa reabastecer urgente"/>
<text name="CP_infoTexts_needsRepair" text="Precisa ser reparado"/>
Expand All @@ -330,6 +331,7 @@
<text name="CP_infoTexts_workFinished" text="Trabalho feito"/>
<text name="CP_infoTexts_outOfMoney" text="Sem dinheiro"/>
<text name="CP_infoTexts_waitForRainToFinish" text="Esperando a chuva passar"/>
<text name="CP_infoTexts_errorStopped" text="Left the course, stopped"/>

<!--Custom Field-->
<text name="CP_customFieldManager_confirm_save" text="Deseja salvar a rota gravado como campo customizado %s?"/>
Expand Down Expand Up @@ -596,7 +598,7 @@ Ao clicar nele, você pode pular diretamente para o veículo.
<text name="CP_help_page_infoPanelMsg_text" text="
As Informações são as seguintes:
- O motorista está preso
- Está no trânsito
- Blocked by an object
- Deve ser reabastecido
- Precisa ser reabastecido
- Precisa ser reparado
Expand Down
6 changes: 4 additions & 2 deletions translations/translation_cs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

<!-- AI messages -->
<text name="CP_ai_messageErrorIsFull" text="工人%s 停止工作-储存箱已满!" />
<text name="CP_ai_messageError" text="AI worker %s has stopped work unexpectedly - left the course!" />

<!-- VehicleSettings -->
<text name="CP_vehicle_setting_title" text="车辆设置(%s)"/>
Expand Down Expand Up @@ -324,7 +325,7 @@

<!-- Info texts -->
<text name="CP_infoTexts_isStuck" text="助手卡住了"/>
<text name="CP_infoTexts_isInTraffic" text="正在路上"/>
<text name="CP_infoTexts_blockedByObject" text="Blocked by an object"/>
<text name="CP_infoTexts_shouldRefuel" text="应该加油"/>
<text name="CP_infoTexts_needsFuel" text="需要加油"/>
<text name="CP_infoTexts_needsRepair" text="需要修理"/>
Expand All @@ -333,6 +334,7 @@
<text name="CP_infoTexts_workFinished" text="完成工作"/>
<text name="CP_infoTexts_outOfMoney" text="资金不足"/>
<text name="CP_infoTexts_waitForRainToFinish" text="等待雨停"/>
<text name="CP_infoTexts_errorStopped" text="Left the course, stopped"/>

<!--Custom Field-->
<text name="CP_customFieldManager_confirm_save" text="是否要将录制的任务保存为自定义田地 %s?"/>
Expand Down Expand Up @@ -589,7 +591,7 @@ R: 从剪贴板中删除复制的路线。
<text name="CP_help_page_infoPanelMsg_text" text="
信息如下:
- 助手卡住了
- 正在路上
- Blocked by an object
- 应该加油
- 需要加油
- 需要修理
Expand Down
6 changes: 4 additions & 2 deletions translations/translation_ct.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

<!-- AI messages -->
<text name="CP_ai_messageErrorIsFull" text="AI worker %s has stopped work unexpectedly - tank is full!" />
<text name="CP_ai_messageError" text="AI worker %s has stopped work unexpectedly - left the course!" />
<!-- VehicleSettings -->
<text name="CP_vehicle_setting_title" text="Vehicle settings for (%s)"/>

Expand Down Expand Up @@ -320,7 +321,7 @@

<!-- Info texts -->
<text name="CP_infoTexts_isStuck" text="Helper is stuck"/>
<text name="CP_infoTexts_isInTraffic" text="Is in traffic"/>
<text name="CP_infoTexts_blockedByObject" text="Blocked by an object"/>
<text name="CP_infoTexts_shouldRefuel" text="Should be refueled"/>
<text name="CP_infoTexts_needsFuel" text="Needs to be refueled"/>
<text name="CP_infoTexts_needsRepair" text="Needs to be repaired"/>
Expand All @@ -329,6 +330,7 @@
<text name="CP_infoTexts_workFinished" text="Finished work"/>
<text name="CP_infoTexts_outOfMoney" text="Out of money"/>
<text name="CP_infoTexts_waitForRainToFinish" text="Waiting for rain to finish"/>
<text name="CP_infoTexts_errorStopped" text="Left the course, stopped"/>

<!--Custom Field-->
<text name="CP_customFieldManager_confirm_save" text="Do you want to save the recorded course as custom field %s?"/>
Expand Down Expand Up @@ -592,7 +594,7 @@ By clicking on it, you can jump directly into the vehicle.
<text name="CP_help_page_infoPanelMsg_text" text="
The Informations are the following:
- Helper is stuck
- Is in traffic
- Blocked by an object
- Should be refueled
- Needs to be refueled
- Needs to be repaired
Expand Down
6 changes: 4 additions & 2 deletions translations/translation_cz.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

<!-- AI messages -->
<text name="CP_ai_messageErrorIsFull" text="Pracovník %s přestal neočekávaně pracovat – zásobník je plný!" />
<text name="CP_ai_messageError" text="AI worker %s has stopped work unexpectedly - left the course!" />

<!-- VehicleSettings -->
<text name="CP_vehicle_setting_title" text="Nastavení pro vozidlo (%s)"/>
Expand Down Expand Up @@ -321,7 +322,7 @@

<!-- Info texts -->
<text name="CP_infoTexts_isStuck" text="Pomocník se zasekl"/>
<text name="CP_infoTexts_isInTraffic" text="Je v provozu"/>
<text name="CP_infoTexts_blockedByObject" text="Blocked by an object"/>
<text name="CP_infoTexts_shouldRefuel" text="Měl by se dotankovat"/>
<text name="CP_infoTexts_needsFuel" text="Je třeba dotankovat"/>
<text name="CP_infoTexts_needsRepair" text="Je třeba opravit"/>
Expand All @@ -330,6 +331,7 @@
<text name="CP_infoTexts_workFinished" text="Dokončil práci"/>
<text name="CP_infoTexts_outOfMoney" text="Došly peníze"/>
<text name="CP_infoTexts_waitForRainToFinish" text="Čekání na konec deště"/>
<text name="CP_infoTexts_errorStopped" text="Left the course, stopped"/>

<!--Custom Field-->
<text name="CP_customFieldManager_confirm_save" text="Chcete uložit zaznamenaný kurz jako vlastní pole %s?"/>
Expand Down Expand Up @@ -589,7 +591,7 @@ Kliknutím na něj můžete skočit přímo do vozidla.
<text name="CP_help_page_infoPanelMsg_text" text="
Informace jsou následující:
- Pomocník se zasekl
- Je v provozu
- Blocked by an object
- Mělo by se natankovat
- Je třeba doplnit palivo
- Potřebuje opravit
Expand Down
6 changes: 4 additions & 2 deletions translations/translation_da.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

<!-- AI messages -->
<text name="CP_ai_messageErrorIsFull" text="Hjælper (%s) har stoppet arbejdet - Enheden er fyldt!"/>
<text name="CP_ai_messageError" text="AI worker %s has stopped work unexpectedly - left the course!" />

<!-- VehicleSettings -->
<text name="CP_vehicle_setting_title" text="Køretøjsinstillinger (%s)"/>
Expand Down Expand Up @@ -324,7 +325,7 @@

<!-- Info texts -->
<text name="CP_infoTexts_isStuck" text="Køretøjet sidder fast"/>
<text name="CP_infoTexts_isInTraffic" text="Er undervejs"/>
<text name="CP_infoTexts_blockedByObject" text="Blocked by an object"/>
<text name="CP_infoTexts_shouldRefuel" text="Skal tankes"/>
<text name="CP_infoTexts_needsFuel" text="Skal tankes"/>
<text name="CP_infoTexts_needsRepair" text="Skal repareres"/>
Expand All @@ -333,6 +334,7 @@
<text name="CP_infoTexts_workFinished" text="Arbejdet er udført"/>
<text name="CP_infoTexts_outOfMoney" text="Ikke nok penge"/>
<text name="CP_infoTexts_waitForRainToFinish" text="Venter på at regnen stopper"/>
<text name="CP_infoTexts_errorStopped" text="Left the course, stopped"/>

<!--Custom Field-->
<text name="CP_customFieldManager_confirm_save" text="Ønsker du at gemme den optagnede rute som en brugerdefineret mark %s?"/>
Expand Down Expand Up @@ -595,7 +597,7 @@ Ved at klikke på den kan du hoppe direkte ind i køretøjet.
<text name="CP_help_page_infoPanelMsg_text" text="
Informationerne er følgende:
- Hjælperen sidder fast
- Er undervejs
- Blocked by an object
- Skal tankes op
- Skal tankes op
- Skal repareres
Expand Down
8 changes: 5 additions & 3 deletions translations/translation_de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

<!-- AI messages -->
<text name="CP_ai_messageErrorIsFull" text="Helfer %s hat die Arbeit gestoppt - Gerät ist voll!" />
<text name="CP_ai_messageError" text="Helfer %s hat die Arbeit gestoppt - Kurs verlassen!" />

<!-- VehicleSettings -->
<text name="CP_vehicle_setting_title" text="Fahrzeugeinstellungen für (%s)"/>
Expand Down Expand Up @@ -321,8 +322,8 @@
<text name="CP_courseManager_activate" text="aktivieren"/>

<!-- Info texts -->
<text name="CP_infoTexts_isStuck" text="Wird blockiert"/>
<text name="CP_infoTexts_isInTraffic" text="Steckt im Verkehr fest"/>
<text name="CP_infoTexts_isStuck" text="Hängt fest"/>
<text name="CP_infoTexts_blockedByObject" text="Wird blockiert"/>
<text name="CP_infoTexts_shouldRefuel" text="Sollte aufgetankt werden"/>
<text name="CP_infoTexts_needsFuel" text="Muss aufgetankt werden"/>
<text name="CP_infoTexts_needsRepair" text="Sollte repariert werden"/>
Expand All @@ -331,6 +332,7 @@
<text name="CP_infoTexts_workFinished" text="Arbeit beendet"/>
<text name="CP_infoTexts_outOfMoney" text="Kein Geld mehr"/>
<text name="CP_infoTexts_waitForRainToFinish" text="Warte auf besseres Wetter"/>
<text name="CP_infoTexts_errorStopped" text="Hat den Kurs verlassen, gestoppt"/>

<!--Custom Field-->
<text name="CP_customFieldManager_confirm_save" text="Möchtest du diesen benutzerdefinierten Randkurs als %s speichern?"/>
Expand Down Expand Up @@ -598,8 +600,8 @@ Klickst du darauf, springst du direkt in das entsprechende Fahrzeug.
"/>
<text name="CP_help_page_infoPanelMsg_text" text="
Die Informationen sind:
- Hängt fest
- Wird blockiert
- Steckt im Verkehr fest
- Sollte aufgetankt werden
- Muss aufgetankt werden
- Sollte repariert werden
Expand Down
7 changes: 4 additions & 3 deletions translations/translation_en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

<!-- AI messages -->
<text name="CP_ai_messageErrorIsFull" text="AI worker %s has stopped work unexpectedly - tank is full!" />
<text name="CP_ai_messageError" text="AI worker %s has stopped work unexpectedly - left the course!" />
<!-- VehicleSettings -->
<text name="CP_vehicle_setting_title" text="Vehicle settings for (%s)"/>

Expand Down Expand Up @@ -322,7 +323,7 @@

<!-- Info texts -->
<text name="CP_infoTexts_isStuck" text="Helper is stuck"/>
<text name="CP_infoTexts_isInTraffic" text="Is in traffic"/>
<text name="CP_infoTexts_blockedByObject" text="Blocked by an object"/>
<text name="CP_infoTexts_shouldRefuel" text="Should be refueled"/>
<text name="CP_infoTexts_needsFuel" text="Needs to be refueled"/>
<text name="CP_infoTexts_needsRepair" text="Needs to be repaired"/>
Expand All @@ -331,7 +332,7 @@
<text name="CP_infoTexts_workFinished" text="Finished work"/>
<text name="CP_infoTexts_outOfMoney" text="Out of money"/>
<text name="CP_infoTexts_waitForRainToFinish" text="Waiting for rain to finish"/>

<text name="CP_infoTexts_errorStopped" text="Left the course, stopped"/>
<!--Custom Field-->
<text name="CP_customFieldManager_confirm_save" text="Do you want to save the recorded course as custom field %s?"/>
<text name="CP_customFieldManager_confirm_delete" text="Do you want to delete the custom field %s?"/>
Expand Down Expand Up @@ -598,7 +599,7 @@ By clicking on it, you can jump directly into the vehicle.
<text name="CP_help_page_infoPanelMsg_text" text="
The Informations are the following:
- Helper is stuck
- Is in traffic
- Blocked by an object
- Should be refueled
- Needs to be refueled
- Needs to be repaired
Expand Down
6 changes: 4 additions & 2 deletions translations/translation_es.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

<!-- AI messages -->
<text name="CP_ai_messageErrorIsFull" text="Trabajador CP %s ha dejado de trabajar inesperadamente: ¡El tanque está lleno!" />
<text name="CP_ai_messageError" text="AI worker %s has stopped work unexpectedly - left the course!" />

<!-- VehicleSettings -->
<text name="CP_vehicle_setting_title" text="Configuración del vehículo (%s)"/>
Expand Down Expand Up @@ -322,7 +323,7 @@

<!-- Info texts -->
<text name="CP_infoTexts_isStuck" text="Está Atascado"/>
<text name="CP_infoTexts_isInTraffic" text="Está en el tráfico"/>
<text name="CP_infoTexts_blockedByObject" text="Blocked by an object"/>
<text name="CP_infoTexts_shouldRefuel" text="Debería ser repostado"/>
<text name="CP_infoTexts_needsFuel" text="Necesita ser repostado"/>
<text name="CP_infoTexts_needsRepair" text="Necesita reparaciones"/>
Expand All @@ -331,6 +332,7 @@
<text name="CP_infoTexts_workFinished" text="Trabajo finalizado"/>
<text name="CP_infoTexts_outOfMoney" text="Sin dinero"/>
<text name="CP_infoTexts_waitForRainToFinish" text="Esperando que termine la lluvia"/>
<text name="CP_infoTexts_errorStopped" text="Left the course, stopped"/>

<!--Custom Field-->
<text name="CP_customFieldManager_confirm_save" text="¿Quieres guardar la ruta como campo personalizado %s?"/>
Expand Down Expand Up @@ -593,7 +595,7 @@ Al hacer clic en él, puede saltar directamente al vehículo.
<text name="CP_help_page_infoPanelMsg_text" text="
Las informaciones son las siguientes:
- El ayudante está atascado
- Está en el tráfico
- Blocked by an object
- Debe ser repostado
- Necesita ser repostado
- Necesita ser reparado
Expand Down
6 changes: 4 additions & 2 deletions translations/translation_fr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

<!-- AI messages -->
<text name="CP_ai_messageErrorIsFull" text="L'ouvrier %s a interrompu son travail - la tremie est pleine!" />
<text name="CP_ai_messageError" text="AI worker %s has stopped work unexpectedly - left the course!" />


<!-- VehicleSettings -->
Expand Down Expand Up @@ -323,7 +324,7 @@

<!-- Info texts -->
<text name="CP_infoTexts_isStuck" text="L'ouvrier est bloqué"/>
<text name="CP_infoTexts_isInTraffic" text="est en transit"/>
<text name="CP_infoTexts_blockedByObject" text="Blocked by an object"/>
<text name="CP_infoTexts_shouldRefuel" text="a besoin de faire le plein d'essence"/>
<text name="CP_infoTexts_needsFuel" text="doit faire le plein d'essence"/>
<text name="CP_infoTexts_needsRepair" text="doit être réparé"/>
Expand All @@ -332,6 +333,7 @@
<text name="CP_infoTexts_workFinished" text="a terminé son travail"/>
<text name="CP_infoTexts_outOfMoney" text="Plus d'argent disponible"/>
<text name="CP_infoTexts_waitForRainToFinish" text="Attend que la pluie s'arrête pour continuer"/>
<text name="CP_infoTexts_errorStopped" text="Left the course, stopped"/>

<!--Custom Field-->
<text name="CP_customFieldManager_confirm_save" text="Souhaitez-vous sauvegarder la course enregistrée comme contour de champ personnalisé %s?"/>
Expand Down Expand Up @@ -585,7 +587,7 @@ En cliquant dessus, vous arrivez directement dans le véhicule.
<text name="CP_help_page_infoPanelMsg_text" text="
Les informations concernant l'ouvrier peuvent être les suivantes:
- Est bloqué
- Est en transit
- Blocked by an object
- Devrait bientôt refaire le plein de carburant
- Doit refaire le plein de carburant
- Doit être réparé
Expand Down
Loading

0 comments on commit 417d7bb

Please sign in to comment.