mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-28 23:13:59 -04:00
Optimized level serialization a little so that level editing is a bit less painful.
This commit is contained in:
parent
13b066f6aa
commit
b521aee322
2 changed files with 6 additions and 6 deletions
app
|
@ -12,12 +12,12 @@ module.exports = class Level extends CocoModel
|
||||||
o = @denormalize supermodel, session
|
o = @denormalize supermodel, session
|
||||||
|
|
||||||
# Figure out Components
|
# Figure out Components
|
||||||
o.levelComponents = _.cloneDeep (lc.attributes for lc in supermodel.getModels LevelComponent)
|
o.levelComponents = $.extend true, [], (lc.attributes for lc in supermodel.getModels LevelComponent)
|
||||||
@sortThangComponents o.thangs, o.levelComponents, 'Level Thang'
|
@sortThangComponents o.thangs, o.levelComponents, 'Level Thang'
|
||||||
@fillInDefaultComponentConfiguration o.thangs, o.levelComponents
|
@fillInDefaultComponentConfiguration o.thangs, o.levelComponents
|
||||||
|
|
||||||
# Figure out Systems
|
# Figure out Systems
|
||||||
systemModels = _.cloneDeep (ls.attributes for ls in supermodel.getModels LevelSystem)
|
systemModels = $.extend true, [], (ls.attributes for ls in supermodel.getModels LevelSystem)
|
||||||
o.systems = @sortSystems o.systems, systemModels
|
o.systems = @sortSystems o.systems, systemModels
|
||||||
@fillInDefaultSystemConfiguration o.systems
|
@fillInDefaultSystemConfiguration o.systems
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ module.exports = class Level extends CocoModel
|
||||||
system2 = _.find levelSystems, {original: d.original}
|
system2 = _.find levelSystems, {original: d.original}
|
||||||
visit system2
|
visit system2
|
||||||
#console.log 'sorted systems adding', systemModel.name
|
#console.log 'sorted systems adding', systemModel.name
|
||||||
sorted.push {model: systemModel, config: _.cloneDeep system.config}
|
sorted.push {model: systemModel, config: $.extend true, {}, system.config}
|
||||||
originalsSeen[system.original] = true
|
originalsSeen[system.original] = true
|
||||||
visit system for system in levelSystems ? []
|
visit system for system in levelSystems ? []
|
||||||
sorted
|
sorted
|
||||||
|
@ -140,7 +140,7 @@ module.exports = class Level extends CocoModel
|
||||||
for component in thang.components or []
|
for component in thang.components or []
|
||||||
continue unless lc = _.find levelComponents, {original: component.original}
|
continue unless lc = _.find levelComponents, {original: component.original}
|
||||||
component.config ?= {}
|
component.config ?= {}
|
||||||
TreemaUtils.populateDefaults(component.config, lc.configSchema)
|
TreemaUtils.populateDefaults(component.config, lc.configSchema, tv4)
|
||||||
@lastType = 'component'
|
@lastType = 'component'
|
||||||
@lastOriginal = component.original
|
@lastOriginal = component.original
|
||||||
@walkDefaults component.config, lc.configSchema.properties
|
@walkDefaults component.config, lc.configSchema.properties
|
||||||
|
@ -148,7 +148,7 @@ module.exports = class Level extends CocoModel
|
||||||
fillInDefaultSystemConfiguration: (levelSystems) ->
|
fillInDefaultSystemConfiguration: (levelSystems) ->
|
||||||
for system in levelSystems ? []
|
for system in levelSystems ? []
|
||||||
system.config ?= {}
|
system.config ?= {}
|
||||||
TreemaUtils.populateDefaults(system.config, system.model.configSchema)
|
TreemaUtils.populateDefaults(system.config, system.model.configSchema, tv4)
|
||||||
@lastType = 'system'
|
@lastType = 'system'
|
||||||
@lastOriginal = system.model.name
|
@lastOriginal = system.model.name
|
||||||
@walkDefaults system.config, system.model.configSchema.properties
|
@walkDefaults system.config, system.model.configSchema.properties
|
||||||
|
|
|
@ -412,7 +412,7 @@ module.exports = class ThangsTabView extends CocoView
|
||||||
# update selection, since the thangs have been remade
|
# update selection, since the thangs have been remade
|
||||||
if @selectedExtantThang
|
if @selectedExtantThang
|
||||||
@selectedExtantSprite = @surface.spriteBoss.sprites[@selectedExtantThang.id]
|
@selectedExtantSprite = @surface.spriteBoss.sprites[@selectedExtantThang.id]
|
||||||
@selectedExtantThang = @selectedExtantSprite.thang
|
@selectedExtantThang = @selectedExtantSprite?.thang
|
||||||
Backbone.Mediator.publish 'editor:thangs-edited', thangs: @world.thangs
|
Backbone.Mediator.publish 'editor:thangs-edited', thangs: @world.thangs
|
||||||
|
|
||||||
onTreemaThangSelected: (e, selectedTreemas) =>
|
onTreemaThangSelected: (e, selectedTreemas) =>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue