From 2197a93cbd0d1edc04a0789588df999506f0d01f Mon Sep 17 00:00:00 2001 From: Nebual Date: Thu, 4 Jan 2018 00:45:07 -0800 Subject: [PATCH] Add nadmod_overlay convar --- lua/autorun/client/cl_nadmodpp.lua | 30 ++++++++++++++++++++---------- lua/autorun/server/nadmod_pp.lua | 1 + 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/lua/autorun/client/cl_nadmodpp.lua b/lua/autorun/client/cl_nadmodpp.lua index 9d6f137..09372e5 100644 --- a/lua/autorun/client/cl_nadmodpp.lua +++ b/lua/autorun/client/cl_nadmodpp.lua @@ -23,25 +23,35 @@ net.Receive("nadmod_propowners",function(len) end end) +local nadmod_overlay_convar = CreateConVar("nadmod_overlay", 2, {FCVAR_NOTIFY, FCVAR_ARCHIVE, FCVAR_REPLICATED}, "0 - Disables NPP Overlay. 1 - Minimal overlay of just owner info. 2 - Includes model, entityID, class") local font = "ChatFont" hook.Add("HUDPaint", "NADMOD.HUDPaint", function() + local nadmod_overlay_setting = nadmod_overlay_convar:GetInt() + if nadmod_overlay_setting == 0 then return end local tr = LocalPlayer():GetEyeTrace() if !tr.HitNonWorld then return end local ent = tr.Entity if ent:IsValid() && !ent:IsPlayer() then local text = "Owner: " .. (Props[ent:EntIndex()] or "N/A") - local text2 = "'"..string.sub(table.remove(string.Explode("/", ent:GetModel() or "?")), 1,-5).."' ["..ent:EntIndex().."]" - local text3 = ent:GetClass() surface.SetFont(font) local Width, Height = surface.GetTextSize(text) - local w2,h2 = surface.GetTextSize(text2) - local w3,h3 = surface.GetTextSize(text3) - local boxHeight = Height + h2 + h3 + 16 - local boxWidth = math.Max(Width,w2,w3) + 25 - draw.RoundedBox(4, ScrW() - (boxWidth + 4), (ScrH()/2 - 200) - 16, boxWidth, boxHeight, Color(0, 0, 0, 150)) - draw.SimpleText(text, font, ScrW() - (Width / 2) - 20, ScrH()/2 - 200, Color(255, 255, 255, 255), 1, 1) - draw.SimpleText(text2, font, ScrW() - (w2 / 2) - 20, ScrH()/2 - 200 + Height, Color(255, 255, 255, 255), 1, 1) - draw.SimpleText(text3, font, ScrW() - (w3 / 2) - 20, ScrH()/2 - 200 + Height + h2, Color(255, 255, 255, 255), 1, 1) + local boxWidth = Width + 25 + local boxHeight = Height + 16 + if nadmod_overlay_setting > 1 then + local text2 = "'"..string.sub(table.remove(string.Explode("/", ent:GetModel() or "?")), 1,-5).."' ["..ent:EntIndex().."]" + local text3 = ent:GetClass() + local w2,h2 = surface.GetTextSize(text2) + local w3,h3 = surface.GetTextSize(text3) + boxWidth = math.Max(Width,w2,w3) + 25 + boxHeight = boxHeight + h2 + h3 + draw.RoundedBox(4, ScrW() - (boxWidth + 4), (ScrH()/2 - 200) - 16, boxWidth, boxHeight, Color(0, 0, 0, 150)) + draw.SimpleText(text, font, ScrW() - (Width / 2) - 20, ScrH()/2 - 200, Color(255, 255, 255, 255), 1, 1) + draw.SimpleText(text2, font, ScrW() - (w2 / 2) - 20, ScrH()/2 - 200 + Height, Color(255, 255, 255, 255), 1, 1) + draw.SimpleText(text3, font, ScrW() - (w3 / 2) - 20, ScrH()/2 - 200 + Height + h2, Color(255, 255, 255, 255), 1, 1) + else + draw.RoundedBox(4, ScrW() - (boxWidth + 4), (ScrH()/2 - 200) - 16, boxWidth, boxHeight, Color(0, 0, 0, 150)) + draw.SimpleText(text, font, ScrW() - (Width / 2) - 20, ScrH()/2 - 200, Color(255, 255, 255, 255), 1, 1) + end end end) diff --git a/lua/autorun/server/nadmod_pp.lua b/lua/autorun/server/nadmod_pp.lua index 760086f..43862bf 100644 --- a/lua/autorun/server/nadmod_pp.lua +++ b/lua/autorun/server/nadmod_pp.lua @@ -488,6 +488,7 @@ function NADMOD.DebugTotals(ply,cmd,args) end concommand.Add("nadmod_totals", NADMOD.DebugTotals) +CreateConVar("nadmod_overlay", 2, {FCVAR_NOTIFY, FCVAR_ARCHIVE, FCVAR_REPLICATED}, "0 - Disables NPP Overlay. 1 - Minimal overlay of just owner info. 2 - Includes model, entityID, class") --=========================================================-- -- Clientside Callbacks for the Friends/Options panels --