mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-16 21:33:46 +03:00
60 lines
1.8 KiB
Lua
60 lines
1.8 KiB
Lua
--[[
|
|
| 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/
|
|
--]]
|
|
|
|
--[[--------------------------------------------------------------------------
|
|
-- Namespace Tables
|
|
--------------------------------------------------------------------------]]--
|
|
|
|
local PANEL = {}
|
|
|
|
--[[--------------------------------------------------------------------------
|
|
-- Localized Functions & Variables
|
|
--------------------------------------------------------------------------]]--
|
|
|
|
local math = math
|
|
local vgui = vgui
|
|
local tonumber = tonumber
|
|
|
|
--[[--------------------------------------------------------------------------
|
|
-- Namespace Functions
|
|
--------------------------------------------------------------------------]]--
|
|
|
|
--[[--------------------------------------------------------------------------
|
|
--
|
|
-- PANEL:SetValue( string, boolean )
|
|
--
|
|
--]]--
|
|
function PANEL:SetValue( val, bSuppress )
|
|
val = math.Clamp( tonumber( val ) or 0, self:GetMin(), self:GetMax() )
|
|
|
|
if ( val == nil ) then return end
|
|
if ( self:GetValue() == val ) then return end
|
|
|
|
self.Scratch:SetFloatValue( val )
|
|
self:ValueChanged( self:GetValue(), bSuppress )
|
|
end
|
|
|
|
--[[--------------------------------------------------------------------------
|
|
--
|
|
-- PANEL:ValueChanged( string, value)
|
|
--
|
|
--]]--
|
|
function PANEL:ValueChanged( val, bSuppress )
|
|
val = math.Clamp( tonumber( val ) or 0, self:GetMin(), self:GetMax() )
|
|
self.Slider:SetSlideX( self.Scratch:GetFraction( val ) )
|
|
if ( self.TextArea ~= vgui.GetKeyboardFocus() ) then
|
|
self.TextArea:SetValue( self.Scratch:GetTextValue() )
|
|
end
|
|
if ( not bSuppress ) then
|
|
self:OnValueChanged( val )
|
|
end
|
|
end
|
|
|
|
vgui.Register( "StackerDNumSlider", PANEL, "DNumSlider" ) |