mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-16 00:19:50 -05:00
Change how goals are expanded/collapsed at beginnings of levels
This commit is contained in:
parent
ebc081d105
commit
65890130bb
2 changed files with 17 additions and 3 deletions
|
@ -268,6 +268,7 @@ module.exports = class SpectateLevelView extends RootView
|
|||
|
||||
onNextGamePressed: (e) ->
|
||||
@fetchRandomSessionPair (err, data) =>
|
||||
return if @destroyed
|
||||
if err? then return console.log "There was an error fetching the random session pair: #{data}"
|
||||
@sessionOne = data[0]._id
|
||||
@sessionTwo = data[1]._id
|
||||
|
|
|
@ -12,12 +12,12 @@ module.exports = class LevelGoalsView extends CocoView
|
|||
template: template
|
||||
className: 'secret expanded'
|
||||
playbackEnded: false
|
||||
mouseEntered: false
|
||||
|
||||
subscriptions:
|
||||
'goal-manager:new-goal-states': 'onNewGoalStates'
|
||||
'tome:cast-spells': 'onTomeCast'
|
||||
'level:set-letterbox': 'onSetLetterbox'
|
||||
'level:set-playing': 'onSetPlaying'
|
||||
'surface:playback-restarted': 'onSurfacePlaybackRestarted'
|
||||
'surface:playback-ended': 'onSurfacePlaybackEnded'
|
||||
|
||||
|
@ -84,6 +84,13 @@ module.exports = class LevelGoalsView extends CocoView
|
|||
@$el.find('.goal-status').addClass('secret')
|
||||
@$el.find('.goal-status.running').removeClass('secret')
|
||||
|
||||
onSetPlaying: (e) ->
|
||||
return unless e.playing
|
||||
# Automatically hide it while we replay
|
||||
@mouseEntered = false
|
||||
@expanded = true
|
||||
@updatePlacement()
|
||||
|
||||
onSurfacePlaybackRestarted: ->
|
||||
@playbackEnded = false
|
||||
@$el.removeClass 'brighter'
|
||||
|
@ -105,11 +112,17 @@ module.exports = class LevelGoalsView extends CocoView
|
|||
@normalHeight = @$el.outerHeight()
|
||||
|
||||
updatePlacement: ->
|
||||
expand = @playbackEnded or @mouseEntered
|
||||
# Expand it if it's at the end. Mousing over reverses this.
|
||||
expand = @playbackEnded isnt @mouseEntered
|
||||
return if expand is @expanded
|
||||
@updateHeight()
|
||||
sound = if expand then 'goals-expand' else 'goals-collapse'
|
||||
top = if expand then -5 else 41 - (@normalHeight ? @$el.outerHeight())
|
||||
if expand
|
||||
top = -5
|
||||
else
|
||||
height = @normalHeight
|
||||
height = @$el.outerHeight() if not height or @playbackEnded
|
||||
top = 41 - height
|
||||
@$el.css 'top', top
|
||||
if @soundTimeout
|
||||
# Don't play the sound we were going to play after all; the transition has reversed.
|
||||
|
|
Loading…
Reference in a new issue