Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local PANEL = {}
- PANEL.Done = false
- PANEL.maskSize = 16 --Default for 32
- function PANEL:Init()
- self.Avatar = vgui.Create("AvatarImage", self)
- self.Avatar:SetPaintedManually(true)
- end
- function PANEL:PerformLayout()
- self.Avatar:SetSize(self:GetWide(), self:GetTall())
- end
- function PANEL:SetMaskSize(size)
- self.maskSize = size
- end
- function PANEL:Paint(w, h)
- if ( self.Done == true ) then
- return
- end
- render.ClearStencil()
- render.SetStencilEnable(true)
- render.SetStencilWriteMask( 1 )
- render.SetStencilTestMask( 1 )
- render.SetStencilFailOperation( STENCIL_REPLACE )
- render.SetStencilPassOperation( STENCIL_ZERO )
- render.SetStencilZFailOperation( STENCIL_ZERO )
- render.SetStencilCompareFunction( STENCIL_NEVER )
- render.SetStencilReferenceValue( 1 )
- draw.RoundedBox(18, 0, 0, w, h, color_white)
- render.SetStencilFailOperation( STENCIL_ZERO )
- render.SetStencilPassOperation( STENCIL_REPLACE )
- render.SetStencilZFailOperation( STENCIL_ZERO )
- render.SetStencilCompareFunction( STENCIL_EQUAL ) -- STENCILCOMPARISONFUNCTION_EQUAL will only draw what you draw as the mask.
- render.SetStencilReferenceValue( 1 )
- self.Avatar:SetPaintedManually(false)
- self.Avatar:PaintManual()
- self.Avatar:SetPaintedManually(true)
- render.SetStencilEnable(false)
- render.ClearStencil()
- self.Done = true
- end
- function PANEL:SetPlayer(ply, size)
- self.Avatar:SetPlayer(ply, size)
- end
- function PANEL:SetSteamID(steamid, size)
- self.Avatar:SetSteamID(util.SteamIDTo64(steamid), size)
- end
- vgui.Register("FancyAvatarImage", PANEL)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement