diff --git a/garrysmod/lua/menu/problems/problem_lua.lua b/garrysmod/lua/menu/problems/problem_lua.lua index ea8a895846..7175e10ed0 100644 --- a/garrysmod/lua/menu/problems/problem_lua.lua +++ b/garrysmod/lua/menu/problems/problem_lua.lua @@ -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 @@ -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 diff --git a/garrysmod/lua/menu/problems/problems.lua b/garrysmod/lua/menu/problems/problems.lua index 73cff6e387..6ba853e045 100644 --- a/garrysmod/lua/menu/problems/problems.lua +++ b/garrysmod/lua/menu/problems/problems.lua @@ -1,4 +1,3 @@ - include( "problems_pnl.lua" ) local ProblemsPanel diff --git a/garrysmod/lua/menu/problems/problems_pnl.lua b/garrysmod/lua/menu/problems/problems_pnl.lua index c314368c8a..20396f66c0 100644 --- a/garrysmod/lua/menu/problems/problems_pnl.lua +++ b/garrysmod/lua/menu/problems/problems_pnl.lua @@ -6,7 +6,7 @@ include( "permissions.lua" ) local PANEL = {} function PANEL:Init() - + self:SetText( "" ) self:SetSize( ScrW(), ScrH() ) self:MakePopup() @@ -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" ) @@ -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 @@ -126,4 +142,4 @@ function PANEL:ReceivedProblem( uid, prob ) end -vgui.Register( "ProblemsPanel", PANEL, "EditablePanel" ) +vgui.Register( "ProblemsPanel", PANEL, "DButton" )