2014-03-14 20:06:08 -04:00
|
|
|
View = require 'views/kinds/CocoView'
|
|
|
|
template = require 'templates/play/level/level_loading'
|
|
|
|
|
|
|
|
module.exports = class LevelLoadingView extends View
|
|
|
|
id: "level-loading-view"
|
|
|
|
template: template
|
|
|
|
|
|
|
|
subscriptions:
|
|
|
|
'level-loader:progress-changed': 'onLevelLoaderProgressChanged'
|
|
|
|
|
|
|
|
onLevelLoaderProgressChanged: (e) ->
|
|
|
|
@progress = e.progress
|
|
|
|
@updateProgressBar()
|
|
|
|
|
|
|
|
updateProgressBar: ->
|
|
|
|
#@text.text = "BUILDING" if @progress is 1
|
|
|
|
@$el.find('.progress-bar').css('width', (100 * @progress) + '%')
|
|
|
|
|
|
|
|
showReady: ->
|
|
|
|
return
|
|
|
|
|
|
|
|
unveil: ->
|
2014-03-14 22:44:19 -04:00
|
|
|
_.delay @reallyUnveil, 1000
|
2014-03-14 20:06:08 -04:00
|
|
|
|
|
|
|
reallyUnveil: =>
|
|
|
|
return if @destroyed
|
|
|
|
loadingDetails = @$el.find('.loading-details')
|
|
|
|
duration = parseFloat loadingDetails.css 'transition-duration'
|
|
|
|
loadingDetails.css 'top', -loadingDetails.outerHeight(true)
|
2014-03-14 22:44:19 -04:00
|
|
|
@$el.find('.left-wing').css left: '-100%', backgroundPosition: 'right -400px top 0'
|
|
|
|
@$el.find('.right-wing').css right: '-100%', backgroundPosition: 'left -400px top 0'
|
2014-03-14 20:06:08 -04:00
|
|
|
_.delay @onUnveilEnded, duration * 1000
|
|
|
|
|
|
|
|
onUnveilEnded: =>
|
|
|
|
return if @destroyed
|
|
|
|
Backbone.Mediator.publish 'onLoadingViewUnveiled', view: @
|
|
|
|
|
|
|
|
getRenderData: (c={}) ->
|
|
|
|
super c
|
|
|
|
c
|