Random thangs are now created and positioned in the thangs view

This commit is contained in:
Jayant Jain 2014-06-26 21:40:11 +05:30
parent 74205b31d2
commit 38bed0ee93

View file

@ -228,6 +228,8 @@ module.exports = class ThangsTabView extends View
console.log e
for thang in e.thangs
console.log thang.id, thang.pos
@selectAddThangType thang.id
@addThang @addThangType, thang.pos
# TODO: figure out a good way to have all Surface clicks and Treema clicks just proxy in one direction, so we can maintain only one way of handling selection and deletion
onExtantThangSelected: (e) ->
@ -280,6 +282,7 @@ module.exports = class ThangsTabView extends View
@selectAddThang {target: icons[nextSelectedIndex]}
selectAddThangType: (type, @cloneSourceThang) ->
console.log type
if _.isString type
type = _.find @supermodel.getModels(ThangType), (m) -> m.get('name') is type
pos = @addThangSprite?.thang.pos # Maintain old sprite's pos if we have it
@ -397,6 +400,7 @@ module.exports = class ThangsTabView extends View
@editThang thangID: id if id
addThang: (thangType, pos) ->
console.log thangType, pos
thangID = Thang.nextID(thangType.get('name'), @world) until thangID and not @thangsTreema.get "id=#{thangID}"
if @cloneSourceThang
components = _.cloneDeep @thangsTreema.get "id=#{@cloneSourceThang.id}/components"