選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

114 行
2.2 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. events.on('onResize', this.onResize.bind(this));
  17. },
  18. onEnterGame: function () {
  19. events.clearQueue();
  20. [
  21. 'inventory',
  22. 'equipment',
  23. 'hud',
  24. 'target',
  25. 'menu',
  26. 'spells',
  27. 'messages',
  28. 'online',
  29. 'options',
  30. 'context',
  31. 'party',
  32. 'help',
  33. 'dialogue',
  34. 'buffs',
  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. 'mail',
  51. 'wardrobe',
  52. 'passives'
  53. ].forEach(function (u) {
  54. this.build(u);
  55. }, this);
  56. },
  57. build: function (type, options) {
  58. //Don't make doubles?
  59. var className = 'ui' + type[0].toUpperCase() + type.substr(1);
  60. var el = $('.' + className);
  61. if (el.length > 0)
  62. return;
  63. this.getTemplate(type, options);
  64. },
  65. getTemplate: function (type, options) {
  66. require([this.root + 'ui/templates/' + type + '/' + type], this.onGetTemplate.bind(this, options));
  67. },
  68. onGetTemplate: function (options, template) {
  69. var ui = _.create(uiBase, template);
  70. ui.setOptions(options);
  71. ui.render();
  72. ui.el.data('ui', ui);
  73. this.uis.push(ui);
  74. },
  75. onResize: function () {
  76. this.uis.forEach(function (ui) {
  77. if (ui.centered)
  78. ui.center();
  79. else if ((ui.centeredX) || (ui.centeredY))
  80. ui.center(ui.centeredX, ui.centeredY);
  81. }, this);
  82. },
  83. onKeyDown: function (key) {
  84. if (key == 'esc') {
  85. this.uis.forEach(function (u) {
  86. if (!u.modal)
  87. return;
  88. u.hide();
  89. });
  90. $('.uiOverlay').hide();
  91. events.emit('onHideContextMenu');
  92. } else if (['o', 'j', 'h', 'i'].indexOf(key) > -1)
  93. $('.uiOverlay').hide();
  94. },
  95. update: function () {
  96. var uis = this.uis;
  97. var uLen = uis.length;
  98. for (var i = 0; i < uLen; i++) {
  99. var u = uis[i];
  100. if (u.update)
  101. u.update();
  102. }
  103. }
  104. };
  105. });