void CASWHud3DMarineNames::PaintMarineNameLabels() { C_ASW_Player *local = C_ASW_Player::GetLocalASWPlayer(); if ( !local ) return; C_ASW_Game_Resource *pGameResource = ASWGameResource(); if ( !pGameResource ) return; int count = 0; int my_count = 0; for ( int i = 0; i < pGameResource->GetMaxMarineResources(); i++ ) { C_ASW_Marine_Resource *pMR = pGameResource->GetMarineResource( i ); if ( pMR && pMR->GetHealthPercent() > 0 ) { C_ASW_Marine *pMarine = pMR->GetMarineEntity(); if ( pMarine ) { if ( pMarine->GetCommander() == local ) { PaintMarineLabel( my_count, pMarine, pMR, local->GetMarine() == pMarine ); my_count++; } else { PaintMarineLabel( -1, pMarine, pMR, false ); } count++; } } } }
void MissionCompleteStatsLine::UpdateLabels() { C_ASW_Game_Resource* pGameResource = ASWGameResource(); if (!pGameResource) return; if (m_iMarineIndex <0 || m_iMarineIndex>=pGameResource->GetMaxMarineResources()) { m_pNameLabel->SetText(""); m_pMedalArea->SetMarineResource(NULL); Q_snprintf(m_szCurrentName, sizeof(m_szCurrentName), ""); return; } C_ASW_Marine_Resource* pMR = pGameResource->GetMarineResource(m_iMarineIndex); if (m_pMedalArea) m_pMedalArea->SetMarineResource(pMR); if (pMR) { if ( pMR->GetProfile() && Q_strcmp( pMR->GetProfile()->m_ShortName, m_szCurrentName ) ) { m_pNameLabel->SetText(pMR->GetProfile()->m_ShortName); Q_snprintf(m_szCurrentName, sizeof(m_szCurrentName), "%s", pMR->GetProfile()->m_ShortName); } SetBgColor(m_pBGColor); } else { m_pNameLabel->SetText(""); } // todo: reset stats bars }
void CASWHudPortraits::OnThink() { VPROF_BUDGET( "CASWHudPortraits::OnThink", VPROF_BUDGETGROUP_ASW_CLIENT ); int iNumMyMarines = 0; int iNumOtherMarines = 0; C_ASW_Player *local = C_ASW_Player::GetLocalASWPlayer(); if ( local ) { C_ASW_Game_Resource* pGameResource = ASWGameResource(); if (pGameResource) { for (int i=0; i<pGameResource->GetMaxMarineResources(); i++) { C_ASW_Marine_Resource* pMR = pGameResource->GetMarineResource(i); if (pMR) { if (pMR->GetCommander() == local) { m_hMyMarine[iNumMyMarines] = pMR; iNumMyMarines++; if (pMR->GetMarineEntity() == local->GetMarine()) m_hCurrentlySelectedMarineResource = pMR; } else if (!(ASWGameRules() && ASWGameRules()->IsTutorialMap())) // in tutorial, don't show marines not under your command { m_hOtherMarine[iNumOtherMarines] = pMR; iNumOtherMarines++; } } } // clear out future slots for (int i=iNumMyMarines; i<ASW_MAX_MARINE_RESOURCES; i++) { m_hMyMarine[i] == NULL; } for (int i=iNumOtherMarines; i<ASW_MAX_MARINE_RESOURCES; i++) { m_hOtherMarine[i] == NULL; } } } // JOYPAD REMOVED //bool bJoypadModeChanged = (m_bLastJoypadMode != engine->ASW_IsJoypadMode()); //m_bLastJoypadMode = engine->ASW_IsJoypadMode(); bool bJoypadModeChanged = m_bLastJoypadMode = false; bool bResize = ((m_iNumMyMarines != iNumMyMarines) || (m_iNumOtherMarines != iNumOtherMarines) || bJoypadModeChanged); m_iNumMyMarines = iNumMyMarines; m_iNumOtherMarines = iNumOtherMarines; UpdatePortraits(bResize); }
void StatsReport::OnThink() { int nMarine = 0; m_pObjectiveMap->ClearBlips(); 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 ) { Vector vPos; vPos.x = pMR->m_TimelinePosX.GetValueAtInterp( m_pStatGraphPlayer->m_fTimeInterp ); vPos.y = pMR->m_TimelinePosY.GetValueAtInterp( m_pStatGraphPlayer->m_fTimeInterp ); vPos.z = 0.0f; bool bDead = ( pMR->m_TimelineHealth.GetValueAtInterp( m_pStatGraphPlayer->m_fTimeInterp ) <= 0.0f ); m_pObjectiveMap->AddBlip( MapBlip_t( vPos, bDead ? Color( 255, 255, 255, 255 ) : getColorPerIndex(pMR->GetCommanderIndex()), bDead ? MAP_BLIP_TEXTURE_DEATH : MAP_BLIP_TEXTURE_NORMAL ) ); if ( m_pReadyCheckImages[ nMarine ]->IsVisible() ) { C_ASW_Player *pPlayer = pMR->GetCommander(); if ( pPlayer ) { if ( !pMR->IsInhabited() || ASWGameResource()->IsPlayerReady( pPlayer ) ) { m_pReadyCheckImages[ i ]->SetImage( "swarm/HUD/TickBoxTicked" ); } else if ( pPlayer == ASWGameResource()->GetLeader() ) { m_pReadyCheckImages[ i ]->SetImage( "swarm/PlayerList/LeaderIcon" ); } else { m_pReadyCheckImages[ i ]->SetImage( "swarm/HUD/TickBoxEmpty" ); } } } nMarine++; } } for ( int i = 0; i < ASW_STATS_REPORT_MAX_PLAYERS; i++ ) { } }
void CASWHudEmotes::PaintEmotes() { C_ASW_Game_Resource *pGameResource = ASWGameResource(); if (!pGameResource) return; for (int i=0; i<pGameResource->GetMaxMarineResources(); i++) { C_ASW_Marine_Resource *pMR = pGameResource->GetMarineResource(i); if (!pMR) continue; C_ASW_Marine *marine = pMR->GetMarineEntity(); if ( !marine ) continue; PaintEmotesFor(marine); } }
void ListMarineResources(void) { C_ASW_Game_Resource *pGameResource = ASWGameResource(); if ( !pGameResource ) return; for (int i=0;i<pGameResource->GetMaxMarineResources();i++) { if (pGameResource->GetMarineResource(i) == NULL) Msg("MarineResource %d = empty\n", i); else { Msg("MarineResource %d = present, profileindex %d, commander %d commander index %d\n", i, pGameResource->GetMarineResource(i)->m_MarineProfileIndex, pGameResource->GetMarineResource(i)->GetCommander(), pGameResource->GetMarineResource(i)->GetCommanderIndex()); } } }
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++; } }
// fills in all the bars and labels with the current players and their XP values void StatsReport::SetStatCategory( int nCategory ) { for ( int i = 0; i < ASW_STATS_REPORT_CATEGORIES; ++i ) { m_pCategoryButtons[ i ]->SetDefaultColor( Color( 100, 100, 100, 255 ), Color( 35, 41, 57, 90 ) ); } m_pCategoryButtons[ nCategory ]->SetDefaultColor( Color( 255, 255, 255, 255 ), Color( 35, 41, 57, 192 ) ); int nRankOrder[ ASW_STATS_REPORT_MAX_PLAYERS ]; float fBestValues[ ASW_STATS_REPORT_MAX_PLAYERS ]; for ( int i = 0; i < ASW_STATS_REPORT_MAX_PLAYERS; ++i ) { nRankOrder[ i ] = i; } //float fMinValue = FLT_MAX; float fMaxValue = -FLT_MAX; 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 ) { switch ( nCategory ) { case 0: m_pStatGraphPlayer->m_pStatGraphs[ nMarine ]->SetTimeline( &pMR->m_TimelineFriendlyFire ); fMaxValue = MAX( fMaxValue, 50.0f ); break; case 1: m_pStatGraphPlayer->m_pStatGraphs[ nMarine ]->SetTimeline( &pMR->m_TimelineKillsTotal ); break; case 2: m_pStatGraphPlayer->m_pStatGraphs[ nMarine ]->SetTimeline( &pMR->m_TimelineHealth ); break; case 3: m_pStatGraphPlayer->m_pStatGraphs[ nMarine ]->SetTimeline( &pMR->m_TimelineAmmo ); break; } fBestValues[ nMarine ] = m_pStatGraphPlayer->m_pStatGraphs[ nMarine ]->GetFinalValue(); //fMinValue = MIN( fMinValue, m_pStatGraphPlayer->m_pStatGraphs[ nMarine ]->GetTroughValue() ); fMaxValue = MAX( fMaxValue, m_pStatGraphPlayer->m_pStatGraphs[ nMarine ]->GetCrestValue() ); nMarine++; } } // Sort the names based on who did the best in this category for ( int i = 0; i < ASW_STATS_REPORT_MAX_PLAYERS - 1; ++i ) { for ( int j = 0; j < ASW_STATS_REPORT_MAX_PLAYERS - 1 - i; ++j ) { if ( fBestValues[ j ] < fBestValues[ j + 1 ] ) { float fTemp = fBestValues[ j ]; fBestValues[ j ] = fBestValues[ j + 1 ]; fBestValues[ j + 1 ] = fTemp; int nTemp = nRankOrder[ j ]; nRankOrder[ j ] = nRankOrder[ j + 1 ]; nRankOrder[ j + 1 ] = nTemp; } } } // Physically position all the marine names in their ranked order for ( int i = 0; i < ASW_STATS_REPORT_MAX_PLAYERS; ++i ) { m_pStatGraphPlayer->m_pStatGraphs[ i ]->SetMinMaxValues( 0.0f, fMaxValue ); vgui::GetAnimationController()->RunAnimationCommand( m_pPlayerNames[ nRankOrder[ i ] ], "ypos", m_fPlayerNamePosY[ i ], 0, 0.25f, vgui::AnimationController::INTERPOLATOR_LINEAR ); vgui::GetAnimationController()->RunAnimationCommand( m_pAvatarImages[ nRankOrder[ i ] ], "ypos", m_fPlayerNamePosY[ i ], 0, 0.25f, vgui::AnimationController::INTERPOLATOR_LINEAR ); vgui::GetAnimationController()->RunAnimationCommand( m_pReadyCheckImages[ nRankOrder[ i ] ], "ypos", m_fPlayerNamePosY[ i ], 0, 0.25f, vgui::AnimationController::INTERPOLATOR_LINEAR ); } m_pStatGraphPlayer->InvalidateLayout( true ); }