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.
 
 
 

101 regels
2.3 KiB

  1. define([
  2. 'js/system/events',
  3. 'html!ui/templates/options/template',
  4. 'css!ui/templates/options/styles',
  5. 'js/rendering/renderer',
  6. 'ui/factory',
  7. 'js/objects/objects',
  8. 'js/system/client'
  9. ], function (
  10. events,
  11. template,
  12. styles,
  13. renderer,
  14. factory,
  15. objects,
  16. client
  17. ) {
  18. return {
  19. tpl: template,
  20. centered: true,
  21. modal: true,
  22. postRender: function () {
  23. //this.onEvent('onKeyDown', this.onKeyDown.bind(this));
  24. this.onEvent('onToggleOptions', this.toggle.bind(this));
  25. this.el.find('.btnScreen').on('click', this.toggleScreen.bind(this));
  26. this.el.find('.btnCharSelect').on('click', this.charSelect.bind(this));
  27. this.el.find('.btnLogOut').on('click', this.logOut.bind(this));
  28. this.el.find('.btnContinue').on('click', this.toggle.bind(this));
  29. this.el.find('.btnPatreon').on('click', this.patreon.bind(this));
  30. this.el.find('.btnIssue').on('click', this.reportIssue.bind(this));
  31. this.onEvent('onResize', this.onResize.bind(this));
  32. },
  33. reportIssue: function () {
  34. window.open('https://gitlab.com/Isleward/isleward/issues/new', '_blank');
  35. },
  36. patreon: function () {
  37. window.open('https://patreon.com/bigbadwaffle', '_blank');
  38. },
  39. charSelect: function () {
  40. client.request({
  41. module: 'cons',
  42. method: 'unzone'
  43. });
  44. renderer.clean();
  45. objects.onRezone();
  46. renderer.buildTitleScreen();
  47. events.emit('onShowCharacterSelect');
  48. $('[class^="ui"]:not(.ui-container)').each(function (i, el) {
  49. var ui = $(el).data('ui');
  50. if ((ui) && (ui.destroy))
  51. ui.destroy();
  52. });
  53. factory.build('characters', {});
  54. },
  55. toggleScreen: function () {
  56. this.el.find('.btnScreen').html(renderer.toggleScreen());
  57. },
  58. onResize: function () {
  59. var isFullscreen = (window.innerHeight == screen.height);
  60. if (isFullscreen)
  61. this.el.find('.btnScreen').html('Windowed');
  62. else
  63. this.el.find('.btnScreen').html('Fullscreen');
  64. },
  65. toggle: function () {
  66. this.onResize();
  67. this.shown = !this.el.is(':visible');
  68. if (this.shown) {
  69. this.show();
  70. events.emit('onShowOverlay', this.el);
  71. } else {
  72. this.hide();
  73. events.emit('onHideOverlay', this.el);
  74. }
  75. },
  76. logOut: function () {
  77. window.location = window.location;
  78. },
  79. onKeyDown: function (key) {
  80. if (key == 'esc')
  81. this.toggle();
  82. }
  83. }
  84. });