From 7f2e442a9ab526d33ca236f22e32136dd0d36baa Mon Sep 17 00:00:00 2001 From: schwiti6190 <58079399+schwiti6190@users.noreply.github.com> Date: Fri, 15 Sep 2023 15:28:23 +0200 Subject: [PATCH] Display debug text instead of dbg channel number --- config/DebugChannels.xml | 38 +++++++++++++++++++------------------- scripts/CpUtil.lua | 4 ++-- scripts/debug/CpDebug.lua | 11 ++++++++--- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/config/DebugChannels.xml b/config/DebugChannels.xml index b5f4eb4b1..6b9220c90 100644 --- a/config/DebugChannels.xml +++ b/config/DebugChannels.xml @@ -7,24 +7,24 @@ text : is the tooltip shown in the hud. --> - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/scripts/CpUtil.lua b/scripts/CpUtil.lua index 84dc7dca8..65f2436ad 100644 --- a/scripts/CpUtil.lua +++ b/scripts/CpUtil.lua @@ -150,7 +150,7 @@ end ---@param channel number function CpUtil.debugFormat(channel, ...) if CpDebug and CpDebug:isChannelActive(channel) then - CpUtil.internalPrint("dbg"..channel, ...) + CpUtil.internalPrint(CpDebug:getText(channel), ...) end end @@ -162,7 +162,7 @@ function CpUtil.debugVehicle(channel, vehicle, ...) local rootVehicle = vehicle and vehicle.rootVehicle local active = rootVehicle == nil or rootVehicle.getCpSettings == nil or CpUtil.isVehicleDebugActive(rootVehicle) if CpDebug and active and CpDebug:isChannelActive(channel) then - CpUtil.internalPrintVehicle(vehicle, "dbg"..channel, ...) + CpUtil.internalPrintVehicle(vehicle, CpDebug:getText(channel), ...) end end diff --git a/scripts/debug/CpDebug.lua b/scripts/debug/CpDebug.lua index 446ecdbc4..be247519d 100644 --- a/scripts/debug/CpDebug.lua +++ b/scripts/debug/CpDebug.lua @@ -20,7 +20,6 @@ function CpDebug:init() self.isEnabled = true --- Is the debug channel menu active ? self.menuVisible = false - self.activatedColor = {1, 0.5, 0, 1.0} self.disabledColor = {1, 1, 1, 1} end @@ -62,9 +61,15 @@ function CpDebug:isChannelActive(ix, vehicle) if self.channels[ix] then return self.channels[ix].active and vehicleDebugEnabled else - CpUtil.info('Error: debug channel %s not found!', tostring(ix)) - printCallstack() + CpUtil.error('Error: debug channel %s not found!', tostring(ix)) + end +end + +function CpDebug:getText(ix) + if not self.channels[ix] then + return "---" end + return self.channels[ix].text end function CpDebug:setChannelActive(ix, active)