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