From 440e1700b1c1bd236e7ebad5498e470167fd6071 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Sun, 19 Oct 2014 12:44:58 -0700 Subject: [PATCH] Using aiSource now for enemy AIs in multiplayer, separate from sample code source. --- .../editor/level/modals/SaveLevelModal.coffee | 1 + .../editor/thang/ThangTypeEditView.coffee | 21 ++++++++++--------- app/views/play/level/tome/Spell.coffee | 2 ++ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/views/editor/level/modals/SaveLevelModal.coffee b/app/views/editor/level/modals/SaveLevelModal.coffee index 3913257a4..7d90d1e74 100644 --- a/app/views/editor/level/modals/SaveLevelModal.coffee +++ b/app/views/editor/level/modals/SaveLevelModal.coffee @@ -52,6 +52,7 @@ module.exports = class SaveLevelModal extends SaveVersionModal console.log "Should we save", m.get('system'), m.get('name'), m, "? localChanges:", m.hasLocalChanges(), "version:", m.get('version'), 'isPublished:', m.isPublished(), 'collection:', m.collection return false return true if m.hasLocalChanges() + console.error "Trying to check major version of #{m.type()} #{m.get('name')}, but it doesn't have a version:", m unless m.get('version') return true if (m.get('version').major is 0 and m.get('version').minor is 0) or not m.isPublished() and not m.collection # Sometimes we have two versions: one in a search collection and one with a URL. We only save changes to the latter. false diff --git a/app/views/editor/thang/ThangTypeEditView.coffee b/app/views/editor/thang/ThangTypeEditView.coffee index 91d3f47d3..5ee5c35d7 100644 --- a/app/views/editor/thang/ThangTypeEditView.coffee +++ b/app/views/editor/thang/ThangTypeEditView.coffee @@ -77,7 +77,7 @@ module.exports = class ThangTypeEditView extends RootView context getAnimationNames: -> _.keys(@thangType.get('actions') or {}) - + afterRender: -> super() return unless @supermodel.finished() @@ -119,7 +119,7 @@ module.exports = class ThangTypeEditView extends RootView @stage = new createjs.Stage(canvas[0]) @layerAdapter = new LayerAdapter({name:'Default', webGL: true}) @topLayer = new createjs.Container() - + @layerAdapter.container.x = @topLayer.x = CENTER.x @layerAdapter.container.y = @topLayer.y = CENTER.y @stage.addChild(@layerAdapter.container, @topLayer) @@ -135,7 +135,7 @@ module.exports = class ThangTypeEditView extends RootView @updateGrid() _.defer @refreshAnimation @toggleDots(false) - + createjs.Ticker.setFPS(30) createjs.Ticker.addEventListener('tick', @stage) @@ -244,7 +244,7 @@ module.exports = class ThangTypeEditView extends RootView lank = new Lank(@thangType, @getLankOptions()) @showLank(lank) @updateScale() - + onNewSpriteSheet: -> $('#spritesheets').empty() for image in @layerAdapter.spriteSheet._images @@ -260,7 +260,7 @@ module.exports = class ThangTypeEditView extends RootView @showAction(animationName) @updateRotation() @updateScale() # must happen after update rotation, because updateRotation calls the sprite update() method. - + showMovieClip: (animationName) -> vectorParser = new SpriteBuilder(@thangType) movieClip = vectorParser.buildMovieClip(animationName) @@ -289,7 +289,7 @@ module.exports = class ThangTypeEditView extends RootView portrait?.attr('id', 'portrait').addClass('img-thumbnail') portrait.addClass 'img-thumbnail' $('#portrait').replaceWith(portrait) - + showLank: (lank) -> @clearDisplayObject() @clearLank() @@ -306,7 +306,7 @@ module.exports = class ThangTypeEditView extends RootView clearDisplayObject: -> @topLayer.removeChild(@currentObject) if @currentObject? - + clearLank: -> @layerAdapter.removeLank(@currentLank) if @currentLank @currentLank?.destroy() @@ -365,7 +365,8 @@ module.exports = class ThangTypeEditView extends RootView url = "/editor/thang/#{newThangType.get('slug') or newThangType.id}" portraitSource = null if @thangType.get('raster') - image = @currentLank.sprite.image + #image = @currentLank.sprite.image # Doesn't work? + image = @currentLank.sprite.spriteSheet._images[0] portraitSource = imageToPortrait image # bit of a hacky way to get that portrait success = => @@ -429,7 +430,7 @@ module.exports = class ThangTypeEditView extends RootView obj = vectorParser.buildMovieClip(key) if type is 'animations' obj = vectorParser.buildContainerFromStore(key) if type is 'containers' obj = vectorParser.buildShapeFromStore(key) if type is 'shapes' - + bounds = obj?.bounds or obj?.nominalBounds if bounds @boundsBox = new createjs.Shape() @@ -437,7 +438,7 @@ module.exports = class ThangTypeEditView extends RootView @topLayer.addChild(@boundsBox) obj.regX = @boundsBox.regX = bounds.x + bounds.width / 2 obj.regY = @boundsBox.regY = bounds.y + bounds.height / 2 - + @showSprite(obj) if obj @showingSelectedNode = true @currentLank?.destroy() diff --git a/app/views/play/level/tome/Spell.coffee b/app/views/play/level/tome/Spell.coffee index aba1c56b1..0c0e50e8d 100644 --- a/app/views/play/level/tome/Spell.coffee +++ b/app/views/play/level/tome/Spell.coffee @@ -40,6 +40,8 @@ module.exports = class Spell if @permissions.readwrite.length and sessionSource = @session.getSourceFor(@spellKey) if sessionSource isnt '// Should fill in some default source\n' # TODO: figure out why session is getting this default source in there and stop it @source = sessionSource + if p.aiSource and not @otherSession and not @canWrite() + @source = @originalSource = p.aiSource @thangs = {} if @canRead() # We can avoid creating these views if we'll never use them. @view = new SpellView {spell: @, level: options.level, session: @session, worker: @worker}