Guest User

Untitled

a guest
Mar 9th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.41 KB | None | 0 0
  1. function GM:ShowTeam()
  2.  
  3. if ( IsValid( self.TeamSelectFrame ) ) then return end
  4.  
  5. -- Simple team selection box
  6. self.TeamSelectFrame = vgui.Create( "DPanel" )
  7. self.TeamSelectFrame:SetPos(0,0)
  8. self.TeamSelectFrame:SetSize( ScrW(), ScrH() )
  9.  
  10. local links = { { ( "teamselect_workshop_ref" ), "http://steamcommunity.com/sharedfiles/filedetails/?id=480998235" },
  11. { ( "teamselect_workshop_changelog" ), "http://steamcommunity.com/sharedfiles/filedetails/changelog/480998235" },
  12. { ( "teamselect_workshop_bug" ), "http://steamcommunity.com/workshop/filedetails/discussion/480998235/523897653307060068/" },
  13. --{ ( "teamselect_workshop_contact" ), "http://steamcommunity.com/id/lolleko/" }
  14. }
  15.  
  16. local linkOffsetY = 180
  17.  
  18. for _, v in pairs( links ) do
  19. local LinkButton = vgui.Create( "DButton", self.TeamSelectFrame )
  20. LinkButton:SetPos( ScrW() / 2 - 620, linkOffsetY )
  21. LinkButton:SetSize( 280, 40 )
  22. LinkButton:SetFont("robot_small")
  23. LinkButton:SetText( v[1] )
  24. LinkButton:SetTextColor( clrs.lightgrey )
  25. function LinkButton.DoClick() gui.OpenURL( v[2] ) end
  26. function LinkButton:Paint( w, h)
  27. draw.RoundedBox( 0, 0, 0, w, h, clrs.grey )
  28. end
  29. linkOffsetY = linkOffsetY + 80
  30. end
  31.  
  32. local controls = {}
  33. if input.LookupBinding( "duck" ) then table.insert( controls, { string.upper( input.LookupBinding( "duck" ) ), ( "teamselect_controls_sit" ) } ) end
  34. if input.LookupBinding( "attack2" ) then table.insert( controls, { string.upper( input.LookupBinding( "attack2" ) ), ( "teamselect_controls_ability" ) } ) end
  35. if input.LookupBinding( "gm_showhelp" ) then table.insert( controls, { string.upper( input.LookupBinding( "gm_showhelp" ) ), ( "teamselect_controls_settings" ) } ) end
  36. if input.LookupBinding( "gm_showteam" ) then table.insert( controls, { string.upper( input.LookupBinding( "gm_showteam" ) ), ( "teamselect_controls_team" ) } ) end
  37. if input.LookupBinding( "gm_showspare2" ) then table.insert( controls, { string.upper( input.LookupBinding( "gm_showspare2" ) ), ( "teamselect_controls_random" ) } ) end
  38. if input.LookupBinding( "menu" ) && input.LookupBinding( "menu_context" ) then table.insert( controls, { string.upper( input.LookupBinding( "menu" ) ) .. " + " .. string.upper( input.LookupBinding( "menu_context" ) ), ( "teamselect_controls_taunts" ) } ) end
  39.  
  40. local controlsOffsetY = 180
  41.  
  42. for _, v in pairs( controls ) do
  43. local ControlKey = vgui.Create( "DLabel", self.TeamSelectFrame )
  44. ControlKey:SetPos( ScrW() / 2 + 340, controlsOffsetY )
  45. ControlKey:SetSize( 80, 40 )
  46. ControlKey:SetFont("robot_smaller")
  47. ControlKey:SetText( v[1] )
  48. ControlKey:SetTextColor( clrs.lightgrey )
  49. ControlKey:SetContentAlignment( 5 )
  50. function ControlKey:Paint( w, h)
  51. draw.RoundedBox( 0, 0, 0, w, h, clrs.red )
  52. end
  53.  
  54. local ControlDesc = vgui.Create( "DLabel", self.TeamSelectFrame )
  55. ControlDesc:SetPos( ScrW() / 2 + 420, controlsOffsetY )
  56. ControlDesc:SetSize( 200, 40 )
  57. ControlDesc:SetFont("robot_small")
  58. ControlDesc:SetText( v[2] )
  59. ControlDesc:SetTextColor( clrs.lightgrey )
  60. ControlDesc:SetContentAlignment( 5 )
  61. function ControlDesc:Paint( w, h)
  62. draw.RoundedBox( 0, 0, 0, w, h, clrs.grey )
  63. end
  64.  
  65. controlsOffsetY = controlsOffsetY + 80
  66. end
  67.  
  68. local HeaderImage = vgui.Create("DImage", self.TeamSelectFrame)
  69. HeaderImage:SetSize( 285, 96 )
  70. HeaderImage:SetPos( 0, 60 )
  71. HeaderImage:SetImage( "vgui/gw/logo_main.png" )
  72. HeaderImage:CenterHorizontal()
  73.  
  74. --Hiding Button
  75. local TeamHidingPanel = vgui.Create( "DPanel", self.TeamSelectFrame )
  76. TeamHidingPanel:SetPos( ScrW() / 2 - 300, 180 )
  77. TeamHidingPanel:SetSize( 280, 280 )
  78. function TeamHidingPanel:Paint( w, h )
  79. draw.RoundedBox( 0, 0, 0, w, h, team.GetColor(TEAM_JACK) )
  80. end
  81.  
  82. local TeamHidingModel = vgui.Create( "DModelPanel", TeamHidingPanel )
  83. TeamHidingModel:SetSize( 280, 280 )
  84. TeamHidingModel:SetModel( "models/player/gman_high.mdl" )
  85. local seq, dur = TeamHidingModel.Entity:LookupSequence("gesture_wave")
  86. TeamHidingModel.Entity:SetSequence(seq)
  87. TeamHidingModel.Entity:SetAngles( Angle( 0, 70, 0 ) )
  88. TeamHidingModel.Entity:DrawShadow(true)
  89. timer.Simple(dur-0.2,function() if !TeamHidingModel.Entity then return end TeamHidingModel.Entity:SetSequence("idle_all_01") TeamHidingModel.Entity:SetAngles( Angle( 0, 0, 0 ) ) end)
  90. function TeamHidingModel:LayoutEntity( ent )
  91. self:RunAnimation()
  92. end
  93.  
  94. local TeamHidingButton = vgui.Create( "DButton", TeamHidingPanel )
  95. function TeamHidingButton.DoClick()
  96. if self:IsBalancedToJoin(TEAM_JACK) then
  97. self:HideTeam() RunConsoleCommand( "changeteam", TEAM_JACK )
  98. end
  99. end
  100. TeamHidingButton:SetFont( "robot_normal" )
  101. TeamHidingButton:SetTextColor( clrs.lightgrey )
  102. TeamHidingButton:SetText( ( "Team Jack" ) .. "(" .. team.NumPlayers( TEAM_JACK ) .. ")" )
  103. TeamHidingButton:SetSize( 280, 280 )
  104. function TeamHidingButton:Paint( w, h )
  105. return
  106. end
  107. function TeamHidingButton:Think()
  108. self:SetText( ( "Team Jack" ) .. "(" .. team.NumPlayers( TEAM_JACK ) .. ")" )
  109. end
  110.  
  111. --Seeking Button
  112. local TeamSeekingPanel = vgui.Create( "DPanel", self.TeamSelectFrame )
  113. TeamSeekingPanel:SetPos( ScrW() / 2 + 20, 180 )
  114. TeamSeekingPanel:SetSize( 280, 280 )
  115. function TeamSeekingPanel:Paint( w, h )
  116. draw.RoundedBox( 0, 0, 0, w, h, team.GetColor(TEAM_SOLUTAR) )
  117. end
  118.  
  119. local TeamSeekingModel = vgui.Create( "DModelPanel", TeamSeekingPanel )
  120. TeamSeekingModel:SetSize( 280, 280 )
  121. TeamSeekingModel:SetModel( "models/player/Police.mdl" )
  122. function TeamSeekingModel:LayoutEntity( ent )
  123. ent:SetAngles( Angle( 0, 30, 0 ) )
  124. end
  125.  
  126. local TeamSeekingButton = vgui.Create( "DButton", TeamSeekingPanel )
  127. function TeamSeekingButton.DoClick()
  128. if self:IsBalancedToJoin(TEAM_SOLUTAR) then
  129. self:HideTeam() RunConsoleCommand( "changeteam", TEAM_SOLUTAR )
  130. end
  131. end
  132. TeamSeekingButton:SetFont( "robot_normal" )
  133. TeamSeekingButton:SetTextColor( clrs.lightgrey )
  134. TeamSeekingButton:SetText( ( "Team Solutar" ) .. "(" .. team.NumPlayers( TEAM_SOLUTAR ) .. ")" )
  135. TeamSeekingButton:SetSize( 280, 280 )
  136. function TeamSeekingButton:Paint( w, h )
  137. return
  138. end
  139. function TeamSeekingButton:Think()
  140. self:SetText( ( "Team Solutar" ) .. "(" .. team.NumPlayers( TEAM_SOLUTAR ) .. ")" )
  141. end
  142.  
  143. --spectate and auto buttons
  144. local TeamSpectateButton = vgui.Create( "DButton", self.TeamSelectFrame )
  145. TeamSpectateButton:SetPos( ScrW() / 2 - 300, 500 )
  146. TeamSpectateButton:SetSize( 600, 40 )
  147. TeamSpectateButton:SetFont("robot_small")
  148. TeamSpectateButton:SetText( ( "Zuschauen" ) )
  149. TeamSpectateButton:SetTextColor( clrs.lightgrey )
  150. function TeamSpectateButton.DoClick() self:HideTeam() RunConsoleCommand( "changeteam", TEAM_SPECTATOR ) end
  151. function TeamSpectateButton:Paint( w, h)
  152. draw.RoundedBox( 0, 0, 0, w, h, clrs.grey )
  153. end
  154.  
  155. local TeamAutoButton = vgui.Create( "DButton", self.TeamSelectFrame )
  156. TeamAutoButton:SetPos( ScrW() / 2 - 300, 580 )
  157. TeamAutoButton:SetSize( 600, 40 )
  158. TeamAutoButton:SetFont("robot_small")
  159. TeamAutoButton:SetText( ( "Auto Team" ) )
  160. TeamAutoButton:SetTextColor( clrs.lightgrey )
  161. function TeamAutoButton.DoClick() self:HideTeam() RunConsoleCommand( "changeteam", team.BestAutoJoinTeam() ) end
  162. function TeamAutoButton:Paint( w, h)
  163. draw.RoundedBox( 0, 0, 0, w, h, clrs.grey )
  164. end
  165.  
  166. self.TeamSelectFrame:SetSize( ScrW(), ScrH() )
  167. self.TeamSelectFrame:Center()
  168. self.TeamSelectFrame:MakePopup()
  169. self.TeamSelectFrame:SetKeyboardInputEnabled( false )
  170.  
  171. function self.TeamSelectFrame:Paint(w,h)
  172. return
  173. end
  174.  
  175. function self.TeamSelectFrame:Think()
  176. if GAMEMODE:GetRoundState() == NAV_GEN then
  177. self:Remove()
  178. self = nil
  179. end
  180. end
  181.  
  182. local GMVersion = vgui.Create( "DLabel", self.TeamSelectFrame )
  183. GMVersion:SetPos( ScrW() - 400, ScrH() - 40 )
  184. GMVersion:SetSize( 400, 40 )
  185. GMVersion:SetFont("robot_medium")
  186. GMVersion:SetText( "Version " .. GAMEMODE.Version )
  187. GMVersion:SetTextColor( clrs.lightgrey )
  188. GMVersion:SetContentAlignment( 6 )
  189. function GMVersion:Paint( w, h)
  190. return
  191. end
  192.  
  193. end
  194.  
  195. function GM:IsBalancedToJoin( teamid )
  196.  
  197. if LocalPlayer():Team() == teamid then return true end
  198.  
  199. if teamid == TEAM_SOLUTAR then
  200. if team.NumPlayers( TEAM_SOLUTAR ) > team.NumPlayers( TEAM_JACK ) or (LocalPlayer():Team() == TEAM_JACK && team.NumPlayers( TEAM_SOLUTAR ) == team.NumPlayers( TEAM_JACK )) then
  201. return false
  202. end
  203. elseif teamid == TEAM_JACK then
  204. if team.NumPlayers( TEAM_JACK ) > team.NumPlayers( TEAM_SOLUTAR ) or (LocalPlayer():Team() == TEAM_SOLUTAR && team.NumPlayers( TEAM_SOLUTAR) == team.NumPlayers( TEAM_JACK )) then
  205. return false
  206. end
  207. end
  208. return true
  209. end
  210.  
  211. function GM:HideTeam()
  212.  
  213. if ( IsValid(self.TeamSelectFrame) ) then
  214. self.TeamSelectFrame:Remove()
  215. self.TeamSelectFrame = nil
  216. end
  217.  
  218. end
Add Comment
Please, Sign In to add comment