Showing goals on level loading view.
This commit is contained in:
parent
0d495ba36e
commit
949f4594af
9 changed files with 54 additions and 10 deletions
app
lib
schemas/subscriptions
styles/play/level
templates/play/level
views/play
|
@ -56,6 +56,7 @@ module.exports = class LevelLoader extends CocoClass
|
||||||
onLevelLoaded: ->
|
onLevelLoaded: ->
|
||||||
@loadSession()
|
@loadSession()
|
||||||
@populateLevel()
|
@populateLevel()
|
||||||
|
Backbone.Mediator.publish 'level:loaded', level: @level, team: @team ? 'humans'
|
||||||
|
|
||||||
# Session Loading
|
# Session Loading
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
||||||
|
|
||||||
subscriptions:
|
subscriptions:
|
||||||
'script:end-current-script': 'onEndNoteGroup'
|
'script:end-current-script': 'onEndNoteGroup'
|
||||||
'level:started': -> @setWorldLoading(false)
|
'level:loading-view-unveiling': -> @setWorldLoading(false)
|
||||||
'level:restarted': 'onLevelRestarted'
|
'level:restarted': 'onLevelRestarted'
|
||||||
'level:shift-space-pressed': 'onEndNoteGroup'
|
'level:shift-space-pressed': 'onEndNoteGroup'
|
||||||
'level:escape-pressed': 'onEndAll'
|
'level:escape-pressed': 'onEndAll'
|
||||||
|
|
|
@ -34,7 +34,7 @@ module.exports = Surface = class Surface extends CocoClass
|
||||||
currentFrame: 0
|
currentFrame: 0
|
||||||
lastFrame: null
|
lastFrame: null
|
||||||
totalFramesDrawn: 0
|
totalFramesDrawn: 0
|
||||||
playing: true # play vs. pause
|
playing: false # play vs. pause
|
||||||
dead: false # if we kill it for some reason
|
dead: false # if we kill it for some reason
|
||||||
imagesLoaded: false
|
imagesLoaded: false
|
||||||
worldLoaded: false
|
worldLoaded: false
|
||||||
|
|
|
@ -77,6 +77,12 @@ module.exports =
|
||||||
|
|
||||||
'level:next-game-pressed': c.object {}
|
'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']},
|
'level:loading-view-unveiled': c.object {required: ['view']},
|
||||||
view: {type: 'object'}
|
view: {type: 'object'}
|
||||||
|
|
||||||
|
|
|
@ -46,18 +46,34 @@
|
||||||
top: 0px
|
top: 0px
|
||||||
opacity: 0.6
|
opacity: 0.6
|
||||||
width: 96%
|
width: 96%
|
||||||
|
height: 40px
|
||||||
margin: 10px auto 0
|
margin: 10px auto 0
|
||||||
|
|
||||||
.progress-bar
|
.progress
|
||||||
width: 1%
|
height: 100%
|
||||||
transition-duration: 1.2s
|
|
||||||
|
.progress-bar
|
||||||
|
width: 1%
|
||||||
|
height: 100%
|
||||||
|
transition-duration: 1.2s
|
||||||
|
|
||||||
#tip-wrapper
|
#tip-wrapper
|
||||||
position: relative
|
position: relative
|
||||||
z-index: 2
|
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
|
.start-level-button
|
||||||
margin-top: 10px
|
font-size: 40px
|
||||||
|
|
||||||
.left-wing, .right-wing
|
.left-wing, .right-wing
|
||||||
width: 100%
|
width: 100%
|
||||||
|
|
|
@ -42,5 +42,9 @@
|
||||||
span= me.get('name', true)
|
span= me.get('name', true)
|
||||||
|
|
||||||
.errors
|
.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
|
||||||
|
|
|
@ -160,7 +160,9 @@ module.exports = class SpectateLevelView extends RootView
|
||||||
@session.set 'multiplayer', false
|
@session.set 'multiplayer', false
|
||||||
|
|
||||||
onLevelStarted: (e) ->
|
onLevelStarted: (e) ->
|
||||||
go = => @loadingView?.unveil()
|
go = =>
|
||||||
|
@loadingView?.startUnveiling()
|
||||||
|
@loadingView?.unveil()
|
||||||
_.delay go, 1000
|
_.delay go, 1000
|
||||||
|
|
||||||
onLoadingViewUnveiled: (e) ->
|
onLoadingViewUnveiled: (e) ->
|
||||||
|
|
|
@ -6,9 +6,11 @@ module.exports = class LevelLoadingView extends CocoView
|
||||||
template: template
|
template: template
|
||||||
|
|
||||||
events:
|
events:
|
||||||
|
'mousedown .start-level-button': 'startUnveiling' # split into two for animation smoothness
|
||||||
'click .start-level-button': 'onClickStartLevel'
|
'click .start-level-button': 'onClickStartLevel'
|
||||||
|
|
||||||
onLoaded: ->
|
subscriptions:
|
||||||
|
'level:loaded': 'onLevelLoaded'
|
||||||
|
|
||||||
afterRender: ->
|
afterRender: ->
|
||||||
@$el.find('.tip.rare').remove() if _.random(1, 10) < 9
|
@$el.find('.tip.rare').remove() if _.random(1, 10) < 9
|
||||||
|
@ -17,6 +19,13 @@ module.exports = class LevelLoadingView extends CocoView
|
||||||
$(tip).removeClass('to-remove')
|
$(tip).removeClass('to-remove')
|
||||||
@$el.find('.to-remove').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: ->
|
showReady: ->
|
||||||
return if @shownReady
|
return if @shownReady
|
||||||
@shownReady = true
|
@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
|
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'level_loaded', volume: 0.75 # old: loading_ready
|
||||||
@$el.find('.start-level-button').removeClass 'secret'
|
@$el.find('.start-level-button').removeClass 'secret'
|
||||||
|
|
||||||
|
startUnveiling: (e) ->
|
||||||
|
Backbone.Mediator.publish 'level:loading-view-unveiling', {}
|
||||||
|
|
||||||
onClickStartLevel: (e) ->
|
onClickStartLevel: (e) ->
|
||||||
@unveil()
|
@unveil()
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ module.exports = class PlayLevelView extends RootView
|
||||||
'level:edit-wizard-settings': 'showWizardSettingsModal'
|
'level:edit-wizard-settings': 'showWizardSettingsModal'
|
||||||
'level:session-will-save': 'onSessionWillSave'
|
'level:session-will-save': 'onSessionWillSave'
|
||||||
'level:started': 'onLevelStarted'
|
'level:started': 'onLevelStarted'
|
||||||
|
'level:loading-view-unveiling': 'onLoadingViewUnveiling'
|
||||||
'level:loading-view-unveiled': 'onLoadingViewUnveiled'
|
'level:loading-view-unveiled': 'onLoadingViewUnveiled'
|
||||||
'playback:real-time-playback-waiting': 'onRealTimePlaybackWaiting'
|
'playback:real-time-playback-waiting': 'onRealTimePlaybackWaiting'
|
||||||
'playback:real-time-playback-started': 'onRealTimePlaybackStarted'
|
'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
|
# 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')
|
@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) ->
|
onLoadingViewUnveiled: (e) ->
|
||||||
@loadingView.$el.remove()
|
@loadingView.$el.remove()
|
||||||
@removeSubView @loadingView
|
@removeSubView @loadingView
|
||||||
@loadingView = null
|
@loadingView = null
|
||||||
@restoreSessionState()
|
|
||||||
unless @isEditorPreview
|
unless @isEditorPreview
|
||||||
@loadEndTime = new Date()
|
@loadEndTime = new Date()
|
||||||
loadDuration = @loadEndTime - @loadStartTime
|
loadDuration = @loadEndTime - @loadStartTime
|
||||||
|
|
Reference in a new issue