There was a thread asking how to paint notches before, but the only answer on that thread didn't seem to work whatsoever. I literally copied the ENTIRE notch-painting function of the DNumSlider JUST to override the surface.SetDrawColor parts, even though it doesn't override properly. I'm probably just trying to change the wrong element.
Try out this example below. You can see that the notches do not get changed to be white.
[CODE]
local ExampleSlider = vgui.Create( "DNumSlider" )
ExampleSlider:SetMin( 0 )
ExampleSlider:SetMax( 1 )
ExampleSlider:SetText( "Cloud rotation speed" )
ExampleSlider:SetValue( GetConVarNumber( "example_convar" ) )
ExampleSlider:SetDecimals( 1 )
ExampleSlider:SetConVar( "example_convar" )
ExampleSlider.TextArea:SetTextColor(Color(255,255,255,255))
function ExampleSlider.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( 255, 255, 255, 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( 255, 255, 255, alpha * dist )
surface.SetTextColor( 255, 255, 255, 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( 255, 255, 255, alpha )
surface.SetTextColor( 255, 255, 255, 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
[/CODE]
So, how would I properly change the color of the notches?
Sorry, you need to Log In to post a reply to this thread.