Modals now stop the level from starting until they close.
This commit is contained in:
parent
7c734d6bc9
commit
df196cc531
3 changed files with 43 additions and 30 deletions
app
|
@ -93,6 +93,11 @@ module.exports = class LoadingScreen extends CocoClass
|
||||||
@text.text = "BUILDING" if @progress is 1
|
@text.text = "BUILDING" if @progress is 1
|
||||||
@progressBar.scaleX = @progress
|
@progressBar.scaleX = @progress
|
||||||
@stage.update()
|
@stage.update()
|
||||||
|
|
||||||
|
showReady: ->
|
||||||
|
@text.text = 'READY'
|
||||||
|
@text.regX = @text.getMeasuredWidth() / 2
|
||||||
|
@stage.update()
|
||||||
|
|
||||||
destroy: ->
|
destroy: ->
|
||||||
@stage.canvas = null
|
@stage.canvas = null
|
||||||
|
|
|
@ -117,6 +117,7 @@ module.exports = class CocoView extends Backbone.View
|
||||||
visibleModal.willDisappear() if visibleModal
|
visibleModal.willDisappear() if visibleModal
|
||||||
visibleModal.destroy()
|
visibleModal.destroy()
|
||||||
visibleModal = null
|
visibleModal = null
|
||||||
|
window.currentModal = null
|
||||||
#$('#modal-wrapper .modal').off 'hidden.bs.modal', @modalClosed
|
#$('#modal-wrapper .modal').off 'hidden.bs.modal', @modalClosed
|
||||||
if waitingModal
|
if waitingModal
|
||||||
wm = waitingModal
|
wm = waitingModal
|
||||||
|
|
|
@ -126,34 +126,14 @@ module.exports = class PlayLevelView extends View
|
||||||
|
|
||||||
onLevelLoaderLoaded: =>
|
onLevelLoaderLoaded: =>
|
||||||
# Save latest level played in local storage
|
# Save latest level played in local storage
|
||||||
if localStorage?
|
if window.currentModal and not window.currentModal.destroyed
|
||||||
localStorage["lastLevel"] = @levelID
|
@loadingScreen.showReady()
|
||||||
|
return Backbone.Mediator.subscribeOnce 'modal-closed', @onLevelLoaderLoaded, @
|
||||||
@session = @levelLoader.session
|
|
||||||
@world = @levelLoader.world
|
localStorage["lastLevel"] = @levelID if localStorage?
|
||||||
@level = @levelLoader.level
|
@grabLevelLoaderData()
|
||||||
team = @getQueryVariable("team") ? @world.teamForPlayer(0)
|
team = @getQueryVariable("team") ? @world.teamForPlayer(0)
|
||||||
|
@loadOpponentTeam(team)
|
||||||
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
|
|
||||||
@loadingScreen.destroy()
|
@loadingScreen.destroy()
|
||||||
@god.level = @level.serialize @supermodel
|
@god.level = @level.serialize @supermodel
|
||||||
@god.worldClassMap = @world.classMap
|
@god.worldClassMap = @world.classMap
|
||||||
|
@ -161,17 +141,44 @@ module.exports = class PlayLevelView extends View
|
||||||
@initSurface()
|
@initSurface()
|
||||||
@initGoalManager()
|
@initGoalManager()
|
||||||
@initScriptManager()
|
@initScriptManager()
|
||||||
@insertSubviews ladderGame: otherSession?
|
@insertSubviews ladderGame: @otherSession?
|
||||||
@initVolume()
|
@initVolume()
|
||||||
@session.on 'change:multiplayer', @onMultiplayerChanged, @
|
@session.on 'change:multiplayer', @onMultiplayerChanged, @
|
||||||
@originalSessionState = _.cloneDeep(@session.get('state'))
|
@originalSessionState = _.cloneDeep(@session.get('state'))
|
||||||
@register()
|
@register()
|
||||||
@controlBar.setBus(@bus)
|
@controlBar.setBus(@bus)
|
||||||
@surface.showLevel()
|
@surface.showLevel()
|
||||||
if otherSession
|
if @otherSession
|
||||||
# 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')
|
@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: =>
|
onSupermodelLoadedOne: =>
|
||||||
@modelsLoaded ?= 0
|
@modelsLoaded ?= 0
|
||||||
@modelsLoaded += 1
|
@modelsLoaded += 1
|
||||||
|
|
Reference in a new issue