Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render local UI within chatbox so it always has the same Z pos as the chatbox #134

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lua/easychat/client/vgui/chatbox_panel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
30 changes: 22 additions & 8 deletions lua/easychat/modules/client/local_ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,18 @@ function panel:Think()
end

panel:SetWide(150)
panel:SetZPos(-32768)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this particular Z index?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minimal value

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont get why you need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make panel's hitbox not overlap with anything

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unnecessarily high value. This will suffice.

Suggested change
panel:SetZPos(-32768)
panel:SetZPos(-5)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is that why is there a need to change the z index of this panel in particular, what is it overlapping that it should be underneath everything?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess they encountered a bug it overlaps with another UI layer but I find it highly implausible to happen in normal use.

Copy link
Contributor Author

@AokiAreAoki AokiAreAoki Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole point of this PR was to make message receivers panel to be rendered together with the chatbox on the same level, but the message receivers panel itself should not prevent other panels from being clickable + the panel has nothing to click so there's no point in it being clickable and moreover preventing any other panels from being clicked.

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
Expand All @@ -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
Expand Down