Merge branch 'migrateBBevents' of https://github.com/Shrihari/codecombat into Shrihari-migrateBBevents

This commit is contained in:
Scott Erickson 2014-03-24 10:38:57 -07:00
commit f55cef5ced
33 changed files with 82 additions and 96 deletions

View file

@ -32,7 +32,7 @@ module.exports = class LevelBus extends Bus
@fireScriptsRef = @fireRef?.child('scripts')
setSession: (@session) ->
@session.on 'change:multiplayer', @onMultiplayerChanged, @
@listenTo(@session, 'change:multiplayer', @onMultiplayerChanged)
onPoint: ->
return true unless @session?.get('multiplayer')
@ -226,5 +226,4 @@ module.exports = class LevelBus extends Bus
tempSession.save(patch, {patch: true})
destroy: ->
@session.off 'change:multiplayer', @onMultiplayerChanged, @
super()

View file

@ -60,13 +60,13 @@ module.exports = class LevelLoader extends CocoClass
# Unless you specify cache:false, sometimes the browser will use a cached session
# and players will 'lose' code
@session.fetch({cache:false})
@session.once 'sync', @onSessionLoaded, @
@listenToOnce(@session, 'sync', @onSessionLoaded)
if @opponentSessionID
@opponentSession = new LevelSession()
@opponentSession.url = "/db/level_session/#{@opponentSessionID}"
@opponentSession.fetch()
@opponentSession.once 'sync', @onSessionLoaded, @
@listenToOnce(@opponentSession, 'sync', @onSessionLoaded)
sessionsLoaded: ->
return true if @headless
@ -82,8 +82,8 @@ module.exports = class LevelLoader extends CocoClass
# Supermodel (Level) Loading
loadLevelModels: ->
@supermodel.on 'loaded-one', @onSupermodelLoadedOne, @
@supermodel.once 'error', @onSupermodelError, @
@listenTo(@supermodel, 'loaded-one', @onSupermodelLoadedOne)
@listenToOnce(@supermodel, 'error', @onSupermodelError)
@level = @supermodel.getModel(Level, @levelID) or new Level _id: @levelID
levelID = @levelID
headless = @headless
@ -235,7 +235,6 @@ module.exports = class LevelLoader extends CocoClass
@trigger 'loaded-all' if @progress() is 1
destroy: ->
@supermodel.off 'loaded-one', @onSupermodelLoadedOne
@world = null # don't hold onto garbage
@update = null
super()

View file

@ -58,7 +58,7 @@ init = ->
storage.save(CURRENT_USER_KEY, me.attributes)
me.loadGravatarProfile() if me.get('email')
me.on('sync', userSynced)
Backbone.listenTo(me, 'sync', userSynced)
userSynced = (user) ->
Backbone.Mediator.publish('me:synced', {me:user})

View file

@ -48,9 +48,9 @@ module.exports = class Simulator extends CocoClass
@god = new God maxWorkerPoolSize: 1, maxAngels: 1 # Start loading worker.
@levelLoader = new LevelLoader supermodel: @supermodel, levelID: @task.getLevelName(), sessionID: @task.getFirstSessionID(), headless: true
@levelLoader.once 'loaded-all', @simulateGame
@listenToOnce(@levelLoader, 'loaded-all', @simulateGame)
simulateGame: =>
simulateGame: ->
return if @destroyed
@trigger 'statusUpdate', 'All resources loaded, simulating!', @task.getSessions()
@assignWorldAndLevelFromLevelLoaderAndDestroyIt()

View file

@ -75,7 +75,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
else
@stillLoading = true
@thangType.fetch()
@thangType.once 'sync', @setupSprite, @
@listenToOnce(@thangType, 'sync', @setupSprite)
setupSprite: ->
@stillLoading = false

View file

@ -22,7 +22,6 @@ module.exports = class Mark extends CocoClass
destroy: ->
@mark?.parent?.removeChild @mark
@markSprite?.destroy()
@thangType?.off 'sync', @onLoadedThangType, @
@sprite = null
super()
@ -177,7 +176,7 @@ module.exports = class Mark extends CocoClass
return @loadThangType() if not thangType
@thangType = thangType
return @thangType.once 'sync', @onLoadedThangType, @ if not @thangType.loaded
return @listenToOnce(@thangType, 'sync', @onLoadedThangType) if not @thangType.loaded
CocoSprite = require './CocoSprite'
markSprite = new CocoSprite @thangType, @thangType.spriteOptions
markSprite.queueAction 'idle'
@ -188,7 +187,7 @@ module.exports = class Mark extends CocoClass
name = @thangType
@thangType = new ThangType()
@thangType.url = -> "/db/thang.type/#{name}"
@thangType.once 'sync', @onLoadedThangType, @
@listenToOnce(@thangType, 'sync', @onLoadedThangType)
@thangType.fetch()
markThangTypes[name] = @thangType
window.mtt = markThangTypes

View file

@ -9,8 +9,8 @@ class SuperModel
@mustPopulate = model
model.saveBackups = @shouldSaveBackups(model)
model.fetch() unless model.loaded or model.loading
model.once('sync', @modelLoaded, @) unless model.loaded
model.once('error', @modelErrored, @) unless model.loaded
@listenToOnce(model, 'sync', @modelLoaded) unless model.loaded
@listenToOnce(model, 'error', @modelErrored) unless model.loaded
url = model.url()
@models[url] = model unless @models[url]?
@modelLoaded(model) if model.loaded
@ -40,7 +40,7 @@ class SuperModel
continue if @models[refURL]
@models[refURL] = ref
ref.fetch()
ref.once 'sync', @modelLoaded, @
@listenToOnce(ref, 'sync', @modelLoaded)
@trigger 'loaded-one', model: model
@trigger 'loaded-all' if @finished()

View file

@ -20,7 +20,7 @@ class LiveEditingMarkup extends TreemaNode.nodeMap.ace
buildValueForEditing: (valEl) ->
super(valEl)
@editor.on 'change', @onEditorChange
@editor.on('change', @onEditorChange)
@addImageUpload(valEl)
addImageUpload: (valEl) ->
@ -203,7 +203,7 @@ class CoffeeTreema extends TreemaNode.nodeMap.ace
buildValueForEditing: (valEl) ->
super(valEl)
@editor.on 'change', @onEditorChange
@editor.on('change', @onEditorChange)
valEl
onEditorChange: =>
@ -297,9 +297,9 @@ class LatestVersionReferenceNode extends TreemaNode
@collection.url = "#{@url}?term=#{''}&project=true"
@collection.fetch()
@collection.on 'sync', @searchCallback
@listenTo(@collection, 'sync', @searchCallback)
searchCallback: =>
searchCallback: ->
container = @getSearchResultsEl().detach().empty()
first = true
for model in @collection.models

View file

@ -11,14 +11,14 @@ module.exports = class ProfileView extends View
super options
@user = User.getByID(@userID)
@loading = false if 'gravatarProfile' of @user
@user.on('change', @userChanged)
@user.on('error', @userError)
@listenTo(@user, 'change', @userChanged)
@listenTo(@user, 'error', @userError)
userChanged: (user) =>
userChanged: (user) ->
@loading = false if 'gravatarProfile' of user
@render()
userError: (user) =>
userError: (user) ->
@loading = false
@render()

View file

@ -19,11 +19,11 @@ module.exports = class SettingsView extends View
@save = _.debounce(@save, 200)
super options
return unless me
me.on('change', @refreshPicturePane) # depends on gravatar load
me.on('invalid', (errors) -> forms.applyErrorsToForm(@$el, me.validationError))
@listenTo(me, 'change', @refreshPicturePane) # depends on gravatar load
@listenTo(me, 'invalid', (errors) -> forms.applyErrorsToForm(@$el, me.validationError))
window.f = @getSubscriptions
refreshPicturePane: =>
refreshPicturePane: ->
h = $(@template(@getRenderData()))
newPane = $('#picture-pane', h)
oldPane = $('#picture-pane')
@ -46,7 +46,7 @@ module.exports = class SettingsView extends View
@chooseTab(location.hash.replace('#',''))
WizardSettingsView = new WizardSettingsView()
WizardSettingsView.on 'change', @save, @
@listenTo(WizardSettingsView, 'change', @save)
@insertSubView WizardSettingsView
chooseTab: (category) ->
@ -81,7 +81,7 @@ module.exports = class SettingsView extends View
$('#email-pane input[type="checkbox"]', @$el).prop('checked', not Boolean(subs.length))
@save()
save: =>
save: ->
forms.clearFormAlerts(@$el)
@grabData()
res = me.validate()

View file

@ -16,7 +16,7 @@ module.exports = class CLAsView extends View
})
@clas = new CLACollection()
@clas.fetch()
@clas.on 'sync', @onCLAsLoaded, @
@listenTo(@clas, 'sync', @onCLAsLoaded)
onCLAsLoaded: ->
@startsLoading = false

View file

@ -18,7 +18,7 @@ module.exports = class LevelSessionsView extends View
getLevelSessions: ->
@sessions = new LevelSessionCollection
@sessions.fetch()
@sessions.on('all', @render)
@listenTo(@sessions, 'all', @render)
getRenderData: =>
c = super()

View file

@ -36,7 +36,7 @@ module.exports = class UsersView extends View
})
@users = new UserCollection()
@users.fetch()
@users.on('all', @render)
@listenTo(@users, 'all', @render)
getRenderData: =>
c = super()

View file

@ -20,15 +20,15 @@ module.exports = class ArticleEditView extends View
@article = new Article(_id: @articleID)
@article.saveBackups = true
@article.fetch()
@article.once('sync', @onArticleSync)
@article.on('schema-loaded', @buildTreema)
@listenToOnce(@article, 'sync', @onArticleSync)
@listenTo(@article, 'schema-loaded', @buildTreema)
@pushChangesToPreview = _.throttle(@pushChangesToPreview, 500)
onArticleSync: =>
onArticleSync: ->
@article.loaded = true
@buildTreema()
buildTreema: =>
buildTreema: ->
return if @treema? or (not @article.loaded) or (not Article.hasSchema())
unless @article.attributes.body
@article.set('body', '')

View file

@ -24,7 +24,7 @@ module.exports = class ThangComponentEditView extends CocoView
if not @componentCollection
@componentCollection = @supermodel.getCollection new ComponentsCollection()
unless @componentCollection.loaded
@componentCollection.once 'sync', @onComponentsSync
@listenToOnce(@componentCollection, 'sync', @onComponentsSync)
@componentCollection.fetch()
super() # do afterRender at the end
@ -35,7 +35,7 @@ module.exports = class ThangComponentEditView extends CocoView
@buildExtantComponentTreema()
@buildAddComponentTreema()
onComponentsSync: =>
onComponentsSync: ->
return if @destroyed
@supermodel.addCollection @componentCollection
@render()

View file

@ -23,10 +23,10 @@ module.exports = class AddThangsView extends View
super options
@world = options.world
@thangTypes = @supermodel.getCollection new ThangTypeSearchCollection() # should load depended-on Components, too
@thangTypes.once 'sync', @onThangTypesLoaded
@listenToOnce(@thangTypes, 'sync', @onThangTypesLoaded)
@thangTypes.fetch()
onThangTypesLoaded: =>
onThangTypesLoaded: ->
return if @destroyed
@render() # do it again but without the loading screen

View file

@ -79,7 +79,7 @@ module.exports = class LevelComponentEditView extends View
session.setTabSize 2
session.setNewLineMode = 'unix'
session.setUseSoftTabs true
@editor.on 'change', @onEditorChange
@editor.on('change', @onEditorChange)
onEditorChange: =>
@levelComponent.set 'code', @editor.getValue()

View file

@ -28,7 +28,7 @@ module.exports = class EditorLevelView extends View
constructor: (options, @levelID) ->
super options
@supermodel.once 'loaded-all', @onAllLoaded
@listenToOnce(@supermodel, 'loaded-all', @onAllLoaded)
# load only the level itself and the one it points to, but no others
# TODO: this is duplicated in views/play/level_view.coffee; need cleaner method
@ -42,18 +42,18 @@ module.exports = class EditorLevelView extends View
model.constructor.className in ['Level', 'LevelComponent', 'LevelSystem']
@level = new Level _id: @levelID
@level.once 'sync', @onLevelLoaded
@listenToOnce(@level, 'sync', @onLevelLoaded)
@supermodel.populateModel @level
showLoading: ($el) ->
$el ?= @$el.find('.tab-content')
super($el)
onLevelLoaded: =>
onLevelLoaded: ->
@files = new DocumentFiles(@level)
@files.fetch()
onAllLoaded: =>
onAllLoaded: ->
@level.unset('nextLevel') if _.isString(@level.get('nextLevel'))
@initWorld()
@startsLoading = false

View file

@ -24,7 +24,7 @@ module.exports = class LevelSystemAddView extends View
if not @systems
@systems = @supermodel.getCollection new LevelSystemSearchCollection()
unless @systems.loaded
@systems.once 'sync', @onSystemsSync
@listenToOnce(@systems, 'sync', @onSystemsSync)
@systems.fetch()
super() # do afterRender at the end
@ -44,7 +44,7 @@ module.exports = class LevelSystemAddView extends View
for system in systems
ul.append $(availableSystemTemplate(system: system))
onSystemsSync: =>
onSystemsSync: ->
@supermodel.addCollection @systems
@render()

View file

@ -77,7 +77,7 @@ module.exports = class LevelSystemEditView extends View
session.setTabSize 2
session.setNewLineMode = 'unix'
session.setUseSoftTabs true
@editor.on 'change', @onEditorChange
@editor.on('change', @onEditorChange)
onEditorChange: =>
@levelSystem.set 'code', @editor.getValue()

View file

@ -34,11 +34,11 @@ module.exports = class SystemsTabView extends View
do (url) -> ls.url = -> url
continue if @supermodel.getModelByURL ls.url
ls.fetch()
ls.on 'sync', @onSystemLoaded
@listenTo(ls, 'sync', @onSystemLoaded)
++@toLoad
@onDefaultSystemsLoaded() unless @toLoad
onSystemLoaded: (ls) =>
onSystemLoaded: (ls) ->
@supermodel.addModel ls
--@toLoad
@onDefaultSystemsLoaded() unless @toLoad

View file

@ -59,15 +59,15 @@ module.exports = class ThangsTabView extends View
super options
@world = options.world
@thangTypes = @supermodel.getCollection new ThangTypeSearchCollection() # should load depended-on Components, too
@thangTypes.once 'sync', @onThangTypesLoaded
@listenToOnce(@thangTypes, 'sync', @onThangTypesLoaded)
@thangTypes.fetch()
# just loading all Components for now: https://github.com/codecombat/codecombat/issues/405
@componentCollection = @supermodel.getCollection new ComponentsCollection()
@componentCollection.once 'sync', @onComponentsLoaded
@listenToOnce(@componentCollection, 'sync', @onComponentsLoaded)
@componentCollection.fetch()
onThangTypesLoaded: =>
onThangTypesLoaded: ->
return if @destroyed
@supermodel.addCollection @thangTypes
@supermodel.populateModel model for model in @thangTypes.models
@ -75,7 +75,7 @@ module.exports = class ThangsTabView extends View
@render() # do it again but without the loading screen
@onLevelLoaded level: @level if @level and not @startsLoading
onComponentsLoaded: =>
onComponentsLoaded: ->
return if @destroyed
@supermodel.addCollection @componentCollection
@startsLoading = not @thangTypes.loaded

View file

@ -64,7 +64,7 @@ module.exports = class ThangTypeHomeView extends View
@collection = new SearchCollection(@modelURL, @model, term)
@collection.term = term # needed?
@collection.on('sync', @onSearchChange)
@listenTo(@collection, 'sync', @onSearchChange)
@showLoading(@$el.find('.results'))
@updateHash(term)
@ -79,7 +79,7 @@ module.exports = class ThangTypeHomeView extends View
return false unless @collection
return term is @collection.term
onSearchChange: =>
onSearchChange: ->
@hideLoading()
documents = @collection.models
table = $(@tableTemplate(documents:documents))

View file

@ -23,14 +23,14 @@ module.exports = class VersionsModalView extends ModalView
super options
@view = new model(_id: @ID)
@view.fetch()
@view.once('sync', @onViewSync)
@listenToOnce(@view, 'sync', @onViewSync)
onViewSync: =>
onViewSync: ->
@collection = new VersionsViewCollection(@url, @view.attributes.original, @model)
@collection.fetch()
@collection.on('sync', @onVersionFetched)
@listenTo(@collection, 'sync', @onVersionFetched)
onVersionFetched: =>
onVersionFetched: ->
@startsLoading = false
@render()

View file

@ -30,7 +30,7 @@ module.exports = class LadderPlayModal extends View
loadChallengers: ->
@challengersCollection = new ChallengersData(@level, @team, @otherTeam, @session)
@challengersCollection.on 'sync', @loadNames, @
@listenTo(@challengersCollection, 'sync', @loadNames)
# PART 2: Loading the names of the other users
@ -53,7 +53,7 @@ module.exports = class LadderPlayModal extends View
# PART 3: Make sure wizard is loaded
checkWizardLoaded: ->
if @wizardType.loaded then @finishRendering() else @wizardType.once 'sync', @finishRendering, @
if @wizardType.loaded then @finishRendering() else @listenToOnce(@wizardType, 'sync', @finishRendering)
# PART 4: Render
@ -158,13 +158,13 @@ class ChallengersData
score = @session?.get('totalScore') or 25
@easyPlayer = new LeaderboardCollection(@level, {order:1, scoreOffset: score - 5, limit: 1, team: @otherTeam})
@easyPlayer.fetch()
@easyPlayer.once 'sync', @challengerLoaded, @
@listenToOnce(@easyPlayer, 'sync', @challengerLoaded)
@mediumPlayer = new LeaderboardCollection(@level, {order:1, scoreOffset: score, limit: 1, team: @otherTeam})
@mediumPlayer.fetch()
@mediumPlayer.once 'sync', @challengerLoaded, @
@listenToOnce(@mediumPlayer, 'sync', @challengerLoaded)
@hardPlayer = new LeaderboardCollection(@level, {order:-1, scoreOffset: score + 5, limit: 1, team: @otherTeam})
@hardPlayer.fetch()
@hardPlayer.once 'sync', @challengerLoaded, @
@listenToOnce(@hardPlayer, 'sync', @challengerLoaded)
challengerLoaded: ->
if @allLoaded()

View file

@ -42,7 +42,7 @@ module.exports = class LadderView extends RootView
@sessions = new LevelSessionsCollection(levelID)
p2 = @sessions.fetch({})
@simulator = new Simulator()
@simulator.on 'statusUpdate', @updateSimulationStatus, @
@listenTo(@simulator, 'statusUpdate', @updateSimulationStatus)
@teams = []
$.when(p1, p2).then @onLoaded
@ -104,7 +104,7 @@ module.exports = class LadderView extends RootView
@simulator.fetchAndSimulateTask()
updateSimulationStatus: (simulationStatus, sessions)->
updateSimulationStatus: (simulationStatus, sessions) ->
@simulationStatus = simulationStatus
try
if sessions?

View file

@ -18,7 +18,7 @@ module.exports = class LevelChatView extends View
constructor: (options) ->
@levelID = options.levelID
@session = options.session
@session.on 'change:multiplayer', @updateMultiplayerVisibility, @
@listenTo(@session, 'change:multiplayer', @updateMultiplayerVisibility)
@sessionID = options.sessionID
@bus = LevelBus.get(@levelID, @sessionID)
super()
@ -122,7 +122,6 @@ module.exports = class LevelChatView extends View
destroy: ->
key.deleteScope('level')
@session.off 'change:multiplayer', @updateMultiplayerVisibility, @
clearInterval @clearOldMessagesInterval if @clearOldMessagesInterval
@clearOldMessages = null
super()

View file

@ -15,7 +15,7 @@ module.exports = class MultiplayerModal extends View
super(options)
@session = options.session
@level = options.level
@session.on 'change:multiplayer', @updateLinkSection, @
@listenTo(@session, 'change:multiplayer', @updateLinkSection)
@playableTeams = options.playableTeams
@ladderGame = options.ladderGame
console.log 'ladder game is', @ladderGame
@ -51,5 +51,4 @@ module.exports = class MultiplayerModal extends View
@session.set('multiplayer', multiplayer)
destroy: ->
@session.off 'change:multiplayer', @updateLinkSection, @
super()

View file

@ -43,7 +43,7 @@ module.exports = class PlaybackView extends View
constructor: ->
super(arguments...)
me.on('change:music', @updateMusicButton, @)
@listenTo(me, 'change:music', @updateMusicButton)
afterRender: ->
super()
@ -223,7 +223,5 @@ module.exports = class PlaybackView extends View
$(document.activeElement).blur()
destroy: ->
me.off('change:music', @updateMusicButton, @)
$(window).off('resize', @onWindowResize)
@onWindowResize = null
super()

View file

@ -6,6 +6,10 @@ module.exports = class CastButtonView extends View
id: 'cast-button-view'
template: template
events:
'click .cast-button': 'onCastButtonClick'
'click .autocast-delays a': 'onCastOptionsClick'
subscriptions:
'tome:spell-changed': "onSpellChanged"
'tome:cast-spells': 'onCastSpells'
@ -30,8 +34,6 @@ module.exports = class CastButtonView extends View
@castButton = $('.cast-button', @$el)
@castButtonGroup = $('.cast-button-group', @$el)
@castOptions = $('.autocast-delays', @$el)
@castButton.on 'click', @onCastButtonClick
@castOptions.find('a').on 'click', @onCastOptionsClick
delay = me.get('autocastDelay')
delay ?= 5000
if @levelID in ['brawlwood', 'brawlwood-tutorial', 'dungeon-arena', 'dungeon-arena-tutorial']

View file

@ -43,7 +43,7 @@ module.exports = class SpellView extends View
constructor: (options) ->
super options
@session = options.session
@session.on 'change:multiplayer', @onMultiplayerChanged, @
@listenTo(@session, 'change:multiplayer', @onMultiplayerChanged)
@spell = options.spell
@problems = {}
@writable = false unless me.team in @spell.permissions.readwrite # TODO: make this do anything
@ -582,7 +582,6 @@ module.exports = class SpellView extends View
@aceSession = null
@debugView?.destroy()
@spell = null
@session.off 'change:multiplayer', @onMultiplayerChanged, @
for fat in ['notifySpellChanged', 'notifyEditingEnded', 'notifyEditingBegan', 'onFirepadLoaded', 'onLoaded', 'toggleBackground', 'setRecompileNeeded', 'onCursorActivity', 'highlightCurrentLine', 'updateAether', 'onCodeChangeMetaHandler', 'recompileIfNeeded', 'currentAutocastHandler']
@[fat] = null
super()

View file

@ -83,7 +83,7 @@ module.exports = class PlayLevelView extends View
@sessionID = @getQueryVariable 'session'
$(window).on('resize', @onWindowResize)
@supermodel.once 'error', @onLevelLoadError
@listenToOnce(@supermodel, 'error', @onLevelLoadError)
@saveScreenshot = _.throttle @saveScreenshot, 30000
if @isEditorPreview
@ -95,7 +95,7 @@ module.exports = class PlayLevelView extends View
else
@load()
onLevelLoadError: (e) =>
onLevelLoadError: (e) ->
application.router.navigate "/play?not_found=#{@levelID}", {trigger: true}
setLevel: (@level, @supermodel) ->
@ -108,8 +108,8 @@ module.exports = class PlayLevelView extends View
load: ->
@levelLoader = new LevelLoader supermodel: @supermodel, levelID: @levelID, sessionID: @sessionID, opponentSessionID: @getQueryVariable('opponent'), team: @getQueryVariable("team")
@levelLoader.once 'loaded-all', @onLevelLoaderLoaded, @
@levelLoader.on 'progress', @onLevelLoaderProgressChanged, @
@listenToOnce(@levelLoader, 'loaded-all', @onLevelLoaderLoaded)
@listenTo(@levelLoader, 'progress', @onLevelLoaderProgressChanged)
@god = new God()
getRenderData: ->
@ -168,7 +168,7 @@ module.exports = class PlayLevelView extends View
@initScriptManager()
@insertSubviews ladderGame: (@level.get('type') is "ladder")
@initVolume()
@session.on 'change:multiplayer', @onMultiplayerChanged, @
@listenTo(@session, 'change:multiplayer', @onMultiplayerChanged)
@originalSessionState = $.extend(true, {}, @session.get('state'))
@register()
@controlBar.setBus(@bus)
@ -462,20 +462,16 @@ module.exports = class PlayLevelView extends View
AudioPlayer.preloadSoundReference sound
destroy: ->
@supermodel?.off 'error', @onLevelLoadError
@levelLoader?.off 'loaded-all', @onLevelLoaderLoaded
@levelLoader?.destroy()
@surface?.destroy()
@god?.destroy()
@goalManager?.destroy()
@scriptManager?.destroy()
$(window).off('resize', @onWindowResize)
delete window.world # not sure where this is set, but this is one way to clean it up
clearInterval(@pointerInterval)
@bus?.destroy()
#@instance.save() unless @instance.loading
console.profileEnd?() if PROFILE_ME
@session?.off 'change:multiplayer', @onMultiplayerChanged, @
@onLevelLoadError = null
@onLevelLoaderLoaded = null
@onSupermodelLoadedOne = null

View file

@ -68,8 +68,8 @@ module.exports = class SpectateLevelView extends View
constructor: (options, @levelID) ->
console.profile?() if PROFILE_ME
super options
$(window).on('resize', @onWindowResize)
@supermodel.once 'error', @onLevelLoadError
@listenTo($(window), 'resize', @onWindowResize)
@listenToOnce(@supermodel, 'error', @onLevelLoadError)
@sessionOne = @getQueryVariable 'session-one'
@sessionTwo = @getQueryVariable 'session-two'
@ -105,8 +105,8 @@ module.exports = class SpectateLevelView extends View
opponentSessionID: @sessionTwo
spectateMode: true
team: @getQueryVariable("team")
@levelLoader.once 'loaded-all', @onLevelLoaderLoaded, @
@levelLoader.on 'progress', @onLevelLoaderProgressChanged, @
@listenToOnce(@levelLoader, 'loaded-all', @onLevelLoaderLoaded)
@listenTo(@levelLoader, 'progress', @onLevelLoaderProgressChanged)
@god = new God maxWorkerPoolSize: 1, maxAngels: 1
getRenderData: ->
@ -467,18 +467,14 @@ module.exports = class SpectateLevelView extends View
cb(null, $.parseJSON(jqxhr.responseText))
destroy: ()->
@supermodel?.off 'error', @onLevelLoadError
@levelLoader?.off 'loaded-all', @onLevelLoaderLoaded
@levelLoader?.destroy()
@surface?.destroy()
@god?.destroy()
@goalManager?.destroy()
@scriptManager?.destroy()
$(window).off('resize', @onWindowResize)
delete window.world # not sure where this is set, but this is one way to clean it up
clearInterval(@pointerInterval)
console.profileEnd?() if PROFILE_ME
@session?.off 'change:multiplayer', @onMultiplayerChanged, @
@onLevelLoadError = null
@onLevelLoaderLoaded = null
@onSupermodelLoadedOne = null