Clicking a thang in the left list automatically pans to the sprite on the editor map

This commit is contained in:
Jayant Jain 2014-03-15 01:57:29 +05:30
parent d5a4b1f5ef
commit 91515b1cea
2 changed files with 5 additions and 5 deletions

View file

@ -256,15 +256,15 @@ module.exports = class SpriteBoss extends CocoClass
return if key.shift #and @options.choosing
@selectSprite e if e.onBackground
selectThang: (thangID, spellName=null) ->
selectThang: (thangID, spellName=null, treemaThangSelected = null) ->
return @willSelectThang = [thangID, spellName] unless @sprites[thangID]
@selectSprite null, @sprites[thangID], spellName
@selectSprite null, @sprites[thangID], spellName, treemaThangSelected
selectSprite: (e, sprite=null, spellName=null) ->
selectSprite: (e, sprite=null, spellName=null, treemaThangSelected = null) ->
return if e and (@disabled or @selectLocked) # Ignore clicks for selection/panning/wizard movement while disabled or select is locked
worldPos = sprite?.thang?.pos
worldPos ?= @camera.canvasToWorld {x: e.originalEvent.rawX, y: e.originalEvent.rawY} if e
if worldPos and (@options.navigateToSelection or not sprite)
if worldPos and (@options.navigateToSelection or not sprite or treemaThangSelected)
@camera.zoomTo(sprite?.displayObject or @camera.worldToSurface(worldPos), @camera.zoom, 1000)
sprite = null if @options.choosing # Don't select sprites while choosing
if sprite isnt @selectedSprite

View file

@ -360,7 +360,7 @@ module.exports = class ThangsTabView extends View
onTreemaThangSelected: (e, selectedTreemas) =>
selectedThangID = _.last(selectedTreemas)?.data.id
if selectedThangID isnt @selectedExtantThang?.id
@surface.spriteBoss.selectThang selectedThangID
@surface.spriteBoss.selectThang selectedThangID, null, true
onTreemaThangDoubleClicked: (e, treema) =>
id = treema?.data?.id