Modals now stop the level from starting until they close.

This commit is contained in:
Scott Erickson 2014-02-27 16:44:11 -08:00
parent 7c734d6bc9
commit df196cc531
3 changed files with 43 additions and 30 deletions

View file

@ -93,6 +93,11 @@ module.exports = class LoadingScreen extends CocoClass
@text.text = "BUILDING" if @progress is 1
@progressBar.scaleX = @progress
@stage.update()
showReady: ->
@text.text = 'READY'
@text.regX = @text.getMeasuredWidth() / 2
@stage.update()
destroy: ->
@stage.canvas = null

View file

@ -117,6 +117,7 @@ module.exports = class CocoView extends Backbone.View
visibleModal.willDisappear() if visibleModal
visibleModal.destroy()
visibleModal = null
window.currentModal = null
#$('#modal-wrapper .modal').off 'hidden.bs.modal', @modalClosed
if waitingModal
wm = waitingModal

View file

@ -126,34 +126,14 @@ module.exports = class PlayLevelView extends View
onLevelLoaderLoaded: =>
# Save latest level played in local storage
if localStorage?
localStorage["lastLevel"] = @levelID
@session = @levelLoader.session
@world = @levelLoader.world
@level = @levelLoader.level
if window.currentModal and not window.currentModal.destroyed
@loadingScreen.showReady()
return Backbone.Mediator.subscribeOnce 'modal-closed', @onLevelLoaderLoaded, @
localStorage["lastLevel"] = @levelID if localStorage?
@grabLevelLoaderData()
team = @getQueryVariable("team") ? @world.teamForPlayer(0)
opponentSpells = []
for spellTeam, spells of @session.get('teamSpells') ? otherSession?.get('teamSpells') ? {}
continue if spellTeam is team or not team
opponentSpells = opponentSpells.concat spells
otherSession = @levelLoader.opponentSession
opponentCode = otherSession?.get('submittedCode') or {}
myCode = @session.get('code') or {}
for spell in opponentSpells
[thang, spell] = spell.split '/'
c = opponentCode[thang]?[spell]
myCode[thang] ?= {}
if c then myCode[thang][spell] = c else delete myCode[thang][spell]
@session.set('code', myCode)
if @session.get('multiplayer') and otherSession?
# For now, ladderGame will disallow multiplayer, because session code combining doesn't play nice yet.
@session.set 'multiplayer', false
@levelLoader.destroy()
@levelLoader = null
@loadOpponentTeam(team)
@loadingScreen.destroy()
@god.level = @level.serialize @supermodel
@god.worldClassMap = @world.classMap
@ -161,17 +141,44 @@ module.exports = class PlayLevelView extends View
@initSurface()
@initGoalManager()
@initScriptManager()
@insertSubviews ladderGame: otherSession?
@insertSubviews ladderGame: @otherSession?
@initVolume()
@session.on 'change:multiplayer', @onMultiplayerChanged, @
@originalSessionState = _.cloneDeep(@session.get('state'))
@register()
@controlBar.setBus(@bus)
@surface.showLevel()
if otherSession
if @otherSession
# 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')
@surface.createOpponentWizard id: @otherSession.get('creator'), name: @otherSession.get('creatorName'), team: @otherSession.get('team')
grabLevelLoaderData: ->
@session = @levelLoader.session
@world = @levelLoader.world
@level = @levelLoader.level
@otherSession = @levelLoader.opponentSession
@levelLoader.destroy()
@levelLoader = null
loadOpponentTeam: (myTeam) ->
opponentSpells = []
for spellTeam, spells of @session.get('teamSpells') ? @otherSession?.get('teamSpells') ? {}
continue if spellTeam is myTeam or not myTeam
opponentSpells = opponentSpells.concat spells
opponentCode = @otherSession?.get('submittedCode') or {}
myCode = @session.get('code') or {}
for spell in opponentSpells
[thang, spell] = spell.split '/'
c = opponentCode[thang]?[spell]
myCode[thang] ?= {}
if c then myCode[thang][spell] = c else delete myCode[thang][spell]
@session.set('code', myCode)
if @session.get('multiplayer') and @otherSession?
# For now, ladderGame will disallow multiplayer, because session code combining doesn't play nice yet.
@session.set 'multiplayer', false
onSupermodelLoadedOne: =>
@modelsLoaded ?= 0
@modelsLoaded += 1