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.

1659 lines
60 KiB

  1. //========= Copyright � 1996-2008, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=====================================================================================//
  6. #include "cbase.h"
  7. #include "basepanel.h"
  8. #include "uigamedata.h"
  9. #include <ctype.h>
  10. #include "./GameUI/IGameUI.h"
  11. #include "ienginevgui.h"
  12. #include "icommandline.h"
  13. #include "vgui/ISurface.h"
  14. #include "engineinterface.h"
  15. #include "tier0/dbg.h"
  16. #include "ixboxsystem.h"
  17. #include "gameui_interface.h"
  18. #include "game/client/IGameClientExports.h"
  19. #include "fmtstr.h"
  20. #include "vstdlib/random.h"
  21. #include "utlbuffer.h"
  22. #include "filesystem/IXboxInstaller.h"
  23. #include "tier1/tokenset.h"
  24. #include "filesystem.h"
  25. #include "filesystem/IXboxInstaller.h"
  26. #include "inputsystem/iinputsystem.h"
  27. #include <time.h>
  28. #include "messagebox_scaleform.h"
  29. #if defined( _PS3 )
  30. #include <cell/camera.h> // PS3 eye camera
  31. #endif
  32. // BaseModUI High-level windows
  33. //#include "VFoundGames.h"
  34. //#include "VFoundGroupGames.h"
  35. //#include "VGameLobby.h"
  36. //#include "VGenericConfirmation.h"
  37. //#include "VGenericWaitScreen.h"
  38. //#include "VInGameMainMenu.h"
  39. //#include "VMainMenu.h"
  40. //#include "VFooterPanel.h"
  41. //#include "VAttractScreen.h"
  42. //#include "VPasswordEntry.h"
  43. // vgui controls
  44. #include "vgui/ILocalize.h"
  45. #include "netmessages.h"
  46. #ifndef _GAMECONSOLE
  47. #include "steam/steam_api.h"
  48. #endif
  49. #include "gameui_util.h"
  50. #include "cdll_client_int.h"
  51. #include "cstrike15_gcmessages.pb.h"
  52. #include "cstrike15_gcconstants.h"
  53. #include "engine/inetsupport.h"
  54. // memdbgon must be the last include file in a .cpp file!!!
  55. #include "tier0/memdbgon.h"
  56. using namespace BaseModUI;
  57. using namespace vgui;
  58. //setup in GameUI_Interface.cpp
  59. // DWenger - Pulled out temporarily - extern const char *COM_GetModDirectory( void );
  60. // DWenger - Pulled out temporarily - ConVar x360_audio_english("x360_audio_english", "0", 0, "Keeps track of whether we're forcing english in a localized language." );
  61. ConVar demo_ui_enable( "demo_ui_enable", "", FCVAR_DEVELOPMENTONLY, "Suffix for the demo UI" );
  62. ConVar demo_connect_string( "demo_connect_string", "", FCVAR_DEVELOPMENTONLY, "Connect string for demo UI" );
  63. ///Asyncronous Operations
  64. ConVar mm_ping_max_green( "ping_max_green", "70" );
  65. ConVar mm_ping_max_yellow( "ping_max_yellow", "140" );
  66. ConVar mm_ping_max_red( "ping_max_red", "250" );
  67. //=============================================================================
  68. const tokenset_t< const char * > BaseModUI::s_characterPortraits[] =
  69. {
  70. { "", "select_Random" },
  71. { "random", "select_Random" },
  72. //{ "BtnNamVet", "select_Bill" },
  73. //{ "BtnTeenGirl", "select_Zoey" },
  74. //{ "BtnBiker", "select_Francis" },
  75. //{ "BtnManager", "select_Louis" },
  76. { "coach", "s_panel_lobby_coach" },
  77. { "producer", "s_panel_lobby_producer" },
  78. { "gambler", "s_panel_lobby_gambler" },
  79. { "mechanic", "s_panel_lobby_mechanic" },
  80. { "infected", "s_panel_hand" },
  81. { NULL, "" }
  82. };
  83. //=============================================================================
  84. // Xbox 360 Marketplace entry point
  85. //=============================================================================
  86. struct X360MarketPlaceEntryPoint
  87. {
  88. DWORD dwEntryPoint;
  89. uint64 uiOfferID;
  90. };
  91. static X360MarketPlaceEntryPoint g_MarketplaceEntryPoint;
  92. #ifdef _GAMECONSOLE
  93. struct X360MarketPlaceQuery
  94. {
  95. uint64 uiOfferID;
  96. HRESULT hResult;
  97. XOVERLAPPED xOverlapped;
  98. };
  99. static CUtlVector< X360MarketPlaceQuery * > g_arrMarketPlaceQueries;
  100. #endif
  101. static void GoToMarketplaceForOffer()
  102. {
  103. // dgoodenough - this looks to be x360 specific, so tag it as such
  104. // PS3_BUILDFIX
  105. #ifdef _X360
  106. // Stop installing to the hard drive, otherwise STFC fragmentation hazard, as multiple non sequential HDD writes will occur.
  107. // This needs to be done before the DLC might be downloaded to the HDD, otherwise it could be fragmented.
  108. // We restart the installer on DLC download completion. We do not handle the cancel/abort case. The installer
  109. // will restart through the pre-dlc path, i.e. after attract or exiting a map back to the main menu.
  110. if ( g_pXboxInstaller )
  111. g_pXboxInstaller->Stop();
  112. // See if we need to free some of the queries
  113. for ( int k = 0; k < g_arrMarketPlaceQueries.Count(); ++ k )
  114. {
  115. X360MarketPlaceQuery *pQuery = g_arrMarketPlaceQueries[k];
  116. if ( XHasOverlappedIoCompleted( &pQuery->xOverlapped ) )
  117. {
  118. delete pQuery;
  119. g_arrMarketPlaceQueries.FastRemove( k -- );
  120. }
  121. }
  122. // Allocate a new query
  123. X360MarketPlaceQuery *pQuery = new X360MarketPlaceQuery;
  124. memset( pQuery, 0, sizeof( *pQuery ) );
  125. pQuery->uiOfferID = g_MarketplaceEntryPoint.uiOfferID;
  126. g_arrMarketPlaceQueries.AddToTail( pQuery );
  127. // Open the marketplace entry point
  128. //int iSlot = ;
  129. ACTIVE_SPLITSCREEN_PLAYER_GUARD( GET_ACTIVE_SPLITSCREEN_SLOT() );
  130. xonline->XShowMarketplaceDownloadItemsUI( XBX_GetActiveUserId(),
  131. g_MarketplaceEntryPoint.dwEntryPoint,
  132. &pQuery->uiOfferID,
  133. 1,
  134. &pQuery->hResult,
  135. &pQuery->xOverlapped );
  136. #endif
  137. }
  138. static void ShowMarketplaceUiForOffer()
  139. {
  140. // dgoodenough - this looks to be x360 specific, so tag it as such
  141. // PS3_BUILDFIX
  142. #ifdef _X360
  143. // Stop installing to the hard drive, otherwise STFC fragmentation hazard, as multiple non sequential HDD writes will occur.
  144. // This needs to be done before the DLC might be downloaded to the HDD, otherwise it could be fragmented.
  145. // We restart the installer on DLC download completion. We do not handle the cancel/abort case. The installer
  146. // will restart through the pre-dlc path, i.e. after attract or exiting a map back to the main menu.
  147. if ( g_pXboxInstaller )
  148. g_pXboxInstaller->Stop();
  149. // Open the marketplace entry point
  150. // DWenger - Pulled out temporarily - int iSlot = CBaseModPanel::GetSingleton().GetLastActiveUserId();
  151. // DWenger - Pulled out temporarily - int iCtrlr = XBX_GetUserIsGuest( iSlot ) ? XBX_GetPrimaryUserId() : XBX_GetUserId( iSlot );
  152. // DWenger - Pulled out temporarily - DWORD ret = xonline->XShowMarketplaceUI( iCtrlr, g_MarketplaceEntryPoint.dwEntryPoint, g_MarketplaceEntryPoint.uiOfferID, DWORD( -1 ) );
  153. // DWenger - Pulled out temporarily - DevMsg( "XShowMarketplaceUI for offer %llx entry point %d ctrlr%d returned %d\n",
  154. // DWenger - Pulled out temporarily - g_MarketplaceEntryPoint.uiOfferID, g_MarketplaceEntryPoint.dwEntryPoint, iCtrlr, ret );
  155. #endif
  156. }
  157. #ifdef _GAMECONSOLE
  158. CON_COMMAND_F( x360_marketplace_offer, "Get a known offer from x360 marketplace", FCVAR_CLIENTCMD_CAN_EXECUTE )
  159. {
  160. if ( args.ArgC() != 4 )
  161. {
  162. Warning( "Usage: x360_marketplace_offer type 0xOFFERID ui|dl\n" );
  163. return;
  164. }
  165. int iEntryPoint = Q_atoi( args.Arg( 1 ) );
  166. char const *szArg2 = args.Arg( 2 );
  167. uint64 uiOfferId = 0ull;
  168. if ( 1 != sscanf( szArg2, "0x%llx", &uiOfferId ) )
  169. uiOfferId = 0ull;
  170. // Go to marketplace
  171. g_MarketplaceEntryPoint.dwEntryPoint = iEntryPoint;
  172. g_MarketplaceEntryPoint.uiOfferID = uiOfferId;
  173. if ( !Q_stricmp( args.Arg( 3 ), "ui" ) )
  174. ShowMarketplaceUiForOffer();
  175. else
  176. GoToMarketplaceForOffer();
  177. }
  178. #endif
  179. // Console command that's fired from the destructive action confirmation for joining a new session while already in a previous session.
  180. CON_COMMAND_F( confirm_join_new_session_exit_current, "Confirm that we wish to join a new session, destroying a previous session", FCVAR_CLIENTCMD_CAN_EXECUTE | FCVAR_HIDDEN )
  181. {
  182. g_pMatchFramework->GetEventsSubscription()->BroadcastEvent(
  183. new KeyValues( "OnInvite", "action", "join" ) );
  184. }
  185. //=============================================================================
  186. //
  187. //=============================================================================
  188. CUIGameData* CUIGameData::m_Instance = 0;
  189. bool CUIGameData::m_bModuleShutDown = false;
  190. //=============================================================================
  191. CUIGameData::CUIGameData() :
  192. #if !defined( NO_STEAM )
  193. m_CallbackUserStatsStored( NULL, NULL ),
  194. m_CallbackUserStatsReceived( NULL, NULL ),
  195. #endif
  196. #if !defined( _GAMECONSOLE ) && !defined( NO_STEAM )
  197. m_CallbackPersonaStateChanged( NULL, NULL ),
  198. #endif
  199. m_CGameUIPostInit( false )
  200. {
  201. // It's very dangerous to use "this" in initializer lists. Do it this way for safety and to kill some warnings.
  202. #if !defined( NO_STEAM )
  203. m_CallbackUserStatsStored.Register(this, &CUIGameData::Steam_OnUserStatsStored);
  204. m_CallbackUserStatsReceived.Register(this, &CUIGameData::Steam_OnUserStatsReceived);
  205. #endif
  206. #if !defined( _GAMECONSOLE ) && !defined( NO_STEAM )
  207. m_CallbackPersonaStateChanged.Register(this, &CUIGameData::Steam_OnPersonaStateChanged);
  208. #endif
  209. m_LookSensitivity = 1.0f;
  210. m_flShowConnectionProblemTimer = 0.0f;
  211. m_flTimeLastFrame = Plat_FloatTime();
  212. m_bShowConnectionProblemActive = false;
  213. g_pMatchFramework->GetEventsSubscription()->Subscribe( this );
  214. m_bXUIOpen = false;
  215. m_bWaitingForStorageDeviceHandle = false;
  216. m_iStorageID = XBX_INVALID_STORAGE_ID;
  217. m_pAsyncJob = NULL;
  218. m_pSelectStorageClient = NULL;
  219. SetDefLessFunc( m_mapUserXuidToAvatar );
  220. SetDefLessFunc( m_mapUserXuidToName );
  221. }
  222. //=============================================================================
  223. CUIGameData::~CUIGameData()
  224. {
  225. // Unsubscribe from events system
  226. g_pMatchFramework->GetEventsSubscription()->Unsubscribe( this );
  227. }
  228. //=============================================================================
  229. CUIGameData* CUIGameData::Get()
  230. {
  231. if ( !m_Instance && !m_bModuleShutDown )
  232. {
  233. m_Instance = new CUIGameData();
  234. }
  235. return m_Instance;
  236. }
  237. void CUIGameData::Shutdown()
  238. {
  239. if ( !m_bModuleShutDown )
  240. {
  241. m_bModuleShutDown = true;
  242. delete m_Instance;
  243. m_Instance = NULL;
  244. }
  245. }
  246. #ifdef _GAMECONSOLE
  247. CON_COMMAND( ui_fake_connection_problem, "" )
  248. {
  249. int numMilliSeconds = 1000;
  250. if ( args.ArgC() > 1 )
  251. {
  252. numMilliSeconds = Q_atoi( args.Arg( 1 ) );
  253. }
  254. float flTime = Plat_FloatTime();
  255. DevMsg( "ui_fake_connection_problem %d @%.2f\n", numMilliSeconds, flTime );
  256. int numTries = 2;
  257. while ( ( 1000 * ( Plat_FloatTime() - flTime ) < numMilliSeconds ) &&
  258. numTries --> 0 )
  259. {
  260. ThreadSleep( numMilliSeconds + 50 );
  261. }
  262. flTime = Plat_FloatTime();
  263. DevMsg( "ui_fake_connection_problem finished @%.2f\n", flTime );
  264. }
  265. #endif
  266. //=============================================================================
  267. void CUIGameData::RunFrame()
  268. {
  269. // DWenger - Pulled out temporarily - RunFrame_Storage();
  270. // DWenger - Pulled out temporarily - RunFrame_Invite();
  271. // msmith - Put in the RunFrame for PS3.
  272. #if defined( _PS3 )
  273. GetPs3SaveSteamInfoProvider()->RunFrame();
  274. #endif
  275. if ( m_flShowConnectionProblemTimer > 0.0f )
  276. {
  277. float flCurrentTime = Plat_FloatTime();
  278. float flTimeElapsed = ( flCurrentTime - m_flTimeLastFrame );
  279. m_flTimeLastFrame = flCurrentTime;
  280. if ( flTimeElapsed > 0.0f )
  281. {
  282. m_flShowConnectionProblemTimer -= flTimeElapsed;
  283. }
  284. if ( m_flShowConnectionProblemTimer > 0.0f )
  285. {
  286. // DWenger - Pulled out temporarily
  287. /*
  288. if ( !m_bShowConnectionProblemActive &&
  289. !CBaseModPanel::GetSingleton().IsVisible() )
  290. {
  291. GameUI().ActivateGameUI();
  292. OpenWaitScreen( "#GameUI_RetryingConnectionToServer", 0.0f );
  293. m_bShowConnectionProblemActive = true;
  294. }
  295. */
  296. }
  297. else
  298. {
  299. // DWenger - Pulled out temporarily
  300. /*
  301. if ( m_bShowConnectionProblemActive )
  302. {
  303. // Before closing this particular waitscreen we need to establish
  304. // a correct navback, otherwise it will not close - Vitaliy (bugbait #51272)
  305. if ( CBaseModFrame *pWaitScreen = CBaseModPanel::GetSingleton().GetWindow( WT_GENERICWAITSCREEN ) )
  306. {
  307. if ( !pWaitScreen->GetNavBack() )
  308. {
  309. if ( CBaseModFrame *pIngameMenu = CBaseModPanel::GetSingleton().GetWindow( WT_INGAMEMAINMENU ) )
  310. pWaitScreen->SetNavBack( pIngameMenu );
  311. }
  312. if ( !pWaitScreen->GetNavBack() )
  313. {
  314. // This waitscreen will fail to close, force the close!
  315. pWaitScreen->Close();
  316. }
  317. }
  318. CloseWaitScreen( NULL, "Connection Problems" );
  319. GameUI().HideGameUI();
  320. m_bShowConnectionProblemActive = false;
  321. }
  322. */
  323. }
  324. }
  325. }
  326. // DWenger - Pulled out temporarily
  327. /*
  328. void CUIGameData::OnSetStorageDeviceId( int iController, uint nDeviceId )
  329. {
  330. // Check to see if there is enough room on this storage device
  331. if ( nDeviceId == XBX_STORAGE_DECLINED || nDeviceId == XBX_INVALID_STORAGE_ID )
  332. {
  333. CloseWaitScreen( NULL, "ReportNoDeviceSelected" );
  334. m_pSelectStorageClient->OnDeviceFail( ISelectStorageDeviceClient::FAIL_NOT_SELECTED );
  335. m_pSelectStorageClient = NULL;
  336. }
  337. else if ( xboxsystem->DeviceCapacityAdequate( iController, nDeviceId, COM_GetModDirectory() ) == false )
  338. {
  339. CloseWaitScreen( NULL, "ReportDeviceFull" );
  340. m_pSelectStorageClient->OnDeviceFail( ISelectStorageDeviceClient::FAIL_FULL );
  341. m_pSelectStorageClient = NULL;
  342. }
  343. else
  344. {
  345. // Set the storage device
  346. XBX_SetStorageDeviceId( iController, nDeviceId );
  347. OnDeviceAttached();
  348. m_pSelectStorageClient->OnDeviceSelected();
  349. }
  350. }
  351. */
  352. //=============================================================================
  353. void CUIGameData::OnGameUIPostInit()
  354. {
  355. m_CGameUIPostInit = true;
  356. }
  357. //=============================================================================
  358. bool CUIGameData::CanPlayer2Join()
  359. {
  360. if ( demo_ui_enable.GetString()[0] )
  361. return false;
  362. #ifdef _GAMECONSOLE
  363. if ( XBX_GetNumGameUsers() != 1 )
  364. return false;
  365. if ( XBX_GetPrimaryUserIsGuest() )
  366. return false;
  367. // DWenger - Pulled out temporarily
  368. /*
  369. if ( CBaseModPanel::GetSingleton().GetActiveWindowType() != WT_MAINMENU )
  370. return false;
  371. */
  372. return true;
  373. #else
  374. return false;
  375. #endif
  376. }
  377. //=============================================================================
  378. void CUIGameData::OpenFriendRequestPanel(int index, uint64 playerXuid)
  379. {
  380. // dgoodenough - this looks to be x360 specific, so tag it as such
  381. // PS3_BUILDFIX
  382. #ifdef _X360
  383. XShowFriendRequestUI(index, playerXuid);
  384. #endif
  385. }
  386. //=============================================================================
  387. void CUIGameData::OpenInviteUI( char const *szInviteUiType )
  388. {
  389. #ifdef _GAMECONSOLE
  390. // DWenger - Pulled out temporarily - int iSlot = CBaseModPanel::GetSingleton().GetLastActiveUserId();
  391. // DWenger - Pulled out temporarily - int iCtrlr = XBX_GetUserIsGuest( iSlot ) ? XBX_GetPrimaryUserId() : XBX_GetUserId( iSlot );
  392. // DWenger - Pulled out temporarily - if ( !Q_stricmp( szInviteUiType, "friends" ) )
  393. // DWenger - Pulled out temporarily - ::XShowFriendsUI( iCtrlr );
  394. // DWenger - Pulled out temporarily - else if ( !Q_stricmp( szInviteUiType, "players" ) )
  395. // DWenger - Pulled out temporarily - xonline->XShowGameInviteUI( iCtrlr, NULL, 0, 0 );
  396. // DWenger - Pulled out temporarily - else if ( !Q_stricmp( szInviteUiType, "party" ) )
  397. // DWenger - Pulled out temporarily - xonline->XShowPartyUI( iCtrlr );
  398. // DWenger - Pulled out temporarily - else if ( !Q_stricmp( szInviteUiType, "inviteparty" ) )
  399. // DWenger - Pulled out temporarily - xonline->XPartySendGameInvites( iCtrlr, NULL );
  400. // DWenger - Pulled out temporarily - else if ( !Q_stricmp( szInviteUiType, "community" ) )
  401. // DWenger - Pulled out temporarily - xonline->XShowCommunitySessionsUI( iCtrlr, XSHOWCOMMUNITYSESSION_SHOWPARTY );
  402. // DWenger - Pulled out temporarily - else if ( !Q_stricmp( szInviteUiType, "voiceui" ) )
  403. // DWenger - Pulled out temporarily - ::XShowVoiceChannelUI( iCtrlr );
  404. // DWenger - Pulled out temporarily - else if ( !Q_stricmp( szInviteUiType, "gamevoiceui" ) )
  405. // DWenger - Pulled out temporarily - ::XShowGameVoiceChannelUI();
  406. // DWenger - Pulled out temporarily - else
  407. // DWenger - Pulled out temporarily - {
  408. // DWenger - Pulled out temporarily - DevWarning( "OpenInviteUI with wrong parameter `%s`!\n", szInviteUiType );
  409. // DWenger - Pulled out temporarily - Assert( 0 );
  410. // DWenger - Pulled out temporarily - }
  411. #endif
  412. }
  413. void CUIGameData::ExecuteOverlayCommand( char const *szCommand )
  414. {
  415. #if !defined( _GAMECONSOLE ) && !defined( NO_STEAM )
  416. if ( steamapicontext && steamapicontext->SteamFriends() &&
  417. steamapicontext->SteamUtils() && steamapicontext->SteamUtils()->IsOverlayEnabled() )
  418. {
  419. steamapicontext->SteamFriends()->ActivateGameOverlay( szCommand );
  420. }
  421. else
  422. {
  423. DisplayOkOnlyMsgBox( NULL, "#SFUI_SteamOverlay_Title", "#SFUI_SteamOverlay_Text" );
  424. }
  425. #else
  426. ExecuteNTimes( 5, DevWarning( "ExecuteOverlayCommand( %s ) is unsupported\n", szCommand ) );
  427. Assert( !"ExecuteOverlayCommand" );
  428. #endif
  429. }
  430. //=============================================================================
  431. bool CUIGameData::SignedInToLive()
  432. {
  433. #ifdef _GAMECONSOLE
  434. if ( XBX_GetNumGameUsers() <= 0 ||
  435. XBX_GetPrimaryUserIsGuest() )
  436. return false;
  437. for ( DWORD k = 0; k < XBX_GetNumGameUsers(); ++ k )
  438. {
  439. int iController = XBX_GetUserId( k );
  440. IPlayer *player = g_pMatchFramework->GetMatchSystem()->GetPlayerManager()->GetLocalPlayer( iController );
  441. if ( !player )
  442. return false;
  443. if ( player->GetOnlineState() != IPlayer::STATE_ONLINE )
  444. return false;
  445. }
  446. #endif
  447. return true;
  448. }
  449. bool CUIGameData::AnyUserSignedInToLiveWithMultiplayerDisabled()
  450. {
  451. #ifdef _GAMECONSOLE
  452. if ( XBX_GetNumGameUsers() <= 0 ||
  453. XBX_GetPrimaryUserIsGuest() )
  454. return false;
  455. for ( DWORD k = 0; k < XBX_GetNumGameUsers(); ++ k )
  456. {
  457. int iController = XBX_GetUserId( k );
  458. IPlayer *player = g_pMatchFramework->GetMatchSystem()->GetPlayerManager()->GetLocalPlayer( iController );
  459. if ( player && player->GetOnlineState() == IPlayer::STATE_NO_MULTIPLAYER )
  460. return true;
  461. }
  462. #endif
  463. return false;
  464. }
  465. bool CUIGameData::CheckAndDisplayErrorIfOffline( CBaseModFrame *pCallerFrame, char const *szMsg )
  466. {
  467. #ifdef _GAMECONSOLE
  468. bool bOnlineFound = false;
  469. if ( XBX_GetNumGameUsers() > 0 &&
  470. !XBX_GetPrimaryUserIsGuest() )
  471. {
  472. for ( DWORD k = 0; k < XBX_GetNumGameUsers(); ++ k )
  473. {
  474. int iController = XBX_GetUserId( k );
  475. IPlayer *player = g_pMatchFramework->GetMatchSystem()->GetPlayerManager()->GetLocalPlayer( iController );
  476. if ( player && player->GetOnlineState() > IPlayer::STATE_OFFLINE )
  477. return false;
  478. }
  479. }
  480. if ( bOnlineFound )
  481. return false;
  482. DisplayOkOnlyMsgBox( pCallerFrame, "#SFUI_XboxLive", szMsg );
  483. return true;
  484. #endif
  485. return false;
  486. }
  487. bool CUIGameData::CheckAndDisplayErrorIfNotSignedInToLive( CBaseModFrame *pCallerFrame )
  488. {
  489. if ( !IsGameConsole() )
  490. return false;
  491. if ( SignedInToLive() )
  492. return false;
  493. char const *szMsg = "";
  494. if ( AnyUserSignedInToLiveWithMultiplayerDisabled() )
  495. {
  496. szMsg = "#SFUI_MsgBx_NeedLiveNonGoldMsg";
  497. #ifdef _GAMECONSOLE
  498. // Show the splitscreen version if there are 2 non-guest accounts
  499. if ( XBX_GetNumGameUsers() > 1 && XBX_GetUserIsGuest( 0 ) == false && XBX_GetUserIsGuest( 1 ) == false )
  500. {
  501. szMsg = "#SFUI_MsgBx_NeedLiveNonGoldSplitscreenMsg";
  502. }
  503. #endif
  504. }
  505. else
  506. {
  507. szMsg = "#SFUI_MsgBx_NeedLiveSinglescreenMsg";
  508. #ifdef _GAMECONSOLE
  509. // Show the splitscreen version if there are 2 non-guest accounts
  510. if ( XBX_GetNumGameUsers() > 1 && XBX_GetUserIsGuest( 0 ) == false && XBX_GetUserIsGuest( 1 ) == false )
  511. {
  512. szMsg = "#SFUI_MsgBx_NeedLiveSplitscreenMsg";
  513. }
  514. #endif
  515. }
  516. DisplayOkOnlyMsgBox( pCallerFrame, "#SFUI_XboxLive", szMsg );
  517. return true;
  518. }
  519. void CUIGameData::DisplayOkOnlyMsgBox( CBaseModFrame *pCallerFrame, const char *szTitle, const char *szMsg )
  520. {
  521. // DWenger - Pulled out temporarily - GenericConfirmation* confirmation =
  522. // DWenger - Pulled out temporarily - static_cast<GenericConfirmation*>( CBaseModPanel::GetSingleton().OpenWindow( WT_GENERICCONFIRMATION, pCallerFrame, false ) );
  523. // DWenger - Pulled out temporarily - GenericConfirmation::Data_t data;
  524. // DWenger - Pulled out temporarily - data.pWindowTitle = szTitle;
  525. // DWenger - Pulled out temporarily - data.pMessageText = szMsg;
  526. // DWenger - Pulled out temporarily - data.bOkButtonEnabled = true;
  527. // DWenger - Pulled out temporarily - confirmation->SetUsageData(data);
  528. }
  529. const char *CUIGameData::GetLocalPlayerName( int iController )
  530. {
  531. static CGameUIConVarRef cl_names_debug( "cl_names_debug" );
  532. if ( cl_names_debug.GetInt() )
  533. return "WWWWWWWWWWWWWWW";
  534. IPlayer *player = g_pMatchFramework->GetMatchSystem()->GetPlayerManager()->GetLocalPlayer( iController );
  535. if ( !player )
  536. {
  537. return "";
  538. }
  539. return player->GetName();
  540. }
  541. //////////////////////////////////////////////////////////////////////////
  542. //=============================================================================
  543. void CUIGameData::SetLookSensitivity(float sensitivity)
  544. {
  545. m_LookSensitivity = sensitivity;
  546. static CGameUIConVarRef joy_yawsensitivity("joy_yawsensitivity");
  547. if(joy_yawsensitivity.IsValid())
  548. {
  549. float defaultValue = atof(joy_yawsensitivity.GetDefault());
  550. joy_yawsensitivity.SetValue(defaultValue * sensitivity);
  551. }
  552. static CGameUIConVarRef joy_pitchsensitivity("joy_pitchsensitivity");
  553. if(joy_pitchsensitivity.IsValid())
  554. {
  555. float defaultValue = atof(joy_pitchsensitivity.GetDefault());
  556. joy_pitchsensitivity.SetValue(defaultValue * sensitivity);
  557. }
  558. }
  559. //=============================================================================
  560. float CUIGameData::GetLookSensitivity()
  561. {
  562. return m_LookSensitivity;
  563. }
  564. bool CUIGameData::IsXUIOpen()
  565. {
  566. return m_bXUIOpen;
  567. }
  568. void CUIGameData::OpenWaitScreen( const char * messageText, float minDisplayTime, KeyValues *pSettings )
  569. {
  570. // DWenger - Pulled out temporarily - if ( UI_IsDebug() )
  571. // DWenger - Pulled out temporarily - {
  572. // DWenger - Pulled out temporarily - Msg( "[GAMEUI] OpenWaitScreen( %s )\n", messageText );
  573. // DWenger - Pulled out temporarily - }
  574. // DWenger - Pulled out temporarily - WINDOW_TYPE wtActive = CBaseModPanel::GetSingleton().GetActiveWindowType();
  575. // DWenger - Pulled out temporarily - CBaseModFrame * backFrame = CBaseModPanel::GetSingleton().GetWindow( wtActive );
  576. // DWenger - Pulled out temporarily - if ( wtActive == WT_GENERICWAITSCREEN && backFrame )
  577. // DWenger - Pulled out temporarily - {
  578. // DWenger - Pulled out temporarily - backFrame = backFrame->GetNavBack();
  579. // DWenger - Pulled out temporarily - DevMsg( "CUIGameData::OpenWaitScreen - setting navback to %s instead of waitscreen\n", backFrame ? backFrame->GetName() : "NULL" );
  580. // DWenger - Pulled out temporarily - }
  581. // DWenger - Pulled out temporarily - if ( wtActive == WT_GENERICCONFIRMATION && backFrame )
  582. // DWenger - Pulled out temporarily - {
  583. // DWenger - Pulled out temporarily - DevWarning( "Cannot display waitscreen! Active window of higher priority: %s\n", backFrame->GetName() );
  584. // DWenger - Pulled out temporarily - return;
  585. // DWenger - Pulled out temporarily - }
  586. // DWenger - Pulled out temporarily - GenericWaitScreen* waitScreen = static_cast<GenericWaitScreen*>(
  587. // DWenger - Pulled out temporarily - CBaseModPanel::GetSingleton().OpenWindow( WT_GENERICWAITSCREEN, backFrame, false, pSettings ) );
  588. // DWenger - Pulled out temporarily - if( waitScreen )
  589. // DWenger - Pulled out temporarily - {
  590. // DWenger - Pulled out temporarily - waitScreen->SetNavBack( backFrame );
  591. // DWenger - Pulled out temporarily - waitScreen->ClearData();
  592. // DWenger - Pulled out temporarily - waitScreen->AddMessageText( messageText, minDisplayTime );
  593. // DWenger - Pulled out temporarily - }
  594. }
  595. void CUIGameData::UpdateWaitPanel( const char * messageText, float minDisplayTime )
  596. {
  597. // DWenger - Pulled out temporarily - if ( UI_IsDebug() )
  598. // DWenger - Pulled out temporarily - {
  599. // DWenger - Pulled out temporarily - Msg( "[GAMEUI] UpdateWaitPanel( %s )\n", messageText );
  600. // DWenger - Pulled out temporarily - }
  601. // DWenger - Pulled out temporarily - GenericWaitScreen* waitScreen = static_cast<GenericWaitScreen*>(
  602. // DWenger - Pulled out temporarily - CBaseModPanel::GetSingleton().GetWindow( WT_GENERICWAITSCREEN ) );
  603. // DWenger - Pulled out temporarily - if( waitScreen )
  604. // DWenger - Pulled out temporarily - {
  605. // DWenger - Pulled out temporarily - waitScreen->AddMessageText( messageText, minDisplayTime );
  606. // DWenger - Pulled out temporarily - }
  607. }
  608. void CUIGameData::UpdateWaitPanel( const wchar_t * messageText, float minDisplayTime )
  609. {
  610. // DWenger - Pulled out temporarily - if ( UI_IsDebug() )
  611. // DWenger - Pulled out temporarily - {
  612. // DWenger - Pulled out temporarily - Msg( "[GAMEUI] UpdateWaitPanel( %S )\n", messageText );
  613. // DWenger - Pulled out temporarily - }
  614. // DWenger - Pulled out temporarily - GenericWaitScreen* waitScreen = static_cast<GenericWaitScreen*>(
  615. // DWenger - Pulled out temporarily - CBaseModPanel::GetSingleton().GetWindow( WT_GENERICWAITSCREEN ) );
  616. // DWenger - Pulled out temporarily - if( waitScreen )
  617. // DWenger - Pulled out temporarily - {
  618. // DWenger - Pulled out temporarily - waitScreen->AddMessageText( messageText, minDisplayTime );
  619. // DWenger - Pulled out temporarily - }
  620. }
  621. void CUIGameData::CloseWaitScreen( vgui::Panel * callbackPanel, const char * message )
  622. {
  623. // DWenger - Pulled out temporarily - if ( UI_IsDebug() )
  624. // DWenger - Pulled out temporarily - {
  625. // DWenger - Pulled out temporarily - Msg( "[GAMEUI] CloseWaitScreen( %s )\n", message );
  626. // DWenger - Pulled out temporarily - }
  627. // DWenger - Pulled out temporarily - GenericWaitScreen* waitScreen = static_cast<GenericWaitScreen*>(
  628. // DWenger - Pulled out temporarily - CBaseModPanel::GetSingleton().GetWindow( WT_GENERICWAITSCREEN ) );
  629. // DWenger - Pulled out temporarily - if( waitScreen )
  630. // DWenger - Pulled out temporarily - {
  631. // DWenger - Pulled out temporarily - waitScreen->SetCloseCallback( callbackPanel, message );
  632. // DWenger - Pulled out temporarily - }
  633. }
  634. void CUIGameData::NeedConnectionProblemWaitScreen ( void )
  635. {
  636. m_flShowConnectionProblemTimer = 1.0f;
  637. }
  638. static void PasswordEntered()
  639. {
  640. CUIGameData::Get()->FinishPasswordUI( true );
  641. }
  642. static void PasswordNotEntered()
  643. {
  644. CUIGameData::Get()->FinishPasswordUI( false );
  645. }
  646. void CUIGameData::ShowPasswordUI( char const *pchCurrentPW )
  647. {
  648. // DWenger - Pulled out temporarily - PasswordEntry *pwEntry = static_cast<PasswordEntry*>( CBaseModPanel::GetSingleton().OpenWindow( WT_PASSWORDENTRY, NULL, false ) );
  649. // DWenger - Pulled out temporarily - if ( pwEntry )
  650. // DWenger - Pulled out temporarily - {
  651. // DWenger - Pulled out temporarily - PasswordEntry::Data_t data;
  652. // DWenger - Pulled out temporarily - data.pWindowTitle = "#SFUI_PasswordEntry_Title";
  653. // DWenger - Pulled out temporarily - data.pMessageText = "#SFUI_PasswordEntry_Prompt";
  654. // DWenger - Pulled out temporarily - data.bOkButtonEnabled = true;
  655. // DWenger - Pulled out temporarily - data.bCancelButtonEnabled = true;
  656. // DWenger - Pulled out temporarily - data.m_szCurrentPW = pchCurrentPW;
  657. // DWenger - Pulled out temporarily - data.pfnOkCallback = PasswordEntered;
  658. // DWenger - Pulled out temporarily - data.pfnCancelCallback = PasswordNotEntered;
  659. // DWenger - Pulled out temporarily - pwEntry->SetUsageData(data);
  660. // DWenger - Pulled out temporarily - }
  661. }
  662. void CUIGameData::FinishPasswordUI( bool bOk )
  663. {
  664. // DWenger - Pulled out temporarily - PasswordEntry *pwEntry = static_cast<PasswordEntry*>( CBaseModPanel::GetSingleton().GetWindow( WT_PASSWORDENTRY ) );
  665. // DWenger - Pulled out temporarily - if ( pwEntry )
  666. // DWenger - Pulled out temporarily - {
  667. // DWenger - Pulled out temporarily - if ( bOk )
  668. // DWenger - Pulled out temporarily - {
  669. // DWenger - Pulled out temporarily - char pw[ 256 ];
  670. // DWenger - Pulled out temporarily - pwEntry->GetPassword( pw, sizeof( pw ) );
  671. // DWenger - Pulled out temporarily - engine->SetConnectionPassword( pw );
  672. // DWenger - Pulled out temporarily - }
  673. // DWenger - Pulled out temporarily - else
  674. // DWenger - Pulled out temporarily - {
  675. // DWenger - Pulled out temporarily - engine->SetConnectionPassword( "" );
  676. // DWenger - Pulled out temporarily - }
  677. // DWenger - Pulled out temporarily - }
  678. }
  679. IImage *CUIGameData::GetAvatarImage( XUID playerID )
  680. {
  681. #ifdef _GAMECONSOLE
  682. return NULL;
  683. #else
  684. if ( !playerID )
  685. return NULL;
  686. // do we already have this image cached?
  687. // DWenger - Pulled out temporarily - CAvatarImage *pImage = NULL;
  688. int iIndex = m_mapUserXuidToAvatar.Find( playerID );
  689. if ( iIndex == m_mapUserXuidToAvatar.InvalidIndex() )
  690. {
  691. // cache a new image
  692. // DWenger - Pulled out temporarily - pImage = new CAvatarImage();
  693. // We may fail to set the steam ID - if the player is not our friend and we are not in a lobby or game, eg
  694. // DWenger - Pulled out temporarily - if ( !pImage->SetAvatarSteamID( playerID ) )
  695. // DWenger - Pulled out temporarily - {
  696. // DWenger - Pulled out temporarily - delete pImage;
  697. // DWenger - Pulled out temporarily - return NULL;
  698. // DWenger - Pulled out temporarily - }
  699. // DWenger - Pulled out temporarily - iIndex = m_mapUserXuidToAvatar.Insert( playerID, pImage );
  700. }
  701. // DWenger - Pulled out temporarily - else
  702. // DWenger - Pulled out temporarily - {
  703. // DWenger - Pulled out temporarily - pImage = m_mapUserXuidToAvatar.Element( iIndex );
  704. // DWenger - Pulled out temporarily - }
  705. // DWenger - Pulled out temporarily - return pImage;
  706. return NULL; // DWenger - Added temporarily
  707. #endif // !_GAMECONSOLE
  708. }
  709. char const * CUIGameData::GetPlayerName( XUID playerID, char const *szPlayerNameSpeculative )
  710. {
  711. static CGameUIConVarRef cl_names_debug( "cl_names_debug" );
  712. if ( cl_names_debug.GetInt() )
  713. return "WWWWWWWWWWWWWWW";
  714. #if !defined( _GAMECONSOLE ) && !defined( NO_STEAM )
  715. if ( steamapicontext && steamapicontext->SteamUtils() &&
  716. steamapicontext->SteamFriends() && steamapicontext->SteamUser() )
  717. {
  718. int iIndex = m_mapUserXuidToName.Find( playerID );
  719. if ( iIndex == m_mapUserXuidToName.InvalidIndex() )
  720. {
  721. char const *szName = steamapicontext->SteamFriends()->GetFriendPersonaName( playerID );
  722. if ( szName && *szName )
  723. {
  724. iIndex = m_mapUserXuidToName.Insert( playerID, szName );
  725. }
  726. }
  727. if ( iIndex != m_mapUserXuidToName.InvalidIndex() )
  728. return m_mapUserXuidToName.Element( iIndex ).Get();
  729. }
  730. #endif
  731. return szPlayerNameSpeculative;
  732. }
  733. #if !defined( _GAMECONSOLE ) && !defined( NO_STEAM )
  734. void CUIGameData::Steam_OnPersonaStateChanged( PersonaStateChange_t *pParam )
  735. {
  736. if ( !pParam->m_ulSteamID )
  737. return;
  738. if ( pParam->m_nChangeFlags & k_EPersonaChangeName )
  739. {
  740. int iIndex = m_mapUserXuidToName.Find( pParam->m_ulSteamID );
  741. if ( iIndex != m_mapUserXuidToName.InvalidIndex() )
  742. {
  743. CUtlString utlName = m_mapUserXuidToName.Element( iIndex );
  744. m_mapUserXuidToName.RemoveAt( iIndex );
  745. GetPlayerName( pParam->m_ulSteamID, utlName.Get() );
  746. }
  747. }
  748. if ( pParam->m_nChangeFlags & k_EPersonaChangeAvatar )
  749. {
  750. // DWenger - Pulled out temporarily - CAvatarImage *pImage = NULL;
  751. // DWenger - Pulled out temporarily - int iIndex = m_mapUserXuidToAvatar.Find( pParam->m_ulSteamID );
  752. // DWenger - Pulled out temporarily - if ( iIndex != m_mapUserXuidToAvatar.InvalidIndex() )
  753. // DWenger - Pulled out temporarily - {
  754. // DWenger - Pulled out temporarily - pImage = m_mapUserXuidToAvatar.Element( iIndex );
  755. // DWenger - Pulled out temporarily - }
  756. // Re-fetch the image if we have it cached
  757. // DWenger - Pulled out temporarily - if ( pImage )
  758. // DWenger - Pulled out temporarily - {
  759. // DWenger - Pulled out temporarily - pImage->SetAvatarSteamID( pParam->m_ulSteamID );
  760. // DWenger - Pulled out temporarily - }
  761. }
  762. }
  763. #endif
  764. CON_COMMAND_F( ui_reloadscheme, "Reloads the resource files for the active UI window", 0 )
  765. {
  766. g_pFullFileSystem->SyncDvdDevCache();
  767. CUIGameData::Get()->ReloadScheme();
  768. }
  769. void CUIGameData::ReloadScheme()
  770. {
  771. // DWenger - Pulled out temporarily - CBaseModPanel::GetSingleton().ReloadScheme();
  772. // DWenger - Pulled out temporarily - CBaseModFrame *window = CBaseModPanel::GetSingleton().GetWindow( CBaseModPanel::GetSingleton().GetActiveWindowType() );
  773. // DWenger - Pulled out temporarily - if( window )
  774. // DWenger - Pulled out temporarily - {
  775. // DWenger - Pulled out temporarily - window->ReloadSettings();
  776. // DWenger - Pulled out temporarily - }
  777. // DWenger - Pulled out temporarily - CBaseModFooterPanel *footer = CBaseModPanel::GetSingleton().GetFooterPanel();
  778. // DWenger - Pulled out temporarily - if( footer )
  779. // DWenger - Pulled out temporarily - {
  780. // DWenger - Pulled out temporarily - footer->ReloadSettings();
  781. // DWenger - Pulled out temporarily - }
  782. }
  783. CBaseModFrame * CUIGameData::GetParentWindowForSystemMessageBox()
  784. {
  785. // DWenger - Pulled out temporarily - WINDOW_TYPE wtActive = CBaseModPanel::GetSingleton().GetActiveWindowType();
  786. // DWenger - Pulled out temporarily - WINDOW_PRIORITY wPriority = CBaseModPanel::GetSingleton().GetActiveWindowPriority();
  787. // DWenger - Pulled out temporarily - CBaseModFrame *pCandidate = CBaseModPanel::GetSingleton().GetWindow( wtActive );
  788. // DWenger - Pulled out temporarily - if ( pCandidate )
  789. // DWenger - Pulled out temporarily - {
  790. // DWenger - Pulled out temporarily - if ( wPriority >= WPRI_WAITSCREEN && wPriority <= WPRI_MESSAGE )
  791. // DWenger - Pulled out temporarily - {
  792. // DWenger - Pulled out temporarily - if ( UI_IsDebug() )
  793. // DWenger - Pulled out temporarily - {
  794. // DWenger - Pulled out temporarily - DevMsg( "GetParentWindowForSystemMessageBox: using navback of %s\n", pCandidate->GetName() );
  795. // DWenger - Pulled out temporarily - }
  796. // Message would not be able to nav back to waitscreen or another message
  797. // DWenger - Pulled out temporarily - pCandidate = pCandidate->GetNavBack();
  798. // DWenger - Pulled out temporarily - }
  799. // DWenger - Pulled out temporarily - else if ( wPriority > WPRI_MESSAGE )
  800. // DWenger - Pulled out temporarily - {
  801. // DWenger - Pulled out temporarily - if ( UI_IsDebug() )
  802. // DWenger - Pulled out temporarily - {
  803. // DWenger - Pulled out temporarily - DevMsg( "GetParentWindowForSystemMessageBox: using NULL since a higher priority window is open %s\n", pCandidate->GetName() );
  804. // DWenger - Pulled out temporarily - }
  805. // Message would not be able to nav back to a higher level priority window
  806. // DWenger - Pulled out temporarily - pCandidate = NULL;
  807. // DWenger - Pulled out temporarily - }
  808. // DWenger - Pulled out temporarily - }
  809. // DWenger - Pulled out temporarily - return pCandidate;
  810. return NULL; // DWenger - temporary code
  811. }
  812. bool CUIGameData::IsActiveSplitScreenPlayerSpectating( void )
  813. {
  814. // int iLocalPlayerTeam;
  815. // if ( GameClientExports()->GetPlayerTeamIdByUserId( -1, iLocalPlayerTeam ) )
  816. // {
  817. // if ( iLocalPlayerTeam != GameClientExports()->GetTeamId_Survivor() &&
  818. // iLocalPlayerTeam != GameClientExports()->GetTeamId_Infected() )
  819. // return true;
  820. // }
  821. return false;
  822. }
  823. struct ServerCookie_t
  824. {
  825. uint64 m_uiCookie;
  826. double m_dblTimeCached;
  827. };
  828. CUtlMap< uint64, ServerCookie_t, int32, CDefLess< uint64 > > g_mapServerCookies;
  829. static uint64 Helper_GetServerCookie( uint64 gsid )
  830. {
  831. int32 i = g_mapServerCookies.Find( gsid );
  832. if ( i == g_mapServerCookies.InvalidIndex() )
  833. return 0;
  834. if ( Plat_FloatTime() - g_mapServerCookies.Element( i ).m_dblTimeCached > 60.0f )
  835. return 0;
  836. return g_mapServerCookies.Element( i ).m_uiCookie;
  837. }
  838. void CUIGameData::OnEvent( KeyValues *pEvent )
  839. {
  840. char const *szEvent = pEvent->GetName();
  841. if ( !Q_stricmp( "OnSysXUIEvent", szEvent ) )
  842. {
  843. m_bXUIOpen = !Q_stricmp( "opening", pEvent->GetString( "action", "" ) );
  844. }
  845. else if ( !Q_stricmp( "OnProfileUnavailable", szEvent ) )
  846. {
  847. #if defined( _DEMO ) && defined( _GAMECONSOLE )
  848. return;
  849. #endif
  850. // Activate game ui to see the dialog
  851. // DWenger - Pulled out temporarily - if ( !CBaseModPanel::GetSingleton().IsVisible() )
  852. // DWenger - Pulled out temporarily - {
  853. // DWenger - Pulled out temporarily - engine->ExecuteClientCmd( "gameui_activate" );
  854. // DWenger - Pulled out temporarily - }
  855. // Pop a message dialog if their storage device was changed
  856. // DWenger - Pulled out temporarily - GenericConfirmation* confirmation = static_cast<GenericConfirmation*>( CBaseModPanel::GetSingleton().OpenWindow( WT_GENERICCONFIRMATION,
  857. // DWenger - Pulled out temporarily - GetParentWindowForSystemMessageBox(), false ) );
  858. // DWenger - Pulled out temporarily - GenericConfirmation::Data_t data;
  859. // DWenger - Pulled out temporarily - data.pWindowTitle = "#SFUI_MsgBx_AchievementNotWrittenTitle";
  860. // DWenger - Pulled out temporarily - data.pMessageText = "#SFUI_MsgBx_AchievementNotWritten";
  861. // DWenger - Pulled out temporarily - data.bOkButtonEnabled = true;
  862. // DWenger - Pulled out temporarily - confirmation->SetUsageData( data );
  863. }
  864. else if ( !Q_stricmp( "OnInvite", szEvent ) )
  865. {
  866. // Check if the user just accepted invite
  867. if ( !Q_stricmp( "accepted", pEvent->GetString( "action" ) ) )
  868. {
  869. // Check if we have an outstanding session
  870. IMatchSession *pIMatchSession = g_pMatchFramework->GetMatchSession();
  871. if ( !pIMatchSession )
  872. {
  873. // DWenger - Pulled out temporarily - Invite_Connecting();
  874. return;
  875. }
  876. // User is accepting an invite and has an outstanding
  877. // session, TCR requires confirmation of destructive actions
  878. if ( int *pnConfirmed = ( int * ) pEvent->GetPtr( "confirmed" ) )
  879. {
  880. *pnConfirmed = 0;
  881. }
  882. // Show the prompt to confirm they wish to join a new session
  883. GameUI().CreateCommandMsgBoxInSlot(
  884. CMB_SLOT_FULL_SCREEN,
  885. "#SFUI_Confirm_JoinAnotherGameTitle",
  886. "#SFUI_Confirm_JoinAnotherGameText",
  887. true,
  888. true,
  889. "confirm_join_new_session_exit_current\n",
  890. NULL,
  891. NULL,
  892. NULL );
  893. }
  894. else if ( !Q_stricmp( "storage", pEvent->GetString( "action" ) ) )
  895. {
  896. // DWenger - Pulled out temporarily - if ( !Invite_IsStorageDeviceValid() )
  897. // DWenger - Pulled out temporarily - {
  898. // DWenger - Pulled out temporarily - if ( int *pnConfirmed = ( int * ) pEvent->GetPtr( "confirmed" ) )
  899. // DWenger - Pulled out temporarily - {
  900. // DWenger - Pulled out temporarily - *pnConfirmed = 0; // make the invite accepting code wait
  901. // DWenger - Pulled out temporarily - }
  902. // DWenger - Pulled out temporarily - }
  903. }
  904. else if ( !Q_stricmp( "error", pEvent->GetString( "action" ) ) )
  905. {
  906. char const *szReason = pEvent->GetString( "error", "" );
  907. if ( XBX_GetNumGameUsers() < 2 )
  908. {
  909. RemapText_t arrText[] = {
  910. { "", "#InviteError_Unknown", RemapText_t::MATCH_FULL },
  911. { "NotOnline", "#InviteError_NotOnline1", RemapText_t::MATCH_FULL },
  912. { "NoMultiplayer", "#InviteError_NoMultiplayer1", RemapText_t::MATCH_FULL },
  913. { "SameConsole", "#InviteError_SameConsole1", RemapText_t::MATCH_FULL },
  914. { NULL, NULL, RemapText_t::MATCH_FULL }
  915. };
  916. szReason = RemapText_t::RemapRawText( arrText, szReason );
  917. }
  918. else
  919. {
  920. RemapText_t arrText[] = {
  921. { "", "#InviteError_Unknown", RemapText_t::MATCH_FULL },
  922. { "NotOnline", "#InviteError_NotOnline2", RemapText_t::MATCH_FULL },
  923. { "NoMultiplayer", "#InviteError_NoMultiplayer2", RemapText_t::MATCH_FULL },
  924. { "SameConsole", "#InviteError_SameConsole2", RemapText_t::MATCH_FULL },
  925. { NULL, NULL, RemapText_t::MATCH_FULL }
  926. };
  927. szReason = RemapText_t::RemapRawText( arrText, szReason );
  928. }
  929. // Show the message box
  930. // DWenger - Pulled out temporarily - GenericConfirmation* confirmation = static_cast<GenericConfirmation*>( CBaseModPanel::GetSingleton().OpenWindow( WT_GENERICCONFIRMATION,
  931. // DWenger - Pulled out temporarily - GetParentWindowForSystemMessageBox(), false ) );
  932. // DWenger - Pulled out temporarily - GenericConfirmation::Data_t data;
  933. // DWenger - Pulled out temporarily - data.pWindowTitle = "#SFUI_XboxLive";
  934. // DWenger - Pulled out temporarily - data.pMessageText = szReason;
  935. // DWenger - Pulled out temporarily - data.bOkButtonEnabled = true;
  936. // DWenger - Pulled out temporarily - confirmation->SetUsageData(data);
  937. }
  938. }
  939. else if ( !Q_stricmp( "OnSysStorageDevicesChanged", szEvent ) )
  940. {
  941. #if defined( _DEMO ) && defined( _GAMECONSOLE )
  942. return;
  943. #endif
  944. // If a storage device change is in progress, the simply ignore
  945. // the notification callback, but pop the dialog
  946. if ( m_pSelectStorageClient )
  947. {
  948. DevWarning( "Ignored OnSysStorageDevicesChanged while the storage selection was in progress...\n" );
  949. }
  950. // Activate game ui to see the dialog
  951. // DWenger - Pulled out temporarily - if ( !CBaseModPanel::GetSingleton().IsVisible() )
  952. // DWenger - Pulled out temporarily - {
  953. // DWenger - Pulled out temporarily - engine->ExecuteClientCmd( "gameui_activate" );
  954. // DWenger - Pulled out temporarily - }
  955. // Pop a message dialog if their storage device was changed
  956. // DWenger - Pulled out temporarily - GenericConfirmation* confirmation = static_cast<GenericConfirmation*>( CBaseModPanel::GetSingleton().OpenWindow( WT_GENERICCONFIRMATION,
  957. // DWenger - Pulled out temporarily - GetParentWindowForSystemMessageBox(), false ) );
  958. // DWenger - Pulled out temporarily - GenericConfirmation::Data_t data;
  959. // DWenger - Pulled out temporarily - data.pWindowTitle = "#GameUI_Console_StorageRemovedTitle";
  960. // DWenger - Pulled out temporarily - data.pMessageText = "#SFUI_MsgBx_StorageDeviceRemoved";
  961. // DWenger - Pulled out temporarily - data.bOkButtonEnabled = true;
  962. // DWenger - Pulled out temporarily - extern void OnStorageDevicesChangedSelectNewDevice();
  963. // DWenger - Pulled out temporarily - data.pfnOkCallback = m_pSelectStorageClient ? NULL : &OnStorageDevicesChangedSelectNewDevice; // No callback if already in the middle of selecting a storage device
  964. // DWenger - Pulled out temporarily - confirmation->SetUsageData( data );
  965. }
  966. #if defined( _PS3 )
  967. else if ( !Q_stricmp( "OnPSMoveOutOfViewChanged", szEvent ) )
  968. {
  969. int inViewStatus = pEvent->GetInt( "OutOfViewBool" );
  970. if ( inViewStatus == 0 )
  971. {
  972. if ( g_pInputSystem->MotionControllerActive() )
  973. {
  974. // here is where we open the "move out of view" message box!
  975. PopupManager::ShowSingleUsePopup( POPUP_TYPE_PSMOVE_OUT_OF_VIEW );
  976. }
  977. }
  978. else
  979. {
  980. PopupManager::HideSingleUsePopup( POPUP_TYPE_PSMOVE_OUT_OF_VIEW );
  981. }
  982. }
  983. else if ( !Q_stricmp( "OnPSEyeChangedStatus", szEvent ) )
  984. {
  985. int32 camStatus = pEvent->GetInt( "CamStatus" );
  986. if ( camStatus == CELL_OK )
  987. {
  988. // remove message box either way.
  989. PopupManager::HideSingleUsePopup( POPUP_TYPE_PSEYE_DISCONNECTED );
  990. }
  991. else
  992. {
  993. // only show this warning if the camera is removed AND we're using the move or sharpshooter
  994. // otherwise it's not important
  995. if ( g_pInputSystem->MotionControllerActive() )
  996. {
  997. PopupManager::ShowSingleUsePopup( POPUP_TYPE_PSEYE_DISCONNECTED );
  998. }
  999. }
  1000. }
  1001. #endif
  1002. else if ( !Q_stricmp( "OnSysInputDevicesChanged", szEvent ) )
  1003. {
  1004. unsigned int nInactivePlayers = 0; // Number of users on the spectating team (ie. idle), or disconnected in this call
  1005. int iOldSlot = engine->GetActiveSplitScreenPlayerSlot();
  1006. int nDisconnectedDevices = pEvent->GetInt( "mask" );
  1007. for ( unsigned int nSlot = 0; nSlot < XBX_GetNumGameUsers(); ++nSlot, nDisconnectedDevices >>= 1 )
  1008. {
  1009. engine->SetActiveSplitScreenPlayerSlot( nSlot );
  1010. // See if this player is spectating (ie. idle)
  1011. bool bSpectator = IsActiveSplitScreenPlayerSpectating();
  1012. if ( bSpectator )
  1013. {
  1014. nInactivePlayers++;
  1015. }
  1016. if ( nDisconnectedDevices & 0x1 )
  1017. {
  1018. // Only count disconnections if that player wasn't idle
  1019. if ( !bSpectator )
  1020. {
  1021. nInactivePlayers++;
  1022. }
  1023. engine->ClientCmd( "go_away_from_keyboard" );
  1024. }
  1025. }
  1026. engine->SetActiveSplitScreenPlayerSlot( iOldSlot );
  1027. // If all the spectators and all the disconnections account for all possible users, we need to pop a message
  1028. // Also, if the GameUI is up, always show the disconnection message
  1029. // DWenger - Pulled out temporarily - if ( CBaseModPanel::GetSingleton().IsVisible() || nInactivePlayers == XBX_GetNumGameUsers() )
  1030. // DWenger - Pulled out temporarily - {
  1031. // DWenger - Pulled out temporarily - if ( !CBaseModPanel::GetSingleton().IsVisible() )
  1032. // DWenger - Pulled out temporarily - {
  1033. // DWenger - Pulled out temporarily - engine->ExecuteClientCmd( "gameui_activate" );
  1034. // DWenger - Pulled out temporarily - }
  1035. // Pop a message if a valid controller was removed!
  1036. // DWenger - Pulled out temporarily - GenericConfirmation* confirmation = static_cast<GenericConfirmation*>( CBaseModPanel::GetSingleton().OpenWindow( WT_GENERICCONFIRMATION,
  1037. // DWenger - Pulled out temporarily - GetParentWindowForSystemMessageBox(), false ) );
  1038. // DWenger - Pulled out temporarily - GenericConfirmation::Data_t data;
  1039. // DWenger - Pulled out temporarily - data.pWindowTitle = "#SFUI_MsgBx_ControllerUnpluggedTitle";
  1040. // DWenger - Pulled out temporarily - data.pMessageText = "#SFUI_MsgBx_ControllerUnplugged";
  1041. // DWenger - Pulled out temporarily - data.bOkButtonEnabled = true;
  1042. // DWenger - Pulled out temporarily - confirmation->SetUsageData(data);
  1043. // DWenger - Pulled out temporarily - }
  1044. }
  1045. else if ( !Q_stricmp( "OnMatchPlayerMgrReset", szEvent ) )
  1046. {
  1047. char const *szReason = pEvent->GetString( "reason", "" );
  1048. bool bShowDisconnectedMsgBox = true;
  1049. if ( !Q_stricmp( szReason, "GuestSignedIn" ) )
  1050. {
  1051. char const *szDestroyedSessionState = pEvent->GetString( "settings/game/state", "lobby" );
  1052. if ( !Q_stricmp( "lobby", szDestroyedSessionState ) )
  1053. bShowDisconnectedMsgBox = false;
  1054. }
  1055. engine->HideLoadingPlaque(); // This may not go away unless we force it to hide
  1056. // Go to the attract screen
  1057. // DWenger - Pulled out temporarily - CBaseModPanel::GetSingleton().CloseAllWindows( CBaseModPanel::CLOSE_POLICY_EVEN_MSGS );
  1058. // Show the message box
  1059. // DWenger - Pulled out temporarily - GenericConfirmation* confirmation = bShowDisconnectedMsgBox ? static_cast<GenericConfirmation*>( CBaseModPanel::GetSingleton().OpenWindow( WT_GENERICCONFIRMATION, NULL, false ) ) : NULL;
  1060. // DWenger - Pulled out temporarily - CAttractScreen::SetAttractMode( CAttractScreen::ATTRACT_GAMESTART );
  1061. // DWenger - Pulled out temporarily - CBaseModPanel::GetSingleton().OpenWindow( WT_ATTRACTSCREEN, NULL );
  1062. // DWenger - Pulled out temporarily - if ( confirmation )
  1063. // DWenger - Pulled out temporarily - {
  1064. // DWenger - Pulled out temporarily - GenericConfirmation::Data_t data;
  1065. // DWenger - Pulled out temporarily - data.pWindowTitle = "#SFUI_MsgBx_SignInChangeC";
  1066. // DWenger - Pulled out temporarily - data.pMessageText = "#SFUI_MsgBx_SignInChange";
  1067. // DWenger - Pulled out temporarily - data.bOkButtonEnabled = true;
  1068. // DWenger - Pulled out temporarily - if ( !Q_stricmp( szReason, "GuestSignedIn" ) )
  1069. // DWenger - Pulled out temporarily - {
  1070. // DWenger - Pulled out temporarily - data.pWindowTitle = "#SFUI_MsgBx_DisconnectedFromSession"; // "Disconnect"
  1071. // DWenger - Pulled out temporarily - data.pMessageText = "#SFUI_MsgBx_SignInChange"; // "Sign-in change has occured."
  1072. // DWenger - Pulled out temporarily - }
  1073. // DWenger - Pulled out temporarily - confirmation->SetUsageData(data);
  1074. #ifdef _GAMECONSOLE
  1075. // When a confirmation shows up it prevents attract screen from opening, so reset user slots here:
  1076. // DWenger - Pulled out temporarily - XBX_ResetUserIdSlots();
  1077. // DWenger - Pulled out temporarily - XBX_SetPrimaryUserId( XBX_INVALID_USER_ID );
  1078. // DWenger - Pulled out temporarily - XBX_SetPrimaryUserIsGuest( 0 );
  1079. // DWenger - Pulled out temporarily - XBX_SetNumGameUsers( 0 ); // users not selected yet
  1080. #endif
  1081. // DWenger - Pulled out temporarily - }
  1082. }
  1083. else if ( !Q_stricmp( "OnEngineDisconnectReason", szEvent ) )
  1084. {
  1085. char const *szReason = pEvent->GetString( "reason", "" );
  1086. if ( char const *szDisconnectHdlr = pEvent->GetString( "disconnecthdlr", NULL ) )
  1087. {
  1088. // If a disconnect handler was set during the event, then we don't interfere with
  1089. // the dialog explaining disconnection, just let the disconnect handler do everything.
  1090. return;
  1091. }
  1092. RemapText_t arrText[] = {
  1093. { "", "#DisconnectReason_Unknown", RemapText_t::MATCH_FULL },
  1094. { "Lost connection to LIVE", "#DisconnectReason_LostConnectionToLIVE", RemapText_t::MATCH_FULL },
  1095. { "Player removed from host session", "#DisconnectReason_PlayerRemovedFromSession", RemapText_t::MATCH_SUBSTR },
  1096. { "Connection to server timed out", "#SFUI_MsgBx_DisconnectedFromServer", RemapText_t::MATCH_SUBSTR },
  1097. { "Server shutting down", "#SFUI_MsgBx_DisconnectedServerShuttingDown", RemapText_t::MATCH_SUBSTR },
  1098. { "Added to banned list", "#SessionError_Kicked", RemapText_t::MATCH_SUBSTR },
  1099. { "Kicked and banned", "#SessionError_Kicked", RemapText_t::MATCH_SUBSTR },
  1100. { "You have been voted off", "#SessionError_Kicked", RemapText_t::MATCH_SUBSTR },
  1101. { "All players idle", "#L4D_ServerShutdownIdle", RemapText_t::MATCH_SUBSTR },
  1102. #ifdef _GAMECONSOLE
  1103. { "", "#DisconnectReason_Unknown", RemapText_t::MATCH_START }, // Catch all cases for X360
  1104. #endif
  1105. { NULL, NULL, RemapText_t::MATCH_FULL }
  1106. };
  1107. szReason = RemapText_t::RemapRawText( arrText, szReason );
  1108. //
  1109. // Go back to main menu and display the disconnection reason
  1110. //
  1111. engine->HideLoadingPlaque(); // This may not go away unless we force it to hide
  1112. // Go to the main menu
  1113. // DWenger - Pulled out temporarily - CBaseModPanel::GetSingleton().CloseAllWindows( CBaseModPanel::CLOSE_POLICY_EVEN_MSGS );
  1114. // Show the message box
  1115. // DWenger - Pulled out temporarily - GenericConfirmation* confirmation = static_cast<GenericConfirmation*>( CBaseModPanel::GetSingleton().OpenWindow( WT_GENERICCONFIRMATION, NULL, false ) );
  1116. // DWenger - Pulled out temporarily - CBaseModPanel::GetSingleton().OpenWindow( WT_MAINMENU, NULL );
  1117. // DWenger - Pulled out temporarily - GenericConfirmation::Data_t data;
  1118. // DWenger - Pulled out temporarily - data.pWindowTitle = "#SFUI_MsgBx_DisconnectedFromSession"; // "Disconnect"
  1119. // DWenger - Pulled out temporarily - data.pMessageText = szReason;
  1120. // DWenger - Pulled out temporarily - data.bOkButtonEnabled = true;
  1121. // DWenger - Pulled out temporarily - confirmation->SetUsageData(data);
  1122. }
  1123. else if ( !Q_stricmp( "OnEngineEndGame", szEvent ) )
  1124. {
  1125. // If we are connected and there was no session object to handle the event
  1126. if ( !g_pMatchFramework->GetMatchSession() )
  1127. {
  1128. // Issue the disconnect command
  1129. engine->ExecuteClientCmd( "disconnect" );
  1130. }
  1131. }
  1132. else if ( !Q_stricmp( "OnMatchSessionUpdate", szEvent ) )
  1133. {
  1134. if ( !Q_stricmp( "error", pEvent->GetString( "state", "" ) ) )
  1135. {
  1136. g_pMatchFramework->CloseSession();
  1137. char chErrorMsgBuffer[128] = {0};
  1138. char chErrorTitleBuffer[128] = {0};
  1139. char const *szError = pEvent->GetString( "error", "" );
  1140. char const *szErrorTitle = "#SFUI_MsgBx_DisconnectedFromSession";
  1141. RemapText_t arrText[] = {
  1142. { "", "#SessionError_Unknown", RemapText_t::MATCH_FULL },
  1143. { "n/a", "#SessionError_NotAvailable", RemapText_t::MATCH_FULL },
  1144. { "create", "#SessionError_Create", RemapText_t::MATCH_FULL },
  1145. { "createclient", "#SessionError_NotAvailable", RemapText_t::MATCH_FULL },
  1146. { "connect", "#SessionError_Connect", RemapText_t::MATCH_FULL },
  1147. { "full", "#SessionError_Full", RemapText_t::MATCH_FULL },
  1148. { "lock", "#SessionError_Lock", RemapText_t::MATCH_FULL },
  1149. { "kicked", "#SessionError_Kicked", RemapText_t::MATCH_FULL },
  1150. { "migrate", "#SessionError_Migrate", RemapText_t::MATCH_FULL },
  1151. { "nomap", "#SessionError_NoMap", RemapText_t::MATCH_FULL },
  1152. { "SteamServersDisconnected", "#SessionError_SteamServersDisconnected", RemapText_t::MATCH_FULL },
  1153. { NULL, NULL, RemapText_t::MATCH_FULL }
  1154. };
  1155. szError = RemapText_t::RemapRawText( arrText, szError );
  1156. if ( !Q_stricmp( "turequired", szError ) )
  1157. {
  1158. // Special case for TU required message
  1159. // If we have a localization string for the TU message then this means that the other box
  1160. // is running and older version of the TU
  1161. char const *szTuRequiredCode = pEvent->GetString( "turequired" );
  1162. CFmtStr strLocKey( "#SessionError_TU_Required_%s", szTuRequiredCode );
  1163. if ( g_pVGuiLocalize->Find( strLocKey ) )
  1164. {
  1165. Q_strncpy( chErrorMsgBuffer, strLocKey, sizeof( chErrorMsgBuffer ) );
  1166. szError = chErrorMsgBuffer;
  1167. }
  1168. else
  1169. {
  1170. szError = "#SessionError_TU_RequiredMessage";
  1171. }
  1172. szErrorTitle = "#SessionError_TU_RequiredTitle";
  1173. }
  1174. // Go to the main menu
  1175. // DWenger - Pulled out temporarily - CBaseModPanel::GetSingleton().CloseAllWindows( CBaseModPanel::CLOSE_POLICY_EVEN_MSGS );
  1176. // Show the message box
  1177. // DWenger - Pulled out temporarily - GenericConfirmation* confirmation = static_cast<GenericConfirmation*>( CBaseModPanel::GetSingleton().OpenWindow( WT_GENERICCONFIRMATION, NULL, false ) );
  1178. // DWenger - Pulled out temporarily - CBaseModPanel::GetSingleton().OpenWindow( WT_MAINMENU, NULL );
  1179. // DWenger - Pulled out temporarily - GenericConfirmation::Data_t data;
  1180. // DWenger - Pulled out temporarily - data.pWindowTitle = szErrorTitle;
  1181. // DWenger - Pulled out temporarily - data.pMessageText = szError;
  1182. // DWenger - Pulled out temporarily - data.bOkButtonEnabled = true;
  1183. if ( !Q_stricmp( "dlcrequired", szError ) )
  1184. {
  1185. // Special case for DLC required message
  1186. uint64 uiDlcRequiredMask = pEvent->GetUint64( "dlcrequired" );
  1187. int iDlcRequired = 0;
  1188. // Find the first DLC in the reported missing mask that is required
  1189. for ( int k = 1; k < sizeof( uiDlcRequiredMask ); ++ k )
  1190. {
  1191. if ( uiDlcRequiredMask & ( 1ull << k ) )
  1192. {
  1193. iDlcRequired = k;
  1194. break;
  1195. }
  1196. }
  1197. CFmtStr strLocKey( "#SessionError_DLC_RequiredTitle_%d", iDlcRequired );
  1198. if ( !g_pVGuiLocalize->Find( strLocKey ) )
  1199. iDlcRequired = 0;
  1200. // Try to figure out if this DLC is paid/free/unknown
  1201. KeyValues *kvDlcDetails = new KeyValues( "" );
  1202. KeyValues::AutoDelete autodelete_kvDlcDetails( kvDlcDetails );
  1203. if ( !kvDlcDetails->LoadFromFile( g_pFullFileSystem, "resource/UI/BaseModUI/dlcdetailsinfo.res", "MOD" ) )
  1204. kvDlcDetails = NULL;
  1205. // Determine the DLC offer ID
  1206. uint64 uiDlcOfferID = 0ull;
  1207. if ( 1 != sscanf( kvDlcDetails->GetString( CFmtStr( "dlc%d/offerid", iDlcRequired ) ), "0x%llx", &uiDlcOfferID ) )
  1208. uiDlcOfferID = 0ull;
  1209. // Format the strings
  1210. bool bKicked = !Q_stricmp( pEvent->GetString( "action" ), "kicked" );
  1211. wchar_t const *wszLine1 = g_pVGuiLocalize->Find( CFmtStr( "#SessionError_DLC_Required%s_%d", bKicked ? "Kicked" : "Join", iDlcRequired ) );
  1212. wchar_t const *wszLine2 = g_pVGuiLocalize->Find( CFmtStr( "#SessionError_DLC_Required%s_%d", uiDlcOfferID ? "Offer" : "Message", iDlcRequired ) );
  1213. int numBytesTwoLines = ( Q_wcslen( wszLine1 ) + Q_wcslen( wszLine2 ) + 4 ) * sizeof( wchar_t );
  1214. wchar_t *pwszTwoLines = ( wchar_t * ) stackalloc( numBytesTwoLines );
  1215. Q_snwprintf( pwszTwoLines, numBytesTwoLines, L"%s%s", wszLine1, wszLine2 );
  1216. // DWenger - Pulled out temporarily - data.pMessageTextW = pwszTwoLines;
  1217. // DWenger - Pulled out temporarily - data.pMessageText = NULL;
  1218. Q_snprintf( chErrorTitleBuffer, sizeof( chErrorTitleBuffer ), "#SessionError_DLC_RequiredTitle_%d", iDlcRequired );
  1219. // DWenger - Pulled out temporarily - data.pWindowTitle = chErrorTitleBuffer;
  1220. if ( uiDlcOfferID )
  1221. {
  1222. // DWenger - Pulled out temporarily - data.bCancelButtonEnabled = true;
  1223. // DWenger - Pulled out temporarily - data.pfnOkCallback = GoToMarketplaceForOffer;
  1224. g_MarketplaceEntryPoint.uiOfferID = uiDlcOfferID;
  1225. g_MarketplaceEntryPoint.dwEntryPoint = kvDlcDetails->GetInt( CFmtStr( "dlc%d/type", iDlcRequired ) );
  1226. }
  1227. }
  1228. // DWenger - Pulled out temporarily - confirmation->SetUsageData(data);
  1229. }
  1230. }
  1231. #if ENGINE_CONNECT_VIA_MMS
  1232. #else
  1233. else if ( !Q_strcmp( "OnEngineLevelLoadingSession", szEvent ) )
  1234. {
  1235. /* Removed for partner depot */
  1236. }
  1237. #endif
  1238. }
  1239. class ClientJob_EMsgGCCStrike15_v2_ClientRequestJoinFriendData : public GCSDK::CGCClientJob
  1240. {
  1241. public:
  1242. explicit ClientJob_EMsgGCCStrike15_v2_ClientRequestJoinFriendData( GCSDK::CGCClient *pGCClient ) : GCSDK::CGCClientJob( pGCClient )
  1243. {
  1244. }
  1245. virtual bool BYieldingRunJobFromMsg( GCSDK::IMsgNetPacket *pNetPacket )
  1246. {
  1247. GCSDK::CProtoBufMsg<CMsgGCCStrike15_v2_ClientRequestJoinFriendData> msg( pNetPacket );
  1248. if ( msg.Body().has_errormsg() )
  1249. {
  1250. RemapText_t arrText[] = {
  1251. { "Game is full", "#SFUI_DisconnectReason_LobbyFull", RemapText_t::MATCH_FULL },
  1252. { "Certified server required", "#SFUI_DisconnectReason_CertifiedServerRequired", RemapText_t::MATCH_FULL },
  1253. { "Certified server denied", "#SFUI_DisconnectReason_CertifiedServerDenied", RemapText_t::MATCH_FULL },
  1254. { "PW server required", "#SFUI_DisconnectReason_PWServerRequired", RemapText_t::MATCH_FULL },
  1255. { "PW server denied", "#SFUI_DisconnectReason_PWServerDenied", RemapText_t::MATCH_FULL },
  1256. { NULL, NULL, RemapText_t::MATCH_FULL }
  1257. };
  1258. char const *szReason = RemapText_t::RemapRawText( arrText, msg.Body().errormsg().c_str() );
  1259. g_pMatchFramework->CloseSession();
  1260. CMessageBoxScaleform::UnloadAllDialogs( true );
  1261. BasePanel()->RestoreMainMenuScreen();
  1262. CCommandMsgBox::CreateAndShow( "#SFUI_Disconnect_Title", szReason, true );
  1263. return false;
  1264. }
  1265. if ( msg.Body().res().serverid() )
  1266. {
  1267. ServerCookie_t sc = { msg.Body().res().reservationid(), Plat_FloatTime() };
  1268. g_mapServerCookies.InsertOrReplace( msg.Body().res().serverid(), sc );
  1269. }
  1270. return true;
  1271. }
  1272. };
  1273. GC_REG_CLIENT_JOB( ClientJob_EMsgGCCStrike15_v2_ClientRequestJoinFriendData, k_EMsgGCCStrike15_v2_ClientRequestJoinFriendData );
  1274. class ClientJob_EMsgGCCStrike15_v2_ClientRequestJoinServerData : public GCSDK::CGCClientJob
  1275. {
  1276. public:
  1277. explicit ClientJob_EMsgGCCStrike15_v2_ClientRequestJoinServerData( GCSDK::CGCClient *pGCClient ) : GCSDK::CGCClientJob( pGCClient )
  1278. {
  1279. }
  1280. virtual bool BYieldingRunJobFromMsg( GCSDK::IMsgNetPacket *pNetPacket )
  1281. {
  1282. GCSDK::CProtoBufMsg<CMsgGCCStrike15_v2_ClientRequestJoinServerData> msg( pNetPacket );
  1283. if ( msg.Body().has_errormsg() )
  1284. {
  1285. RemapText_t arrText[] = {
  1286. { "Game is full", "#SFUI_DisconnectReason_LobbyFull", RemapText_t::MATCH_FULL },
  1287. { "Certified server required", "#SFUI_DisconnectReason_CertifiedServerRequired", RemapText_t::MATCH_FULL },
  1288. { "Certified server denied", "#SFUI_DisconnectReason_CertifiedServerDenied", RemapText_t::MATCH_FULL },
  1289. { "PW server required", "#SFUI_DisconnectReason_PWServerRequired", RemapText_t::MATCH_FULL },
  1290. { "PW server denied", "#SFUI_DisconnectReason_PWServerDenied", RemapText_t::MATCH_FULL },
  1291. { NULL, NULL, RemapText_t::MATCH_FULL }
  1292. };
  1293. char const *szReason = RemapText_t::RemapRawText( arrText, msg.Body().errormsg().c_str() );
  1294. g_pMatchFramework->CloseSession();
  1295. CMessageBoxScaleform::UnloadAllDialogs( true );
  1296. BasePanel()->RestoreMainMenuScreen();
  1297. GameUI().CreateCommandMsgBox( "#SFUI_Disconnect_Title", szReason, true );
  1298. return false;
  1299. }
  1300. ServerCookie_t sc = { msg.Body().res().reservationid(), Plat_FloatTime() };
  1301. g_mapServerCookies.InsertOrReplace( msg.Body().serverid(), sc );
  1302. return true;
  1303. }
  1304. };
  1305. GC_REG_CLIENT_JOB( ClientJob_EMsgGCCStrike15_v2_ClientRequestJoinServerData, k_EMsgGCCStrike15_v2_ClientRequestJoinServerData );
  1306. #if !defined( NO_STEAM )
  1307. void CUIGameData::Steam_OnUserStatsStored( UserStatsStored_t *pParam )
  1308. {
  1309. #if defined( _PS3 )
  1310. GetPs3SaveSteamInfoProvider()->WriteSteamStats();
  1311. #endif
  1312. }
  1313. void CUIGameData::Steam_OnUserStatsReceived( UserStatsReceived_t *pParam )
  1314. {
  1315. #if defined( _PS3 )
  1316. GetPs3SaveSteamInfoProvider()->WriteSteamStats();
  1317. #endif
  1318. }
  1319. #endif
  1320. //////////////////////////////////////////////////////////////////////////
  1321. //
  1322. //
  1323. // A bunch of helper KeyValues hierarchy readers
  1324. //
  1325. //
  1326. //////////////////////////////////////////////////////////////////////////
  1327. bool GameModeHasDifficulty( char const *szGameMode )
  1328. {
  1329. return !Q_stricmp( szGameMode, "coop" ) || !Q_stricmp( szGameMode, "realism" );
  1330. }
  1331. char const * GameModeGetDefaultDifficulty( char const *szGameMode )
  1332. {
  1333. if ( !GameModeHasDifficulty( szGameMode ) )
  1334. return "normal";
  1335. ACTIVE_SPLITSCREEN_PLAYER_GUARD( GET_ACTIVE_SPLITSCREEN_SLOT() );
  1336. IPlayerLocal *pProfile = g_pMatchFramework->GetMatchSystem()->GetPlayerManager()->GetLocalPlayer( XBX_GetActiveUserId() );
  1337. if ( !pProfile )
  1338. return "normal";
  1339. UserProfileData const &upd = pProfile->GetPlayerProfileData();
  1340. switch ( upd.difficulty )
  1341. {
  1342. case 1: return "easy";
  1343. case 2: return "hard";
  1344. default: return "normal";
  1345. }
  1346. }
  1347. bool GameModeHasRoundLimit( char const *szGameMode )
  1348. {
  1349. return !Q_stricmp( szGameMode, "scavenge" ) || !Q_stricmp( szGameMode, "teamscavenge" );
  1350. }
  1351. bool GameModeIsSingleChapter( char const *szGameMode )
  1352. {
  1353. return !Q_stricmp( szGameMode, "survival" ) || !Q_stricmp( szGameMode, "scavenge" ) || !Q_stricmp( szGameMode, "teamscavenge" );
  1354. }
  1355. // DWenger - Pulled out temporarily
  1356. /*
  1357. const char *COM_GetModDirectory()
  1358. {
  1359. static char modDir[MAX_PATH];
  1360. if ( Q_strlen( modDir ) == 0 )
  1361. {
  1362. const char *gamedir = CommandLine()->ParmValue("-game", CommandLine()->ParmValue( "-defaultgamedir", "hl2" ) );
  1363. Q_strncpy( modDir, gamedir, sizeof(modDir) );
  1364. if ( strchr( modDir, '/' ) || strchr( modDir, '\\' ) )
  1365. {
  1366. Q_StripLastDir( modDir, sizeof(modDir) );
  1367. int dirlen = Q_strlen( modDir );
  1368. Q_strncpy( modDir, gamedir + dirlen, sizeof(modDir) - dirlen );
  1369. }
  1370. }
  1371. return modDir;
  1372. }
  1373. */
  1374. uint64 GetDlcInstalledMask()
  1375. {
  1376. static ConVarRef mm_dlcs_mask_fake( "mm_dlcs_mask_fake" );
  1377. char const *szFakeDlcsString = mm_dlcs_mask_fake.GetString();
  1378. if ( *szFakeDlcsString )
  1379. return atoi( szFakeDlcsString );
  1380. static ConVarRef mm_dlcs_mask_extras( "mm_dlcs_mask_extras" );
  1381. uint64 uiDLCmask = ( unsigned ) mm_dlcs_mask_extras.GetInt();
  1382. bool bSearchPath = false;
  1383. int numDLCs = g_pFullFileSystem->IsAnyDLCPresent( &bSearchPath );
  1384. for ( int j = 0; j < numDLCs; ++ j )
  1385. {
  1386. unsigned int uiDlcHeader = 0;
  1387. if ( !g_pFullFileSystem->GetAnyDLCInfo( j, &uiDlcHeader, NULL, 0 ) )
  1388. continue;
  1389. int idDLC = DLC_LICENSE_ID( uiDlcHeader );
  1390. if ( idDLC < 1 || idDLC >= 31 )
  1391. continue; // unsupported DLC id
  1392. uiDLCmask |= ( 1ull << idDLC );
  1393. }
  1394. return uiDLCmask;
  1395. }