summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/engine
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/rectangles/engine')
-rw-r--r--public/assets/javascripts/rectangles/engine/map/ui_editor.js28
-rw-r--r--public/assets/javascripts/rectangles/engine/rooms/_rooms.js4
-rw-r--r--public/assets/javascripts/rectangles/engine/scenery/undo.js12
3 files changed, 42 insertions, 2 deletions
diff --git a/public/assets/javascripts/rectangles/engine/map/ui_editor.js b/public/assets/javascripts/rectangles/engine/map/ui_editor.js
index c838b8b..d1b0b89 100644
--- a/public/assets/javascripts/rectangles/engine/map/ui_editor.js
+++ b/public/assets/javascripts/rectangles/engine/map/ui_editor.js
@@ -42,6 +42,7 @@ Map.UI.Editor = function(map){
cursor.y.div(map.dimensions.b).sub(0.5).mul(map.dimensions.b / map.zoom).sub(map.center.b)
if (e.ctrlKey || e.which === 3) {
+ if (Rooms.regions.length == 0) return
cursor.quantize(1/map.zoom)
map.center.a = cursor.x.a
map.center.b = -cursor.y.a
@@ -226,7 +227,32 @@ Map.UI.Editor = function(map){
return r.focused // = r.rect.contains(cursor.x.a, cursor.y.a)
})
- if (intersects.length) {
+ if (intersects.length && window.heightIsGlobal) {
+ var rooms = Rooms.values()
+ wheelState = wheelState || rooms[0].height
+ var height = clamp( ~~(rooms[0].height + deltaY * 2), height_min, height_max )
+ rooms.forEach(function(room){
+ room.height = height
+ })
+
+ app.tube("builder-pick-room", intersects[0])
+
+ clearTimeout(wheelTimeout)
+ wheelTimeout = setTimeout(function(){
+ UndoStack.push({
+ type: "update-rooms-height",
+ undo: wheelState,
+ redo: height
+ })
+ Rooms.rebuild()
+
+ // TODO: watch individual scenery object here
+ Minotaur.watch( app.router.editorView.settings )
+
+ wheelState = null
+ }, 250)
+ }
+ else if (intersects.length) {
wheelState = wheelState || intersects[0].copy()
intersects[0].height = clamp( ~~(intersects[0].height + deltaY * 2), height_min, height_max )
diff --git a/public/assets/javascripts/rectangles/engine/rooms/_rooms.js b/public/assets/javascripts/rectangles/engine/rooms/_rooms.js
index 5686aba..46c1d7f 100644
--- a/public/assets/javascripts/rectangles/engine/rooms/_rooms.js
+++ b/public/assets/javascripts/rectangles/engine/rooms/_rooms.js
@@ -81,6 +81,10 @@
base.forEach = function(f){
return base.values().forEach(f)
}
+
+ base.some = function(f){
+ return base.values().some(f)
+ }
base.map = function(f){
return base.values().map(f)
diff --git a/public/assets/javascripts/rectangles/engine/scenery/undo.js b/public/assets/javascripts/rectangles/engine/scenery/undo.js
index 6ad9e0d..8b85d02 100644
--- a/public/assets/javascripts/rectangles/engine/scenery/undo.js
+++ b/public/assets/javascripts/rectangles/engine/scenery/undo.js
@@ -111,7 +111,17 @@
Rooms.rebuild()
},
},
-
+
+ {
+ type: "update-rooms-height",
+ undo: function(state){
+ var rooms = Rooms.values()
+ rooms.forEach(function(room){
+ room.height = state
+ })
+ },
+ },
+
//
{