I got a problem with my background is black, but the small black dots n the NumSlider is also black so you cant see it. How do i recolor it, and is there a list where i can find all the methods to recolor something in derma?
[QUOTE=TheEvilDirect;47496750]I got a problem with my background is black, but the small black dots n the NumSlider is also black so you cant see it. How do i recolor it, and is there a list where i can find all the methods to recolor something in derma?[/QUOTE]
The function below is what draws the notches, if you redefine it, you could change the colour.
[LUA]
local DNumSlider -- Your VGUI Element
local slider = DNumSlider.Slider;
function slider:DrawNotches( level, x, y, w, h, range, value, min, max )
local size = level * self:GetZoom();
if ( size < 5 ) then return end
if ( size > w*2 ) then return end
local alpha = 255
if ( size < 150 ) then alpha = alpha * ((size - 2) / 140) end
if ( size > (w*2) - 100 ) then alpha = alpha * (1 - ((size - (w - 50)) / 50)) end
local halfw = w * 0.5
local span = math.ceil( w / size )
local realmid = x + w * 0.5 - (value * self:GetZoom());
local mid = x + w * 0.5 - math.mod( value * self:GetZoom(), size );
local top = h * 0.4;
local nh = h - (top);
local frame_min = realmid + min * self:GetZoom()
local frame_width = range * self:GetZoom()
surface.SetDrawColor( 0, 0, 0, alpha )
surface.DrawRect( frame_min, y + top, frame_width, 2 );
surface.SetFont( "DermaDefault" )
for n = -span, span, 1 do
local nx = ((mid) + n * size)
local dist = 1 - (math.abs( halfw - nx + x ) / w);
local val = (nx - realmid) / self:GetZoom();
if ( val <= min+0.001 ) then continue end
if ( val >= max-0.001 ) then continue end
surface.SetDrawColor( 0, 0, 0, alpha * dist )
surface.SetTextColor( 0, 0, 0, alpha * dist )
surface.DrawRect( nx, y+top, 2, nh )
local tw, th = surface.GetTextSize( val )
surface.SetTextPos( nx - (tw * 0.5), y + top - th )
surface.DrawText( val )
end
surface.SetDrawColor( 0, 0, 0, alpha )
surface.SetTextColor( 0, 0, 0, alpha )
--
-- Draw the last one.
--
local nx = realmid + max * self:GetZoom()
surface.DrawRect( nx, y+top, 2, nh )
local val = max;
local tw, th = surface.GetTextSize( val )
surface.SetTextPos( nx - (tw * 0.5), y + top - th )
surface.DrawText( val )
--
-- Draw the first
--
local nx = realmid + min * self:GetZoom()
surface.DrawRect( nx, y+top, 2, nh )
local val = min;
local tw, th = surface.GetTextSize( val )
surface.SetTextPos( nx - (tw * 0.5), y + top - th )
surface.DrawText( val )
end
[/LUA]
Where should i put this?
Where you are defining your DNumSlider instance. Get the slider child panel, and redefine its DrawNotches function with your modified version.
Sorry, but can you give a example where to place it?
It's not exactly complicated
[Lua]
local DermaNumSlider = vgui.Create( "DNumSlider")
DermaNumSlider:SetPos( 25, 50 ) // Set the position
DermaNumSlider:SetSize( 150, 100 ) // Set the size
DermaNumSlider:SetText( "Maximum props" ) // Set the text above the slider
DermaNumSlider:SetMin( 0 ) // Set the minimum number you can slide to
DermaNumSlider:SetMax( 256 ) // Set the maximum number you can slide to
DermaNumSlider:SetDecimals( 0 ) // Decimal places - zero for whole number
DermaNumSlider:SetConVar( "sbox_maxprops" ) // Changes the ConVar when you slide
local slider = DermaNumSlider.Slider;
function slider:DrawNotches( level, x, y, w, h, range, value, min, max )
-- Code
end
[/lua]
Yeah, but i cant get it to change color, and then i was thinking it implemented it wrong.
[QUOTE=TheEvilDirect;47498049]Yeah, but i cant get it to change color, and then i was thinking it implemented it wrong.[/QUOTE]
You change the colour inside the function be changing the surface.SetDrawColor functions inside the redefinition.
[QUOTE=James xX;47498065]You change the colour inside the function be changing the surface.SetDrawColor functions inside the redefinition.[/QUOTE]
James, try out the code you suggested. I did, and it didn't seem to override for me.
Sorry, you need to Log In to post a reply to this thread.