summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-11-03 15:59:08 -0500
committerJules Laplace <jules@okfoc.us>2014-11-03 15:59:08 -0500
commit64748a6d55f1e4d08270367767b631b724833b19 (patch)
treedc54c30208fca09451c3cf5165bf715e3545beeb
parent21ca0470b4b7731e0ab527a52d53aa308cad41d1 (diff)
parent16e4733522018477062abd8d60837c2bd69a93cb (diff)
merge
-rw-r--r--public/assets/javascripts/app.js4
-rw-r--r--public/assets/javascripts/mx/extensions/mx.movements.js6
-rw-r--r--public/assets/javascripts/rectangles/engine/rooms/_walls.js15
-rw-r--r--public/assets/javascripts/rectangles/engine/rooms/mover.js5
-rw-r--r--public/assets/javascripts/rectangles/engine/scenery/undo.js30
-rw-r--r--public/assets/javascripts/ui/builder/BuilderInfo.js6
-rw-r--r--public/assets/javascripts/ui/editor/EditorSettings.js2
-rw-r--r--public/assets/javascripts/ui/editor/EditorToolbar.js26
-rw-r--r--public/assets/javascripts/ui/editor/HelpCursor.js3
-rw-r--r--public/assets/javascripts/ui/editor/MediaUpload.js5
-rw-r--r--public/assets/javascripts/ui/editor/Presets.js31
-rw-r--r--public/assets/javascripts/ui/lib/UploadView.js6
-rw-r--r--server/lib/api/media.js2
-rw-r--r--server/lib/upload.js2
14 files changed, 92 insertions, 51 deletions
diff --git a/public/assets/javascripts/app.js b/public/assets/javascripts/app.js
index fddbd5a..f3da470 100644
--- a/public/assets/javascripts/app.js
+++ b/public/assets/javascripts/app.js
@@ -15,7 +15,9 @@ else {
$("html").addClass("desktop");
}
-new WOW().init();
+$(function(){
+ new WOW().init()
+})
var scene, cam, map;
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/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/rooms/mover.js b/public/assets/javascripts/rectangles/engine/rooms/mover.js
index 5682be8..ac27aba 100644
--- a/public/assets/javascripts/rectangles/engine/rooms/mover.js
+++ b/public/assets/javascripts/rectangles/engine/rooms/mover.js
@@ -117,7 +117,6 @@ Rooms.mover = new function(){
wall.get_points(wall_vec)
-
t = perp(origins, wall_vec) / ( perp(cursor_copy, wall_vec) || 0.0000001 )
if ( min_t < t || t < 0 || 1 < t ) return
@@ -240,13 +239,13 @@ Rooms.mover = new function(){
wall_vec.normalize = function(){
var carry
if (this.x.a > this.y.a) {
- console.log("SWAP X")
+// console.log("SWAP X")
carry = this.x.a
this.x.a = this.y.a
this.y.a = carry
}
if (this.x.b > this.y.b) {
- console.log("SWAP Y")
+// console.log("SWAP Y")
carry = this.x.b
this.x.b = this.y.b
this.y.b = carry
diff --git a/public/assets/javascripts/rectangles/engine/scenery/undo.js b/public/assets/javascripts/rectangles/engine/scenery/undo.js
index ff4f911..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 ))
@@ -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/builder/BuilderInfo.js b/public/assets/javascripts/ui/builder/BuilderInfo.js
index 4fd145d..e1c90c8 100644
--- a/public/assets/javascripts/ui/builder/BuilderInfo.js
+++ b/public/assets/javascripts/ui/builder/BuilderInfo.js
@@ -46,6 +46,12 @@ var BuilderInfo = View.extend({
this.$settings.toggle( !! this.room )
this.$noSelection.toggle( ! this.room )
this.$el.toggleClass("active", state)
+ if (state) {
+ this.parent.cursor.message("builder")
+ }
+ else {
+ this.parent.cursor.message("start")
+ }
},
show: function(){
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/EditorToolbar.js b/public/assets/javascripts/ui/editor/EditorToolbar.js
index 3c75b95..277718a 100644
--- a/public/assets/javascripts/ui/editor/EditorToolbar.js
+++ b/public/assets/javascripts/ui/editor/EditorToolbar.js
@@ -55,16 +55,14 @@ var EditorToolbar = View.extend({
},
openMediaViewer: function(){
- this.parent.mediaViewer.show()
- this.parent.mediaUpload.show()
this.resetMode()
this.resetControls()
this.toggleMap(false)
+ this.parent.mediaViewer.show()
+ this.parent.mediaUpload.show()
},
resetMode: function(){
- // this.resizeMedia(true)
- // this.destroyMedia(false)
$(".inuse").removeClass("inuse")
$("body").removeClass("addText")
this.parent.hideExtras()
@@ -88,26 +86,6 @@ var EditorToolbar = View.extend({
editor.permissions.remove("destroy")
},
- destroyMedia: function(e, state){
- this.resetControls()
- if (! state && typeof e == "boolean") {
- state = e
- editor.permissions.assign("destroy", state)
- }
- else {
- state = editor.permissions.toggle("destroy")
- }
- if (! state) {
- this.resetPermissions()
- }
- else {
- app.controller.hideExtras()
- }
- $(".inuse").removeClass("inuse")
- $("[data-role='destroy-media']").toggleClass("inuse", state)
- $("body").toggleClass("destroyActive", state)
- },
-
toggleWallpaper: function(){
var state = ! $("[data-role='toggle-wallpaper-panel']").hasClass("inuse")
this.resetMode()
diff --git a/public/assets/javascripts/ui/editor/HelpCursor.js b/public/assets/javascripts/ui/editor/HelpCursor.js
index 8ada237..4c8ff0c 100644
--- a/public/assets/javascripts/ui/editor/HelpCursor.js
+++ b/public/assets/javascripts/ui/editor/HelpCursor.js
@@ -13,12 +13,14 @@ var HelpCursor = View.extend({
wallpaper: "Click the wallpaper you want then apply it to the walls. Feel free to upload your own too!",
colors: "Use these colors to change the color of the walls, floor, and ceiling.",
settings: "This is where you publish your project. Give it a name, hit save, and you'll have a URL you can share with your friends.",
+ builder: "This is a map of your rooms. Draw new boxes, or move and resize the ones that are there. Hit ESCAPE to toggle the map.",
},
initialize: function(){
this.helpButton = $('#help-button')
this.helpButton.click(this.toggle.bind(this))
+ this.$el.html(this.messages['start'])
},
toggle: function(){
@@ -28,7 +30,6 @@ var HelpCursor = View.extend({
start: function(){
if (this.active) return
this.active = true
- this.message('start')
this.helpButton.addClass('active')
this.$el.show()
this.move({ pageX: -1000, pageY: -10000 })
diff --git a/public/assets/javascripts/ui/editor/MediaUpload.js b/public/assets/javascripts/ui/editor/MediaUpload.js
index b3f4ac3..65778dd 100644
--- a/public/assets/javascripts/ui/editor/MediaUpload.js
+++ b/public/assets/javascripts/ui/editor/MediaUpload.js
@@ -62,6 +62,11 @@ var MediaUpload = UploadView.extend({
this.parent.mediaViewer.addUploadedMedia(media)
},
+ error: function(error){
+ console.log(error)
+ alert(error.errors.media.message)
+ },
+
beforeUpload: function(){
this.parent.mediaViewer.deleteArmed(false)
}
diff --git a/public/assets/javascripts/ui/editor/Presets.js b/public/assets/javascripts/ui/editor/Presets.js
index ac77d6b..5f5ac35 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: {
@@ -21,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],
@@ -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
diff --git a/public/assets/javascripts/ui/lib/UploadView.js b/public/assets/javascripts/ui/lib/UploadView.js
index 2d2c2c7..4b56828 100644
--- a/public/assets/javascripts/ui/lib/UploadView.js
+++ b/public/assets/javascripts/ui/lib/UploadView.js
@@ -77,6 +77,9 @@ var UploadView = View.extend({
success: function(media){
if (media.error) {
+ // console.log(media.error)
+ this.$upload.removeClass('uploading')
+ this.error(media.error)
return
}
this.$upload.removeClass('uploading')
@@ -86,5 +89,8 @@ var UploadView = View.extend({
add: function(media){
console.log(media)
},
+
+ error: function(error){
+ },
})
diff --git a/server/lib/api/media.js b/server/lib/api/media.js
index 4e2fad5..85cbdd6 100644
--- a/server/lib/api/media.js
+++ b/server/lib/api/media.js
@@ -49,7 +49,7 @@ var media = {
upload.put("media", req.files.image, {
username: req.user.username,
unacceptable: function(err){
- res.json({ error: { errors: { avatar: { message: "Problem saving image: " + err } } } })
+ res.json({ error: { errors: { media: { message: "Problem saving image: " + err } } } })
},
success: function(url){
data.url = url
diff --git a/server/lib/upload.js b/server/lib/upload.js
index e206f7c..f6e22da 100644
--- a/server/lib/upload.js
+++ b/server/lib/upload.js
@@ -41,7 +41,7 @@ module.exports.put = function (key, file, opt) {
err = "file too small"
}
else if (file.size > 2097152) { // 2mb limit
- err = "file too large"
+ err = "file too large. Uploads can be a maximum of 2 mb."
}
if (err) {