diff options
Diffstat (limited to 'gui.js')
| -rw-r--r-- | gui.js | 34 |
1 files changed, 31 insertions, 3 deletions
@@ -211,6 +211,7 @@ IDE_Morph.prototype.init = function (isAutoFill) { this.serializer = new SnapSerializer(); this.globalVariables = new VariableFrame(); + this.currentSprite = new SpriteMorph(this.globalVariables); this.sprites = new List([this.currentSprite]); this.currentCategory = 'motion'; @@ -240,6 +241,22 @@ IDE_Morph.prototype.init = function (isAutoFill) { this.loadNewProject = false; // flag when starting up translated this.shield = null; + // Snap! YOW + // set initial sprite position after the map has loaded + // The map center is set at the same time as 'geoposition' + // when a position has been acquired. + var myself = this; + if (!window.geoposition) { + window.map.on('load', function () { + myself.currentSprite.gotoXY(window.map.getCenter().lng, + window.map.getCenter().lat); + }); + } else { + // in case init() is called after the map loaded + this.currentSprite.gotoXY(window.map.getCenter().lng, + window.map.getCenter().lat); + } + // initialize inherited properties: IDE_Morph.uber.init.call(this); @@ -1862,8 +1879,7 @@ IDE_Morph.prototype.addNewSprite = function () { sprite.setHue(rnd.call(this, 0, 100)); sprite.setBrightness(rnd.call(this, 50, 100)); sprite.turn(rnd.call(this, 1, 360)); - sprite.setXPosition(rnd.call(this, -220, 220)); - sprite.setYPosition(rnd.call(this, -160, 160)); + sprite.gotoXY(window.map.getCenter().lng, window.map.getCenter().lat); this.sprites.add(sprite); this.corral.addSprite(sprite); @@ -2810,6 +2826,17 @@ IDE_Morph.prototype.newProject = function () { location.hash = ''; } this.globalVariables = new VariableFrame(); + + // recreate all Sprite markers (Snap-YOW) + if (window.map.hasLayer(window.spriteGroup)) { + window.map.removeLayer(window.spriteGroup); + } + window.spriteGroup = L.layerGroup().addTo(window.map); + if (window.map.hasLayer(window.penTrails)) { + window.map.removeLayer(window.penTrails); + } + window.penTrails = L.layerGroup().addTo(window.map); + this.currentSprite = new SpriteMorph(this.globalVariables); this.sprites = new List([this.currentSprite]); StageMorph.prototype.dimensions = new Point(480, 360); @@ -2825,6 +2852,7 @@ IDE_Morph.prototype.newProject = function () { this.createCorral(); this.selectSprite(this.stage.children[0]); this.fixLayout(); + this.droppedText(this.getURL('overpass.xml')); // YOW hack (TODO) }; IDE_Morph.prototype.save = function () { @@ -3607,7 +3635,7 @@ IDE_Morph.prototype.userSetBlocksScale = function () { action; scrpt = new CommandBlockMorph(); - scrpt.color = SpriteMorph.prototype.blockColor.motion; + scrpt.color = SpriteMorph.prototype.blockColor.map; scrpt.setSpec(localize('build')); blck = new CommandBlockMorph(); blck.color = SpriteMorph.prototype.blockColor.sound; |
