mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-04 17:19:47 -04:00
More memory fixes.
This commit is contained in:
parent
b904e1f939
commit
2a19da5ba2
26 changed files with 48 additions and 29 deletions
app
lib/surface
views
editor
article
components
level
thang
kinds
play/level
play_view.coffee
|
@ -260,3 +260,7 @@ module.exports = class Camera extends CocoClass
|
|||
@locked = true
|
||||
unlock: ->
|
||||
@locked = false
|
||||
|
||||
destroy: ->
|
||||
super()
|
||||
@onTweenEnd = null
|
|
@ -81,6 +81,7 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
destroy: ->
|
||||
super()
|
||||
@dead = true
|
||||
@camera?.destroy()
|
||||
createjs.Ticker.removeEventListener("tick", @tick)
|
||||
createjs.Sound.stop()
|
||||
layer.destroy() for layer in @layers
|
||||
|
@ -324,6 +325,7 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
@stage = new createjs.Stage(@canvas[0])
|
||||
canvasWidth = parseInt(@canvas.attr('width'), 10)
|
||||
canvasHeight = parseInt(@canvas.attr('height'), 10)
|
||||
@camera?.destroy()
|
||||
@camera = new Camera canvasWidth, canvasHeight
|
||||
@layers.push @surfaceLayer = new Layer name: "Surface", layerPriority: 0, transform: Layer.TRANSFORM_SURFACE, camera: @camera
|
||||
@layers.push @surfaceTextLayer = new Layer name: "Surface Text", layerPriority: 1, transform: Layer.TRANSFORM_SURFACE_TEXT, camera: @camera
|
||||
|
|
|
@ -52,7 +52,7 @@ module.exports = class ArticleEditView extends View
|
|||
b.find('#insert').html(m)
|
||||
b.find('#title').text(@treema.data.name)
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
context.article = @article
|
||||
context
|
||||
|
|
|
@ -20,7 +20,7 @@ module.exports = class ComponentConfigView extends CocoView
|
|||
@editing = options.editing
|
||||
@callback = options.callback
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
context.component = @component
|
||||
context.configProperties = []
|
||||
|
|
|
@ -16,7 +16,7 @@ module.exports = class LevelComponentEditView extends View
|
|||
@levelComponent = @supermodel.getModelByOriginalAndMajorVersion LevelComponent, options.original, options.majorVersion or 0
|
||||
console.log "Couldn't get levelComponent for", options, "from", @supermodel.models unless @levelComponent
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
context.editTitle = "#{@levelComponent.get('system')}.#{@levelComponent.get('name')}"
|
||||
context
|
||||
|
|
|
@ -60,7 +60,7 @@ module.exports = class EditorLevelView extends View
|
|||
initWorld: ->
|
||||
@world = new World @level.name
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
context.level = @level
|
||||
context
|
||||
|
|
|
@ -17,7 +17,7 @@ module.exports = class LevelForkView extends View
|
|||
super options
|
||||
@level = options.level
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
context.level = @level
|
||||
context
|
||||
|
|
|
@ -17,7 +17,7 @@ module.exports = class LevelSaveView extends SaveVersionModal
|
|||
super options
|
||||
@level = options.level
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
context.level = @level
|
||||
context.levelNeedsSave = @level.hasLocalChanges()
|
||||
|
|
|
@ -16,7 +16,7 @@ module.exports = class LevelSystemEditView extends View
|
|||
@levelSystem = @supermodel.getModelByOriginalAndMajorVersion LevelSystem, options.original, options.majorVersion or 0
|
||||
console.log "Couldn't get levelSystem for", options, "from", @supermodel.models unless @levelSystem
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
context.editTitle = "#{@levelSystem.get('name')}"
|
||||
context
|
||||
|
|
|
@ -28,7 +28,7 @@ module.exports = class LevelThangEditView extends View
|
|||
@level = options.level
|
||||
@oldID = @thangData.id
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
context.thang = @thangData
|
||||
context
|
||||
|
|
|
@ -72,7 +72,7 @@ module.exports = class ThangsTabView extends View
|
|||
@render() # do it again but without the loading screen
|
||||
@onLevelLoaded level: @level if @level
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
thangTypes = (thangType.attributes for thangType in @supermodel.getModels(ThangType))
|
||||
thangTypes = _.uniq thangTypes, false, 'original'
|
||||
|
|
|
@ -52,7 +52,7 @@ module.exports = class ThangTypeEditView extends View
|
|||
@files.fetch()
|
||||
@render()
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
context.thangType = @thangType
|
||||
context.animations = @getAnimationNames()
|
||||
|
@ -97,6 +97,7 @@ module.exports = class ThangTypeEditView extends View
|
|||
@stage = new createjs.Stage(canvas[0])
|
||||
canvasWidth = parseInt(canvas.attr('width'), 10)
|
||||
canvasHeight = parseInt(canvas.attr('height'), 10)
|
||||
@camera?.destroy()
|
||||
@camera = new Camera canvasWidth, canvasHeight
|
||||
|
||||
@torsoDot = @makeDot('blue')
|
||||
|
@ -371,3 +372,7 @@ module.exports = class ThangTypeEditView extends View
|
|||
@grid.alpha = 1.0
|
||||
@showAnimation()
|
||||
@showingSelectedNode = false
|
||||
|
||||
destroy: ->
|
||||
super()
|
||||
@camera?.destroy()
|
|
@ -16,7 +16,7 @@ module.exports = class ModalView extends CocoView
|
|||
@modalWidthPercent = options.modalWidthPercent if options.modalWidthPercent
|
||||
super options
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
context.closeButton = @closeButton
|
||||
context
|
||||
|
|
|
@ -34,7 +34,7 @@ module.exports = class SuperVersionsView extends View
|
|||
@startsLoading = false
|
||||
@render()
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
context.page = @page
|
||||
context.dataList = (m.attributes for m in @collection.models) if @collection
|
||||
|
|
|
@ -26,7 +26,7 @@ module.exports = class HUDView extends View
|
|||
events:
|
||||
'click': -> Backbone.Mediator.publish 'focus-editor'
|
||||
|
||||
afterRender: =>
|
||||
afterRender: ->
|
||||
super()
|
||||
@$el.addClass 'no-selection'
|
||||
|
||||
|
@ -335,3 +335,6 @@ module.exports = class HUDView extends View
|
|||
destroy: ->
|
||||
super()
|
||||
@stage?.stopTalking()
|
||||
@addMoreMessage = null
|
||||
@animateEnterButton = null
|
||||
clearInterval(@messageInterval) if @messageInterval
|
||||
|
|
|
@ -18,14 +18,14 @@ module.exports = class LevelChatView extends View
|
|||
constructor: (options) ->
|
||||
@levelID = options.levelID
|
||||
@session = options.session
|
||||
@session.on 'change:multiplayer', @updateMultiplayerVisibility
|
||||
@session.on 'change:multiplayer', @updateMultiplayerVisibility, @
|
||||
@sessionID = options.sessionID
|
||||
@bus = LevelBus.get(@levelID, @sessionID)
|
||||
super()
|
||||
@regularlyClearOldMessages()
|
||||
@playNoise = _.debounce(@playNoise, 100)
|
||||
|
||||
updateMultiplayerVisibility: =>
|
||||
updateMultiplayerVisibility: ->
|
||||
return unless @$el?
|
||||
if @session.get('multiplayer')
|
||||
@$el.removeClass('hide')
|
||||
|
@ -47,7 +47,7 @@ module.exports = class LevelChatView extends View
|
|||
if new Date().getTime() - added > 60 * 1000
|
||||
row.fadeOut(1000, -> $(this).remove())
|
||||
|
||||
onNewMessage: (e) =>
|
||||
onNewMessage: (e) ->
|
||||
@$el.removeClass('hide') unless e.message.system
|
||||
@addOne(e.message)
|
||||
@trimClosedPanel()
|
||||
|
@ -99,7 +99,7 @@ module.exports = class LevelChatView extends View
|
|||
break if rows.length - i <= limit
|
||||
row.remove()
|
||||
|
||||
onChatKeydown: (e) =>
|
||||
onChatKeydown: (e) ->
|
||||
if key.isPressed('enter')
|
||||
message = _.string.strip($(e.target).val())
|
||||
return false unless message
|
||||
|
@ -107,7 +107,7 @@ module.exports = class LevelChatView extends View
|
|||
$(e.target).val('')
|
||||
return false
|
||||
|
||||
onIconClick: =>
|
||||
onIconClick: ->
|
||||
openPanel = $('.open-chat-area', @$el)
|
||||
closedPanel = $('.closed-chat-area', @$el)
|
||||
@open = not @open
|
||||
|
@ -130,6 +130,8 @@ module.exports = class LevelChatView extends View
|
|||
openPanel.scrollTop = openPanel.scrollHeight or 1000000
|
||||
|
||||
destroy: ->
|
||||
console.log('DESTROY CHAT', @levelID)
|
||||
super()
|
||||
key.deleteScope('level')
|
||||
@session.off 'change:multiplayer', @updateMultiplayerVisibility, @
|
||||
clearInterval @clearOldMessagesInterval if @clearOldMessagesInterval
|
||||
@clearOldMessages = null
|
|
@ -15,7 +15,7 @@ module.exports = class ThangAvatarView extends View
|
|||
@thang = options.thang
|
||||
@includeName = options.includeName
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
context = super context
|
||||
context.thang = @thang
|
||||
thangs = @supermodel.getModels(ThangType)
|
||||
|
|
|
@ -19,7 +19,7 @@ module.exports = class CastButtonView extends View
|
|||
@castShortcut = "⇧↩"
|
||||
@castShortcutVerbose = "Shift+Enter"
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
context = super context
|
||||
context.castShortcutVerbose = @castShortcutVerbose
|
||||
context
|
||||
|
|
|
@ -15,7 +15,7 @@ module.exports = class ProblemAlertView extends View
|
|||
super options
|
||||
@problem = options.problem
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
context = super context
|
||||
context.message = @problem.aetherProblem.message.replace("\n", "<br>")
|
||||
context.hint = @problem.aetherProblem.hint?.replace("\n", "<br>")
|
||||
|
|
|
@ -13,7 +13,7 @@ module.exports = class SpellListEntryThangsView extends View
|
|||
@spell = options.spell
|
||||
@avatars = []
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
context = super context
|
||||
context.thangs = @thangs
|
||||
context.spell = @spell
|
||||
|
|
|
@ -27,7 +27,7 @@ module.exports = class SpellListEntryView extends View
|
|||
@spell = options.spell
|
||||
@showTopDivider = options.showTopDivider
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
context = super context
|
||||
context.spell = @spell
|
||||
context.parameters = (@spell.parameters or []).join ', '
|
||||
|
@ -68,7 +68,7 @@ module.exports = class SpellListEntryView extends View
|
|||
return unless @controlsEnabled and _.size(@spell.thangs) > 1
|
||||
@hideThangsTimeout = _.delay @hideThangs, 100
|
||||
|
||||
showThangs: =>
|
||||
showThangs: ->
|
||||
clearTimeout @hideThangsTimeout if @hideThangsTimeout
|
||||
return if @thangsView
|
||||
@thangsView = new SpellListEntryThangsView thangs: (spellThang.thang for thangID, spellThang of @spell.thangs), thang: @getPrimarySpellThang().thang, spell: @spell, supermodel: @supermodel
|
||||
|
@ -105,3 +105,4 @@ module.exports = class SpellListEntryView extends View
|
|||
destroy: ->
|
||||
super()
|
||||
@avatar?.destroy()
|
||||
@hideThangs = null
|
||||
|
|
|
@ -19,7 +19,7 @@ module.exports = class SpellListTabEntryView extends SpellListEntryView
|
|||
constructor: (options) ->
|
||||
super options
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
context = super context
|
||||
context
|
||||
|
||||
|
|
|
@ -90,4 +90,5 @@ module.exports = class SpellListView extends View
|
|||
|
||||
destroy: ->
|
||||
super()
|
||||
entry.destroy() for entry in @entries
|
||||
entry.destroy() for entry in @entries
|
||||
@sortScoreForSpell = null
|
|
@ -34,7 +34,7 @@ module.exports = class ThangListEntryView extends View
|
|||
@reasonsToBeDisabled = {}
|
||||
@sortSpells()
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
context = super context
|
||||
context.thang = @thang
|
||||
context.spell = @spells
|
||||
|
|
|
@ -84,4 +84,5 @@ module.exports = class ThangListView extends View
|
|||
destroy: ->
|
||||
super()
|
||||
entry.destroy() for entry in @entries
|
||||
@sortScoreForThang = null
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ module.exports = class PlayView extends View
|
|||
id: "play-view"
|
||||
template: template
|
||||
|
||||
getRenderData: (context={}) =>
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
context.home = true
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue