mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 01:55:38 -05:00
Merge branch 'production'
This commit is contained in:
commit
9ffd0498f2
5 changed files with 22 additions and 4 deletions
|
@ -245,7 +245,7 @@ module.exports = class LevelLoader extends CocoClass
|
|||
if extantRequiredThangTypes.length < requiredThangTypes.length
|
||||
console.error "Some Thang had a blank required ThangType in components list:", components
|
||||
for thangType in extantRequiredThangTypes
|
||||
url = "/db/thang.type/#{thangType}/version?project=name,components,original,rasterIcon,kind"
|
||||
url = "/db/thang.type/#{thangType}/version?project=name,components,original,rasterIcon,kind,prerenderedSpriteSheetData"
|
||||
@worldNecessities.push @maybeLoadURL(url, ThangType, 'thang')
|
||||
|
||||
onThangNamesLoaded: (thangNames) ->
|
||||
|
|
|
@ -128,6 +128,7 @@ module.exports = class SpriteBuilder
|
|||
@colorMap = {}
|
||||
colorGroups = @thangType.get('colorGroups')
|
||||
return if _.isEmpty colorGroups
|
||||
return unless _.size @shapeStore # We don't have the shapes loaded because we are doing a prerendered spritesheet approach
|
||||
colorConfig = @options.colorConfig
|
||||
# colorConfig ?= {team: {hue:0.4, saturation: -0.5, lightness: -0.5}} # test config
|
||||
return if not colorConfig
|
||||
|
|
|
@ -151,7 +151,7 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
|
|||
lank.layer = @
|
||||
@listenTo(lank, 'action-needs-render', @onActionNeedsRender)
|
||||
@lanks.push lank
|
||||
lank.thangType.initPrerenderedSpriteSheets()
|
||||
lank.thangType.initPrerenderedSpriteSheets() unless currentView.getQueryVariable 'jitSpritesheets'
|
||||
prerenderedSpriteSheet = lank.thangType.getPrerenderedSpriteSheet(lank.options.colorConfig, @defaultSpriteType)
|
||||
prerenderedSpriteSheet?.markToLoad()
|
||||
@loadThangType(lank.thangType)
|
||||
|
@ -273,6 +273,7 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
|
|||
builder.buildAsync()
|
||||
catch e
|
||||
@resolutionFactor *= 0.9
|
||||
#console.log " Rerendering sprite sheet didn't fit, going down to resolutionFactor", @resolutionFactor, "async", async
|
||||
return @_renderNewSpriteSheet(async)
|
||||
builder.on 'complete', @onBuildSpriteSheetComplete, @, true, builder
|
||||
@asyncBuilder = builder
|
||||
|
@ -290,7 +291,8 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
|
|||
# get a rough estimate of how much smaller the spritesheet needs to be
|
||||
for image, index in builder.spriteSheet._images
|
||||
total += image.height / builder.maxHeight
|
||||
@resolutionFactor /= (Math.max(1.1, Math.sqrt(total)))
|
||||
@resolutionFactor /= (Math.max(1.25, Math.sqrt(total)))
|
||||
#console.log "#{@name} rerendering new sprite sheet with resolutionFactor", @resolutionFactor, "async", e.async
|
||||
@_renderNewSpriteSheet(e.async)
|
||||
return
|
||||
|
||||
|
@ -357,6 +359,7 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
|
|||
if prerenderedSpriteSheet and not prerenderedSpriteSheet.loadedImage
|
||||
return
|
||||
containersToRender = thangType.getContainersForActions(actionNames)
|
||||
#console.log 'render segmented', thangType.get('name'), actionNames, colorConfig, 'because we do not have prerendered sprite sheet?', prerenderedSpriteSheet
|
||||
spriteBuilder = new SpriteBuilder(thangType, {colorConfig: colorConfig})
|
||||
for containerGlobalName in containersToRender
|
||||
containerKey = @renderGroupingKey(thangType, containerGlobalName, colorConfig)
|
||||
|
@ -387,6 +390,8 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
|
|||
sprite = new createjs.Sprite(prerenderedSpriteSheet.spriteSheet)
|
||||
sprite.gotoAndStop(i)
|
||||
prerenderedFramesMap[i] = spriteSheetBuilder.addFrame(sprite, null, scale)
|
||||
#else
|
||||
# console.log ' Rerendering singular thang type', thangType.get('name'), thangType.get('spriteType'), colorConfig, actionNames
|
||||
|
||||
actionObjects = _.values(thangType.getActions())
|
||||
animationActions = []
|
||||
|
|
|
@ -80,4 +80,16 @@ ThangTypeHandler = class ThangTypeHandler extends Handler
|
|||
else
|
||||
super(arguments...)
|
||||
|
||||
# Was testing to see what the bandwidth savings are here. This would need more logic to determine whether we need the vector data, probably with extra info from the client.
|
||||
#formatEntity: (req, document) ->
|
||||
# result = document?.toObject()
|
||||
# if false and result.prerenderedSpriteSheetData and result.raw and result.kind isnt 'Mark'
|
||||
# if false and result.spriteType is 'singular' # Wait, do we need animations and containers for Singular?
|
||||
# result.raw = shapes: {}, containers: {}, animations: {}
|
||||
# else
|
||||
# result.raw.shapes = {}
|
||||
# #result.raw.containers = {} # Segmented and Singular sprites currently look at the bounds of containers to determine scale sometimes; wonder if we need that, or if containers are ever even that big
|
||||
# result
|
||||
|
||||
|
||||
module.exports = new ThangTypeHandler()
|
||||
|
|
|
@ -32,7 +32,7 @@ module.exports.setup = (app) ->
|
|||
else if isHTTPMethodPut req
|
||||
handler.processTaskResult req, res
|
||||
else if isHTTPMethodPost req
|
||||
handler.createNewTask req, res #TODO: do not use this in production
|
||||
handler.createNewTask req, res
|
||||
else
|
||||
sendMethodNotSupportedError req, res
|
||||
catch error
|
||||
|
|
Loading…
Reference in a new issue