Tweaks for thang portraits.

This commit is contained in:
Scott Erickson 2014-01-06 15:36:35 -08:00
parent f656a4f4cf
commit 27e7b6c240
4 changed files with 13 additions and 7 deletions
app

View file

@ -84,7 +84,8 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
else
sprite = new createjs.Shape()
sprite.scaleX = sprite.scaleY = 1 / @options.resolutionFactor
if @thangType.get('name') in ['Dungeon Floor', 'Grass', 'Goal Trigger', 'Obstacle'] # temp, until these are re-exported with perspective
# temp, until these are re-exported with perspective
if @options.camera and @thangType.get('name') in ['Dungeon Floor', 'Grass', 'Goal Trigger', 'Obstacle']
sprite.scaleY *= @options.camera.y2x
@displayObject = new createjs.Container()
@imageObject = sprite

View file

@ -148,7 +148,7 @@ module.exports = class ThangType extends CocoModel
getPortraitImage: (spriteOptionsOrKey, size=100) ->
src = @getPortraitSource(spriteOptionsOrKey, size)
$('<img />').attr('src', url)
$('<img />').attr('src', src)
getPortraitSource: (spriteOptionsOrKey, size=100) ->
key = spriteOptionsOrKey
@ -167,7 +167,7 @@ module.exports = class ThangType extends CocoModel
stage.update()
stage.toDataURL()
uploadGenericPortrait: ->
uploadGenericPortrait: (callback) ->
src = @getPortraitSource()
return unless src
src = src.replace('data:image/png;base64,', '').replace(/\ /g, '+')
@ -177,7 +177,7 @@ module.exports = class ThangType extends CocoModel
path: "db/thang.type/#{@get('original')}"
b64png: src
force: 'true'
$.ajax('/file', { type: 'POST', data: body, success: @onFileUploaded })
$.ajax('/file', { type: 'POST', data: body, success: callback or @onFileUploaded })
onFileUploaded: =>
console.log 'Image uploaded'

View file

@ -286,7 +286,7 @@ module.exports = class ThangTypeEditView extends View
res = newThangType.save()
return unless res
modal = @$el.find('#save-modal')
modal = $('#save-version-modal')
@enableModalInProgress(modal)
res.error =>
@ -294,7 +294,8 @@ module.exports = class ThangTypeEditView extends View
res.success =>
url = "/editor/thang/#{newThangType.get('slug') or newThangType.id}"
document.location.href = url
newThangType.uploadGenericPortrait =>
document.location.href = url
clearRawData: ->
@thangType.resetRawData()

View file

@ -7,4 +7,8 @@ module.exports = class ThangTypeHomeView extends SearchView
modelURL: '/db/thang.type'
tableTemplate: require 'templates/editor/thang/table'
# TODO: do the new thing on click, not just enter
onSearchChange: =>
super()
@$el.find("img").error(-> $(this).hide())
# TODO: do the new thing on click, not just enter