diff options
Diffstat (limited to 'public/assets/javascripts/ui/editor/LightControl.js')
| -rw-r--r-- | public/assets/javascripts/ui/editor/LightControl.js | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/public/assets/javascripts/ui/editor/LightControl.js b/public/assets/javascripts/ui/editor/LightControl.js index a3a19c7..5133de2 100644 --- a/public/assets/javascripts/ui/editor/LightControl.js +++ b/public/assets/javascripts/ui/editor/LightControl.js @@ -26,14 +26,25 @@ var LightControl = View.extend({ this.$floorSwatch = this.$("#floor-color") this.$ceilingSwatch = this.$("#ceiling-color") this.$brightnessControl = this.$("#brightness-control") - - this.setMode("wall") - - this.setWallColor(this.wallColor, false) - this.setOutlineColor(this.outlineColor) - this.setFloorColor(this.floorColor) - this.setCeilingColor(this.ceilingColor) }, + + load: function(data){ + this.setWallColor(data.wallColor, false) + this.setOutlineColor(data.outlineColor) + this.setFloorColor(data.floorColor) + this.setCeilingColor(data.ceilingColor) + this.setMode("wall") + }, + + loadDefaults: function(){ + var colors = { + wallColor: app.defaults.wallColor.slice(), + outlineColor: app.defaults.outlineColor.slice(), + floorColor: app.defaults.floorColor.slice(), + ceilingColor: app.defaults.ceilingColor.slice(), + } + this.load(colors) + }, toggle: function(state){ this.$el.toggleClass("active", state); @@ -65,11 +76,6 @@ var LightControl = View.extend({ } }, - wallColor: [255,255,255], - outlineColor: [0,0,0], - floorColor: [246,246,246], - ceilingColor: [255,255,255], - setMode: function (mode) { var color, brightness this.mode = mode @@ -119,10 +125,10 @@ var LightControl = View.extend({ setWallColor: function(rgb, repaint){ repaint = typeof repaint != "undefined" ? repaint : true var rgbColor = rgb_string(rgb) - var rgbaColor = rgba_string(rgb, 0.95) - this.wallColor = rgb + var rgbaColor = rgba_string(rgb, app.defaults.wallOpacity) + Walls.colors.wall = this.wallColor = rgb this.$wallSwatch.css("background-color", rgbColor) - Rooms.walls.forEach(function(wall){ + Walls.forEach(function(wall){ wall.outline(rgbaColor, null) }) }, @@ -130,7 +136,7 @@ var LightControl = View.extend({ setFloorColor: function(rgb, repaint){ repaint = typeof repaint != "undefined" ? repaint : true var rgbColor = rgb_string(rgb) - this.floorColor = rgb + Walls.colors.floor = this.floorColor = rgb this.$floorSwatch.css("background-color", rgbColor) Rooms.forEach(function(room){ room.setFloorColor(rgbColor) @@ -140,7 +146,7 @@ var LightControl = View.extend({ setCeilingColor: function(rgb, repaint){ repaint = typeof repaint != "undefined" ? repaint : true var rgbColor = rgb_string(rgb) - this.ceilingColor = rgb + Walls.colors.ceiling = this.ceilingColor = rgb this.$ceilingSwatch.css("background-color", rgbColor) Rooms.forEach(function(room){ room.setCeilingColor(rgbColor) @@ -150,9 +156,9 @@ var LightControl = View.extend({ setOutlineColor: function(rgb){ repaint = typeof repaint != "undefined" ? repaint : true var rgbColor = rgb_string(rgb) - this.outlineColor = rgb + Walls.colors.outline = this.outlineColor = rgb this.$outlineSwatch.css("background-color", rgbColor) - Rooms.walls.forEach(function(wall){ + Walls.forEach(function(wall){ wall.outline(null, rgbColor) }) }, |
