mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-26 05:53:39 -04:00
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'
|
||||
|
||||
module.exports = class PlaybackoverScreen extends CocoClass
|
||||
module.exports = class PlaybackOverScreen extends CocoClass
|
||||
constructor: (options) ->
|
||||
super()
|
||||
options ?= {}
|
||||
|
@ -10,7 +10,7 @@ module.exports = class PlaybackoverScreen extends CocoClass
|
|||
console.error @toString(), "needs a layer." unless @layer
|
||||
@build()
|
||||
|
||||
toString: -> "<PlaybackoverScreen>"
|
||||
toString: -> "<PlaybackOverScreen>"
|
||||
|
||||
build: ->
|
||||
@dimLayer = new createjs.Container()
|
||||
|
@ -23,18 +23,16 @@ module.exports = class PlaybackoverScreen extends CocoClass
|
|||
@layer.addChild @dimLayer
|
||||
|
||||
show: ->
|
||||
console.log 'show playback over screen', @showing
|
||||
return if @showing
|
||||
@showing = true
|
||||
|
||||
|
||||
@dimLayer.alpha = 0
|
||||
createjs.Tween.removeTweens @dimLayer
|
||||
createjs.Tween.get(@dimLayer).to({alpha:1}, 500)
|
||||
|
||||
hide: ->
|
||||
console.log 'hide playback over screen', @showing
|
||||
return unless @showing
|
||||
@showing = false
|
||||
|
||||
|
||||
createjs.Tween.removeTweens @dimLayer
|
||||
createjs.Tween.get(@dimLayer).to({alpha:0}, 500)
|
||||
|
|
|
@ -151,8 +151,10 @@ module.exports = class SpriteBoss extends CocoClass
|
|||
|
||||
removeSprite: (sprite) ->
|
||||
sprite.displayObject.parent.removeChild sprite.displayObject
|
||||
thang = sprite.thang
|
||||
delete @sprites[sprite.thang.id]
|
||||
sprite.destroy()
|
||||
sprite.thang = thang # Keep around so that we know which thang the destroyed thang was for
|
||||
|
||||
updateSounds: ->
|
||||
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
|
||||
if @willSelectThang and @sprites[@willSelectThang[0]]
|
||||
@selectThang @willSelectThang...
|
||||
@willSelectThang = null
|
||||
|
||||
cache: (update=false) ->
|
||||
return if @cached and not update
|
||||
|
@ -273,6 +274,8 @@ module.exports = class SpriteBoss extends CocoClass
|
|||
originalEvent: e
|
||||
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
|
||||
instance = sprite.playSound 'selected'
|
||||
if instance?.playState is 'playSucceeded'
|
||||
|
@ -280,12 +283,15 @@ module.exports = class SpriteBoss extends CocoClass
|
|||
instance.addEventListener 'complete', ->
|
||||
Backbone.Mediator.publish 'thang-finished-talking', thang: sprite?.thang
|
||||
|
||||
|
||||
# Marks
|
||||
|
||||
updateSelection: ->
|
||||
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
|
||||
@willSelectThang = [thangID, null]
|
||||
@updateTarget()
|
||||
return unless @selectionMark
|
||||
@selectedSprite = null unless @selectedSprite?.thang
|
||||
|
|
|
@ -95,6 +95,9 @@
|
|||
height: 100px
|
||||
@include user-select(text)
|
||||
|
||||
&.nonexistent
|
||||
visibility: hidden
|
||||
|
||||
.text-prop
|
||||
width: 50%
|
||||
|
||||
|
|
|
@ -238,8 +238,9 @@ module.exports = class HUDView extends View
|
|||
|
||||
update: ->
|
||||
return unless @thang and not @speaker
|
||||
# Update properties
|
||||
@updatePropElement(prop, @thang[prop]) for prop in @thang.hudProperties ? []
|
||||
@$el.find('.thang-props-column').toggleClass 'nonexistent', not @thang.exists
|
||||
if @thang.exists
|
||||
@updatePropElement(prop, @thang[prop]) for prop in @thang.hudProperties ? []
|
||||
# Update action timeline
|
||||
@updateActions()
|
||||
|
||||
|
@ -305,7 +306,7 @@ module.exports = class HUDView extends View
|
|||
for actionName, action of @thang.actions
|
||||
@updateActionElement(actionName, @timespans[actionName], @thang.action is actionName)
|
||||
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
|
||||
arrow = tableContainer.find('.progress-arrow')
|
||||
arrow.css 'right', right - arrow.width() / 2
|
||||
|
|
|
@ -419,7 +419,7 @@ module.exports = class SpellView extends View
|
|||
@ace.clearSelection()
|
||||
|
||||
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
|
||||
@highlightCurrentLine()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue