not really known
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.

54 lines
1.4 KiB

  1. var app = null;
  2. var l10n;
  3. var preferences;
  4. var play;
  5. var sound;
  6. var mouse = {};
  7. define(["sugar-web/activity/activity"], function (activity) {
  8. // Manipulate the DOM only when it is ready.
  9. requirejs(['domReady!',"settings"], function (doc, settings) {
  10. // Initialize the activity.
  11. activity.setup();
  12. // Save mouse position
  13. document.onmousemove = function(e) { mouse.position = {x: e.pageX, y: e.pageY}; }
  14. preferences = settings;
  15. preferences.load(function() {
  16. l10n = preferences.l10n;
  17. // Wait for locale load
  18. var localized_received = function() {
  19. // Init activity
  20. if (app == null) {
  21. // Force language
  22. if (preferences.l10n.language.code != preferences.language) {
  23. preferences.l10n.language.code = preferences.language;
  24. return;
  25. }
  26. // Create sound component
  27. sound = new TankOp.Audio();
  28. sound.renderInto(document.getElementById("audio"));
  29. // Launch main screen
  30. app = new TankOp.App({activity: activity});
  31. app.load();
  32. app.renderInto(document.getElementById("board"));
  33. // Stop sound at end of game to sanitize media environment, specifically on Android
  34. document.getElementById("stop-button").addEventListener('click', function (event) {
  35. sound.pause();
  36. });
  37. } else {
  38. // Just change locale
  39. app.setLocale();
  40. }
  41. };
  42. window.addEventListener('localized', localized_received, false);
  43. });
  44. });
  45. });