mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 21:53:46 +03:00
Upload
This commit is contained in:
241
lua/menu/problems/permissions.lua
Normal file
241
lua/menu/problems/permissions.lua
Normal file
@@ -0,0 +1,241 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
local PANEL = {}
|
||||
|
||||
function PANEL:Init()
|
||||
|
||||
self:Dock( TOP )
|
||||
self:DockMargin( 0, 0, 0, 1 )
|
||||
|
||||
self.RemoveBtn = self:Add( "DImageButton" )
|
||||
self.RemoveBtn:SetImage( "icon16/cross.png" )
|
||||
self.RemoveBtn:SetSize( 16, 16 )
|
||||
self.RemoveBtn.DoClick = function( btm )
|
||||
if ( !self.Permission ) then return end
|
||||
|
||||
permissions.Revoke( self.Permission, self:GetParent():GetParent().Title )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local textPaddingX = 5
|
||||
local textPaddingY = 5
|
||||
local buttonPad = 8
|
||||
|
||||
-- lua_run_cl permissions.AskToConnect( "da" )
|
||||
function PANEL:PerformLayout( w, h )
|
||||
|
||||
local txt = "<font=DermaLarge>" .. language.GetPhrase( "permission." .. self.Permission ) .. ( self.IsTemporary and " <color=255,128,0>(TEMPORARY)</color>" or "" ) .. "</font>\n <font=DermaDefault>" .. language.GetPhrase( "permission." .. self.Permission .. ".help" ) .. "</font>"
|
||||
self.Markup = markup.Parse( txt, self:GetWide() - self.RemoveBtn:GetWide() - buttonPad * 2 - textPaddingX * 2 )
|
||||
|
||||
self:SetTall( textPaddingY + self.Markup:GetHeight() + textPaddingY )
|
||||
|
||||
local bW, bH = self.RemoveBtn:GetSize()
|
||||
self.RemoveBtn:SetPos( w - bW - buttonPad, self:GetTall() / 2 - bH / 2 )
|
||||
|
||||
end
|
||||
|
||||
local bgClr = Color( 75, 75, 75, 255 )
|
||||
function PANEL:Paint( w, h )
|
||||
|
||||
bgClr.a = self:GetAlpha()
|
||||
draw.RoundedBox( 0, 0, 0, w, h, bgClr )
|
||||
|
||||
-- No info yet
|
||||
if ( !self.Permission ) then return end
|
||||
|
||||
-- The error
|
||||
self.Markup:Draw( textPaddingX, textPaddingY, nil, nil, self:GetAlpha() )
|
||||
|
||||
end
|
||||
|
||||
function PANEL:Think()
|
||||
end
|
||||
|
||||
function PANEL:SetPermission( perm, temp )
|
||||
|
||||
self.Permission = perm
|
||||
self.IsTemporary = temp
|
||||
|
||||
self:InvalidateLayout( true )
|
||||
|
||||
end
|
||||
|
||||
vgui.Register( "Permission", PANEL, "Panel" )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local PANEL = {}
|
||||
|
||||
local arrowMat = Material( "gui/point.png" )
|
||||
local collapsedCache = {}
|
||||
|
||||
function PANEL:Init()
|
||||
|
||||
self:Dock( TOP )
|
||||
self:SetTall( 20 )
|
||||
self:DockMargin( 0, 0, 0, 5 )
|
||||
|
||||
self.PermissionPanels = {}
|
||||
|
||||
self.PermissionList = self:Add( "Panel" )
|
||||
|
||||
self.Collapsed = false
|
||||
|
||||
end
|
||||
|
||||
local white = Color( 255, 255, 255, 255 )
|
||||
local bg = Color( 50, 50, 50, 255 )
|
||||
function PANEL:Paint( w, h )
|
||||
|
||||
white.a = self:GetAlpha()
|
||||
bg.a = self:GetAlpha()
|
||||
|
||||
draw.RoundedBox( 4, 0, 0, w, h, bg )
|
||||
draw.SimpleText( self.Title, "DermaLarge", 4, 2, white, draw.TEXT_ALIGN_LEFT, draw.TEXT_ALIGN_TOP )
|
||||
|
||||
surface.SetMaterial( arrowMat )
|
||||
surface.SetDrawColor( white )
|
||||
surface.DrawTexturedRectRotated( w - 20, 20, 20, 20, self.Collapsed and 180 or 0 )
|
||||
|
||||
end
|
||||
|
||||
function PANEL:OnMousePressed()
|
||||
|
||||
self.Collapsed = !self.Collapsed
|
||||
self:InvalidateLayout()
|
||||
|
||||
collapsedCache[ self.Title ] = self.Collapsed
|
||||
|
||||
end
|
||||
|
||||
function PANEL:SetGroup( groupID )
|
||||
|
||||
self.Title = groupID
|
||||
|
||||
end
|
||||
|
||||
function PANEL:PerformLayout( w, h )
|
||||
|
||||
self.PermissionList:InvalidateLayout( true )
|
||||
self.PermissionList:SizeToChildren( false, true )
|
||||
|
||||
surface.SetFont( "DermaLarge" )
|
||||
local _, headerSize = surface.GetTextSize( self.Title )
|
||||
|
||||
self.PermissionList:SetPos( 4, 4 + headerSize )
|
||||
self.PermissionList:SetWide( self:GetWide() - 8 )
|
||||
|
||||
if ( self.Collapsed ) then
|
||||
self:SetTall( headerSize + 5 )
|
||||
return
|
||||
end
|
||||
|
||||
self:SetTall( self.PermissionList:GetTall() + ( 8 + headerSize ) )
|
||||
|
||||
end
|
||||
|
||||
function PANEL:ReceivePerm( perm, temp )
|
||||
local pnl = self.PermissionPanels[ perm ]
|
||||
|
||||
if ( !IsValid( pnl ) ) then
|
||||
pnl = self.PermissionList:Add( "Permission" )
|
||||
self.PermissionPanels[ perm ] = pnl
|
||||
self:InvalidateLayout()
|
||||
end
|
||||
|
||||
pnl:SetPermission( perm, temp )
|
||||
end
|
||||
|
||||
function PANEL:ReceivePerms( perms, temp )
|
||||
|
||||
for id, str in pairs( string.Explode( ",", perms ) ) do
|
||||
self:ReceivePerm( str, temp )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
vgui.Register( "ServerPermissionsPanel", PANEL, "Panel" )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local PANEL = {}
|
||||
local g_Permissions = nil
|
||||
|
||||
function PANEL:Init()
|
||||
|
||||
self.ServerPanels = {}
|
||||
|
||||
self:DoPermissions()
|
||||
|
||||
g_Permissions = self
|
||||
|
||||
end
|
||||
|
||||
function PANEL:AddServerGroup( address, perms, temp )
|
||||
local pnl = self.ServerPanels[ address ]
|
||||
|
||||
if ( !IsValid( pnl ) ) then
|
||||
pnl = self:Add( "ServerPermissionsPanel" )
|
||||
pnl:SetGroup( address )
|
||||
self.ServerPanels[ address ] = pnl
|
||||
|
||||
self:InvalidateLayout()
|
||||
end
|
||||
|
||||
pnl:ReceivePerms( perms, temp )
|
||||
end
|
||||
|
||||
function PANEL:DoPermissions()
|
||||
|
||||
for id, pnl in pairs( self.ServerPanels ) do
|
||||
pnl:Remove()
|
||||
end
|
||||
|
||||
local perms = permissions.GetAll()
|
||||
for address, perm in pairs( perms.temporary ) do
|
||||
self:AddServerGroup( address, perm, true )
|
||||
end
|
||||
for address, perm in pairs( perms.permanent ) do
|
||||
self:AddServerGroup( address, perm )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function PANEL:Think()
|
||||
|
||||
if ( self:GetCanvas():ChildCount() < 1 and !IsValid( self.NoPermissionsLabel ) ) then
|
||||
self.NoPermissionsLabel = self.ParentFrame:AddEmptyWarning( "#permissions.none", self )
|
||||
elseif ( self:GetCanvas():ChildCount() > 1 and IsValid( self.NoPermissionsLabel ) ) then
|
||||
self.NoPermissionsLabel:Remove()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
vgui.Register( "PermissionViewer", PANEL, "DScrollPanel" )
|
||||
|
||||
hook.Add( "OnPermissionsChanged", "OnPermissionsChanged", function()
|
||||
|
||||
if ( IsValid( g_Permissions ) ) then
|
||||
g_Permissions:DoPermissions()
|
||||
end
|
||||
|
||||
end )
|
||||
|
||||
204
lua/menu/problems/problem_generic.lua
Normal file
204
lua/menu/problems/problem_generic.lua
Normal file
@@ -0,0 +1,204 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
local PANEL = {}
|
||||
|
||||
function PANEL:Init()
|
||||
|
||||
self:Dock( TOP )
|
||||
self:DockMargin( 0, 0, 0, 1 )
|
||||
|
||||
self.CopyBtn = self:Add( "DImageButton" )
|
||||
self.CopyBtn:SetImage( "icon16/page_copy.png" )
|
||||
self.CopyBtn:SetSize( 16, 16 )
|
||||
self.CopyBtn.DoClick = function( btm )
|
||||
if ( !self.Problem ) then return end
|
||||
|
||||
SetClipboardText( language.GetPhrase( self.Problem.text ) )
|
||||
end
|
||||
|
||||
self.FixBtn = self:Add( "DButton" )
|
||||
self.FixBtn.DoClick = function( btm )
|
||||
if ( !self.Problem or !self.Problem.fix ) then return end
|
||||
|
||||
self.Problem.fix()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local severityWidth = 8
|
||||
local severityOffset = severityWidth + 4
|
||||
local textPaddingX = 5
|
||||
local textPaddingY = 10
|
||||
local copyIconPad = 8
|
||||
|
||||
local severityColors = {}
|
||||
severityColors[ 0 ] = Color( 217, 217, 217 )
|
||||
severityColors[ 1 ] = Color( 255, 200, 0 )
|
||||
severityColors[ 2 ] = Color( 255, 64, 0 )
|
||||
|
||||
function PANEL:PerformLayout( w, h )
|
||||
|
||||
self.Markup = markup.Parse( "<font=DermaDefault>" .. language.GetPhrase( self.Problem.text ) .. "</font>", w - self.CopyBtn:GetWide() - copyIconPad * 2 - severityOffset - textPaddingX * 2 )
|
||||
|
||||
local targetH = textPaddingY
|
||||
|
||||
if ( self.Problem ) then
|
||||
targetH = targetH + self.Markup:GetHeight() + textPaddingY
|
||||
end
|
||||
|
||||
local fixW, fixH = self.FixBtn:GetSize()
|
||||
self.FixBtn:SetPos( textPaddingX + severityOffset, targetH )
|
||||
targetH = targetH + fixH + textPaddingY
|
||||
|
||||
self:SetTall( targetH )
|
||||
|
||||
local bW, bH = self.CopyBtn:GetSize()
|
||||
self.CopyBtn:SetPos( w - bW - copyIconPad, targetH / 2 - bH / 2 )
|
||||
|
||||
end
|
||||
|
||||
local bgClr = Color( 75, 75, 75, 255 )
|
||||
function PANEL:Paint( w, h )
|
||||
|
||||
bgClr.a = self:GetAlpha()
|
||||
|
||||
-- No info yet
|
||||
if ( !self.Problem ) then
|
||||
draw.RoundedBox( 0, 0, 0, w, h, bgClr )
|
||||
return
|
||||
end
|
||||
|
||||
-- Background
|
||||
local bgClrH = bgClr
|
||||
if ( self.Problem.lastOccurence ) then
|
||||
local add = 75 + math.max( 25 - ( SysTime() - self.Problem.lastOccurence ) * 25, 0 )
|
||||
bgClrH = Color( add, add, add, self:GetAlpha() )
|
||||
end
|
||||
|
||||
draw.RoundedBox( 0, 0, 0, w, h, bgClrH )
|
||||
|
||||
-- Severity indicator
|
||||
local color = severityColors[ self.Problem.severity ]
|
||||
if ( color == nil ) then color = severityColors[ 0 ] end
|
||||
draw.RoundedBox( 0, 0, 0, severityWidth, h, color )
|
||||
|
||||
-- The error
|
||||
self.Markup:Draw( textPaddingX + severityOffset, textPaddingY, nil, nil, self:GetAlpha() )
|
||||
|
||||
end
|
||||
|
||||
function PANEL:Think()
|
||||
end
|
||||
|
||||
function PANEL:Setup( problem )
|
||||
|
||||
self.Problem = problem
|
||||
|
||||
self.Markup = markup.Parse( "<font=DermaDefault>" .. language.GetPhrase( self.Problem.text ) .. "</font>", self:GetWide() - self.CopyBtn:GetWide() - copyIconPad * 2 - severityOffset - textPaddingX * 2 )
|
||||
|
||||
self.FixBtn:SetEnabled( problem.fix != nil )
|
||||
self.FixBtn:SetText( problem.fix and "#problems.quick_fix" or "#problems.no_quick_fix" )
|
||||
self.FixBtn:SizeToContentsX( 10 )
|
||||
|
||||
end
|
||||
|
||||
vgui.Register( "GenericProblem", PANEL, "Panel" )
|
||||
|
||||
--[[
|
||||
ProblemGroup
|
||||
]]
|
||||
|
||||
local PANEL = {}
|
||||
|
||||
local arrowMat = Material( "gui/point.png" )
|
||||
local collapsedCache = {}
|
||||
|
||||
function PANEL:Init()
|
||||
|
||||
self:Dock( TOP )
|
||||
self:SetTall( 20 )
|
||||
self:DockMargin( 0, 0, 0, 5 )
|
||||
|
||||
self.ProblemPanels = {}
|
||||
|
||||
self.ProblemList = self:Add( "Panel" )
|
||||
|
||||
self.Collapsed = false
|
||||
|
||||
end
|
||||
|
||||
local white = Color( 255, 255, 255, 255 )
|
||||
local bg = Color( 50, 50, 50, 255 )
|
||||
function PANEL:Paint( w, h )
|
||||
|
||||
white.a = self:GetAlpha()
|
||||
bg.a = self:GetAlpha()
|
||||
|
||||
draw.RoundedBox( 4, 0, 0, w, h, bg )
|
||||
draw.SimpleText( language.GetPhrase( "problem_grp." .. self.Title ), "DermaLarge", 4, 2, white, draw.TEXT_ALIGN_LEFT, draw.TEXT_ALIGN_TOP )
|
||||
|
||||
surface.SetMaterial( arrowMat )
|
||||
surface.SetDrawColor( white )
|
||||
surface.DrawTexturedRectRotated( w - 20, 20, 20, 20, self.Collapsed and 180 or 0 )
|
||||
|
||||
end
|
||||
|
||||
function PANEL:OnMousePressed()
|
||||
|
||||
self.Collapsed = !self.Collapsed
|
||||
self:InvalidateLayout()
|
||||
|
||||
collapsedCache[ self.Title ] = self.Collapsed
|
||||
|
||||
end
|
||||
|
||||
function PANEL:SetGroup( groupID )
|
||||
|
||||
self.Title = groupID
|
||||
|
||||
end
|
||||
|
||||
function PANEL:PerformLayout( w, h )
|
||||
|
||||
self.ProblemList:InvalidateLayout( true )
|
||||
self.ProblemList:SizeToChildren( false, true )
|
||||
|
||||
surface.SetFont( "DermaLarge" )
|
||||
local _, headerSize = surface.GetTextSize( self.Title )
|
||||
|
||||
self.ProblemList:SetPos( 4, 4 + headerSize )
|
||||
self.ProblemList:SetWide( self:GetWide() - 8 )
|
||||
|
||||
if ( self.Collapsed ) then
|
||||
self:SetTall( headerSize + 5 )
|
||||
return
|
||||
end
|
||||
|
||||
self:SetTall( self.ProblemList:GetTall() + ( 8 + headerSize ) )
|
||||
|
||||
end
|
||||
|
||||
function PANEL:ReceivedProblem( uid, prob )
|
||||
|
||||
local pnl = self.ProblemPanels[ uid ]
|
||||
|
||||
if ( !IsValid( pnl ) ) then
|
||||
pnl = self.ProblemList:Add( "GenericProblem" )
|
||||
self.ProblemPanels[ uid ] = pnl
|
||||
self:InvalidateLayout()
|
||||
end
|
||||
|
||||
pnl:Setup( prob )
|
||||
|
||||
end
|
||||
|
||||
vgui.Register( "GenericProblemGroup", PANEL, "Panel" )
|
||||
296
lua/menu/problems/problem_lua.lua
Normal file
296
lua/menu/problems/problem_lua.lua
Normal file
@@ -0,0 +1,296 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
local realmColors = {}
|
||||
realmColors[ "menu" ] = Color( 121, 221, 100 )
|
||||
realmColors[ "client" ] = Color( 255, 222, 102 )
|
||||
realmColors[ "server" ] = Color( 137, 222, 255 )
|
||||
|
||||
surface.CreateFont( "DermaMedium", {
|
||||
font = "Roboto",
|
||||
size = 24,
|
||||
weight = 500
|
||||
} )
|
||||
|
||||
local PANEL = {}
|
||||
|
||||
function PANEL:Init()
|
||||
|
||||
self:Dock( TOP )
|
||||
self:DockMargin( 0, 0, 0, 1 )
|
||||
|
||||
self.CopyBtn = self:Add( "DImageButton" )
|
||||
self.CopyBtn:SetImage( "icon16/page_copy.png" )
|
||||
self.CopyBtn:SetSize( 16, 16 )
|
||||
self.CopyBtn.DoClick = function( btm )
|
||||
if ( !self.Problem ) then return end
|
||||
|
||||
local prepend = ""
|
||||
if ( self.Problem.title and self.Problem.title:len() > 0 and self.Problem.title != "Other" ) then prepend = "[" .. self.Problem.title .. "] " end
|
||||
SetClipboardText( prepend .. self.Problem.text )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function PANEL:PerformLayout( w, h )
|
||||
|
||||
surface.SetFont( "DermaDefault" )
|
||||
|
||||
if ( self.Problem ) then
|
||||
local _, th = surface.GetTextSize( self.Problem.text )
|
||||
self:SetTall( th + 10 )
|
||||
end
|
||||
|
||||
local bW, bH = self.CopyBtn:GetSize()
|
||||
self.CopyBtn:SetPos( w - bW - 8, h / 2 - bH / 2 )
|
||||
|
||||
end
|
||||
|
||||
local bgClr = Color( 75, 75, 75, 255 )
|
||||
local fgClr = Color( 255, 255, 255, 255 )
|
||||
function PANEL:Paint( w, h )
|
||||
|
||||
bgClr.a = self:GetAlpha()
|
||||
|
||||
-- No info yet
|
||||
if ( !self.Problem ) then
|
||||
draw.RoundedBox( 0, 0, 0, w, h, bgClr )
|
||||
return
|
||||
end
|
||||
|
||||
-- Get the colors
|
||||
local clr = table.Copy( realmColors[ self.Problem.realm ] or fgClr )
|
||||
clr.a = self:GetAlpha()
|
||||
|
||||
-- Background color
|
||||
local bgClrH = bgClr
|
||||
if ( self.Problem.lastOccurence ) then
|
||||
local add = 75 + math.max( 25 - ( SysTime() - self.Problem.lastOccurence ) * 25, 0 )
|
||||
bgClrH = Color( add, add, add, self:GetAlpha() )
|
||||
end
|
||||
|
||||
draw.RoundedBox( 0, 0, 0, w, h, bgClrH )
|
||||
|
||||
-- Draw background
|
||||
local count = 0
|
||||
if ( self.Problem and self.Problem.count ) then count = self.Problem.count end
|
||||
|
||||
-- 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 )
|
||||
end
|
||||
|
||||
-- The error
|
||||
draw.DrawText( self.Problem.text, "DermaDefault", 5, 5, clr )
|
||||
|
||||
end
|
||||
|
||||
function PANEL:Setup( problem )
|
||||
|
||||
self.Problem = problem
|
||||
|
||||
end
|
||||
|
||||
vgui.Register( "LuaProblem", PANEL, "Panel" )
|
||||
|
||||
--[[ ////////////////////////////////////////////////// GROUP ////////////////////////////////////////////////// ]] --
|
||||
|
||||
local PANEL = {}
|
||||
|
||||
local arrowMat = Material( "gui/point.png" )
|
||||
local collapsedCache = {}
|
||||
|
||||
function PANEL:Init()
|
||||
|
||||
self:Dock( TOP )
|
||||
self:SetTall( 20 )
|
||||
self:DockMargin( 0, 0, 0, 5 )
|
||||
|
||||
self.ErrorPanels = {}
|
||||
|
||||
self.LuaErrorList = self:Add( "Panel" )
|
||||
|
||||
self.ClearButton = self:Add( "DImageButton" )
|
||||
self.ClearButton:SetImage( "gui/cross.png" )
|
||||
self.ClearButton:SetSize( 18, 18 )
|
||||
self.ClearButton.DoClick = function( s ) self:ClearThisGroup() end
|
||||
|
||||
self.Collapsed = false
|
||||
|
||||
end
|
||||
|
||||
local white = Color( 255, 255, 255, 255 )
|
||||
local bg = Color( 50, 50, 50, 255 )
|
||||
function PANEL:Paint( w, h )
|
||||
|
||||
white.a = self:GetAlpha()
|
||||
bg.a = self:GetAlpha()
|
||||
|
||||
draw.RoundedBox( 4, 0, 0, w, h, bg )
|
||||
draw.SimpleText( self.Title, "DermaLarge", 4, 2, white, draw.TEXT_ALIGN_LEFT, draw.TEXT_ALIGN_TOP )
|
||||
|
||||
surface.SetMaterial( arrowMat )
|
||||
surface.SetDrawColor( white )
|
||||
surface.DrawTexturedRectRotated( w - 20, 18, 20, 12, self.Collapsed and 180 or 0 )
|
||||
|
||||
local h2 = self.LuaErrorList:GetTall()
|
||||
local _, lY = self.LuaErrorList:GetPos()
|
||||
|
||||
draw.DrawText( self:GetExplainerText(), "DermaDefault", w / 2, lY + h2 + 5, white, draw.TEXT_ALIGN_CENTER )
|
||||
|
||||
end
|
||||
|
||||
function PANEL:ClearThisGroup()
|
||||
|
||||
ClearLuaErrorGroup( self.GroupID )
|
||||
|
||||
end
|
||||
|
||||
function PANEL:OnMousePressed( code )
|
||||
|
||||
if ( code != MOUSE_LEFT ) then return end
|
||||
|
||||
self.Collapsed = !self.Collapsed
|
||||
self:InvalidateLayout()
|
||||
|
||||
collapsedCache[ self.Title ] = self.Collapsed
|
||||
|
||||
end
|
||||
|
||||
function PANEL:GetExplainerText()
|
||||
|
||||
if ( self.Title == "Other" and self.AddonID and self.AddonID:len() < 2 ) then
|
||||
return language.GetPhrase( "problems.generic_lua_error" )
|
||||
end
|
||||
|
||||
-- Not a workshop addon, or a floating .gma (WSID=0)
|
||||
if ( self.AddonID and self.AddonID:len() < 2 ) then
|
||||
return language.GetPhrase( "problems.addon_lua_error" ):format( self.Title )
|
||||
end
|
||||
|
||||
return language.GetPhrase( "problems.workshop_lua_error" ):format( self.Title )
|
||||
|
||||
end
|
||||
|
||||
function PANEL:SetTitleAndID( title, id, groupid )
|
||||
|
||||
self.Title = title
|
||||
self.AddonID = id
|
||||
self.GroupID = groupid
|
||||
|
||||
self.Collapsed = collapsedCache[ self.Title ]
|
||||
|
||||
if ( self.AddonID and self.AddonID:len() > 1 ) then
|
||||
self.DisableBtn = self:Add( "DButton" )
|
||||
self.DisableBtn:SetText( "#problems.disable" )
|
||||
self.DisableBtn:SizeToContentsX( 10 )
|
||||
self.DisableBtn.DoClick = function() steamworks.SetShouldMountAddon( self.AddonID, false ) steamworks.ApplyAddons() end
|
||||
|
||||
self.OpenWSBtn = self:Add( "DButton" )
|
||||
self.OpenWSBtn:SetText( "#problems.open_on_workshop" )
|
||||
self.OpenWSBtn:SizeToContentsX( 10 )
|
||||
self.OpenWSBtn.DoClick = function() steamworks.ViewFile( self.AddonID ) end
|
||||
|
||||
self.UninstallBtn = self:Add( "DButton" )
|
||||
self.UninstallBtn:SetText( "#problems.uninstall" )
|
||||
self.UninstallBtn:SizeToContentsX( 10 )
|
||||
self.UninstallBtn.DoClick = function() steamworks.Unsubscribe( self.AddonID ) end
|
||||
|
||||
local maxS = math.max( self.DisableBtn:GetWide(), self.OpenWSBtn:GetWide(), self.UninstallBtn:GetWide() )
|
||||
self.DisableBtn:SetWide( maxS )
|
||||
self.OpenWSBtn:SetWide( maxS )
|
||||
self.UninstallBtn:SetWide( maxS )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function PANEL:PerformLayout( w, h )
|
||||
|
||||
self.ClearButton:SetPos( w - 56, 9 )
|
||||
|
||||
self.LuaErrorList:InvalidateLayout( true )
|
||||
self.LuaErrorList:SizeToChildren( false, true )
|
||||
|
||||
surface.SetFont( "DermaLarge" )
|
||||
local _, headerSize = surface.GetTextSize( self.Title )
|
||||
|
||||
self.LuaErrorList:SetPos( 4, 4 + headerSize )
|
||||
self.LuaErrorList:SetWide( self:GetWide() - 8 )
|
||||
|
||||
|
||||
surface.SetFont( "DermaDefault" )
|
||||
local _, etH = surface.GetTextSize( self:GetExplainerText() )
|
||||
|
||||
if ( IsValid( self.DisableBtn ) ) then
|
||||
local h2 = self.LuaErrorList:GetTall()
|
||||
local _, lY = self.LuaErrorList:GetPos()
|
||||
local y = lY + h2 + 5 + etH + 5
|
||||
|
||||
self.OpenWSBtn:SetPos( w * 0.25 - self.OpenWSBtn:GetWide() / 2, y )
|
||||
self.DisableBtn:SetPos( w * 0.5 - self.DisableBtn:GetWide() / 2, y )
|
||||
self.UninstallBtn:SetPos( w * 0.75 - self.UninstallBtn:GetWide() / 2, y )
|
||||
etH = etH + self.DisableBtn:GetTall() + 5
|
||||
end
|
||||
|
||||
if ( self.Collapsed ) then
|
||||
self:SetTall( headerSize + 5 )
|
||||
return
|
||||
end
|
||||
|
||||
self:SetTall( self.LuaErrorList:GetTall() + ( 8 + headerSize ) + ( etH + 5 ) )
|
||||
|
||||
end
|
||||
|
||||
function PANEL:Think()
|
||||
|
||||
if ( IsValid( self.DisableBtn ) ) then
|
||||
self.DisableBtn:SetEnabled( steamworks.IsSubscribed( self.AddonID ) and steamworks.ShouldMountAddon( self.AddonID ) )
|
||||
self.UninstallBtn:SetEnabled( steamworks.IsSubscribed( self.AddonID ) )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function PANEL:ReceivedError( uid, err )
|
||||
|
||||
local pnl = self.ErrorPanels[ uid ]
|
||||
|
||||
local shouldSort = false
|
||||
if ( !IsValid( pnl ) ) then
|
||||
pnl = self.LuaErrorList:Add( "LuaProblem" )
|
||||
self.ErrorPanels[ uid ] = pnl
|
||||
self:InvalidateLayout()
|
||||
|
||||
shouldSort = true
|
||||
end
|
||||
|
||||
pnl:Setup( err )
|
||||
|
||||
if ( shouldSort ) then
|
||||
local sorted = {}
|
||||
for gid, epnl in pairs( self.ErrorPanels ) do
|
||||
sorted[ epnl.Problem.firstOccurence ] = epnl
|
||||
end
|
||||
|
||||
local z = 0
|
||||
for sort, spnl in SortedPairs( sorted ) do
|
||||
spnl:SetZPos( z )
|
||||
z = z + 1
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
vgui.Register( "LuaProblemGroup", PANEL, "Panel" )
|
||||
352
lua/menu/problems/problems.lua
Normal file
352
lua/menu/problems/problems.lua
Normal file
@@ -0,0 +1,352 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
include( "problems_pnl.lua" )
|
||||
|
||||
local ProblemsPanel
|
||||
local ProblemsCount = 0
|
||||
local ProblemSeverity = 0
|
||||
local MenuUpdated = false
|
||||
|
||||
Problems = Problems or {}
|
||||
ErrorLog = ErrorLog or {}
|
||||
|
||||
local function RefreshGenericProblemList()
|
||||
if ( IsValid( ProblemsPanel ) ) then
|
||||
ProblemsPanel.ProblemsList:Clear()
|
||||
ProblemsPanel.ProblemPanels = {}
|
||||
for id, prob in pairs( Problems ) do
|
||||
ProblemsPanel:ReceivedProblem( id, prob )
|
||||
end
|
||||
ProblemsPanel:InvalidateLayout()
|
||||
end
|
||||
end
|
||||
|
||||
local function RefreshLuaErrorList()
|
||||
if ( IsValid( ProblemsPanel ) ) then
|
||||
ProblemsPanel.LuaErrorList:Clear()
|
||||
ProblemsPanel.ErrorPanels = {}
|
||||
for id, err in pairs( ErrorLog ) do
|
||||
ProblemsPanel:ReceivedError( id, err )
|
||||
end
|
||||
ProblemsPanel:InvalidateLayout()
|
||||
end
|
||||
end
|
||||
|
||||
local function CountProblem( severity )
|
||||
|
||||
ProblemsCount = ProblemsCount + 1
|
||||
ProblemSeverity = math.max( ProblemSeverity, severity or 0 )
|
||||
|
||||
if ( IsValid( pnlMainMenu ) ) then
|
||||
pnlMainMenu:SetProblemCount( ProblemsCount, ProblemSeverity )
|
||||
MenuUpdated = true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local function RecountProblems()
|
||||
|
||||
ProblemsCount = 0
|
||||
ProblemSeverity = 0
|
||||
|
||||
for id, err in pairs( ErrorLog ) do
|
||||
ProblemsCount = ProblemsCount + 1
|
||||
ProblemSeverity = math.max( err.severity or 0, ProblemSeverity )
|
||||
end
|
||||
|
||||
for id, prob in pairs( Problems ) do
|
||||
ProblemsCount = ProblemsCount + 1
|
||||
ProblemSeverity = math.max( prob.severity or 0, ProblemSeverity )
|
||||
end
|
||||
|
||||
if ( IsValid( pnlMainMenu ) ) then
|
||||
pnlMainMenu:SetProblemCount( ProblemsCount, ProblemSeverity )
|
||||
MenuUpdated = true
|
||||
end
|
||||
end
|
||||
|
||||
timer.Create( "menu_problem_counter", 1, 0, function()
|
||||
if ( MenuUpdated ) then timer.Remove( "menu_problem_counter" ) return end
|
||||
|
||||
RecountProblems()
|
||||
end )
|
||||
|
||||
function ClearLuaErrorGroup( group_id )
|
||||
|
||||
-- pairs should guard us against changing the array we are looping through
|
||||
for id, err in pairs( ErrorLog ) do
|
||||
if ( err.type == group_id ) then
|
||||
ErrorLog[ id ] = nil
|
||||
end
|
||||
end
|
||||
|
||||
RecountProblems()
|
||||
|
||||
RefreshLuaErrorList()
|
||||
|
||||
end
|
||||
|
||||
function ClearProblem( id )
|
||||
|
||||
if ( !Problems[ id ] ) then return end
|
||||
|
||||
Problems[ id ] = nil
|
||||
|
||||
RecountProblems()
|
||||
|
||||
RefreshGenericProblemList()
|
||||
|
||||
end
|
||||
|
||||
function FireProblem( prob )
|
||||
|
||||
local probID = prob.id or prob.text
|
||||
|
||||
if ( !Problems[ probID ] ) then
|
||||
CountProblem( prob.severity )
|
||||
end
|
||||
|
||||
Problems[ probID ] = prob
|
||||
if ( IsValid( ProblemsPanel ) ) then ProblemsPanel:ReceivedProblem( probID, prob ) end
|
||||
|
||||
end
|
||||
|
||||
local function FireError( str, realm, stack, addontitle, addonid )
|
||||
|
||||
-- Reconstruct the stack trace
|
||||
local errorText = str
|
||||
errorText = string.Replace( errorText, "\t", ( " " ):rep( 12 ) ) -- Ew
|
||||
|
||||
for i, t in pairs( stack ) do
|
||||
if ( !t.Function or t.Function == "" ) then t.Function = "unknown" end
|
||||
|
||||
errorText = errorText .. "\n" .. (" "):rep( i ) .. i .. ". " .. t.Function .. " - " .. t.File .. ":" .. t.Line
|
||||
end
|
||||
|
||||
local errorUniqueID = errorText .. realm
|
||||
|
||||
if ( !addontitle or addontitle == "" ) then addontitle = "Other" end
|
||||
|
||||
if ( !ErrorLog[ errorUniqueID ] ) then
|
||||
local newErr = {
|
||||
text = errorText,
|
||||
realm = realm,
|
||||
addonid = addonid or "",
|
||||
title = addontitle,
|
||||
count = 1,
|
||||
severity = 1,
|
||||
lastOccurence = SysTime(),
|
||||
firstOccurence = SysTime()
|
||||
}
|
||||
newErr.type = newErr.title .. "-" .. newErr.addonid
|
||||
|
||||
CountProblem( newErr.severity )
|
||||
ErrorLog[ errorUniqueID ] = newErr
|
||||
else
|
||||
ErrorLog[ errorUniqueID ].count = ErrorLog[ errorUniqueID ].count + 1
|
||||
ErrorLog[ errorUniqueID ].lastOccurence = SysTime()
|
||||
end
|
||||
|
||||
if ( IsValid( ProblemsPanel ) ) then ProblemsPanel:ReceivedError( errorUniqueID, ErrorLog[ errorUniqueID ] ) end
|
||||
|
||||
end
|
||||
|
||||
hook.Add( "OnLuaError", "MenuErrorLogger", function( str, realm, stack, addontitle, addonid )
|
||||
|
||||
local good, err = pcall( function()
|
||||
FireError( str, realm, stack, addontitle, addonid )
|
||||
end )
|
||||
|
||||
if ( !good ) then
|
||||
print( "Failed to log a Lua error!\n", err)
|
||||
end
|
||||
|
||||
end )
|
||||
|
||||
function OpenProblemsPanel()
|
||||
|
||||
if ( IsValid( ProblemsPanel ) ) then ProblemsPanel:Remove() end
|
||||
|
||||
ProblemsPanel = vgui.Create( "ProblemsPanel" )
|
||||
|
||||
local anyErrors = false
|
||||
for id, err in pairs( table.Copy( ErrorLog ) ) do
|
||||
ProblemsPanel:ReceivedError( id, err )
|
||||
anyErrors = true
|
||||
end
|
||||
|
||||
for id, prob in pairs( Problems ) do
|
||||
ProblemsPanel:ReceivedProblem( id, prob )
|
||||
end
|
||||
|
||||
if ( !anyErrors ) then
|
||||
ProblemsPanel.Tabs:SwitchToName( "#problems.problems" )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Called from the engine to notify the player about a problem in a more user friendly way compared to a console message
|
||||
function FireProblemFromEngine( id, severity, params )
|
||||
if ( id == "menu_cleanupgmas" ) then
|
||||
local text = language.GetPhrase( "problem." .. id ) .. "\n\n" .. params:Replace( ";", "\n" )
|
||||
FireProblem( { id = id, text = text, severity = severity, type = "addons", fix = function() RunConsoleCommand( "menu_cleanupgmas" ) ClearProblem( id ) end } )
|
||||
elseif ( id == "readonly_file" ) then
|
||||
local text = params
|
||||
FireProblem( { id = id .. params, text = text, severity = severity, type = "config" } )
|
||||
else
|
||||
-- missing_addon_file
|
||||
-- addon_download_failed = title;reason
|
||||
local text = language.GetPhrase( "problem." .. id )
|
||||
text = text:format( unpack( string.Explode( ";", params ) ) )
|
||||
|
||||
FireProblem( { id = id .. params, text = text, severity = severity, type = "addons" } )
|
||||
end
|
||||
end
|
||||
|
||||
timer.Create( "menu_check_for_problems", 1, 0, function()
|
||||
|
||||
if ( math.floor( GetConVarNumber( "mat_hdr_level" ) ) != 2 ) then
|
||||
FireProblem( { id = "mat_hdr_level", text = "#problem.mat_hdr_level", type = "config", fix = function() RunConsoleCommand( "mat_hdr_level", "2" ) end, severity = 1 } )
|
||||
else
|
||||
ClearProblem( "mat_hdr_level" )
|
||||
end
|
||||
|
||||
if ( math.floor( math.abs( GetConVarNumber( "mat_bumpmap" ) ) ) == 0 ) then
|
||||
FireProblem( { id = "mat_bumpmap", text = "#problem.mat_bumpmap", type = "config", fix = function() RunConsoleCommand( "mat_bumpmap", "1" ) end } )
|
||||
else
|
||||
ClearProblem( "mat_bumpmap" )
|
||||
end
|
||||
|
||||
if ( math.floor( math.abs( GetConVarNumber( "mat_specular" ) ) ) == 0 ) then
|
||||
FireProblem( { id = "mat_specular", text = "#problem.mat_specular", type = "config", fix = function() RunConsoleCommand( "mat_specular", "1" ) end } )
|
||||
else
|
||||
ClearProblem( "mat_specular" )
|
||||
end
|
||||
|
||||
if ( math.floor( math.abs( GetConVarNumber( "gmod_mcore_test" ) ) ) != 0 ) then
|
||||
FireProblem( { id = "gmod_mcore_test", text = "#problem.gmod_mcore_test", type = "config" } )
|
||||
else
|
||||
ClearProblem( "gmod_mcore_test" )
|
||||
end
|
||||
|
||||
if ( math.abs( GetConVarNumber( "voice_fadeouttime" ) - 0.1 ) > 0.001 ) then
|
||||
FireProblem( { id = "voice_fadeouttime", text = "#problem.voice_fadeouttime", type = "config", fix = function() RunConsoleCommand( "voice_fadeouttime", "0.1" ) ClearProblem( "voice_fadeouttime" ) end } )
|
||||
else
|
||||
ClearProblem( "voice_fadeouttime" )
|
||||
end
|
||||
|
||||
if ( GetConVarNumber( "mat_viewportscale" ) < 0.1 ) then
|
||||
FireProblem( { id = "mat_viewportscale", text = "#problem.mat_viewportscale", type = "config", fix = function() RunConsoleCommand( "mat_viewportscale", "1" ) ClearProblem( "mat_viewportscale" ) end } )
|
||||
else
|
||||
ClearProblem( "mat_viewportscale" )
|
||||
end
|
||||
|
||||
if ( ScrW() < 1000 or ScrH() < 700 ) then
|
||||
FireProblem( { id = "screen_res", text = "#problem.screen_res", type = "config" } )
|
||||
else
|
||||
ClearProblem( "screen_res" )
|
||||
end
|
||||
|
||||
-- These are not saved, but still affect gameplay
|
||||
if ( GetConVarNumber( "cl_forwardspeed" ) != 10000 or GetConVarNumber( "cl_sidespeed" ) != 10000 or GetConVarNumber( "cl_backspeed" ) != 10000 ) then
|
||||
FireProblem( { id = "cl_speeds", text = "#problem.cl_speeds", type = "config", fix = function()
|
||||
RunConsoleCommand( "cl_forwardspeed", "10000" )
|
||||
RunConsoleCommand( "cl_sidespeed", "10000" )
|
||||
RunConsoleCommand( "cl_backspeed", "10000" )
|
||||
end } )
|
||||
else
|
||||
ClearProblem( "cl_speeds" )
|
||||
end
|
||||
|
||||
if ( render.GetDXLevel() != 95 and render.GetDXLevel() != 90 ) then
|
||||
FireProblem( { id = "mat_dxlevel", text = language.GetPhrase( "problem.mat_dxlevel" ):format( render.GetDXLevel() ), type = "config" } )
|
||||
else
|
||||
ClearProblem( "mat_dxlevel" )
|
||||
end
|
||||
|
||||
end )
|
||||
|
||||
-- Problems that we only need to check on startup
|
||||
if ( !render.SupportsHDR() ) then FireProblem( { text = "#problem.no_hdr", type = "hardware" } ) end
|
||||
if ( !render.SupportsPixelShaders_1_4() ) then FireProblem( { text = "#problem.no_ps14", type = "hardware" } ) end
|
||||
if ( !render.SupportsPixelShaders_2_0() ) then FireProblem( { text = "#problem.no_ps20", type = "hardware" } ) end
|
||||
if ( !render.SupportsVertexShaders_2_0() ) then FireProblem( { text = "#problem.no_vs20", type = "hardware" } ) end
|
||||
|
||||
|
||||
|
||||
local AddonConflicts = {}
|
||||
|
||||
hook.Add( "OnNotifyAddonConflict", "AddonConflictNotification", function( addon1, addon2, fileName )
|
||||
|
||||
local id = addon1 .. "vs" .. addon2
|
||||
local id1 = addon2 .. "vs" .. addon1
|
||||
if ( AddonConflicts[ id1 ] ) then id = id1 end
|
||||
|
||||
if ( AddonConflicts[ id ] == nil ) then
|
||||
AddonConflicts[ id ] = {
|
||||
addon1 = addon1,
|
||||
addon2 = addon2,
|
||||
files = {}
|
||||
}
|
||||
|
||||
steamworks.FileInfo( addon1, function( result )
|
||||
|
||||
if ( !result ) then return end
|
||||
|
||||
AddonConflicts[ id ].addon1 = result.title
|
||||
RefreshAddonConflicts()
|
||||
|
||||
end )
|
||||
|
||||
steamworks.FileInfo( addon2, function( result )
|
||||
|
||||
if ( !result ) then return end
|
||||
|
||||
AddonConflicts[ id ].addon2 = result.title
|
||||
RefreshAddonConflicts()
|
||||
|
||||
end )
|
||||
|
||||
end
|
||||
|
||||
AddonConflicts[ id ].files[ fileName ] = true
|
||||
|
||||
RefreshAddonConflicts()
|
||||
|
||||
end )
|
||||
|
||||
function RefreshAddonConflicts()
|
||||
timer.Create( "addon_conflicts", 1, 1, FireAddonConflicts )
|
||||
end
|
||||
|
||||
function FireAddonConflicts()
|
||||
|
||||
for id, tbl in pairs( AddonConflicts ) do
|
||||
|
||||
local files = ""
|
||||
for file, _ in pairs( tbl.files ) do
|
||||
files = files .. file .. "\n"
|
||||
end
|
||||
|
||||
local text = language.GetPhrase( "problem.addon_conflict" )
|
||||
text = text:format( "<color=255,128,0>" .. tbl.addon1 .. "</color>", "<color=255,128,0>" .. tbl.addon2 .. "</color>", files )
|
||||
|
||||
FireProblem( {
|
||||
id = id,
|
||||
type = "addons",
|
||||
severity = 0,
|
||||
text = text
|
||||
} )
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
139
lua/menu/problems/problems_pnl.lua
Normal file
139
lua/menu/problems/problems_pnl.lua
Normal file
@@ -0,0 +1,139 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
include( "problem_lua.lua" )
|
||||
include( "problem_generic.lua" )
|
||||
include( "permissions.lua" )
|
||||
|
||||
local PANEL = {}
|
||||
|
||||
function PANEL:Init()
|
||||
|
||||
self:SetSize( ScrW(), ScrH() )
|
||||
self:MakePopup()
|
||||
|
||||
self.ErrorPanels = {}
|
||||
self.ProblemPanels = {}
|
||||
|
||||
local ProblemsFrame = vgui.Create( "DFrame", self )
|
||||
ProblemsFrame:SetSize( ScrW() * 0.75, ScrH() * 0.75 )
|
||||
ProblemsFrame:Center()
|
||||
ProblemsFrame:SetTitle( "" )
|
||||
ProblemsFrame:SetDraggable( false )
|
||||
ProblemsFrame:SetBackgroundBlur( true )
|
||||
ProblemsFrame.OnRemove = function( frm ) self:Remove() end
|
||||
ProblemsFrame.Paint = function( frm ) end
|
||||
ProblemsFrame:DockPadding( 5, 3, 5, 0 )
|
||||
|
||||
local sheet = vgui.Create( "DPropertySheet", ProblemsFrame )
|
||||
sheet:Dock( FILL )
|
||||
self.Tabs = sheet
|
||||
|
||||
-- Lua errors
|
||||
local luaErrorList = ProblemsFrame:Add( "DScrollPanel" )
|
||||
sheet:AddSheet( "#problems.lua_errors", luaErrorList, "icon16/error.png" )
|
||||
self.LuaErrorList = luaErrorList
|
||||
|
||||
-- Generic problems
|
||||
local problemsList = ProblemsFrame:Add( "DScrollPanel" )
|
||||
sheet:AddSheet( "#problems.problems", problemsList, "icon16/tick.png" )
|
||||
self.ProblemsList = problemsList
|
||||
|
||||
-- Permissions
|
||||
local permissionList = ProblemsFrame:Add( "PermissionViewer" )
|
||||
permissionList.ParentFrame = self
|
||||
sheet:AddSheet( "#permissions.title", permissionList, "icon16/lock.png" )
|
||||
|
||||
ProblemsFrame.btnClose:MoveToFront()
|
||||
ProblemsFrame.btnMaxim:MoveToFront()
|
||||
ProblemsFrame.btnMinim:MoveToFront()
|
||||
|
||||
end
|
||||
|
||||
function PANEL:AddEmptyWarning( txt, parent )
|
||||
|
||||
local lab = parent:Add( "DLabel" )
|
||||
lab:SetText( txt )
|
||||
lab:SetBright( true )
|
||||
lab:SetFont( "DermaLarge" )
|
||||
lab:SetContentAlignment( 5 )
|
||||
lab:Dock( FILL )
|
||||
|
||||
-- Horrible hack
|
||||
lab.Paint = function( s, w, h )
|
||||
s:SetTall( parent:GetTall() )
|
||||
end
|
||||
|
||||
return lab
|
||||
|
||||
end
|
||||
|
||||
function PANEL:Paint( w, h )
|
||||
|
||||
draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 240 ) )
|
||||
|
||||
end
|
||||
|
||||
function PANEL:PerformLayout()
|
||||
|
||||
if ( self.LuaErrorList:GetCanvas():ChildCount() < 1 ) then
|
||||
self.NoErrorsLabel = self:AddEmptyWarning( "#problems.no_lua_errors", self.LuaErrorList )
|
||||
end
|
||||
|
||||
if ( self.ProblemsList:GetCanvas():ChildCount() < 1 ) then
|
||||
self.NoProblemsLabel = self:AddEmptyWarning( "#problems.no_problems", self.ProblemsList )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function PANEL:ReceivedError( uid, err )
|
||||
|
||||
if ( IsValid( self.NoErrorsLabel ) ) then self.NoErrorsLabel:Remove() end
|
||||
|
||||
local groupID = err.type or "Other"
|
||||
local pnl = self.ErrorPanels[ groupID ]
|
||||
if ( !IsValid( pnl ) ) then
|
||||
pnl = self.LuaErrorList:Add( "LuaProblemGroup" )
|
||||
pnl:SetTitleAndID( err.title, err.addonid, groupID )
|
||||
self.ErrorPanels[ groupID ] = pnl
|
||||
|
||||
-- Sort
|
||||
local z = 0
|
||||
for gid, epnl in SortedPairs( self.ErrorPanels ) do
|
||||
epnl:SetZPos( z )
|
||||
z = z + 1
|
||||
end
|
||||
self:InvalidateLayout()
|
||||
end
|
||||
|
||||
pnl:ReceivedError( uid, err )
|
||||
|
||||
end
|
||||
|
||||
function PANEL:ReceivedProblem( uid, prob )
|
||||
|
||||
if ( IsValid( self.NoProblemsLabel ) ) then self.NoProblemsLabel:Remove() end
|
||||
|
||||
local groupID = prob.type or "other"
|
||||
local pnl = self.ProblemPanels[ groupID ]
|
||||
if ( !IsValid( pnl ) ) then
|
||||
pnl = self.ProblemsList:Add( "GenericProblemGroup" )
|
||||
pnl:SetGroup( groupID )
|
||||
self.ProblemPanels[ groupID ] = pnl
|
||||
|
||||
self:InvalidateLayout()
|
||||
end
|
||||
|
||||
pnl:ReceivedProblem( uid, prob )
|
||||
|
||||
end
|
||||
|
||||
vgui.Register( "ProblemsPanel", PANEL, "EditablePanel" )
|
||||
Reference in New Issue
Block a user