From c777456e398fc0f7aed955596505720e0f13e1a8 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 10 Oct 2014 19:30:19 -0400 Subject: Presets --- public/assets/javascripts/ui/editor/Presets.js | 59 ++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 public/assets/javascripts/ui/editor/Presets.js (limited to 'public/assets/javascripts/ui/editor/Presets.js') diff --git a/public/assets/javascripts/ui/editor/Presets.js b/public/assets/javascripts/ui/editor/Presets.js new file mode 100644 index 0000000..a7e92b6 --- /dev/null +++ b/public/assets/javascripts/ui/editor/Presets.js @@ -0,0 +1,59 @@ +var Presets = View.extend({ + el: "#presets", + + events: { + "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], + }, + pfunk: { + 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], + }, + }, + + initialize: function(opt){ + this.parent = opt.parent + }, + + toggle: function(state){ + this.$el.toggleClass("active", state); + }, + + 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.parent.lightControl.load(this.presets[preset]) + this.$(".active").removeClass('active') + $(e.currentTarget).addClass('active') + }, + +}) \ No newline at end of file -- cgit v1.2.3-70-g09d2 From c31330242541305147a0f2c699d7cc215bd41cd2 Mon Sep 17 00:00:00 2001 From: Julie Lala Date: Tue, 14 Oct 2014 20:59:46 -0400 Subject: color swatches --- .../assets/javascripts/ui/editor/LightControl.js | 1 + public/assets/javascripts/ui/editor/Presets.js | 30 ++++++++++++++++++++++ public/assets/stylesheets/app.css | 19 ++++++++++++++ views/controls/editor/presets.ejs | 4 +++ views/controls/editor/wallpaper.ejs | 2 +- 5 files changed, 55 insertions(+), 1 deletion(-) (limited to 'public/assets/javascripts/ui/editor/Presets.js') diff --git a/public/assets/javascripts/ui/editor/LightControl.js b/public/assets/javascripts/ui/editor/LightControl.js index 3eb2861..166fc50 100644 --- a/public/assets/javascripts/ui/editor/LightControl.js +++ b/public/assets/javascripts/ui/editor/LightControl.js @@ -64,6 +64,7 @@ var LightControl = View.extend({ pick: function(rgb, Lab){ this.labColor = Lab this.setSwatchColor(this.mode, rgb) + console.log(rgb) Walls.setColor[ this.mode ](rgb) }, diff --git a/public/assets/javascripts/ui/editor/Presets.js b/public/assets/javascripts/ui/editor/Presets.js index a7e92b6..1e70aa2 100644 --- a/public/assets/javascripts/ui/editor/Presets.js +++ b/public/assets/javascripts/ui/editor/Presets.js @@ -2,8 +2,26 @@ var Presets = View.extend({ el: "#presets", events: { + "mousedown": "stopPropagation", "click .presets span": "selectPreset", + "click .swatches span": "selectColor", }, + + colors: [ + [255,94,58], + [255,149,0], + [255,219,76], + [76,217,100], + [52,170,220], + [29,98,240], + [198,68,252], + [0,0,0], + [74,74,74], + [125,126,127], + [209,211,212], + [235,235,235], + [255,255,255], + ], presets: { wireframe: { @@ -34,6 +52,13 @@ var Presets = View.extend({ initialize: function(opt){ this.parent = opt.parent + this.$colors = this.$(".colors") + this.colors.forEach(function(color){ + var $swatch = $("") + $swatch.css("background-color","rgb(" + color + ")") + $swatch.data('color', color) + this.$colors.append($swatch) + }.bind(this)) }, toggle: function(state){ @@ -56,4 +81,9 @@ var Presets = View.extend({ $(e.currentTarget).addClass('active') }, + selectColor: function(e){ + var preset = $(e.currentTarget).data('color') + console.log(preset) + }, + }) \ No newline at end of file diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index 038b0c4..731a92b 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -138,10 +138,12 @@ a{ display: none; z-index: 10; pointer-events: none; + background-size: cover; } .floatingSwatch.scissors { background-image: url(/assets/img/scissors.png) !important; background-repeat: no-repeat; + background-size: auto; border: 0; box-shadow: 0 0 transparent; } @@ -1484,6 +1486,23 @@ border-left: 1px solid black; padding-bottom: 6px; } +#presets .colors { + margin-bottom: 5px; +} +#presets .colors span { + display: inline-block; + font-size: 0; + width: 20px; + height: 20px; + border: 1px solid #ddd; + margin: 0px 2px 0 0; + cursor: pointer; + transition: transform 0.2s; +} +#presets .colors span:hover { + transform: translateX(3px) translateY(-3px); +} + .toolButton { border: 1px solid; display: inline-block; diff --git a/views/controls/editor/presets.ejs b/views/controls/editor/presets.ejs index a41c527..70e48e3 100644 --- a/views/controls/editor/presets.ejs +++ b/views/controls/editor/presets.ejs @@ -1,4 +1,8 @@
+

Preset Colors

+
+
+

Preset Styles

diff --git a/views/controls/editor/wallpaper.ejs b/views/controls/editor/wallpaper.ejs index ac025b5..5ca0390 100644 --- a/views/controls/editor/wallpaper.ejs +++ b/views/controls/editor/wallpaper.ejs @@ -14,7 +14,7 @@
- +
+
-- cgit v1.2.3-70-g09d2 From d9a6199f75d324c7b644beb1c732680a67ab8047 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 17 Oct 2014 13:37:23 -0400 Subject: layout editor stuff --- .../assets/javascripts/rectangles/models/floor.js | 34 ++++++++++++- public/assets/javascripts/ui/_router.js | 1 - .../assets/javascripts/ui/builder/BuilderInfo.js | 13 ++++- public/assets/javascripts/ui/editor/Presets.js | 11 ++--- public/assets/javascripts/ui/lib/UploadView.js | 4 +- public/assets/javascripts/util.js | 55 ++++++++++++++++++++++ public/assets/stylesheets/app.css | 22 ++++++--- views/controls/editor/media-drawer.ejs | 2 +- views/controls/editor/wallpaper.ejs | 17 ++----- 9 files changed, 125 insertions(+), 34 deletions(-) (limited to 'public/assets/javascripts/ui/editor/Presets.js') diff --git a/public/assets/javascripts/rectangles/models/floor.js b/public/assets/javascripts/rectangles/models/floor.js index a144ecd..3f452e1 100644 --- a/public/assets/javascripts/rectangles/models/floor.js +++ b/public/assets/javascripts/rectangles/models/floor.js @@ -36,8 +36,40 @@ this.mx.forEach(function(mx, index){ $(mx.el).bind({ + contextmenu: function(e){ + if (! (e.ctrlKey || e.metaKey || e.shiftKey) ) { + e.preventDefault() + } + if (Scenery.nextMedia) { + e.preventDefault() + Scenery.nextMedia = null + app.tube('cancel-scenery') + } + else if (Scenery.nextWallpaper) { + e.preventDefault() + Scenery.nextWallpaper = null + app.tube('cancel-wallpaper') + } + }, + mousedown: function(e){ - if (Scenery.nextWallpaper) { + + // right-click + if (e.which == 3) { + if (Scenery.nextMedia) { + e.preventDefault() + Scenery.nextMedia = null + app.tube('cancel-scenery') + } + else if (Scenery.nextWallpaper) { + e.preventDefault() + Scenery.nextWallpaper = null + app.tube('cancel-wallpaper') + } + return + } + + if (Scenery.nextWallpaper) { var oldState = base.serialize() base.wallpaper(Scenery.nextWallpaper) // Scenery.nextWallpaper = null diff --git a/public/assets/javascripts/ui/_router.js b/public/assets/javascripts/ui/_router.js index 794079e..bda0960 100644 --- a/public/assets/javascripts/ui/_router.js +++ b/public/assets/javascripts/ui/_router.js @@ -212,7 +212,6 @@ var SiteRouter = Router.extend({ // this.documentModal.destroy(name) }, - testWallpaper: function(e){ var content = document.getElementById("content") content.style.width = "680px" diff --git a/public/assets/javascripts/ui/builder/BuilderInfo.js b/public/assets/javascripts/ui/builder/BuilderInfo.js index 67834e7..c708275 100644 --- a/public/assets/javascripts/ui/builder/BuilderInfo.js +++ b/public/assets/javascripts/ui/builder/BuilderInfo.js @@ -10,8 +10,10 @@ var BuilderInfo = View.extend({ "change [name=width]": 'changeWidth', "change [name=depth]": 'changeDepth', "change [name=height]": 'changeHeight', + "keydown [name=width]": 'enterWidth', + "keydown [name=depth]": 'enterDepth', + "keydown [name=height]": 'enterHeight', "change [name=units]": 'changeUnits', - "change [name=resolution]": 'changeResolution', "change [name=viewHeight]": 'changeViewHeight', "click [data-role=destroy-room]": 'destroy', }, @@ -85,16 +87,25 @@ var BuilderInfo = View.extend({ this.hide() }, + enterWidth: function(e){ + if (e.keyCode == 13) this.changeWidth(e) + }, changeWidth: function(e){ e.stopPropagation() this.room.rect.x.setLength( this.$width.unitVal() ) Rooms.rebuild() }, + enterDepth: function(e){ + if (e.keyCode == 13) this.changeDepth(e) + }, changeDepth: function(e){ e.stopPropagation() this.room.rect.y.setLength( this.$depth.unitVal() ) Rooms.rebuild() }, + enterHeight: function(e){ + if (e.keyCode == 13) this.changeHeight(e) + }, changeHeight: function(e){ e.stopPropagation() this.room.height = this.$height.unitVal() diff --git a/public/assets/javascripts/ui/editor/Presets.js b/public/assets/javascripts/ui/editor/Presets.js index be86af3..ab311ef 100644 --- a/public/assets/javascripts/ui/editor/Presets.js +++ b/public/assets/javascripts/ui/editor/Presets.js @@ -84,15 +84,12 @@ var Presets = View.extend({ this.parent.colorControl.modes.forEach(function(mode){ if (! preset[mode].length) { Walls.setWallpaper[mode](preset[mode]) - Walls.setColor[mode](preset[mode].color) } else { - if (preset[mode].length) { - Walls.clearWallpaper[mode]() - } - Walls.setColor[mode](preset[mode]) - this.parent.colorControl.$swatch[ mode ].css("background-color", rgb_string(preset[mode])) - } + Walls.clearWallpaper[mode]() + } + Walls.setColor[mode](preset[mode]) + this.parent.colorControl.$swatch[ mode ].css("background-color", rgb_string(preset[mode])) }.bind(this)) this.parent.colorControl.setMode(preset.wall.color ? "wall" : "floor") Walls.setBodyColor() diff --git a/public/assets/javascripts/ui/lib/UploadView.js b/public/assets/javascripts/ui/lib/UploadView.js index efaa8c9..2d2c2c7 100644 --- a/public/assets/javascripts/ui/lib/UploadView.js +++ b/public/assets/javascripts/ui/lib/UploadView.js @@ -4,12 +4,12 @@ var UploadView = View.extend({ // define uploadAction events: { - "change .file": "handleFileSelect", + "change [type=file]": "handleFileSelect", "submit form": "preventDefault", }, initialize: function(){ - this.$file = this.$(".file") + this.$file = this.$("[type=file]") this.$upload = this.$(".upload-icon") }, diff --git a/public/assets/javascripts/util.js b/public/assets/javascripts/util.js index 367e20e..2fa994a 100644 --- a/public/assets/javascripts/util.js +++ b/public/assets/javascripts/util.js @@ -185,3 +185,58 @@ function bitcount(v) { v = (v & 0x33333333) + ((v >>> 2) & 0x33333333); return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24; } + +// Function.bind polyfill +if (!Function.prototype.bind) { + Function.prototype.bind = function(oThis) { + if (typeof this !== 'function') { + // closest thing possible to the ECMAScript 5 + // internal IsCallable function + throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable'); + } + + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, + fNOP = function() {}, + fBound = function() { + return fToBind.apply(this instanceof fNOP && oThis + ? this + : oThis, + aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + + return fBound; + }; +} + +// rAF polyfill +(function() { + var lastTime = 0; + var vendors = ['ms', 'moz', 'webkit', 'o']; + for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { + window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; + window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] + || window[vendors[x]+'CancelRequestAnimationFrame']; + } + + if (!window.requestAnimationFrame) + window.requestAnimationFrame = function(callback, element) { + var currTime = new Date().getTime(); + var timeToCall = Math.max(0, 16 - (currTime - lastTime)); + var id = window.setTimeout(function() { callback(currTime + timeToCall); }, + timeToCall); + lastTime = currTime + timeToCall; + return id; + }; + + if (!window.cancelAnimationFrame) + window.cancelAnimationFrame = function(id) { + clearTimeout(id); + }; +}()); + + + diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index 28eabd9..9df1573 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -1507,9 +1507,12 @@ border-left: 1px solid black; .toolButton { border: 1px solid; - display: inline-block; - width: 100%; - margin-top: 5px; + position: relative; + display: block; + float: right; + margin-left: 3px; + width: 35px; + height: 35px; font-size: 14px; font-weight: 300; } @@ -1524,9 +1527,9 @@ border-left: 1px solid black; } .wallpaper form { position: relative; - padding: 2px 0 0 0; font-size: 14px; font-weight: 300; + overflow: hidden; } .toolButton:hover { background:black; @@ -1550,14 +1553,19 @@ border-left: 1px solid black; .wallpaper .wallpaperRemove:hover img { -webkit-filter:invert(100%); } +.wallpaperUpload .upload-icon { + margin: 0 8px; +} .wallpaperUpload .upload-icon.uploading { } .wallpaperUpload .upload-icon.uploading:before { content: ' ' !important; background-image: url("/assets/img/loader.gif"); background-repeat: no-repeat; - width: 40px; - height: 40px; + background-position: center; + width: 100%; + height: 100%; + position:absolute;top:0;left:0; } .wallpaperUpload input[type="text"]{ border: 1px solid #ccc; @@ -1575,7 +1583,7 @@ border-left: 1px solid black; top: 0; left: 0; background: blue; - height: 28px; + height: 100%; width: 100%; opacity: 0; cursor: pointer; diff --git a/views/controls/editor/media-drawer.ejs b/views/controls/editor/media-drawer.ejs index d1e2c99..1404d86 100644 --- a/views/controls/editor/media-drawer.ejs +++ b/views/controls/editor/media-drawer.ejs @@ -26,7 +26,7 @@

Upload File - +
~ or ~
diff --git a/views/controls/editor/wallpaper.ejs b/views/controls/editor/wallpaper.ejs index ed175ae..69a60ec 100644 --- a/views/controls/editor/wallpaper.ejs +++ b/views/controls/editor/wallpaper.ejs @@ -9,31 +9,20 @@ + +
- - +
-
-
- - -
-- cgit v1.2.3-70-g09d2 From e2de422ece0c98c2dbea41e7156455dcf91b9db4 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 20 Oct 2014 15:11:30 -0400 Subject: fix preset bug --- public/assets/javascripts/ui/editor/Presets.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'public/assets/javascripts/ui/editor/Presets.js') diff --git a/public/assets/javascripts/ui/editor/Presets.js b/public/assets/javascripts/ui/editor/Presets.js index ab311ef..d233144 100644 --- a/public/assets/javascripts/ui/editor/Presets.js +++ b/public/assets/javascripts/ui/editor/Presets.js @@ -82,14 +82,17 @@ var Presets = View.extend({ lastPreset: {wall:[1],outline:[1],floor:[1],ceiling:[1]}, 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]() - } - Walls.setColor[mode](preset[mode]) - this.parent.colorControl.$swatch[ mode ].css("background-color", rgb_string(preset[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() -- cgit v1.2.3-70-g09d2 From 7a64a9fef46ddd1180dfa00fddd363b7814e381d Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 27 Oct 2014 11:47:06 -0400 Subject: hide preset underline if u modify something --- public/assets/javascripts/ui/editor/ColorControl.js | 1 + public/assets/javascripts/ui/editor/Presets.js | 9 ++++++--- public/assets/javascripts/ui/editor/WallpaperPicker.js | 3 +-- 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'public/assets/javascripts/ui/editor/Presets.js') diff --git a/public/assets/javascripts/ui/editor/ColorControl.js b/public/assets/javascripts/ui/editor/ColorControl.js index 459ac1e..72e9fb1 100644 --- a/public/assets/javascripts/ui/editor/ColorControl.js +++ b/public/assets/javascripts/ui/editor/ColorControl.js @@ -92,6 +92,7 @@ var ColorControl = View.extend({ this.setSwatchColor(this.mode, rgb) // console.log(rgb) Walls.setColor[ this.mode ](rgb) + this.parent.presets.modified = true }, setSwatchColor: function(mode, rgb) { diff --git a/public/assets/javascripts/ui/editor/Presets.js b/public/assets/javascripts/ui/editor/Presets.js index d233144..ac77d6b 100644 --- a/public/assets/javascripts/ui/editor/Presets.js +++ b/public/assets/javascripts/ui/editor/Presets.js @@ -34,7 +34,7 @@ var Presets = View.extend({ ceiling: [0,0,0], }, matrix: { - wall: { src: "http://dump.fm/images/20130225/1361818675427-dumpfm-melipone-matrixremixtransfast.gif", scale: 4.0, color: [0,0,0] }, + 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], @@ -53,9 +53,13 @@ var Presets = View.extend({ }.bind(this)) }, + modified: false, toggle: function(state){ this.$el.toggleClass("active", state) this.parent.cursor.message(state ? "presets" : "start") + if (this.modified) { + this.$(".active").removeClass('active') + } }, show: function(){ @@ -72,6 +76,7 @@ var Presets = View.extend({ this.$(".active").removeClass('active') $(e.currentTarget).addClass('active') this.load(this.presets[preset]) + this.modified = false }, selectColor: function(e){ @@ -79,7 +84,6 @@ var Presets = View.extend({ console.log(preset) }, - lastPreset: {wall:[1],outline:[1],floor:[1],ceiling:[1]}, load: function(preset){ this.parent.colorControl.modes.forEach(function(mode){ var color @@ -96,7 +100,6 @@ var Presets = View.extend({ }.bind(this)) this.parent.colorControl.setMode(preset.wall.color ? "wall" : "floor") Walls.setBodyColor() - this.lastPreset = preset }, }) \ No newline at end of file diff --git a/public/assets/javascripts/ui/editor/WallpaperPicker.js b/public/assets/javascripts/ui/editor/WallpaperPicker.js index 2d60f11..d7d666c 100644 --- a/public/assets/javascripts/ui/editor/WallpaperPicker.js +++ b/public/assets/javascripts/ui/editor/WallpaperPicker.js @@ -21,7 +21,6 @@ var WallpaperPicker = UploadView.extend({ this.__super__.initialize.call(this) this.$swatches = this.$(".swatches") this.$remove = this.$(".wallpaperRemove") - this.$remove.hide() this.$url = this.$(".url") @@ -108,7 +107,7 @@ var WallpaperPicker = UploadView.extend({ app.tube('cancel-wallpaper') var $swatch = $(e.currentTarget) this.follow( e, $swatch.css('background-image') ) - this.$remove.show() + this.parent.presets.modified = true }, remove: function(e){ -- cgit v1.2.3-70-g09d2 From 0df2cd6c000e593795c1de868a47666862d3ed96 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 3 Nov 2014 14:54:12 -0500 Subject: undo presets --- .../javascripts/rectangles/engine/rooms/_walls.js | 15 +++++++---- .../javascripts/rectangles/engine/scenery/undo.js | 28 +++++++++++++++++++-- public/assets/javascripts/ui/editor/Presets.js | 29 +++++++++++++++++----- 3 files changed, 59 insertions(+), 13 deletions(-) (limited to 'public/assets/javascripts/ui/editor/Presets.js') diff --git a/public/assets/javascripts/rectangles/engine/rooms/_walls.js b/public/assets/javascripts/rectangles/engine/rooms/_walls.js index 25b1c58..04d0594 100644 --- a/public/assets/javascripts/rectangles/engine/rooms/_walls.js +++ b/public/assets/javascripts/rectangles/engine/rooms/_walls.js @@ -40,12 +40,17 @@ base.colors = {} base.init = function(){ - base.colors = { - wall: app.defaults.colors.wall.slice(), - outline: app.defaults.colors.outline.slice(), - floor: app.defaults.colors.floor.slice(), - ceiling: app.defaults.colors.ceiling.slice(), + base.colors = base.copyColors( app.defaults.colors ) + } + + base.copyColors = function(colors){ + var copy = { + wall: colors.wall.slice(), + outline: colors.outline.slice(), + floor: colors.floor.slice(), + ceiling: colors.ceiling.slice(), } + return copy } base.first = function(){ diff --git a/public/assets/javascripts/rectangles/engine/scenery/undo.js b/public/assets/javascripts/rectangles/engine/scenery/undo.js index ff4f911..52a57d9 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/undo.js +++ b/public/assets/javascripts/rectangles/engine/scenery/undo.js @@ -114,7 +114,32 @@ undo: function(state){ var wall = Walls.lookup[state.id] wall.deserialize(state) - + Minotaur.watch( app.router.editorView.settings ) + }, + }, + { + type: "update-all-wallpaper", + undo: function(state){ + Walls.deserialize(state) + Minotaur.watch( app.router.editorView.settings ) + }, + }, + { + type: "choose-preset", + undo: function(state){ + app.controller.colorControl.load(state.colors) + Walls.deserialize(state.walls) + Minotaur.watch( app.router.editorView.settings ) + }, + redo: function(state){ + app.controller.presets.loadByName(state) + Minotaur.watch( app.router.editorView.settings ) + }, + }, + { + type: "choose-another-preset", + undo: function(state){ + app.controller.presets.loadByName(state) Minotaur.watch( app.router.editorView.settings ) }, }, @@ -123,7 +148,6 @@ undo: function(state){ Walls.setColor[ state.mode ]( state.rgb ) app.router.editorView.colorControl.setSwatchColor( state.mode, state.rgb ) - Minotaur.watch( app.router.editorView.settings ) }, }, diff --git a/public/assets/javascripts/ui/editor/Presets.js b/public/assets/javascripts/ui/editor/Presets.js index ac77d6b..1327e03 100644 --- a/public/assets/javascripts/ui/editor/Presets.js +++ b/public/assets/javascripts/ui/editor/Presets.js @@ -4,7 +4,6 @@ var Presets = View.extend({ events: { "mousedown": "stopPropagation", "click .presets span": "selectPreset", - "click .swatches span": "selectColor", }, presets: { @@ -53,7 +52,9 @@ var Presets = View.extend({ }.bind(this)) }, - modified: false, + modified: true, + lastPreset: "wireframe", + toggle: function(state){ this.$el.toggleClass("active", state) this.parent.cursor.message(state ? "presets" : "start") @@ -75,15 +76,31 @@ var Presets = View.extend({ 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 }, - selectColor: function(e){ - var preset = $(e.currentTarget).data('color') - console.log(preset) + loadByName: function(name){ + var preset = this.presets[name] + this.load(preset) }, - load: function(preset){ this.parent.colorControl.modes.forEach(function(mode){ var color -- cgit v1.2.3-70-g09d2 From 79a8caa17b05152533641cfd937925822f569fc1 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 3 Nov 2014 15:11:27 -0500 Subject: after you delete a room, user is redirected to profile --- public/assets/javascripts/mx/extensions/mx.movements.js | 6 ++---- public/assets/javascripts/rectangles/engine/scenery/undo.js | 2 +- public/assets/javascripts/ui/editor/EditorSettings.js | 2 +- public/assets/javascripts/ui/editor/Presets.js | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) (limited to 'public/assets/javascripts/ui/editor/Presets.js') diff --git a/public/assets/javascripts/mx/extensions/mx.movements.js b/public/assets/javascripts/mx/extensions/mx.movements.js index 2993fb6..dc9660b 100644 --- a/public/assets/javascripts/mx/extensions/mx.movements.js +++ b/public/assets/javascripts/mx/extensions/mx.movements.js @@ -326,15 +326,13 @@ MX.Movements = function (cam) { pos.y = viewHeight vy = 0 jumping = false - vz = vz || 1 } var ceiling = (Rooms.mover.room ? Rooms.mover.room.height : 5000) - if (pos.y >= ceiling) { + if (pos.y >= ceiling-5) { vy = 0 - pos.y = ceiling - vz = vz || 1 + pos.y = ceiling-5 } } diff --git a/public/assets/javascripts/rectangles/engine/scenery/undo.js b/public/assets/javascripts/rectangles/engine/scenery/undo.js index 52a57d9..3deb764 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/undo.js +++ b/public/assets/javascripts/rectangles/engine/scenery/undo.js @@ -20,7 +20,7 @@ type: "update-scenery", undo: function(state){ var scenery = Scenery.find(state.id) - + scenery.deserialize(state) scenery.set_wall(Walls.find( state.wall_id )) diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js index 430acc7..b96943e 100644 --- a/public/assets/javascripts/ui/editor/EditorSettings.js +++ b/public/assets/javascripts/ui/editor/EditorSettings.js @@ -114,7 +114,7 @@ var EditorSettings = FormView.extend({ type: "delete", data: { _id: this.$id.val(), _csrf: this.$csrf.val() }, success: function(data){ - window.location.href = "/project" + window.location.href = "/profile" } }) }.bind(this)) diff --git a/public/assets/javascripts/ui/editor/Presets.js b/public/assets/javascripts/ui/editor/Presets.js index 1327e03..5f5ac35 100644 --- a/public/assets/javascripts/ui/editor/Presets.js +++ b/public/assets/javascripts/ui/editor/Presets.js @@ -20,7 +20,7 @@ var Presets = View.extend({ ceiling: [159,163,157], background: [109,116,106], }, - "p.Funk": { + "P.Funk": { wall: [255,63,78], outline: [255,246,0], floor: [255,255,0], -- cgit v1.2.3-70-g09d2