Enables moving around the map while an addThang is selected

This commit is contained in:
Jayant Jain 2014-06-12 01:50:24 +05:30
parent d5d20377a2
commit ed95206868

View file

@ -186,6 +186,7 @@ module.exports = class ThangsTabView extends View
onStageMouseUp: (e) ->
if @addThangSprite
@surface.camera.lock()
# If we click on the background, we need to add @addThangSprite, but not if onSpriteMouseUp will fire.
@backgroundAddClickTimeout = _.defer => @onExtantThangSelected {}
$('#contextmenu').hide()
@ -202,6 +203,7 @@ module.exports = class ThangsTabView extends View
onSpriteMouseUp: (e) ->
clearTimeout @backgroundAddClickTimeout
@surface.camera.unlock()
if e.originalEvent.nativeEvent.button == 2 and @selectedExtantThang
@onSpriteContextMenu e
clearInterval(@movementInterval) if @movementInterval?
@ -276,7 +278,6 @@ module.exports = class ThangsTabView extends View
@surface.spriteBoss.removeSprite @addThangSprite if @addThangSprite
@addThangType = type
if @addThangType
@surface.camera.lock()
thang = @createAddThang()
@addThangSprite = @surface.spriteBoss.addThangToSprites thang, @surface.spriteBoss.spriteLayers["Floating"]
@addThangSprite.notOfThisWorld = true
@ -285,7 +286,6 @@ module.exports = class ThangsTabView extends View
pos ?= x: Math.round(@world.width / 2), y: Math.round(@world.height / 2)
@adjustThangPos @addThangSprite, thang, pos
else
@surface.camera.unlock()
@addThangSprite = null
createEssentialComponents: ->