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

  1. //Copyright (c) 2002 Electronic Arts Inc. All rights reserved.
  2.  
  3. var currentControl      = 0;
  4. var aItems                = new Array('srcBasic', 'srcAdvanced', 'srcOther');
  5. DialogWindow            = top.DialogWindow;
  6. var inputDevice;
  7. var myDialog;
  8. var oAudioInterface = oGameFace.AudioInterface;
  9. var controlConfig;
  10.  
  11. var nAction1 = 0;
  12. var nAction2 = 0;
  13. var nAction3 = 0;
  14. var nAction4 = 0;
  15. var nAction5 = 0;
  16. var nAction6 = 0;
  17. var nAction7 = 0;
  18. var nAction8 = 0;
  19. var nAction9 = 0;
  20. var nAction10 = 0;
  21. var nAction11 = 0;
  22.  
  23. var nControllerCount        = 0;
  24.  
  25. function doSkin()
  26. {
  27.     skinTable1Header.background = "../images2/common/" + System.GUI.getTeamSkin() + "/1x1_subhead.gif";
  28. }
  29.  
  30. function initSettings()
  31. {
  32.     doSkin();
  33.  
  34.     if (!oLeagueFace.ProviderInterface.IsInSetup())
  35.        {
  36.         oLeagueFace.ProviderInterface.EnterSetup();
  37.     }
  38.  
  39.  
  40.     //System.GUI.setTitleMovie("Controller_Config.swf");
  41.  
  42.     controlConfig = new ControlConfigObject();
  43.     //init game interface
  44.     oCallbackTable = new CallbackTableObject();
  45.     initGameInterface( oCallbackTable );
  46.     inputDevice = new InputDeviceObject();
  47.     initDrpScreens();
  48.     initDrpControllers();
  49.     // get the control config -- will be keyboard
  50.     initControl();
  51.     displayFirstScreen();
  52. }
  53.  
  54. function canExitScreen()
  55. {
  56.     oGameFace.DeviceInterface.SaveInputDeviceConfig(currentControl);
  57.  
  58.     oGameFace.RemoveLocalEventTable();    
  59.     //oLeagueFace.ManagerInterface.SaveGameSettings( oGameData );    
  60.     removeCallbackTable();    
  61.     return true;
  62. }
  63.  
  64. function clearSettings()
  65. {
  66. }
  67.  
  68. function ControlConfigObject()
  69. {
  70.     this.Action1 = "";
  71.  
  72.     this.Action2 = "";
  73.     this.Action3 = "";
  74.     this.Action4 = "";
  75.     this.Action5 = "";
  76.     this.Action6 = "";
  77.     this.Action7 = "";
  78.     this.Action8 = "";
  79.  
  80.  
  81.     this.Action9= "";
  82.     this.Action10= "";
  83.     this.Action11= "";
  84.  
  85. }
  86.  
  87. function CallbackTableObject()
  88. {
  89.     this.ControlConfigChanged = onControlConfigChanged;
  90. }
  91.  
  92. function InputDeviceObject()
  93. {
  94.     this.keyboard = 0;
  95.     this.joystick1 = 0;
  96.     this.joystick2 = 0;
  97.     this.joystick3 = 0;
  98.     this.joystick4 = 0;
  99.     this.joystick5 = 0;
  100.     this.joystick6 = 0;
  101.     this.joystick1Name = "";
  102.     this.joystick2Name = "";
  103.     this.joystick3Name = "";
  104.     this.joystick4Name = "";
  105.     this.joystick5Name = "";
  106.     this.joystick6Name = "";
  107.  
  108.     oGameFace.DeviceInterface.GetInputDevices(this);
  109.     //alert("joystick1Name " + this.joystick1Name);
  110.     //alert("joystick2Name " + this.joystick2Name);
  111. }
  112.  
  113. function changeController()
  114. {
  115.     switch( drpController.Selected )
  116.     {
  117.         case 0:
  118.             addKeyboardOption();
  119.             break;
  120.         default:
  121.             removeKeyboardOption();
  122.     }
  123.     doController();
  124. }
  125.  
  126. function changeScreen()
  127. {
  128.     var nExpression = (arguments.length == 0 ) ? parseInt( drpScreen.Selected ) : arguments[0];
  129.  
  130.     // first make everything hidden
  131.     srcBasic.style.visibility = "hidden";
  132.     srcAdvanced.style.visibility = "hidden";
  133.     srcOther.style.visibility = "hidden";
  134.  
  135.     switch( nExpression )
  136.         {
  137.         case 0:
  138.             toggleVisibility(srcBasic);
  139.             break;
  140.         case 1:
  141.             toggleVisibility(srcAdvanced);
  142.             break;
  143.         case 2:
  144.             toggleVisibility(srcOther);
  145.             break;
  146.         }
  147. }
  148.  
  149. function onControlConfigChanged()
  150. {
  151.     if (System.GUI.dialog)
  152.     {
  153.         System.GUI.dialog.hide();
  154.     }
  155.  
  156.     oGameFace.DeviceInterface.GetInputDeviceConfig(currentControl, controlConfig);
  157.  
  158.     //drpController.Selected = controlConfig.Name;
  159.  
  160.     txtKey01.innerText = controlConfig.Action1;
  161.     txtKey02.innerText = controlConfig.Action2;
  162.     txtKey03.innerText = controlConfig.Action3;
  163.     txtKey04.innerText = controlConfig.Action4;
  164.     txtKey05.innerText = controlConfig.Action5;
  165.     txtKey06.innerText = controlConfig.Action6;
  166.     txtKey07.innerText = controlConfig.Action7;
  167.     txtKey08.innerText = controlConfig.Action8;
  168.     txtKey09.innerText = controlConfig.Action9;
  169.     txtKey10.innerText = controlConfig.Action10;
  170.  
  171.     txtKey11.innerText = controlConfig.Action8;
  172.     txtKey12.innerText = controlConfig.Action11;
  173. }
  174.  
  175.  
  176. function toggleVisibility( srcItem )
  177. {
  178.     srcItem.style.visibility = 'visible';
  179.     hideOthers( srcItem );
  180. }
  181.  
  182. function hideOthers( srcItem )
  183. {
  184.  
  185.     //for( var index = 0 ; index < aItems.length ; index ++ )
  186.     //{
  187.     //    if(aItems[ index ] != srcItem.id)
  188.     //    {
  189.     //        var oScreen = document.all[ aItems[ index ]];
  190.    //         oScreen.style.visibility = 'hidden';
  191.    //     }
  192.    // }
  193.  
  194.     //srcDirectional.style.visibility = 'hidden';
  195. }
  196.  
  197. function initDrpControllers()
  198. {
  199.     var aComboBox = new ComboBox("drpController", 24, 165, 300, 18, 80, "divController");
  200.  
  201.     drpController.ClearAll();
  202.     nControllerCount = 0;
  203.  
  204.     drpController.AddString(nhlMsg('KEYBOARD'));
  205.     nControllerCount++;
  206.     if(inputDevice.joystick1)
  207.     {
  208.         //drpController.AddString(nhlMsg('JOYPAD'));
  209.         drpController.AddString(inputDevice.joystick1Name);
  210.         nControllerCount++;
  211.     }
  212.     if(inputDevice.joystick2)
  213.     {
  214.         //drpController.AddString(nhlMsg('JOYPAD'));
  215.         drpController.AddString(inputDevice.joystick2Name);
  216.         nControllerCount++;
  217.     }
  218.     if(inputDevice.joystick3)
  219.     {
  220.         //drpController.AddString(nhlMsg('JOYPAD'));
  221.         drpController.AddString(inputDevice.joystick3Name);
  222.         nControllerCount++;
  223.     }
  224.     if(inputDevice.joystick4)
  225.     {
  226.         //drpController.AddString(nhlMsg('JOYPAD'));
  227.         drpController.AddString(inputDevice.joystick4Name);
  228.         nControllerCount++;
  229.     }
  230.     if(inputDevice.joystick5)
  231.     {
  232.         //drpController.AddString(nhlMsg('JOYPAD'));
  233.         drpController.AddString(inputDevice.joystick5Name);
  234.         nControllerCount++;
  235.     }
  236.     drpController.Selected = 0;
  237. }
  238.  
  239. function initDrpScreens()
  240. {
  241.     var aComboBox = new ComboBox("drpScreen", 50, 48, 171, 18, 80, "divScreen");
  242.  
  243.     drpScreen.ClearAll();
  244.     drpScreen.AddString(nhlMsg('BASIC_CONTROLS'));
  245.     drpScreen.AddString(nhlMsg('ADVANCED_CONTROLS'));
  246.     drpScreen.AddString(nhlMsg('OTHER'));
  247.  
  248.     //addKeyboardOption();
  249. }
  250.  
  251. function addKeyboardOption()
  252. {
  253.     if (drpScreen.Selected == 4)
  254.         srcDirectional.style.visibility = 'visible';
  255. }
  256.  
  257. function removeKeyboardOption()
  258. {
  259.     //srcDirectional.style.visibility = 'hidden';
  260. }
  261.  
  262. function initControl()
  263. {
  264.     onControlConfigChanged();
  265. }
  266.  
  267. function displayFirstScreen()
  268. {
  269.     changeScreen( 0 );
  270.     drpScreen.Selected = 0;
  271. }
  272.  
  273. function doClick( controlEvent )
  274. {
  275.     oAudioInterface.PlayWarningSFX();
  276.  
  277.     System.GUI.dialog.innerHTML = nhlMsg("CONTROLLER_CONFIG_INSTRUCTIONS");
  278.     System.GUI.dialog.setSize( 350 , 100 );
  279.     System.GUI.dialog.align = "center";
  280.     System.GUI.dialog.addButton( "cancelButton" , nhlMsg("CANCEL"), cancelController);
  281.     System.GUI.dialog.show( true );
  282.     oGameFace.DeviceInterface.ConfigureInputDeviceItem( currentControl , controlEvent );
  283. }
  284.  
  285. function doController()
  286. {
  287.     oGameFace.DeviceInterface.SaveInputDeviceConfig(currentControl);
  288.     currentControl = parseInt( drpController.Selected );
  289.     onControlConfigChanged();
  290. }
  291.  
  292. function cancelController()
  293. {
  294.     oGameFace.DeviceInterface.CancelConfigureInputDevice();
  295. }
  296.  
  297. function doDefault()
  298. {
  299.     oAudioInterface.PlaySFX(1099);
  300.     oGameFace.DeviceInterface.DefaultInputDeviceConfig(currentControl);
  301.     oGameFace.DeviceInterface.SaveInputDeviceConfig(currentControl);
  302. }
  303.  
  304.  
  305. function drpControllerOnDropDown()
  306. {
  307.     drpController.style.height=20+(20*nControllerCount);
  308.     drpController.style.zIndex=100;
  309. }
  310. function drpControllerOnPullUp()
  311. {
  312.     drpController.style.zIndex=0;
  313.     drpController.style.height=20;
  314. }
  315.  
  316.  
  317. function drpScreenOnDropDown()
  318. {
  319.     drpScreen.style.height=130;
  320.     drpScreen.style.zIndex=100;
  321. }
  322. function drpScreenOnPullUp()
  323. {
  324.     drpScreen.style.zIndex=0;
  325.     drpScreen.style.height=20;
  326. }
  327.