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.
 
 
 

110 lines
2.1 KiB

  1. define([
  2. 'js/system/client',
  3. 'ui/factory',
  4. 'js/rendering/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. 'ui/templates/passives/passives'
  25. ], function (
  26. client,
  27. uiFactory,
  28. renderer,
  29. objects,
  30. effects,
  31. numbers,
  32. input,
  33. events,
  34. resources
  35. ) {
  36. return {
  37. hasFocus: true,
  38. init: function () {
  39. client.init(this.onClientReady.bind(this));
  40. },
  41. onClientReady: function () {
  42. client.request({
  43. module: 'clientConfig',
  44. method: 'getResourcesList',
  45. callback: this.onGetResourceList.bind(this)
  46. });
  47. },
  48. onGetResourceList: function (list) {
  49. resources.init(list);
  50. events.on('onResourcesLoaded', this.start.bind(this));
  51. },
  52. start: function () {
  53. window.onfocus = this.onFocus.bind(this, true);
  54. window.onblur = this.onFocus.bind(this, false);
  55. $(window).on('contextmenu', function (e) {
  56. let allowedList = ['txtUsername', 'txtPassword'];
  57. let allowed = allowedList.some(function (item) {
  58. return $(e.target).hasClass(item);
  59. });
  60. if (!allowed) {
  61. e.preventDefault();
  62. return false;
  63. }
  64. });
  65. objects.init();
  66. renderer.init();
  67. input.init();
  68. numbers.init();
  69. uiFactory.init();
  70. uiFactory.build('login', 'body');
  71. this.update();
  72. this.render();
  73. },
  74. onFocus: function (hasFocus) {
  75. //Hack: Later we might want to make it not render when out of focus
  76. this.hasFocus = true;
  77. if (!hasFocus)
  78. input.resetKeys();
  79. },
  80. render: function () {
  81. numbers.render();
  82. renderer.render();
  83. requestAnimationFrame(this.render.bind(this));
  84. },
  85. update: function () {
  86. objects.update();
  87. renderer.update();
  88. uiFactory.update();
  89. setTimeout(this.update.bind(this), 16);
  90. }
  91. };
  92. });