summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/engine/map/ui_minimap.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/rectangles/engine/map/ui_minimap.js')
-rw-r--r--public/assets/javascripts/rectangles/engine/map/ui_minimap.js74
1 files changed, 11 insertions, 63 deletions
diff --git a/public/assets/javascripts/rectangles/engine/map/ui_minimap.js b/public/assets/javascripts/rectangles/engine/map/ui_minimap.js
index d8f39b0..fabbdb9 100644
--- a/public/assets/javascripts/rectangles/engine/map/ui_minimap.js
+++ b/public/assets/javascripts/rectangles/engine/map/ui_minimap.js
@@ -21,11 +21,16 @@ Map.UI.Minimap = function(map){
update: mousewheel,
})
+ var x, z
+
//
function down (e, cursor){
cursor.x.div(map.dimensions.a).add(0.5).mul(map.dimensions.a / map.zoom).add(map.center.a)
cursor.y.div(map.dimensions.b).sub(0.5).mul(map.dimensions.b / map.zoom).sub(map.center.b)
+
+ x = scene.camera.x
+ z = scene.camera.z
if (e.ctrlKey || e.which === 3) {
cursor.quantize(1/map.zoom)
@@ -39,23 +44,6 @@ Map.UI.Minimap = function(map){
e.stopPropagation()
return
}
-
- var intersects = Rooms.filter(function(r){
- return r.focused = r.rect.contains(cursor.x.a, cursor.y.a)
- })
-
- if (intersects.length) {
- base.dragging = intersects[0]
- base.resizing = base.dragging.rect.nearEdge(cursor.x.a, cursor.y.a, resize_margin / map.zoom)
- base.dragging.rect.translation.sides = base.resizing
- }
- else {
- base.creating = true
- }
-
- if (e.shiftKey && base.dragging) {
- base.dragging.rect.quantize(10/map.zoom)
- }
}
function move (e, cursor) {
@@ -67,24 +55,11 @@ Map.UI.Minimap = function(map){
cursor.x.b = ((cursor.x.b/map.dimensions.a)+0.5) * map.dimensions.a / map.zoom + map.center.a
cursor.y.b = ((cursor.y.b/map.dimensions.b)-0.5) * map.dimensions.b / map.zoom - map.center.b
- if (base.resizing) {
- var x_length = base.dragging.rect.x.length(),
- y_length = base.dragging.rect.y.length()
+ scene.camera.x = x + cursor.x.magnitude() * map.zoom * 16
+ scene.camera.z = z + cursor.y.magnitude() * map.zoom * 16
+ Rooms.mover.room = null
- if (base.resizing & LEFT) {
- base.dragging.rect.translation.a = clamp( cursor.x.magnitude(), x_length - side_max, x_length - side_min )
- }
- if (base.resizing & RIGHT) {
- base.dragging.rect.translation.a = clamp( cursor.x.magnitude(), side_min - x_length, side_max - x_length )
- }
- if (base.resizing & FRONT) {
- base.dragging.rect.translation.b = clamp( cursor.y.magnitude(), y_length - side_max, y_length - side_min )
- }
- if (base.resizing & BACK) {
- base.dragging.rect.translation.b = clamp( cursor.y.magnitude(), side_min - y_length, side_max - y_length )
- }
- }
- else if (base.dragging) {
+ if (base.dragging) {
base.dragging.rect.translation.a = cursor.x.magnitude()
base.dragging.rect.translation.b = cursor.y.magnitude()
}
@@ -94,38 +69,11 @@ Map.UI.Minimap = function(map){
new_cursor.x.div(map.dimensions.a).add(0.5).mul(map.dimensions.a / map.zoom).add(map.center.a)
new_cursor.y.div(map.dimensions.b).sub(0.5).mul(map.dimensions.b / map.zoom).sub(map.center.b)
- if (base.creating) {
- if (cursor.height() > side_min && cursor.width() > side_min) {
- cursor.x.abs().quantize(1)
- cursor.y.abs().quantize(1)
- Rooms.add_with_rect( cursor )
- }
- }
-
- if (base.resizing) {
- base.dragging.rect.resize()
- }
- else if (base.dragging) {
- base.dragging.rect.translate()
- }
-
- base.creating = base.dragging = base.resizing = false
+ base.dragging = false
}
function mousewheel (e, val, delta){
- var cursor = base.mouse.cursor
-
- var intersects = Rooms.filter(function(r){
- return r.focused = r.rect.contains(cursor.x.a, cursor.y.a)
- })
-
- if (intersects.length) {
- intersects[0].height = clamp( ~~(intersects[0].height - delta), height_min, height_max )
- Rooms.clipper.update()
- }
- else {
- map.set_zoom(map.zoom_exponent - delta/20)
- }
+ map.set_zoom(map.zoom_exponent - delta/20)
}
function rightclick (e){