Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

666 lines
19 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "dod_hud_freezepanel.h"
  9. #include "vgui_controls/AnimationController.h"
  10. #include "iclientmode.h"
  11. #include "c_dod_player.h"
  12. #include "c_dod_playerresource.h"
  13. #include <vgui_controls/Label.h>
  14. #include <vgui/ILocalize.h>
  15. #include <vgui/ISurface.h>
  16. #include "fmtstr.h"
  17. #include "dod_gamerules.h"
  18. #include "view.h"
  19. #include "ivieweffects.h"
  20. #include "viewrender.h"
  21. // memdbgon must be the last include file in a .cpp file!!!
  22. #include "tier0/memdbgon.h"
  23. DECLARE_HUDELEMENT_DEPTH( CDODFreezePanel, 1 );
  24. #define CALLOUT_WIDE (XRES(100))
  25. #define CALLOUT_TALL (XRES(50))
  26. extern float g_flFreezeFlash;
  27. ConVar cl_dod_freezecam( "cl_dod_freezecam", "1", FCVAR_ARCHIVE, "Client option to not show freeze camera on death" );
  28. #define FREEZECAM_SCREENSHOT_STRING "is looking good!"
  29. bool IsTakingAFreezecamScreenshot( void )
  30. {
  31. // Don't draw in freezecam, or when the game's not running
  32. C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
  33. bool bInFreezeCam = ( pPlayer && pPlayer->GetObserverMode() == OBS_MODE_FREEZECAM );
  34. if ( bInFreezeCam == true && engine->IsTakingScreenshot() )
  35. return true;
  36. CDODFreezePanel *pPanel = GET_HUDELEMENT( CDODFreezePanel );
  37. if ( pPanel )
  38. {
  39. if ( pPanel->IsHoldingAfterScreenShot() )
  40. return true;
  41. }
  42. return false;
  43. }
  44. //-----------------------------------------------------------------------------
  45. // Purpose: Constructor
  46. //-----------------------------------------------------------------------------
  47. CDODFreezePanel::CDODFreezePanel( const char *pElementName )
  48. : EditablePanel( NULL, "FreezePanel" ), CHudElement( pElementName )
  49. {
  50. vgui::Panel *pParent = g_pClientMode->GetViewport();
  51. SetParent( pParent );
  52. SetVisible( false );
  53. SetScheme( "ClientScheme" );
  54. m_iKillerIndex = 0;
  55. m_iShowNemesisPanel = SHOW_NO_NEMESIS;
  56. m_iYBase = -1;
  57. m_flShowCalloutsAt = 0;
  58. m_iBasePanelOriginalX = -1;
  59. m_iBasePanelOriginalY = -1;
  60. RegisterForRenderGroup( "winpanel" );
  61. }
  62. //-----------------------------------------------------------------------------
  63. // Purpose:
  64. //-----------------------------------------------------------------------------
  65. void CDODFreezePanel::Reset()
  66. {
  67. Hide();
  68. }
  69. //-----------------------------------------------------------------------------
  70. // Purpose:
  71. //-----------------------------------------------------------------------------
  72. void CDODFreezePanel::Init()
  73. {
  74. // listen for events
  75. ListenForGameEvent( "show_freezepanel" );
  76. ListenForGameEvent( "hide_freezepanel" );
  77. ListenForGameEvent( "freezecam_started" );
  78. ListenForGameEvent( "player_death" );
  79. ListenForGameEvent( "dod_win_panel" );
  80. Hide();
  81. CHudElement::Init();
  82. }
  83. //-----------------------------------------------------------------------------
  84. // Purpose: Applies scheme settings
  85. //-----------------------------------------------------------------------------
  86. void CDODFreezePanel::ApplySchemeSettings( vgui::IScheme *pScheme )
  87. {
  88. BaseClass::ApplySchemeSettings( pScheme );
  89. LoadControlSettings( "resource/UI/FreezePanel_Basic.res" );
  90. m_pBasePanel = dynamic_cast<EditablePanel *>( FindChildByName("FreezePanelBase") );
  91. Assert( m_pBasePanel );
  92. if ( m_pBasePanel )
  93. {
  94. m_pFreezeLabel = dynamic_cast<Label *>( m_pBasePanel->FindChildByName("FreezeLabel") );
  95. m_pFreezePanelBG = m_pBasePanel->FindChildByName( "FreezePanelBG" );
  96. m_pNemesisSubPanel = dynamic_cast<EditablePanel *>( m_pBasePanel->FindChildByName( "NemesisSubPanel" ) );
  97. m_pHealthStatus = dynamic_cast<CDoDHudHealth *>( m_pBasePanel->FindChildByName( "PlayerStatusHealth" ) );
  98. m_pAvatar = dynamic_cast<CAvatarImagePanel *>( m_pBasePanel->FindChildByName("AvatarImage") );
  99. if ( m_pAvatar )
  100. {
  101. m_pAvatar->SetShouldScaleImage( true );
  102. m_pAvatar->SetShouldDrawFriendIcon( false );
  103. }
  104. }
  105. m_pScreenshotPanel = dynamic_cast<EditablePanel *>( FindChildByName( "ScreenshotPanel" ) );
  106. Assert( m_pScreenshotPanel );
  107. // Move killer panels when the win panel is up
  108. int xp,yp;
  109. GetPos( xp, yp );
  110. m_iYBase = yp;
  111. int w, h;
  112. m_pBasePanel->GetBounds( m_iBasePanelOriginalX, m_iBasePanelOriginalY, w, h );
  113. }
  114. //-----------------------------------------------------------------------------
  115. // Purpose:
  116. //-----------------------------------------------------------------------------
  117. void CDODFreezePanel::FireGameEvent( IGameEvent * event )
  118. {
  119. if ( !cl_dod_freezecam.GetBool() )
  120. {
  121. if ( IsVisible() )
  122. {
  123. Hide();
  124. }
  125. return;
  126. }
  127. const char *pEventName = event->GetName();
  128. if ( Q_strcmp( "player_death", pEventName ) == 0 )
  129. {
  130. // see if the local player died
  131. int iPlayerIndexVictim = engine->GetPlayerForUserID( event->GetInt( "userid" ) );
  132. C_DODPlayer *pLocalPlayer = C_DODPlayer::GetLocalDODPlayer();
  133. if ( pLocalPlayer && iPlayerIndexVictim == pLocalPlayer->entindex() )
  134. {
  135. // the local player is dead, see if this is a new nemesis or a revenge
  136. if ( event->GetInt( "dominated" ) > 0 )
  137. {
  138. m_iShowNemesisPanel = SHOW_NEW_NEMESIS;
  139. }
  140. else if ( event->GetInt( "revenge" ) > 0 )
  141. {
  142. m_iShowNemesisPanel = SHOW_REVENGE;
  143. }
  144. else
  145. {
  146. m_iShowNemesisPanel = SHOW_NO_NEMESIS;
  147. }
  148. }
  149. }
  150. else if ( Q_strcmp( "hide_freezepanel", pEventName ) == 0 )
  151. {
  152. Hide();
  153. }
  154. else if ( Q_strcmp( "freezecam_started", pEventName ) == 0 )
  155. {
  156. ShowCalloutsIn( 1.0 );
  157. ShowSnapshotPanelIn( 1.0 );
  158. }
  159. else if ( Q_strcmp( "dod_win_panel", pEventName ) == 0 )
  160. {
  161. Hide();
  162. }
  163. else if ( Q_strcmp( "show_freezepanel", pEventName ) == 0 )
  164. {
  165. C_DOD_PlayerResource *tf_PR = dynamic_cast<C_DOD_PlayerResource *>(g_PR);
  166. if ( !tf_PR )
  167. {
  168. m_pNemesisSubPanel->SetDialogVariable( "nemesisname", NULL );
  169. return;
  170. }
  171. Show();
  172. ShowSnapshotPanel( false );
  173. m_bHoldingAfterScreenshot = false;
  174. if ( m_iBasePanelOriginalX > -1 && m_iBasePanelOriginalY > -1 )
  175. {
  176. m_pBasePanel->SetPos( m_iBasePanelOriginalX, m_iBasePanelOriginalY );
  177. }
  178. // Get the entity who killed us
  179. m_iKillerIndex = event->GetInt( "killer" );
  180. C_BaseEntity *pKiller = ClientEntityList().GetBaseEntity( m_iKillerIndex );
  181. int xp,yp;
  182. GetPos( xp, yp );
  183. SetPos( xp, m_iYBase );
  184. bool bShowHealth = pKiller && pKiller->IsPlayer();
  185. m_pHealthStatus->SetVisible( bShowHealth );
  186. if ( bShowHealth )
  187. {
  188. m_pHealthStatus->SetHealthDelegatePlayer( ToDODPlayer(pKiller) );
  189. }
  190. if ( pKiller )
  191. {
  192. if ( pKiller->IsPlayer() )
  193. {
  194. C_DODPlayer *pVictim = C_DODPlayer::GetLocalDODPlayer();
  195. C_DODPlayer *pDODKiller = ToDODPlayer( pKiller );
  196. //If this was just a regular kill but this guy is our nemesis then just show it.
  197. if ( pVictim && pDODKiller && pDODKiller->m_Shared.IsPlayerDominated( pVictim->entindex() ) )
  198. {
  199. if ( !pKiller->IsAlive() )
  200. {
  201. m_pFreezeLabel->SetText( "#FreezePanel_Nemesis_Dead" );
  202. }
  203. else
  204. {
  205. m_pFreezeLabel->SetText( "#FreezePanel_Nemesis" );
  206. }
  207. }
  208. else
  209. {
  210. if ( !pKiller->IsAlive() )
  211. {
  212. m_pFreezeLabel->SetText( "#FreezePanel_Killer_Dead" );
  213. }
  214. else
  215. {
  216. m_pFreezeLabel->SetText( "#FreezePanel_Killer" );
  217. }
  218. }
  219. m_pBasePanel->SetDialogVariable( "killername", g_PR->GetPlayerName( m_iKillerIndex ) );
  220. if ( m_pAvatar )
  221. {
  222. m_pAvatar->SetPlayer( (C_BasePlayer*)pKiller );
  223. }
  224. }
  225. else if ( m_pFreezeLabel )
  226. {
  227. if ( !pKiller->IsAlive() )
  228. {
  229. m_pFreezeLabel->SetText( "#FreezePanel_Killer_Dead" );
  230. }
  231. else
  232. {
  233. m_pFreezeLabel->SetText( "#FreezePanel_Killer" );
  234. }
  235. }
  236. }
  237. // see if we should show nemesis panel
  238. const wchar_t *pchNemesisText = NULL;
  239. switch ( m_iShowNemesisPanel )
  240. {
  241. case SHOW_NO_NEMESIS:
  242. {
  243. C_DODPlayer *pVictim = C_DODPlayer::GetLocalDODPlayer();
  244. C_DODPlayer *pTFKiller = ToDODPlayer( pKiller );
  245. //If this was just a regular kill but this guy is our nemesis then just show it.
  246. if ( pTFKiller && pTFKiller->m_Shared.IsPlayerDominated( pVictim->entindex() ) )
  247. {
  248. pchNemesisText = g_pVGuiLocalize->Find( "#FreezePanel_FreezeNemesis" );
  249. }
  250. }
  251. break;
  252. case SHOW_NEW_NEMESIS:
  253. {
  254. C_DODPlayer *pVictim = C_DODPlayer::GetLocalDODPlayer();
  255. C_DODPlayer *pTFKiller = ToDODPlayer( pKiller );
  256. // check to see if killer is still the nemesis of victim; victim may have managed to kill him after victim's
  257. // death by grenade or some such, extracting revenge and clearing nemesis condition
  258. if ( pTFKiller && pTFKiller->m_Shared.IsPlayerDominated( pVictim->entindex() ) )
  259. {
  260. pchNemesisText = g_pVGuiLocalize->Find( "#FreezePanel_NewNemesis" );
  261. }
  262. }
  263. break;
  264. case SHOW_REVENGE:
  265. pchNemesisText = g_pVGuiLocalize->Find( "#FreezePanel_GotRevenge" );
  266. break;
  267. default:
  268. Assert( false ); // invalid value
  269. break;
  270. }
  271. m_pNemesisSubPanel->SetDialogVariable( "nemesisname", pchNemesisText );
  272. ShowNemesisPanel( NULL != pchNemesisText );
  273. m_iShowNemesisPanel = SHOW_NO_NEMESIS;
  274. }
  275. }
  276. //-----------------------------------------------------------------------------
  277. // Purpose:
  278. //-----------------------------------------------------------------------------
  279. void CDODFreezePanel::ShowCalloutsIn( float flTime )
  280. {
  281. m_flShowCalloutsAt = gpGlobals->curtime + flTime;
  282. }
  283. //-----------------------------------------------------------------------------
  284. // Purpose:
  285. //-----------------------------------------------------------------------------
  286. CDODFreezePanelCallout *CDODFreezePanel::TestAndAddCallout( Vector &origin, Vector &vMins, Vector &vMaxs, CUtlVector<Vector> *vecCalloutsTL,
  287. CUtlVector<Vector> *vecCalloutsBR, Vector &vecFreezeTL, Vector &vecFreezeBR, Vector &vecStatTL, Vector &vecStatBR, int *iX, int *iY )
  288. {
  289. // This is the offset from the topleft of the callout to the arrow tip
  290. const int iXOffset = XRES(25);
  291. const int iYOffset = YRES(50);
  292. //if ( engine->IsBoxInViewCluster( vMins + origin, vMaxs + origin) && !engine->CullBox( vMins + origin, vMaxs + origin ) )
  293. {
  294. if ( GetVectorInHudSpace( origin, *iX, *iY ) ) // TODO: GetVectorInHudSpace or GetVectorInScreenSpace?
  295. {
  296. *iX -= iXOffset;
  297. *iY -= iYOffset;
  298. int iRight = *iX + CALLOUT_WIDE;
  299. int iBottom = *iY + CALLOUT_TALL;
  300. if ( *iX > 0 && *iY > 0 && (iRight < ScreenWidth()) && (iBottom < (ScreenHeight()-YRES(40))) )
  301. {
  302. // Make sure it wouldn't be over the top of the freezepanel or statpanel
  303. Vector vecCalloutTL( *iX, *iY, 0 );
  304. Vector vecCalloutBR( iRight, iBottom, 1 );
  305. if ( !QuickBoxIntersectTest( vecCalloutTL, vecCalloutBR, vecFreezeTL, vecFreezeBR ) &&
  306. !QuickBoxIntersectTest( vecCalloutTL, vecCalloutBR, vecStatTL, vecStatBR ) )
  307. {
  308. // Make sure it doesn't intersect any other callouts
  309. bool bClear = true;
  310. for ( int iCall = 0; iCall < vecCalloutsTL->Count(); iCall++ )
  311. {
  312. if ( QuickBoxIntersectTest( vecCalloutTL, vecCalloutBR, vecCalloutsTL->Element(iCall), vecCalloutsBR->Element(iCall) ) )
  313. {
  314. bClear = false;
  315. break;
  316. }
  317. }
  318. if ( bClear )
  319. {
  320. // Verify that we have LOS to the gib
  321. trace_t tr;
  322. UTIL_TraceLine( origin, MainViewOrigin(), MASK_OPAQUE, NULL, COLLISION_GROUP_NONE, &tr );
  323. bClear = ( tr.fraction >= 1.0f );
  324. }
  325. if ( bClear )
  326. {
  327. CDODFreezePanelCallout *pCallout = new CDODFreezePanelCallout( g_pClientMode->GetViewport(), "FreezePanelCallout" );
  328. m_pCalloutPanels.AddToTail( vgui::SETUP_PANEL(pCallout) );
  329. vecCalloutsTL->AddToTail( vecCalloutTL );
  330. vecCalloutsBR->AddToTail( vecCalloutBR );
  331. pCallout->SetVisible( true );
  332. pCallout->SetBounds( *iX, *iY, CALLOUT_WIDE, CALLOUT_TALL );
  333. return pCallout;
  334. }
  335. }
  336. }
  337. }
  338. }
  339. return NULL;
  340. }
  341. //-----------------------------------------------------------------------------
  342. // Purpose:
  343. //-----------------------------------------------------------------------------
  344. void CDODFreezePanel::UpdateCallout( void )
  345. {
  346. CDODPlayer *pPlayer = C_DODPlayer::GetLocalDODPlayer();
  347. if ( !pPlayer )
  348. return;
  349. // Abort early if we have no ragdoll
  350. IRagdoll *pRagdoll = pPlayer->GetRepresentativeRagdoll();
  351. if ( !pRagdoll )
  352. return;
  353. if ( m_pFreezePanelBG == NULL )
  354. return;
  355. // Precalc the vectors of the freezepanel & statpanel
  356. int iX, iY;
  357. m_pFreezePanelBG->GetPos( iX, iY );
  358. Vector vecFreezeTL( iX, iY, 0 );
  359. Vector vecFreezeBR( iX + m_pFreezePanelBG->GetWide(), iY + m_pFreezePanelBG->GetTall(), 1 );
  360. CUtlVector<Vector> vecCalloutsTL;
  361. CUtlVector<Vector> vecCalloutsBR;
  362. Vector vecStatTL(0,0,0);
  363. Vector vecStatBR(0,0,1);
  364. Vector vMins, vMaxs;
  365. if ( pRagdoll )
  366. {
  367. Vector origin = pRagdoll->GetRagdollOrigin();
  368. pRagdoll->GetRagdollBounds( vMins, vMaxs );
  369. // Try and add the callout
  370. //CDODFreezePanelCallout *pCallout =
  371. TestAndAddCallout( origin, vMins, vMaxs, &vecCalloutsTL, &vecCalloutsBR,
  372. vecFreezeTL, vecFreezeBR, vecStatTL, vecStatBR, &iX, &iY );
  373. }
  374. }
  375. //-----------------------------------------------------------------------------
  376. // Purpose:
  377. //-----------------------------------------------------------------------------
  378. void CDODFreezePanel::Show()
  379. {
  380. m_flShowCalloutsAt = 0;
  381. SetVisible( true );
  382. int iRenderGroup = gHUD.LookupRenderGroupIndexByName( "freezepanel" );
  383. if ( iRenderGroup >= 0 )
  384. {
  385. gHUD.LockRenderGroup( iRenderGroup );
  386. }
  387. }
  388. //-----------------------------------------------------------------------------
  389. // Purpose:
  390. //-----------------------------------------------------------------------------
  391. void CDODFreezePanel::Hide()
  392. {
  393. SetVisible( false );
  394. m_bHoldingAfterScreenshot = false;
  395. // Delete all our callout panels
  396. for ( int i = m_pCalloutPanels.Count()-1; i >= 0; i-- )
  397. {
  398. m_pCalloutPanels[i]->MarkForDeletion();
  399. }
  400. m_pCalloutPanels.RemoveAll();
  401. int iRenderGroup = gHUD.LookupRenderGroupIndexByName( "winpanel" );
  402. if ( iRenderGroup >= 0 )
  403. {
  404. gHUD.UnlockRenderGroup( iRenderGroup );
  405. }
  406. }
  407. //-----------------------------------------------------------------------------
  408. // Purpose:
  409. //-----------------------------------------------------------------------------
  410. bool CDODFreezePanel::ShouldDraw( void )
  411. {
  412. if ( !CHudElement::ShouldDraw() )
  413. return false;
  414. return ( IsVisible() );
  415. }
  416. //-----------------------------------------------------------------------------
  417. // Purpose:
  418. //-----------------------------------------------------------------------------
  419. void CDODFreezePanel::OnThink( void )
  420. {
  421. BaseClass::OnThink();
  422. if ( m_flShowCalloutsAt && m_flShowCalloutsAt < gpGlobals->curtime )
  423. {
  424. if ( ShouldDraw() )
  425. {
  426. UpdateCallout();
  427. }
  428. m_flShowCalloutsAt = 0;
  429. }
  430. if ( m_flShowSnapshotReminderAt && m_flShowSnapshotReminderAt < gpGlobals->curtime )
  431. {
  432. if ( ShouldDraw() )
  433. {
  434. ShowSnapshotPanel( true );
  435. }
  436. m_flShowSnapshotReminderAt = 0;
  437. }
  438. }
  439. //-----------------------------------------------------------------------------
  440. // Purpose:
  441. //-----------------------------------------------------------------------------
  442. void CDODFreezePanel::ShowSnapshotPanelIn( float flTime )
  443. {
  444. m_flShowSnapshotReminderAt = gpGlobals->curtime + flTime;
  445. }
  446. //-----------------------------------------------------------------------------
  447. // Purpose:
  448. //-----------------------------------------------------------------------------
  449. void CDODFreezePanel::ShowSnapshotPanel( bool bShow )
  450. {
  451. if ( !m_pScreenshotPanel )
  452. return;
  453. const char *key = engine->Key_LookupBinding( "screenshot" );
  454. if ( key == NULL || FStrEq( key, "(null)" ) )
  455. {
  456. bShow = false;
  457. key = " ";
  458. }
  459. if ( bShow )
  460. {
  461. char szKey[16];
  462. Q_snprintf( szKey, sizeof(szKey), "%s", key );
  463. wchar_t wKey[16];
  464. wchar_t wLabel[256];
  465. g_pVGuiLocalize->ConvertANSIToUnicode(szKey, wKey, sizeof(wKey));
  466. g_pVGuiLocalize->ConstructString( wLabel, sizeof( wLabel ), g_pVGuiLocalize->Find("#TF_freezecam_snapshot" ), 1, wKey );
  467. m_pScreenshotPanel->SetDialogVariable( "text", wLabel );
  468. g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( this, "HudSnapShotReminderIn" );
  469. }
  470. m_pScreenshotPanel->SetVisible( bShow );
  471. }
  472. int CDODFreezePanel::HudElementKeyInput( int down, ButtonCode_t keynum, const char *pszCurrentBinding )
  473. {
  474. if ( ShouldDraw() && pszCurrentBinding )
  475. {
  476. if ( FStrEq( pszCurrentBinding, "screenshot" ) || FStrEq( pszCurrentBinding, "jpeg" ) )
  477. {
  478. // move the target id to the corner
  479. if ( m_pBasePanel )
  480. {
  481. int w, h;
  482. m_pBasePanel->GetSize( w, h );
  483. m_pBasePanel->SetPos( ScreenWidth() - w, ScreenHeight() - h );
  484. }
  485. // Get the local player.
  486. C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
  487. if ( pPlayer )
  488. {
  489. //Do effects
  490. g_flFreezeFlash = gpGlobals->curtime + 0.75f;
  491. pPlayer->EmitSound( "Camera.SnapShot" );
  492. //Extend Freezecam by a couple more seconds.
  493. engine->ClientCmd( "extendfreeze" );
  494. view->FreezeFrame( 3.0f );
  495. //Hide the reminder panel
  496. m_flShowSnapshotReminderAt = 0;
  497. ShowSnapshotPanel( false );
  498. m_bHoldingAfterScreenshot = true;
  499. //Set the screenshot name
  500. if ( m_iKillerIndex <= MAX_PLAYERS )
  501. {
  502. const char *pszKillerName = g_PR->GetPlayerName( m_iKillerIndex );
  503. if ( pszKillerName )
  504. {
  505. ConVarRef cl_screenshotname( "cl_screenshotname" );
  506. if ( cl_screenshotname.IsValid() )
  507. {
  508. char szScreenShotName[512];
  509. Q_snprintf( szScreenShotName, sizeof( szScreenShotName ), "%s %s", pszKillerName, FREEZECAM_SCREENSHOT_STRING );
  510. cl_screenshotname.SetValue( szScreenShotName );
  511. }
  512. }
  513. }
  514. }
  515. }
  516. }
  517. return 0;
  518. }
  519. //-----------------------------------------------------------------------------
  520. // Purpose: Shows or hides the nemesis part of the panel
  521. //-----------------------------------------------------------------------------
  522. void CDODFreezePanel::ShowNemesisPanel( bool bShow )
  523. {
  524. m_pNemesisSubPanel->SetVisible( bShow );
  525. if ( bShow )
  526. {
  527. vgui::Label *pLabel = dynamic_cast< vgui::Label *>( m_pNemesisSubPanel->FindChildByName( "NemesisLabel" ) );
  528. vgui::Panel *pBG = m_pNemesisSubPanel->FindChildByName( "NemesisPanelBG" );
  529. vgui::ImagePanel *pIcon = dynamic_cast< vgui::ImagePanel *>( m_pNemesisSubPanel->FindChildByName( "NemesisIcon" ) );
  530. // check that our Nemesis panel and resize it to the length of the string (the right side is pinned and doesn't move)
  531. if ( pLabel && pBG && pIcon )
  532. {
  533. int wide, tall;
  534. pLabel->GetContentSize( wide, tall );
  535. int nDiff = wide - pLabel->GetWide();
  536. if ( nDiff != 0 )
  537. {
  538. int x, y, w, t;
  539. // move the icon
  540. pIcon->GetBounds( x, y, w, t );
  541. pIcon->SetBounds( x - nDiff, y, w, t );
  542. // move/resize the label
  543. pLabel->GetBounds( x, y, w, t );
  544. pLabel->SetBounds( x - nDiff, y, w + nDiff, t );
  545. // move/resize the background
  546. pBG->GetBounds( x, y, w, t );
  547. pBG->SetBounds( x - nDiff, y, w + nDiff, t );
  548. }
  549. }
  550. }
  551. }
  552. //-----------------------------------------------------------------------------
  553. // Purpose:
  554. //-----------------------------------------------------------------------------
  555. CDODFreezePanelCallout::CDODFreezePanelCallout( Panel *parent, const char *name ) : EditablePanel(parent,name)
  556. {
  557. }
  558. //-----------------------------------------------------------------------------
  559. // Purpose: Applies scheme settings
  560. //-----------------------------------------------------------------------------
  561. void CDODFreezePanelCallout::ApplySchemeSettings( vgui::IScheme *pScheme )
  562. {
  563. BaseClass::ApplySchemeSettings( pScheme );
  564. LoadControlSettings( "resource/UI/FreezePanelCallout.res" );
  565. }