zombiesurvival-evolved/gamemodes/zombiesurvival/gamemode/vgui/dexchanginglabel.lua

37 lines
614 B
Lua
Raw Normal View History

2014-10-02 08:49:54 +08:00
local PANEL = {}
local function empty() end
function PANEL:SetChangeFunction(func, autosize)
self.Think = function(me)
local val = func()
if self.LastValue ~= val and val ~= nil then
self.LastValue = val
self:SetText(val)
if autosize then
self:SizeToContents()
end
if self.OnChanged then
self:OnChanged(val)
end
end
end
end
function PANEL:RemoveChangeFunction()
self.Think = empty
end
function PANEL:SetChangedFunction(func)
self.OnChanged = func
end
function PANEL:RemoveChangedFunction()
self.OnChanged = empty
end
vgui.Register("DEXChangingLabel", PANEL, "DLabel")