Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

110 řádky
2.1 KiB

  1. define([
  2. 'ui/uiBase',
  3. 'js/system/events'
  4. ], function(
  5. uiBase,
  6. events
  7. ) {
  8. return {
  9. uis: [],
  10. root: '',
  11. init: function(root) {
  12. if (root)
  13. this.root = root + '/';
  14. events.on('onEnterGame', this.onEnterGame.bind(this));
  15. events.on('onKeyDown', this.onKeyDown.bind(this));
  16. },
  17. onEnterGame: function() {
  18. events.clearQueue();
  19. [
  20. 'inventory',
  21. 'equipment',
  22. 'hud',
  23. 'target',
  24. 'menu',
  25. 'spells',
  26. 'messages',
  27. 'online',
  28. 'options',
  29. 'context',
  30. 'party',
  31. 'help',
  32. 'dialogue',
  33. 'buffs',
  34. 'partyLoot',
  35. 'tooltips',
  36. 'tooltipInfo',
  37. 'tooltipItem',
  38. 'announcements',
  39. 'quests',
  40. 'events',
  41. 'progressBar',
  42. 'stash',
  43. 'smithing',
  44. 'talk',
  45. 'trade',
  46. 'overlay',
  47. 'death',
  48. 'leaderboard',
  49. 'reputation'
  50. ].forEach(function(u) {
  51. this.build(u);
  52. }, this);
  53. },
  54. build: function(type, options) {
  55. //Don't make doubles?
  56. var className = 'ui' + type[0].toUpperCase() + type.substr(1);
  57. var el = $('.' + className);
  58. if (el.length > 0)
  59. return;
  60. this.getTemplate(type, options);
  61. $(window).on('resize', this.onResize.bind(this));
  62. },
  63. getTemplate: function(type, options) {
  64. require([this.root + 'ui/templates/' + type + '/' + type], this.onGetTemplate.bind(this, options));
  65. },
  66. onGetTemplate: function(options, template) {
  67. var ui = _.create(uiBase, template);
  68. ui.setOptions(options);
  69. ui.render();
  70. ui.el.data('ui', ui);
  71. this.uis.push(ui);
  72. },
  73. onResize: function() {
  74. this.uis.forEach(function(ui) {
  75. if (ui.centered)
  76. ui.center();
  77. else if ((ui.centeredX) || (ui.centeredY))
  78. ui.center(ui.centeredX, ui.centeredY);
  79. }, this);
  80. },
  81. onKeyDown: function(key) {
  82. if (key == 'esc') {
  83. this.uis.forEach(function(u) {
  84. if (!u.modal)
  85. return;
  86. u.hide();
  87. });
  88. $('.uiOverlay').hide();
  89. events.emit('onHideContextMenu');
  90. }
  91. },
  92. update: function() {
  93. var uis = this.uis;
  94. var uLen = uis.length;
  95. for (var i = 0; i < uLen; i++) {
  96. var u = uis[i];
  97. if (u.update)
  98. u.update();
  99. }
  100. }
  101. };
  102. });