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); } }
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); }
void MissionCompletePanel::UpdateVisibleButtons() { if ( gpGlobals->maxClients <= 1 && !asw_show_stats_in_singleplayer.GetBool() ) { m_pNextButton->SetVisible( false ); m_pRestartButton->SetVisible( false ); m_pReadyButton->SetVisible( false ); m_pReadyCheckImage->SetVisible( false ); m_pContinueButton->SetVisible( false ); m_pTab[ 0 ]->SetVisible( false ); m_pTab[ 1 ]->SetVisible( false ); return; } 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()); if ( !m_bViewedStatsPage ) { if ( ( m_pExperienceReport->m_bDoneAnimating || gpGlobals->curtime > m_flForceVisibleButtonsTime ) && m_iStage >= MCP_STAGE_STATS ) { m_pNextButton->SetVisible( true ); } else { m_pNextButton->SetVisible( false ); } m_pRestartButton->SetVisible( false ); m_pReadyButton->SetVisible( false ); m_pReadyCheckImage->SetVisible( false ); m_pContinueButton->SetVisible( false ); m_pTab[ 0 ]->SetVisible( false ); m_pTab[ 1 ]->SetVisible( false ); } else { if ( bLeader ) { m_pReadyButton->SetVisible( false ); m_pReadyCheckImage->SetVisible( false ); if ( ASWGameRules()->GetMissionSuccess() ) { if ( ASWGameRules()->IsCampaignGame() && ASWGameRules()->CampaignMissionsLeft() <= 1 ) { if ( !m_bCreditsSeen ) { m_pContinueButton->SetText( "#asw_button_credits" ); } else { m_pContinueButton->SetText( "#asw_button_new_campaign" ); } } else { m_pContinueButton->SetText( "#asw_button_continue" ); } m_pContinueButton->SetVisible( true ); m_pRestartButton->SetVisible( false ); } else { m_pContinueButton->SetVisible( false ); m_pRestartButton->SetVisible( true ); } } else { if ( ASWGameRules()->GetMissionSuccess() && ASWGameRules()->IsCampaignGame() && ASWGameRules()->CampaignMissionsLeft() <= 1 ) { if ( !m_bCreditsSeen ) { m_pContinueButton->SetText( "#asw_button_credits" ); } else { m_pContinueButton->SetText( "#asw_button_new_campaign" ); } m_pContinueButton->SetVisible( true ); m_pReadyButton->SetVisible( false ); m_pReadyCheckImage->SetVisible( false ); } else { m_pContinueButton->SetVisible( false ); m_pReadyButton->SetVisible( true ); m_pReadyCheckImage->SetVisible( true ); } m_pRestartButton->SetVisible( false ); if ( ASWGameResource()->IsPlayerReady( player ) ) { m_pReadyCheckImage->SetImage( "swarm/HUD/TickBoxTicked" ); } else { m_pReadyCheckImage->SetImage( "swarm/HUD/TickBoxEmpty" ); } } m_pTab[ 0 ]->SetVisible( true ); m_pTab[ 1 ]->SetVisible( true ); } }