summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/builder/BuilderInfo.js
blob: 53a122d1b5e2abc6e6d850cb569df31551ddc163 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
var BuilderInfo = View.extend({
	el: "#builderInfo",

	events: {
		"keydown": 'stopPropagation',
		"change [name=x]": 'changePosition',
		"change [name=z]": 'changePosition',
		"change [name=width]": 'changeDimensions',
		"change [name=depth]": 'changeDimensions',
		"change [name=height]": 'changeDimensions',
		"change [name=units]": 'changeUnits',
		"change [name=resolution]": 'changeResolution',
		"change [name=camera-height]": 'changeCameraHeight',
	},
	
	initialize: function(opt){
		this.parent = opt.parent
		this.$x = this.$("[name=x]")
		this.$z = this.$("[name=z]")
		this.$width = this.$("[name=width]")
		this.$depth = this.$("[name=depth]")
		this.$height = this.$("[name=height]")
		this.$units = this.$("[name=units]")
		this.$resolution = this.$("[name=resolution]")
		this.$cameraHeight = this.$("[name=camera-height]")
		app.on("builder-pick-room", this.pick.bind(this))
		app.on("builder-destroy-room", this.destroy.bind(this))
	},

	toggle: function(state){
		this.$el.toggleClass("active", state)
	},
	
	show: function(){	
		this.toggle(true)
	},
	
	hide: function(){	
		this.toggle(false)
	},

	room: null,
	
	pick: function(room){
		this.room = room
		this.$width.val( room.rect.x.length() )
		this.$depth.val( room.rect.y.length() )
		this.$height.val( room.height )
		this.$x.val( room.rect.x.a )
		this.$z.val( room.rect.y.a )

		console.log(room)
	},

	destroy: function(room){
		this.room = null
		this.hide()
	},
	
	changeDimensions: function(){
	},
	
	changeUnits: function(){
	},
	
	changeCameraHeight: function(){
	},

})