home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Joystick Magazine 2003 November
/
CD1_JOY_153.iso
/
demos
/
NHL2004Demo.exe
/
fe
/
nhl
/
js
/
NHLGlobalEvents.js
< prev
next >
Wrap
Text File
|
2003-08-20
|
5KB
|
175 lines
//Copyright (c) 2002 Electronic Arts Inc. All rights reserved.
var oGameFace = window.external.GameInterface;
function initGlobalEvents()
{
oCallbackTable = new CallbackTableObject();
window.external.GameInterface.SetGlobalEventTable( oCallbackTable );
}
function clearGlobalEvents()
{
window.external.GameInterface.RemoveLocalEventTable();
}
function OnCheaterInGame()
{
if (System.GUI.isNavigating())
{
setTimeout("OnCheaterInGame();", 50);
}
else
{
if (oGameFace.LeagueServerInterface.LeagueDispatch.ProviderInterface.IsInSetup())
{
// we are killing the connection
// we can return to the main menu, the league, the sports lobby depending on the league
window.external.GameInterface.AudioInterface.PlayWarningSFX();
System.GUI.dialog.innerHTML = nhlMsg('ERROR_GAME_MISMATCH');
System.GUI.dialog.setSize( 400 , 150 );
System.GUI.dialog.align = "center";
System.GUI.dialog.addButton( "okButton" , nhlMsg("OKAY", true), GameAbortBackout);
System.GUI.dialog.show( true );
}
}
}
function OnAbortGame()
{
if (System.GUI.isNavigating())
{
setTimeout("OnAbortGame();", 50);
}
else
{
if (oGameFace.LeagueServerInterface.LeagueDispatch.ProviderInterface.IsInSetup())
{
// we are killing the connection
// we can return to the main menu, the league, the sports lobby depending on the league
window.external.GameInterface.AudioInterface.PlayWarningSFX();
if (oGameFace.LeagueServerInterface.LeagueType == 2)
{
oGameFace.CommInterface.ReportNoStart();
oGameFace.CommInterface.PurgeGameReporter();
}
System.GUI.dialog.innerHTML = nhlMsg('CONNECTION_CANCELLED');
System.GUI.dialog.setSize( 400 , 150 );
System.GUI.dialog.align = "center";
System.GUI.dialog.addButton( "okButton" , nhlMsg("OKAY", true), GameAbortBackout);
System.GUI.dialog.show( true );
}
}
}
function OnSongInfoChanged()
{
// get the song info
var artist = window.external.GameInterface.AudioInterface.GetSongArtist();
var title = window.external.GameInterface.AudioInterface.GetSongTitle();
var album = window.external.GameInterface.AudioInterface.GetSongAlbum();
// now send this info to the chyron display
System.GUI.setChyronInfo(artist, title, album);
}
function GameAbortBackout()
{
var sPostGameID = System.Session.getPostGameNavigation();
System.GUI.navigate( sPostGameID );
}
function CallbackTableObject()
{
this.AbortGame = OnAbortGame;
this.CheaterInGame = OnCheaterInGame;
this.SongInfoChanged = OnSongInfoChanged;
}
function OnLeagueSimulate()
{
var oManager = oGameFace.LeagueServerInterface.LeagueDispatch.ManagerInterface;
var oAudioInterface = oGameFace.AudioInterface;
if (oManager.IsValidNextGame())
{
oAudioInterface.PlaySimGameSFX();
if (!oManager.IsOnlineNextGame())
{
// do the simple simulate
oManager.SimNextGame();
}
else
{
// show the dialog that won't allow us to sim the online game
window.external.GameInterface.AudioInterface.PlayWarningSFX();
System.GUI.dialog.innerHTML = nhlMsg('NOGAMES');
System.GUI.dialog.setSize( 400 , 150 );
System.GUI.dialog.align = "center";
System.GUI.dialog.addButton("closeBtn", nhlMsg("CANCEL"));
System.GUI.dialog.show( true );
}
}
else
{
window.external.GameInterface.AudioInterface.PlayWarningSFX();
System.GUI.dialog.innerHTML = nhlMsg('NOGAMES');
System.GUI.dialog.setSize( 400 , 150 );
System.GUI.dialog.align = "center";
System.GUI.dialog.addButton("closeBtn", nhlMsg("CANCEL"));
System.GUI.dialog.show();
}
}
function OnLeaguePlay()
{
if (System.GUI.isNavigating()) { return; }
var oGameFace = window.external.GameInterface;
var oManager = oGameFace.LeagueServerInterface.LeagueDispatch.ManagerInterface;
var oExecutor = oGameFace.ExecutorServerInterface;
var oComm = oGameFace.CommInterface;
var oAudioInterface = oGameFace.AudioInterface;
// we are being asked to start the next game. we should really
// do a double check on whether this is a valid game for playing
if (oManager.IsValidNextGame())
{
oAudioInterface.PlaySimGameSFX(); //intentionally playing same sfx as Sim here.
// if we are online we should go to the online setup screens
if (oManager.IsOnlineNextGame())
{
if (oComm.IsCommAvailable())
{
oManager.ExitCentral();
oExecutor.LoadExecutorInternal(0);
// go to the next screen
System.GUI.navigate( "1869" );
}
}
else
{
oManager.ExitCentral();
oExecutor.LoadExecutorInternal(0);
// go to the next screen
System.GUI.navigate( "1100" );
}
}
else
{
window.external.GameInterface.AudioInterface.PlayWarningSFX();
System.GUI.dialog.innerHTML = nhlMsg('NOGAMES');
System.GUI.dialog.setSize( 400 , 150 );
System.GUI.dialog.align = "center";
System.GUI.dialog.addButton("closeBtn", nhlMsg("CANCEL"));
System.GUI.dialog.show();
}
}