From a102c25ab7987d5650fb8cc1ef52a5b29a01ffaa Mon Sep 17 00:00:00 2001 From: "U-DESKTOP-FOJ6TK1\\Alex" Date: Wed, 12 Feb 2025 16:44:31 -0600 Subject: Final commit --- lua/vgui/dtiltedlabel.lua | 78 +++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 39 deletions(-) (limited to 'lua/vgui/dtiltedlabel.lua') diff --git a/lua/vgui/dtiltedlabel.lua b/lua/vgui/dtiltedlabel.lua index a0aaf7d..1d34f6b 100644 --- a/lua/vgui/dtiltedlabel.lua +++ b/lua/vgui/dtiltedlabel.lua @@ -1,39 +1,39 @@ -local PANEL = {} -local base = vgui.GetControlTable("DLabel") -setmetatable(PANEL,{__index=base}) - ---Function stolen from the lua wiki -function draw.TextRotated( text, x, y, color, font, ang ) - render.PushFilterMag( TEXFILTER.ANISOTROPIC ) - render.PushFilterMin( TEXFILTER.ANISOTROPIC ) - surface.SetFont( font ) - surface.SetTextColor( color ) - surface.SetTextPos( 0, 0 ) - local textWidth, textHeight = surface.GetTextSize( text ) - local rad = -math.rad( ang ) - x = x - ( math.cos( rad ) * textWidth / 2 + math.sin( rad ) * textHeight / 2 ) - y = y + ( math.sin( rad ) * textWidth / 2 + math.cos( rad ) * textHeight / 2 ) - local m = Matrix() - m:SetAngles( Angle( 0, ang, 0 ) ) - m:SetTranslation( Vector( x, y, 0 ) ) - cam.PushModelMatrix( m ) - surface.DrawText( text ) - cam.PopModelMatrix() - render.PopFilterMag() - render.PopFilterMin() -end -function PANEL:Paint(w,h) - local x,y = self:LocalToScreen(0,0) - print("x",x,"y",y) - draw.TextRotated(self:GetText(),0,y,Color(0,0,0,255),"DermaDefault",-45) -end -function PANEL:GetHeaderHeight() - return 0--10 * #(self.Header:GetText()) -end -function PANEL:Init() - - --self.Header = vgui.Create( "DButton", self ) - --self.Header.DoClick = function() self:DoClick() end - --self.Header.DoRightClick = function() self:DoRightClick() end -end -vgui.Register("DTiltedLabel", PANEL, "DLabel") +local PANEL = {} +local base = vgui.GetControlTable("DLabel") +setmetatable(PANEL,{__index=base}) + +--Function stolen from the lua wiki +function draw.TextRotated( text, x, y, color, font, ang ) + render.PushFilterMag( TEXFILTER.ANISOTROPIC ) + render.PushFilterMin( TEXFILTER.ANISOTROPIC ) + surface.SetFont( font ) + surface.SetTextColor( color ) + surface.SetTextPos( 0, 0 ) + local textWidth, textHeight = surface.GetTextSize( text ) + local rad = -math.rad( ang ) + x = x - ( math.cos( rad ) * textWidth / 2 + math.sin( rad ) * textHeight / 2 ) + y = y + ( math.sin( rad ) * textWidth / 2 + math.cos( rad ) * textHeight / 2 ) + local m = Matrix() + m:SetAngles( Angle( 0, ang, 0 ) ) + m:SetTranslation( Vector( x, y, 0 ) ) + cam.PushModelMatrix( m ) + surface.DrawText( text ) + cam.PopModelMatrix() + render.PopFilterMag() + render.PopFilterMin() +end +function PANEL:Paint(w,h) + local x,y = self:LocalToScreen(0,0) + print("x",x,"y",y) + draw.TextRotated(self:GetText(),0,y,Color(0,0,0,255),"DermaDefault",-45) +end +function PANEL:GetHeaderHeight() + return 0--10 * #(self.Header:GetText()) +end +function PANEL:Init() + + --self.Header = vgui.Create( "DButton", self ) + --self.Header.DoClick = function() self:DoClick() end + --self.Header.DoRightClick = function() self:DoRightClick() end +end +vgui.Register("DTiltedLabel", PANEL, "DLabel") -- cgit v1.2.3-70-g09d2