2014-01-03 13:32:13 -05:00
|
|
|
CocoClass = require 'lib/CocoClass'
|
|
|
|
|
|
|
|
module.exports = class PointChooser extends CocoClass
|
|
|
|
constructor: (@options) ->
|
|
|
|
super()
|
|
|
|
@buildShape()
|
|
|
|
@options.stage.addEventListener 'stagemousedown', @onMouseDown
|
2014-02-26 18:56:05 -05:00
|
|
|
@options.camera.dragDisabled = true
|
2014-01-03 13:32:13 -05:00
|
|
|
|
|
|
|
destroy: ->
|
|
|
|
@options.stage.removeEventListener 'stagemousedown', @onMouseDown
|
2014-02-14 13:57:47 -05:00
|
|
|
super()
|
2014-01-03 13:32:13 -05:00
|
|
|
|
|
|
|
# Called also from WorldSelectModal
|
|
|
|
setPoint: (@point) ->
|
|
|
|
@updateShape()
|
|
|
|
|
|
|
|
buildShape: ->
|
|
|
|
@shape = new createjs.Shape()
|
|
|
|
@shape.alpha = 0.9
|
|
|
|
@shape.mouseEnabled = false
|
2014-06-30 22:16:26 -04:00
|
|
|
@shape.graphics.setStrokeStyle(1, 'round').beginStroke('#000000').beginFill('#fedcba')
|
2014-01-03 13:32:13 -05:00
|
|
|
@shape.graphics.drawCircle(0, 0, 4).endFill()
|
|
|
|
@shape.layerIndex = 100
|
|
|
|
|
|
|
|
onMouseDown: (e) =>
|
|
|
|
return unless key.shift
|
2014-05-16 18:33:49 -04:00
|
|
|
@setPoint @options.camera.screenToWorld {x: e.stageX, y: e.stageY}
|
2014-08-27 15:24:03 -04:00
|
|
|
Backbone.Mediator.publish 'surface:choose-point', point: @point
|
2014-01-03 13:32:13 -05:00
|
|
|
|
|
|
|
updateShape: ->
|
|
|
|
sup = @options.camera.worldToSurface @point
|
|
|
|
@options.surfaceLayer.addChild @shape
|
|
|
|
@shape.x = sup.x
|
|
|
|
@shape.y = sup.y
|