Guest User

prop_spawn

a guest
Jul 25th, 2015
14
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ply = LocalPlayer()
  2. local PANEL = { }
  3. function PANEL:Init( )
  4.     self.Label = vgui.Create( "DLabel", self )
  5.     self.Label:SetText( "GoFish" )
  6.     self.Label:SetTextColor( Color( 255, 255, 255, 255 ) )
  7.     self.Label:SizeToContents( )
  8.    
  9.     self.ListList = vgui.Create( "DPanelList", self )
  10.    
  11.     self.IconList = {}
  12.     self.IconListCollapse = {}
  13.     for k,v in pairs (BAITGROUPS) do
  14.     self.IconList[k] = vgui.Create( "DPanelList", self )
  15.     self.IconList[k]:EnableVerticalScrollbar( true )
  16.     self.IconList[k]:EnableHorizontal( true )
  17.     self.IconList[k]:SetPadding( 4 )
  18.     self.IconList[k]:SetVisible( true )
  19.    
  20.     self.IconListCollapse[k] = vgui.Create( "DCollapsibleCategory", self )
  21.     self.IconListCollapse[k]:SetSize( 610,20 )
  22.     self.IconListCollapse[k]:SetLabel( v )
  23.     self.IconListCollapse[k]:SetVisible( true )
  24.     self.IconListCollapse[k]:SetContents(self.IconList[k])
  25.     self.ListList:AddItem( self.IconListCollapse[k] )
  26.     end
  27.  
  28. for k,v in pairs( FISH ) do
  29.         local ent = ents.Create("prop_physics") -- lol ailias filthy hack
  30.         ent:SetAngles(Angle(0,0,0))
  31.         ent:SetPos(Vector(0,0,0))
  32.         ent:SetModel(k)
  33.         ent:Spawn()
  34.         ent:Activate()
  35.         ent:PhysicsInit( SOLID_VPHYSICS )  
  36.         local ico = vgui.Create( "DModelPanel", self )
  37.         ico:SetModel(k)
  38.         ico.Skin = math.random(0,util.GetModelInfo(k).SkinCount-1)
  39.         ico.Entity:SetSkin(ico.Skin)
  40.         ico.DoClick = function( ico )
  41.         RunConsoleCommand("ProcessCommand"..v.NAME)
  42.         surface.PlaySound( "ui/buttonclick.wav" )      
  43.         end
  44.  
  45.         ico:SetSize(55,55)
  46.  
  47.         local center = ent:OBBCenter()
  48.         local dist = ent:BoundingRadius()*v.VIEW
  49.         ico:SetToolTip( Format( "%s", v.DESCRIPTION.."  -  Cost: $"..v.PRICE ) )
  50.         ico:SetLookAt( center )
  51.         ico:SetCamPos( center+Vector(dist,dist,dist) )
  52.  
  53.         ico:InvalidateLayout( true )
  54.         if v.GROUP then
  55.             self.IconList[v.GROUP]:AddItem( ico )
  56.         end
  57.         ent:Remove()
  58.     end
  59. end
  60.  
  61. function PANEL:PerformLayout( )
  62.     self:StretchToParent( 2, 24, 2, 2 )
  63.     self.Label:SetPos( 2, 2 )
  64.     self.ListList:StretchToParent( 4, 26, 4, 4 )
  65.     self.ListList:InvalidateLayout()
  66.     for k,v in pairs (self.IconList) do
  67.     --v:StretchToParent( 4, 26, 4, 4 )
  68.     v:SizeToContents( )
  69.     v:InvalidateLayout()
  70.     end
  71. end
  72.  
  73. function PANEL:OnVScroll( iOffset )
  74.     self.pnlCanvas:SetPos( 25, 25 + iOffset )
  75. end
  76.  
  77. function PANEL:OnMouseWheeled( dlta )
  78.     if ( self.VBar ) then
  79.         return self.VBar:OnMouseWheeled( dlta )
  80.     end
  81. end
  82.  
  83. vgui.Register( "gofish_menu", PANEL, "DPanel" )
RAW Paste Data