From ad9a178b12e06fdfa1ab9080dcd7a8b740e57bf7 Mon Sep 17 00:00:00 2001 From: Goober5000 Date: Sun, 5 Jul 2020 18:51:39 -0400 Subject: [PATCH] add additional options to markbox keep track of fonts in a central place optionally draw the diagonals and health don't draw health if the subsys has no hitpoints --- MarkBox/data/tables/markbox-sct.tbm | 44 ++++++++++++++++------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/MarkBox/data/tables/markbox-sct.tbm b/MarkBox/data/tables/markbox-sct.tbm index 4204f0c..7ea230e 100644 --- a/MarkBox/data/tables/markbox-sct.tbm +++ b/MarkBox/data/tables/markbox-sct.tbm @@ -10,7 +10,12 @@ function MarkBox:Init() self.Enabled = false self.List = {} self.WeaponList = {} - + + self.DefaultFont = gr.Fonts[1] + self.MarkFont = gr.Fonts[3] + self.DrawSubsysDiagonals = true + self.DrawSubsysHealth = true + self.NextDistCheck = 0 self.DistCheckInterval = 1 @@ -328,7 +333,7 @@ function MarkBox:DrawSubsystemBracket(subsys, data) local player = hv.Player --[[gr.setColor(255,255,255,255) - gr.CurrentFont = gr.Fonts[1] + gr.CurrentFont = self.DefaultFont gr.drawString("Target Data:",100*i,100) gr.drawString("Ship: " .. player.Target.Name) gr.drawString("Actual: " .. player.TargetSubsystem:getModelName()) @@ -378,33 +383,32 @@ function MarkBox:DrawSubsystemBracket(subsys, data) gr.drawLine(nx2-1, ny2-1, nx2-lineLength, ny2) gr.drawLine(nx2-1, ny2-1, nx2, ny2-lineLength) - gr.CurrentFont = gr.Fonts[3] - - local hpPct = subsys.HitpointsLeft / subsys.HitpointsMax - local hpWidth = 100 + gr.CurrentFont = self.MarkFont - if focus then + if focus and self.DrawSubsysDiagonals then gr.drawLine(x1, y1, nx1, ny1) gr.drawLine(x1, y2, nx1, ny2) gr.drawLine(x2, y1, nx2, ny1) gr.drawLine(x2, y2, nx2, ny2) - - --gr.drawString(data.Text,x2+5,y2-20) - --gr.drawRectangle(x2+5,y2-5,x2+5+(hpWidth*hpPct), y2+0) - else - end if data.Text then gr.drawString(data.Text,nx2+5,ny2-20) end - gr.drawRectangle(nx2+5,ny2-5,nx2+5+(hpWidth*hpPct), ny2+0) + + if self.DrawSubsysHealth and subsys.HitpointsMax > 0 then + local hpPct = subsys.HitpointsLeft / subsys.HitpointsMax + local hpWidth = 100 + + gr.drawRectangle(nx2+5,ny2-5,nx2+5+(hpWidth*hpPct), ny2+0) + end + gr.setLineWidth(1) - end - - if not x1 then gr.drawSubsystemTargetingBrackets(subsys) end + else + gr.drawSubsystemTargetingBrackets(subsys) + end end @@ -412,7 +416,7 @@ function MarkBox:DrawShipBracket(ship, data) local player = hv.Player local focus - + local r,g,b = ship.Team:getColor() gr.setColor(r,g,b,192) @@ -426,15 +430,15 @@ function MarkBox:DrawShipBracket(ship, data) gr.setLineWidth(1) else if data.Text then - gr.CurrentFont = gr.Fonts[3] + gr.CurrentFont = self.MarkFont local x1,y1,x2,y2 = gr.drawTargetingBrackets(ship, false) if x1 and y1 then gr.drawString(data.Text,x1-5,y1-16) end - gr.CurrentFont = gr.Fonts[1] + gr.CurrentFont = self.DefaultFont end end - + end