From 51b90fefe5c06e55a00db25eb0e4d893d38159af Mon Sep 17 00:00:00 2001 From: AlmTech Software Date: Sun, 5 Jan 2020 00:11:51 +0100 Subject: [PATCH] Added custom voice active panels --- content/materials/quantum/mic_icon24.png | Bin 0 -> 311 bytes content/materials/quantum/mic_icon48.png | Bin 0 -> 599 bytes gamemode/engine/core/client/cl_fonts.lua | 2 +- gamemode/engine/core/client/cl_hud.lua | 119 +++++++++++++++-------- gamemode/init.lua | 3 + 5 files changed, 82 insertions(+), 42 deletions(-) create mode 100644 content/materials/quantum/mic_icon24.png create mode 100644 content/materials/quantum/mic_icon48.png diff --git a/content/materials/quantum/mic_icon24.png b/content/materials/quantum/mic_icon24.png new file mode 100644 index 0000000000000000000000000000000000000000..f6aad67c60f5f5ed9ce75297c5a05740fd1ad76e GIT binary patch literal 311 zcmV-70m%M|P)NJ7 zO#s-muhT(mUF-q71;AJQD4j^nB0t1QCD)DG&&Gh1(lp{x#K(xQDW!3&A0i${e5<=j z^#*s*)l=-Vc+Ew1RNy6QN814U_=tnoHFY;p^Nz#DfH-`GMHoEe6rK3aN}Vrov6XoV za*6qxLATT#=f5&9L3$WrQZk<47QH{2uYolla!c+0OWx~8eFLYnGOd?dXwv`y002ov JPDHLkV1iYygjN6m literal 0 HcmV?d00001 diff --git a/content/materials/quantum/mic_icon48.png b/content/materials/quantum/mic_icon48.png new file mode 100644 index 0000000000000000000000000000000000000000..cec011a9119d7879cac4bae4db743bc5415b31a6 GIT binary patch literal 599 zcmV-d0;v6oP)CHFQ8;g`ZG)^A7I_3k=~^MfhQ&e=2Hw>!H#vu2S< zq*Q=@;4QENbX?m37J>fI`mP120Zp!EAE<@a>BU|7>%^x`+`T*DrcGWJLhH={?25=$ zV92#^(zhL2Zw8<(B8O6a!_xP+tZ|dF3ISXyoFqw+{+rTMMv;(21EGlqLK6*yCK?D$ zG!UBH20V+k0ZHjd{-wp7+|G)m6``YX&WsaY~FKK zm%6C8;;A=Rre+ZS_XViuIKS?hHn^H2m5NV^ zc*(^tL**R!2)qHtfJd&4xnrNmKCrl2Q@0{MW#R?U@`x!)3z)oB@hKBefb}lKZ;)f! zRc#^xUITjtgzvd?x_(`j`o0Aw%xv1sCM~;sSTnOtGh0uRi)zj4`)Ac lSBVBfbMFmAB9TZ~{sY4Ipz-B^6O;e|002ovPDHLkV1g1p50wA_ literal 0 HcmV?d00001 diff --git a/gamemode/engine/core/client/cl_fonts.lua b/gamemode/engine/core/client/cl_fonts.lua index 8dac180..ccb50e0 100644 --- a/gamemode/engine/core/client/cl_fonts.lua +++ b/gamemode/engine/core/client/cl_fonts.lua @@ -153,6 +153,6 @@ surface.CreateFont( "q_item_hud_soulbound", { surface.CreateFont( "q_char_hud_name", { font = "Cambria", - size = 28 * Quantum.Client.ResolutionScale, + size = 40 * Quantum.Client.ResolutionScale, antialias = true }) \ No newline at end of file diff --git a/gamemode/engine/core/client/cl_hud.lua b/gamemode/engine/core/client/cl_hud.lua index f075bbb..4230128 100644 --- a/gamemode/engine/core/client/cl_hud.lua +++ b/gamemode/engine/core/client/cl_hud.lua @@ -11,7 +11,7 @@ local enabledHUDs = { } hook.Add( "HUDShouldDraw", "Quantum_RemoveDefualtHUD", function( hudid ) - return enabledHUDs[hudid] ~= nil + return enabledHUDs[hudid] == true end) local scale = Quantum.Client.ResolutionScale @@ -55,6 +55,7 @@ end local function renderItemInfoHUD() local trace = LocalPlayer():GetEyeTraceNoCursor() local entsNear = ents.FindInSphere( LocalPlayer():GetPos(), Quantum.ItemInfoDisplayMaxDistance ) + local txtPadding = 24 * scale for i, ent in pairs( entsNear ) do if( ent:GetClass() == "q_item" ) then @@ -70,7 +71,6 @@ local function renderItemInfoHUD() local screenPos = pos:ToScreen() - local txtPadding = 20 * scale local itemAmountTxt = "" if( amount > 1 ) then itemAmountTxt = amount .. "x " end @@ -87,13 +87,9 @@ local function renderItemInfoHUD() end end -local handle - -local function renderCharNamesHUD() - local trace = LocalPlayer():GetEyeTraceNoCursor() - - +local function renderCharNamesHUD3D2D() local entsNear = ents.FindInSphere( LocalPlayer():GetPos(), Quantum.CharInfoDisplayDistance ) + local txtPadding = 32 * scale for i, ent in pairs( entsNear ) do if( ent:IsPlayer() && ent != LocalPlayer() ) then @@ -101,45 +97,87 @@ local function renderCharNamesHUD() local distFrac = Lerp( distance/Quantum.CharInfoDisplayDistance, 1, 0 ) if( distance <= Quantum.CharInfoDisplayDistance ) then - handle = util.GetPixelVisibleHandle() - local pixelVis = util.PixelVisible( ent:GetPos(), 20, handle ) - print( ent:Nick(), pixelVis, ent:GetPos() ) - --if( util.PixelVisible( ent:GetPos(), 5, handle ) > 0 ) then - local name = ent:GetNWString( "q_char_name" ) - local pos = ent:GetPos() - pos.z = pos.z + 75 - - local screenPos = pos:ToScreen() - - local txtPadding = 20 * scale - local alphaFrac = distFrac + local name = ent:GetNWString( "q_char_name" ) + local pos = ent:GetPos() + pos.z = pos.z + 75 + + local ang = ent:GetAngles() + ang:RotateAroundAxis( ang:Forward(), 90 ) + + ang.y = LocalPlayer():EyeAngles().y - 90 + + local isServerMasterOnDuty = ent:GetNWBool( "q_servermaster_onduty" ) + if( isServerMasterOnDuty ) then pos.z = pos.z + 4 end - - draw.SimpleText( name, "q_char_hud_name", screenPos.x, screenPos.y, Color( 225, 225, 225, 255 * distFrac ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) - --end + 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 ) + + if( isServerMasterOnDuty ) then + draw.SimpleText( "", "q_char_hud_name", 0, txtPadding, Color( 100, 150, 245, 255 * distFrac ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) + end + cam.End3D2D() end end end +end - -- local ent = trace.Entity - -- if( ent:IsPlayer() ) then - -- local distance = LocalPlayer():GetPos():Distance( ent:GetPos() ) - -- local distFrac = Lerp( distance/Quantum.CharInfoDisplayDistance, 1, 0 ) - - -- if( distance <= Quantum.CharInfoDisplayDistance ) then - -- local name = ent:GetNWString( "q_char_name" ) - -- local pos = ent:GetPos() - -- pos.z = pos.z + 20 - - -- local screenPos = pos:ToScreen() +hook.Add( "PostDrawOpaqueRenderables", "Quantum_HUD_PlayerNames", function() + renderCharNamesHUD3D2D() +end) - -- local txtPadding = 20 * scale - -- local alphaFrac = distFrac - +local function createTalkingPanel() + local mat = "materials/quantum/mic_icon48.png" + + local icon = vgui.Create( "Material" ) + icon:SetSize( 48 * scale, 48 * scale ) + icon.w, icon.h = icon:GetSize() + icon:SetPos( ( sw - icon.w ) - padding*25, sh*0.65 - icon.h/2 ) + icon:SetMaterial( mat ) + + icon.frac = 0 + icon.fadein = true + icon.startTime = CurTime() + local intervall = 1.25 + local midIntervall = 0.2 + + icon.Think = function( self ) + if( icon.fadein ) then + if( self.startTime == nil ) then self.startTime = CurTime() end + self.frac = Lerp( (CurTime() - self.startTime ) / intervall, 0, 1 ) + self:SetAlpha( math.Clamp( 255 * self.frac, 5, 255 ) ) + if( self.frac >= 1 ) then + self.fadein = false + self.startTime = nil + self.frac = 1 + end + else + if( self.startTime == nil ) then self.startTime = CurTime() end + self.frac = Lerp( (CurTime() - self.startTime ) / intervall, 1, 0 ) + self:SetAlpha( math.Clamp( 255 * self.frac, 5, 255 ) ) + if( self.frac <= 0 ) then + self.fadein = true + self.startTime = nil + self.frac = 1 + end + end + end - -- draw.SimpleText( name, "q_char_hud_name", screenPos.x, screenPos.y, Color( 225, 225, 225, 255 * distFrac ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) - -- end - -- end + return icon +end + +function GM:PlayerStartVoice( cl ) -- replace the ugly voice panel + if( cl == LocalPlayer() ) then + cl.talkicon = createTalkingPanel() + end + return +end + +function GM:PlayerEndVoice( cl ) + if( cl == LocalPlayer() ) then + if( IsValid( cl.talkicon ) ) then + cl.talkicon:Remove() + end + end end local showRarities = { @@ -177,7 +215,6 @@ function GM:HUDPaint() if( LocalPlayer():Alive() ) then renderStatHUD() renderItemInfoHUD() - renderCharNamesHUD() end end end diff --git a/gamemode/init.lua b/gamemode/init.lua index 292eab5..5b62f61 100644 --- a/gamemode/init.lua +++ b/gamemode/init.lua @@ -16,6 +16,9 @@ if SERVER then local path = "gamemodes/" .. GM.FolderName .. "/gamemode/content/materials/quantum/server_banner.png" resource.AddSingleFile( path ) + resource.AddSingleFile( "materials/quantum/mic_icon48.png" ) -- add the mic icon + resource.AddSingleFile( "materials/quantum/mic_icon24.png" ) + include( "shared.lua" ) -- Quantum.Server = {}