home *** CD-ROM | disk | FTP | other *** search
/ CyberMycha 2003 October / cmycha200310.iso / NHL2004 / NHL2004Demo.exe / fe / nhl / js / NHLGlobalEvents.js < prev    next >
Text File  |  2003-08-20  |  5KB  |  175 lines

  1. //Copyright (c) 2002 Electronic Arts Inc. All rights reserved.
  2.  
  3. var oGameFace = window.external.GameInterface;
  4.  
  5. function initGlobalEvents()
  6. {
  7.     oCallbackTable = new CallbackTableObject();
  8.     window.external.GameInterface.SetGlobalEventTable( oCallbackTable );
  9. }
  10.  
  11. function clearGlobalEvents()
  12. {
  13.     window.external.GameInterface.RemoveLocalEventTable();
  14. }
  15.  
  16. function OnCheaterInGame()
  17. {
  18.     if (System.GUI.isNavigating())
  19.     {
  20.         setTimeout("OnCheaterInGame();", 50);
  21.     }
  22.     else
  23.     {
  24.         if (oGameFace.LeagueServerInterface.LeagueDispatch.ProviderInterface.IsInSetup())
  25.         {
  26.             // we are killing the connection
  27.             // we can return to the main menu, the league, the sports lobby depending on the league
  28.             window.external.GameInterface.AudioInterface.PlayWarningSFX();
  29.             System.GUI.dialog.innerHTML = nhlMsg('ERROR_GAME_MISMATCH');
  30.             System.GUI.dialog.setSize( 400 , 150 );
  31.             System.GUI.dialog.align = "center";
  32.             System.GUI.dialog.addButton( "okButton" , nhlMsg("OKAY", true), GameAbortBackout);
  33.             System.GUI.dialog.show( true );
  34.         }
  35.     }
  36. }
  37.  
  38. function OnAbortGame()
  39. {
  40.     if (System.GUI.isNavigating())
  41.     {
  42.         setTimeout("OnAbortGame();", 50);
  43.     }
  44.     else
  45.     {
  46.         if (oGameFace.LeagueServerInterface.LeagueDispatch.ProviderInterface.IsInSetup())
  47.         {
  48.             // we are killing the connection
  49.             // we can return to the main menu, the league, the sports lobby depending on the league
  50.             window.external.GameInterface.AudioInterface.PlayWarningSFX();
  51.  
  52.             if (oGameFace.LeagueServerInterface.LeagueType == 2)
  53.             {
  54.                 oGameFace.CommInterface.ReportNoStart();
  55.                    oGameFace.CommInterface.PurgeGameReporter();
  56.                }
  57.  
  58.             System.GUI.dialog.innerHTML = nhlMsg('CONNECTION_CANCELLED');
  59.             System.GUI.dialog.setSize( 400 , 150 );
  60.             System.GUI.dialog.align = "center";
  61.             System.GUI.dialog.addButton( "okButton" , nhlMsg("OKAY", true), GameAbortBackout);
  62.             System.GUI.dialog.show( true );
  63.         }
  64.     }
  65. }
  66.  
  67. function OnSongInfoChanged()
  68. {
  69.     // get the song info
  70.  
  71.     var artist = window.external.GameInterface.AudioInterface.GetSongArtist();
  72.     var title = window.external.GameInterface.AudioInterface.GetSongTitle();
  73.     var album = window.external.GameInterface.AudioInterface.GetSongAlbum();
  74.  
  75.     // now send this info to the chyron display
  76.     System.GUI.setChyronInfo(artist, title, album);
  77. }
  78.  
  79.  
  80. function GameAbortBackout()
  81. {
  82.     var sPostGameID = System.Session.getPostGameNavigation();
  83.     System.GUI.navigate( sPostGameID );
  84. }
  85.  
  86. function CallbackTableObject()
  87. {
  88.     this.AbortGame = OnAbortGame;
  89.     this.CheaterInGame = OnCheaterInGame;
  90.     this.SongInfoChanged = OnSongInfoChanged;
  91. }
  92.  
  93. function OnLeagueSimulate()
  94. {
  95.     var oManager = oGameFace.LeagueServerInterface.LeagueDispatch.ManagerInterface;
  96.     var oAudioInterface    = oGameFace.AudioInterface;
  97.  
  98.     if (oManager.IsValidNextGame())
  99.     {
  100.         oAudioInterface.PlaySimGameSFX();
  101.         if (!oManager.IsOnlineNextGame())
  102.         {
  103.             // do the simple simulate
  104.             oManager.SimNextGame();
  105.         }
  106.         else
  107.         {
  108.             // show the dialog that won't allow us to sim the online game
  109.             window.external.GameInterface.AudioInterface.PlayWarningSFX();
  110.             System.GUI.dialog.innerHTML = nhlMsg('NOGAMES');
  111.             System.GUI.dialog.setSize( 400 , 150 );
  112.             System.GUI.dialog.align = "center";
  113.             System.GUI.dialog.addButton("closeBtn", nhlMsg("CANCEL"));
  114.             System.GUI.dialog.show( true );
  115.         }
  116.     }
  117.     else
  118.     {
  119.         window.external.GameInterface.AudioInterface.PlayWarningSFX();
  120.         System.GUI.dialog.innerHTML = nhlMsg('NOGAMES');
  121.         System.GUI.dialog.setSize( 400 , 150 );
  122.         System.GUI.dialog.align = "center";
  123.         System.GUI.dialog.addButton("closeBtn", nhlMsg("CANCEL"));
  124.         System.GUI.dialog.show();
  125.     }
  126. }
  127.  
  128. function OnLeaguePlay()
  129. {
  130.     if (System.GUI.isNavigating()) { return; }
  131.  
  132.     var oGameFace = window.external.GameInterface;
  133.  
  134.     var oManager = oGameFace.LeagueServerInterface.LeagueDispatch.ManagerInterface;
  135.     var oExecutor = oGameFace.ExecutorServerInterface;
  136.     var oComm = oGameFace.CommInterface;
  137.     var oAudioInterface        = oGameFace.AudioInterface;
  138.  
  139.     // we are being asked to start the next game. we should really
  140.     // do a double check on whether this is a valid game for playing
  141.     if (oManager.IsValidNextGame())
  142.     {
  143.         oAudioInterface.PlaySimGameSFX();    //intentionally playing same sfx as Sim here.
  144.         // if we are online we should go to the online setup screens
  145.         if (oManager.IsOnlineNextGame())
  146.         {
  147.             if (oComm.IsCommAvailable())
  148.             {
  149.                 oManager.ExitCentral();
  150.                 oExecutor.LoadExecutorInternal(0);
  151.  
  152.                 // go to the next screen
  153.                 System.GUI.navigate( "1869" );
  154.             }
  155.         }
  156.         else
  157.         {
  158.             oManager.ExitCentral();
  159.             oExecutor.LoadExecutorInternal(0);
  160.  
  161.             // go to the next screen
  162.             System.GUI.navigate( "1100" );
  163.         }
  164.     }
  165.     else
  166.     {
  167.         window.external.GameInterface.AudioInterface.PlayWarningSFX();
  168.         System.GUI.dialog.innerHTML = nhlMsg('NOGAMES');
  169.         System.GUI.dialog.setSize( 400 , 150 );
  170.         System.GUI.dialog.align = "center";
  171.         System.GUI.dialog.addButton("closeBtn", nhlMsg("CANCEL"));
  172.         System.GUI.dialog.show();
  173.     }
  174. }
  175.