More tweaks to the thang editor.

This commit is contained in:
Scott Erickson 2014-01-06 19:33:36 -08:00
parent 7d638b596f
commit f0147e8f7c
3 changed files with 29 additions and 6 deletions

View file

@ -35,10 +35,17 @@
position: relative position: relative
top: 3px top: 3px
#marker-button
float: right
margin-right: 10px
position: relative
top: 15px
#canvas #canvas
float: right float: right
width: 400px width: 400px
border: 1px solid blue border: 1px solid blue
background-color: lightgray
#settings-col #settings-col
float: left float: left

View file

@ -31,6 +31,9 @@ block content
i.icon-remove i.icon-remove
input#real-upload-button(type="file") input#real-upload-button(type="file")
button.btn.btn-small.btn-primary#marker-button
i.icon-map-marker
div.slider-cell div.slider-cell
| Rotation: | Rotation:
span.rotation-label span.rotation-label
@ -53,7 +56,7 @@ block content
div#settings-col div#settings-col
div#thang-type-treema div#thang-type-treema
canvas#canvas(width="400", height="400", style="background-color:#999999") canvas#canvas(width="400", height="400")
.clearfix .clearfix

View file

@ -27,6 +27,7 @@ module.exports = class ThangTypeEditView extends View
'click #upload-button': -> @$el.find('input#real-upload-button').click() 'click #upload-button': -> @$el.find('input#real-upload-button').click()
'change #real-upload-button': 'animationFileChosen' 'change #real-upload-button': 'animationFileChosen'
'change #animations-select': 'showAnimation' 'change #animations-select': 'showAnimation'
'click #marker-button': 'toggleDots'
subscriptions: subscriptions:
'save-new-version': 'saveNewThangType' 'save-new-version': 'saveNewThangType'
@ -96,16 +97,22 @@ module.exports = class ThangTypeEditView extends View
@torsoDot = @makeDot('blue') @torsoDot = @makeDot('blue')
@mouthDot = @makeDot('yellow') @mouthDot = @makeDot('yellow')
@aboveHeadDot = @makeDot('green') @aboveHeadDot = @makeDot('green')
@stage.addChild(@makeDot('red'), @torsoDot, @mouthDot, @aboveHeadDot) @groundDot = @makeDot('red')
@stage.addChild(@groundDot, @torsoDot, @mouthDot, @aboveHeadDot)
@updateGrid() @updateGrid()
@refreshAnimation() @refreshAnimation()
createjs.Ticker.setFPS(30) createjs.Ticker.setFPS(30)
createjs.Ticker.addEventListener("tick", @stage) createjs.Ticker.addEventListener("tick", @stage)
toggleDots: ->
@showDots = not @showDots
@updateDots()
updateDots: -> updateDots: ->
@stage.removeChild(@torsoDot, @mouthDot, @aboveHeadDot) @stage.removeChild(@torsoDot, @mouthDot, @aboveHeadDot, @groundDot)
return unless @currentSprite return unless @currentSprite
return unless @showDots
torso = @currentSprite.getOffset 'torso' torso = @currentSprite.getOffset 'torso'
mouth = @currentSprite.getOffset 'mouth' mouth = @currentSprite.getOffset 'mouth'
aboveHead = @currentSprite.getOffset 'aboveHead' aboveHead = @currentSprite.getOffset 'aboveHead'
@ -115,13 +122,13 @@ module.exports = class ThangTypeEditView extends View
@mouthDot.y = CENTER.y + mouth.y * @scale @mouthDot.y = CENTER.y + mouth.y * @scale
@aboveHeadDot.x = CENTER.x + aboveHead.x * @scale @aboveHeadDot.x = CENTER.x + aboveHead.x * @scale
@aboveHeadDot.y = CENTER.y + aboveHead.y * @scale @aboveHeadDot.y = CENTER.y + aboveHead.y * @scale
@stage.addChild(@torsoDot, @mouthDot, @aboveHeadDot) @stage.addChild(@groundDot, @torsoDot, @mouthDot, @aboveHeadDot)
updateGrid: -> updateGrid: ->
grid = new createjs.Container() grid = new createjs.Container()
line = new createjs.Shape() line = new createjs.Shape()
width = 1000 width = 1000
line.graphics.beginFill('#000000').drawRect(-width/2, -0.5, width, 1) line.graphics.beginFill('#666666').drawRect(-width/2, -0.5, width, 0.5)
line.x = CENTER.x line.x = CENTER.x
line.y = CENTER.y line.y = CENTER.y
@ -343,14 +350,20 @@ module.exports = class ThangTypeEditView extends View
if obj?.bounds if obj?.bounds
obj.regX = obj.bounds.x + obj.bounds.width / 2 obj.regX = obj.bounds.x + obj.bounds.width / 2
obj.regY = obj.bounds.y + obj.bounds.height / 2 obj.regY = obj.bounds.y + obj.bounds.height / 2
else if obj?.frameBounds?[0]
bounds = obj.frameBounds[0]
obj.regX = bounds.x + bounds.width / 2
obj.regY = bounds.y + bounds.height / 2
@showDisplayObject(obj) if obj @showDisplayObject(obj) if obj
obj.y = 200 if obj # truly center the container obj.y = 200 if obj # truly center the container
@showingSelectedNode = true @showingSelectedNode = true
@currentSprite?.destroy() @currentSprite?.destroy()
@currentSprite = null @currentSprite = null
@updateScale() @updateScale()
@grid.alpha = 0.0
stopShowingSelectedNode: -> stopShowingSelectedNode: ->
return unless @showingSelectedNode return unless @showingSelectedNode
@grid.alpha = 1.0
@showAnimation() @showAnimation()
@showingSelectedNode = false @showingSelectedNode = false