//----------------------------------------------------------------------------- // Frame-based update //----------------------------------------------------------------------------- void CVehicleFlatbedControlPanel::OnTick() { BaseClass::OnTick(); C_BaseObject *pObj = GetOwningObject(); if (!pObj) return; Assert( dynamic_cast<C_VehicleFlatbed*>(pObj) ); C_VehicleFlatbed *pRam = static_cast<C_VehicleFlatbed*>(pObj); char buf[256]; // Update the currently manned player label if ( pRam->GetDriverPlayer() ) { Q_snprintf( buf, sizeof( buf ), "Driven by %s", pRam->GetDriverPlayer()->GetPlayerName() ); m_pDriverLabel->SetText( buf ); m_pDriverLabel->SetVisible( true ); } else { m_pDriverLabel->SetVisible( false ); } int nPassengerCount = pRam->GetPassengerCount(); int nMaxPassengerCount = pRam->GetMaxPassengerCount(); Q_snprintf( buf, sizeof( buf ), "Passengers %d/%d", nPassengerCount >= 1 ? nPassengerCount - 1 : 0, nMaxPassengerCount - 1 ); m_pPassengerLabel->SetText( buf ); // Update the get in button if ( pRam->IsPlayerInVehicle( C_BaseTFPlayer::GetLocalPlayer() ) ) { m_pOccupyButton->SetEnabled( false ); return; } if ( pRam->GetOwner() == C_BaseTFPlayer::GetLocalPlayer() ) { if (nPassengerCount == nMaxPassengerCount) { // Owners can boot other players to get in C_BaseTFPlayer *pPlayer = static_cast<C_BaseTFPlayer*>(pRam->GetPassenger( VEHICLE_ROLE_DRIVER )); Q_snprintf( buf, sizeof( buf ), "Get In (Ejecting %s)", pPlayer->GetPlayerName() ); m_pDriverLabel->SetText( buf ); m_pOccupyButton->SetEnabled( true ); } else { m_pOccupyButton->SetText( "Get In" ); m_pOccupyButton->SetEnabled( true ); } } else { m_pOccupyButton->SetText( "Get In" ); m_pOccupyButton->SetEnabled( pRam->GetPassengerCount() < pRam->GetMaxPassengerCount() ); } }
void CPortalStatsDisplayScreen::UpdateTextFields( C_PropPortalStatsDisplay *pPropPortalStatsDisplay ) { bool bIsTime = pPropPortalStatsDisplay->IsTime(); float fNumPlayer = pPropPortalStatsDisplay->GetNumPlayerDisplay(); float fNumGoal = pPropPortalStatsDisplay->GetNumGoalDisplay(); // Figure out colors Color *( pColors[ 3 ] ) = { &m_cUnknown, &m_cFail, &m_cPass }; int iColor = pPropPortalStatsDisplay->GetGoalSuccess() + 1; m_pNumPlayerLabel->SetFgColor( ( fNumPlayer != 0.0f ) ? ( *pColors[ iColor ] ) : ( m_cInvisible ) ); m_pNumGoalLabel->SetFgColor( ( pPropPortalStatsDisplay->GetGoalVisible() ) ? ( *pColors[ iColor ] ) : ( m_cInvisible ) ); // Fill in labels CFmtStr str; if ( !bIsTime ) { str.sprintf( "%.0f", fNumPlayer ); m_pNumPlayerLabel->SetText( str ); str.sprintf( "%.0f", fNumGoal ); m_pNumGoalLabel->SetText( str ); } else { // break seconds into mnutes and seconds int iMinutes = static_cast<int>( fNumPlayer / 60.0f ); int iHours = iMinutes / 60; iMinutes %= 60; int iSeconds = static_cast<int>( fNumPlayer ) % 60; MakeTimeString( str, iHours, iMinutes, iSeconds ); m_pNumPlayerLabel->SetText( str ); // break seconds into mnutes and seconds iMinutes = static_cast<int>( fNumGoal / 60.0f ); iHours = iMinutes / 60; iMinutes %= 60; iSeconds = static_cast<int>( fNumGoal ) % 60; MakeTimeString( str, iHours, iMinutes, iSeconds ); m_pNumGoalLabel->SetText( str ); } // Draw cheated label when needed m_pCheatedLabel->SetVisible( pPropPortalStatsDisplay->HasCheated() ); }
//----------------------------------------------------------------------------- // Frame-based update //----------------------------------------------------------------------------- void CBuffStationControlPanel::OnTick() { BaseClass::OnTick(); C_BaseObject *pObj = GetOwningObject(); if (!pObj) return; Assert( dynamic_cast<C_ObjectBuffStation*>(pObj) ); C_ObjectBuffStation *pStation = static_cast<C_ObjectBuffStation*>(pObj); char buf[256]; int nSocketsLeft = pStation->PlayerSocketsLeft(); if (nSocketsLeft > 0) { Q_snprintf( buf, 256, "%d sockets left", pStation->PlayerSocketsLeft() ); } else { Q_snprintf( buf, 256, "No sockets left" ); } m_pSocketsLabel->SetText( buf ); // Make sure the connect/disconnect button is correct if ( pStation->IsLocalPlayerAttached() ) { m_pConnectButton->SetText( "Disconnect from Station" ); } else { m_pConnectButton->SetText( "Connect To Station" ); } }
//----------------------------------------------------------------------------- // Begin editing a particular material //----------------------------------------------------------------------------- void CMaterialEditorPanel::BeginEditingMaterial( const char *pMaterialName, IMaterial *pMaterial ) { m_bMaterialDirty = false; m_EditedMaterial = pMaterialName; m_pTitleLabel->SetText( m_EditedMaterial.String() ); m_pMaterialViewer->SetMaterial(pMaterial); m_pMaterial = pMaterial; }
//----------------------------------------------------------------------------- // Frame-based update //----------------------------------------------------------------------------- void CTeleportCountdownScreen::OnTick() { BaseClass::OnTick(); // Find the active info teleporter countdown C_InfoTeleporterCountdown *pActiveCountdown = NULL; for ( int i = g_InfoTeleporterCountdownList.Head(); i != g_InfoTeleporterCountdownList.InvalidIndex(); i = g_InfoTeleporterCountdownList.Next(i) ) { if ( g_InfoTeleporterCountdownList[i]->m_bCountdownStarted ) { pActiveCountdown = g_InfoTeleporterCountdownList[i]; break; } } if ( !GetEntity() || !pActiveCountdown ) { m_pTimeRemainingTitleLabel->SetVisible( false ); m_pTimeRemainingLabel->SetVisible( false ); m_pMalfunctionLabel->SetVisible( false ); return; } // Make the appropriate labels visible bool bMalfunction = pActiveCountdown->m_bDisabled; m_pTimeRemainingTitleLabel->SetVisible( !bMalfunction ); m_pTimeRemainingLabel->SetVisible( !bMalfunction ); // This will make it flash m_pMalfunctionLabel->SetVisible( bMalfunction && (((int)(gpGlobals->curtime) & 0x1) == 0x1) ); // Update the time remaining if ( !bMalfunction ) { char buf[32]; if (m_pTimeRemainingLabel) { float dt = gpGlobals->curtime - pActiveCountdown->m_flStartTime; if ( dt < 0.0f ) { dt = 0.0f; } int nTimeRemaining = (int)(pActiveCountdown->m_flTimeRemaining - dt + 0.5f); if ( nTimeRemaining < 0 ) { nTimeRemaining = 0; } Q_snprintf( buf, sizeof( buf ), "%d", nTimeRemaining ); m_pTimeRemainingLabel->SetText( buf ); } } }
//----------------------------------------------------------------------------- // Frame-based update //----------------------------------------------------------------------------- void CResourcePumpControlPanel::OnTick() { BaseClass::OnTick(); C_BaseObject *pObj = GetOwningObject(); if (!pObj) return; Assert( dynamic_cast<C_ObjectResourcePump*>(pObj) ); C_ObjectResourcePump *pPump = static_cast<C_ObjectResourcePump*>(pObj); char buf[256]; int iPumpLevel = pPump->GetLevel(); int iCost = CalculateObjectUpgrade( OBJ_RESOURCEPUMP, iPumpLevel ); if ( iCost ) { V_snprintf( buf, 256, "Upgrade to Level %d\nCost: %d", iPumpLevel+1, iCost ); } else { V_snprintf( buf, 256, "Level %d", iPumpLevel ); } m_pUpgradeButton->SetText( buf ); C_ResourceZone *pResourceZone = pPump->GetResourceZone(); if (pResourceZone) { V_snprintf( buf, 256, "Resources: %d", pResourceZone->m_nResourcesLeft ); m_pResourcesLabel->SetText( buf ); } else { m_pResourcesLabel->SetText( "Resources: 0" ); } }
void CSlideshowDisplayScreen::Update( C_SlideshowDisplay *pSlideshowDisplay ) { char szBuff[ 256 ]; pSlideshowDisplay->GetDisplayText( szBuff ); m_pDisplayTextLabel->SetText( szBuff ); if ( m_pSlideshowImages.Count() == 0 ) { // Build the list of image panels! for ( int iSlide = 0; iSlide < pSlideshowDisplay->NumMaterials(); ++iSlide ) { m_pSlideshowImages.AddToTail( SETUP_PANEL( new ImagePanel( this, "SlideshowImage" ) ) ); int iMatIndex = pSlideshowDisplay->GetMaterialIndex( iSlide ); if ( iMatIndex > 0 ) { const char *pMaterialName = GetMaterialNameFromIndex( iMatIndex ); if ( pMaterialName ) { pMaterialName = Q_strnchr( pMaterialName, '/', Q_strlen( pMaterialName ) ); if ( pMaterialName ) { pMaterialName = pMaterialName + 1; m_pSlideshowImages[ iSlide ]->SetImage( pMaterialName ); m_pSlideshowImages[ iSlide ]->SetVisible( false ); m_pSlideshowImages[ iSlide ]->SetZPos( -3 ); m_pSlideshowImages[ iSlide ]->SetWide( GetWide() ); m_pSlideshowImages[ iSlide ]->SetTall( GetTall() ); } } } } } int iCurrentSlideIndex = pSlideshowDisplay->CurrentSlideIndex(); if ( iCurrentSlideIndex != iLastSlideIndex ) { m_pSlideshowImages[ iLastSlideIndex ]->SetVisible( false ); m_pSlideshowImages[ iCurrentSlideIndex ]->SetVisible( true ); iLastSlideIndex = iCurrentSlideIndex; } }
void CASWHudMoney::OnThink() { if ( !ASWGameResource() ) return; int iMoney = ASWGameResource()->GetMoney(); if ( iMoney != m_iMoney ) { if ( !m_pMoneyLabel ) { m_pMoneyLabel = dynamic_cast<vgui::Label*>(FindChildByName( "MoneyLabel" )); } m_iMoney = iMoney; if ( m_pMoneyLabel ) { m_pMoneyLabel->SetText( VarArgs( "$%d", m_iMoney ) ); } } }
//----------------------------------------------------------------------------- // Frame-based update //----------------------------------------------------------------------------- void CSentrygunControlPanel::OnTick() { BaseClass::OnTick(); C_BaseObject *pObj = GetOwningObject(); if (!pObj) return; Assert( dynamic_cast<C_ObjectSentrygun*>(pObj) ); C_ObjectSentrygun *pSentrygun = static_cast<C_ObjectSentrygun*>(pObj); char buf[256]; int iAmmo = pSentrygun->GetAmmoLeft(); if (iAmmo > 0) { Q_snprintf( buf, 256, "%d rounds left", iAmmo ); } else { Q_snprintf( buf, 256, "OUT OF AMMO" ); } m_pAmmoLabel->SetText( buf ); }
//============================================== // CHudFlags's Paint // errr... paints the panel //============================================== void CHudCTFFlags::Paint() { int m_iFlagCount = g_CtfFlags.Count(); C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if( !pPlayer ) return; //char text[512]; int i;// = 0; int x_offset = 0; //int y_offset = 5; Color ColourWhite( 255, 255, 255, 255 ); i = 0; while (i < MAX_FLAGS) { m_pLabelFlag[i]->SetVisible(false); i++; } //x_offset = ( (ScreenWidth() / 2) - (m_iFlagCount * 74) ); //Always lean to the left from the center. -HairyPotter x_offset = 0; for( i = 0; i < m_iFlagCount; i++ ) { x_offset += 68; float fTimeToCap = gpGlobals->curtime; //switch( g_Flags[i]->m_iLastTeam ) switch( g_CtfFlags[i]->GetTeamNumber() ) { case TEAM_UNASSIGNED: switch( g_CtfFlags[i]->m_iForTeam ) { case 0: m_pIconBlank->DrawSelf( x_offset, 0, ColourWhite ); break; case 1: //This flag is picked up by the brits... so it's actually the american flag. m_pIconBlue->DrawSelf( x_offset, 0, ColourWhite ); break; case 2: //This flag is picked up by the americans... so it's actually the british flag. m_pIconRed->DrawSelf( x_offset, 0, ColourWhite ); break; } break; case TEAM_AMERICANS: m_pIconBlue->DrawSelf( x_offset, 0, ColourWhite ); break; case TEAM_BRITISH: m_pIconRed->DrawSelf( x_offset, 0, ColourWhite ); break; } if ( g_CtfFlags[i]->m_bIsCarried ) { int r=0,g=0,b=0; //Start at blue. r = 0; g = 0; b = 255; //End up at red. r += 255 * (sin(fTimeToCap*4) + 1)/2; //g -= 100 * (sin(gpGlobals->curtime*4) + 1)/2; b -= 255 * (sin(fTimeToCap*4) + 1)/2; m_pLabelFlag[i]->SetText( "Taken" ); m_pLabelFlag[i]->SizeToContents(); //m_pLabelFlag[i]->SetVisible( true ); //center on icon int w,h; m_pLabelFlag[i]->GetSize( w, h ); m_pLabelFlag[i]->SetPos( (x_offset + 32) - w/2, 32 - h/2 ); m_pLabelFlag[i]->SetFgColor( Color(r,g,b,255) ); m_pLabelFlag[i]->SetVisible(true); } if ( g_CtfFlags[i]->GetMoveParent() && g_CtfFlags[i]->GetMoveParent() == pPlayer ) { int ystart = GetTall() - 140; //Place this just above the LMS indicator. int w,h; m_pLabelCarrier->SetText( g_pVGuiLocalize->Find("#CTF")); m_pLabelCarrier->SizeToContents(); m_pLabelCarrier->GetSize( w, h ); m_pLabelCarrier->SetPos( 5, ystart - 1.3*h); m_pLabelCarrier->SetFgColor( ColourWhite ); m_pLabelCarrier->SetVisible( true ); //Msg("You are carrying a flag! \n"); } else m_pLabelCarrier->SetVisible( false ); } }