summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/engine/scenery
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/rectangles/engine/scenery')
-rw-r--r--public/assets/javascripts/rectangles/engine/scenery/_scenery.js2
-rw-r--r--public/assets/javascripts/rectangles/engine/scenery/resize.js6
-rw-r--r--public/assets/javascripts/rectangles/engine/scenery/undo.js83
3 files changed, 53 insertions, 38 deletions
diff --git a/public/assets/javascripts/rectangles/engine/scenery/_scenery.js b/public/assets/javascripts/rectangles/engine/scenery/_scenery.js
index 2fd6122..4cf5b06 100644
--- a/public/assets/javascripts/rectangles/engine/scenery/_scenery.js
+++ b/public/assets/javascripts/rectangles/engine/scenery/_scenery.js
@@ -84,7 +84,7 @@ var Scenery = new function(){
base.deserialize = function(scenery_data){
scenery_data.forEach(function(data){
- var wall = Rooms.walls[data.wall_id] || Rooms.walls[0]
+ var wall = Walls.list[data.wall_id] || Walls.first()
var scene_media = base.add({
data: data,
wall: wall,
diff --git a/public/assets/javascripts/rectangles/engine/scenery/resize.js b/public/assets/javascripts/rectangles/engine/scenery/resize.js
index d9cce18..e26c0a7 100644
--- a/public/assets/javascripts/rectangles/engine/scenery/resize.js
+++ b/public/assets/javascripts/rectangles/engine/scenery/resize.js
@@ -109,6 +109,7 @@ Scenery.resize = new function(){
}
base.hide = function () {
+ if (! obj) return
obj = null
dots.forEach(function(dot){
scene.remove(dot)
@@ -175,7 +176,8 @@ Scenery.resize = new function(){
mag = y_sign * mag * sign(height)
}
- obj.mx.scale = ( dimension.a + mag ) / naturalDimension.a // dimension.a // scale * (old_width + mag) / old_width
+ obj.set_scale( ( dimension.a + mag ) / naturalDimension.a )
+ // dimension.a // scale * (old_width + mag) / old_width
// console.log(scale, obj.mx.scale, dimension.a + mag, naturalDimension.a)
@@ -188,6 +190,8 @@ Scenery.resize = new function(){
}
base.move_dots()
+
+ app.router.editorView.mediaEditor.setDimensions()
}
function up (e, cursor){
diff --git a/public/assets/javascripts/rectangles/engine/scenery/undo.js b/public/assets/javascripts/rectangles/engine/scenery/undo.js
index 54ab755..e5624a0 100644
--- a/public/assets/javascripts/rectangles/engine/scenery/undo.js
+++ b/public/assets/javascripts/rectangles/engine/scenery/undo.js
@@ -1,7 +1,7 @@
(function(){
- UndoStack.register([
- {
- type: "create-scenery",
+ UndoStack.register([
+ {
+ type: "create-scenery",
undo: function(state){
Scenery.remove(state.id)
@@ -14,13 +14,13 @@
// TODO: watch individual scenery object here
Minotaur.watch( app.router.editorView.settings )
},
- },
- {
- type: "update-scenery",
+ },
+ {
+ type: "update-scenery",
undo: function(state){
var scenery = Scenery.find(state.id)
scenery.deserialize(state)
- scenery.set_wall(Rooms.walls[ state.wall_id ])
+ scenery.set_wall(Walls.find( state.wall_id ))
if (editor.permissions.resize) {
Scenery.resize.show(scenery)
@@ -32,7 +32,7 @@
redo: function(state){
var scenery = Scenery.find(state.id)
scenery.deserialize(state)
- scenery.set_wall(Rooms.walls[ state.wall_id ])
+ scenery.set_wall(Walls.find( state.wall_id ))
if (editor.permissions.resize) {
Scenery.resize.show(scenery)
@@ -43,9 +43,9 @@
// TODO: watch individual scenery object here
Minotaur.watch( app.router.editorView.settings )
},
- },
- {
- type: "destroy-scenery",
+ },
+ {
+ type: "destroy-scenery",
undo: function(state){
Scenery.deserialize([ state ])
@@ -58,12 +58,12 @@
// TODO: watch individual scenery object here
Minotaur.watch( app.router.editorView.settings )
},
- },
-
- //
-
- {
- type: "create-room",
+ },
+
+ //
+
+ {
+ type: "create-room",
undo: function(room){
Rooms.remove(room)
Rooms.clipper.update()
@@ -71,48 +71,59 @@
redo: function(room){
Rooms.add(new Room(room))
Rooms.clipper.update()
- app.tube("builder-pick-room", room)
+ app.tube("builder-pick-room", room)
},
- },
- {
- type: "update-room",
+ },
+ {
+ type: "update-room",
undo: function(state){
var room = Rooms.list[state.id]
room.rect.assign( state.rect )
room.height = state.height
Rooms.clipper.update()
- app.tube("builder-pick-room", room)
+ app.tube("builder-pick-room", room)
},
redo: function(state){
var room = Rooms.list[state.id]
room.rect.assign( state.rect )
room.height = state.height
Rooms.clipper.update()
- app.tube("builder-pick-room", room)
+ app.tube("builder-pick-room", room)
},
- },
- {
- type: "destroy-room",
+ },
+ {
+ type: "destroy-room",
undo: function(room){
Rooms.add(new Room(room))
Rooms.clipper.update()
- app.tube("builder-pick-room", room)
+ app.tube("builder-pick-room", room)
},
redo: function(room){
Rooms.remove(room)
Rooms.clipper.update()
},
- },
-
- //
+ },
+
+ //
- {
- type: "update-wallpaper",
+ {
+ type: "update-wallpaper",
undo: function(state){
+ var wall = Walls.lookup[state.id]
+ wall.deserialize(state)
+
+ Minotaur.watch( app.router.editorView.settings )
},
- redo: function(state){
+ },
+ {
+ type: "update-colors",
+ undo: function(state){
+ Walls.setColor[ state.mode ]( state.rgb )
+ app.router.editorView.lightControl.setSwatchColor( state.mode, state.rgb )
+
+ Minotaur.watch( app.router.editorView.settings )
},
- },
-
- ])
+ },
+
+ ])
})()