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.
 
 
 

60 lines
1.1 KiB

  1. define([
  2. 'js/system/events',
  3. 'html!ui/templates/buffs/template',
  4. 'css!ui/templates/buffs/styles',
  5. 'html!ui/templates/buffs/templateBuff'
  6. ], function (
  7. events,
  8. template,
  9. styles,
  10. templateBuff
  11. ) {
  12. let icons = {
  13. stunned: [4, 0],
  14. regenHp: [3, 1],
  15. regenMana: [4, 1],
  16. swiftness: [5, 1],
  17. stealth: [7, 0],
  18. reflectDamage: [2, 1],
  19. holyVengeance: [4, 0]
  20. };
  21. return {
  22. tpl: template,
  23. icons: {},
  24. postRender: function () {
  25. this.onEvent('onGetBuff', this.onGetBuff.bind(this));
  26. this.onEvent('onRemoveBuff', this.onRemoveBuff.bind(this));
  27. },
  28. onGetBuff: function (buff) {
  29. let icon = icons[buff.type];
  30. if (!icon)
  31. return;
  32. let imgX = icon[0] * -32;
  33. let imgY = icon[1] * -32;
  34. let html = templateBuff;
  35. let el = $(html).appendTo(this.el)
  36. .find('.inner')
  37. .css({
  38. background: 'url(../../../images/statusIcons.png) ' + imgX + 'px ' + imgY + 'px'
  39. });
  40. this.icons[buff.id] = el.parent();
  41. },
  42. onRemoveBuff: function (buff) {
  43. let el = this.icons[buff.id];
  44. if (!el)
  45. return;
  46. el.remove();
  47. delete this.icons[buff.id];
  48. }
  49. };
  50. });