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.

91 lines
1.9 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.onEvent('onResize', this.onResize.bind(this));
  30. },
  31. charSelect: function() {
  32. client.request({
  33. module: 'cons',
  34. method: 'unzone'
  35. });
  36. renderer.clean();
  37. objects.onRezone();
  38. renderer.buildTitleScreen();
  39. events.emit('onShowCharacterSelect');
  40. $('[class^="ui"]:not(.ui-container)').each(function(i, el) {
  41. var ui = $(el).data('ui');
  42. if ((ui) && (ui.destroy))
  43. ui.destroy();
  44. });
  45. factory.build('characters', {});
  46. },
  47. toggleScreen: function() {
  48. this.el.find('.btnScreen').html(renderer.toggleScreen());
  49. },
  50. onResize: function() {
  51. var isFullscreen = (window.innerHeight == screen.height);
  52. if (isFullscreen)
  53. this.el.find('.btnScreen').html('Fullscreen');
  54. else
  55. this.el.find('.btnScreen').html('Windowed');
  56. },
  57. toggle: function() {
  58. this.onResize();
  59. this.shown = !this.el.is(':visible');
  60. if (this.shown) {
  61. this.show();
  62. events.emit('onShowOverlay', this.el);
  63. }
  64. else {
  65. this.hide();
  66. events.emit('onHideOverlay', this.el);
  67. }
  68. },
  69. logOut: function() {
  70. window.location = window.location;
  71. },
  72. onKeyDown: function(key) {
  73. if (key == 'esc')
  74. this.toggle();
  75. }
  76. }
  77. });