Showing goals on level loading view.

This commit is contained in:
Nick Winter 2014-09-21 15:52:49 -07:00
parent 0d495ba36e
commit 949f4594af
9 changed files with 54 additions and 10 deletions

View file

@ -56,6 +56,7 @@ module.exports = class LevelLoader extends CocoClass
onLevelLoaded: ->
@loadSession()
@populateLevel()
Backbone.Mediator.publish 'level:loaded', level: @level, team: @team ? 'humans'
# Session Loading

View file

@ -28,7 +28,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
subscriptions:
'script:end-current-script': 'onEndNoteGroup'
'level:started': -> @setWorldLoading(false)
'level:loading-view-unveiling': -> @setWorldLoading(false)
'level:restarted': 'onLevelRestarted'
'level:shift-space-pressed': 'onEndNoteGroup'
'level:escape-pressed': 'onEndAll'

View file

@ -34,7 +34,7 @@ module.exports = Surface = class Surface extends CocoClass
currentFrame: 0
lastFrame: null
totalFramesDrawn: 0
playing: true # play vs. pause
playing: false # play vs. pause
dead: false # if we kill it for some reason
imagesLoaded: false
worldLoaded: false

View file

@ -77,6 +77,12 @@ module.exports =
'level:next-game-pressed': c.object {}
'level:loaded': c.object {required: ['level']},
level: {type: 'object'}
team: {type: ['string', 'null', 'undefined']}
'level:loading-view-unveiling': c.object {}
'level:loading-view-unveiled': c.object {required: ['view']},
view: {type: 'object'}

View file

@ -46,18 +46,34 @@
top: 0px
opacity: 0.6
width: 96%
height: 40px
margin: 10px auto 0
.progress-bar
width: 1%
transition-duration: 1.2s
.progress
height: 100%
.progress-bar
width: 1%
height: 100%
transition-duration: 1.2s
#tip-wrapper
position: relative
z-index: 2
top: 10px
.level-loading-goals
margin: 30px auto 10px
width: 400px
.panel-heading
font-size: 24px
.list-group-item
font-size: 20px
.start-level-button
margin-top: 10px
font-size: 40px
.left-wing, .right-wing
width: 100%

View file

@ -42,5 +42,9 @@
span= me.get('name', true)
.errors
.panel.panel-default.level-loading-goals.secret
.panel-heading.header-font(data-i18n="play_level.goals") Goals
ul.list-group
button.start-level-button.btn.btn-lg.btn-success.secret(data-i18n="play_level.loading_start") Start Level
button.start-level-button.btn.btn-lg.btn-success.header-font.secret(data-i18n="play_level.loading_start") Start Level

View file

@ -160,7 +160,9 @@ module.exports = class SpectateLevelView extends RootView
@session.set 'multiplayer', false
onLevelStarted: (e) ->
go = => @loadingView?.unveil()
go = =>
@loadingView?.startUnveiling()
@loadingView?.unveil()
_.delay go, 1000
onLoadingViewUnveiled: (e) ->

View file

@ -6,9 +6,11 @@ module.exports = class LevelLoadingView extends CocoView
template: template
events:
'mousedown .start-level-button': 'startUnveiling' # split into two for animation smoothness
'click .start-level-button': 'onClickStartLevel'
onLoaded: ->
subscriptions:
'level:loaded': 'onLevelLoaded'
afterRender: ->
@$el.find('.tip.rare').remove() if _.random(1, 10) < 9
@ -17,6 +19,13 @@ module.exports = class LevelLoadingView extends CocoView
$(tip).removeClass('to-remove')
@$el.find('.to-remove').remove()
onLevelLoaded: (e) ->
@level = e.level
goalList = @$el.find('.level-loading-goals').removeClass('secret').find('ul')
for goalID, goal of @level.get('goals') when not goal.team or goal.team is e.team
goalList.append $('<li class="list-group-item header-font">' + goal.name + '</li>')
console.log 'got goals', @level.get('goals'), 'team', e.team
showReady: ->
return if @shownReady
@shownReady = true
@ -25,6 +34,9 @@ module.exports = class LevelLoadingView extends CocoView
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'level_loaded', volume: 0.75 # old: loading_ready
@$el.find('.start-level-button').removeClass 'secret'
startUnveiling: (e) ->
Backbone.Mediator.publish 'level:loading-view-unveiling', {}
onClickStartLevel: (e) ->
@unveil()

View file

@ -62,6 +62,7 @@ module.exports = class PlayLevelView extends RootView
'level:edit-wizard-settings': 'showWizardSettingsModal'
'level:session-will-save': 'onSessionWillSave'
'level:started': 'onLevelStarted'
'level:loading-view-unveiling': 'onLoadingViewUnveiling'
'level:loading-view-unveiled': 'onLoadingViewUnveiled'
'playback:real-time-playback-waiting': 'onRealTimePlaybackWaiting'
'playback:real-time-playback-started': 'onRealTimePlaybackStarted'
@ -323,11 +324,13 @@ module.exports = class PlayLevelView extends RootView
# TODO: colorize name and cloud by team, colorize wizard by user's color config
@surface.createOpponentWizard id: @otherSession.get('creator'), name: @otherSession.get('creatorName'), team: @otherSession.get('team'), levelSlug: @level.get('slug'), codeLanguage: @otherSession.get('submittedCodeLanguage')
onLoadingViewUnveiling: (e) ->
@restoreSessionState()
onLoadingViewUnveiled: (e) ->
@loadingView.$el.remove()
@removeSubView @loadingView
@loadingView = null
@restoreSessionState()
unless @isEditorPreview
@loadEndTime = new Date()
loadDuration = @loadEndTime - @loadStartTime