Garry's Mod Wiki

Revision Difference

WEAPON:PrintWeaponInfo#512239

<function name="PrintWeaponInfo" parent="WEAPON" type="hook">⤶ <ishook>yes</ishook>⤶ <description>A convenience function that draws the weapon info box, used in <page>WEAPON:DrawWeaponSelection</page>.</description>⤶ <realm>Client</realm>⤶ <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 = "&amp;lt;color=230,230,230,255&amp;gt;"⤶ local text_color = "&amp;lt;color=150,150,150,255&amp;gt;"⤶ ⤶ str = "&amp;lt;font=HudSelectionText&amp;gt;"⤶ if ( self.Author != "" ) then str = str .. title_color .. "Author:&amp;lt;/color&amp;gt;\t"..text_color..self.Author.."&amp;lt;/color&amp;gt;\n" end⤶ if ( self.Contact != "" ) then str = str .. title_color .. "Contact:&amp;lt;/color&amp;gt;\t"..text_color..self.Contact.."&amp;lt;/color&amp;gt;\n\n" end⤶ if ( self.Purpose != "" ) then str = str .. title_color .. "Purpose:&amp;lt;/color&amp;gt;\n"..text_color..self.Purpose.."&amp;lt;/color&amp;gt;\n\n" end⤶ if ( self.Instructions != "" ) then str = str .. title_color .. "Instructions:&amp;lt;/color&amp;gt;\n"..text_color..self.Instructions.."&amp;lt;/color&amp;gt;\n" end⤶ str = str .. "&amp;lt;/font&amp;gt;"⤶ ⤶ 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>