Ejemplo n.º 1
0
bool CASW_Briefing::IsCommanderSpeaking( int nLobbySlot )
{
	if ( gpGlobals->maxClients <= 1 )
		return false;

	UpdateLobbySlotMapping();

	C_ASW_Player *pPlayer = m_LobbySlotMapping[ nLobbySlot ].m_hPlayer.Get();
	if ( !pPlayer )
		return false;

	CVoiceStatus *pVoiceMgr = GetClientVoiceMgr();	
	if ( !pVoiceMgr )
		return false;

	int index = pPlayer->entindex();
	bool bTalking = false;
	if ( pPlayer == C_ASW_Player::GetLocalASWPlayer() )
	{
		bTalking = pVoiceMgr->IsLocalPlayerSpeakingAboveThreshold( FirstValidSplitScreenSlot() );
	}
	else
	{
		bTalking = pVoiceMgr->IsPlayerSpeaking( index );
	}
	return bTalking;
}
Ejemplo n.º 2
0
void asw_entindex_f()
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (pPlayer)
	{
		Msg("Hidehud is %d\n", pPlayer->m_Local.m_iHideHUD);		
		Msg("Local player entity index is %d\n", pPlayer->entindex());
		if (pPlayer->GetMarine())
		{
			Msg("  and your current marine's entity index is %d\n", pPlayer->GetMarine()->entindex());
			if (pPlayer->GetMarine()->GetMarineResource())
			{
				Msg("    and your current marine's marine info's entity index is %d\n", pPlayer->GetMarine()->GetMarineResource()->entindex());
			}
			else
			{
				Msg("    and your current marine has no marine info\n");
			}
		}
		else
		{
			Msg("  and you have no current marine\n");
		}
	}
	else
	{
		Msg("No local player!\n");
	}
}
Ejemplo n.º 3
0
CSteamID CASW_Briefing::GetCommanderSteamID( int nLobbySlot )
{
	CSteamID invalid_result;
	if ( nLobbySlot < 0 || nLobbySlot >= NUM_BRIEFING_LOBBY_SLOTS )
		return invalid_result;

	UpdateLobbySlotMapping();

	C_ASW_Player *pPlayer = m_LobbySlotMapping[ nLobbySlot ].m_hPlayer.Get();
	if ( !pPlayer )
		return invalid_result;

	int iIndex = pPlayer->entindex();
	player_info_t pi;
	if ( engine->GetPlayerInfo(iIndex, &pi) )
	{
		if ( pi.friendsID )
		{
			CSteamID steamIDForPlayer( pi.friendsID, 1, steamapicontext->SteamUtils()->GetConnectedUniverse(), k_EAccountTypeIndividual );
			return steamIDForPlayer;
		}
	}
	
	return invalid_result;
}
Ejemplo n.º 4
0
bool CASW_Briefing::AreOtherPlayersReady()
{
	if ( !ASWGameResource() )
		return false;

	C_ASW_Player *pLeader = ASWGameResource()->GetLeader();
	if ( !pLeader )
		return false;

	return ASWGameResource()->AreAllOtherPlayersReady( pLeader->entindex() );
}
Ejemplo n.º 5
0
void ReturnCampaignMapButton::OnThink()
{
	BaseClass::OnThink();

	C_ASW_Player* player = C_ASW_Player::GetLocalASWPlayer();
	if (!player || !ASWGameRules())
		return;

	C_ASW_Game_Resource *pGameResource = ASWGameResource();
	if (!pGameResource)
		return;

	bool bLeader = (player == pGameResource->GetLeader());

	// only show this button if you successfully complete a campaign mission - otherwise the start/ready button in the corner will offer restart options for the leader
	if (bLeader && ASWGameRules()->IsCampaignGame() && ASWGameRules()->GetMissionFailed())
	{		
		if (GetAlpha() <= 0)
		{
			SetAlpha(1);
			vgui::GetAnimationController()->RunAnimationCommand(this, "alpha", 255.0f, 0, 1.0f, vgui::AnimationController::INTERPOLATOR_LINEAR);
		}
		m_bCanReturn = pGameResource->AreAllOtherPlayersReady(player->entindex());

		if (m_bCanReturn)
		{
			SetButtonEnabled(true);
		}
		else
		{
			SetButtonEnabled(false);
		}
	}
	else
	{
		if (GetAlpha() > 0)
			SetAlpha(0);
	}	
}
Ejemplo n.º 6
0
void StatsReport::SetPlayerNames( void )
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return;

	int nMarine = 0;

	C_ASW_Game_Resource *pGameResource = ASWGameResource();

	for ( int i = 0; i < pGameResource->GetMaxMarineResources() && nMarine < ASW_STATS_REPORT_MAX_PLAYERS; i++ )
	{
		CASW_Marine_Resource *pMR = pGameResource->GetMarineResource( i );
		if ( pMR )
		{
			C_ASW_Player *pCommander = pMR->GetCommander();

			Color color = getColorPerIndex(pMR->GetCommanderIndex());

			if ( pPlayer != pCommander )
			{
				color[ 3 ] = 128;
			}

			m_pStatGraphPlayer->m_pStatGraphs[ nMarine ]->SetLineColor( color );
			m_pPlayerNames[ nMarine ]->SetFgColor( color );

			wchar_t wszMarineName[ 32 ];
			pMR->GetDisplayName( wszMarineName, sizeof( wszMarineName ) );

			m_pPlayerNames[ nMarine ]->SetText( wszMarineName );

			if ( gpGlobals->maxClients == 1 )
			{
				// Don't need these in singleplayer
				m_pAvatarImages[ nMarine ]->SetVisible( false );
				m_pReadyCheckImages[ nMarine ]->SetVisible( false );
			}
			else
			{
#if !defined(NO_STEAM)
				CSteamID steamID;

				if ( pCommander )
				{
					player_info_t pi;
					if ( engine->GetPlayerInfo( pCommander->entindex(), &pi ) )
					{
						if ( pi.friendsID )
						{
							CSteamID steamIDForPlayer( pi.friendsID, 1, steamapicontext->SteamUtils()->GetConnectedUniverse(), k_EAccountTypeIndividual );
							steamID = steamIDForPlayer;
						}
					}
				}

				if ( steamID.IsValid() )
				{
					m_pAvatarImages[ nMarine ]->SetAvatarBySteamID( &steamID );

					int wide, tall;
					m_pAvatarImages[ nMarine ]->GetSize( wide, tall );

					CAvatarImage *pImage = static_cast< CAvatarImage* >( m_pAvatarImages[ nMarine ]->GetImage() );
					if ( pImage )
					{
						pImage->SetAvatarSize( wide, tall );
						pImage->SetPos( -AVATAR_INDENT_X, -AVATAR_INDENT_Y );
					}
				}
#endif
			}

			nMarine++;
		}
	}

	while ( nMarine < ASW_STATS_REPORT_MAX_PLAYERS )
	{
		m_pAvatarImages[ nMarine ]->SetVisible( false );
		m_pReadyCheckImages[ nMarine ]->SetVisible( false );
		nMarine++;
	}
}
Ejemplo n.º 7
0
void PlayerListPanel::OnCommand( char const *cmd )
{
    if ( !Q_stricmp( cmd, "NewMissionVote" ) )
    {
        GetParent()->SetVisible(false);
        GetParent()->MarkForDeletion();
        Msg("PlayerListPanel::OnCommand sending asw_vote_chooser cc\n");
        if (ASWGameRules() && ASWGameRules()->GetGameState() == ASW_GS_INGAME)
            engine->ClientCmd("asw_vote_chooser 2");
        else
            engine->ClientCmd("asw_vote_chooser 2 notrans");
    }
    else if ( !Q_stricmp( cmd, "NewCampaignVote" ) )
    {
        GetParent()->SetVisible(false);
        GetParent()->MarkForDeletion();
        if (ASWGameRules() && ASWGameRules()->GetGameState() == ASW_GS_INGAME)
            engine->ClientCmd("asw_vote_chooser 0");
        else
            engine->ClientCmd("asw_vote_chooser 0 notrans");
    }
    else if ( !Q_stricmp( cmd, "NewSavedVote" ) )
    {
        GetParent()->SetVisible(false);
        GetParent()->MarkForDeletion();
        if (ASWGameRules() && ASWGameRules()->GetGameState() == ASW_GS_INGAME)
            engine->ClientCmd("asw_vote_chooser 1");
        else
            engine->ClientCmd("asw_vote_chooser 1 notrans");
    }
    else if ( !Q_stricmp( cmd, "VoteYes" ) )
    {
        GetParent()->SetVisible(false);
        GetParent()->MarkForDeletion();
        engine->ClientCmd("vote_yes");
    }
    else if ( !Q_stricmp( cmd, "VoteNo" ) )
    {
        GetParent()->SetVisible(false);
        GetParent()->MarkForDeletion();
        engine->ClientCmd("vote_no");
    }
    else if ( !Q_stricmp( cmd, "Back" ) )
    {
        GetParent()->SetVisible(false);
        GetParent()->MarkForDeletion();
    }
    else if ( !Q_stricmp( cmd, "RestartMis" ) )
    {
        C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
        if (!pPlayer)
            return;
        bool bLeader = pPlayer && ASWGameResource() && ASWGameResource()->GetLeaderEntIndex() == pPlayer->entindex();
        if (!bLeader)
            return;

        bool bCanStart = ASWGameRules() &&
                         ( (ASWGameRules()->GetGameState() <= ASW_GS_INGAME)
                           || (ASWGameResource() && ASWGameResource()->AreAllOtherPlayersReady(pPlayer->entindex()) ) );

        if (bCanStart)
        {
            GetParent()->SetVisible(false);
            GetParent()->MarkForDeletion();
            engine->ClientCmd("asw_restart_mission");
        }
        else
        {
            if (GetParent() && GetParent()->GetParent())
            {
                vgui::Panel *p = new ForceReadyPanel(GetParent()->GetParent(), "ForceReady", "#asw_force_restartm", ASW_FR_RESTART);
                p->SetZPos(201);	// make sure it's in front of the player list
            }
        }
    }
    else
    {
        BaseClass::OnCommand( cmd );
    }
}
Ejemplo n.º 8
0
void PlayerListPanel::OnThink()
{
    // make sure we have enough line panels per player and that each line knows the index of the player its displaying
    int iNumPlayersInGame = 0;
    bool bNeedsLayout = false;
    for ( int j = 1; j <= gpGlobals->maxClients; j++ )
    {
        if ( g_PR->IsConnected( j ) )
        {
            iNumPlayersInGame++;
            while (m_PlayerLine.Count() <= iNumPlayersInGame)
            {
                // temp comment
                m_PlayerLine.AddToTail(new PlayerListLine(this, "PlayerLine"));
            }
            if ( m_PlayerLine.Count() > ( iNumPlayersInGame - 1 ) && m_PlayerLine[ iNumPlayersInGame - 1 ] )
            {
                m_PlayerLine[iNumPlayersInGame-1]->SetVisible(true);
                if (m_PlayerLine[iNumPlayersInGame-1]->SetPlayerIndex(j))
                {
                    bNeedsLayout = true;
                }
            }
        }
    }

    // hide any extra ones we might have
    for (int i=iNumPlayersInGame; i<m_PlayerLine.Count(); i++)
    {
        m_PlayerLine[i]->SetVisible(false);
    }

    UpdateVoteButtons();
    UpdateKickLeaderTicks();
    if (gpGlobals->curtime > m_fUpdateDifficultyTime)
    {
        MissionStatsPanel::SetMissionLabels(m_pMissionLabel, m_pDifficultyLabel);
        m_fUpdateDifficultyTime = gpGlobals->curtime + 1.0f;
    }

    C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
    bool bShowRestart = pPlayer && ASWGameResource() && (ASWGameResource()->GetLeaderEntIndex() == pPlayer->entindex());
    if ( ASWGameRules() && ASWGameRules()->IsIntroMap() )
        bShowRestart = false;
    //Msg("bLeader = %d leaderentindex=%d player entindex=%d\n", bLeader, ASWGameResource()->GetLeaderEntIndex(), pPlayer->entindex());
    m_pRestartMissionButton->SetVisible(bShowRestart);
    m_pLeaderButtonsBackground->SetVisible(bShowRestart);

    UpdateServerName();

    if (bNeedsLayout)
        InvalidateLayout(true);
}
Ejemplo n.º 9
0
void CASW_Briefing::UpdateLobbySlotMapping()
{
	if ( m_nLastLobbySlotMappingFrame == gpGlobals->framecount )		// don't update twice in one frame
		return;

	m_nLastLobbySlotMappingFrame = gpGlobals->framecount;

	if ( !ASWGameResource() )
		return;

	C_ASW_Player *pLocalPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pLocalPlayer )
		return;

	if ( IsOfflineGame() )
	{
		// just map marine resources to slots directly		
		for ( int i = 0; i < ASWGameResource()->GetMaxMarineResources() && i < NUM_BRIEFING_LOBBY_SLOTS; i++ )
		{
			C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource( i );
			if ( !pMR )
			{
				if ( i == 0 )
				{
					m_LobbySlotMapping[ i ].m_nPlayerEntIndex = pLocalPlayer->entindex();
					m_LobbySlotMapping[ i ].m_hPlayer = pLocalPlayer;
				}
				else
				{
					m_LobbySlotMapping[ i ].m_nPlayerEntIndex = -1;
					m_LobbySlotMapping[ i ].m_hPlayer = NULL;
				}
				m_LobbySlotMapping[ i ].m_nMarineResourceIndex = -1;
				m_LobbySlotMapping[ i ].m_hMR = NULL;
			}
			else
			{
				m_LobbySlotMapping[ i ].m_nPlayerEntIndex = pLocalPlayer->entindex();
				m_LobbySlotMapping[ i ].m_hPlayer = pLocalPlayer;
				m_LobbySlotMapping[ i ].m_nMarineResourceIndex = i;
				m_LobbySlotMapping[ i ].m_hMR = pMR;
			}
		}
		return;
	}

	// lobby slot 0 is always reserved for the local player
	m_LobbySlotMapping[ 0 ].m_nPlayerEntIndex = pLocalPlayer->entindex();
	m_LobbySlotMapping[ 0 ].m_hPlayer = pLocalPlayer;
	m_LobbySlotMapping[ 0 ].m_nMarineResourceIndex = -1;
	m_LobbySlotMapping[ 0 ].m_hMR = NULL;

	for ( int i = 0; i < ASWGameResource()->GetMaxMarineResources(); i++ )
	{
		C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource( i );
		if ( !pMR || pMR->GetCommander() != pLocalPlayer )
			continue;

		m_LobbySlotMapping[ 0 ].m_nMarineResourceIndex = i;
		m_LobbySlotMapping[ 0 ].m_hMR = pMR;
		break;
	}

	int nSlot = 1;
	
	// if the player has any other marines selected, they come first
	for ( int i = 0; i < ASWGameResource()->GetMaxMarineResources(); i++ )
	{
		C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource( i );
		if ( !pMR || pMR->GetCommander() != pLocalPlayer )
			continue;
		
		bool bAlreadyInList = false;
		for ( int k = 0; k < nSlot; k++ )
		{
			if ( pMR == m_LobbySlotMapping[ k ].m_hMR.Get() )
			{
				bAlreadyInList = true;
				break;
			}
		}

		if ( bAlreadyInList )
			continue;

		m_LobbySlotMapping[ nSlot ].m_nPlayerEntIndex = pLocalPlayer->entindex();
		m_LobbySlotMapping[ nSlot ].m_hPlayer = pLocalPlayer;
		m_LobbySlotMapping[ nSlot ].m_hMR = pMR;
		m_LobbySlotMapping[ nSlot ].m_nMarineResourceIndex = i;

		nSlot++;
		if ( nSlot >= NUM_BRIEFING_LOBBY_SLOTS )
			break;
	}

	if ( nSlot >= NUM_BRIEFING_LOBBY_SLOTS )
		return;

	// now add marines for other players in order
	for( int iClient = 1; iClient < MAX_PLAYERS; iClient++ )
	{
		if ( !g_PR->IsConnected( iClient ) )
			continue;

		if ( iClient == pLocalPlayer->entindex() )
			continue;

		for ( int i = 0; i < ASWGameResource()->GetMaxMarineResources(); i++ )
		{
			C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource( i );
			if ( !pMR || pMR->m_iCommanderIndex != iClient )
				continue;

			bool bAlreadyInList = false;
			for ( int k = 0; k < nSlot; k++ )
			{
				if ( pMR == m_LobbySlotMapping[ k ].m_hMR.Get() )
				{
					bAlreadyInList = true;
					break;
				}
			}

			if ( bAlreadyInList )
				continue;

			m_LobbySlotMapping[ nSlot ].m_nPlayerEntIndex = iClient;
			m_LobbySlotMapping[ nSlot ].m_hPlayer = static_cast<C_ASW_Player*>( UTIL_PlayerByIndex( iClient ) );
			m_LobbySlotMapping[ nSlot ].m_hMR = pMR;
			m_LobbySlotMapping[ nSlot ].m_nMarineResourceIndex = i;

			nSlot++;
			if ( nSlot >= NUM_BRIEFING_LOBBY_SLOTS )
				break;
		}
	}

	if ( nSlot >= NUM_BRIEFING_LOBBY_SLOTS )
		return;

	// now add any players who don't have any marines
	for( int iClient = 1; iClient < MAX_PLAYERS; iClient++ )
	{
		if ( !g_PR->IsConnected( iClient ) )
			continue;

		if ( iClient == pLocalPlayer->entindex() )
			continue;

		int nMarines = 0;
		for ( int i = 0; i < ASWGameResource()->GetMaxMarineResources(); i++ )
		{
			C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource( i );
			if ( !pMR || pMR->m_iCommanderIndex != iClient )
				continue;

			nMarines++;
		}

		if ( nMarines == 0)
		{
			m_LobbySlotMapping[ nSlot ].m_nPlayerEntIndex = iClient;
			m_LobbySlotMapping[ nSlot ].m_hPlayer = static_cast<C_ASW_Player*>( UTIL_PlayerByIndex( iClient ) );
			m_LobbySlotMapping[ nSlot ].m_hMR = NULL;
			m_LobbySlotMapping[ nSlot ].m_nMarineResourceIndex = -1;

			nSlot++;
			if ( nSlot >= NUM_BRIEFING_LOBBY_SLOTS )
				break;
		}
	}

	for ( int k = nSlot; k < NUM_BRIEFING_LOBBY_SLOTS; k++ )
	{
		m_LobbySlotMapping[ k ].m_nPlayerEntIndex = -1;
		m_LobbySlotMapping[ k ].m_hPlayer = NULL;
		m_LobbySlotMapping[ k ].m_hMR = NULL;
		m_LobbySlotMapping[ k ].m_nMarineResourceIndex = -1;
	}
}
Ejemplo n.º 10
0
void MissionCompletePanel::OnCommand(const char* command)
{
	C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer || !ASWGameRules() )
		return;

	C_ASW_Game_Resource *pGameResource = ASWGameResource();
	if ( !pGameResource )
		return;

	bool bLeader = ( pPlayer == pGameResource->GetLeader() );

	if ( !Q_stricmp( command, "XPTab" ) )
	{
		m_PropertySheet->SetActivePage( m_PropertySheet->GetPage( 0 ) );
		if ( !ASWGameRules()->GetMissionSuccess() )
		{
			m_pHeaderFooter->SetTitle("#asw_mission_failed");
		}
		else
		{
			m_pHeaderFooter->SetTitle( "#asw_summary" );
		}
	}
	else if ( !Q_stricmp( command, "StatsTab" ) )
	{
		m_PropertySheet->SetActivePage( m_PropertySheet->GetPage( 1 ) );
		m_pHeaderFooter->SetTitle( "#asw_stats_tab" );
		m_bViewedStatsPage = true;
	}
	else if ( !Q_stricmp( command, "Restart" ) )
	{
		if ( !bLeader )
			return;

		bool bAllReady = pGameResource->AreAllOtherPlayersReady( pPlayer->entindex() );
		if ( bAllReady )
		{
			pPlayer->RequestMissionRestart();
		}
		else
		{
			// ForceReadyPanel* pForceReady = 
			engine->ClientCmd("cl_wants_restart"); // notify other players that we're waiting on them
			new ForceReadyPanel(GetParent(), "ForceReady", "#asw_force_restartm", ASW_FR_RESTART);
		}
	}
	else if ( !Q_stricmp( command, "Ready" ) )
	{
		// just make us ready
		pPlayer->StartReady();
	}
	else if ( !Q_stricmp( command, "Continue" ) )
	{
		if ( ASWGameRules()->GetMissionSuccess() && ASWGameRules()->IsCampaignGame() && ASWGameRules()->CampaignMissionsLeft() <= 1 )
		{
			if ( !m_bCreditsSeen )
			{
				C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
				if ( pPlayer )
				{
					m_pStatsPanel->m_pDebrief->m_pPara[0]->SetVisible( false );
					m_pStatsPanel->m_pDebrief->m_pPara[1]->SetVisible( false );
					m_pStatsPanel->m_pDebrief->m_pPara[2]->SetVisible( false );
					pPlayer->LaunchCredits( m_pStatsPanel->m_pDebrief->m_pBackground->m_pBackgroundInner );
					m_bCreditsSeen = true;
					UpdateVisibleButtons();
				}
			}
			else
			{
				// Vote on a new mission
				engine->ClientCmd("asw_vote_chooser 0 notrans");
			}
		}
		else if ( bLeader )
		{
			bool bAllReady = pGameResource->AreAllOtherPlayersReady( pPlayer->entindex() );
			if ( bAllReady )
			{
				if ( ASWGameRules()->IsCampaignGame() && ASWGameRules()->GetMissionSuccess() )   // completed a campaign map
				{
					pPlayer->CampaignSaveAndShow();
				}
				else
				{
					// TODO: Proceed to the next mission, pop up a mission selection dialog, etc?
					// just do a restart for now
					pPlayer->RequestMissionRestart();
				}
			}
			else
			{
				if ( ASWGameRules()->GetMissionSuccess() && ASWGameRules()->IsCampaignGame() )
				{
					// ForceReadyPanel* pForceReady = 
					engine->ClientCmd("cl_wants_continue");	// notify other players that we're waiting on them
					new ForceReadyPanel(GetParent(), "ForceReady", "#asw_force_continuem", ASW_FR_CONTINUE);
				}
				else
				{
					// TODO: Proceed to the next mission, pop up a mission selection dialog, etc?
					// just do a restart for now
					// ForceReadyPanel* pForceReady = 
					engine->ClientCmd("cl_wants_restart"); // notify other players that we're waiting on them
					new ForceReadyPanel(GetParent(), "ForceReady", "#asw_force_restartm", ASW_FR_RESTART);
				}
			}
		}

		return;
	}

	BaseClass::OnCommand(command);
}
Ejemplo n.º 11
0
void MissionCompletePanel::ShowImageAndPlaySound()
{
	if ( m_pResultImage )
	{
		m_pResultImage->MarkForDeletion();
	}
	m_pResultImage = new CMission_Complete_Message( this, "MissionCompleteMessage" );
	m_pResultImage->StartMessage( m_bSuccess );

	m_pResultImage->SetMouseInputEnabled( false );


	// set up fail advice
	if ( m_bSuccess )
	{
		m_pFailAdvice->SetText( "" );
	}
	else
	{
		m_pFailAdvice->SetText( ASWGameRules()->GetFailAdviceText() );
		m_pHeaderFooter->SetAlpha( 0 );
	}

	// play sound
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( pPlayer )
	{
		if ( m_bSuccess )
		{
			pPlayer->EmitSound( "Game.MissionWon" );
			CLocalPlayerFilter filter;
			C_BaseEntity::EmitSound( filter, pPlayer->entindex(), "asw_song.statsSuccess", NULL, gpGlobals->curtime + asw_success_sound_delay.GetFloat() );
		}
		else
		{
			pPlayer->EmitSound( "Game.MissionLost" );
			CLocalPlayerFilter filter;
			C_BaseEntity::EmitSound( filter, pPlayer->entindex(), "asw_song.statsFail", NULL, gpGlobals->curtime + asw_fail_sound_delay.GetFloat() );
		}
	}	

	m_pFailAdvice->SetAlpha(0);
	m_pIconForwardArrow->SetAlpha(0);
	vgui::GetAnimationController()->RunAnimationCommand(this, "alpha", 255, 0, 1.5f, vgui::AnimationController::INTERPOLATOR_LINEAR);	
	vgui::GetAnimationController()->RunAnimationCommand(m_pFailAdvice, "alpha", 255, 1.5f, 2.0f, vgui::AnimationController::INTERPOLATOR_LINEAR);	
	if ( m_pFailedHeaderFooter )
	{
		vgui::GetAnimationController()->RunAnimationCommand(m_pIconForwardArrow, "alpha", 255, 1.5f, 2.0f, vgui::AnimationController::INTERPOLATOR_LINEAR);	
		vgui::GetAnimationController()->RunAnimationCommand(m_pFailedHeaderFooter, "alpha", 255, 0.0f, 1.0f, vgui::AnimationController::INTERPOLATOR_LINEAR);	
	}
	MissionCompleteFrame *pFrame = dynamic_cast<MissionCompleteFrame*>(GetParent());
	if ( pFrame )
	{
		pFrame->m_bFadeInBackground = true;
	}
	m_pMainElements->SetAlpha(0);	// hide everything else for now
	m_pHeaderFooter->m_pTitle->SetAlpha( 0 );
	m_pMissionName->SetAlpha( 0 );

	InvalidateLayout();

	m_iStage = MCP_STAGE_FAILSUCCESS;
	if ( m_bSuccess )
	{
		if ( ASWGameRules() && ASWGameRules()->IsCampaignGame() && ASWGameRules()->CampaignMissionsLeft() <= 1 )
		{
			m_fNextStageTime = gpGlobals->curtime + 6.0f;
		}
		else
		{
			m_fNextStageTime = gpGlobals->curtime + 4.0f;
		}
	}
	else
	{
		m_fNextStageTime = gpGlobals->curtime + 6.0f;
	}
}
Ejemplo n.º 12
0
void C_ASW_Hack_Wire_Tile::ClientThink()
{
	HACK_GETLOCALPLAYER_GUARD( "Need to support launching multiple hack panels on one machine (1 for each splitscreen player) for this to make sense." );
	if (m_bLaunchedHackPanel)	// if we've launched our hack window, but the hack has lost its hacking marine, then close our window down
	{		
		bool bStillUsing = true;
		if (!GetHackerMarineResource())
			bStillUsing = false;

		if (!bStillUsing)
		{
			//Msg("wire hack has lost his hacking marine\n");
			m_bLaunchedHackPanel = false;
			if (m_hFrame.Get())
			{
				m_hFrame->SetVisible(false);
				m_hFrame->MarkForDeletion();
				m_hFrame = NULL;
				ASWInput()->SetCameraFixed( false );
			}
		}
	}
	// if we haven't launched the window and data is all present, launch it
	if (!m_bLaunchedHackPanel && m_iNumWires > 0 && GetHackerMarineResource() != NULL)
	{
		vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFile("resource/SwarmSchemeNew.res", "SwarmSchemeNew");

		m_hFrame = new CASW_VGUI_Hack_Wire_Tile_Container( GetClientMode()->GetViewport(), "WireTileContainer", this);
		m_hFrame->SetScheme(scheme);					

		CASW_VGUI_Hack_Wire_Tile* pHackWireFrame = new CASW_VGUI_Hack_Wire_Tile( m_hFrame.Get(), "HackWireTile", this );
		pHackWireFrame->SetScheme(scheme);	
		pHackWireFrame->ASWInit();	
		pHackWireFrame->MoveToFront();
		pHackWireFrame->RequestFocus();
		pHackWireFrame->SetVisible(true);
		pHackWireFrame->SetEnabled(true);
		m_bLaunchedHackPanel = true;
	}
	// check for hiding the panel if the player has a different marine selected, or if the selected marine is remote controlling a turret
	if (m_bLaunchedHackPanel && GetHackerMarineResource() && m_hFrame.Get())
	{
		C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();		
		if (!pPlayer)
		{
			m_hFrame->SetVisible(false);
		}
		else
		{
			bool bLocalPlayerControllingHacker = (GetHackerMarineResource()->IsInhabited() && GetHackerMarineResource()->GetCommanderIndex() == pPlayer->entindex());
			bool bMarineControllingTurret = (GetHackerMarineResource()->GetMarineEntity() && GetHackerMarineResource()->GetMarineEntity()->IsControllingTurret());

			if (bLocalPlayerControllingHacker && !bMarineControllingTurret)
			{
				ASWInput()->SetCameraFixed( true );

				m_hFrame->SetVisible(true);

				if (gpGlobals->curtime > m_fNextLockCycleTime)
				{
					m_fNextLockCycleTime = gpGlobals->curtime + asw_hack_cycle_time.GetFloat();
					CycleRows();
				}
			}
			else
			{
				ASWInput()->SetCameraFixed( false );

				m_hFrame->SetVisible(false);
			}
		}
	}	
}
Ejemplo n.º 13
0
void CASWHudCrosshair::Paint( void )
{
	VPROF_BUDGET( "CASWHudCrosshair::Paint", VPROF_BUDGETGROUP_ASW_CLIENT );
	if ( !crosshair.GetBool() )
		return;

	if ( engine->IsDrawingLoadingImage() || engine->IsPaused() || !engine->IsActiveApp() )
		return;
	
	C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return;

	if ( pPlayer->GetFlags() & FL_FROZEN )
		return;

	if ( pPlayer->entindex() != render->GetViewEntity() )
		return;

	m_curViewAngles = CurrentViewAngles();
	m_curViewOrigin = CurrentViewOrigin();

	C_ASW_Marine *pMarine = pPlayer->GetViewMarine();
	bool bControllingTurret = (pMarine && pMarine->IsControllingTurret());
	if ( bControllingTurret )
	{
		PaintTurretTextures();
		return;	// don't draw the normal cross hair in addition
	}

	int x, y;
	GetCurrentPos( x, y );

	int nCrosshair = GetCurrentCrosshair( x, y );

	if ( nCrosshair == m_nCrosshairTexture )
	{
		if ( pPlayer->IsSniperScopeActive() )
		{
			DrawSniperScope( x, y );
		}
		else
		{
			if ( pPlayer->GetASWControls() != 1 )
				return;
			DrawDirectionalCrosshair( x, y, YRES( asw_crosshair_progress_size.GetInt() ) );
		}
	}
	else if ( nCrosshair != -1 )
	{
		const float fCrosshairScale = 1.0f;
		int w = YRES( 20 ) * fCrosshairScale;
		int h = YRES( 20 ) * fCrosshairScale;
		surface()->DrawSetColor( m_clrCrosshair );
		surface()->DrawSetTexture( nCrosshair );
		surface()->DrawTexturedRect( x - w, y - h, x + w, y + h );
	}

	// icons attached to the cursor
	x += 32; y += 16;	// move them down and to the right a bit
	if ( m_bShowGiveAmmo )
	{
		// todo: this text should in the ammo report tooltip?
		const wchar_t *ammoName = g_pVGuiLocalize->Find(GetAmmoName(m_iShowGiveAmmoType));
		DrawAttachedIcon(m_nGiveAmmoTexture, x, y, ammoName);
	}
	else if (m_bShowGiveHealth)
	{
		DrawAttachedIcon(m_nGiveHealthTexture, x, y);
	}
}