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.
 
 
 

100 lines
1.9 KiB

  1. define([
  2. 'js/system/client',
  3. 'ui/factory',
  4. 'js/renderer',
  5. 'js/objects/objects',
  6. 'js/rendering/effects',
  7. 'js/rendering/numbers',
  8. 'js/input',
  9. 'js/system/events',
  10. 'js/resources',
  11. 'ui/templates/inventory/inventory',
  12. 'ui/templates/equipment/equipment',
  13. 'ui/templates/stash/stash',
  14. 'ui/templates/hud/hud',
  15. 'ui/templates/online/online',
  16. 'ui/templates/quests/quests',
  17. 'ui/templates/events/events',
  18. 'ui/templates/dialogue/dialogue',
  19. 'ui/templates/smithing/smithing',
  20. 'ui/templates/overlay/overlay',
  21. 'ui/templates/tooltips/tooltips',
  22. 'ui/templates/reputation/reputation',
  23. 'ui/templates/death/death'
  24. ], function(
  25. client,
  26. uiFactory,
  27. renderer,
  28. objects,
  29. effects,
  30. numbers,
  31. input,
  32. events,
  33. resources
  34. ) {
  35. return {
  36. hasFocus: true,
  37. init: function() {
  38. client.init(this.onClientReady.bind(this));
  39. },
  40. onClientReady: function() {
  41. client.request({
  42. module: 'clientConfig',
  43. method: 'getResourcesList',
  44. callback: this.onGetResourceList.bind(this)
  45. });
  46. },
  47. onGetResourceList: function(list) {
  48. resources.init(list);
  49. events.on('onResourcesLoaded', this.start.bind(this));
  50. },
  51. start: function() {
  52. window.onfocus = this.onFocus.bind(this, true);
  53. window.onblur = this.onFocus.bind(this, false);
  54. $(window).on('contextmenu', function(e) {
  55. e.preventDefault();
  56. return false;
  57. });
  58. objects.init();
  59. renderer.init();
  60. input.init();
  61. numbers.init();
  62. uiFactory.init();
  63. uiFactory.build('login', 'body');
  64. this.update();
  65. this.render();
  66. },
  67. onFocus: function(hasFocus) {
  68. //Hack: Later we might want to make it not render when out of focus
  69. this.hasFocus = true;
  70. if (!hasFocus)
  71. input.resetKeys();
  72. },
  73. render: function() {
  74. numbers.render();
  75. renderer.render();
  76. requestAnimationFrame(this.render.bind(this));
  77. },
  78. update: function() {
  79. objects.update();
  80. renderer.update();
  81. uiFactory.update();
  82. setTimeout(this.update.bind(this), 16);
  83. }
  84. };
  85. });