From bf4011044f74db58e30a5637a4052fded60f2379 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Tue, 14 Jan 2014 13:16:30 -0800 Subject: [PATCH 1/5] Initially working on using team colors, but it's not working yet. --- app/lib/LevelLoader.coffee | 70 +++++++++++++++---- app/lib/surface/CocoSprite.coffee | 8 +-- app/lib/surface/Mark.coffee | 5 +- app/lib/surface/SpriteBoss.coffee | 2 +- app/lib/world/thang.coffee | 11 ++- app/lib/world/world.coffee | 6 ++ app/models/ThangType.coffee | 14 ++-- app/styles/editor.sass | 47 +++---------- app/views/play/level/thang_avatar_view.coffee | 2 +- app/views/play/level_view.coffee | 6 +- 10 files changed, 104 insertions(+), 67 deletions(-) diff --git a/app/lib/LevelLoader.coffee b/app/lib/LevelLoader.coffee index 2299a1852..eafbd5e42 100644 --- a/app/lib/LevelLoader.coffee +++ b/app/lib/LevelLoader.coffee @@ -4,6 +4,7 @@ AudioPlayer = require 'lib/AudioPlayer' LevelSession = require 'models/LevelSession' ThangType = require 'models/ThangType' app = require 'application' +World = require 'lib/world/world' # This is an initial stab at unifying loading and setup into a single place which can # monitor everything and keep a LoadingScreen visible overall progress. @@ -70,17 +71,17 @@ module.exports = class LevelLoader extends CocoClass onSupermodelLoadedOne: (e) => @notifyProgress() - if e.model.type() is 'ThangType' - thangType = e.model - options = {async: true} - if thangType.get('name') is 'Wizard' - options.colorConfig = me.get('wizard')?.colorConfig or {} - building = thangType.buildSpriteSheet options - if building - @spriteSheetsToBuild += 1 - thangType.on 'build-complete', => - @spriteSheetsBuilt += 1 - @notifyProgress() +# if e.model.type() is 'ThangType' +# thangType = e.model +# options = {async: true} +# if thangType.get('name') is 'Wizard' +# options.colorConfig = me.get('wizard')?.colorConfig or {} +# building = thangType.buildSpriteSheet options +# if building +# @spriteSheetsToBuild += 1 +# thangType.on 'build-complete', => +# @spriteSheetsBuilt += 1 +# @notifyProgress() onSupermodelLoadedAll: => @trigger 'loaded-supermodel' @@ -111,7 +112,50 @@ module.exports = class LevelLoader extends CocoClass tempSession = new LevelSession _id: @session.id tempSession.save(patch, {patch: true}) @sessionDenormalized = true + + # World init + initWorld: -> + return if @world + @world = new World @level.get('name') + serializedLevel = @level.serialize(@supermodel) + @world.loadFromLevel serializedLevel, false +# @setTeam @world.teamForPlayer 1 # We don't know which player we are; this will go away--temp TODO + @buildSpriteSheets() + + buildSpriteSheets: -> + thangTypes = {} + thangTypes[tt.get('name')] = tt for tt in @supermodel.getModels(ThangType) + + colorConfigs = @world.getTeamColors() + + thangsProduced = {} + baseOptions = {resolutionFactor: 4, async: true} + + for thang in @world.thangs + continue unless thang.spriteName + thangType = thangTypes[thang.spriteName] + options = thang.getSpriteOptions(colorConfigs) + options.async = true + thangsProduced[thang.spriteName] = true + @buildSpriteSheet(thangType, options) + + for thangName, thangType of thangTypes + continue if thangsProduced[thangName] + thangType.spriteOptions = {resolutionFactor: 4, async: true} + @buildSpriteSheet(thangType, thangType.spriteOptions) + + buildSpriteSheet: (thangType, options) -> + if thangType.get('name') is 'Wizard' + options.colorConfig = me.get('wizard')?.colorConfig or {} + building = thangType.buildSpriteSheet options + return unless building + console.log 'Building:', thangType.get('name'), options + @spriteSheetsToBuild += 1 + thangType.on 'build-complete', => + @spriteSheetsBuilt += 1 + @notifyProgress() + # Initial Sound Loading loadAudio: -> @@ -159,7 +203,9 @@ module.exports = class LevelLoader extends CocoClass notifyProgress: -> Backbone.Mediator.publish 'level-loader:progress-changed', progress: @progress() - @trigger 'ready-to-init-world' if @allDone() + @initWorld() if @allDone() +# @trigger 'ready-to-init-world' if @allDone() + @trigger 'loaded-all' if @progress() is 1 destroy: -> @supermodel.off 'loaded-one', @onSupermodelLoadedOne diff --git a/app/lib/surface/CocoSprite.coffee b/app/lib/surface/CocoSprite.coffee index c1ed73344..6be37126b 100644 --- a/app/lib/surface/CocoSprite.coffee +++ b/app/lib/surface/CocoSprite.coffee @@ -72,10 +72,10 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass toString: -> "" - spriteSheetKey: -> - "#{@thangType.get('name')} - #{@options.resolutionFactor}" - - buildSpriteSheet: -> @thangType.getSpriteSheet @options + buildSpriteSheet: -> + options = @thang?.getSpriteOptions() or {} + options.async = false + @thangType.getSpriteSheet options buildFromSpriteSheet: (spriteSheet) -> if spriteSheet diff --git a/app/lib/surface/Mark.coffee b/app/lib/surface/Mark.coffee index c3833f5ae..ab9fef4cd 100644 --- a/app/lib/surface/Mark.coffee +++ b/app/lib/surface/Mark.coffee @@ -115,10 +115,9 @@ module.exports = class Mark extends CocoClass buildSprite: -> #console.log "building", @name, "with thangtype", @thangType - options = resolutionFactor: 4 CocoSprite = require './CocoSprite' - markSprite = new CocoSprite @thangType, options - markSprite.queueAction "idle" + markSprite = new CocoSprite @thangType, @thangType.spriteOptions + markSprite.queueAction 'idle' @mark = markSprite.displayObject update: (pos=null) -> diff --git a/app/lib/surface/SpriteBoss.coffee b/app/lib/surface/SpriteBoss.coffee index 14718d136..1be8767b6 100644 --- a/app/lib/surface/SpriteBoss.coffee +++ b/app/lib/surface/SpriteBoss.coffee @@ -87,7 +87,7 @@ module.exports = class SpriteBoss extends CocoClass @selectionMark = new Mark name: 'selection', camera: @camera, layer: @spriteLayers["Ground"], thangType: @thangTypeFor("Selection") createSpriteOptions: (options) -> - _.extend options, camera: @camera, resolutionFactor: 4, groundLayer: @spriteLayers["Ground"], textLayer: @surfaceTextLayer, floatingLayer: @spriteLayers["Floating"], markThangTypes: @markThangTypes(), spriteSheetCache: @spriteSheetCache, showInvisible: @options.showInvisible + _.extend options, camera: @camera, resolutionFactor: 4, groundLayer: @spriteLayers["Ground"], textLayer: @surfaceTextLayer, floatingLayer: @spriteLayers["Floating"], markThangTypes: @markThangTypes(), spriteSheetCache: @spriteSheetCache, showInvisible: @options.showInvisible, world: @world createIndieSprites: (indieSprites, withWizards) -> unless @indieSprites diff --git a/app/lib/world/thang.coffee b/app/lib/world/thang.coffee index 57e83d087..6d85cdf15 100644 --- a/app/lib/world/thang.coffee +++ b/app/lib/world/thang.coffee @@ -156,4 +156,13 @@ module.exports = class Thang for prop, val of o.finalState # TODO: take some (but not all) of deserialize logic from ThangState to handle other types t[prop] = val - t \ No newline at end of file + t + + getSpriteOptions: -> + colorConfigs = @world?.getTeamColors() or {} + options = {} + if @team and colorConfigs[@team] + options.colorConfig = {team: colorConfigs[@team]} + if @spriteName is 'Tharin' + console.log 'THARIN made options', options, colorConfigs, @world + options diff --git a/app/lib/world/world.coffee b/app/lib/world/world.coffee index a6ba95418..021f54e5e 100644 --- a/app/lib/world/world.coffee +++ b/app/lib/world/world.coffee @@ -457,3 +457,9 @@ module.exports = class World lastAction = action @actionsForThangCache[cacheKey] = actions return actions + + getTeamColors: -> + teamConfigs = @teamConfigs or {} + colorConfigs = {} + colorConfigs[teamName] = config.color for teamName, config of teamConfigs + colorConfigs \ No newline at end of file diff --git a/app/models/ThangType.coffee b/app/models/ThangType.coffee index 62885e3b4..1f7a994cb 100644 --- a/app/models/ThangType.coffee +++ b/app/models/ThangType.coffee @@ -4,10 +4,11 @@ SpriteBuilder = require 'lib/sprites/SpriteBuilder' module.exports = class ThangType extends CocoModel @className: "ThangType" urlRoot: "/db/thang.type" - building: 0 + building: {} initialize: -> super() + @building = {} @setDefaults() @on 'sync', @setDefaults @spriteSheets = {} @@ -47,15 +48,18 @@ module.exports = class ThangType extends CocoModel options buildSpriteSheet: (options) -> + @options = @fillOptions options + key = @spriteSheetKey(@options) + return if @building[key] @initBuild(options) -# @options.portraitOnly = true @addGeneralFrames() unless @options.portraitOnly @addPortrait() - @finishBuild() + @building[key] = true + result = @finishBuild() + return result initBuild: (options) -> @buildActions() if not @actions - @options = @fillOptions options @vectorParser = new SpriteBuilder(@, options) @builder = new createjs.SpriteSheetBuilder() @builder.padding = 2 @@ -132,7 +136,7 @@ module.exports = class ThangType extends CocoModel @builder.on 'complete', @onBuildSpriteSheetComplete, @, true, key return true - console.warn 'Building', @get('name'), 'and blocking the main thread. LevelLoader should have it built asynchronously instead.' + console.warn 'Building', @get('name'), 'and blocking the main thread.', @options, @spriteSheets spriteSheet = @builder.build() @spriteSheets[key] = spriteSheet spriteSheet diff --git a/app/styles/editor.sass b/app/styles/editor.sass index 622adecfe..c4c46280d 100644 --- a/app/styles/editor.sass +++ b/app/styles/editor.sass @@ -1,41 +1,12 @@ @import "bootstrap/variables" #editor-level-view - .images - margin: 30px 0 - text-align: center - div - float: left - width: 25% - padding: 10px 40px - box-sizing: border-box - img - width: 100% - - #image-modal - .modal-body - max-height: 100% - - height: 80% - width: 80% - margin-left: -40% - - img - display: block - margin: 0 auto - max-height: 80% - - #after-images - clear: both - - ul#prereqs - margin: 20px 40px + .editor-column + width: 33% + box-sizing: border-box + padding-right: 20px + float: left + h3 + text-decoration: underline + margin-bottom: 2px - #editor-links .btn - margin-right: 20px - margin-bottom: 30px - -//.screencast-wrapper - // text-align: center - // background: $gray - // object - // display: inline-block \ No newline at end of file + \ No newline at end of file diff --git a/app/views/play/level/thang_avatar_view.coffee b/app/views/play/level/thang_avatar_view.coffee index a03d4a63c..14b8fefd1 100644 --- a/app/views/play/level/thang_avatar_view.coffee +++ b/app/views/play/level/thang_avatar_view.coffee @@ -20,7 +20,7 @@ module.exports = class ThangAvatarView extends View thangs = @supermodel.getModels(ThangType) thangs = (t for t in thangs when t.get('name') is @thang.spriteName) thang = thangs[0] - context.avatarURL = thang.getPortraitSource() + context.avatarURL = thang.getPortraitSource(@thang.spriteOptions) context.includeName = @includeName context diff --git a/app/views/play/level_view.coffee b/app/views/play/level_view.coffee index 8c5288e0a..2766b129f 100644 --- a/app/views/play/level_view.coffee +++ b/app/views/play/level_view.coffee @@ -74,6 +74,7 @@ module.exports = class PlayLevelView extends View sessionID = @getQueryVariable "session" @levelLoader = new LevelLoader(@levelID, @supermodel, sessionID) @levelLoader.once 'ready-to-init-world', @onReadyToInitWorld + @levelLoader.once 'loaded-all', @onLevelLoaderLoaded $(window).on('resize', @onWindowResize) @supermodel.once 'error', => @@ -96,11 +97,12 @@ module.exports = class PlayLevelView extends View @loadingScreen.show() super() - onReadyToInitWorld: => + onLevelLoaderLoaded: => @session = @levelLoader.session @level = @levelLoader.level + @world = @levelLoader.world @loadingScreen.destroy() - @initWorld() +# @initWorld() @initSurface() @initGod() @initGoalManager() From 7f1f0fadff7b14e775f1d27e06fe25a3487aad47 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Tue, 14 Jan 2014 14:03:55 -0800 Subject: [PATCH 2/5] Fixed System deserialization. --- app/lib/world/thang.coffee | 6 ++---- app/lib/world/world.coffee | 9 +++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/lib/world/thang.coffee b/app/lib/world/thang.coffee index 6d85cdf15..11de09ae3 100644 --- a/app/lib/world/thang.coffee +++ b/app/lib/world/thang.coffee @@ -36,7 +36,7 @@ module.exports = class Thang Thang.lastIDNums[spriteName] = if Thang.lastIDNums[spriteName]? then Thang.lastIDNums[spriteName] + 1 else 0 id = spriteName + (Thang.lastIDNums[spriteName] or '') id - + @resetThangIDs: -> Thang.lastIDNums = {} constructor: (@world, @spriteName, @id) -> @@ -157,12 +157,10 @@ module.exports = class Thang # TODO: take some (but not all) of deserialize logic from ThangState to handle other types t[prop] = val t - + getSpriteOptions: -> colorConfigs = @world?.getTeamColors() or {} options = {} if @team and colorConfigs[@team] options.colorConfig = {team: colorConfigs[@team]} - if @spriteName is 'Tharin' - console.log 'THARIN made options', options, colorConfigs, @world options diff --git a/app/lib/world/world.coffee b/app/lib/world/world.coffee index 021f54e5e..92cc1424d 100644 --- a/app/lib/world/world.coffee +++ b/app/lib/world/world.coffee @@ -252,10 +252,9 @@ module.exports = class World # Code hotspot; optimize it if @frames.length < @totalFrames then worldShouldBeOverBeforeSerialization [transferableObjects, nontransferableObjects] = [0, 0] - o = {name: @name, totalFrames: @totalFrames, maxTotalFrames: @maxTotalFrames, frameRate: @frameRate, dt: @dt, victory: @victory, userCodeMap: {}} + o = {name: @name, totalFrames: @totalFrames, maxTotalFrames: @maxTotalFrames, frameRate: @frameRate, dt: @dt, victory: @victory, userCodeMap: {}, trackedProperties: {}} + o.trackedProperties[prop] = @[prop] for prop in @trackedProperties or [] - o[prop] = @[prop] for prop in @trackedProperties or [] - for thangID, methods of @userCodeMap serializedMethods = o.userCodeMap[thangID] = {} for methodName, method of methods @@ -348,6 +347,8 @@ module.exports = class World perf.t0 = now() w = new World o.name, o.userCodeMap, classMap [w.totalFrames, w.maxTotalFrames, w.frameRate, w.dt, w.scriptNotes, w.victory] = [o.totalFrames, o.maxTotalFrames, o.frameRate, o.dt, o.scriptNotes ? [], o.victory] + w[prop] = val for prop, val of o.trackedProperties + [w.showCoordinates, w.showGrid, w.showPaths, w.indieSprites] = [o.showCoordinates, o.showGrid, o.showPaths, o.indieSprites] perf.t1 = now() w.thangs = (Thang.deserialize(thang, w, classMap) for thang in o.thangs) @@ -462,4 +463,4 @@ module.exports = class World teamConfigs = @teamConfigs or {} colorConfigs = {} colorConfigs[teamName] = config.color for teamName, config of teamConfigs - colorConfigs \ No newline at end of file + colorConfigs From 47effcd50eaba70393b04af9948d95ceb8f65f96 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Wed, 15 Jan 2014 15:16:31 -0800 Subject: [PATCH 3/5] Got the rest of team colors set up. --- app/lib/surface/CocoSprite.coffee | 1 + app/styles/account/settings.sass | 43 +++++++++++++------ .../account/wizard_settings_tab.jade | 23 +++++----- .../account/wizard_settings_tab_view.coffee | 21 +++++---- app/views/play/level/hud_view.coffee | 10 +++-- app/views/play/level/thang_avatar_view.coffee | 4 +- 6 files changed, 66 insertions(+), 36 deletions(-) diff --git a/app/lib/surface/CocoSprite.coffee b/app/lib/surface/CocoSprite.coffee index 6be37126b..3daaa5635 100644 --- a/app/lib/surface/CocoSprite.coffee +++ b/app/lib/surface/CocoSprite.coffee @@ -74,6 +74,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass buildSpriteSheet: -> options = @thang?.getSpriteOptions() or {} + options.colorConfig = @options.colorConfig if @options.colorConfig options.async = false @thangType.getSpriteSheet options diff --git a/app/styles/account/settings.sass b/app/styles/account/settings.sass index 773c25df3..2df6b14c4 100644 --- a/app/styles/account/settings.sass +++ b/app/styles/account/settings.sass @@ -35,22 +35,41 @@ font-size: 12px #wizard-settings-tab-view - .form-horizontal + #color-settings float: left - width: 400px - margin-left: 50px + width: 600px + margin-left: 30px + canvas float: left border: 2px solid black margin: 20px - .selector - position: relative - top: 10px - left: 10px - - h2 input - margin-left: 10px - - .form-horizontal .control-group + .color-group + clear: both + padding-bottom: 10px margin-bottom: 10px + border-bottom: 1px solid gray + + .name-cell + float: left + width: 100px + padding-top: 2px + + input + margin-right: 10px + position: relative + top: -3px + + .checkbox-cell + float: left + width: 40px + + .slider-cell + margin-bottom: 10px + float: left + width: 120px + + .selector + width: 100px + diff --git a/app/templates/account/wizard_settings_tab.jade b/app/templates/account/wizard_settings_tab.jade index dd5dbc0cd..7738c64e7 100644 --- a/app/templates/account/wizard_settings_tab.jade +++ b/app/templates/account/wizard_settings_tab.jade @@ -1,21 +1,22 @@ canvas#tinting-display(width=200, height=200).img-rounded -.form-horizontal +#color-settings for group in colorGroups .color-group(data-name=group.name) - h2 - span(data-i18n=group.dasherized)= group.humanized + div.name-cell input(type='checkbox', checked=group.exists).color-group-checkbox - .sliders - .control-group - label.control-label(for=group.humanized+"_hue", data-i18n="hue") Hue + span(data-i18n=group.dasherized)= group.humanized + div.sliders + div.slider-cell + label(for=group.humanized+"_hue", data-i18n="hue") Hue .controls .selector(id=group.humanized+"_hue", name=group.name+'.hue', data-key='hue') - .control-group - label.control-label(for=group.humanized+"_saturation", data-i18n="saturation") Saturation + div.slider-cell + label(for=group.humanized+"_saturation", data-i18n="saturation") Saturation .controls .selector(id=group.humanized+"_saturation", name=group.name+'.saturation', data-key='saturation') - .control-group - label.control-label(for=group.humanized+"_lightness", data-i18n="lightness") Lightness + div.slider-cell + label(for=group.humanized+"_lightness", data-i18n="lightness") Lightness .controls - .selector(id=group.humanized+"_lightness", name=group.name+'.lightness', data-key='lightness') \ No newline at end of file + .selector(id=group.humanized+"_lightness", name=group.name+'.lightness', data-key='lightness') + div.clearfix \ No newline at end of file diff --git a/app/views/account/wizard_settings_tab_view.coffee b/app/views/account/wizard_settings_tab_view.coffee index 81263df6c..a26c1452f 100644 --- a/app/views/account/wizard_settings_tab_view.coffee +++ b/app/views/account/wizard_settings_tab_view.coffee @@ -49,7 +49,7 @@ module.exports = class WizardSettingsTabView extends RootView @$el.find('.selector').each (i, slider) => [groupName, prop] = $(slider).attr('name').split('.') - value = 100 * (wizardSettings.colorConfig[groupName]?[prop] or 0) + value = 100 * (wizardSettings.colorConfig[groupName]?[prop] ? 0.5) @initSlider $(slider), value, @onSliderChanged @$el.find('.color-group').each (i, colorGroup) => @@ -82,7 +82,9 @@ module.exports = class WizardSettingsTabView extends RootView initStage: -> @stage = new createjs.Stage(@$el.find('canvas')[0]) @updateMovieClip() - + createjs.Ticker.setFPS 20 + createjs.Ticker.addEventListener("tick", @stage) + updateMovieClip: -> return unless @wizardThangType.loaded wizardSettings = me.get('wizard') or {} @@ -92,13 +94,16 @@ module.exports = class WizardSettingsTabView extends RootView options = {colorConfig: wizardSettings.colorConfig} @spriteBuilder.setOptions options @spriteBuilder.buildColorMaps() - portraitAction = @wizardThangType.get('actions')?.portrait - return unless portraitAction?.animation - @movieClip = @spriteBuilder.buildMovieClip portraitAction.animation - @movieClip.scaleY = @movieClip.scaleX = 2 * (portraitAction.scale or 1) - reg = portraitAction.positions?.registration + castAction = @wizardThangType.get('actions')?.cast + return unless castAction?.animation + @movieClip = @spriteBuilder.buildMovieClip castAction.animation + @movieClip.scaleY = @movieClip.scaleX = 1.7 * (castAction.scale or 1) + reg = castAction.positions?.registration if reg @movieClip.regX = reg.x @movieClip.regY = reg.y @stage.addChild @movieClip - @stage.update() \ No newline at end of file + @stage.update() + + destroy: -> + @stage?.removeAllEventListeners() \ No newline at end of file diff --git a/app/views/play/level/hud_view.coffee b/app/views/play/level/hud_view.coffee index 3eb295a6f..c4f7f3e97 100644 --- a/app/views/play/level/hud_view.coffee +++ b/app/views/play/level/hud_view.coffee @@ -74,7 +74,7 @@ module.exports = class HUDView extends View if not @thang @hintNextSelectionTimeout = _.delay((=> @$el.find('.no-selection-message').slideDown('slow')), 10000) return - @createAvatar thangType + @createAvatar thangType, @thang @createProperties() @createActions() @update() @@ -84,7 +84,7 @@ module.exports = class HUDView extends View return if speakerSprite is @speakerSprite @speakerSprite = speakerSprite @speaker = @speakerSprite.thang.id - @createAvatar @speakerSprite.thangType + @createAvatar @speakerSprite.thangType, @speakerSprite.thang @$el.removeClass 'no-selection' @switchToDialogueElements() @@ -98,8 +98,10 @@ module.exports = class HUDView extends View @bubble = null @update() - createAvatar: (thangType) -> - stage = thangType.getPortraitStage() + createAvatar: (thangType, thang) -> + options = thang.getSpriteOptions() or {} + options.async = false + stage = thangType.getPortraitStage options wrapper = @$el.find '.thang-canvas-wrapper' newCanvas = $(stage.canvas).addClass('thang-canvas') wrapper.empty().append(newCanvas) diff --git a/app/views/play/level/thang_avatar_view.coffee b/app/views/play/level/thang_avatar_view.coffee index 14b8fefd1..91b2ae15a 100644 --- a/app/views/play/level/thang_avatar_view.coffee +++ b/app/views/play/level/thang_avatar_view.coffee @@ -20,7 +20,9 @@ module.exports = class ThangAvatarView extends View thangs = @supermodel.getModels(ThangType) thangs = (t for t in thangs when t.get('name') is @thang.spriteName) thang = thangs[0] - context.avatarURL = thang.getPortraitSource(@thang.spriteOptions) + options = @thang?.getSpriteOptions() or {} + options.async = false + context.avatarURL = thang.getPortraitSource(options) context.includeName = @includeName context From f230e8983c181d09e7fe76bf3673af8c5addd7f3 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Wed, 15 Jan 2014 18:37:47 -0800 Subject: [PATCH 4/5] Fixed the level preview view. --- app/views/play/level_view.coffee | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/views/play/level_view.coffee b/app/views/play/level_view.coffee index 2766b129f..a3dc9a3ec 100644 --- a/app/views/play/level_view.coffee +++ b/app/views/play/level_view.coffee @@ -71,20 +71,24 @@ module.exports = class PlayLevelView extends View window.tracker?.trackEvent 'Hour of Code Begin', {} @isEditorPreview = @getQueryVariable "dev" - sessionID = @getQueryVariable "session" - @levelLoader = new LevelLoader(@levelID, @supermodel, sessionID) - @levelLoader.once 'ready-to-init-world', @onReadyToInitWorld - @levelLoader.once 'loaded-all', @onLevelLoaderLoaded + @sessionID = @getQueryVariable "session" $(window).on('resize', @onWindowResize) @supermodel.once 'error', => msg = $.i18n.t('play_level.level_load_error', defaultValue: "Level could not be loaded.") @$el.html('
' + msg + '
') @saveScreenshot = _.throttle @saveScreenshot, 30000 + + @load() unless @isEditorPreview setLevel: (@level, @supermodel) -> @god?.level = @level.serialize @supermodel - @initWorld() + @load() + + load: -> + @levelLoader = new LevelLoader(@levelID, @supermodel, @sessionID) + @levelLoader.once 'ready-to-init-world', @onReadyToInitWorld + @levelLoader.once 'loaded-all', @onLevelLoaderLoaded getRenderData: -> c = super() From ba01101ae0057c6248132d737623b5823bf32d2c Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Thu, 16 Jan 2014 10:04:52 -0800 Subject: [PATCH 5/5] Cleanup from the system tracked properties refactoring. --- app/lib/world/world.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/app/lib/world/world.coffee b/app/lib/world/world.coffee index 92cc1424d..1d5b2ee34 100644 --- a/app/lib/world/world.coffee +++ b/app/lib/world/world.coffee @@ -349,7 +349,6 @@ module.exports = class World [w.totalFrames, w.maxTotalFrames, w.frameRate, w.dt, w.scriptNotes, w.victory] = [o.totalFrames, o.maxTotalFrames, o.frameRate, o.dt, o.scriptNotes ? [], o.victory] w[prop] = val for prop, val of o.trackedProperties - [w.showCoordinates, w.showGrid, w.showPaths, w.indieSprites] = [o.showCoordinates, o.showGrid, o.showPaths, o.indieSprites] perf.t1 = now() w.thangs = (Thang.deserialize(thang, w, classMap) for thang in o.thangs) w.setThang thang for thang in w.thangs