summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/engine/map
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/rectangles/engine/map')
-rw-r--r--public/assets/javascripts/rectangles/engine/map/_map.js11
-rw-r--r--public/assets/javascripts/rectangles/engine/map/ui_editor.js18
2 files changed, 21 insertions, 8 deletions
diff --git a/public/assets/javascripts/rectangles/engine/map/_map.js b/public/assets/javascripts/rectangles/engine/map/_map.js
index d5a8442..99ede82 100644
--- a/public/assets/javascripts/rectangles/engine/map/_map.js
+++ b/public/assets/javascripts/rectangles/engine/map/_map.js
@@ -65,13 +65,14 @@ var Map = function(opt){
canvas.width = base.dimensions.a = window.innerWidth
canvas.height = base.dimensions.b = window.innerHeight
}
-
- base.update = function(){
- base.draw.animate()
- }
-
+
base.toggle = function(){
$(base.el).toggle()
}
}
+
+Map.prototype.update = function(){
+ this.draw && this.draw.animate()
+}
+
diff --git a/public/assets/javascripts/rectangles/engine/map/ui_editor.js b/public/assets/javascripts/rectangles/engine/map/ui_editor.js
index 262272b..ea7a356 100644
--- a/public/assets/javascripts/rectangles/engine/map/ui_editor.js
+++ b/public/assets/javascripts/rectangles/engine/map/ui_editor.js
@@ -20,6 +20,13 @@ Map.UI.Editor = function(map){
update: mousewheel,
})
+ base.permissions = new Permissions({
+ create: true,
+ move: true,
+ resize: true,
+ destroy: false,
+ })
+
//
function down (e, cursor){
@@ -43,12 +50,17 @@ Map.UI.Editor = function(map){
return r.focused = r.rect.contains(cursor.x.a, cursor.y.a)
})
- if (intersects.length) {
+ if (intersects.length && base.permissions.destroy) {
+ base.mouse.down = false
+ Rooms.remove(intersects[0])
+ return
+ }
+ else if (intersects.length && (base.permissions.move || base.permissions.resize)) {
base.dragging = intersects[0]
- base.resizing = base.dragging.rect.nearEdge(cursor.x.a, cursor.y.a, resize_margin / map.zoom)
+ base.resizing = base.permissions.resize && base.dragging.rect.nearEdge(cursor.x.a, cursor.y.a, resize_margin / map.zoom)
base.dragging.rect.translation.sides = base.resizing
}
- else {
+ else if (base.permissions.create) {
base.creating = true
}