Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Index: binaries/data/mods/public/gui/session_new/session.js
  2. ===================================================================
  3. --- binaries/data/mods/public/gui/session_new/session.js    (revision 8588)
  4. +++ binaries/data/mods/public/gui/session_new/session.js    (working copy)
  5. @@ -89,8 +89,8 @@
  6.  
  7.  function leaveGame()
  8.  {
  9. -   var simState = Engine.GuiInterfaceCall("GetSimulationState");
  10. -   var playerState = simState.players[Engine.GetPlayerID()];
  11. +   var extendedSimState = Engine.GuiInterfaceCall("GetExtendedSimulationState");
  12. +   var playerState = extendedSimState.players[Engine.GetPlayerID()];
  13.  
  14.     var gameResult;
  15.     if (playerState.state == "won")
  16. @@ -119,8 +119,8 @@
  17.    
  18.     Engine.SwitchGuiPage("page_summary.xml",
  19.                             { "gameResult"  : gameResult,
  20. -                             "timeElapsed" : simState.timeElapsed,
  21. -                             "playerStates": simState.players
  22. +                             "timeElapsed" : extendedSimState.timeElapsed,
  23. +                             "playerStates": extendedSimState.players
  24.                             });
  25.  }
  26.  
  27. Index: binaries/data/mods/public/simulation/components/GuiInterface.js
  28. ===================================================================
  29. --- binaries/data/mods/public/simulation/components/GuiInterface.js (revision 8588)
  30. +++ binaries/data/mods/public/simulation/components/GuiInterface.js (working copy)
  31. @@ -17,6 +17,10 @@
  32.     this.rallyPoints = undefined;
  33.  };
  34.  
  35. +/**
  36. + * All of the functions defined below are called via Engine.GuiInterfaceCall(name, arg) from GUI scripts, and executed here with arguments (player, arg)
  37. +*/
  38. +
  39.  GuiInterface.prototype.GetSimulationState = function(player)
  40.  {
  41.     var ret = {
  42. @@ -60,6 +64,28 @@
  43.     return ret;
  44.  };
  45.  
  46. +GuiInterface.prototype.GetExtendedSimulationState = function(player)
  47. +{
  48. +   // Get basic simulation info
  49. +   var ret = this.GetSimulationState();
  50. +
  51. +   // Add timeElapsed
  52. +   var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
  53. +   ret.timeElapsed = cmpTimer.GetTime();
  54. +  
  55. +   // Add statistics to each player
  56. +   var cmpPlayerMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
  57. +   var n = cmpPlayerMan.GetNumPlayers();
  58. +   for (var i = 0; i < n; ++i)
  59. +   {
  60. +       var playerEnt = cmpPlayerMan.GetPlayerByID(i);
  61. +       var cmpPlayerStatisticsTracker = Engine.QueryInterface(playerEnt, IID_StatisticsTracker);
  62. +       ret.players[i].statistics = cmpPlayerStatisticsTracker.GetStatistics();
  63. +   }
  64. +
  65. +   return ret;
  66. +};
  67. +
  68.  GuiInterface.prototype.GetEntityState = function(player, ent)
  69.  {
  70.     var cmpTempMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement