Fixed several bugs with Thang selection and the SpellView and HUD.
This commit is contained in:
parent
485b179f5d
commit
e2d2e96cf5
5 changed files with 20 additions and 12 deletions
app
lib/surface
styles/play/level
views/play/level
|
@ -1,6 +1,6 @@
|
||||||
CocoClass = require 'lib/CocoClass'
|
CocoClass = require 'lib/CocoClass'
|
||||||
|
|
||||||
module.exports = class PlaybackoverScreen extends CocoClass
|
module.exports = class PlaybackOverScreen extends CocoClass
|
||||||
constructor: (options) ->
|
constructor: (options) ->
|
||||||
super()
|
super()
|
||||||
options ?= {}
|
options ?= {}
|
||||||
|
@ -10,7 +10,7 @@ module.exports = class PlaybackoverScreen extends CocoClass
|
||||||
console.error @toString(), "needs a layer." unless @layer
|
console.error @toString(), "needs a layer." unless @layer
|
||||||
@build()
|
@build()
|
||||||
|
|
||||||
toString: -> "<PlaybackoverScreen>"
|
toString: -> "<PlaybackOverScreen>"
|
||||||
|
|
||||||
build: ->
|
build: ->
|
||||||
@dimLayer = new createjs.Container()
|
@dimLayer = new createjs.Container()
|
||||||
|
@ -23,18 +23,16 @@ module.exports = class PlaybackoverScreen extends CocoClass
|
||||||
@layer.addChild @dimLayer
|
@layer.addChild @dimLayer
|
||||||
|
|
||||||
show: ->
|
show: ->
|
||||||
console.log 'show playback over screen', @showing
|
|
||||||
return if @showing
|
return if @showing
|
||||||
@showing = true
|
@showing = true
|
||||||
|
|
||||||
@dimLayer.alpha = 0
|
@dimLayer.alpha = 0
|
||||||
createjs.Tween.removeTweens @dimLayer
|
createjs.Tween.removeTweens @dimLayer
|
||||||
createjs.Tween.get(@dimLayer).to({alpha:1}, 500)
|
createjs.Tween.get(@dimLayer).to({alpha:1}, 500)
|
||||||
|
|
||||||
hide: ->
|
hide: ->
|
||||||
console.log 'hide playback over screen', @showing
|
|
||||||
return unless @showing
|
return unless @showing
|
||||||
@showing = false
|
@showing = false
|
||||||
|
|
||||||
createjs.Tween.removeTweens @dimLayer
|
createjs.Tween.removeTweens @dimLayer
|
||||||
createjs.Tween.get(@dimLayer).to({alpha:0}, 500)
|
createjs.Tween.get(@dimLayer).to({alpha:0}, 500)
|
||||||
|
|
|
@ -151,8 +151,10 @@ module.exports = class SpriteBoss extends CocoClass
|
||||||
|
|
||||||
removeSprite: (sprite) ->
|
removeSprite: (sprite) ->
|
||||||
sprite.displayObject.parent.removeChild sprite.displayObject
|
sprite.displayObject.parent.removeChild sprite.displayObject
|
||||||
|
thang = sprite.thang
|
||||||
delete @sprites[sprite.thang.id]
|
delete @sprites[sprite.thang.id]
|
||||||
sprite.destroy()
|
sprite.destroy()
|
||||||
|
sprite.thang = thang # Keep around so that we know which thang the destroyed thang was for
|
||||||
|
|
||||||
updateSounds: ->
|
updateSounds: ->
|
||||||
sprite.playSounds() for thangID, sprite of @sprites # hmm; doesn't work for sprites which we didn't add yet in adjustSpriteExistence
|
sprite.playSounds() for thangID, sprite of @sprites # hmm; doesn't work for sprites which we didn't add yet in adjustSpriteExistence
|
||||||
|
@ -186,7 +188,6 @@ module.exports = class SpriteBoss extends CocoClass
|
||||||
# mainly for handling selecting thangs from session when the thang is not always in existence
|
# mainly for handling selecting thangs from session when the thang is not always in existence
|
||||||
if @willSelectThang and @sprites[@willSelectThang[0]]
|
if @willSelectThang and @sprites[@willSelectThang[0]]
|
||||||
@selectThang @willSelectThang...
|
@selectThang @willSelectThang...
|
||||||
@willSelectThang = null
|
|
||||||
|
|
||||||
cache: (update=false) ->
|
cache: (update=false) ->
|
||||||
return if @cached and not update
|
return if @cached and not update
|
||||||
|
@ -273,6 +274,8 @@ module.exports = class SpriteBoss extends CocoClass
|
||||||
originalEvent: e
|
originalEvent: e
|
||||||
worldPos: worldPos
|
worldPos: worldPos
|
||||||
|
|
||||||
|
@willSelectThang = null if sprite # Now that we've done a real selection, don't reselect some other Thang later.
|
||||||
|
|
||||||
if alive and not @suppressSelectionSounds
|
if alive and not @suppressSelectionSounds
|
||||||
instance = sprite.playSound 'selected'
|
instance = sprite.playSound 'selected'
|
||||||
if instance?.playState is 'playSucceeded'
|
if instance?.playState is 'playSucceeded'
|
||||||
|
@ -280,12 +283,15 @@ module.exports = class SpriteBoss extends CocoClass
|
||||||
instance.addEventListener 'complete', ->
|
instance.addEventListener 'complete', ->
|
||||||
Backbone.Mediator.publish 'thang-finished-talking', thang: sprite?.thang
|
Backbone.Mediator.publish 'thang-finished-talking', thang: sprite?.thang
|
||||||
|
|
||||||
|
|
||||||
# Marks
|
# Marks
|
||||||
|
|
||||||
updateSelection: ->
|
updateSelection: ->
|
||||||
if @selectedSprite?.thang and (not @selectedSprite.thang.exists or not @world.getThangByID @selectedSprite.thang.id)
|
if @selectedSprite?.thang and (not @selectedSprite.thang.exists or not @world.getThangByID @selectedSprite.thang.id)
|
||||||
@selectSprite null, null, null
|
thangID = @selectedSprite.thang.id
|
||||||
|
@selectedSprite = null # Don't actually trigger deselection, but remove the selected sprite.
|
||||||
@selectionMark?.toggle false
|
@selectionMark?.toggle false
|
||||||
|
@willSelectThang = [thangID, null]
|
||||||
@updateTarget()
|
@updateTarget()
|
||||||
return unless @selectionMark
|
return unless @selectionMark
|
||||||
@selectedSprite = null unless @selectedSprite?.thang
|
@selectedSprite = null unless @selectedSprite?.thang
|
||||||
|
|
|
@ -95,6 +95,9 @@
|
||||||
height: 100px
|
height: 100px
|
||||||
@include user-select(text)
|
@include user-select(text)
|
||||||
|
|
||||||
|
&.nonexistent
|
||||||
|
visibility: hidden
|
||||||
|
|
||||||
.text-prop
|
.text-prop
|
||||||
width: 50%
|
width: 50%
|
||||||
|
|
||||||
|
|
|
@ -238,8 +238,9 @@ module.exports = class HUDView extends View
|
||||||
|
|
||||||
update: ->
|
update: ->
|
||||||
return unless @thang and not @speaker
|
return unless @thang and not @speaker
|
||||||
# Update properties
|
@$el.find('.thang-props-column').toggleClass 'nonexistent', not @thang.exists
|
||||||
@updatePropElement(prop, @thang[prop]) for prop in @thang.hudProperties ? []
|
if @thang.exists
|
||||||
|
@updatePropElement(prop, @thang[prop]) for prop in @thang.hudProperties ? []
|
||||||
# Update action timeline
|
# Update action timeline
|
||||||
@updateActions()
|
@updateActions()
|
||||||
|
|
||||||
|
@ -305,7 +306,7 @@ module.exports = class HUDView extends View
|
||||||
for actionName, action of @thang.actions
|
for actionName, action of @thang.actions
|
||||||
@updateActionElement(actionName, @timespans[actionName], @thang.action is actionName)
|
@updateActionElement(actionName, @timespans[actionName], @thang.action is actionName)
|
||||||
tableContainer = @$el.find('.table-container')
|
tableContainer = @$el.find('.table-container')
|
||||||
timelineWidth = tableContainer.find('.action-timeline').width()
|
timelineWidth = tableContainer.find('tr:not(.secret) .action-timeline').width()
|
||||||
right = (1 - (@timeProgress ? 0)) * timelineWidth
|
right = (1 - (@timeProgress ? 0)) * timelineWidth
|
||||||
arrow = tableContainer.find('.progress-arrow')
|
arrow = tableContainer.find('.progress-arrow')
|
||||||
arrow.css 'right', right - arrow.width() / 2
|
arrow.css 'right', right - arrow.width() / 2
|
||||||
|
|
|
@ -419,7 +419,7 @@ module.exports = class SpellView extends View
|
||||||
@ace.clearSelection()
|
@ace.clearSelection()
|
||||||
|
|
||||||
onFrameChanged: (e) ->
|
onFrameChanged: (e) ->
|
||||||
return unless e.selectedThang?.id is @thang?.id
|
return unless @spellThang and e.selectedThang?.id is @spellThang?.thang.id
|
||||||
@thang = e.selectedThang # update our thang to the current version
|
@thang = e.selectedThang # update our thang to the current version
|
||||||
@highlightCurrentLine()
|
@highlightCurrentLine()
|
||||||
|
|
||||||
|
|
Reference in a new issue