diff options
Diffstat (limited to 'public/assets/javascripts/ui/editor/Presets.js')
| -rw-r--r-- | public/assets/javascripts/ui/editor/Presets.js | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/public/assets/javascripts/ui/editor/Presets.js b/public/assets/javascripts/ui/editor/Presets.js new file mode 100644 index 0000000..5f5ac35 --- /dev/null +++ b/public/assets/javascripts/ui/editor/Presets.js @@ -0,0 +1,122 @@ +var Presets = View.extend({ + el: "#presets", + + events: { + "mousedown": "stopPropagation", + "click .presets span": "selectPreset", + }, + + presets: { + wireframe: { + wall: [255,255,255], + outline: [0,0,0], + floor: [246,246,246], + ceiling: [255,255,255], + }, + shaded: { + wall: [205,205,204], + outline: [0,0,0], + floor: [109,116,106], + ceiling: [159,163,157], + background: [109,116,106], + }, + "P.Funk": { + wall: [255,63,78], + outline: [255,246,0], + floor: [255,255,0], + ceiling: [225,118,252], + }, + inverse: { + wall: [0,0,0], + outline: [255,255,255], + floor: [0,0,0], + ceiling: [0,0,0], + }, + matrix: { + wall: { src: "http://dumpfm.s3.amazonaws.com/images/20130225/1361818675427-dumpfm-melipone-matrixremixtransfast.gif", scale: 4.0, color: [0,0,0] }, + outline: [0,0,0], + floor: [10,15,10], + ceiling: [0,0,0], + }, + }, + + initialize: function(opt){ + this.parent = opt.parent + + this.$presets = this.$(".presets") + _.keys(this.presets).forEach(function(name){ + var $swatch = $("<span>") + $swatch.html(capitalize(name)) + $swatch.data('preset', name) + this.$presets.append($swatch) + }.bind(this)) + }, + + modified: true, + lastPreset: "wireframe", + + toggle: function(state){ + this.$el.toggleClass("active", state) + this.parent.cursor.message(state ? "presets" : "start") + if (this.modified) { + this.$(".active").removeClass('active') + } + }, + + show: function(){ + this.toggle(true) + }, + + hide: function(){ + this.toggle(false) + }, + + selectPreset: function(e){ + var preset = $(e.currentTarget).data('preset') + if (! this.presets[preset]) return + this.$(".active").removeClass('active') + $(e.currentTarget).addClass('active') + if (this.modified) { + UndoStack.push({ + type: "choose-preset", + undo: { walls: Walls.serialize(), colors: Walls.copyColors(Walls.colors) }, + redo: preset, + }) + Minotaur.watch( app.router.editorView.settings ) + } + else { + UndoStack.push({ + type: "choose-another-preset", + undo: this.lastPreset, + redo: preset, + }) + Minotaur.watch( app.router.editorView.settings ) + } + this.lastPreset = preset + this.load(this.presets[preset]) + this.modified = false + }, + + loadByName: function(name){ + var preset = this.presets[name] + this.load(preset) + }, + load: function(preset){ + this.parent.colorControl.modes.forEach(function(mode){ + var color + if (! preset[mode].length) { + Walls.setWallpaper[mode](preset[mode]) + color = preset[mode].color + } + else { + Walls.clearWallpaper[mode]() + color = preset[mode] + } + Walls.setColor[mode](color) + this.parent.colorControl.$swatch[ mode ].css("background-color", rgb_string(color)) + }.bind(this)) + this.parent.colorControl.setMode(preset.wall.color ? "wall" : "floor") + Walls.setBodyColor() + }, + +})
\ No newline at end of file |
