-
Notifications
You must be signed in to change notification settings - Fork 842
Expand file tree
/
Copy pathcontextbase.lua
More file actions
57 lines (34 loc) · 941 Bytes
/
contextbase.lua
File metadata and controls
57 lines (34 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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" )