• TTT GUI help
    2 replies, posted
I'm trying to make it so text is added beside the voicechat box that comes up in the top left corner in TTT. I was able to add in text to the area so that it can be seen if it is inside the box its self. but If I try to move the label outside to the right of the box where I want it you can't see it. This is the code I have so far in gamemodes/base/gamemode [code] local PANEL = {} local PlayerVoicePanels = {} function PANEL:Init() self.LabelName = vgui.Create( "DLabel", self ) self.LabelName:SetFont( "GModNotify" ) self.LabelName:Dock( FILL ) self.LabelName:DockMargin( 8, 0, 0, 0 ) self.LabelName:SetTextColor( Color( 255, 255, 255, 255 ) ) myLabel = vgui.Create("DLabel", self) myLabel:SetPos(110,10) // Position myLabel:SetColor(Color(255,255,255,255)) // Color myLabel:SetFont("GModNotify") myLabel:SetText("I Love Gmod") // Text myLabel:SizeToContents() // make the control the same size as the text. self.Avatar = vgui.Create( "AvatarImage", self ) self.Avatar:Dock( LEFT ); self.Avatar:SetSize( 32, 32 ) self.Color = color_transparent self:SetSize( 250, 32 + 8 ) self:DockPadding( 4, 4, 4, 4 ) self:DockMargin( 2, 2, 2, 2 ) self:Dock( BOTTOM ) end function PANEL:Setup( ply ) self.ply = ply self.LabelName:SetText( ply:Nick() ) self.Avatar:SetPlayer( ply ) self.Color = team.GetColor( ply:Team() ) self:InvalidateLayout() end function PANEL:Paint( w, h ) if ( !IsValid( self.ply ) ) then return end draw.RoundedBox( 4, 0, 0, w, h, Color( 0, self.ply:VoiceVolume() * 255, 0, 240 ) ) end function PANEL:Think( ) if ( self.fadeAnim ) then self.fadeAnim:Run() end end function PANEL:FadeOut( anim, delta, data ) if ( anim.Finished ) then if ( IsValid( PlayerVoicePanels[ self.ply ] ) ) then PlayerVoicePanels[ self.ply ]:Remove() PlayerVoicePanels[ self.ply ] = nil return end return end self:SetAlpha( 255 - (255 * delta) ) end derma.DefineControl( "VoiceNotify", "", PANEL, "DPanel" ) function GM:PlayerStartVoice( ply ) if ( !IsValid( g_VoicePanelList ) ) then return end -- There'd be an exta one if voice_loopback is on, so remove it. GAMEMODE:PlayerEndVoice( ply ) if ( IsValid( PlayerVoicePanels[ ply ] ) ) then if ( PlayerVoicePanels[ ply ].fadeAnim ) then PlayerVoicePanels[ ply ].fadeAnim:Stop() PlayerVoicePanels[ ply ].fadeAnim = nil end PlayerVoicePanels[ ply ]:SetAlpha( 255 ) return; end if ( !IsValid( ply ) ) then return end local pnl = g_VoicePanelList:Add( "VoiceNotify" ) pnl:Setup( ply ) PlayerVoicePanels[ ply ] = pnl end local function VoiceClean() for k, v in pairs( PlayerVoicePanels ) do if ( !IsValid( k ) ) then GAMEMODE:PlayerEndVoice( k ) end end end timer.Create( "VoiceClean", 10, 0, VoiceClean ) function GM:PlayerEndVoice( ply ) if ( IsValid( PlayerVoicePanels[ ply ] ) ) then if ( PlayerVoicePanels[ ply ].fadeAnim ) then return end PlayerVoicePanels[ ply ].fadeAnim = Derma_Anim( "FadeOut", PlayerVoicePanels[ ply ], PlayerVoicePanels[ ply ].FadeOut ) PlayerVoicePanels[ ply ].fadeAnim:Start( 2 ) end end local function CreateVoiceVGUI() g_VoicePanelList = vgui.Create( "DPanel" ) g_VoicePanelList:ParentToHUD() g_VoicePanelList:SetPos( ScrW() - 300, 100 ) g_VoicePanelList:SetSize( 250, ScrH() - 200 ) g_VoicePanelList:SetDrawBackground( false ) end hook.Add( "InitPostEntity", "CreateVoiceVGUI", CreateVoiceVGUI ) [/code] The code with myLabel at the top is what I put in, its from a wiki reference.
The reason you're not seeing it is because you're constrained to this size: self:SetSize( 250, 32 + 8 ) That's the vgui panel size, if something goes outside of that with a standard call, it won't work. You could alternatively draw simple text in the paint function, that may work. Additionally, you're creating a global variable by just calling myLabel = ..., use self.myLabel = ..., or at the very least local myLabel = ...
I tried to draw the simple text in paint but it didn't work.
Sorry, you need to Log In to post a reply to this thread.