Merge pull request #565 from jayant1992/master

Bugfix for play, usability improvement for editor.
This commit is contained in:
Nick Winter 2014-03-15 15:32:17 -07:00
commit 4e14ff3b11
3 changed files with 15 additions and 6 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

@ -120,11 +120,20 @@ module.exports = class WizardSprite extends IndieSprite
@shoveOtherWizards(true) if @targetSprite
@targetSprite = if isSprite then newTarget else null
@targetPos = targetPos
@targetPos = @boundWizard targetPos
@beginMoveTween(duration, isLinear)
@shoveOtherWizards()
Backbone.Mediator.publish('self-wizard:target-changed', {sender:@}) if @isSelf
boundWizard: (target) ->
# Passed an {x, y} in world coordinates, returns {x, y} within world bounds
return target unless @options.camera.bounds
@bounds = @options.camera.bounds
surfaceTarget = @options.camera.worldToSurface target
x = Math.min(Math.max(surfaceTarget.x, @bounds.x), @bounds.x + @bounds.width)
y = Math.min(Math.max(surfaceTarget.y, @bounds.y), @bounds.y + @bounds.height)
return @options.camera.surfaceToWorld {x: x, y: y}
getPosFromTarget: (target) ->
"""
Could be null, a vector, or sprite object. Get the position from any of these.

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