mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 21:53:46 +03:00
Upload
This commit is contained in:
67
lua/vgui/contextbase.lua
Normal file
67
lua/vgui/contextbase.lua
Normal file
@@ -0,0 +1,67 @@
|
||||
--[[
|
||||
| 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.Label = vgui.Create( "DLabel", self )
|
||||
self.Label:SetText( "" )
|
||||
self.Label:SetDark( true )
|
||||
|
||||
end
|
||||
|
||||
function PANEL:SetConVar( cvar )
|
||||
self.ConVarValue = cvar
|
||||
end
|
||||
|
||||
function PANEL:ConVar()
|
||||
return self.ConVarValue
|
||||
end
|
||||
|
||||
function PANEL:ControlValues( kv )
|
||||
|
||||
self:SetConVar( kv.convar or "" )
|
||||
self.Label:SetText( kv.label or "" )
|
||||
|
||||
end
|
||||
|
||||
function PANEL:PerformLayout()
|
||||
|
||||
local y = 5
|
||||
self.Label:SetPos( 5, y )
|
||||
self.Label:SetWide( self:GetWide() )
|
||||
|
||||
y = y + self.Label:GetTall()
|
||||
y = y + 5
|
||||
|
||||
return y
|
||||
|
||||
end
|
||||
|
||||
function PANEL:TestForChanges()
|
||||
|
||||
-- You should override this function and use it to
|
||||
-- check whether your convar value changed
|
||||
|
||||
end
|
||||
|
||||
function PANEL:Think()
|
||||
|
||||
if ( self.NextPoll && self.NextPoll > CurTime() ) then return end
|
||||
|
||||
self.NextPoll = CurTime() + 0.1
|
||||
|
||||
self:TestForChanges()
|
||||
|
||||
end
|
||||
|
||||
vgui.Register( "ContextBase", PANEL, "Panel" )
|
||||
Reference in New Issue
Block a user