Counter Strike : Global Offensive Source Code
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.

1153 lines
36 KiB

  1. //========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #if defined( INCLUDE_SCALEFORM )
  9. #include "sfhudwinpanel.h"
  10. #include "hud_macros.h"
  11. #include "vgui/ILocalize.h"
  12. #include "vgui/ISurface.h"
  13. #include "iclientmode.h"
  14. #include "hud.h"
  15. #include "hudelement.h"
  16. #include "hud_element_helper.h"
  17. #include "scaleformui/scaleformui.h"
  18. #include "c_playerresource.h"
  19. #include "c_cs_playerresource.h"
  20. #include "sfhudfreezepanel.h"
  21. #include "cs_player_rank_mgr.h"
  22. #include "achievements_cs.h"
  23. #include "cs_player_rank_shared.h"
  24. #include "gamestringpool.h"
  25. #include "sfhud_teamcounter.h"
  26. #include "cs_client_gamestats.h"
  27. #include "fmtstr.h"
  28. #include <engine/IEngineSound.h>
  29. #include "c_team.h"
  30. // memdbgon must be the last include file in a .cpp file!!!
  31. #include "tier0/memdbgon.h"
  32. DECLARE_HUDELEMENT( SFHudWinPanel );
  33. SFUI_BEGIN_GAME_API_DEF
  34. SFUI_END_GAME_API_DEF( SFHudWinPanel, WinPanel );
  35. extern ConVar cl_draw_only_deathnotices;
  36. //-----------------------------------------------------------------------------
  37. // Purpose: Constructor
  38. //-----------------------------------------------------------------------------
  39. SFHudWinPanel::SFHudWinPanel( const char *value ) : SFHudFlashInterface( value ),
  40. m_bVisible( false ),
  41. m_hWinPanelParent( NULL ),
  42. m_hWinner( NULL ),
  43. m_hReason( NULL ),
  44. m_hMVP( NULL ),
  45. m_hSurrender( NULL ),
  46. m_hFunFact( NULL ),
  47. m_hEloPanel( NULL ),
  48. m_hRankPanel( NULL ),
  49. m_hMedalPanel( NULL ),
  50. m_hProgressText( NULL ),
  51. m_hNextWeaponPanel( NULL ),
  52. m_nFunFactPlayer( 0 ),
  53. m_nFunfactToken( NULL ),
  54. m_nFunFactParam1( 0 ),
  55. m_nFunFactParam2( 0 ),
  56. m_nFunFactParam3( 0 ),
  57. m_bShouldSetWinPanelExtraData( false ),
  58. m_fSetWinPanelExtraDataTime( 0.0 ),
  59. m_nRoundStartELO( 0 ),
  60. m_iMVP( 0 )
  61. {
  62. SetHiddenBits( HIDEHUD_MISCSTATUS );
  63. }
  64. void SFHudWinPanel::LevelInit( void )
  65. {
  66. int slot = GET_ACTIVE_SPLITSCREEN_SLOT();
  67. if ( !FlashAPIIsValid() && slot == 0 )
  68. {
  69. SFUI_REQUEST_ELEMENT( SF_SS_SLOT( GET_ACTIVE_SPLITSCREEN_SLOT() ), g_pScaleformUI, SFHudWinPanel, this, WinPanel );
  70. }
  71. }
  72. void SFHudWinPanel::LevelShutdown( void )
  73. {
  74. if ( FlashAPIIsValid() )
  75. {
  76. RemoveFlashElement();
  77. }
  78. }
  79. bool SFHudWinPanel::ShouldDraw( void )
  80. {
  81. if ( IsTakingAFreezecamScreenshot() )
  82. return false;
  83. return cl_drawhud.GetBool() && cl_draw_only_deathnotices.GetBool() == false && CHudElement::ShouldDraw();
  84. }
  85. void SFHudWinPanel::SetActive( bool bActive )
  86. {
  87. // if ( !bActive && m_bVisible )
  88. // {
  89. // Hide();
  90. // }
  91. CHudElement::SetActive( bActive );
  92. }
  93. void SFHudWinPanel::FlashReady( void )
  94. {
  95. if ( !m_FlashAPI )
  96. {
  97. return;
  98. }
  99. m_hWinPanelParent = g_pScaleformUI->Value_GetMember( m_FlashAPI, "WinPanel" );
  100. if ( m_hWinPanelParent )
  101. {
  102. SFVALUE innerRoot = g_pScaleformUI->Value_GetMember( m_hWinPanelParent, "InnerWinPanel" );
  103. if ( innerRoot )
  104. {
  105. m_hWinner = g_pScaleformUI->TextObject_MakeTextObjectFromMember( innerRoot, "WinnerText" );
  106. m_hReason = g_pScaleformUI->TextObject_MakeTextObjectFromMember( innerRoot, "WinReason" );
  107. m_hMVP = g_pScaleformUI->TextObject_MakeTextObjectFromMember( innerRoot, "MVPText" );
  108. m_hSurrender = g_pScaleformUI->TextObject_MakeTextObjectFromMember( innerRoot, "Surrender" );
  109. m_hFunFact = g_pScaleformUI->TextObject_MakeTextObjectFromMember( innerRoot, "FunFact" );
  110. m_hEloPanel = g_pScaleformUI->Value_GetMember( innerRoot, "EloPanel" );
  111. m_hRankPanel = g_pScaleformUI->Value_GetMember( innerRoot, "RankPanel" );
  112. m_hMedalPanel = g_pScaleformUI->Value_GetMember( innerRoot, "MedalPanel" );
  113. m_hProgressText = g_pScaleformUI->Value_GetMember( innerRoot, "ProgressText" );
  114. m_hNextWeaponPanel = g_pScaleformUI->Value_GetMember( innerRoot, "NextWeaponPanel" );
  115. g_pScaleformUI->ReleaseValue( innerRoot );
  116. }
  117. }
  118. //Tell scaleform about the constant we plan on using later
  119. WITH_SFVALUEARRAY_SLOT_LOCKED( data, 3 )
  120. {
  121. m_pScaleformUI->ValueArray_SetElement( data, 0, WINNER_DRAW );
  122. m_pScaleformUI->ValueArray_SetElement( data, 1, WINNER_CT );
  123. m_pScaleformUI->ValueArray_SetElement( data, 2, WINNER_TER );
  124. m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "setResultConstants", data, 3 );
  125. }
  126. // listen for events
  127. ListenForGameEvent( "round_start" );
  128. ListenForGameEvent( "cs_win_panel_round" );
  129. ListenForGameEvent( "round_mvp" );
  130. g_pScaleformUI->AddDeviceDependentObject( this );
  131. Hide();
  132. }
  133. bool SFHudWinPanel::PreUnloadFlash( void )
  134. {
  135. g_pScaleformUI->RemoveDeviceDependentObject( this );
  136. SafeReleaseSFTextObject( m_hWinner );
  137. SafeReleaseSFTextObject( m_hReason );
  138. SafeReleaseSFTextObject( m_hMVP );
  139. SafeReleaseSFTextObject( m_hSurrender );
  140. SafeReleaseSFTextObject( m_hFunFact );
  141. SafeReleaseSFVALUE( m_hEloPanel );
  142. SafeReleaseSFVALUE( m_hRankPanel );
  143. SafeReleaseSFVALUE( m_hMedalPanel );
  144. SafeReleaseSFVALUE( m_hProgressText );
  145. SafeReleaseSFVALUE( m_hNextWeaponPanel );
  146. SafeReleaseSFVALUE( m_hWinPanelParent );
  147. return true;
  148. }
  149. void SFHudWinPanel::ProcessInput( void )
  150. {
  151. if ( m_bShouldSetWinPanelExtraData && m_fSetWinPanelExtraDataTime <= gpGlobals->curtime )
  152. {
  153. m_bShouldSetWinPanelExtraData = false;
  154. SetWinPanelExtraData();
  155. }
  156. }
  157. CEG_NOINLINE void SFHudWinPanel::FireGameEvent( IGameEvent* event )
  158. {
  159. const char *pEventName = event->GetName();
  160. if ( V_strcmp( "round_start", pEventName ) == 0 )
  161. {
  162. if ( m_pScaleformUI )
  163. {
  164. WITH_SLOT_LOCKED
  165. {
  166. // At the end of every round, clear the Scaleform mesh cache to recover some memory
  167. g_pScaleformUI->ClearCache();
  168. }
  169. }
  170. // Reset MVP info when round starts
  171. SetMVP( NULL, CSMVP_UNDEFINED );
  172. Hide();
  173. GetViewPortInterface()->UpdateAllPanels();
  174. }
  175. else if ( V_strcmp( "round_mvp", pEventName ) == 0 )
  176. {
  177. C_BasePlayer *basePlayer = UTIL_PlayerByUserId( event->GetInt( "userid" ) );
  178. if ( basePlayer )
  179. {
  180. CSMvpReason_t mvpReason = (CSMvpReason_t)event->GetInt( "reason" );
  181. int32 nMusicKitMVPs = event->GetInt( "musickitmvps" );
  182. SetMVP( ToCSPlayer( basePlayer ), mvpReason, nMusicKitMVPs );
  183. }
  184. }
  185. else if ( V_strcmp( "cs_win_panel_round", pEventName ) == 0 )
  186. {
  187. if ( !FlashAPIIsValid() )
  188. return;
  189. m_bShouldSetWinPanelExtraData = true;
  190. m_fSetWinPanelExtraDataTime = gpGlobals->curtime + 1.0f;
  191. int nConnectionProtocol = engine->GetConnectionDataProtocol();
  192. int iEndEvent = event->GetInt( "final_event" );
  193. if ( nConnectionProtocol &&
  194. ( iEndEvent >= 0 ) && // backwards compatibility: we switched to consistent numbering in the enum
  195. ( nConnectionProtocol < 13500 ) ) // and older demos have one-less numbers in "final_event" before 1.35.0.0 (Sep 15, 2015 3:20 PM release BuildID 776203)
  196. ++ iEndEvent;
  197. m_nFunFactPlayer = event->GetInt( "funfact_player" );
  198. m_nFunfactToken = AllocPooledString( event->GetString( "funfact_token", "" ) );
  199. m_nFunFactParam1 = event->GetInt( "funfact_data1" );
  200. m_nFunFactParam2 = event->GetInt( "funfact_data2" );
  201. m_nFunFactParam3 = event->GetInt( "funfact_data3" );
  202. if ( CSGameRules() && (CSGameRules()->IsPlayingGunGameProgressive() || CSGameRules()->IsPlayingGunGameDeathmatch()) )
  203. {
  204. ShowGunGameWinPanel();
  205. }
  206. else
  207. {
  208. // show the win panel
  209. switch ( iEndEvent )
  210. {
  211. case Target_Bombed:
  212. case VIP_Assassinated:
  213. case Terrorists_Escaped:
  214. case Terrorists_Win:
  215. case Hostages_Not_Rescued:
  216. case VIP_Not_Escaped:
  217. case CTs_Surrender:
  218. case Terrorists_Planted:
  219. ShowTeamWinPanel( WINNER_TER, "SFUI_WinPanel_T_Win" );
  220. break;
  221. case VIP_Escaped:
  222. case CTs_PreventEscape:
  223. case Escaping_Terrorists_Neutralized:
  224. case Bomb_Defused:
  225. case CTs_Win:
  226. case All_Hostages_Rescued:
  227. case Target_Saved:
  228. case Terrorists_Not_Escaped:
  229. case Terrorists_Surrender:
  230. case CTs_ReachedHostage:
  231. ShowTeamWinPanel( WINNER_CT, "SFUI_WinPanel_CT_Win" );
  232. break;
  233. case Round_Draw:
  234. ShowTeamWinPanel( WINNER_DRAW, "SFUI_WinPanel_Round_Draw" );
  235. break;
  236. default:
  237. Assert( 0 );
  238. break;
  239. }
  240. Assert( m_pScaleformUI );
  241. WITH_SLOT_LOCKED
  242. {
  243. // Set the MVP text.
  244. if ( m_hSurrender )
  245. {
  246. if ( iEndEvent == CTs_Surrender )
  247. {
  248. m_hSurrender->SetTextHTML( "#winpanel_end_cts_surrender" );
  249. }
  250. else if ( iEndEvent == Terrorists_Surrender )
  251. {
  252. m_hSurrender->SetTextHTML( "#winpanel_end_terrorists_surrender" );
  253. }
  254. else
  255. {
  256. m_hSurrender->SetTextHTML( "" );
  257. }
  258. }
  259. }
  260. //Map the round end events onto localized strings
  261. char* endEventToString[RoundEndReason_Count];
  262. V_memset( endEventToString, 0, sizeof( endEventToString ) );
  263. //terrorist win events
  264. endEventToString[Target_Bombed] = "#winpanel_end_target_bombed";
  265. endEventToString[VIP_Assassinated] = "#winpanel_end_vip_assassinated";
  266. endEventToString[Terrorists_Escaped] = "#winpanel_end_terrorists_escaped";
  267. endEventToString[Terrorists_Win] = "#winpanel_end_terrorists__kill";
  268. endEventToString[Hostages_Not_Rescued] = "#winpanel_end_hostages_not_rescued";
  269. endEventToString[VIP_Not_Escaped] = "#winpanel_end_vip_not_escaped";
  270. endEventToString[CTs_Surrender] = "#winpanel_end_cts_surrender";
  271. endEventToString[Terrorists_Planted] = "TEMP STRING - TERRORISTS PLANTED";
  272. //CT win events
  273. endEventToString[VIP_Escaped] = "#winpanel_end_vip_escaped";
  274. endEventToString[CTs_PreventEscape] = "#winpanel_end_cts_prevent_escape";
  275. endEventToString[Escaping_Terrorists_Neutralized] = "#winpanel_end_escaping_terrorists_neutralized";
  276. endEventToString[Bomb_Defused] = "#winpanel_end_bomb_defused";
  277. endEventToString[CTs_Win] = "#winpanel_end_cts_win";
  278. endEventToString[All_Hostages_Rescued] = "#winpanel_end_all_hostages_rescued";
  279. endEventToString[Target_Saved] = "#winpanel_end_target_saved";
  280. endEventToString[Terrorists_Not_Escaped] = "#winpanel_end_terrorists_not_escaped";
  281. endEventToString[Terrorists_Surrender] = "#winpanel_end_terrorists_surrender";
  282. endEventToString[CTs_ReachedHostage] = "#winpanel_end_cts_reach_hostage";
  283. //We don't show a round end panel for these
  284. endEventToString[Game_Commencing] = "";
  285. endEventToString[Round_Draw] = "";
  286. const wchar_t* wszEventMessage = NULL;
  287. if ( iEndEvent >= 0 && iEndEvent < RoundEndReason_Count )
  288. {
  289. wszEventMessage = g_pVGuiLocalize->Find( endEventToString[iEndEvent] );
  290. }
  291. Assert( m_pScaleformUI );
  292. WITH_SLOT_LOCKED
  293. {
  294. if ( m_hReason )
  295. {
  296. if ( wszEventMessage != NULL )
  297. {
  298. m_hReason->SetTextHTML( wszEventMessage );
  299. }
  300. else
  301. {
  302. m_hReason->SetTextHTML( "" );
  303. }
  304. }
  305. }
  306. }
  307. }
  308. }
  309. void SFHudWinPanel::SetWinPanelExtraData()
  310. {
  311. if ( !FlashAPIIsValid() )
  312. return;
  313. if ( !CSGameRules() )
  314. return;
  315. /*
  316. WIN_EXTRATYPE_FUN = 0,
  317. WIN_EXTRATYPE_AWARD,
  318. WIN_EXTRATYPE_RANK,
  319. WIN_EXTRATYPE_ELO,
  320. WIN_EXTRATYPE_SEASONRANK,
  321. */
  322. int nExtraPanelType = WIN_EXTRATYPE_NONE;
  323. //SetWinPanelItemDrops( index:Number, strId:String, PlayerXuid:String )
  324. //g_PlayerRankManager.PrintRankProgressThisRound();
  325. int nIdealProgressCatagory = MEDAL_CATEGORY_NONE;
  326. // ELO will need to be updated before this event happens so we get the right info
  327. int nEloBracket = -1;
  328. int nEloDelta = g_PlayerRankManager.GetEloBracketChange( nEloBracket );
  329. const CUtlVector<RankIncreasedEvent_t> &medalRankIncreases = g_PlayerRankManager.GetRankIncreasesThisRound();
  330. const CUtlVector<MedalEarnedEvent_t> &medalsAwarded = g_PlayerRankManager.GetMedalsEarnedThisRound();
  331. CUtlVector<MedalStatEvent_t> medalStatsAwarded;
  332. g_PlayerRankManager.GetMedalStatsEarnedThisRound( medalStatsAwarded );
  333. bool bShowProgress = false;
  334. bool bHideProgressAndFunFact = false;
  335. bool bIsWarmup = CSGameRules()->IsWarmupPeriod();
  336. if ( !bIsWarmup && nEloBracket >= 0 && nEloDelta != 0 && m_hEloPanel )
  337. {
  338. // tell the script to set the icon and show it
  339. // get the text needed and set the text
  340. const wchar_t *eloString;
  341. if ( nEloDelta > 0 )
  342. eloString = g_pVGuiLocalize->Find( "#SFUI_WinPanel_elo_up_string" );
  343. else
  344. eloString = g_pVGuiLocalize->Find( "#SFUI_WinPanel_elo_down_string" );
  345. if ( !eloString )
  346. {
  347. Warning( "Failed to find localization strings for elo change in win panel\n" );
  348. }
  349. WITH_SFVALUEARRAY_SLOT_LOCKED( data, 2 )
  350. {
  351. m_pScaleformUI->ValueArray_SetElement( data, 0, nEloBracket );
  352. m_pScaleformUI->ValueArray_SetElement( data, 1, eloString ? eloString : L"" );
  353. m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "SetEloBracketInfo", data, 2 );
  354. }
  355. nExtraPanelType = WIN_EXTRATYPE_ELO;
  356. // Once we display the change in rank, reset the recorded delta.
  357. g_PlayerRankManager.ResetRecordedEloBracketChange();
  358. }
  359. else if ( !bIsWarmup && medalRankIncreases.Count() > 0 )
  360. {
  361. // static "award" text
  362. ISFTextObject* hRankPromtText = g_pScaleformUI->TextObject_MakeTextObjectFromMember( m_hRankPanel, "RankEarned" );
  363. ISFTextObject* hRankNameText = g_pScaleformUI->TextObject_MakeTextObjectFromMember( m_hRankPanel, "RankName" );
  364. if ( hRankPromtText && hRankNameText )
  365. {
  366. int nTotalRankIncreases = medalRankIncreases.Count();
  367. //MEDAL_CATEGORY_TEAM_AND_OBJECTIVE = MEDAL_CATEGORY_START,
  368. //MEDAL_CATEGORY_COMBAT,
  369. //MEDAL_CATEGORY_WEAPON,
  370. //MEDAL_CATEGORY_MAP,
  371. //MEDAL_CATEGORY_ARSENAL,
  372. int nBestIndex = 0;
  373. int nHighestRank = 0;
  374. CUtlVector< int > tieList;
  375. // find the place where we earned the highest rank
  376. for ( int i=0; i < nTotalRankIncreases; i++ )
  377. {
  378. nHighestRank = g_PlayerRankManager.CalculateRankForCategory( medalRankIncreases[nBestIndex].m_category );
  379. int nCurRank = g_PlayerRankManager.CalculateRankForCategory( medalRankIncreases[i].m_category );
  380. int nDelta = nCurRank - nHighestRank;
  381. if ( medalRankIncreases[i].m_category >= MEDAL_CATEGORY_ACHIEVEMENTS_END )
  382. {
  383. nBestIndex = i;
  384. tieList.RemoveAll();
  385. }
  386. else if ( nDelta == 0 )
  387. {
  388. // keep track of the ranks of the same value
  389. nBestIndex = i;
  390. tieList.AddToTail(i);
  391. }
  392. else if ( nDelta > 0 )
  393. {
  394. nBestIndex = i;
  395. tieList.RemoveAll();
  396. }
  397. }
  398. if ( tieList.Count() > 0 )
  399. {
  400. // break any ties by picking on randomly
  401. nBestIndex = tieList[ RandomInt( 0, tieList.Count()-1) ];
  402. }
  403. bool bIsCoinLevelUp = false;
  404. MedalCategory_t nCurrentBestCatagory = medalRankIncreases[nBestIndex].m_category;
  405. int nCurrentRankForCatagory = 0;
  406. nCurrentRankForCatagory = g_PlayerRankManager.CalculateRankForCategory( medalRankIncreases[nBestIndex].m_category );
  407. WITH_SFVALUEARRAY_SLOT_LOCKED( data, 2 )
  408. {
  409. m_pScaleformUI->ValueArray_SetElement( data, 0, nCurrentBestCatagory );
  410. m_pScaleformUI->ValueArray_SetElement( data, 1, nCurrentRankForCatagory );
  411. m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "SetRankUpIcon", data, 2 );
  412. }
  413. wchar_t finalAwardText[256];
  414. // say whether they earned a new rank, 2 new ranks, a new rank in two catagories, etc
  415. if ( hRankPromtText && ( ( nTotalRankIncreases <= 1 ) || bIsCoinLevelUp ) )
  416. {
  417. g_pVGuiLocalize->ConstructString( finalAwardText, sizeof(finalAwardText),
  418. bIsCoinLevelUp ? "#SFUI_WinPanel_coin_awarded" : "#SFUI_WinPanel_rank_awarded",
  419. NULL );
  420. }
  421. else
  422. {
  423. wchar_t wNum[16];
  424. V_snwprintf( wNum, ARRAYSIZE( wNum ), L"%i", nTotalRankIncreases );
  425. int param1 = nTotalRankIncreases;
  426. wchar_t wAnnounceText[256];
  427. V_snwprintf( wAnnounceText, ARRAYSIZE( wAnnounceText ), L"%i", param1 );
  428. const wchar_t *awardString = g_pVGuiLocalize->Find( "#SFUI_WinPanel_rank_awarded_multi" );
  429. g_pVGuiLocalize->ConstructString( finalAwardText, sizeof(finalAwardText), awardString , 1, wNum );
  430. }
  431. // set the name of the new rank that you achieved
  432. wchar_t finalRankText[256];
  433. if ( hRankNameText )
  434. {
  435. const wchar_t *rankString = g_pVGuiLocalize->Find( "#SFUI_WinPanel_rank_name_string" );
  436. g_pVGuiLocalize->ConstructString( finalRankText, sizeof(finalRankText), rankString , 2, g_pVGuiLocalize->Find(g_PlayerRankManager.GetMedalCatagoryName(nCurrentBestCatagory)),
  437. g_pVGuiLocalize->Find(g_PlayerRankManager.GetMedalCatagoryRankName( bIsCoinLevelUp ? (nCurrentRankForCatagory-1) : nCurrentRankForCatagory )) );
  438. WITH_SLOT_LOCKED
  439. {
  440. hRankNameText->SetTextHTML( finalRankText );
  441. }
  442. }
  443. WITH_SFVALUEARRAY_SLOT_LOCKED( data, 2 )
  444. {
  445. m_pScaleformUI->ValueArray_SetElement( data, 0, finalAwardText );
  446. m_pScaleformUI->ValueArray_SetElement( data, 1, finalRankText );
  447. m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "SetRankUpText", data, 2 );
  448. }
  449. if ( nHighestRank < (MEDAL_CATEGORY_COUNT-1) )
  450. nIdealProgressCatagory = nCurrentBestCatagory;
  451. SafeReleaseSFTextObject( hRankPromtText );
  452. SafeReleaseSFTextObject( hRankNameText );
  453. }
  454. nExtraPanelType = WIN_EXTRATYPE_RANK;
  455. bShowProgress = true;
  456. }
  457. else if ( !bIsWarmup && medalsAwarded.Count() > 0 )
  458. {
  459. WITH_SLOT_LOCKED
  460. {
  461. int nMaxMedals = 7;
  462. for ( int i = 0; i < nMaxMedals; i++ )
  463. {
  464. //get the award name for slot i
  465. WITH_SFVALUEARRAY( data, 2 )
  466. {
  467. m_pScaleformUI->ValueArray_SetElement( data, 0, i );
  468. if ( i < medalsAwarded.Count() && medalsAwarded[i].m_pAchievement )
  469. {
  470. CBaseAchievement *pAchievement = medalsAwarded[i].m_pAchievement;
  471. m_pScaleformUI->ValueArray_SetElement( data, 1, pAchievement->GetName() );
  472. }
  473. else
  474. {
  475. m_pScaleformUI->ValueArray_SetElement( data, 1, "" );
  476. }
  477. m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "SetWinPanelAwardIcon", data, 2 );
  478. }
  479. }
  480. }
  481. nExtraPanelType = WIN_EXTRATYPE_AWARD;
  482. bShowProgress = true;
  483. }
  484. else if ( !bIsWarmup && medalStatsAwarded.Count() > 0 )
  485. {
  486. MedalStatEvent_t *pBestStat = NULL;
  487. float flHighestCompletionPct = -1.0f;
  488. FOR_EACH_VEC( medalStatsAwarded, i )
  489. {
  490. MedalStatEvent_t&stat = medalStatsAwarded[i];
  491. float pct = (float)(stat.m_pAchievement->GetCount()) / (float)(stat.m_pAchievement->GetGoal());
  492. if ( pct > flHighestCompletionPct )
  493. {
  494. flHighestCompletionPct = pct;
  495. pBestStat = &medalStatsAwarded[i];
  496. }
  497. }
  498. if ( pBestStat )
  499. {
  500. const char* pszLocToken = GetLocTokenForStatId( pBestStat->m_StatType );
  501. if ( pszLocToken && pBestStat->m_pAchievement )
  502. {
  503. WITH_SFVALUEARRAY_SLOT_LOCKED( data, 6 )
  504. {
  505. m_pScaleformUI->ValueArray_SetElement( data, 0, pBestStat->m_pAchievement->GetName() );
  506. m_pScaleformUI->ValueArray_SetElement( data, 1, pBestStat->m_pAchievement->GetCount() );
  507. m_pScaleformUI->ValueArray_SetElement( data, 2, pBestStat->m_pAchievement->GetGoal() );
  508. const StatsCollection_t roundStats = g_CSClientGameStats.GetRoundStats(0);
  509. m_pScaleformUI->ValueArray_SetElement( data, 3, roundStats[pBestStat->m_StatType] );
  510. m_pScaleformUI->ValueArray_SetElement( data, 4, pBestStat->m_category );
  511. // Progress text for this stat based medal
  512. const wchar_t *progString = g_pVGuiLocalize->Find( pszLocToken );
  513. wchar_t finalProgressText[256];
  514. wchar_t count[8], goal[8];
  515. V_snwprintf( count, ARRAYSIZE( count ), L"%i", pBestStat->m_pAchievement->GetCount() );
  516. V_snwprintf( goal, ARRAYSIZE( goal ), L"%i", pBestStat->m_pAchievement->GetGoal() );
  517. g_pVGuiLocalize->ConstructString( finalProgressText, sizeof(finalProgressText), progString, 3, count, goal, ACHIEVEMENT_LOCALIZED_NAME( pBestStat->m_pAchievement ) );
  518. m_pScaleformUI->ValueArray_SetElement( data, 5, finalProgressText );
  519. m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "SetWinPanelStatProgress", data, 6 );
  520. bHideProgressAndFunFact = true;
  521. }
  522. }
  523. }
  524. }
  525. else if ( !bIsWarmup && CSGameRules() && CSGameRules()->IsPlayingGunGame() )
  526. {
  527. const char *szGrenName = NULL;
  528. C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
  529. if ( pPlayer )
  530. {
  531. int nextWeaponID = CSGameRules()->GetNextGunGameWeapon( pPlayer->GetPlayerGunGameWeaponIndex(), pPlayer->GetTeamNumber() );
  532. const char *pchClassName = "unknown";
  533. const char *pchPrintName = "unknown";
  534. const CEconItemDefinition *pDef = GetItemSchema()->GetItemDefinition( nextWeaponID );
  535. if ( pDef && pDef->GetDefinitionIndex() != 0 )
  536. {
  537. pchClassName = pDef->GetDefinitionName();
  538. pchPrintName = pDef->GetItemBaseName();
  539. }
  540. else
  541. {
  542. const CCSWeaponInfo* pWeaponInfo = GetWeaponInfo( (CSWeaponID)nextWeaponID );
  543. if ( pWeaponInfo )
  544. {
  545. pchClassName = pWeaponInfo->szClassName;
  546. pchPrintName = pWeaponInfo->szPrintName;
  547. }
  548. }
  549. int nKillValue = pPlayer->GetNumGunGameTRKillPoints();
  550. int nCurIndex = (float)pPlayer->GetPlayerGunGameWeaponIndex();
  551. int nMaxIndex = CSGameRules()->GetNumProgressiveGunGameWeapons( pPlayer->GetTeamNumber() );
  552. if ( nCurIndex != nMaxIndex && nKillValue > 0 )
  553. {
  554. int nBonusGrenade = CSGameRules()->GetGunGameTRBonusGrenade( pPlayer );
  555. if ( nBonusGrenade == WEAPON_MOLOTOV || nBonusGrenade == WEAPON_INCGRENADE )
  556. {
  557. if ( pPlayer->GetTeamNumber() == TEAM_CT )
  558. {
  559. szGrenName = "weapon_incgrenade";
  560. }
  561. else
  562. {
  563. szGrenName = "weapon_molotov";
  564. }
  565. }
  566. else if ( nBonusGrenade == WEAPON_FLASHBANG )
  567. {
  568. szGrenName = "weapon_flashbang";
  569. }
  570. else if ( nBonusGrenade == WEAPON_HEGRENADE )
  571. {
  572. szGrenName = "weapon_hegrenade";
  573. }
  574. wchar_t *titleString = NULL;
  575. if ( CSGameRules()->IsPlayingGunGameTRBomb() )
  576. {
  577. titleString = g_pVGuiLocalize->Find( "#SFUI_WS_GG_YourNextWeaponIs" );
  578. }
  579. else
  580. {
  581. titleString = g_pVGuiLocalize->Find( "#SFUI_WS_GG_NextWep" );
  582. }
  583. WITH_SFVALUEARRAY_SLOT_LOCKED( data, 4 )
  584. {
  585. // Scaleform cannot handle NULL as a wide string name. Make sure it always gets a valid string.
  586. wchar_t *weaponName = L"";
  587. wchar_t *newWeaponName = g_pVGuiLocalize->Find( pchPrintName );
  588. if ( newWeaponName )
  589. {
  590. weaponName = newWeaponName;
  591. }
  592. m_pScaleformUI->ValueArray_SetElement( data, 0, titleString );
  593. m_pScaleformUI->ValueArray_SetElement( data, 1, weaponName );
  594. m_pScaleformUI->ValueArray_SetElement( data, 2, pchClassName );
  595. m_pScaleformUI->ValueArray_SetElement( data, 3, szGrenName ? szGrenName : "");
  596. m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "SetGunGamePanelData", data, 4 );
  597. }
  598. nExtraPanelType = WIN_EXTRATYPE_GGNEXT;
  599. }
  600. }
  601. }
  602. // set the progress bar text
  603. //int nMedalsNeededToRank = 0;
  604. CUtlVector< int > nProgressCatagories;
  605. // if one of the other panel above told us to show, we should show
  606. if ( !bHideProgressAndFunFact )
  607. {
  608. if ( bShowProgress )
  609. {
  610. if ( nIdealProgressCatagory == -1 )
  611. {
  612. for ( int i = 0; i < MEDAL_CATEGORY_ACHIEVEMENTS_END; i++ )
  613. {
  614. int nTempRank = g_PlayerRankManager.CalculateRankForCategory( (MedalCategory_t)i );
  615. if ( nTempRank < (MEDAL_RANK_COUNT-1) )
  616. nProgressCatagories.AddToTail(i);
  617. }
  618. if ( nProgressCatagories.Count() == 0 )
  619. {
  620. // we maxed out all of our ranks, congrats!!!!
  621. bShowProgress = false;
  622. }
  623. else
  624. {
  625. // we don't have an ideal category to show a hint, so pick one to display
  626. nIdealProgressCatagory = nProgressCatagories[ RandomInt( 0, nProgressCatagories.Count()-1 ) ];
  627. nProgressCatagories.RemoveAll();
  628. }
  629. }
  630. if ( bShowProgress )
  631. {
  632. int nCurrentRank = g_PlayerRankManager.CalculateRankForCategory( (MedalCategory_t)nIdealProgressCatagory );
  633. int nMinMedalsNeeded = g_PlayerRankManager.GetMinMedalsForRank( (MedalCategory_t)nIdealProgressCatagory, (MedalRank_t)(MIN(nCurrentRank + 1, (int)(MEDAL_RANK_COUNT-1))) );
  634. int nMedalsAchieved = g_PlayerRankManager.CountAchievedInCategory( (MedalCategory_t)nIdealProgressCatagory );
  635. const wchar_t *progString = g_pVGuiLocalize->Find( "#SFUI_WinPanelProg_need_in_catagory" );
  636. wchar_t wzAwardNum[4];
  637. _snwprintf( wzAwardNum, ARRAYSIZE(wzAwardNum), L"%d", (nMinMedalsNeeded-nMedalsAchieved) );
  638. wchar_t finalProgressText[256];
  639. g_pVGuiLocalize->ConstructString( finalProgressText, sizeof(finalProgressText), progString , 2, wzAwardNum, g_pVGuiLocalize->Find( g_PlayerRankManager.GetMedalCatagoryName((MedalCategory_t)nIdealProgressCatagory) ) );
  640. SetProgressBarText( (nMinMedalsNeeded-nMedalsAchieved), finalProgressText );
  641. //Msg( "MinMedalsNeeded = %d, MedalsAchieved = %d, NeededForNext = %d\n", nMinMedalsNeeded, nMedalsAchieved, (nMinMedalsNeeded-nMedalsAchieved) );
  642. }
  643. }
  644. if ( bIsWarmup )
  645. {
  646. SetFunFactLabel( L"" );
  647. }
  648. // otherwise we show a FUN FACT!
  649. else if ( !bShowProgress )
  650. {
  651. /*
  652. "show_timer_defend" "bool"
  653. "show_timer_attack" "bool"
  654. "timer_time" "int"
  655. "final_event" "byte" // 0 - no event, 1 - bomb exploded, 2 - flag capped, 3 - timer expired
  656. "funfact_type" "byte" //WINPANEL_FUNFACT in cs_shareddef.h
  657. "funfact_player" "byte"
  658. "funfact_data1" "long"
  659. "funfact_data2" "long"
  660. "funfact_data3" "long"
  661. */
  662. if ( m_nFunFactPlayer == GetLocalPlayerIndex() )
  663. {
  664. CEG_PROTECT_VIRTUAL_FUNCTION( SFHudWinPanel_FireGameEvent );
  665. }
  666. // Final Fun Fact
  667. SetFunFactLabel( L"" );
  668. const char *pFunFact = STRING( m_nFunfactToken );
  669. if ( pFunFact && V_strlen( pFunFact ) > 0 )
  670. {
  671. wchar_t funFactText[256];
  672. wchar_t playerText[MAX_DECORATED_PLAYER_NAME_LENGTH];
  673. wchar_t dataText1[8], dataText2[8], dataText3[8];
  674. if ( m_nFunFactPlayer >= 1 && m_nFunFactPlayer <= MAX_PLAYERS )
  675. {
  676. playerText[0] = L'\0';
  677. C_CS_PlayerResource *cs_PR = dynamic_cast<C_CS_PlayerResource *>( g_PR );
  678. if ( !cs_PR )
  679. return;
  680. cs_PR->GetDecoratedPlayerName( m_nFunFactPlayer, playerText, sizeof( playerText ), k_EDecoratedPlayerNameFlag_Simple );
  681. if ( playerText[0] == L'\0' )
  682. {
  683. V_snwprintf( playerText, ARRAYSIZE( playerText ), PRI_WS_FOR_WS, g_pVGuiLocalize->Find( "#winpanel_former_player" ) );
  684. }
  685. }
  686. else
  687. {
  688. V_snwprintf( playerText, ARRAYSIZE( playerText ), L"" );
  689. }
  690. V_snwprintf( dataText1, ARRAYSIZE( dataText1 ), L"%i", m_nFunFactParam1 );
  691. V_snwprintf( dataText2, ARRAYSIZE( dataText2 ), L"%i", m_nFunFactParam2 );
  692. V_snwprintf( dataText3, ARRAYSIZE( dataText3 ), L"%i", m_nFunFactParam3 );
  693. // Vararg support on consoles isn't complete, so use the keyvalue version of ConstructString instead so
  694. // we can support formatting like "%s2 has fired %s1 shots", etc.
  695. KeyValues *pkvFunFactVariables = new KeyValues( "variables" );
  696. KeyValues::AutoDelete autodelete( pkvFunFactVariables );
  697. pkvFunFactVariables->SetWString( "s1", playerText );
  698. pkvFunFactVariables->SetWString( "s2", dataText1 );
  699. pkvFunFactVariables->SetWString( "s3", dataText2 );
  700. pkvFunFactVariables->SetWString( "s4", dataText3 );
  701. g_pVGuiLocalize->ConstructString( funFactText, sizeof(funFactText), pFunFact, pkvFunFactVariables );
  702. SetFunFactLabel( funFactText );
  703. if( g_pVGuiLocalize->Find( pFunFact ) == NULL )
  704. {
  705. Warning( "No valid fun fact string for %s\n", pFunFact );
  706. }
  707. }
  708. }
  709. }
  710. ShowWinExtraDataPanel( nExtraPanelType );
  711. }
  712. void SFHudWinPanel::SetProgressBarText( int nAmount, const wchar *wszDescText )
  713. {
  714. if ( !FlashAPIIsValid() )
  715. return;
  716. wchar_t wNum[16];
  717. V_snwprintf( wNum, ARRAYSIZE( wNum ), L"%i", nAmount );
  718. WITH_SFVALUEARRAY_SLOT_LOCKED( data, 2 )
  719. {
  720. m_pScaleformUI->ValueArray_SetElement( data, 0, wNum );
  721. m_pScaleformUI->ValueArray_SetElement( data, 1, wszDescText );
  722. m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "SetProgressText", data, 2 );
  723. }
  724. }
  725. void SFHudWinPanel::SetFunFactLabel( const wchar *szFunFact )
  726. {
  727. if ( !FlashAPIIsValid() )
  728. return;
  729. WITH_SFVALUEARRAY_SLOT_LOCKED( data, 1 )
  730. {
  731. m_pScaleformUI->ValueArray_SetElement( data, 0, szFunFact );
  732. m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "SetFunFactText", data, 1 );
  733. }
  734. }
  735. void SFHudWinPanel::SetMVP( C_CSPlayer* pPlayer, CSMvpReason_t reason, int32 nMusicKitMVPs /* = 0 */ )
  736. {
  737. if ( pPlayer )
  738. m_iMVP = pPlayer->entindex();
  739. if ( FlashAPIIsValid() )
  740. {
  741. if ( g_PR && pPlayer )
  742. {
  743. // First set the text to the name of the player.
  744. wchar_t wszPlayerName[MAX_DECORATED_PLAYER_NAME_LENGTH];
  745. ( ( C_CS_PlayerResource* ) g_PR )->GetDecoratedPlayerName( pPlayer->entindex(), wszPlayerName, sizeof( wszPlayerName ), EDecoratedPlayerNameFlag_t( k_EDecoratedPlayerNameFlag_Simple | k_EDecoratedPlayerNameFlag_DontUseNameOfControllingPlayer ) );
  746. //
  747. // Construct the reason text.
  748. //
  749. const char* mvpReasonToken = NULL;
  750. switch ( reason )
  751. {
  752. case CSMVP_ELIMINATION:
  753. mvpReasonToken = "winpanel_mvp_award_kills";
  754. break;
  755. case CSMVP_BOMBPLANT:
  756. mvpReasonToken = "winpanel_mvp_award_bombplant";
  757. break;
  758. case CSMVP_BOMBDEFUSE:
  759. mvpReasonToken = "winpanel_mvp_award_bombdefuse";
  760. break;
  761. case CSMVP_HOSTAGERESCUE:
  762. mvpReasonToken = "winpanel_mvp_award_rescue";
  763. break;
  764. case CSMVP_GUNGAMEWINNER:
  765. mvpReasonToken = "winpanel_mvp_award_gungame";
  766. break;
  767. default:
  768. mvpReasonToken = "winpanel_mvp_award";
  769. break;
  770. }
  771. wchar_t *pReason = g_pVGuiLocalize->Find( mvpReasonToken );
  772. if ( !pReason )
  773. {
  774. pReason = L"%s1";
  775. }
  776. wchar_t wszBuf[256];
  777. g_pVGuiLocalize->ConstructString( wszBuf, sizeof( wszBuf ), pReason, 1, wszPlayerName );
  778. // Get the player xuid.
  779. char xuidText[255];
  780. g_PR->FillXuidText( pPlayer->entindex(), xuidText, sizeof( xuidText ) );
  781. const int nParamCount = 5;
  782. WITH_SFVALUEARRAY_SLOT_LOCKED( data, nParamCount )
  783. {
  784. if ( m_hMVP )
  785. {
  786. m_hMVP->SetTextHTML( wszBuf );
  787. }
  788. int nParamNum = 0;
  789. m_pScaleformUI->ValueArray_SetElement( data, nParamNum++, xuidText );
  790. m_pScaleformUI->ValueArray_SetElement( data, nParamNum++, pPlayer->GetPlayerName() );
  791. m_pScaleformUI->ValueArray_SetElement( data, nParamNum++, pPlayer->GetTeamNumber() );
  792. m_pScaleformUI->ValueArray_SetElement( data, nParamNum++, pPlayer->IsLocalPlayer() );
  793. m_pScaleformUI->ValueArray_SetElement( data, nParamNum++, nMusicKitMVPs );
  794. Assert( nParamNum == nParamCount );
  795. m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "ShowAvatar", data, nParamCount );
  796. }
  797. if ( reason == CSMVP_GUNGAMEWINNER )
  798. {
  799. WITH_SFVALUEARRAY_SLOT_LOCKED( data, 5 )
  800. {
  801. int nSecond = -1;
  802. int nThird = -1;
  803. SFHudTeamCounter* pTeamCounter = GET_HUDELEMENT( SFHudTeamCounter );
  804. if ( pTeamCounter )
  805. {
  806. for ( int i = 0 ; i < MAX_PLAYERS ; ++i)
  807. {
  808. int indx = pTeamCounter->GetPlayerEntIndexInSlot( i );
  809. if ( pPlayer->entindex() != indx )
  810. {
  811. if ( nSecond == -1 )
  812. {
  813. nSecond = indx;
  814. }
  815. else
  816. {
  817. nThird = indx;
  818. break;
  819. }
  820. }
  821. }
  822. }
  823. char xuidText1[255];
  824. g_PR->FillXuidText( nSecond, xuidText1, sizeof( xuidText1 ) );
  825. char xuidText2[255];
  826. g_PR->FillXuidText( nThird, xuidText2, sizeof( xuidText2 ) );
  827. CBasePlayer* pBasePlayer1 = UTIL_PlayerByIndex( nSecond );
  828. C_CSPlayer* pPlayer1 = ToCSPlayer( pBasePlayer1 );
  829. CBasePlayer* pBasePlayer2 = UTIL_PlayerByIndex( nThird );
  830. C_CSPlayer* pPlayer2 = ToCSPlayer( pBasePlayer2 );
  831. m_pScaleformUI->ValueArray_SetElement( data, 0, wszPlayerName );
  832. m_pScaleformUI->ValueArray_SetElement( data, 1, xuidText1 );
  833. m_pScaleformUI->ValueArray_SetElement( data, 2, xuidText2 );
  834. m_pScaleformUI->ValueArray_SetElement( data, 3, pPlayer1 ? pPlayer1->GetTeamNumber() : -1 );
  835. m_pScaleformUI->ValueArray_SetElement( data, 4, pPlayer2 ? pPlayer2->GetTeamNumber() : -1 );
  836. m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "ShowGGRunnerUpAvatars", data, 5 );
  837. }
  838. }
  839. }
  840. else
  841. {
  842. WITH_SLOT_LOCKED
  843. {
  844. // Hide the MVP text.
  845. if ( m_hMVP )
  846. {
  847. m_hMVP->SetTextHTML( "" );
  848. }
  849. m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "HideAvatar", NULL, 0 );
  850. }
  851. }
  852. }
  853. }
  854. void SFHudWinPanel::ApplyYOffset( int nOffset )
  855. {
  856. if ( FlashAPIIsValid() )
  857. {
  858. WITH_SFVALUEARRAY_SLOT_LOCKED( data, 1 )
  859. {
  860. m_pScaleformUI->ValueArray_SetElement( data, 0, nOffset );
  861. m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "setYOffset", data, 1 );
  862. }
  863. }
  864. }
  865. void SFHudWinPanel::ShowTeamWinPanel( int result, const char* winnerText )
  866. {
  867. bool bOkToDraw = true;
  868. C_CSPlayer *pLocalPlayer = C_CSPlayer::GetLocalCSPlayer();
  869. if ( !pLocalPlayer )
  870. return;
  871. if ( pLocalPlayer->GetTeamNumber() == TEAM_UNASSIGNED && !pLocalPlayer->IsHLTV() )
  872. {
  873. bOkToDraw = false;
  874. }
  875. bool bShowTeamLogo = false;
  876. char szLogoString[64];
  877. szLogoString[0] = '\0';
  878. wchar_t wszWinnerText[1024];
  879. wszWinnerText[0] = L'\0';
  880. C_Team *pTeam = GetGlobalTeam( result );
  881. if ( pTeam && !StringIsEmpty( pTeam->Get_LogoImageString() ) )
  882. {
  883. bShowTeamLogo = true;
  884. V_snprintf( szLogoString, ARRAYSIZE( szLogoString ), TEAM_LOGO_IMG_STRING, pTeam->Get_LogoImageString() );
  885. }
  886. wchar_t wszName[512];
  887. if ( m_hWinPanelParent && m_hWinner && FlashAPIIsValid() && m_bActive && bOkToDraw )
  888. {
  889. if ( CSGameRules() && CSGameRules()->IsPlayingCoopMission() )
  890. {
  891. if ( result == TEAM_CT )
  892. g_pVGuiLocalize->ConstructString( wszName, sizeof( wszName ), g_pVGuiLocalize->Find( "#SFUI_WinPanel_Coop_Mission_Win" ), nullptr );
  893. else
  894. g_pVGuiLocalize->ConstructString( wszName, sizeof( wszName ), g_pVGuiLocalize->Find( "#SFUI_WinPanel_Coop_Mission_Lose" ), nullptr );
  895. g_pScaleformUI->MakeStringSafe( wszName, wszWinnerText, sizeof( wszWinnerText ) );
  896. }
  897. else if ( ( pTeam != NULL ) && !StringIsEmpty( pTeam->Get_ClanName() ) )
  898. {
  899. wchar_t wszTemp[MAX_TEAM_NAME_LENGTH];
  900. g_pVGuiLocalize->ConvertANSIToUnicode( pTeam->Get_ClanName(), wszTemp, sizeof( wszTemp ) );
  901. // const wchar_t *winString = g_pVGuiLocalize->Find( "#SFUI_WinPanel_Team_Win_Team" );
  902. g_pVGuiLocalize->ConstructString( wszName, sizeof( wszName ), g_pVGuiLocalize->Find( "#SFUI_WinPanel_Team_Win_Team" ), 1, wszTemp );
  903. // we have a custom team name, convert to wide
  904. //
  905. // now make the team name string safe
  906. g_pScaleformUI->MakeStringSafe( wszName, wszWinnerText, sizeof( wszWinnerText ) );
  907. }
  908. else
  909. {
  910. g_pVGuiLocalize->ConstructString( wszName, sizeof( wszName ), g_pVGuiLocalize->Find( winnerText ), nullptr );
  911. g_pScaleformUI->MakeStringSafe( wszName, wszWinnerText, sizeof( wszWinnerText ) );
  912. }
  913. WITH_SFVALUEARRAY_SLOT_LOCKED( data, 2 )
  914. {
  915. m_hWinner->SetTextHTML( wszWinnerText );
  916. {
  917. m_pScaleformUI->ValueArray_SetElement( data, 0, result );
  918. m_pScaleformUI->ValueArray_SetElement( data, 1, bShowTeamLogo ? szLogoString : "" );
  919. m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "showTeamWin", data, 2 );
  920. }
  921. }
  922. if ( GetViewPortInterface() && !pLocalPlayer->IsSpectator() && !engine->IsHLTV() )
  923. {
  924. GetViewPortInterface()->ShowPanel( PANEL_ALL, false );
  925. }
  926. m_bVisible = true;
  927. }
  928. }
  929. void SFHudWinPanel::ShowGunGameWinPanel( void /*int nWinner, int nSecond, int nThird*/ )
  930. {
  931. if ( m_hWinPanelParent && m_hWinner && FlashAPIIsValid() && m_bActive )
  932. {
  933. WITH_SLOT_LOCKED
  934. {
  935. m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "showArsenalWin", NULL, 0 );
  936. }
  937. if ( GetViewPortInterface() )
  938. {
  939. GetViewPortInterface()->ShowPanel( PANEL_ALL, false );
  940. }
  941. m_bVisible = true;
  942. }
  943. }
  944. void SFHudWinPanel::ShowWinExtraDataPanel( int nExtraPanelType )
  945. {
  946. if ( m_hWinPanelParent && m_hWinner && m_FlashAPI && m_bActive )
  947. {
  948. C_CSPlayer *pLocalPlayer = C_CSPlayer::GetLocalCSPlayer();
  949. if( pLocalPlayer )
  950. {
  951. C_RecipientFilter filter;
  952. filter.AddRecipient( pLocalPlayer );
  953. C_BaseEntity::EmitSound( filter, SOUND_FROM_WORLD, "Player.InfoPanel" );
  954. }
  955. WITH_SLOT_LOCKED
  956. {
  957. WITH_SFVALUEARRAY( data, 1 )
  958. {
  959. m_pScaleformUI->ValueArray_SetElement( data, 0, nExtraPanelType );
  960. m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "showTeamWinDataPanel", data, 1 );
  961. }
  962. }
  963. }
  964. }
  965. bool SFHudWinPanel::IsVisible( void )
  966. {
  967. return m_bVisible;
  968. }
  969. void SFHudWinPanel::Hide( void )
  970. {
  971. if ( m_FlashAPI && m_pScaleformUI)
  972. {
  973. WITH_SLOT_LOCKED
  974. {
  975. m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "hide", NULL, 0 );
  976. }
  977. m_bVisible = false;
  978. }
  979. }
  980. void SFHudWinPanel::DeviceReset( void *pDevice, void *pPresentParameters, void *pHWnd )
  981. {
  982. if ( FlashAPIIsValid() )
  983. {
  984. WITH_SLOT_LOCKED
  985. {
  986. m_pScaleformUI->Value_InvokeWithoutReturn( m_FlashAPI, "RefreshAvatarImage", NULL, 0 );
  987. }
  988. }
  989. }
  990. #endif // INCLUDE_SCALEFORM