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.
 
 
 

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