//----------------------------------------------------------------------------- // Purpose: Draw function for the element //----------------------------------------------------------------------------- void CHUDBlockHealth::Paint() { wchar_t sIDString[ MAX_ID_STRING ]; sIDString[0] = 0; m_bBlockInTarget = false; C_BaseEntity *pEntity = ProcessTarget(); // Did we find a target? if ( pEntity ) { // Is it a block? if ( pEntity->IsBlock() && pEntity->GetHealth() > 0 ) { C_BlockBase *pBlock = static_cast< C_BlockBase * > ( pEntity ); Color c = GetTeamColor( pBlock->GetTeamNumber() ); float BlockHealth = pBlock->GetHealth(); float MaxBlockHealth = pBlock->GetMaxHealth(); float HealthRatio = ( BlockHealth / MaxBlockHealth ) * 100; wchar_t wszHealthText[ 10 ]; unsigned int HealthTextLen = ARRAYSIZE( wszHealthText ); _snwprintf( wszHealthText, HealthTextLen - 1, L"%.0f%%", HealthRatio ); wszHealthText[ HealthTextLen - 1 ] = '\0'; wchar_t *printFormatString = NULL; printFormatString = L"Health | %s1 |"; g_pVGuiLocalize->ConstructString( sIDString, sizeof( sIDString ), printFormatString, 1, wszHealthText ); // Check if we have anything to output if ( sIDString[0] ) { int wide, tall; vgui::surface()->GetTextSize( m_hFont, sIDString, wide, tall ); int ypos = YRES(260); int xpos = (ScreenWidth() - wide) / 2; vgui::surface()->DrawSetTextFont( m_hFont ); vgui::surface()->DrawSetTextPos( xpos, ypos ); vgui::surface()->DrawSetTextColor( c ); vgui::surface()->DrawPrintText( sIDString, wcslen(sIDString) ); } } } }
void CC_FreezeStatus( const CCommand& args ) { C_BaseEntity *pEntity = ProcessTarget(); // Did we find a target? if ( pEntity ) { // Is it a block? if ( pEntity->IsBlock() && pEntity->GetHealth() > 0 ) { C_BlockBase *pBlock = static_cast< C_BlockBase * > ( pEntity ); if ( ClassicGameRules() ) { int frozenplayerindex = engine->GetPlayerForUserID( pBlock->GetLastFrozenByUserID() ); C_BasePlayer *pPlayer = UTIL_PlayerByIndex( frozenplayerindex ); if ( pPlayer ) { Msg( "\tFrozen by %s\n", pPlayer->GetPlayerName() ); } else { Msg( "\tFrozen by WORLD\n" ); } int unfrozenplayerindex = engine->GetPlayerForUserID( pBlock->GetLastUnFrozenByUserID() ); pPlayer = UTIL_PlayerByIndex( unfrozenplayerindex ); if ( pPlayer ) { Msg( "\tUnFrozen by %s\n", pPlayer->GetPlayerName() ); } else { Msg( "\tUnFrozen by WORLD\n" ); } } } } }
DualErr CShellExt::PreparePathsAndCommandLine() { DualErr derr; PGPBoolean createdTargets = FALSE; try { FORMATETC fmte = {CF_HDROP, (DVTARGETDEVICE FAR *) NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; PGPBoolean createdTargets = FALSE; PGPUInt32 i; STGMEDIUM medium; mPDataObj->GetData(&fmte, &medium); // Get the number of targets. mNumDropped = DragQueryFile((HDROP) medium.hGlobal, 0xFFFFFFFF, NULL, NULL); if (mNumDropped == 0) derr = DualErr(kPGDMinorError_FailSilently); if (derr.IsntError()) { mNumTotalPGPdisks = mNumMountedPGPdisks = 0; // Get space for the target array. mTargets = new TargetInfo[mNumDropped]; createdTargets = TRUE; // Get info about each of them. for (i = 0; i < mNumDropped; i++) { derr = ProcessTarget((HDROP) medium.hGlobal, i); if (derr.IsError()) break; } } } catch (CMemoryException *ex) { derr = DualErr(kPGDMinorError_OutOfMemory); ex->Delete(); } // Cleanup if error. if (derr.IsError()) { if (createdTargets) { delete[] mTargets; mTargets = NULL; } mNumDropped = mNumTotalPGPdisks = mNumMountedPGPdisks = 0; } return derr; }