diff options
Diffstat (limited to 'public/assets/javascripts/rectangles/engine')
9 files changed, 80 insertions, 39 deletions
diff --git a/public/assets/javascripts/rectangles/engine/map/ui_editor.js b/public/assets/javascripts/rectangles/engine/map/ui_editor.js index 1ab9c73..c838b8b 100644 --- a/public/assets/javascripts/rectangles/engine/map/ui_editor.js +++ b/public/assets/javascripts/rectangles/engine/map/ui_editor.js @@ -70,6 +70,9 @@ Map.UI.Editor = function(map){ Rooms.remove(room) app.tube("builder-destroy-room", room) + + // TODO: watch individual scenery object here + Minotaur.watch( app.router.editorView.settings ) return } else if (intersects.length) { @@ -178,6 +181,9 @@ Map.UI.Editor = function(map){ Rooms.rebuild() app.tube("builder-pick-room", room) + + // TODO: watch individual scenery object here + Minotaur.watch( app.router.editorView.settings ) } } if (base.resizing || base.dragging) { @@ -196,6 +202,9 @@ Map.UI.Editor = function(map){ redo: base.dragging.copy() }) Rooms.rebuild() + + // TODO: watch individual scenery object here + Minotaur.watch( app.router.editorView.settings ) } var intersects = Rooms.filter(function(r){ @@ -231,6 +240,10 @@ Map.UI.Editor = function(map){ redo: intersects[0].copy() }) Rooms.rebuild() + + // TODO: watch individual scenery object here + Minotaur.watch( app.router.editorView.settings ) + wheelState = null }, 250) } diff --git a/public/assets/javascripts/rectangles/engine/scenery/_scenery.js b/public/assets/javascripts/rectangles/engine/scenery/_scenery.js index 3d3067f..24c2602 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/_scenery.js +++ b/public/assets/javascripts/rectangles/engine/scenery/_scenery.js @@ -6,7 +6,7 @@ var Scenery = new function(){ base.list = {} base.nextMedia = null - base.mouse = new mouse ({ use_offset: false }) + base.mouse = new mouse ({ use_offset: false, mousedownUsesCapture: true }) base.init = function(){ base.resize.init() diff --git a/public/assets/javascripts/rectangles/engine/scenery/move.js b/public/assets/javascripts/rectangles/engine/scenery/move.js index 7d148cf..12705d3 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/move.js +++ b/public/assets/javascripts/rectangles/engine/scenery/move.js @@ -2,7 +2,7 @@ Scenery.move = function(base){ var x, y, z, position, dimension, bounds - var dragging = false + var dragging = false, moved = false var oldState this.bind = function(){ @@ -22,18 +22,9 @@ Scenery.move = function(base){ } function down (e, cursor){ - if (e.target != base.mx.el) return; + if (e.target != base.mx.el && (e.target != base.mx.overlay)) return; if (editor.permissions.destroy) { - UndoStack.push({ - type: 'destroy-scenery', - undo: base.serialize(), - redo: { id: base.id }, - }) - - // TODO: watch individual scenery object here - Minotaur.watch( app.router.editorView.settings ) - - Scenery.remove(base.id) + base.remove() return } @@ -45,6 +36,7 @@ Scenery.move = function(base){ return } dragging = true + moved = false x = base.mx.x y = base.mx.y z = base.mx.z @@ -59,6 +51,8 @@ Scenery.move = function(base){ function drag (e, cursor){ if (! dragging) return + + moved = true var flipX = base.wall.side & (FRONT | RIGHT) @@ -89,21 +83,23 @@ Scenery.move = function(base){ function up (e, cursor){ if (! dragging || ! oldState) return - - dragging = false - document.body.classList.remove("dragging") + + if (moved) { + UndoStack.push({ + type: 'update-scenery', + undo: oldState, + redo: base.serialize(), + }) - UndoStack.push({ - type: 'update-scenery', - undo: oldState, - redo: base.serialize(), - }) + // TODO: watch individual scenery object here + Minotaur.watch( app.router.editorView.settings ) + } - // TODO: watch individual scenery object here - Minotaur.watch( app.router.editorView.settings ) - + dragging = moved = false oldState = null - } + document.body.classList.remove("dragging") + + } function switch_wall (e, target, cursor){ if (! dragging) return diff --git a/public/assets/javascripts/rectangles/engine/scenery/resize.js b/public/assets/javascripts/rectangles/engine/scenery/resize.js index 0ce976e..e424829 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/resize.js +++ b/public/assets/javascripts/rectangles/engine/scenery/resize.js @@ -88,8 +88,8 @@ Scenery.resize = new function(){ // pick a new object to focus on and show the dots base.show = function(new_object) { // if (obj === new_object) return + if (! new_object) return obj = new_object - base.add_dots() base.rotate_dots() base.move_dots() diff --git a/public/assets/javascripts/rectangles/engine/scenery/types/_object.js b/public/assets/javascripts/rectangles/engine/scenery/types/_object.js index 4e5e2c5..10ba2b0 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/types/_object.js +++ b/public/assets/javascripts/rectangles/engine/scenery/types/_object.js @@ -62,20 +62,43 @@ Scenery.types.base = Fiber.extend(function(base){ bind: function(){ this.move.bind() - $(this.mx.el).bind({ - mouseenter: this.enter, - mouseleave: this.leave, - }) +// $(this.mx.el).bind({ +// mouseenter: this.enter, +// mouseleave: this.leave, +// }) }, unbind: function(){ this.move.unbind() - $(this.mx.el).unbind({ - mouseenter: this.enter, - mouseleave: this.leave, - }) +// $(this.mx.el).unbind({ +// mouseenter: this.enter, +// mouseleave: this.leave, +// }) }, + remove: function(){ + UndoStack.push({ + type: 'destroy-scenery', + undo: this.serialize(), + redo: { id: this.id }, + }) + + // TODO: watch individual scenery object here + Minotaur.watch( app.router.editorView.settings ) + + Scenery.remove(this.id) + + Scenery.resize.hide() + if (app.controller.mediaEditor) { + app.controller.mediaEditor.tainted = false + app.controller.mediaEditor.hide() + } + if (app.controller.textEditor) { + app.controller.textEditor.tainted = false + app.controller.textEditor.hide() + } + }, + destroy: function(){ this.unbind() scene.remove(this.mx) diff --git a/public/assets/javascripts/rectangles/engine/scenery/types/image.js b/public/assets/javascripts/rectangles/engine/scenery/types/image.js index 10fc917..848f8d4 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/types/image.js +++ b/public/assets/javascripts/rectangles/engine/scenery/types/image.js @@ -55,6 +55,7 @@ Scenery.types.image = Scenery.types.base.extend(function(base){ this.mx.move(data.position) this.mx.ops.width = data.dimensions.a this.mx.ops.height = data.dimensions.b + this.dimensions.deserialize(data.dimensions) }, } diff --git a/public/assets/javascripts/rectangles/engine/scenery/types/text.js b/public/assets/javascripts/rectangles/engine/scenery/types/text.js index a10a332..dd1385f 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/types/text.js +++ b/public/assets/javascripts/rectangles/engine/scenery/types/text.js @@ -68,7 +68,9 @@ Scenery.types.text = Scenery.types.base.extend(function(base){ this.mx.move(data.position) this.mx.ops.width = data.dimensions.a this.mx.ops.height = data.dimensions.b + this.dimensions.deserialize(data.dimensions) }, + } return exports diff --git a/public/assets/javascripts/rectangles/engine/scenery/types/video.js b/public/assets/javascripts/rectangles/engine/scenery/types/video.js index a669a90..d83cc63 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/types/video.js +++ b/public/assets/javascripts/rectangles/engine/scenery/types/video.js @@ -117,6 +117,7 @@ Scenery.types.video = Scenery.types.base.extend(function(base){ this.mx.move(data.position) this.mx.ops.width = data.dimensions.a this.mx.ops.height = data.dimensions.b + this.dimensions.deserialize(data.dimensions) }, } diff --git a/public/assets/javascripts/rectangles/engine/scenery/undo.js b/public/assets/javascripts/rectangles/engine/scenery/undo.js index 3deb764..6ad9e0d 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/undo.js +++ b/public/assets/javascripts/rectangles/engine/scenery/undo.js @@ -4,12 +4,13 @@ type: "create-scenery", undo: function(state){ Scenery.remove(state.id) + Scenery.resize.hide() // TODO: watch individual scenery object here Minotaur.watch( app.router.editorView.settings ) }, redo: function(state){ - Scenery.deserialize([ state ]) + var scenery = Scenery.deserialize([ state ]) Scenery.resize.show( scenery ) // TODO: watch individual scenery object here @@ -20,9 +21,10 @@ type: "update-scenery", undo: function(state){ var scenery = Scenery.find(state.id) + var wall = Walls.find( state.wall_id ) scenery.deserialize(state) - scenery.set_wall(Walls.find( state.wall_id )) + scenery.set_wall({ wall: wall }) if (editor.permissions.resize) { Scenery.resize.show(scenery) @@ -33,13 +35,15 @@ }, redo: function(state){ var scenery = Scenery.find(state.id) + var wall = Walls.find( state.wall_id ) + scenery.deserialize(state) - scenery.set_wall(Walls.find( state.wall_id )) + scenery.set_wall({ wall: wall }) if (editor.permissions.resize) { Scenery.resize.show(scenery) - Scenery.resize.rotate_dots() Scenery.resize.move_dots() + Scenery.resize.rotate_dots() } // TODO: watch individual scenery object here @@ -49,13 +53,14 @@ { type: "destroy-scenery", undo: function(state){ - Scenery.deserialize([ state ]) + var scenery = Scenery.deserialize([ state ]) Scenery.resize.show( scenery ) // TODO: watch individual scenery object here Minotaur.watch( app.router.editorView.settings ) }, redo: function(state){ + Scenery.resize.hide() Scenery.remove(state.id) // TODO: watch individual scenery object here |
