Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

70 wiersze
1.2 KiB

  1. define([
  2. 'js/system/events',
  3. 'js/system/client',
  4. 'html!ui/templates/talk/template',
  5. 'css!ui/templates/talk/styles',
  6. 'html!ui/templates/talk/tplOption'
  7. ], function(
  8. events,
  9. client,
  10. template,
  11. styles,
  12. tplOption
  13. ) {
  14. return {
  15. tpl: template,
  16. modal: true,
  17. postRender: function() {
  18. this.onEvent('onGetTalk', this.onGetTalk.bind(this));
  19. this.onEvent('onRezone', this.onRezone.bind(this));
  20. },
  21. onRezone: function() {
  22. this.hide();
  23. },
  24. onGetTalk: function(dialogue) {
  25. this.state = dialogue;
  26. if (!dialogue) {
  27. this.hide();
  28. return;
  29. }
  30. else {
  31. this.show();
  32. }
  33. this.find('.name').html(dialogue.from);
  34. this.find('.msg').html('"' + dialogue.msg + '"');
  35. var options = this.find('.options').empty();
  36. dialogue.options.forEach(function(o) {
  37. var html = tplOption;
  38. $(html)
  39. .appendTo(options)
  40. .html('- ' + o.msg)
  41. .on('click', this.onReply.bind(this, o));
  42. }, this);
  43. this.center(true, false);
  44. },
  45. onReply: function(option) {
  46. client.request({
  47. cpn: 'player',
  48. method: 'performAction',
  49. data: {
  50. cpn: 'dialogue',
  51. method: 'talk',
  52. data: {
  53. target: this.state.id,
  54. state: option.id
  55. }
  56. }
  57. });
  58. }
  59. };
  60. });