From b47603c9ea9902a2abde311370c4859dcc7d033c Mon Sep 17 00:00:00 2001 From: AlmTech Software Date: Sun, 2 Feb 2020 18:16:26 +0100 Subject: [PATCH] Improve text above players head --- gamemode/engine/core/client/cl_hud.lua | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/gamemode/engine/core/client/cl_hud.lua b/gamemode/engine/core/client/cl_hud.lua index 4bfa38b..deb8177 100644 --- a/gamemode/engine/core/client/cl_hud.lua +++ b/gamemode/engine/core/client/cl_hud.lua @@ -45,12 +45,6 @@ local function renderStatHUD() local txtW, txtH = surface.GetTextSize( hptxt ) surface.SetTextPos( ( ( sw/2 - txtW/2 ) + padding/2 ), ( ( sh*0.9 - txtH/3 ) ) ) surface.DrawText( hptxt ) - - -- Crosshair - -- if( Quantum.Client.ShowCrosshair ) then - -- surface.SetDrawColor( 255, 255, 255, 200 ) - -- surface.DrawRect( sw/2 - radius, sh/2 - radius, radius*2, radius*2 ) - -- end end local function renderItemInfoHUD() @@ -150,7 +144,7 @@ end local function renderCharNamesHUD3D2D() local entsNear = ents.FindInSphere( LocalPlayer():GetPos(), Quantum.CharInfoDisplayDistance ) - local txtPadding = 32 * scale + local txtPadding = 38 * scale for i, ent in pairs( entsNear ) do if( ent:IsPlayer() && ent != LocalPlayer() ) then @@ -169,10 +163,19 @@ local function renderCharNamesHUD3D2D() local isServerMasterOnDuty = ent:GetNWBool( "q_servermaster_onduty" ) if( isServerMasterOnDuty ) then pos.z = pos.z + 4 end + + surface.SetFont( "q_char_hud_name" ) + local txtW, txtH = surface.GetTextSize( name ) + local W, H = txtW + padding*5, txtH - padding/2 cam.Start3D2D( pos, ang, 0.125 ) - draw.SimpleText( name, "q_char_hud_name", 0, 0, Color( 245, 245, 245, 255 * distFrac ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) + --surface.SetDrawColor( Color( 0, 0, 0, 200 ) ) + --surface.DrawRect( -txtW/2, -txtH/2, txtW, txtH ) + draw.RoundedBox( padding*2.5, -W/2, -H/2, W, H, Color( 0, 0, 0, 200 * distFrac ) ) + + draw.SimpleText( name, "q_char_hud_name", 0, 0, Color( 245, 245, 245, 255 * distFrac ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) + if( isServerMasterOnDuty ) then draw.SimpleText( "", "q_char_hud_name", 0, txtPadding, Color( 100, 150, 245, 255 * distFrac ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) end