mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-24 21:13:35 -04:00
More memory fixes.
This commit is contained in:
parent
1b0c3fb236
commit
b904e1f939
7 changed files with 23 additions and 26 deletions
app
lib
views
|
@ -103,7 +103,7 @@ module.exports = class God
|
|||
window.BOX2D_ENABLED = true
|
||||
@lastSerializedWorldFrames = serialized.frames
|
||||
|
||||
finishBeholdingWorld: (newWorld) =>
|
||||
finishBeholdingWorld: (newWorld) ->
|
||||
newWorld.findFirstChangedFrame @world
|
||||
@world = newWorld
|
||||
errorCount = (t for t in @world.thangs when t.errorsOut).length
|
||||
|
|
|
@ -182,7 +182,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
|||
|
||||
# STARTING NOTES
|
||||
|
||||
run: =>
|
||||
run: ->
|
||||
# catch all for analyzing the current state and doing whatever needs to happen next
|
||||
return if @scriptInProgress
|
||||
@skipAhead()
|
||||
|
|
|
@ -92,6 +92,10 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
@stage.removeEventListener 'stagemousemove', @onMouseMove
|
||||
@stage.removeEventListener 'stagemousedown', @onMouseDown
|
||||
@stage.removeAllEventListeners()
|
||||
@playScrubbedSounds = null
|
||||
@onMouseMove = null
|
||||
@onMouseDown = null
|
||||
@tick = null
|
||||
|
||||
setWorld: (@world) ->
|
||||
@worldLoaded = true
|
||||
|
|
|
@ -11,7 +11,7 @@ makeScopeName = -> "view-scope-#{classCount++}"
|
|||
module.exports = class CocoView extends Backbone.View
|
||||
startsLoading: false
|
||||
cache: true # signals to the router to keep this view around
|
||||
template: => ''
|
||||
template: -> ''
|
||||
|
||||
events:
|
||||
'click a': 'toggleModal'
|
||||
|
@ -41,6 +41,7 @@ module.exports = class CocoView extends Backbone.View
|
|||
@stopListeningToShortcuts()
|
||||
@undelegateEvents() # removes both events and subs
|
||||
view.destroy() for id, view of @subviews
|
||||
@modalClosed = null
|
||||
|
||||
afterInsert: ->
|
||||
|
||||
|
@ -60,7 +61,7 @@ module.exports = class CocoView extends Backbone.View
|
|||
|
||||
# View Rendering
|
||||
|
||||
render: =>
|
||||
render: ->
|
||||
return @ unless me
|
||||
super()
|
||||
return @template if _.isString(@template)
|
||||
|
@ -70,7 +71,7 @@ module.exports = class CocoView extends Backbone.View
|
|||
@$el.i18n()
|
||||
@
|
||||
|
||||
getRenderData: (context) =>
|
||||
getRenderData: (context) ->
|
||||
context ?= {}
|
||||
context.isProduction = document.location.href.search(/codecombat.com/) isnt -1
|
||||
context.me = me
|
||||
|
@ -81,7 +82,6 @@ module.exports = class CocoView extends Backbone.View
|
|||
context
|
||||
|
||||
afterRender: ->
|
||||
@registerModalsWithin()
|
||||
|
||||
# Modals
|
||||
|
||||
|
@ -95,12 +95,6 @@ module.exports = class CocoView extends Backbone.View
|
|||
view = application.router.getView(target, '_modal') # could set up a system for loading cached modals, if told to
|
||||
@openModalView(view)
|
||||
|
||||
registerModalsWithin: (e...) ->
|
||||
# TODO: Get rid of this part
|
||||
for modal in $('.modal', @$el)
|
||||
# console.warn 'Registered modal to get rid of...', modal
|
||||
$(modal).on('show.bs.modal', @clearModals)
|
||||
|
||||
openModalView: (modalView) ->
|
||||
return if @waitingModal # can only have one waiting at once
|
||||
if visibleModal
|
||||
|
@ -112,11 +106,11 @@ module.exports = class CocoView extends Backbone.View
|
|||
modalView.afterInsert()
|
||||
visibleModal = modalView
|
||||
modalOptions = {show: true, backdrop: if modalView.closesOnClickOutside then true else 'static'}
|
||||
$('#modal-wrapper .modal').modal(modalOptions).on('hidden.bs.modal', => @modalClosed())
|
||||
$('#modal-wrapper .modal').modal(modalOptions).on('hidden.bs.modal', @modalClosed)
|
||||
window.currentModal = modalView
|
||||
@getRootView().stopListeningToShortcuts(true)
|
||||
|
||||
modalClosed: =>
|
||||
modalClosed: =>
|
||||
visibleModal.willDisappear() if visibleModal
|
||||
visibleModal.destroy()
|
||||
visibleModal = null
|
||||
|
@ -128,12 +122,6 @@ module.exports = class CocoView extends Backbone.View
|
|||
@getRootView().listenToShortcuts(true)
|
||||
Backbone.Mediator.publish 'modal-closed'
|
||||
|
||||
clearModals: =>
|
||||
if visibleModal
|
||||
visibleModal.$el.addClass('hide')
|
||||
waitingModal = null
|
||||
@modalClosed()
|
||||
|
||||
# Loading RootViews
|
||||
|
||||
showLoading: ($el=@$el) ->
|
||||
|
|
|
@ -45,7 +45,7 @@ module.exports = class ControlBarView extends View
|
|||
text += " (#{numPlayers})" if numPlayers > 1
|
||||
$('#multiplayer-button', @$el).text(text)
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
super context
|
||||
context.worldName = @worldName
|
||||
context.multiplayerEnabled = @session.get('multiplayer')
|
||||
|
|
|
@ -43,7 +43,7 @@ module.exports = class PlaybackView extends View
|
|||
super(arguments...)
|
||||
me.on('change:music', @updateMusicButton, @)
|
||||
|
||||
afterRender: =>
|
||||
afterRender: ->
|
||||
super()
|
||||
@hookUpScrubber()
|
||||
@updateMusicButton()
|
||||
|
@ -62,7 +62,7 @@ module.exports = class PlaybackView extends View
|
|||
onWindowResize: (s...) =>
|
||||
@barWidth = $('.progress', @$el).width()
|
||||
|
||||
onNewWorld: (e) =>
|
||||
onNewWorld: (e) ->
|
||||
pct = parseInt(100 * e.world.totalFrames / e.world.maxTotalFrames) + '%'
|
||||
@barWidth = $('.progress', @$el).css('width', pct).removeClass('hide').width()
|
||||
|
||||
|
@ -79,7 +79,7 @@ module.exports = class PlaybackView extends View
|
|||
onEditWizardSettings: ->
|
||||
Backbone.Mediator.publish 'edit-wizard-settings'
|
||||
|
||||
onDisableControls: (e) =>
|
||||
onDisableControls: (e) ->
|
||||
if not e.controls or 'playback' in e.controls
|
||||
@disabled = true
|
||||
$('button', @$el).addClass('disabled')
|
||||
|
@ -91,7 +91,7 @@ module.exports = class PlaybackView extends View
|
|||
@hoverDisabled = true
|
||||
$('#volume-button', @$el).removeClass('disabled')
|
||||
|
||||
onEnableControls: (e) =>
|
||||
onEnableControls: (e) ->
|
||||
if not e.controls or 'playback' in e.controls
|
||||
@disabled = false
|
||||
$('button', @$el).removeClass('disabled')
|
||||
|
@ -102,7 +102,7 @@ module.exports = class PlaybackView extends View
|
|||
if not e.controls or 'playback-hover' in e.controls
|
||||
@hoverDisabled = false
|
||||
|
||||
onSetPlaying: (e) =>
|
||||
onSetPlaying: (e) ->
|
||||
@playing = (e ? {}).playing ? true
|
||||
button = @$el.find '#play-button'
|
||||
ended = button.hasClass 'ended'
|
||||
|
@ -241,3 +241,7 @@ module.exports = class PlaybackView extends View
|
|||
super()
|
||||
me.off('change:music', @updateMusicButton, @)
|
||||
$(window).off('resize', @onWindowResize)
|
||||
@onWindowResize = null
|
||||
@onProgressMouseOver = null
|
||||
@onProgressMouseLeave = null
|
||||
@onProgressMouseMove = null
|
||||
|
|
|
@ -385,6 +385,7 @@ module.exports = class PlayLevelView extends View
|
|||
@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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue