diff --git a/lua/easychat/client/vgui/chatbox_panel.lua b/lua/easychat/client/vgui/chatbox_panel.lua index 743671f..52e9a8c 100644 --- a/lua/easychat/client/vgui/chatbox_panel.lua +++ b/lua/easychat/client/vgui/chatbox_panel.lua @@ -205,7 +205,10 @@ local CHATBOX = { self.BtnMaxim:SetTextColor(EasyChat.TextColor) --Color(125, 125, 125)) EasyChat.BlurPanel(self, 6, 0, -13, -5) + self:NoClipping(true) self.Paint = function(self, w, h) + hook.Run( 'ECChatboxPaint', self, w, h ) + surface_SetDrawColor(EasyChat.OutlayColor) surface_DrawRect(6, 0, w - 13, 28) surface_SetDrawColor(EasyChat.OutlayOutlineColor) diff --git a/lua/easychat/modules/client/local_ui.lua b/lua/easychat/modules/client/local_ui.lua index ebad6db..5551575 100644 --- a/lua/easychat/modules/client/local_ui.lua +++ b/lua/easychat/modules/client/local_ui.lua @@ -17,9 +17,18 @@ function panel:Think() end panel:SetWide(150) +panel:SetZPos(-32768) +panel:SetPaintedManually(true) panel.old_paint = panel.Paint local panel_title = "Message Receivers" local ec_cvar_dist = GetConVar("easychat_local_msg_distance") +local horizontal_padding = 15 +local vertical_padding = 5 + +hook.Add( "ECChatboxPaint", "LocalUI", function( chatbox, w, h ) + panel:PaintManual() +end ) + function panel:Paint(w, h) if not EasyChat.IsOpened() then return end if EasyChat.GetActiveTab().Name ~= "Global" then return end @@ -36,30 +45,35 @@ function panel:Paint(w, h) surface.SetFont("EasyChatFont") local tw, th = surface.GetTextSize(panel_title) - surface.SetTextPos(w / 2 - tw / 2, 5) + surface.SetTextPos(w / 2 - tw / 2, vertical_padding) surface.SetTextColor(EasyChat.TextColor) surface.DrawText(panel_title) + local me = LocalPlayer() + local my_pos = me:GetPos() + local range = ec_cvar_dist:GetInt() + local range2 = range * range local i = 1 - for _, ply in pairs(player.GetAll()) do - if ply ~= LocalPlayer() and ply:GetPos():Distance(LocalPlayer():GetPos()) <= ec_cvar_dist:GetInt() then - self:SetTall(5 + (20 * (i + 1))) + for _, ply in pairs(player.GetAll()) do + if ply ~= me and ply:GetPos():DistToSqr(my_pos) <= range2 then ec_markup.CachePlayer("LocalUI", ply, function() return ec_markup.AdvancedParse(ply:RichNick(), { nick = true, default_font = "EasyChatFont", default_color = team.GetColor(ply:Team()), }) - end):Draw(15, 5 + (20 * i)) + end):Draw(horizontal_padding, vertical_padding + i * th) i = i + 1 end end - if i == 1 then - self:SetTall(5 + th + 5) - end + self:SetTall(vertical_padding * 2 + th * i) +end + +if EasyChat and EasyChat.GUI and IsValid(EasyChat.GUI.LocalPanel) then + EasyChat.GUI.LocalPanel:Remove() end EasyChat.GUI.LocalPanel = panel