From eb109156ce6e3f20a9b739a500c9f327b0cf46e3 Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Mon, 7 Jul 2014 20:22:42 -0700 Subject: [PATCH 01/11] Consolidated iOS and Android into Mobile Developer --- app/schemas/models/user.coffee | 2 +- app/templates/employers.jade | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/schemas/models/user.coffee b/app/schemas/models/user.coffee index 0bfbcc52d..87884bb93 100644 --- a/app/schemas/models/user.coffee +++ b/app/schemas/models/user.coffee @@ -142,7 +142,7 @@ UserSchema = c.object {}, roleFilter: title: 'Role' type: 'string' - enum: ['Web Developer', 'Software Developer', 'iOS Developer', 'Android Developer', 'Mobile Developer'] + enum: ['Web Developer', 'Software Developer', 'Mobile Developer'] seniorityFilter: title: 'Seniority' type: 'string' diff --git a/app/templates/employers.jade b/app/templates/employers.jade index 38e9f2852..5f3121cce 100644 --- a/app/templates/employers.jade +++ b/app/templates/employers.jade @@ -57,12 +57,8 @@ block content | Software Developer br label - input(type="checkbox" name="roleFilter" value="iOS Developer") - | iOS Developer - br - label - input(type="checkbox" name="roleFilter" value="Android Developer") - | Android Developer + input(type="checkbox" name="roleFilter" value="Mobile Developer") + | Mobile Developer .filter_section#seniority_filter h4 Seniority label From 1493da8fad05a64d063c0885f9a6e84b9ec6aabf Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Mon, 7 Jul 2014 20:23:35 -0700 Subject: [PATCH 02/11] Revert "Consolidated iOS and Android into Mobile Developer" This reverts commit eb109156ce6e3f20a9b739a500c9f327b0cf46e3. --- app/schemas/models/user.coffee | 2 +- app/templates/employers.jade | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/schemas/models/user.coffee b/app/schemas/models/user.coffee index 87884bb93..0bfbcc52d 100644 --- a/app/schemas/models/user.coffee +++ b/app/schemas/models/user.coffee @@ -142,7 +142,7 @@ UserSchema = c.object {}, roleFilter: title: 'Role' type: 'string' - enum: ['Web Developer', 'Software Developer', 'Mobile Developer'] + enum: ['Web Developer', 'Software Developer', 'iOS Developer', 'Android Developer', 'Mobile Developer'] seniorityFilter: title: 'Seniority' type: 'string' diff --git a/app/templates/employers.jade b/app/templates/employers.jade index 5f3121cce..38e9f2852 100644 --- a/app/templates/employers.jade +++ b/app/templates/employers.jade @@ -57,8 +57,12 @@ block content | Software Developer br label - input(type="checkbox" name="roleFilter" value="Mobile Developer") - | Mobile Developer + input(type="checkbox" name="roleFilter" value="iOS Developer") + | iOS Developer + br + label + input(type="checkbox" name="roleFilter" value="Android Developer") + | Android Developer .filter_section#seniority_filter h4 Seniority label From cbd6cacd61e64ab522863cee5e02b9d6680d66a7 Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Mon, 7 Jul 2014 22:50:14 -0700 Subject: [PATCH 03/11] Restyle signup/login modal for employer page --- app/styles/recruitment_base.sass | 36 ++++++++++++++++++- app/templates/modal/auth.jade | 26 +++++++++----- .../modal/employer_signup_modal.jade | 19 +++------- app/views/employers_view.coffee | 2 +- app/views/kinds/ModalView.coffee | 4 +++ app/views/modal/auth_modal.coffee | 3 +- 6 files changed, 64 insertions(+), 26 deletions(-) diff --git a/app/styles/recruitment_base.sass b/app/styles/recruitment_base.sass index 06bfe815c..f6c6e1062 100644 --- a/app/styles/recruitment_base.sass +++ b/app/styles/recruitment_base.sass @@ -18,4 +18,38 @@ #employer-content-area - margin: auto \ No newline at end of file + margin: auto + +.employer-modal-background-wrapper + background-color: white + border: 2px #333333 solid + border-radius: 4px + h1, h2, h3, h4, h5 + color: black + font-family: Arial, Helvetica, sans-serif + .input-large + font-size: 28px + height: 60px + border: 2px rgb(231,231,231) solid + box-shadow: none + width: 70% + margin-left: 15% + #create-account-button, #contract-agreement-button, #login-button + background: #fce232 /* Old browsers */ + background: -moz-linear-gradient(top, #fce232 0%, #ea8e2b 100%) + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#fce232), color-stop(100%,#ea8e2b)) + background: -webkit-linear-gradient(top, #fce232 0%,#ea8e2b 100%) + background: -o-linear-gradient(top, #fce232 0%,#ea8e2b 100%) + background: -ms-linear-gradient(top, #fce232 0%,#ea8e2b 100%) + background: linear-gradient(to bottom, #fce232 0%,#ea8e2b 100%) + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fce232', endColorstr='#ea8e2b',GradientType=0 ) + height: 60px + font-size: 24px + color: black + .login-link + text-decoration: underline + #login-button + margin-left: 40% + width: 20% + + \ No newline at end of file diff --git a/app/templates/modal/auth.jade b/app/templates/modal/auth.jade index 626ca4827..7edff3fff 100644 --- a/app/templates/modal/auth.jade +++ b/app/templates/modal/auth.jade @@ -19,12 +19,19 @@ block modal-body-content p(data-i18n="signup.description") It's free. Just need a couple things and you'll be good to go: form.form - .form-group - label.control-label(for="email", data-i18n="general.email") Email - input#email.input-large.form-control(name="email", type="email", value=formValues.email) - .form-group - label.control-label(for="password", data-i18n="general.password") Password - input#password.input-large.form-control(name="password", type="password", value=formValues.password) + if onEmployersPage + .form-group + input#email.input-large.form-control(name="email", type="email", value=formValues.email, placeholder="Email") + .form-group + input#password.input-large.form-control(name="password", type="password", value=formValues.password, placeholder="Password") + + else + .form-group + label.control-label(for="email", data-i18n="general.email") Email + input#email.input-large.form-control(name="email", type="email", value=formValues.email) + .form-group + label.control-label(for="password", data-i18n="general.password") Password + input#password.input-large.form-control(name="password", type="password", value=formValues.password) if mode === 'signup' .form-group.checkbox @@ -38,8 +45,11 @@ block modal-body-content a(href="https://en.wikipedia.org/wiki/Children's_Online_Privacy_Protection_Act", data-i18n="signup.coppa_why", target="_blank") (Why?) if mode === 'login' - input.btn.btn-info.btn-large#login-button(value=translate("login.log_in"), type="submit") - .btn.btn-default.btn-large#switch-to-signup-button(data-i18n="login.sign_up") Create Account + if onEmployersPage + input.btn.btn-info.btn-large#login-button(value=translate("login.log_in"), type="submit") + else + input.btn.btn-info.btn-large#login-button(value=translate("login.log_in"), type="submit") + .btn.btn-default.btn-large#switch-to-signup-button(data-i18n="login.sign_up") Create Account if mode === 'signup' input.btn.btn-info.btn-large#signup-button(value=translate("signup.sign_up"), type="submit") diff --git a/app/templates/modal/employer_signup_modal.jade b/app/templates/modal/employer_signup_modal.jade index d6a627ddf..8d0429137 100644 --- a/app/templates/modal/employer_signup_modal.jade +++ b/app/templates/modal/employer_signup_modal.jade @@ -2,7 +2,7 @@ extends /templates/modal/modal_base block modal-header-content if userIsAnonymous || !userIsAuthorized - h3(data-i18n="employer_signup.title") Sign up to hire CodeCombat players! + h3(data-i18n="employer_signup.title") Sign Up to Hire CodeCombat Players else h3 CodeCombat Placement Agreement @@ -13,28 +13,17 @@ block modal-body-content else if sentMoreInfoEmail | Thanks! You should receive an email from George shortly. else - h4(data-i18n="employer_signup.sub_heading") Let us find your next brilliant developers. - p Create an account to get started! .form#signup-form .form-group - label.control-label(for="signup-email", data-i18n="general.email") Email - input#signup-email.form-control.input-large(name="email",type="email") - .form-group - label.control-label(for="signup-password", data-i18n="general.password") Password - input#signup-password.input-large.form-control(name="password", type="password") + input#signup-email.form-control.input-large(name="email",type="email" placeholder="Email") + .form-group + input#signup-password.input-large.form-control(name="password", type="password" placeholder="Password") .modal-footer.linkedin button.btn.btn-primary(id="create-account-button") Create Account br br | Already have a CodeCombat account? a.login-link(data-toggle="coco-modal", data-target="modal/auth") Log in to continue! - h4 Want more information first? - p Enter your email and George, our CEO, will contact you shortly. - .form - .form-group - label.control-label(for="more-info-email", data-i18n="general.email") Email - input#more-info-email.form-control.input-large(name="more-info-email",type="email") - button.btn.btn-primary(id="more-info-button") Send me more information! else if !userIsAuthorized .modal-footer.linkedin p Please sign into your LinkedIn account to verify your identity. diff --git a/app/views/employers_view.coffee b/app/views/employers_view.coffee index 050887ed3..8016cdaab 100644 --- a/app/views/employers_view.coffee +++ b/app/views/employers_view.coffee @@ -179,7 +179,7 @@ module.exports = class EmployersView extends View # $('.nano').nanoScroller({scrollTo: $(window.location.hash)}) checkForEmployerSignupHash: => - if window.location.hash is '#employerSignupLoggingIn' and not ('employer' in me.get('permissions')) + if window.location.hash is '#employerSignupLoggingIn' and not ('employer' in me.get('permissions')) and not me.isAdmin() @openModalView application.router.getView('modal/employer_signup', '_modal') window.location.hash = '' diff --git a/app/views/kinds/ModalView.coffee b/app/views/kinds/ModalView.coffee index ad25b3c09..b2fecf1ce 100644 --- a/app/views/kinds/ModalView.coffee +++ b/app/views/kinds/ModalView.coffee @@ -32,6 +32,10 @@ module.exports = class ModalView extends CocoView afterRender: -> super() + if Backbone.history.fragment is "employers" + $(@$el).find(".background-wrapper").each -> + $(this).addClass("employer-modal-background-wrapper").removeClass("background-wrapper") + if @modalWidthPercent @$el.find('.modal-dialog').css width: "#{@modalWidthPercent}%" @$el.on 'hide.bs.modal', => diff --git a/app/views/modal/auth_modal.coffee b/app/views/modal/auth_modal.coffee index 81edc7dd4..5f486281e 100644 --- a/app/views/modal/auth_modal.coffee +++ b/app/views/modal/auth_modal.coffee @@ -30,8 +30,9 @@ module.exports = class AuthModalView extends View application.tracker.trackEvent 'Started Signup', authModalTitle: c.title, descriptionOn: c.descriptionOn c.mode = @mode c.formValues = @previousFormInputs or {} + c.onEmployersPage = Backbone.history.fragment is "employers" c - + afterInsert: -> super() _.delay application.router.renderLoginButtons, 500 From f704a33ece2ebb0756f5f8d672e5ba13f212996a Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Mon, 7 Jul 2014 23:19:07 -0700 Subject: [PATCH 04/11] Table styling/ copy edit --- app/styles/employers.sass | 13 ++++++++++++- app/templates/employers.jade | 11 +++++------ app/views/employers_view.coffee | 1 + 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/styles/employers.sass b/app/styles/employers.sass index c88e1e3c6..78437d593 100644 --- a/app/styles/employers.sass +++ b/app/styles/employers.sass @@ -146,10 +146,21 @@ margin-top: 10px padding-bottom: 5px padding-top: 10px + .candidate-name-cell + position: relative + top: 10px + //refactor later, bad practice + + .border_row border-bottom: 1px solid #d3d3d3 vertical-align: bottom - padding-top: 0px + td + padding-top: 0px + padding-bottom: 5px + .description_row td + padding-bottom: 0px + padding-top: 15px #results display: inline-block diff --git a/app/templates/employers.jade b/app/templates/employers.jade index 3b3bfc661..8d066ab19 100644 --- a/app/templates/employers.jade +++ b/app/templates/employers.jade @@ -93,9 +93,10 @@ block content td(rowspan=3) .candidate-picture img(src=candidate.getPhotoURL(50,false,true), alt=profile.name, title=profile.name, width=50) - td - strong - | #{profile.name} + if !isntEmployer + td.candidate-name-cell + strong + | #{profile.name} tr.description_row(data-candidate-id=candidate.id) if curated && curated.shortDescription td.candidate-description #{curated.shortDescription} @@ -136,9 +137,7 @@ block content h3(data-i18n="employers.weeding") We've done the weeding for you. //this will break in i18n. Fix the inlining p(data-i18n="employers.weeding_blurb") - | Every candidate that has a - span.glyphicon.glyphicon-earphone - | icon has already gone through a phone screen with us. We only feature developers that we would work with. + | We only feature developers that we would work with. We've reviewed each profile (in addition to meeting with many of the candidates.) .reason img(class="employer_icon" src="/images/pages/employer/employer_icon3.png") h3(data-i18n="employers.pass_screen") They will pass your technical screen. diff --git a/app/views/employers_view.coffee b/app/views/employers_view.coffee index 8016cdaab..984e18365 100644 --- a/app/views/employers_view.coffee +++ b/app/views/employers_view.coffee @@ -155,6 +155,7 @@ module.exports = class EmployersView extends View ctx.moment = moment ctx._ = _ ctx.numberOfCandidates = ctx.featuredCandidates.length + ctx.isntEmployer = not (@isEmployer() or me.isAdmin()) ctx isEmployer: -> From a26c8e4659170361dc18ea8baec8063004f25fe2 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Mon, 8 Sep 2014 14:13:19 -0700 Subject: [PATCH 05/11] Reenabling on surface mouse moved. --- app/views/editor/level/thangs/ThangsTabView.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/editor/level/thangs/ThangsTabView.coffee b/app/views/editor/level/thangs/ThangsTabView.coffee index 9fb81044f..fd5201ed2 100644 --- a/app/views/editor/level/thangs/ThangsTabView.coffee +++ b/app/views/editor/level/thangs/ThangsTabView.coffee @@ -384,7 +384,7 @@ module.exports = class ThangsTabView extends CocoView return unless @addThangSprite wop = @surface.camera.screenToWorld x: e.x, y: e.y wop.z = 0.5 - #@adjustThangPos @addThangSprite, @addThangSprite.thang, wop # TODO: this and onSpriteDragged both conflictin' + @adjustThangPos @addThangSprite, @addThangSprite.thang, wop # TODO: this and onSpriteDragged both conflictin' null onSurfaceMouseOver: (e) -> From 858b24a73d1ded1c1e07bee949e26b71579ec924 Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Sat, 27 Sep 2014 09:06:53 -0400 Subject: [PATCH 06/11] Removed superfluous comment --- server/routes/queue.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/routes/queue.coffee b/server/routes/queue.coffee index 169b71371..a2f5988a9 100644 --- a/server/routes/queue.coffee +++ b/server/routes/queue.coffee @@ -36,7 +36,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 From f12dcec0ffe63432671de88de33702a070c346a0 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Fri, 21 Nov 2014 13:08:40 -0800 Subject: [PATCH 07/11] Paths for non-admins. Making sure paths are showing when level first loads and playback ends (not sure why they are not showing up at first otherwise). --- app/lib/surface/Surface.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lib/surface/Surface.coffee b/app/lib/surface/Surface.coffee index 016fc81d6..195dab4b2 100644 --- a/app/lib/surface/Surface.coffee +++ b/app/lib/surface/Surface.coffee @@ -342,6 +342,7 @@ module.exports = Surface = class Surface extends CocoClass @ended = true @setPaused true Backbone.Mediator.publish 'surface:playback-ended', {} + @updatePaths() # TODO: this is a hack to make sure paths are on the first time the level loads else if @currentFrame < @world.totalFrames and @ended @ended = false @setPaused false @@ -586,7 +587,6 @@ module.exports = Surface = class Surface extends CocoClass updatePaths: -> return unless @options.paths and @heroLank - return unless me.isAdmin() # TODO: Fix world thang points, targets, then remove this @hidePaths() return if @world.showPaths is 'never' layerAdapter = @lankBoss.layerAdapters['Path'] From 2574549a786a0951f5210ac7636569b39cbd6208 Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Fri, 28 Nov 2014 11:37:31 -0500 Subject: [PATCH 08/11] Improved error handling --- server/routes/db.coffee | 7 +++++-- server_setup.coffee | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/server/routes/db.coffee b/server/routes/db.coffee index 6b967d38d..9d7a0b5dc 100644 --- a/server/routes/db.coffee +++ b/server/routes/db.coffee @@ -2,6 +2,7 @@ log = require 'winston' errors = require '../commons/errors' handlers = require('../commons/mapping').handlers mongoose = require 'mongoose' +hipchat = require '../hipchat' module.exports.setup = (app) -> # This is hacky and should probably get moved somewhere else, I dunno @@ -41,10 +42,12 @@ module.exports.setup = (app) -> return handler.patch(req, res, parts[1]) if req.route.method is 'patch' and parts[1]? handler[req.route.method](req, res, parts[1..]...) catch error - log.error("Error trying db method #{req.route.method} route #{parts} from #{name}: #{error}") + errorMessage = "Error trying db method #{req?.route?.method} route #{parts} from #{name}: #{error}" + log.error(errorMessage) log.error(error) log.error(error.stack) - errors.notFound(res, "Route #{req.path} not found.") + hipchat.sendTowerHipChatMessage errorMessage + errors.notFound(res, "Route #{req?.path} not found.") getSchema = (req, res, moduleName) -> try diff --git a/server_setup.coffee b/server_setup.coffee index c8cf1631e..a597a013f 100644 --- a/server_setup.coffee +++ b/server_setup.coffee @@ -43,8 +43,7 @@ setupErrorMiddleware = (app) -> app.use (err, req, res, next) -> if err res.status(500).send(error: "Something went wrong!") - hipchat.sendTowerHipChatMessage("The server crashed. Stack trace:
#{err.stack}") - console.log "Got a server error: #{err.stack}" + hipchat.sendTowerHipChatMessage("The server crashed. Path: #{req.path}, Stack trace:
#{err.stack}") else next(err) setupExpressMiddleware = (app) -> From 71e66c4d61e1fe6644d60032220a8cda82f27b80 Mon Sep 17 00:00:00 2001 From: Matt Lott Date: Wed, 17 Dec 2014 10:57:19 -0800 Subject: [PATCH 09/11] No hipchat for analytics.log.event post errors --- server/routes/db.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/routes/db.coffee b/server/routes/db.coffee index 3d490ad60..d35451e7f 100644 --- a/server/routes/db.coffee +++ b/server/routes/db.coffee @@ -43,10 +43,13 @@ module.exports.setup = (app) -> handler[req.route.method](req, res, parts[1..]...) catch error errorMessage = "Error trying db method #{req?.route?.method} route #{parts} from #{name}: #{error}" + # TODO: add user info to this log log.error(errorMessage) log.error(error) log.error(error.stack) - hipchat.sendTowerHipChatMessage errorMessage + # TODO: Generally ignore this error: error: Error trying db method get route analytics.log.event from undefined: Error: Cannot find module '../undefined' + unless "#{parts}" is 'analytics.log.event' + hipchat.sendTowerHipChatMessage errorMessage errors.notFound(res, "Route #{req?.path} not found.") getSchema = (req, res, moduleName) -> From 7186bd55922db6f55444a46086ee0603ce229e31 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Thu, 17 Dec 2015 07:03:54 -0800 Subject: [PATCH 10/11] Fix error handling callback --- server/commons/Handler.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/commons/Handler.coffee b/server/commons/Handler.coffee index db10a26dd..883318ed2 100644 --- a/server/commons/Handler.coffee +++ b/server/commons/Handler.coffee @@ -249,7 +249,7 @@ module.exports = class Handler criteria = {} criteria[if nonVersioned then '_id' else 'original'] = mongoose.Types.ObjectId(id) @modelClass.findOne(criteria, project).sort(sort).exec (err, document) -> - return done(err) if err + return callback err if err callback(null, document?.toObject() or null) funcs = {} From f8091443e9108d1114d4761f8c53cf3dabb7386a Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Fri, 18 Dec 2015 13:26:47 -0800 Subject: [PATCH 11/11] Lower the number of rerenderings needed when spritesheets get full. Add a jitSpritesheets query variable option for comparing performance of prerendered spritesheets. --- app/lib/LevelLoader.coffee | 2 +- app/lib/sprites/SpriteBuilder.coffee | 1 + app/lib/surface/LayerAdapter.coffee | 9 +++++++-- server/levels/thangs/thang_type_handler.coffee | 12 ++++++++++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/lib/LevelLoader.coffee b/app/lib/LevelLoader.coffee index 84ed7fe45..b93a02306 100644 --- a/app/lib/LevelLoader.coffee +++ b/app/lib/LevelLoader.coffee @@ -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) -> diff --git a/app/lib/sprites/SpriteBuilder.coffee b/app/lib/sprites/SpriteBuilder.coffee index 43c967c4a..3329a27d3 100644 --- a/app/lib/sprites/SpriteBuilder.coffee +++ b/app/lib/sprites/SpriteBuilder.coffee @@ -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 diff --git a/app/lib/surface/LayerAdapter.coffee b/app/lib/surface/LayerAdapter.coffee index c7a380a63..52569ac7f 100644 --- a/app/lib/surface/LayerAdapter.coffee +++ b/app/lib/surface/LayerAdapter.coffee @@ -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 = [] diff --git a/server/levels/thangs/thang_type_handler.coffee b/server/levels/thangs/thang_type_handler.coffee index 56f06b625..246c6b4bd 100644 --- a/server/levels/thangs/thang_type_handler.coffee +++ b/server/levels/thangs/thang_type_handler.coffee @@ -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()