diff options
| author | U-DESKTOP-FOJ6TK1\Alex <alex@cogarr.net> | 2025-02-12 16:44:31 -0600 |
|---|---|---|
| committer | U-DESKTOP-FOJ6TK1\Alex <alex@cogarr.net> | 2025-02-12 16:44:31 -0600 |
| commit | a102c25ab7987d5650fb8cc1ef52a5b29a01ffaa (patch) | |
| tree | 85c1cc06867222545ecef6619bf48056a8d4e131 /lua/vgui | |
| parent | b5b9efc28bb65fa3a53db8867310ac42d00f2bc6 (diff) | |
| download | nadmin-a102c25ab7987d5650fb8cc1ef52a5b29a01ffaa.tar.gz nadmin-a102c25ab7987d5650fb8cc1ef52a5b29a01ffaa.tar.bz2 nadmin-a102c25ab7987d5650fb8cc1ef52a5b29a01ffaa.zip | |
Diffstat (limited to 'lua/vgui')
| -rw-r--r-- | lua/vgui/dtiltedlabel.lua | 78 |
1 files changed, 39 insertions, 39 deletions
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")
|
