Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function GM:ShowTeam()
- if ( IsValid( self.TeamSelectFrame ) ) then return end
- -- Simple team selection box
- TeamSelectFrame = vgui.Create( "DPanel" )
- TeamSelectFrame:SetPos(0,0)
- TeamSelectFrame:SetSize( ScrW(), ScrH() )
- local controls = {}
- if input.LookupBinding( "duck" ) then table.insert( controls, { string.upper( input.LookupBinding( "duck" ) ), ( "teamselect_controls_sit" ) } ) end
- if input.LookupBinding( "attack2" ) then table.insert( controls, { string.upper( input.LookupBinding( "attack2" ) ), ( "teamselect_controls_ability" ) } ) end
- if input.LookupBinding( "gm_showhelp" ) then table.insert( controls, { string.upper( input.LookupBinding( "gm_showhelp" ) ), ( "teamselect_controls_settings" ) } ) end
- if input.LookupBinding( "gm_showteam" ) then table.insert( controls, { string.upper( input.LookupBinding( "gm_showteam" ) ), ( "teamselect_controls_team" ) } ) end
- if input.LookupBinding( "gm_showspare2" ) then table.insert( controls, { string.upper( input.LookupBinding( "gm_showspare2" ) ), ( "teamselect_controls_random" ) } ) end
- 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
- local controlsOffsetY = 180
- for _, v in pairs( controls ) do
- local ControlKey = vgui.Create( "DLabel", TeamSelectFrame )
- ControlKey:SetPos( ScrW() / 2 + 340, controlsOffsetY )
- ControlKey:SetSize( 80, 40 )
- ControlKey:SetFont("robot_smaller")
- ControlKey:SetText( v[1] )
- ControlKey:SetTextColor( clrs.lightgrey )
- ControlKey:SetContentAlignment( 5 )
- function ControlKey:Paint( w, h)
- draw.RoundedBox( 0, 0, 0, w, h, clrs.red )
- end
- local ControlDesc = vgui.Create( "DLabel", TeamSelectFrame )
- ControlDesc:SetPos( ScrW() / 2 + 420, controlsOffsetY )
- ControlDesc:SetSize( 200, 40 )
- ControlDesc:SetFont("robot_small")
- ControlDesc:SetText( v[2] )
- ControlDesc:SetTextColor( clrs.lightgrey )
- ControlDesc:SetContentAlignment( 5 )
- function ControlDesc:Paint( w, h)
- draw.RoundedBox( 0, 0, 0, w, h, clrs.grey )
- end
- controlsOffsetY = controlsOffsetY + 80
- end
- local HeaderImage = vgui.Create("DImage", TeamSelectFrame)
- HeaderImage:SetSize( 285, 96 )
- HeaderImage:SetPos( 0, 60 )
- HeaderImage:SetImage( "vgui/gw/logo_main.png" )
- HeaderImage:CenterHorizontal()
- --Hiding Button
- local TeamHidingPanel = vgui.Create( "DPanel", TeamSelectFrame )
- TeamHidingPanel:SetPos( ScrW() / 2 - 300, 180 )
- TeamHidingPanel:SetSize( 280, 280 )
- function TeamHidingPanel:Paint( w, h )
- draw.RoundedBox( 0, 0, 0, w, h, team.GetColor(TEAM_JACK) )
- end
- local TeamHidingModel = vgui.Create( "DModelPanel", TeamHidingPanel )
- TeamHidingModel:SetSize( 280, 280 )
- TeamHidingModel:SetModel( "models/player/gman_high.mdl" )
- local seq, dur = TeamHidingModel.Entity:LookupSequence("gesture_wave")
- TeamHidingModel.Entity:SetSequence(seq)
- TeamHidingModel.Entity:SetAngles( Angle( 0, 70, 0 ) )
- TeamHidingModel.Entity:DrawShadow(true)
- 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)
- function TeamHidingModel:LayoutEntity( ent )
- self:RunAnimation()
- end
- local TeamHidingButton = vgui.Create( "DButton", TeamHidingPanel )
- function TeamHidingButton.DoClick()
- if self:IsBalancedToJoin(TEAM_JACK) then
- self:HideTeam() RunConsoleCommand( "changeteam", TEAM_JACK )
- end
- end
- TeamHidingButton:SetFont( "robot_normal" )
- TeamHidingButton:SetTextColor( clrs.lightgrey )
- TeamHidingButton:SetText( ( "Team Jack" ) .. "(" .. team.NumPlayers( TEAM_JACK ) .. ")" )
- TeamHidingButton:SetSize( 280, 280 )
- function TeamHidingButton:Paint( w, h )
- return
- end
- function TeamHidingButton:Think()
- self:SetText( ( "Team Jack" ) .. "(" .. team.NumPlayers( TEAM_JACK ) .. ")" )
- end
- --Seeking Button
- local TeamSeekingPanel = vgui.Create( "DPanel", TeamSelectFrame )
- TeamSeekingPanel:SetPos( ScrW() / 2 + 20, 180 )
- TeamSeekingPanel:SetSize( 280, 280 )
- function TeamSeekingPanel:Paint( w, h )
- draw.RoundedBox( 0, 0, 0, w, h, team.GetColor(TEAM_SOLUTAR) )
- end
- local TeamSeekingModel = vgui.Create( "DModelPanel", TeamSeekingPanel )
- TeamSeekingModel:SetSize( 280, 280 )
- TeamSeekingModel:SetModel( "models/player/Police.mdl" )
- function TeamSeekingModel:LayoutEntity( ent )
- ent:SetAngles( Angle( 0, 30, 0 ) )
- end
- local TeamSeekingButton = vgui.Create( "DButton", TeamSeekingPanel )
- function TeamSeekingButton.DoClick()
- if self:IsBalancedToJoin(TEAM_SOLUTAR) then
- self:HideTeam() RunConsoleCommand( "changeteam", TEAM_SOLUTAR )
- end
- end
- TeamSeekingButton:SetFont( "robot_normal" )
- TeamSeekingButton:SetTextColor( clrs.lightgrey )
- TeamSeekingButton:SetText( ( "Team Solutar" ) .. "(" .. team.NumPlayers( TEAM_SOLUTAR ) .. ")" )
- TeamSeekingButton:SetSize( 280, 280 )
- function TeamSeekingButton:Paint( w, h )
- return
- end
- function TeamSeekingButton:Think()
- self:SetText( ( "Team Solutar" ) .. "(" .. team.NumPlayers( TEAM_SOLUTAR ) .. ")" )
- end
- --spectate and auto buttons
- local TeamSpectateButton = vgui.Create( "DButton", TeamSelectFrame )
- TeamSpectateButton:SetPos( ScrW() / 2 - 300, 500 )
- TeamSpectateButton:SetSize( 600, 40 )
- TeamSpectateButton:SetFont("robot_small")
- TeamSpectateButton:SetText( ( "Zuschauen" ) )
- TeamSpectateButton:SetTextColor( clrs.lightgrey )
- function TeamSpectateButton.DoClick() self:HideTeam() RunConsoleCommand( "changeteam", TEAM_SPECTATOR ) end
- function TeamSpectateButton:Paint( w, h)
- draw.RoundedBox( 0, 0, 0, w, h, clrs.grey )
- end
- local TeamAutoButton = vgui.Create( "DButton", TeamSelectFrame )
- TeamAutoButton:SetPos( ScrW() / 2 - 300, 580 )
- TeamAutoButton:SetSize( 600, 40 )
- TeamAutoButton:SetFont("robot_small")
- TeamAutoButton:SetText( ( "Auto Team" ) )
- TeamAutoButton:SetTextColor( clrs.lightgrey )
- function TeamAutoButton.DoClick() self:HideTeam() RunConsoleCommand( "changeteam", team.BestAutoJoinTeam() ) end
- function TeamAutoButton:Paint( w, h)
- draw.RoundedBox( 0, 0, 0, w, h, clrs.grey )
- end
- TeamSelectFrame:SetSize( ScrW(), ScrH() )
- TeamSelectFrame:Center()
- TeamSelectFrame:MakePopup()
- TeamSelectFrame:SetKeyboardInputEnabled( false )
- function TeamSelectFrame:Paint(w,h)
- return
- end
- function TeamSelectFrame:Think()
- if GAMEMODE:GetRoundState() == NAV_GEN then
- self:Remove()
- self = nil
- end
- end
- local GMVersion = vgui.Create( "DLabel", TeamSelectFrame )
- GMVersion:SetPos( ScrW() - 400, ScrH() - 40 )
- GMVersion:SetSize( 400, 40 )
- GMVersion:SetFont("robot_medium")
- GMVersion:SetText( "Version " .. GAMEMODE.Version )
- GMVersion:SetTextColor( clrs.lightgrey )
- GMVersion:SetContentAlignment( 6 )
- function GMVersion:Paint( w, h)
- return
- end
- end
- function GM:IsBalancedToJoin( teamid )
- if LocalPlayer():Team() == teamid then return true end
- if teamid == TEAM_SOLUTAR then
- if team.NumPlayers( TEAM_SOLUTAR ) > team.NumPlayers( TEAM_JACK ) or (LocalPlayer():Team() == TEAM_JACK && team.NumPlayers( TEAM_SOLUTAR ) == team.NumPlayers( TEAM_JACK )) then
- return false
- end
- elseif teamid == TEAM_JACK then
- if team.NumPlayers( TEAM_JACK ) > team.NumPlayers( TEAM_SOLUTAR ) or (LocalPlayer():Team() == TEAM_SOLUTAR && team.NumPlayers( TEAM_SOLUTAR) == team.NumPlayers( TEAM_JACK )) then
- return false
- end
- end
- return true
- end
- function GM:HideTeam()
- if ( IsValid(TeamSelectFrame) ) then
- TeamSelectFrame:Remove()
- TeamSelectFrame = nil
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement