Skip to content

Improving the problems menu #2261

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

Open
wants to merge 9 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
29 changes: 16 additions & 13 deletions garrysmod/lua/menu/problems/problem_lua.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,7 @@ function PANEL:Paint( w, h )

-- The error count
if ( count > 0 ) then
local txt = "x" .. count
surface.SetFont( "DermaMedium" )
local tW, tH = surface.GetTextSize( txt )
tW = tW

draw.SimpleText( txt, "DermaMedium", w - 16 - 16, h / 2, clr, draw.TEXT_ALIGN_RIGHT, draw.TEXT_ALIGN_CENTER )
draw.SimpleText( "x" .. count, "DermaMedium", w - 16 - 16, h / 2, clr, draw.TEXT_ALIGN_RIGHT, draw.TEXT_ALIGN_CENTER )
end

-- The error
Expand Down Expand Up @@ -269,15 +264,23 @@ function PANEL:ReceivedError( uid, err )
pnl:Setup( err )

if ( shouldSort ) then
local sorted = {}
for gid, epnl in pairs( self.ErrorPanels ) do
sorted[ epnl.Problem.firstOccurence ] = epnl
local sortedPanels = {}
local count = 0

for _, panel in pairs( self.ErrorPanels ) do
count = count + 1
sortedPanels[ count ] = {
time = panel.Problem.firstOccurence,
panel = panel
}
end

local z = 0
for sort, spnl in SortedPairs( sorted ) do
spnl:SetZPos( z )
z = z + 1
table.sort( sortedPanels, function( a, b )
return a.time < b.time
end )

for i = 1, count do
sortedPanels[ i ].panel:SetZPos( i - 1 )
end
end

Expand Down
1 change: 0 additions & 1 deletion garrysmod/lua/menu/problems/problems.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

include( "problems_pnl.lua" )

local ProblemsPanel
Expand Down
22 changes: 19 additions & 3 deletions garrysmod/lua/menu/problems/problems_pnl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ include( "permissions.lua" )
local PANEL = {}

function PANEL:Init()

self:SetText( "" )
self:SetSize( ScrW(), ScrH() )
self:MakePopup()

Expand Down Expand Up @@ -48,6 +48,20 @@ function PANEL:Init()

end

function PANEL:DoClick()

self:Remove()

end

function PANEL:Think()

if ( input.IsKeyDown( KEY_ESCAPE ) and !IsInGame() ) then
self:Remove()
end

end

function PANEL:AddEmptyWarning( txt, parent )

local lab = parent:Add( "DLabel" )
Expand All @@ -66,9 +80,11 @@ function PANEL:AddEmptyWarning( txt, parent )

end

local color_background = Color( 0, 0, 0, 240 )

function PANEL:Paint( w, h )

draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 240 ) )
draw.RoundedBox( 0, 0, 0, w, h, color_background )

end

Expand Down Expand Up @@ -126,4 +142,4 @@ function PANEL:ReceivedProblem( uid, prob )

end

vgui.Register( "ProblemsPanel", PANEL, "EditablePanel" )
vgui.Register( "ProblemsPanel", PANEL, "DButton" )