Garry's Mod Wiki

Revision Difference

WEAPON:PrintWeaponInfo#565035

<function name="PrintWeaponInfo" parent="WEAPON" type="hook"> <description>A convenience function that draws the weapon info box, used in <page>WEAPON:DrawWeaponSelection</page>.</description> <realm>Client</realm> <file line="63-L89">gamemodes/base/entities/weapons/weapon_base/cl_init.lua</file>⤶ <args> <arg name="x" type="number">The x co-ordinate of box position</arg> <arg name="y" type="number">The y co-ordinate of box position</arg> <arg name="alpha" type="number">Alpha value for the box</arg> </args> </function>⤶ ⤶ <example>⤶ <description>As defined in weapon_base</description>⤶ <code>⤶ function SWEP:PrintWeaponInfo( x, y, alpha )⤶ ⤶ if ( self.DrawWeaponInfoBox == false ) then return end⤶ ⤶ if (self.InfoMarkup == nil ) then⤶ local str⤶ local title_color = "<color=230,230,230,255>"⤶ local text_color = "<color=150,150,150,255>"⤶ ⤶ str = "<font=HudSelectionText>"⤶ if ( self.Author != "" ) then str = str .. title_color .. "Author:</color>\t"..text_color..self.Author.."</color>\n" end⤶ if ( self.Contact != "" ) then str = str .. title_color .. "Contact:</color>\t"..text_color..self.Contact.."</color>\n\n" end⤶ if ( self.Purpose != "" ) then str = str .. title_color .. "Purpose:</color>\n"..text_color..self.Purpose.."</color>\n\n" end⤶ if ( self.Instructions != "" ) then str = str .. title_color .. "Instructions:</color>\n"..text_color..self.Instructions.."</color>\n" end⤶ str = str .. "</font>"⤶ ⤶ self.InfoMarkup = markup.Parse( str, 250 )⤶ end⤶ ⤶ surface.SetDrawColor( 60, 60, 60, alpha )⤶ surface.SetTexture( self.SpeechBubbleLid )⤶ ⤶ surface.DrawTexturedRect( x, y - 64 - 5, 128, 64 ) ⤶ draw.RoundedBox( 8, x - 5, y - 6, 260, self.InfoMarkup:GetHeight() + 18, Color( 60, 60, 60, alpha ) )⤶ ⤶ self.InfoMarkup:Draw( x+5, y+5, nil, nil, alpha )⤶ ⤶ end⤶ </code>⤶ ⤶ </example></function>