mainMenu.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. 'use strict';
  2. var game = Atomic.game;
  3. var view = game.uiView;
  4. var UI = Atomic.UI;
  5. var UIWindow = Atomic.UIWindow;
  6. var window;
  7. function closeWindow() {
  8. if (window)
  9. window.die();
  10. window = null;
  11. }
  12. exports.init = function() {
  13. window = new UIWindow();
  14. window.settings = Atomic.UI.WINDOW_SETTINGS_TITLEBAR;
  15. window.text = "Main Menu";
  16. window.load("UI/mainMenu.ui.txt");
  17. window.resizeToFitContent();
  18. view.addChild(window);
  19. window.center();
  20. window.getWidget("new_game").onClick = function () {
  21. closeWindow();
  22. var node = game.scene.createChild("SpaceGame");
  23. node.createJSComponent("SpaceGame");
  24. }
  25. window.getWidget("about").onClick = function () {
  26. // disable ourselves until ok is clicked on about
  27. window.setState(UI.WIDGET_STATE_DISABLED, true);
  28. var ui = require("./ui");
  29. ui.showAbout(function() {window.setState(UI.WIDGET_STATE_DISABLED, false);});
  30. }
  31. window.getWidget("options").onClick = function () {
  32. // disable ourselves until ok is clicked on about
  33. window.setState(UI.WIDGET_STATE_DISABLED, true);
  34. var ui = require("./ui");
  35. ui.showOptions(function() {window.setState(UI.WIDGET_STATE_DISABLED, false);});
  36. }
  37. window.getWidget("quit").onClick = function () {
  38. game.engine.exit();
  39. }
  40. }
  41. exports.shutdown = function() {
  42. closeWindow();
  43. }