mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Showing goals on level loading view.
This commit is contained in:
parent
0d495ba36e
commit
949f4594af
9 changed files with 54 additions and 10 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'}
|
||||
|
||||
|
|
|
@ -46,18 +46,34 @@
|
|||
top: 0px
|
||||
opacity: 0.6
|
||||
width: 96%
|
||||
height: 40px
|
||||
margin: 10px auto 0
|
||||
|
||||
.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%
|
||||
|
|
|
@ -43,4 +43,8 @@
|
|||
|
||||
.errors
|
||||
|
||||
button.start-level-button.btn.btn-lg.btn-success.secret(data-i18n="play_level.loading_start") Start Level
|
||||
.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.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
|
||||
|
||||
onLevelStarted: (e) ->
|
||||
go = => @loadingView?.unveil()
|
||||
go = =>
|
||||
@loadingView?.startUnveiling()
|
||||
@loadingView?.unveil()
|
||||
_.delay go, 1000
|
||||
|
||||
onLoadingViewUnveiled: (e) ->
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue